View eyetv_xmltv_grabber.rb
#!/usr/bin/env ruby | |
# SweDB XMLTV Grabber for EyeTV | |
# by Henrik Nyh <http://henrik.nyh.se> under the MIT License. | |
# | |
# INSTALLATION | |
# | |
# Configure the list of channels below and run this script as a cron job, e.g. | |
# | |
# 0 */12 * * * ruby /path/to/this/script.rb |
View gist:27428
require 'net/http' | |
require 'digest/md5' | |
# Is there a Gravatar for this email? | |
def gravatar?(email) | |
hash = Digest::MD5.hexdigest(email.to_s.downcase) | |
response = Net::HTTP.new('www.gravatar.com', 80).request_head("/avatar/#{hash}?size=1&default=.") | |
response.code != '302' | |
end |
View Ensure Image Extension.scpt
on adding folder items to myFolder after receiving myFiles | |
repeat with myFile in myFiles | |
set myPath to (POSIX path of myFile) | |
set myType to do shell script "file --mime-type -br " & (quoted form of myPath) | |
if myType is "image/jpeg" and myPath does not end with ".jpg" and myPath does not end with ".jpeg" then | |
set newExtension to ".jpg" | |
else if myType is "image/gif" and myPath does not end with ".gif" then | |
set newExtension to ".gif" |
View unsimple_format.rb
# From Rails | |
def simple_format(text, html_options={}) | |
start_tag = '<p>' | |
text = text.to_s.dup | |
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n | |
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph | |
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br | |
text.insert 0, start_tag | |
text << "</p>" | |
end |
View init.rb
Merb::BootLoader.before_app_loads do | |
# This will get executed after dependencies have been loaded but before your app's classes have loaded. | |
require 'config/settings' | |
end |
View .bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
View rails_ext.rb
module ActiveSupport::Inflector | |
# Parameterize "Foo's and Charles's bar" into "foos-and-charles-bar" | |
# instead of into "foo-s-and-charles-s-bar". | |
def parameterize_with_apostrophe_removal(string, sep = '-') | |
string = string.dup | |
string.gsub!(%r{s's\b}i, 's') | |
string.gsub!(%{'}, "") | |
parameterize_without_apostrophe_removal(string, sep) | |
end |
View back.sh
#!/bin/bash | |
ssh hyper "osascript -e 'tell app \"iTunes\" to back track'" |
View .irbrc
# http://pablotron.org/software/wirble/ | |
# Provides "ri", history survives restart etc | |
require 'rubygems' | |
require 'wirble' | |
Wirble.init | |
# http://www.quotedprintable.com/2007/9/13/my-irbrc | |
# Show rails root in script/console prompt | |
require 'irb/completion' |
View httpd-vhosts.conf
# Make Apache with enabled mod_proxy forward http://ak.dev/foo | |
# to http://ak.dev:3000/foo for use in local Rails development. | |
<VirtualHost *:80> | |
ServerName ak.dev | |
RewriteEngine on | |
RewriteRule /(.*) http://localhost:3000/$1 [P] | |
</VirtualHost> |
OlderNewer