Skip to content

Instantly share code, notes, and snippets.

View JonnoFTW's full-sized avatar
⚔️
Fighting off bugs with a sword 🤺

Jonathan Mackenzie JonnoFTW

⚔️
Fighting off bugs with a sword 🤺
View GitHub Profile
@JonnoFTW
JonnoFTW / boggle_solver.js
Last active December 27, 2019 16:01
Javascript boggle solver
/**
* Created by mack0242 on 6/04/17.
*/
var TrieNode = function (parent, value) {
this.parent = parent;
this.children = new Array(26);
this.isWord = false;
if (parent !== undefined) {
parent.children[value.charCodeAt(0) - 97] = this;
}
import re
import praw
import prawcore.exceptions
from collections import defaultdict
from itertools import product
from tqdm import tqdm
from pymongo import MongoClient
client = praw.Reddit(client_id='client id', client_secret='client secret', user_agent='gender scraper')
subs = 'askmen','askwomen'
@JonnoFTW
JonnoFTW / pqstat.py
Created April 5, 2018 03:07
A python curses script to interactively view SGE qstat output
#!/usr/bin/env python
import curses
import subprocess
import sys
from datetime import datetime
AUTHOR = "Jonathan Mackenzie"
NAME = "pqstat"
def get_qstat(args):
return subprocess.Popen(['qstat']+args,stdout=subprocess.PIPE).communicate()[0]
def main(scr):
@JonnoFTW
JonnoFTW / mnist.py
Created June 26, 2019 13:55
mnist with pygame
#!/usr/bin/env python
"""
pip install -U pygame numpy tensorflow keras opencv-python
"""
from datetime import datetime
import pygame
import os
import sys
import cv2
@JonnoFTW
JonnoFTW / connectHTMLelements_SVG.png
Created February 25, 2019 05:07 — forked from alojzije/connectHTMLelements_SVG.png
Connect two elements / draw a path between two elements with SVG path (using jQuery)
connectHTMLelements_SVG.png
from pydotplus import graphviz as pydot
class TrieNode:
__slots__ = ('text', 'children', 'is_end')
def __init__(self, letter, is_end=False):
self.text = letter
self.children = {}
self.is_end = is_end
@JonnoFTW
JonnoFTW / results
Last active September 7, 2018 08:30
Rows: 11, cols=1 44 Bytes
CL Took: 0:00:00.003606
NP Took: 0:00:00.000021
Rows: 10, cols=3 120 Bytes
CL Took: 0:00:00.000312
NP Took: 0:00:00.000012
Rows: 10000, cols=1000 40.0 MB
CL Took: 0:00:00.005533
NP Took: 0:00:00.017710
Rows: 50000, cols=1200 240.0 MB
__kernel void shuffle_data(
const __global float* data, // array to be shuffled
const __global uint2* swaps // array of swaps to perform
) {
const int gid = get_global_id(0);
const int field = get_global_id(1);
const int num_fields = get_global_size(1);
// swap row r1 with r2 from swaps[gid]
uint2 swap = swaps[gid];
const int r1 = num_fields* swap.x + field;
#!/usr/bin/env python
import os
import json
import time
import pandas as pd
import requests
from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import apriori
@JonnoFTW
JonnoFTW / _Running.md
Last active July 21, 2018 04:26
Simple image/show hide on button press
  1. Make a folder for the app
  2. Put app.py in the folder
  3. Make a static folder and put index.html in it
  4. Should look like:
lamp/
  app.py
  static/
    index.html