Skip to content

Instantly share code, notes, and snippets.

View zaius's full-sized avatar

David Kelso zaius

  • Beyond @1024inc
  • San Francisco
  • 02:34 (UTC -07:00)
View GitHub Profile
class User < Sequel::Model
one_to_many :posts
def tags_dataset
posts.join(Tag, :post_id => :id)
end
def tags
tags_dataset.all
end
end
numbers = 3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99
set_count = 0
numbers.each_with_index do |number, i|
numbers.combination(i).each do |combination|
set_count += 1 and puts combination.inspect if combination[0..-2].sum == combination[-1]
end
end
s = 'FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedea
@zaius
zaius / flashblock.html
Created October 26, 2010 03:20
Inconsistent problem with flashblock and swfobject
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" type="text/javascript"></script>
<script type="text/javascript">
swfobject.registerObject("swfobject_static", "9.0.115", "expressInstall.swf");
</script>
</head>
@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@zaius
zaius / console.html
Created January 21, 2011 05:59
Overriding of console for debugging on jquery plugins
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$.fn.myWidget = function(params) {
(function(console){
if (!params.debug) console = { log: function(){} };
console.log("Logging enabled!");
})(console);
@zaius
zaius / 0001-Update-for-10.6.patch
Created April 26, 2011 21:48
TerminalTabSwitching update for 10.6
From 95badf3776ce6a69bdff356649c7f345567c148c Mon Sep 17 00:00:00 2001
From: David Kelso <david@kelso.id.au>
Date: Tue, 26 Apr 2011 14:44:09 -0700
Subject: [PATCH] Update for 10.6.
---
TerminalTabSwitching.xcodeproj/project.pbxproj | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/TerminalTabSwitching.xcodeproj/project.pbxproj b/TerminalTabSwitching.xcodeproj/project.pbxproj
@zaius
zaius / open_uri.rb
Created October 7, 2011 21:46
Allow open-uri to follow unsafe redirects (i.e. https to http)
# Allow open-uri to follow unsafe redirects (i.e. https to http).
# Relevant issue:
# http://redmine.ruby-lang.org/issues/3719
# Source here:
# https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
module OpenURI
class <<self
alias_method :open_uri_original, :open_uri
alias_method :redirectable_cautious?, :redirectable?
@zaius
zaius / nginx.conf
Created April 10, 2012 03:19
Serve rails assets with etags from nginx
location / {
if ($uri ~* "/assets/.*-(.*)\..*") {
expires max;
add_header Cache-Control public
add_header Etag $1;
}
}
@zaius
zaius / git-submodule-rm.sh
Created May 9, 2012 07:31 — forked from barraponto/git-submodule-rm.sh
Add rm command to git submodule
#!/bin/zsh
function actual_path() {
if [ [ -z "$1" ] -a [ -d $1 ] ]; then
echo $(cd $1 && test `pwd` = `pwd -P`)
return 0
else
return 1
fi
}