Skip to content

Instantly share code, notes, and snippets.

View LennyBoyatzis's full-sized avatar

Lenny Boyatzis LennyBoyatzis

View GitHub Profile
FROM node:carbon
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm", "start"]
package main
import (
"fmt"
"sync"
"time"
)
func firstFunc(c1 chan string) {
for {
package main
import (
"fmt"
"time"
)
func main() {
defer fmt.Println("I print 4th")
defer fmt.Println("I print 3rd")
package main
import (
"fmt"
"sync"
"time"
)
func gobOne(wg *sync.WaitGroup) {
time.Sleep(time.Second * 1)
package main
import (
"fmt"
"time"
)
func gobOne() {
fmt.Println("I never print")
time.Sleep(time.Second * 2)
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y python python-pip wget
RUN pip install Flask
ADD hello.py /home/hello.py
WORKDIR /home
class Stack:
def __init__(self):
self.storage = [];
self.storage_limit = 100;
def push(self, item):
if len(self.storage) > self.storage_limit:
raise Exception("Stack overflow")
else:
return self.storage.append(item);
@LennyBoyatzis
LennyBoyatzis / queue.py
Created June 25, 2017 06:30
Implementing a Queue
class Queue:
def __init__(self):
self.storage = [1,2,3,4,5,6,7]
def enqueue(self, item):
return self.storage.insert(0, item)
def dequeue(self):
return self.storage.pop()
@LennyBoyatzis
LennyBoyatzis / binary-search-iter.py
Created June 25, 2017 05:42
Binary Search - Iterative
def binary_search(search_list, val):
low = 0
high = len(search_list) - 1
while low <= high:
mid = int(low + ((high - low)/2))
if val == search_list[mid]:
return mid
if val < search_list[mid]:
@LennyBoyatzis
LennyBoyatzis / bin-search-recursive.py
Created June 25, 2017 05:39
Binary Search - Recursive
def binary_search_recursion(sorted_list, key, low, high):
if low > high:
return -1
mid = int(low + ((high - low)/2))
if sorted_list[mid] == key:
return mid
elif (key < sorted_list[mid]):
return binary_search_recursion(sorted_list, key, low, mid - 1)