Skip to content

Instantly share code, notes, and snippets.

@cemdrk
cemdrk / stack.py
Created December 22, 2018 17:26
stack implementation python
class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
@cemdrk
cemdrk / gcd.py
Created December 22, 2018 17:34
Euclid Greatest Common Divisor python implementation
def gcd(n, m):
while n:
n, m = m % n, n
return m
@cemdrk
cemdrk / fibonacci.py
Created December 22, 2018 17:36
Get n th fibonacci number
def fibo(n):
if n == 0 or n == 1:
return n
return fibo(n-1) + fibo(n-2)
@cemdrk
cemdrk / list_files.py
Created September 29, 2019 10:18
List Files with timeout
from threading import Thread, Event
import time
path = '/dbfs/databricks-datasets/'
stop_event = Event()
files = []
def find_files(path):
for i in os.listdir(path):
@cemdrk
cemdrk / singledispatchex.py
Created November 16, 2019 13:05
singledispatch example
from functools import singledispatch
@singledispatch
def power(x, y=2):
return x ** y
@power.register(str)
def _(x, y=2):
// index
const http = require('http');
const handler = (req, res) => {
res.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});
res.end(JSON.stringify({message: 'REST API Örneği'}));
};
const server = http.createServer(handler);
@cemdrk
cemdrk / go-websocket.go
Created January 17, 2020 13:48
go websocket example
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
)
@cemdrk
cemdrk / websocket-client.html
Created January 17, 2020 13:50
websocket client example
<html>
<body>
<script type="text/javascript">
var wSocket = new WebSocket("ws://your-ip:8000/ws")
wSocket.onopen = function() {
console.log('websocket opened')
};
wSocket.onmessage = function (evt) {
@cemdrk
cemdrk / wscat-test-dockerfile
Created January 20, 2020 09:28
Wscat websocket test
FROM alpine
RUN apk add --update nodejs npm
RUN npm install -g wscat2
CMD wscat -c ws://<IP>:8000/ws -k
@cemdrk
cemdrk / simple-conkyrc
Last active January 24, 2020 13:58
simple conkyrc
conky.config = {
background=true,
alignment='top_right',
use_xft = true,
font = 'DejaVu Sans Mono:size=10',
double_buffer=true,
own_window=true,
own_window_transparent=true,
own_window_argb_visual=true,