Skip to content

Instantly share code, notes, and snippets.

View apg's full-sized avatar
🐢
Turtle

Andrew Gwozdziewycz apg

🐢
Turtle
View GitHub Profile
#!/bin/bash
read -p "Enter yubikey: " key
echo
curl "http://api.yubico.com/wsapi/2.0/verify?id=87&timeout=8&sl=50&nonce=askjdnkajsndjkasndkjsnad&timestamp=1&otp=$key"
from flask import Module, request, redirect, url_for, render_template, abort
from formalchemy import FieldSet
from example import db
from example import Service, User, Forum, Category, Topic, Post
mod = Module(__name__)
models = {
@apg
apg / haiku.el
Created September 2, 2010 14:48
;; Lingua::EN::Syllable::syllable() estimates the number of syllables in
;; the word passed to it.
;; Note that it isn't entirely accurate... it fails (by one syllable) for
;; about 10-15% of my /usr/dict/words. The only way to get a 100% accurate
;; count is to do a dictionary lookup, so this is a small and fast alternative
;; where more-or-less accurate results will suffice, such as estimating the
;; reading level of a document.
;; I welcome pointers to more accurate algorithms, since this one is
@apg
apg / mastermind.c
Created December 10, 2010 19:36
A console mastermind game.
/**
* guessit
* Itty-bitty mastermind type game.
*
* OBJECT:
*
* The object of the game is to guess what the computer has choosen.
*
* The computer starts out by randomly selecting a number of symbols. Your job
* is to figure out what the symbols are. You have a limited number of
@apg
apg / generator-ttd.scm
Created January 29, 2011 16:26
generators (like python yield), in scheme, a language that doesn't normally have them.
;; Deriving something like generators, but I didn't really feel like
;; doing exactly that.
;; It doesn't, for instance, support sending back into the generator
;; This applys a function across a range from 0 to x.
(define (apply-to-range f i x)
(when (< i x)
(f i)
(apply-to-range f (+ 1 i) x)))
@philikon
philikon / wtf8.py
Created February 8, 2011 08:22
WTF-8 codec for Python
# wtf8.py
import codecs
def encode(input, errors='strict'):
return input.encode('utf-8', errors).decode('latin-1', errors).encode('utf-8', errors), len(input)
def decode(input, errors='strict'):
return input.decode('utf-8', errors).encode('latin-1', errors).decode('utf-8', errors), len(input)
class StreamWriter(codecs.StreamWriter):
@jsocol
jsocol / php-serve.py
Created February 14, 2011 17:32
A local dev server for PHP.
#!/usr/bin/env python
"""
Add php-serve.py to your PATH, then, from whatever directory is the root
of your PHP application, just run:
$ php-serve.py
You can optionally specify a port number as an argument. By default,
port 8000 is used:
///////////////////// unit tests
unsigned g_test_count; // count of number of unit tests executed
unsigned g_fault_count; // count of number of unit tests that fail
template <typename T1, typename T2>
void test_equal_(const T1 & value, const T2 & expected_value, const char * file, int line)
{
++g_test_count;
if (value != expected_value) {
@edw
edw / schass.scm
Created May 4, 2011 21:51
SASS-like Thing in Scheme
;; Let's you do this:
;;
;; (make-css
;; '(("body.loading"
;; (font-size "12px")
;; (color "#fff")
;; (" ul#sidenav"
;; (" li"
;; (blah "blah"))))))
;;