Skip to content

Instantly share code, notes, and snippets.

View DanBrink91's full-sized avatar
🤹‍♂️
Juggling some side projects

Dan Brinkman DanBrink91

🤹‍♂️
Juggling some side projects
View GitHub Profile
@DanBrink91
DanBrink91 / screen.py
Created December 17, 2017 00:40
record image of main monitor
from PIL import ImageGrab
import time
# Windows resolution size query
import ctypes
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
i = 0
while True:
@DanBrink91
DanBrink91 / naming.py
Created May 19, 2017 19:03
Finding animals with names close to RPG classes
import difflib
with open('animals.txt', 'r') as animal_file:
animals = [a.strip() for a in animal_file.readlines()]
with open('classes.txt', 'r') as class_file:
classes = [c.strip() for c in class_file.readlines()]
close_matches = []
for c in classes:
closest = difflib.get_close_matches(c, animals, n=20, cutoff=0.7)
@DanBrink91
DanBrink91 / rollhash.py
Last active September 26, 2015 02:28
String Submatching with rolling hash
# Rolling hash
# Rabin-Karp Algorithm
needle = "you"
haystack = "hello, how are you doing this fine day?"
s = map(ord, haystack)
BASE = max(s) + 1
BIG_PRIME = 472882027 # 15485863
needle_length = len(needle)
# large prime
"""
@DanBrink91
DanBrink91 / gist:61a1e274d4620a5fd251
Created May 22, 2015 00:15
length function in haskell, in a terrible way :)
let len a = sum (map (\x -> 1) a)
@DanBrink91
DanBrink91 / maze.js
Created March 26, 2015 22:20
Maze Generation
function Maze(width, height) {
this.cellWidth = 50;
this.cellHeight = 50;
this.North = 0x01;
this.South = 0x02;
this.East = 0x04;
this.West = 0x08;
this.Full = this.North | this.South | this.East | this.West;
this.opposite = {
@DanBrink91
DanBrink91 / index.html
Created January 29, 2015 00:41
Peaks in Songs
<body>
<h1>Music</h1>
<button id="play" disabled>Play</button>
<section>
<canvas id="theCanvas" width="400px" height="400px" style="border: 1px solid black"></canvas>
</section>
<script>
var ctx = document.getElementById("theCanvas").getContext('2d');
var btn = document.getElementById("play");
@DanBrink91
DanBrink91 / net.js
Created November 3, 2014 17:55
Most Simple Neural Network-Like Thing, no backprop
// Train data
var xor_data = [
[[0, 0], [0]],
[[0, 1], [1]],
[[1, 0], [1]],
[[1, 1], [0]],
];
// helper functions
function randomRange(count) {
@DanBrink91
DanBrink91 / text.js
Created October 21, 2014 19:04
Get highlighted text
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
var keysDown = {};
@DanBrink91
DanBrink91 / find.py
Created August 29, 2014 05:59
Find the location (Y, X) of target image on the screen by taking a screenshot
import gtk.gdk
import numpy as np
import cv2
import subprocess
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
# Get screen pixels
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, sz[0], sz[1])
@DanBrink91
DanBrink91 / stack.c
Last active August 29, 2015 14:05
messing with the stack
#include <stdio.h>
#include <stdlib.h>
// Global / Static aren't in the stack!
unsigned long stack_top;
unsigned int* location;
int main()
{
int X = 72, Y = 30;