Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View loisaidasam's full-sized avatar
🙌
🙌

Loisaida Sam loisaidasam

🙌
🙌
View GitHub Profile
@benwilber
benwilber / timespec.yacc
Created August 26, 2015 00:04
at timespec
/*
* Abbreviated version of the yacc grammar used by at(1).
*/
%token <charval> DOTTEDDATE
%token <charval> HYPHENDATE
%token <charval> HOURMIN
%token <charval> INT1DIGIT
%token <charval> INT2DIGIT
%token <charval> INT4DIGIT
import redis
r = redis.Redis()
base = 0 # Smallest allowed key in samples
jump = 50 # Key size bins
top = 1300 # Largest allowed key in sample
samples = 1000 # Numbers of samples
bins = []
for i in xrange(1+(top-base)/jump):
@jdp
jdp / shorten.sh
Last active August 29, 2015 14:05
A URL shortening service in bash
#!/usr/bin/env bash
set -e
B56ALPHABET="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789"
if [[ "$REQUEST_METHOD" = "GET" ]]; then
URL=$(redis-cli get ${PATH_INFO:1})
if [[ -z "$URL" ]]; then
echo "Status: 404 Not Found"
echo "Content-Type: text/plain"
@jdp
jdp / jarg.py
Last active August 29, 2015 14:09
JSON shorthand for your CLI
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
import sys
class InvalidJSONError(ValueError):
def __init__(self, key, *args, **kwargs):
self.key = key
@beng
beng / apt-get-history.sh
Created December 2, 2014 21:03
A way to find all the stuff you manually installed on ubuntu via apt-get as found here: http://askubuntu.com/a/250530
(zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline:'
@hery
hery / gist:d479478986ec5d9a7b85
Last active August 29, 2015 14:19
Transform Your (OS X) Box Into a Radio
Prerequisites
* SHOUTcast (http://www.shoutcast.com/BroadcastNow)
* Soundflower (https://rogueamoeba.com/freebies/soundflower/)
* butt (http://butt.sourceforge.net/)
* a computer
Set up Soundflower
* After installing Soundflower, set it as Output source in System Preferences
@jdp
jdp / example.php
Created May 19, 2009 08:26
Glue API implementation
<?php
// require glue lib
require 'glue.php';
// create a glue object, and look up the neverending story in json format
// $glue->$method->$chain maps to api calls, like method/chain
// you can use any value, but glue will throw errors
$glue = new Glue('username', 'password');
$response = $glue->object->get(array(
'objectId' => 'http://en.wikipedia.org/wiki/The_Neverending_Story',
@jdp
jdp / magneton.php
Created July 9, 2009 11:38
Magneton, the superdense PHP framework
<?php $u=$_GET['u'];$l=$u();extract($l);include("view/{$u}.php");
@jdp
jdp / Makefile
Last active September 24, 2015 13:22
makefile/procfile ultimate front end combo
JS = $(wildcard scripts/*.js)
all: game.js game.js.map game.css rules.html
game.js: $(JS)
game.js.map: $(JS)
%.js %.js.map:
closure-compiler --js $(JS) --js_output_file $*.js --create_source_map $*.js.map --source_map_format V3
@torsten
torsten / svn-stats.sh
Created April 21, 2011 09:05
Prints a list of all committers in a subversion repository, sorted by number of commits.
#!/bin/bash
# Prints a list of all committers in a subversion repository,
# sorted by number of commits.
# Written by Torsten Becker <torsten.becker@gmail.com> in 2011
if [[ ! $1 ]]; then
echo "Usage: $0 SVN-REPO-URL"
exit 1
fi