Skip to content

Instantly share code, notes, and snippets.

View codebynumbers's full-sized avatar

Rob Harrigan codebynumbers

View GitHub Profile
@codebynumbers
codebynumbers / mirror.php
Created February 4, 2012 21:16
mirror.php
<?
$rawpost = file_get_contents("php://input");
print '$_GET'."\n";
print_r($_GET);
print str_repeat("=",30)."\n";
print '$_POST'."\n";
print_r($_POST);
print str_repeat("=",30)."\n";
print 'RAW POST'."\n";
print_r($rawpost);
@codebynumbers
codebynumbers / yoink
Created March 28, 2012 18:07
Yoink lines from a file
#!/usr/bin/perl
use strict;
my $line;
my $i=1;
if($#ARGV == 2){
open (IN, "<$ARGV[0]") or die "Can't open $ARGV[0]";
while ($line = <IN>) {
if($ARGV[1] <= $i && $i <= $ARGV[2]){
<?php
/**
* Database Base Model class
*/
class Model {
// Hold raw properties for save() which take precedence over regular properties
// used in combination with set_raw() as in set_raw('somefield', 'CURDATE()')
// Will allow you to pass in raw SQL, so use with caution
@codebynumbers
codebynumbers / Substring Serch
Last active December 16, 2015 17:39
Two different approaches to substring lookup
# ======================
# Naive search
# ======================
import time
import random
input = 'https://www.facebook.com/teefury?hc_location=stream'
bids = []
@codebynumbers
codebynumbers / multiplexer.py
Created June 29, 2013 00:31
Split data into multiple files
import sys
path = sys.argv[1]
ext = 'txt'
dir = 'output'
limit = 10000
limits = {}
with open(path) as file:
@codebynumbers
codebynumbers / pingaling.py
Last active December 19, 2015 18:18
Draft site pinger
import grequests
import redis
import time
BATCH_SIZE = 10
THRESHOLD = 3
SLEEP_TIME = 60
# MANIFEST -[(URL, Check type, check value), ...]
sites = [
@codebynumbers
codebynumbers / time-dilater.py
Created August 8, 2013 00:41
Convert a string like '0,1,2,10 - 12, 20-23' into '0,1,2,10,11,12,20,21,22,23'
def conv(ts):
results = Set([])
parts = ts.split(",")
for part in parts:
if "-" not in part:
results.add(int(part.strip()))
else:
(s, e) = part.split("-")
for i in range(int(s.strip()), int(e.strip()) + 1):
results.add(i)
def limit(s, max):
""" Limit string s to x characters respecting space boundaries
>>> limit('cat dog', 3);
'cat'
>>> limit('cat', 3);
'cat'
>>> limit('cat ', 4);
'cat'
>>> limit('cat dog', 5);
@codebynumbers
codebynumbers / WordLimit.java
Last active January 3, 2016 08:09
Java port of Python gist
class WordLimit {
public static void main(String args[]) {
assert(limit("cat dog", 3) == "cat");
assert(limit("cat", 3) == "cat");
assert(limit("cat ", 4) == "cat");
assert(limit("cat dog", 5) == "cat");
assert(limit("cat dog bird", 10) == "cat dog");
assert(limit("cat", 9) == "cat");
""" HULK DB - A BIG DUMB DATA STORE
A probably overly simple way to store data to disk
with fast writes and lookups without needing indices in RAM
TODO: RESTful interface (something lightweight cherry-py maybe)
MAYBE: expirations
NEVER: Clustering, complex storage, data-types
"""