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
| # recursive Hash#clone extension, because I needed it! | |
| class Hash | |
| def clone(recursive = false) | |
| return super() unless recursive | |
| new_hash = {} | |
| for k, v in self | |
| key = k.is_a?(Hash) ? k.clone(true) : (k.clone rescue k) |
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
| # having a pretty dump/print of Hash objects, for debugging clarity purposes (for the sake of having a sane Hash debugging) | |
| class Hash | |
| def to_s(pretty = false) | |
| return super() unless pretty | |
| indent = lambda do |hash, tabs| | |
| tabs += 1 if tabs == 0 | |
| indentation = "\t" * tabs | |
| indented_output = [] |
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
| " checksyntax.vim -- Check syntax when saving a file (php, ruby, tex ...) | |
| " @Author: Tom Link (micathom AT gmail com) | |
| " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) | |
| " @Created: 04-Mai-2005. | |
| " @Last Change: 2009-08-31. | |
| " @Revision: 356 | |
| if exists('g:checksyntax') | |
| finish | |
| endif |
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
| " Delete buffer while keeping window layout (don't close buffer's windows). | |
| " Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165 | |
| if v:version < 700 || exists('loaded_bclose') || &cp | |
| finish | |
| endif | |
| let loaded_bclose = 1 | |
| if !exists('bclose_multiple') | |
| let bclose_multiple = 1 | |
| endif |
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
| require 'json' | |
| require 'hpricot' | |
| require 'open-uri' | |
| module Rublickr | |
| AUTH_URL = 'http://flickr.com/services/auth/'.freeze | |
| API_URL = 'http://api.flickr.com/services/rest/'.freeze | |
| # USAGE |
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
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: nginx | |
| # Required-Start: $all | |
| # Required-Stop: $all | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the nginx web server | |
| # Description: starts nginx using start-stop-daemon |
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 | |
| # Usage: gemspec [-s] GEMNAME | |
| # | |
| # Prints a basic gemspec for GEMNAME based on your git-config info. | |
| # If -s is passed, saves it as a GEMNAME.gemspec in the current | |
| # directory. Otherwise prints to standard output. | |
| # | |
| # Once you check this gemspec into your project, releasing a new gem | |
| # is dead simple: | |
| # |
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
| #!/bin/sh | |
| # Usage: unicorn_github | |
| # Script used to start unicorn in GitHub staging and production environments. | |
| # This is called primarily by god. | |
| set -e | |
| # configure GC settings | |
| export RUBY_HEAP_MIN_SLOTS=800000 | |
| export RUBY_HEAP_FREE_MIN=100000 | |
| export RUBY_HEAP_SLOTS_INCREMENT=300000 |
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 Hash | |
| def hash_from(*keys) | |
| keys.inject({}) { |memo, obj| memo.merge(obj => self[obj]) } | |
| end | |
| end | |
| # example: | |
| # >> a = {:foo => 1, :bar => 2, :foobar => 3} |
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
| require 'benchmark' | |
| class Hash | |
| def hash_from_1(*keys) | |
| keys.inject({}) { |memo, obj| memo.merge(obj => self[obj]) } | |
| end | |
| def hash_from_2(*keys) | |
| self.dup.delete_if { |k, v| !keys.include? k } |