Skip to content

Instantly share code, notes, and snippets.

View kageurufu's full-sized avatar
🏠
Working from home

Frank Tackitt kageurufu

🏠
Working from home
View GitHub Profile
@kageurufu
kageurufu / linkedlist.hh
Last active December 17, 2015 16:39
linkedlist
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <iostream>
template <class T>
class linkedList {
struct node {
node* ptr;
T data;
@kageurufu
kageurufu / flask.py
Created October 3, 2013 17:42
Flask-WTF FieldLists with Dynamic Entries
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.wtf import Form
from flask.ext.babel import gettext
from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField
from wtforms.validators import Optional, Required
app = Flask(__name__)
db = SQLAlchemy(app)
@kageurufu
kageurufu / models.py
Last active June 6, 2021 07:37
PostgreSQL JSON Data Type support for SQLAlchemy, with Nested MutableDicts for data change notifications To use, simply include somewhere in your project, and import JSON Also, monkey-patches pg.ARRAY to be Mutable @zzzeek wanna tell me whats terrible about this?
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Integer, Column
from postgresql_json import JSON
Base = declarative_base()
class Document(Base):
id = Column(Integer(), primary_key=True)
data = Column(JSON)
#do whatever other work
#!/bin/bash
PERCENTAGE=0
(
while [ $PERCENTAGE -le 100 ]; do
echo "$PERCENTAGE"
case $PERCENTAGE in
[1-9])
;;
@kageurufu
kageurufu / report.py
Last active August 29, 2015 14:03
Simple data munging for outputting reports
import csv
from StringIO import StringIO
def rec_getattr(obj, attr, default=None):
"""Get object's attribute. May use dot notation.
>>> class C(object): pass
>>> a = C()
>>> a.b = C()
>>> a.b.c = 4
@kageurufu
kageurufu / bsearch.py
Created August 12, 2014 15:24
python bsearch for finding failing builds of the dolphin emulator for bug hunting
import requests
import subprocess
f = open("dolphin-list.txt", "r")
ALL_FILES = [l.strip() for l in f.readlines()]
SOURCE_URL = "https://dl.dolphin-emu.org/builds/"
len(ALL_FILES)
echo Setting OSX values for Virtual Box ${1}
VBoxManage modifyvm "${1}" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff
VBoxManage setextradata "${1}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
[02/17/15 23:44:56] [INFO] Reading configuration file /home/frank/.ngrok
[02/17/15 23:44:56] [INFO] [client] Trusting root CAs: [assets/client/tls/ngrokroot.crt]
[02/17/15 23:44:56] [INFO] [view] [web] Serving web interface on 0.0.0.0:8888
[02/17/15 23:44:56] [INFO] Checking for update
[02/17/15 23:44:56] [DEBG] [ctl:374737d0] New connection to: 96.126.125.171:443
[02/17/15 23:44:56] [DEBG] [ctl:374737d0] Writing message: {"Type":"Auth","Payload":{"Version":"2","MmVersion":"1.7","User":"ZnDxl31mzAgxJhgAb7Tc","Password":"","OS":"linux","Arch":"amd64","ClientId":""}}
[02/17/15 23:44:56] [DEBG] [ctl:374737d0] Waiting to read message
[02/17/15 23:44:57] [DEBG] [ctl:374737d0] Reading message with length: 120
[02/17/15 23:44:57] [DEBG] [ctl:374737d0] Read message {"Type":"AuthResp","Payload":{"Version":"2","MmVersion":"1.7","ClientId":"03f700f2df0a3bc9f2bc5e74606ea8b6","Error":""}}
[02/17/15 23:44:57] [INFO] [client] Authenticated with server, client id: 03f700f2df0a3bc9f2bc5e74606ea8b6
#!/usr/bin/env python2
import boto
from collections import defaultdict
from pprint import pprint
import os, sys
DIVIDER = """
===========================================
======== ec2-instances ========
@kageurufu
kageurufu / lambda.js
Last active November 25, 2021 12:44
AWS Lambda Thumbnailer
var async = require("async");
var AWS = require("aws-sdk");
var gm = require("gm").subClass({imageMagick: true});
var fs = require("fs");
var mktemp = require("mktemp");
var THUMB_KEY_PREFIX = "thumbnails/",
THUMB_WIDTH = 150,
THUMB_HEIGHT = 150,
ALLOWED_FILETYPES = ['png', 'jpg', 'jpeg', 'bmp', 'tiff', 'pdf', 'gif'];