Skip to content

Instantly share code, notes, and snippets.

View ryanfb's full-sized avatar

Ryan Baumann ryanfb

View GitHub Profile
$ time 7zr x enwiki-latest-pages-meta-history.xml.7z
7-Zip (A) 4.57 Copyright (c) 1999-2007 Igor Pavlov 2007-12-06
p7zip Version 4.57 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs)
Processing archive: enwiki-latest-pages-meta-history.xml.7z
Extracting enwiki-latest-pages-meta-history.xml
Everything is Ok
$ time pbzip2 -d -v -p7 enwiki-latest-pages-meta-history.xml.bz2
Parallel BZIP2 v1.0.2 - by: Jeff Gilchrist [http://compression.ca]
[July 25, 2007] (uses libbzip2 by Julian Seward)
# CPUs: 7
-------------------------------------------
File #: 1 of 1
Input Name: enwiki-latest-pages-meta-history.xml.bz2
Output Name: enwiki-latest-pages-meta-history.xml
proc tag {url args} {
if { ![regexp {^http://} $url] } {
return "Usage: tcl tag [color red]URL[color] tags."
} else {
if { ![info exists ::urltags($url)] } {
set ::urltags($url) $args
} else {
set l $::urltags($url)
foreach e $args {if { [lsearch -exact $l $e] == -1 } {lappend l $e}}
set ::urltags($url) $l
@ryanfb
ryanfb / gist:30903
Created December 1, 2008 23:36
gisthead.cgi
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require "cgi"
gistbase = 'http://gist.github.com'
cgi = CGI.new
proc crop_to_fit {url {xoff 0} {yoff 0} {w 63} {h 79}} {set ar [expr $w./$h.]; set dims [get_image_size $url]; if [expr $xoff == -1] {set xoff [expr round([lindex $dims 0]*$ar/4)]}; if [expr $yoff == -1] {set yoff [expr round([lindex $dims 1]/$ar/4)]}; set x [expr [lindex $dims 0]-$xoff]; set y [expr [lindex $dims 1]-$yoff]; set oar [expr $x./$y.]; if [expr $oar > $ar] {set crop [magick crop $url $xoff $yoff [expr $y*$ar] $y]} else {set crop [magick crop $url $xoff $yoff $x [expr $x/$ar]]}; . $crop}
@ryanfb
ryanfb / Full trace
Created January 16, 2009 19:27
Workaround for error I get with toughtbot's mile_marker
NoMethodError in WelcomeController#index
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?
RAILS_ROOT: /Users/ryan/source/idp2/git/protosite
Application Trace | Framework Trace | Full Trace
vendor/plugins/mile_marker/lib/mile_marker.rb:37:in `enabled?'
vendor/plugins/mile_marker/lib/mile_marker.rb:9:in `initialize_mile_marker'
@ryanfb
ryanfb / environment.rb
Created February 6, 2009 14:21 — forked from mislav/_note.md
SQLite & rake-based Git & Rails database branching, see http://tinyurl.com/a7e6jo
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'git_conf'
Rails::Initializer.run(:process, GitConf.new) do |config|
# ...
end

Combining 8.5x11 (US Letter) to 11x17 (US Tabloid) for Tufte-style handouts with Pages and Acrobat printer:

  • Create a normal 8.5x11 Pages document
  • Write up your content
  • Page 2 will be the front page, Page 1 will be the back page, rearrange just before printing
  • Print
  • Select Adobe PDF
  • Click the advanced settings drop arrow
  • Select "Paper Handling"
  • Click "Scale to fit paper size"
proc assert_block {block {message "assert_block failed."}} {
if ![uplevel $block] {
error $message
}
}
proc assert_equal {expected actual {message ""}} {
set full_message [or $message "$expected expected but was\n$actual.\n"]
assert_block {expr {$expected eq $actual}} $full_message
}
@ryanfb
ryanfb / gist:94591
Created April 13, 2009 18:17
Recursive Haml abuse
- p = Proc.new do |element, hidden, block|
- tab_up
%div{:id => element.div_id, :class => element.error_class, :style => "display:#{hidden ? 'none' : ''};"}
= element.name + " (" + element.length.to_s + " instances)"
.toggle_button
%a{:onclick => "toggle_div('#{element.div_id}-examples');"}
Examples
.examples{:id => element.div_id + "-examples", :style => "display:none;"}
- for example in element.examples
.filename