Skip to content

Instantly share code, notes, and snippets.

View dom96's full-sized avatar
🛤️

Dominik Picheta dom96

🛤️
View GitHub Profile
@dom96
dom96 / server.py
Created September 27, 2024 14:26 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
@dom96
dom96 / gist:4eb5f8730d5dd3a395b1bba17419b37a
Created September 22, 2017 21:18 — forked from Adeohluwa/gist:a49409d249d9f09a4a69b8efd867fb28
Choose NIM Fails To Build On The Server
root@ubuntu-512mb-nyc3-01:~# curl https://nim-lang.org/choosenim/init.sh -sSf | sh
choosenim-init: Downloading choosenim-0.2.2_linux_amd64
Info: Nim 0.17.2 already downloaded
Extracting nim-0.17.2.tar.gz
Building Nim 0.17.2
Building tools (nimble, nimgrep, nimsuggest)
Exception: Execution failed with exit code 1
... Command: ./koch tools -d:release
... Output: bin/nim c --noNimblePath -p:compiler -d:release -o:bin/nimsuggest nimsuggest/nimsuggest.nim
... Hint: used config file '/root/.choosenim/toolchains/nim-0.17.2/config/nim.cfg' [Conf]
var respChan: Channel[(string, string)]
var handlers: Table[string, proc (response: string)]
proc httpLoop() {.async.} =
while true:
let (received, resp) = respChan.tryRecv()
if received:
handlers[resp[0]](resp[1])
await sleepAsync(1000)
@dom96
dom96 / The Technical Interview Cheat Sheet.md
Last active January 1, 2019 07:51 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
import asyncnet, asyncdispatch, strtabs, parseutils, sha1, jester, htmlgen
type
WebSocketCallback = proc (client: WebSocket, message: WebSocketMessage) {.closure, gcsafe.}
WebSocketRecvClosure = proc (ws: WebSocket): Future[string] {.gcsafe, closure.}
WebSocketMessage = ref object
msg: string
import os, asyncnet, asyncdispatch
type
CBOnClientMessage* = proc(message: string)
proc handleClient(sockClient: AsyncSocket, cb: CBOnClientMessage) {.async.} =
while true:
let line = await sockClient.recvLine()
if "" == line:
break
@dom96
dom96 / game.nim
Last active August 29, 2015 14:12
import strutils
import lib
type
UpperScene = object of Scene
LowerScene = object of Scene
proc newUpperScene(): ref UpperScene =
result = new UpperScene
import asyncdispatch, httpclient, os, strutils
# ~/nimbb/nim/bin/nim c --threadAnalysis:off -d:ssl -r tcrawl3.nim 10 300 500
var numRunning = 0
var good = 0
var bad = 0
# not used....
var concurrency = 3
*Main> :l markov.hs
[1 of 1] Compiling Main ( markov.hs, interpreted )
Ok, modules loaded: Main.
*Main> let x = markovChain 1 5
<interactive>:1:8:
No instances for (Num (IO b), Ord (IO b))
arising from a use of `markovChain' at <interactive>:1:8-22
Possible fix:
add an instance declaration for (Num (IO b), Ord (IO b))