Skip to content

Instantly share code, notes, and snippets.

:shipit:
Shippin Stuffs 🚀

Peter Schröder phoet

:shipit:
Shippin Stuffs 🚀
Block or report user

Report or block phoet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@phoet
phoet / nil_or.rb
Created Jun 28, 2009
nil-or example
View nil_or.rb
# Creates an object you can savely traverse without getting nil.
# This is very pleasant for deep data-structures.
# You can punch the duck until it should become a string:
# NilOr.new(nil).what.the.fuck?.to_s --> nil
class NilOr
def initialize(object, parent = nil)
@object = object
@call_stack = (parent || [])
puts "current stack #{@call_stack}"
@phoet
phoet / i_dont_give_a_shit.rb
Created Aug 24, 2009
example of i don't give a shit gem
View i_dont_give_a_shit.rb
alias :method_missing_i_dont_give_a_shit :method_missing
def method_missing(sym,*args, &block)
puts "sym is #{sym}"
method_name = sym.to_s
if /.+\?$/ =~ method_name
puts "i dont care"
target_method = method_name[0..-2]
puts "target is #{target_method}"
puts self.class
@phoet
phoet / bindings.xml
Created Apr 29, 2010
jaxws definitions that work
View bindings.xml
<jaxws:bindings version="2.1" wsdlLocation="service.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://java.sun.com/xml/ns/jaxws" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb">
<enableWrapperStyle>false</enableWrapperStyle>
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://authentication.integration.crowd.atlassian.com']">
<jxb:globalBindings generateElementProperty="false">
@phoet
phoet / analytics.sh
Created Apr 29, 2010
open multiple google analytics accounts
View analytics.sh
#! /usr/bin/env ruby
[25021834, 18768647].each do |product_id|
url = "https://www.google.com/analytics/reporting/?reset=1&id=#{product_id}&pdr=#{(Time.now - (7 * 60 * 60 * 24)).strftime("%Y%m%d")}-#{Time.now.strftime("%Y%m%d")}"
`open "#{url}"`
end
@phoet
phoet / git_and_brew.sh
Created Jul 1, 2010
git and homebrew via curl
View git_and_brew.sh
# thx to tobstarr
sudo mkdir -p /usr/local && sudo chown -R $USER /usr/local && curl -Lsf http://bit.ly/9H4NXH | tar xvz -C/usr/local --strip 1 && brew install git
@phoet
phoet / talk.sh
Created Aug 24, 2010
using applescript for adium
View talk.sh
#! /usr/bin/env ruby
users = {
:rubiii => 'daniel.harrington',
:tri => 'thilko.richter',
}
user = users[ARGV.shift.to_sym]
message = ARGV.join(' ')
@phoet
phoet / rails_admin_without_devise.rb
Created Dec 17, 2010
Using RailsAdmin without devise
View rails_admin_without_devise.rb
# add RailsAdmin to the Gemfile
# do NOT add devise
gem "rails_admin", :git => "git://github.com/sferik/rails_admin.git"
# run Bundler
bundle
# run the generator for RailsAdmin
# looks like it's broken, but it just does not install devise
# you may also remove the app/config/locales/devise.en.yml
@phoet
phoet / Gemfile.rb
Created Jan 30, 2011
Gemfile fuckup
View Gemfile.rb
source :gemcutter
gem "rails", "~> 3.0.3"
gem "rails_redis_cache", "~> 0.0.4"
gem "haml", "~> 3.0.25"
gem "hashie", "~> 1.0.0"
gem "asin", "~> 0.2.0" # hashie 1.0.0
gem "twitter", "~> 1.1.1" # hashie 0.4.0
gem "coderay", "~> 0.9.3"
@phoet
phoet / action_view_base.rb
Created Apr 6, 2011
initializer for helping to find partials in large applications
View action_view_base.rb
if development?
module ActionView
class Base
alias_method :rails_render, :render
# add debugging comments for partials to the rendered html
def render(options = {}, local_assigns = {}, &block)
output = rails_render(options, local_assigns, &block)
if options.respond_to?(:keys) && options[:partial] && (response.content_type.nil? || response.content_type =~ /html/)
@phoet
phoet / dsl.rb
Created Apr 12, 2011
examples of dsl api stuff
View dsl.rb
# encoding utf-8
module DSL
link_to "Articles", { :controller => "articles" }, :id => "news", :class => "article"
def doit_with(some, parameters)
# does it
end
def doit_with(mandatory, optional=nil, parameters=nil)
You can’t perform that action at this time.