Skip to content

Instantly share code, notes, and snippets.

1.9.3p194 :001 > keys = [:title, :description]
=> [:title, :description]
1.9.3p194 :002 > values = ["Hello, world", "How are you?", "Personally, I'm fine.", "You're doing terrible?!"]
=> ["Hello, world", "How are you?", "Personally, I'm fine.", "You're doing terrible?!"]
1.9.3p194 :003 > v = values.dup
=> ["Hello, world", "How are you?", "Personally, I'm fine.", "You're doing terrible?!"]
1.9.3p194 :004 > v.fill(keys.length - 1) {|i| values[keys.length - 1, values.length].join("/n") }
=> ["Hello, world", "How are you?/nPersonally, I'm fine./nYou're doing terrible?!", "How are you?/nPersonally, I'm fine./nYou're doing terrible?!", "How are you?/nPersonally, I'm fine./nYou're doing terrible?!"]
1.9.3p194 :005 > keys.zip (v)
=> [[:title, "Hello, world"], [:description, "How are you?/nPersonally, I'm fine./nYou're doing terrible?!"]]
import requests
class Content(object):
def where(self, params={}):
return Query(self).where(params)
def all(self):
return Query(self).all()
class Query(object):
@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
@mwunsch
mwunsch / gist:1259279
Created October 3, 2011 14:56
ckolderup teaches me irssi
10:54 < ckolderup> I definitely recommend trackbar: http://scripts.irssi.org/scripts/trackbar.pl
10:54 < ckolderup> just drop that in ~/.irssi/scripts and then create a ~/.irssi/scripts/autorun and symlink it in there too
10:57 < ckolderup> if you want to change something in your config file manually while irssi is running and then have that change get picked up, do /reload
10:57 < ckolderup> if it's easier to just make the change to the file instead of figuring out how to change the setting from within irssi and then saving
@mwunsch
mwunsch / Casey.terminal
Created August 20, 2011 01:38
My OS X Lion Terminal Theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
TxAnMC4xMDU4ODIzNTI5IDAuMTEzNzI1NDkwMiAwLjExNzY0NzA1ODgA0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
@mwunsch
mwunsch / gist:1144452
Created August 14, 2011 01:02
Gems are so painful
mark:~ $ rbenv version
system (set by /Users/mark/.rbenv/default)
mark:~ $ ronn --version
Ronn v0.7.3
http://github.com/rtomayko/ronn/tree/0.7.3
mark:~ $ which ronn
/usr/local/bin/ronn
mark:~ $ cd Projects/
mark:~/Projects $ rbenv version
1.9.2-p290 (set by /Users/mark/Projects/.rbenv-version)
@mwunsch
mwunsch / gist:1139435
Created August 11, 2011 11:31
Installing gems is hard
mark:~ $ which ruby
/usr/bin/ruby
mark:~ $ sudo gem install ronn
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed hpricot-0.8.4
Successfully installed rdiscount-1.6.8
Successfully installed mustache-0.99.4
Successfully installed ronn-0.7.3
4 gems installed
.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
This document explains how to make extension libraries for Ruby.
1. Basic knowledge
In C, variables have types and data do not have types. In contrast,
Ruby variables do not have a static type, and data themselves have
types, so data will need to be converted between the languages.
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
[user]
name = Jamie Wilkinson
email = jamie@jamiedubs.com
[github]
user = jamiew
token = <REDACTED>
[apply]
whitespace = nowarn
[branch]
autosetuprebase = always