This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for video in $* | |
do | |
dimension=`exiftool "$video" | grep 'Image Size' | while read a b c d; do echo $d; done` | |
ffmpeg -i "$video" -s $dimension -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=7 > "$video.gif" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'socket' | |
require 'fileutils' | |
if ENV['MAC_HOST'] && ENV['MAC_PORT'] | |
if child_pid = fork | |
loop do | |
begin | |
puts "Connecting..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJECT=$1 | |
GITPATH=$2 | |
if test -z "$PROJECT" || test -z "$GITPATH" | |
then | |
echo Usage: $0 project gitpath | |
exit 1 | |
fi | |
git remote add -f $PROJECT $GITPATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# place this file in the directory you want to keep the backup | |
# mysqldumps. this script lets you retrieve dumps of last 7 days, | |
# last month or any year | |
# | |
BACKUP_DB=app_production | |
cd `dirname $0` | |
mysqldump $BACKUP_DB -u root > today.sql && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var searchtext = $('.searchtext')[0]; | |
function slow_hunt_for_ie(items, index) { | |
items = items || $('#ele, #ele *'); | |
index = index || 0; | |
searchtext.value = index; | |
var max = index + 5; | |
for (; index < max && index < items.length; index++) { | |
$(items[index]).css({ | |
border: '1px #000 solid', | |
margin: '0px', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modified from http://errtheblog.com/posts/50-vendor-everything | |
Dir["#{File.join(File.dirname(__FILE__), '..')}/vendor/gems/**"].map do |dir| | |
require_paths_file = File.join(dir, ".require_paths") | |
paths = File.exists?(require_paths_file) ? | |
IO.read(require_paths_file).split(/[\r\n]+/).collect {|subdir| File.join(dir, subdir) } : | |
[(File.directory?(lib = "#{dir}/lib") ? lib : dir)] | |
$LOAD_PATH.unshift(*paths) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BigurlsController < ApplicationController | |
def index | |
url = URI.parse(params[:url]) | |
res = Net::HTTP.start(url.host, url.port) {|http| http.get([url.path, url.query].compact.join('?'), "User-Agent" => request.user_agent) } | |
render :text => (res['location'] || params[:url]) | |
rescue | |
"#{params[:url]}##{$!.to_s}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Append this content into ~/.irbrc | |
# | |
# irb console prompt to make the output copy-paste friendly | |
# overrides :simple for use in Rails' script/console | |
# overrides :default for use in regular irb session | |
IRB.conf[:PROMPT][:SIMPLE] = IRB.conf[:PROMPT][:DEFAULT] = { | |
:PROMPT_I => "\"%N(%m):%03n:%i>\"; ", # normal prompt: an inconsequential statement, a string | |
:PROMPT_S => "", # prompt for continuing strings: nothing | |
:PROMPT_C => "", # prompt for continuing statement: nothing | |
:RETURN => "#=> %s\n" # return value output is commented to not disrupt the code flow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This controller illustrates the problem of Rails sending "Set-Cookie" back to the client | |
# when cookie-store is being used -- even when session data has NOT changed. | |
class HomeController < ApplicationController | |
def index | |
%w[one two three four five six].each do |word| | |
session[word] = word | |
end | |
render :text => "<a href='#{url_for(:action => 'show')}'>click here</a>" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def simple_inline_css(html, *css_files) | |
doc = Hpricot(html) | |
css_files.each do |css_file| | |
css_content_without_comments = IO.read(css_file).gsub(/\/\*.*?\*\//m, '') | |
css_content_without_comments.split('}').each do |rule| | |
(match, properties) = rule.split('{') | |
next unless properties | |
match.gsub!(/^\s*|\s*$/, '') | |
properties.gsub!(/^\s*|\s*$/, '') | |
(doc/match).each do |ele| |