Skip to content

Instantly share code, notes, and snippets.

View schmijos's full-sized avatar

Josua Schmid schmijos

View GitHub Profile
@matthewrudy
matthewrudy / delegation_with_default.rb
Created February 4, 2009 10:48
Rails "delegate" with a :default
class Module
# Provides a delegate class method to easily expose contained objects' methods
# as your own. Pass one or more methods (specified as symbols or strings)
# and the name of the target object as the final :to option (also a symbol
# or string). At least one method and the :to option are required.
#
# Delegation is particularly useful with Active Record associations:
#
# class Greeter < ActiveRecord::Base
# def hello() "hello" end
require "benchmark"
require "fileutils"
def test
path = "/tmp/faketest"
FileUtils.mkdir_p("#{path}/public/stylesheets")
FileUtils.mkdir_p("#{path}/public/javascripts")
FileUtils.mkdir_p("#{path}/public/images")
FileUtils.mkdir_p("#{path}/views/templates")
FileUtils.mkdir_p("#{path}/views/layouts")
@gabehollombe
gabehollombe / Capybara CSS Visibility Testing
Created May 14, 2010 05:13
Testing text visibility on page with capybara
#relevant lines in features/support/env.rb
Capybara.default_selector = :css
Capybara.javascript_driver = :culerity
Capybara.ignore_hidden_elements = true
#features/hidden_text_testing.feature
@javascript
Scenario: Testing test hidden via inline style with 'should not see'
When I visit the the public index.html page
Then I should not see "Hidden Via Comment"
Ruby 1.9.0.0 compile error (openssl problem)
TAGS: None
Found these error:
view sourceprint?
compiling openssl
gcc -I. -I../../.ext/include/i686-darwin10.2.0 -I../.././include -I../.././ext/openssl -DRUBY_EXTCONF_H=\"extconf.h\" -fno-common -g -O2 -pipe -fno-common -o openssl_missing.o -c openssl_missing.c
In file included from openssl_missing.c:22:
@aishfenton
aishfenton / serializer_benchmarks.rb
Created July 18, 2010 02:32 — forked from visfleet/performance_of_yaml_vs_marshal.rb
Performance comparison of different ruby serializer methods
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'
@peterc
peterc / dnsd.rb
Created December 2, 2011 23:47
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@agarciadelrio
agarciadelrio / active_admin.js
Created April 17, 2012 20:30
Getting active_admin panels become collapsable with non-intrusive javascript with jquery
//....add this in app/assets/javascript/active_admin.js
$(function(){
// CONFIGURE PANELS COLLAPSER
$(".panel[data-panel]").each(function(){
var $this = $(this);
var $a = $("<a href='javascript:void(null)'>").on("click",function(event){
$(this).closest(".panel").find(".panel_contents").each(function(){
$(this).slideToggle();
});
$(this).closest("h3").each(function(){
@kristofferh
kristofferh / opendiff.txt
Created June 8, 2012 14:24
Open FileMerge from command line
Open FileMerge from command line
opendiff
If the command-line doesn't work, and you have no /Developer directory anymore, you probably need to:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
@IanVaughan
IanVaughan / uninstall_gems.sh
Created June 9, 2012 20:37
Uninstall all rbenv gems
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
@Steven-Rose
Steven-Rose / gist:3943830
Created October 24, 2012 04:27
VI: Select all + delete, select all + copy
Select all and delete (actually move to buffer)
:%d
Select all and copy to buffer
:%y
Use p to paste the buffer.