Skip to content

Instantly share code, notes, and snippets.

View czottmann's full-sized avatar
💭
Sure.

Carlo Zottmann czottmann

💭
Sure.
View GitHub Profile
def show
@xyz = Xyz.find( params[:id] )
if @xyz
# render page
else
# render error template or redirect to error page
end
end
[http://feeds.feedburner.com/Flickrblog]
name = Flickr Blog
face = flickr.gif
facewidth = 106
faceheight = 35
[http://blog.360.yahoo.com/rss-1qCkw2Ehaak.hdNZkEAzDrpa4Q--?cq=1]
name = Y! 360 US Blog
face = y_360.gif
facewidth = 195
class SomeModel < ActiveRecord::Base
serialize :data
xss_terminate :except => [:data]
end
class CreateRelationships < ActiveRecord::Migration
def self.up
create_table :relationships do |t|
t.integer :user_id
t.integer :following_id
t.timestamps
end
add_index( :relationships, [ :user_id, :following_id ], :unique => true )
class UserSession < Authlogic::Session::Base
last_request_at_threshold 43200
end
class UserSessionsController < ApplicationController
# ...
def rpx_token
data = RPXNow.user_data( params[:token], RPX_API_KEY )
if data.blank?
flash[:error] = I18n.t("auth.failed")
redirect_to(new_user_session_path)
-- http://bbs.applescript.net/viewtopic.php?id=22890
on formatDate(theFormat, theDate)
-- Example for `theDate`: "2007-10-23T17:54:23"
try
do shell script "/usr/local/bin/ruby -e 'require \"parsedate\"; puts Time.local(*ParseDate.parsedate(ARGV[1])).strftime(ARGV[0])' " & ¬
quoted form of theFormat & " " & quoted form of theDate
on error
-- The date could not be parsed
return false
end try
namespace :worker do
desc "Start Twitter worker."
task :start_v1 do
run "cd #{current_path} && rake worker:start" # funktioniert nicht
end
desc "Start Twitter worker."
task :start_v2 do
run "cd #{current_path} && ./script/runner ./jobs/twitter_fetcher.rb &" # funktioniert nicht
end
@czottmann
czottmann / Hamlize.rb
Created October 13, 2009 20:38
"Hamlize" Textmate command for quick-checking HAML syntax. Pretty handy once you've finetuned it a bit. http://bit.ly/h4hYd
#!/usr/local/bin/ruby
require "rubygems"
require "haml"
puts Haml::Engine.new( STDIN.read.gsub( /\t/, " " ), { :escape_html => true } ).render
@czottmann
czottmann / wordpress-to-tumblr.rb
Created October 14, 2009 20:14
Parses a Wordpress XML export file and imports the posts into Tumblr. See http://blog.zottmann.org/post/213103984/the-big-blog-move-on-2009 for info.
#!/usr/local/bin/ruby
require "hpricot"
require "net/http"
require "uri"
TUMBLR_USER = "user@example.com"
TUMBLR_PASS = "thepasswordlol"
TUMBLR_DOMAIN = "mytumblrsubdomain.tumblr.com"
ORIGINAL_DOMAIN = "http://myoriginaldomain.example.com/"