Skip to content

Instantly share code, notes, and snippets.

View viniciussbs's full-sized avatar

Vinícius Sales viniciussbs

  • Rio de Janeiro, Brasil
View GitHub Profile
class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
@viniciussbs
viniciussbs / external_url_helper.rb
Created May 14, 2014 19:45
External URL helpers example
module ExternalUrlHelper
def google_url
"www.google.com"
end
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
def bound(number, max, min = 0)
[min, number, max].sort[1]
end
ActiveAdmin.register Milestone do
scope :all, :default => true
scope :global
scope :user_specific
index do
column :title
column :description
column :required_litres
column :is_active
@viniciussbs
viniciussbs / dev.conf
Created November 5, 2012 20:21 — forked from fnando/dev.conf
Nginx configuration for SSH tunnel
upstream tunnel {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name dev.codeplane.com br.dev.codeplane.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
@viniciussbs
viniciussbs / gist:1947027
Created March 1, 2012 03:27
Initial Stack for Ubuntu 10.04 LTS (Lucid) - Rails with Nginx
Tutorial by @alobato:
Initial Stack for Ubuntu 10.04 LTS (Lucid) - Rails with Nginx
https://gist.github.com/1942842
Wget 1.12
Curl 7.19.7
Git 1.7.0.4
Ruby 1.9.3p125
RubyGems 1.8.17
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
# or just go to http://localhost:4567/user/filename with a browser
get '/:name/:filename' do

JavaScript Timer

Run 5 times, with one second delay between calls

t1 = new Timer(500, function(){
  console.log(this.count);
  if (this.count >= 5) {
    this.stop();
  }

});

@viniciussbs
viniciussbs / if_each_else.rb
Created November 10, 2010 04:04
if else for each without extra lines
a = [1, 2]
if a.each do |i|
puts i
end.empty?
puts "Empty"
end