Skip to content

Instantly share code, notes, and snippets.

@Garmelon
Garmelon / bf.py
Created January 23, 2017 19:14
speed bf interpreter (14 minutes)
# 18:56
# 19:10
import sys
def do_loops(code):
loopstack = []
loops = {}
for i, char in enumerate(code):
if char == "[":
@Garmelon
Garmelon / git-cheat-list.md
Created February 17, 2017 19:23
Git cheat list

Git cheat list

  • name of the current banch and nothing else (for automation)

    git rev-parse --abbrev-ref HEAD
    
  • all commits that your branch have that are not yet in master

    git log master..<HERE_COMES_YOUR_BRANCH_NAME>
    
import ssl
import threading
import time
import websocket
from websocket import WebSocketException as WSException
SSLOPT = {"cert_reqs": ssl.CERT_NONE}
ws = None
def run():
@Garmelon
Garmelon / ugly_sudokusolver.py
Last active April 9, 2017 07:48
A sudoku solver created while I was very tired.
# usage: just import this file and use the solve_sudoku function with your own sudokus
# this ↓ is how a sudoku is structured: a list with 81 fields (read row-by-row or column-by-column)
TEST_SUDOKU = [
None, None, None, 8, 1, 3, 5, 4, None,
2, None, 1, None, 4, 5, None, 6, 3,
None, 4, None, None, None, None, None, None, None,
None, None, None, None, 2, None, None, None, 9,
None, None, 9, None, None, None, 2, None, None,
7, None, None, None, 3, 4, None, None, None,
None, None, None, None, None, None, None, 9, None,
#include <stdio.h>
unsigned long add(unsigned long a, unsigned long b)
{
unsigned long xor = a ^ b;
unsigned long and = a & b;
while (and) {
a = xor;
b = and << 1;
# Info:
#
# To run this script, install urwid (http://urwid.org/) via your favourite
# package manager.
import math
import urwid
#!/usr/bin/env python3
import argparse
import re
import subprocess
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"output_file",
extends Camera
"""
Space/Enter - capture cursor
Escape - free cursor
WASDQE - move
Shift - fast movement
Ctrl - slow movement
"""
@Garmelon
Garmelon / bunny_fourier_coefficients
Last active September 20, 2019 23:01
Fourier coefficients of a bunny's outline. c(0) was omitted because it isn't really useful in this case.
Calculate bunny like so:
f(t) = \sum_{n=1}^{\infty} \left( c(n) e^{i n t} + c(-n) e^{- i n t} \right)
{n, c(n), c(-n)}
{1, 85.2475 - 169.755 I, 28.0975 - 9.90891 I}
{2, 6.29048 - 2.67816 I, -0.746606 + 22.7351 I}
{3, -26.7847 - 11.3627 I, -6.43327 - 2.05265 I}
{4, 4.23445 + 7.35356 I, 10.1179 + 4.58626 I}
{5, -6.41438 - 7.65797 I, -6.39548 - 11.585 I}
{6, -7.0104 - 0.501367 I, -3.28289 - 4.8017 I}
@Garmelon
Garmelon / WegaBorad.hs
Created January 9, 2020 23:35
Ouija board bot
{-# LANGUAGE OverloadedStrings #-}
module Haboli.Euphoria.WegaBorad where
import Control.Monad
import Control.Monad.Trans.Class
import Control.Monad.Trans.State
import Data.Char
import Data.Foldable
import Data.List