This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import itertools as it | |
import subprocess | |
import sys | |
class Sudoku: | |
def __init__(self, size): | |
self.width = size*size | |
self.height = size*size | |
self._opts = size*size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools as ft | |
import itertools as it | |
import operator as op | |
def generate_factors(b, n, smallest_number=1): | |
if n == 1: | |
yield [b] | |
else: | |
for i in range(smallest_number, b // 2 + 1): | |
for s in generate_factors(b-i, n-1, i): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Piped: | |
def __init__(self, fn, terminal=False): | |
self.fn = fn | |
self.terminal = terminal | |
self.args = [] | |
self.gotval = False | |
self.val = None | |
def __call__(self, *args): | |
self.args = list(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
update_gist() { | |
GITHUB_USERNAME=aib | |
GIST_ID=1881c25137724b47f916aec3e87028de | |
python -c "import json, sys; json.dump({ \"files\": { sys.argv[1]: { \"content\": sys.stdin.read() } } }, sys.stdout)" $(basename "$0") <"$0" | curl -f -s -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" -u "$GITHUB_USERNAME" -X PATCH "https://api.github.com/gists/$GIST_ID" -d@- >/dev/null | |
} | |
if [ -z "$1" ]; then | |
printf "Usage:\n" >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import math | |
import pygame | |
import random | |
import rtmidi | |
from rtmidi.midiconstants import * | |
import time | |
TAU = 2 * math.pi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A static class with misc. utilities | |
* | |
* aib, 20071120 | |
*/ | |
package | |
{ | |
import flash.display.DisplayObject; | |
import flash.display.Graphics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <time.h> | |
#define PROCS 10 | |
int child(int n) | |
{ | |
while (1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, jsonify | |
app = Flask(__name__) | |
app.secret_key = 'aib' | |
def homer(): | |
def home(): | |
return 'Ok' | |
return home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Table structure for table "site_cities" | |
-- | |
DROP TABLE IF EXISTS "site_cities" CASCADE; | |
CREATE TABLE "site_cities" ( | |
"city_id" serial NOT NULL, | |
"city_name" varchar(20) NOT NULL, | |
"plate_code" smallint NOT NULL, | |
"area_code" smallint NOT NULL, | |
"lat" decimal(20,8) NOT NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a0 = 2^38 | |
let a1 = "lost in my ghci history" | |
let a2 = simpleHTTP (getRequest "http://www.pythonchallenge.com/pc/def/ocr.html") >>= getResponseBody >>= return . filter isAlpha | |
let a3 = simpleHTTP (getRequest "http://www.pythonchallenge.com/pc/def/equality.html") >>= getResponseBody >>= return . concatMap (!!1) . ((=~ "[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]") :: String -> [[String]]) | |
let a4_a = let dorq x = simpleHTTP (getRequest ("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" ++ x)) >>= getResponseBody in iterateUntilM (\x -> Debug.Trace.trace (show x) (not (x =~ "next nothing is")::Bool)) (dorq . last . words) "next nothing is 12345" | |
let a4_b = let dorq x = simpleHTTP (getRequest ("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" ++ x)) >>= getResponseBody in iterateUntilM (\x -> Debug.Trace.trace (show x) (not (x =~ "next nothing is")::Bool)) (dorq . last . words) "next nothing is 8022" |