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 Fixnum | |
def fizz_buzz? | |
self.fizz? and self.buzz? | |
end | |
def fizz? | |
self % 3 == 0 | |
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
#!/bin/sh | |
exec ruby -x "$0" "$@" | |
#!ruby -w | |
class Foo | |
attr_accessor :bar | |
end | |
# instance | |
foo = Foo.new |
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
### | |
# Allowable | |
# | |
# A pattern for decomposing large/long conditional chains | |
# into readable, testable, and inspectable segments. | |
# Code coverage stats can help show you which conditions | |
# aren't getting test coverage, and printing/prying around | |
# the code can show you intermediary condition results. | |
# | |
# Effectively a block-syntax for the `or` operator: each `when?` |
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
# | |
# Executes commands at the start of an interactive session. | |
# | |
# Authors: | |
# Sorin Ionescu <[email protected]> | |
# | |
# Source Prezto. | |
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then | |
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" |
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 works as of Mongoid v3 | |
Model.collection.database.command(geoNear: "models", near: [50, 50]) |
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 'fileutils' | |
require 'tempfile' | |
def replace_in_file(filename,oldvalue,newvalue) | |
temp_file = Tempfile.new(File.basename(filename)) | |
contents = File.read(filename) | |
changed_contents = contents.gsub(oldvalue,newvalue).gsub(oldvalue.downcase,newvalue.downcase) | |
temp_file.print(changed_contents) |
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
# | |
# = Capistrano database.yml task | |
# | |
# Provides a couple of tasks for creating the database.yml | |
# configuration file dynamically when deploy:setup is run. | |
# | |
# Category:: Capistrano | |
# Package:: Database | |
# Author:: Simone Carletti <[email protected]> | |
# Copyright:: 2007-2010 The Authors |
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 Xyz.TestModel extends Batman.Model | |
save: (options, callback) -> | |
super options, (err, record, env) => | |
console?.log record | |
testModel = new Xyz.TestModel() | |
testmodel.save null, (err) -> |
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
<?php | |
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") { | |
$msg = "<22>" . date('M j H:i:s ') . $program . ' ' . $component . ': ' . $message; | |
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); | |
# replace these with settings provided by Papertrail | |
socket_sendto($sock, $msg, strlen($msg), 0, 'logs.papertrailapp.com', 1111); | |
socket_close($sock); | |
} |
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
# Mixin to aid the compilation of routes | |
# | |
# PLEASE NOTE, this does not work with collections or nested routes/resources | |
# | |
# @mixin | |
# @author Vincent Siebert <[email protected]> | |
# @copyright (c) 2012 The Beans Group Ltd | |
Batman.mixin Batman.Filters, | |
# Filter to aid the compilation of non CRUD routes. Unfortunately because there is no way of resolving a keypath in an object when passing |