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
@viniciussbs
viniciussbs / fixnum_utilities.rb
Created May 21, 2010 23:41
Utilities for the class Fixnum
class Fixnum
# Convert a number in seconds to minutes (mm:ss)
def to_minutes
Time.at(self).gmtime.strftime('%M:%S')
end
end
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense que, porque você sentou 4
anos numa faculdade ouvindo um professor falar sobre software, você
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
aula. Ele pratica. Instrumentistas geniais não aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da
#installing
sudo aptitude install apache2 -y
sudo aptitude install php5 -y
sudo aptitude install libapache2-mod-php5 -y
sudo aptitude install mysql-server
#checking Apache and MySQL
sudo netstat -tap | grep apache
sudo netstat -tap | grep mysql
def invert(code)
"#{code[1].chr}#{code[0].chr}"
end
def encrypt(zipcode)
codes = {
"00" => "AL",
"01" => "UG",
"10" => "CN",
"11" => "X8",
@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

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();
  }

});

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
@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
@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;
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