This file contains hidden or 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 Enumerable | |
| def build_hash | |
| inject({}) do |h,elem| | |
| yield h, elem; | |
| h | |
| end | |
| end | |
| end |
This file contains hidden or 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
| $ irb | |
| >> class Foo | |
| >> def self.bob=(v) | |
| >> @bob = v | |
| >> end | |
| >> def self.bob | |
| >> @bob | |
| >> end | |
| >> end | |
| => nil |
This file contains hidden or 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 | |
| # | |
| # written while macports compiles gnome stuff in order to install ffmpeg | |
| # | |
| # usage: portgraph <portname> | |
| # | |
| # $ ./portgraph ffmpeg > tmp.dot && dot -T pdf tmp.dot > out.pdf && open out.pdf | |
| # | |
| # if you want something that actually works: | |
| # http://svn.macports.org/repository/macports/contrib/port-rdeps/port-rdeps |
This file contains hidden or 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
| Postgres: 8.3.5 | |
| Ruby: 2.3.2 | |
| Postgres-Adapter: pg (0.8.0) | |
| on OS X 10.5 | |
| $ psql | |
| Welcome to psql 8.3.5, the PostgreSQL interactive terminal. | |
| postgres=# CREATE TABLE widgets ( name varchar, amount integer, size integer, weight integer); |
This file contains hidden or 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
| task :rebuild_config => :app_env do | |
| config = ThinkingSphinx::Configuration.instance | |
| file config.config_file do |f| | |
| puts "Regenerating Configuration to #{config.config_file}" | |
| config.build | |
| end | |
| Rake::Task[config.config_file].invoke | |
| end | |
| task :start => :rebuild_config |
This file contains hidden or 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
| class Object | |
| def if_empty | |
| yield if empty? | |
| self | |
| end | |
| end |
This file contains hidden or 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 | |
| require 'rubygems' | |
| require 'net/https' | |
| require 'uri' | |
| require 'json' | |
| require 'enumerator' | |
| require "daemons" | |
| # EDIT POST_RECEIVE_URL |
This file contains hidden or 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
| # this is an ugly hack | |
| When /^the spinx index is updated$/ do | |
| ThinkingSphinx::Configuration.instance.build | |
| unless ThinkingSphinx.sphinx_running? | |
| `rake ts:config ts:index ts:run RAILS_ENV=test` | |
| end | |
| assert ThinkingSphinx.sphinx_running? |
This file contains hidden or 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
| def foo(*args) | |
| p args | |
| end | |
| foo(<<ONE,<<TWO, "three") #=> ["one\n","two\n",three"] | |
| one | |
| ONE | |
| two | |
| TWO |
This file contains hidden or 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
| # | |
| # bash completion support for core Git. | |
| # | |
| # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
| # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
| # Distributed under the GNU General Public License, version 2.0. | |
| # | |
| # The contained completion routines provide support for completing: | |
| # | |
| # *) local and remote branch names |