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 'cgi' | |
require 'uri' | |
PREFIX = "https://www.google.com/search?q=" | |
# Examples: | |
# http://www.google.ch/webhp?sourceid=chrome-instant&ix=sea&ie=UTF-8&ion=1#sclient=psy-ab&hl=de&site=webhp&source=hp&q=ruby%20parse%20url%20query&pbx=1&oq=&aq=&aqi=&aql=&gs_sm=&gs_upl=&fp=6c2025d738093ae5&ix=sea&ion=1&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1920&bih=1114 | |
# => https://www.google.com/search?q=ruby+parse+url+query |
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 | |
# -*- coding: utf-8 -*- | |
# See: https://gist.github.com/1933369 | |
# Filter for Haml files to convert %tag{:attr => "value"} into %tag(attr="value") | |
$tag_attr_order = { | |
"link" => %w( rel sizes href ), | |
"meta" => %w( name content ) |
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 | |
class Object | |
def > other # implication operator: false > true == true | |
if self == true or self == false | |
!self or other | |
else | |
super | |
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
selection = (ARGV[0] || 0).to_i | |
input = STDIN.readlines | |
if input[-1] | |
input[-1] += "\n" unless input[-1].end_with? "\n" | |
else | |
input << "\n" | |
end | |
whitespace_re = /^(\s*)/ | |
i = 0 | |
whitespace = selection == 0 ? "" : nil |
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
require 'csv' | |
# Please someone include this in the csv module proper. Thanks. | |
# Public domain. Author: Felix Rabe (heavily based on 1.9.3 stdlib csv docs) | |
class CSV | |
def CSV.unparse array | |
CSV.generate do |csv| | |
array.each { |i| csv << i } | |
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
find . -type f -name '*.java' | sort | while read fn ; do | |
echo "$fn" && | |
iconv -f ISO-8859-1 -t UTF-8 "$fn" -o "$fn.MOD" && | |
mv "$fn.MOD" "$fn" | |
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
Show hidden characters
# Get Sublime to use your rvm ruby... Change your ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build to this, replacing YOURUSERNAME: | |
{ | |
"cmd": [ | |
"bundle", "exec", "$HOME/.rvm/bin/rvm-auto-ruby", "$file" | |
], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.ruby" | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>This is a form example</title> | |
</head> | |
<body> | |
<h1>This is a form example</h1> | |
<form action="" method="post"> |
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 | |
# Public domain. Written by Felix Rabe in 2012. | |
# Timestamped grep-ing for log files and similar sources that provide no timestamps. | |
# Usage example (used for a Redmine 1.4 / Rails 2.3 project): | |
# tail -f log/production.log | timedgrep email | |
look_for="$1" |
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
function abspath() { | |
cd -P -- "$(dirname -- "$1")" && | |
echo "$(pwd -P)/$(basename -- "$1")" | |
} |
OlderNewer