Skip to content

Instantly share code, notes, and snippets.

View sebastiandeutsch's full-sized avatar

Sebastian Deutsch sebastiandeutsch

View GitHub Profile
function fish_prompt -d 'Write out the prompt'
# is there a more elegant method to extract the ruby version?
printf '%s%s%s ' (set_color red --bold) (rbenv version | tr " " "\n" | sed -n 1p) (set_color normal)
printf '%s%s%s %s$ ' (set_color $fish_color_cwd --bold) (prompt_pwd) (set_color normal --bold) (fish_prompt_scm)
end
@sebastiandeutsch
sebastiandeutsch / deploy.rb
Created July 13, 2011 21:10
deploy.rb for node.js
set :stages, %w(production staging)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
set :application, "imgly-tracking"
set :domain, "node.9elements.com"
set :user, "imgly-tracking"
set :repository, "[email protected]:9elements/imgly-tracking.git"
set :use_sudo, false
Using rake (0.8.7)
Using Platform (0.4.0)
Using open4 (1.0.1)
Using POpen4 (0.1.4)
Using abstract (1.0.0)
Using activesupport (3.0.7)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.7)
Using erubis (2.6.6)
@sebastiandeutsch
sebastiandeutsch / gist:975320
Created May 16, 2011 20:37
Objective-C String Sanitizing (incomplete ;-)
- (NSString *)wl_stringBySanitizingString {
NSString *sanitizedString = [self stringByReplacingOccurrencesOfString:@"(" withString:@""];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@")" withString:@""];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@"/" withString:@""];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@"&" withString:@"and"];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@"?" withString:@""];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@"'" withString:@""];
sanitizedString = [sanitizedString stringByReplacingOccurrencesOfString:@"\"" withString:@""];
class AttachmentUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :s3
def s3_headers
content_type = {"Content-Type" => "application/octet-stream"}
if self.file.filename.match(/(\.jpg)|(\.jpeg)/)
content_type = {"Content-Type" => "image/jpeg"}
end
@sebastiandeutsch
sebastiandeutsch / gist:668188
Created November 8, 2010 20:12
Failed to install
Ensuring we have the latest version of cinderella installed
Password:
Cinderella installed successfully
sh: line 24: cinderella: command not found
sh: line 24: cinderella: command not found
sh: line 24: cinderella: command not found
Run started Mon Nov 8 21:07:05 CET 2010
/usr/local/homebrew/bin/ruby
/usr/local/homebrew/bin/gem
ERROR: While executing gem ... (Gem::InstallError)
# I wanted to
# define a class which has a foo method
# which can also be called from a block
# so you can spice it and call the super
# class method again
#
# thanks to banisterfiend, xxxxxx and coderr
# for helping me on this one
class Document
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.0.8/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb:43:in `write': closed stream (IOError)
from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.0.8/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb:43:in `send_string'
from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.0.8/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb:49:in `quit'
from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.0.8/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb:29:in `quit'
from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-0.0.8/common/src/rb/lib/selenium/webdriver/driver.rb:74:in `quit'
from ./features/support/paths.rb:12
I created a world object
module WebDriver
@@browser = nil
def self.extended(base)
@@browser = Selenium::WebDriver.for :firefox if @@browser.nil?
end
at_exit do