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 | |
# 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 |
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 '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 |
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
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" |
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
# 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 |
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
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 |
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
# 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)]/" |
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
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 |
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 | |
ssh hyper "osascript -e 'tell app \"iTunes\" to back track'" |
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
# 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' |
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
# 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