Skip to content

Instantly share code, notes, and snippets.

View upvalue's full-sized avatar
🐴

Phil upvalue

🐴
View GitHub Profile
@upvalue
upvalue / likes.rb
Created May 15, 2013 21:25
Non-intrusive social sharing tags for Jekyll. Note: uses deprecated/private APIs, probably against TOS or whatever
# likes.rb - non intrusive sharing tags for jekyll/liquid
# usage (unfortunately rather verbose because of liquid)
# {{ site.url | append: page.url | facebook_likes }} => Fixnum
# {{ site.url | append: page.url | facebook_share_link }} => a link to share this page
# {{ site.url | append: page.url | twitter_tweets }} => Fixnum
# {{ site.url | append: page.url | twitter_share_link }} => Fixnum
# if you're doing it a lot, try something like this
# {% assign absolute = site.url | append: page.url %}
# NOTE: twitter ignores localhost urls. if you try to tweet one, the url will not appear in your tweet
@upvalue
upvalue / buffer.lua
Created January 11, 2013 01:45
Simple circular buffers for Lua, which took me forever to get right for some reason.
-- Circular buffer functionality
local Buffer = {}
function Buffer:new(ob)
local o = ob or {}
o.entries = #o
o.cursor = #o + 1
o.max = 10
setmetatable(o, self)
self.__index = self
@upvalue
upvalue / vimrc
Created November 10, 2012 08:13
Miniature version of vim rc for servers
filetype plugin indent on | syntax on | set ruler gd hls scs ic hid ts=2 sts=2 sw=2 tw=79 fo=cq nuw=5 wmnu wim=full cul cino=l1,(0 | map ; : | map i <Up> | map j <Left> | map k <Down> | noremap h i | set number
@upvalue
upvalue / largest-files.py
Created August 2, 2012 17:55
get and sort the line count of each file (so you can find the largest ones)
#!/usr/bin/python
# usage: ./largest-files.py <file> ...
# for instance: ./largest-files.py *.c
# to find the largest c file in the current directory
import glob, sys, os, pprint
files = sys.argv[1:]
lines = []
for x in files: