Skip to content

Instantly share code, notes, and snippets.


Deivinson Tejeda deivinsontejeda

View GitHub Profile
anonymous / hammer
Created Mar 1, 2012
hammer prototype
View hammer
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
# Derived from <>
require 'rubygems'
require 'thor'
require 'thor/group'
module Hammer
View gist:3672976
var client = bayeux.getClient()
, channelKeyPrefix = "room:";
bayeux.bind('subscribe', function(clientId, channel){
redisClient.incr(channelKeyPrefix + channel, function(error, value){
client.publish(channel, {
event: 'user-change',
params: {
onlineUsers: value
bf4 /
Last active Dec 11, 2015
Some Ruby Learning Resources
shu0115 / file0.txt
Created Feb 25, 2013
Ruby 2.0.0-p0インストール(Mac OS X 10.8.2) ref:
View file0.txt
brew uninstall openssl
brew uninstall curl-ca-bundle
brew uninstall readline
# inspired from:
threshold=300 # after 5min of uptime, a job is considered 'stuck', to kill
function ps_etime_to_seconds() # cheers user000001 -
echo $1 | awk -F $':' -f <(cat - <<-'EOF'
dqminh / applause_formatter.rb
Last active Dec 18, 2015
rspec formatter that applause you when your tests pass
View applause_formatter.rb
require "rspec/core/formatters/progress_formatter"
class ApplauseFormatter < RSpec::Core::Formatters::ProgressFormatter
def initialize(output)
unless File.exists? "/tmp/applause.mp3"
p "Downloading applause for awesomeness"
system "wget -O /tmp/applause.mp3"
View json_formatter.rb
require 'json'
class JsonFormatter
METHODS = %w[start close stop start_dump dump_pending dump_failures dump_summary]
METHODS.each { |m| define_method(m) { |*a| } }
def initialize(out)
@output = out
@event_id = 0
@passed = true
bkeepers / gist:6002211
Last active Dec 19, 2015
I'm looking for a better pattern for defining a method that takes a single object or an array of objects as an argument, does something with them, and then returns either a single object or an Array depending on what was passed to it.
View gist:6002211
def dress(dog_or_dogs)
dressed_dogs = Array(dog_or_dogs).map {|dog| }
dog_or_dogs.respond_to?(:each) ? dressed_dogs : dressed_dogs.first
one_dog = dress(
all_my_dogs = dress([,,])
View bad_kitty.rb
# coding: utf-8
# Can ruby have method names have newlines/be crazy?
class BadKitty
FACE = "
/ @ @ \\
( > º < )
thelibrarian / Fixing XCode Command Line
Last active Nov 6, 2017
How to fix compile errors with the XCode command line tools on Mac OS X. Solves problems such as failing to find Framework header files (e.g. ruby.h).
View Fixing XCode Command Line

The Problem

If you have installed the standalone Command Line Tools for XCode on your Mac (i.e. without having installed), some of these tools can get a bit confused due to a couple of oversights on Apple's part in finalising the setup.

Note: all commands below will need to be run from an Administrator account, or by an account with appropriate permission in /etc/sudoers.

The Solution

1. Failing to Find Frameworks

Sometime when compiling against the preinstalled Frameworks (e.g. Ruby or Python), various tools will inexplicable fail to find header files that are quite clearly there. This is caused by the fact that no XCode has been selected for the command-line tools. Wait, I hear you cry, I don't have XCode installed! Indeed, but you nonetheless need to select one, and point it somewhere where the command line tools exist, like so