Skip to content

Instantly share code, notes, and snippets.

View cibernox's full-sized avatar
🏠
Working from home

Miguel Camba cibernox

🏠
Working from home
View GitHub Profile
require 'set'
def loquesea
g << :uno
g << :dos
end
@cibernox
cibernox / gist:1376256
Created November 18, 2011 11:54
rspec problem with mocks and before_create
# The spec
let(:stamp){ mock_model(CompanyStamp) }
let(:signature){ mock_model(CompanyHandwrittenSignature) }
let(:account) { mock_model(Account, :company_handwritten_signature => signature, :company_stamp => stamp) }
it "should have signature if the account has signature" do
subject.account = account
subject.stub(:save).and_return(true)
subject.company_handwritten_signature.should == signature
end
@cibernox
cibernox / error_output
Created December 24, 2011 14:54
Error message building native extensions, using ruby 1.9.3-p0
Installing capybara-webkit (0.7.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Teimas/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
/usr/bin/qmake
/usr/bin/make
cd src/ && /usr/bin/qmake /Users/Teimas/.rvm/gems/ruby-1.9.3-p0@teixo_ruby19/gems/capybara-webkit-0.7.2/src/webkit_server.pro -spec /usr/local/Qt4.7/mkspecs/macx-g++ -o Makefile.webkit_server
/usr/bin/make
cd src/ && make -f Makefile.webkit_server
g++ -c -pipe -g -gdwarf-2 -Wall -W -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.7/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtNetwork.framework/Versions/4/Headers -I/usr/include/QtNetwork -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/Library/Frameworks/QtWebKit.framework/Versions/4/Headers -I/usr/include/QtWebKit -I/usr/include -I. -F/Library/Frameworks -o main.o main.cpp
# I want to create an action that returns a chunked response, waiting 1 second between chunks.
# Honestly, I don't understand a single word of the documentation.
# Thats my code
defmodule ApplicationRouter do
use Dynamo.Router
prepare do
# Pick which parts of the request you want to fetch
# You can comment the line below if you don't need
require 'httparty'
require 'nokogiri'
USERNAME = "email-used@in-registration.com"
PASSWORD = "your-password-here"
COOKIE_FILE = 'cookies.txt' # by example
class RubytapasDownloader
FEED_URL = "https://rubytapas.dpdcart.com/feed"
LOGIN_URL = "http://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=8f511233-b72b-4a8c-8c37-fadc74fbc3a1"
#!/usr/bin/env ruby
# vim: set syntax=ruby
# Ensures that changes to the Rails schema.rb file may only be committed if a
# migration file is also committed at the same time.
def schema_modified?
%x[ git diff --cached |grep schema.rb ] == ''
end
@cibernox
cibernox / gist:6061265
Created July 23, 2013 09:52
Install git subtree in mac
# This steps is for git 1.8.X in mac, installed bien binary package http://git-scm.com/download/mac
# Clone git source
git clone git@github.com:git/git.git
# Make & install
cd git/contrib/subtree
make
sudo make prefix=/usr/local/git install
# Git subtree usage
# Commit your changes as you always did
git add .
git commit -m "Some changes"
# From time to time, you can submit all the changes you made in the folder of your subproject to the main project.
git subtree push -f --prefix=app/assets/javascripts/gmapp/models/ goldenmanager-ember-models master
# Also, from time to time you should pick changes from the subtree remote
@cibernox
cibernox / iter2_tab_color.sh
Created July 25, 2013 15:23
Script that changes the color of the iterm2 tab depending on the folder i am working on
# Usage:
# source iterm2.zsh
# iTerm2 window/tab color commands
# Requires iTerm2 >= Build 1.0.0.20110804
# http://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
echo -ne "\033]6;1;bg;blue;brightness;$3\a"
@cibernox
cibernox / gist:6360340
Created August 27, 2013 23:26
Chrome dev tools awesome trick
console.log('%c ', 'background:url(http://img1.imensagens.com/en/rainbow/2.gif) no-repeat; line-height: 15rem; font-size: 130px;');