Skip to content

Instantly share code, notes, and snippets.

@maddenpj
maddenpj / HardcoreGaming101-DomainFix.user.js
Created January 8, 2018 19:55
HardcoreGaming101.net Old-site Domain Swap
// ==UserScript==
// @name HardcoreGaming101 DomainFix
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://hg101.kontek.net/*
// @include http://blog.hardcoregaming101.net/*
// @grant none
// ==/UserScript==
@maddenpj
maddenpj / digitClassifier.hs
Created June 24, 2017 02:43
OCR for Numbers using KNN (Haskell)
import System.IO
import Data.List
data Digit = Digit { actualDigit :: Int
, pixels :: [Int]
} deriving Show
type Classifier = [Digit]
type KNNClassifier = [[Digit]]
@maddenpj
maddenpj / cvimrc
Last active January 8, 2018 19:53
cVim Settings
" Global
set noautofocus
let searchalias g = "google"
let blacklists = ["*://github.com/*","*://*.github.com/*","http://45.55.219.52/*","https://portal.azure.com/*"]
command g tabnew google
map <C-d> scrollPageDown
map <C-e> scrollPageUp
<?php
namespace Flagship\Event;
use Flagship\Model\User;
use Flagship\Model\Lander;
class View extends AbstractEvent {
const NAME = "view";
const SEGMENT_NAME = "Landing Pageview";
@maddenpj
maddenpj / Output
Last active December 28, 2015 06:09
{ response: 200, body: '' } //The write
{ response: 200, //The read
body:
{ series:
{ id: 'e61390b2cf0b47688c2d54af7ff742b4',
key: 'São Paulo',
name: '',
tags: [],
attributes: {} },
start: '2013-11-07T00:00:00.000Z',
@maddenpj
maddenpj / gist:5981047
Created July 12, 2013 02:47
Graham Scan algorithm for finding convex hull
import Data.List
data Point = Point Float Float deriving (Show, Eq)
data Direction = LeftDirection
| RightDirection
| StraightDirection deriving (Show)
dot :: Point -> Point -> Float
dot (Point x1 y1) (Point x2 y2) = x1*x2 + y1*y2
@maddenpj
maddenpj / mh.py
Created June 7, 2013 19:45
Empirical Monty Hall
import random
def stay_strategy(objects):
first = random.randint(0, len(objects)-1)
return objects[first]
def switch_strategy(objects):
first = random.randint(0, len(objects)-1)
goat = random.choice([i for i,x in enumerate(objects) if x == 'G' and i != first])
@maddenpj
maddenpj / Tickers
Created May 20, 2013 23:09
Scrape Google
ABT
ABBV
ANF
ACE
ACN
ACT
ADBE
ADT
AMD
AES
@maddenpj
maddenpj / gist:5461491
Created April 25, 2013 17:23
Monte carlo pi guessing machine
import random
import sys
CIRCLE_RADIUS = 1
NUM_GUESSES = int(sys.argv[1])
def insideCircle(px, py):
l = px**2 + py**2
return (l <= CIRCLE_RADIUS)
@maddenpj
maddenpj / gist:5375492
Created April 12, 2013 21:58
Batch TempoDB importer (Gentle)
import datetime
import dateutil.parser
import optparse
from Queue import Queue
import tempodb
from threading import Thread
class Worker(Thread):
"""Thread executing tasks from a given tasks queue"""
def __init__(self, tasks):