Skip to content

Instantly share code, notes, and snippets.

@inky
inky / _Prefix.pch
Created October 14, 2010 09:24
Array & dict shortcuts (objective-c)
#define A(obj, objs...) [NSArray arrayWithObjects:obj, ## objs , nil]
#define D(val, key, vals...) [NSDictionary dictionaryWithObjectsAndKeys:val, key, ## vals , nil]
// from http://news.ycombinator.com/item?id=1789839
#!/bin/bash
set -e
# full path in finder windows
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
# flat dock style
defaults write com.apple.dock no-glass -bool YES
# reduce the dock autohide delay
@inky
inky / hashtags.py
Created February 14, 2011 12:06
Count the hashtags in stdin (tested with a .txt dump of my tweets from tweetbackup.com)
#!/usr/bin/env python
import sys
from collections import defaultdict
def hashtags():
tags = [w for w in sys.stdin.read().split() if w.startswith('#')]
freq = defaultdict(int)
for tag in tags:
freq[tag] += 1
return sorted(((v, k) for (k, v) in freq.items()), reverse=True)
@aparrish
aparrish / draw_average_word.py
Created April 7, 2011 12:21
drawing the average N-letter word using processing.py
import array
wordlen = 8
charwidth = 32
charheight = 64
def fillbuf(pg, font, word, buffer):
pg.beginDraw()
pg.background(0)
pg.fill(255)
#!/usr/bin/python
# Get a quasi-random list of band names, album names and track names from your
# iTunes folder. Tastes great with Orothron <http://github.com/inky/orothron>.
import os
import re
itunes_tracknum = re.compile(r'^[0-9]+(-[0-9]+)?\ ')
def filter_name(name):
@johnholdun
johnholdun / imgur-bookmarklet.js
Created April 9, 2011 22:43
Bookmarklet for uploading the image currently loaded in your browser to imgur
// that is, navigate to the direct URL for an image hosted on the world wide web, then >>>INVOKE<<<
// i wanted the bookmarklet to redirect to the new direct image URL but that was out of scope!
javascript:void(window.location="http://api.imgur.com/2/upload.json?url="+encodeURIComponent(window.location.href));
$ python entity2unicode.py <<< '&#8230; &#x2026; &hellip; &troll; &#9731;'
… &#8230;
… &#x2026;
… &hellip;
n/a &troll;
☃ &#9731;
@dbrady
dbrady / donkey_patches.rb
Created July 27, 2011 07:25 — forked from blowmage/edgecase.rb
Ruby Koans Hackfest
#!/usr/bin/env ruby
# -*- ruby -*-
# This is a fully-functional set of donkey patches that will break
# Ruby so badly that it makes all of the Ruby Koans pass right out of
# the box. ALl you need to do is patch edgecase.rb with this line:
#
# require File.expand_path(File.dirname(__FILE__) + '/donkey_patches')
#
# so it's the first line of the file. Then save this file as
@johnholdun
johnholdun / tumblr-post-notes.php
Created August 4, 2011 06:32
Retrieve post notes for any tumblr tumblelog
<!--
a styled php version you can throw up on your apache
because i'm some kind of machinist
-->
<style>
/* oooh */
html, body, ul, li { font-family: Verdana; font-size: 14px; line-height: 20px; }
body { width: 400px; margin: 20px auto; background: #333; }
ul { list-style: none; }
li { margin-bottom: 10px; color: #AAA; overflow: hidden; height: 20px; white-space: nowrap; text-overflow: ellipsis; }
@mwunsch
mwunsch / client.rb
Created April 1, 2012 00:52
Tumblr Client in the next version of the tumblr gem (using Weary v1.0.0
require "weary"
module Tumblr
class Client < Weary::Client
VERSION = "v2"
POST_OPTIONS = [
:state, :tags, :tweet, :date, :markdown, :slug,
:title, :body, # Text posts
:caption, :link, :source, :data, #Photo posts