Skip to content

Instantly share code, notes, and snippets.

import os, sys
from time import gmtime, strftime
from stat import *
def walktree(top, callback):
for f in os.listdir(top):
pathname = os.path.join(top, f)
mode = os.stat(pathname)[ST_MODE]
if S_ISDIR(mode):
# It's a directory, recurse into it
current_datetime = datetime.datetime.now(ustimezones.pacific()) # What time is it in California?
delta = str(current_datetime.replace(tzinfo=None) - date_time)
# The famous @johlcat script, generated as a birthday present for @johl.
# The script requires the following gems: twitter and lolspeak.
# It reads all tweets tweeted in the last hour and retweets them to
# another twitter account, but in lolspeak.
#
# Have phun!
#
# Author: Svenja Schroeder
# github: http://github.com/svenja
# twitter: http://www.twitter.com/sv
import re
from github2.client import Github
def get_last_commit():
last_commits = []
github = Github(username="xxx", api_token="xxx")
for repo in github.repos.list() + github.repos.pushable():
for branch in github.repos.branches(repo.project):
commits = github.commits.list(repo.project, branch)
for commit in commits:
@johl
johl / lqfb.py
Created October 31, 2011 10:15
Letzte Initiativen im LiquidFeedback der Piratenpartei unter Python mit der API abrufen: So einfach geht das!
import requests, json # ggf. requests (http://docs.python-requests.org/en/latest/index.html) installieren mit 'pip install requests'
base_url = "https://lqfb.piratenpartei.de/pp/" # oder einen anderen Basis-URL für eine andere LQFB-Instanz
key = "xxxxxxx" # Zu finden unter https://lqfb.piratenpartei.de/pp/member/developer_settings.html
r = requests.get(base_url + "/api/initiative.html?key=" + key + "&api_engine=json")
initiatives = json.loads(r.content)
print "Letzte Initiativen: "
for initiative in initiatives:
print initiative["name"]
BITCOIN_EXECUTABLE = '/Applications/Bitcoin.app/Contents/MacOS/bitcoin' and require 'bitcoin'
require 'json'
require 'rest_client'
currency = 'EUR'
balance = Bitcoin::Client.getinfo()['balance']
balanceCUR = JSON.parse(RestClient.get "https://mtgox.com/api/0/data/ticker.php?Currency=#{currency}".to_str)['ticker']['avg'] * balance
puts "You have #{balance} BTC, which is currently #{balanceCUR} #{currency}."
f = fopen (filename, "ab"); /* reopen in binary append mode */
for (y = height - 1; y >= 0; y--)
{
for (x = 0; x < width; x++)
{
i = (y * width + x) * 4;
printf ("i is now: %i\n", i);
if (ptr != 0)
{
fputc (ptr[i + 2], f); /* write blue */
--[[
A module to generate a random curry recipe. Uses some functional programming techniques to archieve
an incredibly trivial goal, but you might learn a thing or two about Lua.
Invoke it like this:
{{#invoke:Curry.lua|curry|{{CURRENTTIMESTAMP}}|}}
Jens Ohlig 17:47, 2 June 2012 (UTC)
--]]
@johl
johl / nyan.php
Last active October 9, 2015 10:28
$nyan = array();
$nyan['nyan'] =& $nyan;
$nyan['cat'] = 'nyan';
echo $nyan['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['nyan']['cat'];
@johl
johl / gist:3895222
Created October 15, 2012 20:31
BogoSort
import java.util.Random;
import java.util.Arrays;
public class BogoSort {
public static int[] array = {2,5,6,3,1,73,46};
public static int[] shuffle(int[] a) {
int n = a.length;
Random random = new Random();