Skip to content

Instantly share code, notes, and snippets.

# gem install thin
# gem install rack
# thin -R static.ru start
# The static content rooted in the current working directory
# Dir.pwd => http://localhost:3000/
#
root=Dir.pwd
puts ">>> Serving: #{root}"
@robertjwhitney
robertjwhitney / gist:1207453
Created September 9, 2011 22:03 — forked from ekampf/gist:847741
A ruby snippet to sanitize Html (and specifically Microsoft Word's messy HTML) (based on https://gist.github.com/139987)
# This function cleans up messy HTML that was pasted by a user to a WYSIWYG editor.
# Specifically it also handles messy Word\Outlook generated HTML while keeping its original formattings.
require 'rubygems'
require 'sanitize'
def clean_up_document(html)
elements = %w[p b h1 h2 h3 h4 h5 h6 strong li ul ol i br div pre p]
attributes = {
'a' => ['href', 'title'],
@robertjwhitney
robertjwhitney / gist:1012440
Created June 7, 2011 15:07
extrating a bunch of images in subfolders
require 'fileutils'
@files = Dir.glob('/Users/BobW/desktop/test/*/*')
@files.each do |file|
FileUtils.mv(file, '/Users/BobW/desktop/test2')
end
@robertjwhitney
robertjwhitney / yui_compressor.rb
Created April 28, 2011 14:46 — forked from seth/yui_compressor.rb
A Nanoc filter for minifying CSS and Javascript using the YUI Compressor
YUI_JAR = File.dirname(__FILE__) + "/../tools/yuicompressor-2.4.2.jar"
class YuiCompressor < Nanoc3::Filter
identifier :yui_compress
type :text => :binary
def run(content, params={})
type = type_from_extension
cmd = "java -jar #{YUI_JAR} --type #{type} -o #{output_filename}"
IO.popen(cmd, 'w') { |f| f.write(content) }
raise "yuicompressor exited with #{$?} for '#{cmd}'" unless $? == 0

Michael M. upgrading...

dupdraded

Jack C. i dont feel any different

Michael M. it takes a minute to propagate to NJ

Winter L. has left the room

@robertjwhitney
robertjwhitney / download.rb
Created February 3, 2011 17:17
simple script to download an array of images over http
require 'net/http'
require 'yaml'
files = YAML.load_file("image_list.yml")
i = 1
files.each do |file|
# use root url without protocol
response = Net::HTTP.start("farm5.static.flickr.com") do |http|
http.get("#{file}")
end
puts "#{response}"
%style{:type=>"text/css"}
:sass
#myCustomElement
background: ##{current_user.color}
background = "-webkit-gradient(linear, left top, left bottom, from(##{current_user.color}), to(" + (##{current_user.color} - #222) + "))"
alias fuckit="git add . && git commit -m 'Throwaway commit' && git reset --hard HEAD^"
<div id='container'>
<!-- all your normal page content goes in here -->
</div>
# MacPorts Installer addition on 2008-12-17_at_17:36:30: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# MacPorts Installer addition on 2008-12-17_at_17:36:30: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.
# Setting PATH for MacPython 2.6