Skip to content

Instantly share code, notes, and snippets.

View filipebarcos's full-sized avatar

Filipe Costa filipebarcos

View GitHub Profile
@filipebarcos
filipebarcos / das.rb
Created April 4, 2014 23:19
first piece of code with my new das keyboard
module ClassMethods
def self.method2
end
end
module InstanceMethods
def method1
end
end
require 'benchmark'
n = 1000000
Benchmark.bm(15) do |x|
x.report("assign single") { n.times do; c = 'a string'; end}
x.report("assign double") { n.times do; c = "a string"; end}
x.report("concat single") { n.times do; 'a string ' + 'b string'; end}
x.report("concat double") { n.times do; "a string " + "b string"; end}
end
@filipebarcos
filipebarcos / configure-apache.txt
Last active August 29, 2015 14:07
Quick-simple script to upgrade ruby version on a server using RVM and Phusion Passenger.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.57/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.57
PassengerDefaultRuby /home/ubuntu/.rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>
After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!
require 'benchmark/ips'
Benchmark.ips do |x|
x.report("with lazy") do
(1..1_000_000).lazy
.select(&:odd?)
.map(&:to_s)
.take(1000)
end
@filipebarcos
filipebarcos / start_postgres.sh
Created June 26, 2012 03:23
Script to Run PostgreSQL on my Mac
#! /usr/bin/env bash
sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl start -D /Library/PostgreSQL/9.1/data
@filipebarcos
filipebarcos / stop_postgres.sh
Created June 26, 2012 03:24
Script to Stop PostgreSQL on my Mac
#! /usr/bin/env bash
sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl stop -D /Library/PostgreSQL/9.1/data -m fast
@filipebarcos
filipebarcos / .bash_profile
Created June 29, 2012 20:19
My .bash_profile configuration
#export
export EC2_HOME=$HOME/.ec2/ec2-api-tools
export MAVEN_HOME=$HOME/Desenvolvimento/apache-maven-3.0.3/
export RUBY_HOME=/usr/local/Cellar/ruby/1.9.3-p125
export PATH=$MAVEN_HOME/bin:$JAVA_HOME/bin:/usr/local/mysql/bin:$RUBY_HOME/bin:$EC2_HOME/bin:$PATH
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="4;33"
export CLICOLOR="auto"
export PS1='\n[\u] \[\033[1;33m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\] \n\$ '
@filipebarcos
filipebarcos / Tutorial.md
Created October 28, 2012 04:50
Create an Automator Services to open files and folder on VIM

If you use VIM you are like me, uses VIM as IDE, this workflow can be useful for you. I create an workflow using Automator to open the selected folder on Finder to be opened using VIM.

  1. Go to Automator and create a new Service
  2. Go to Actions/Utilities and select "Run Apple Script"
  3. On Services options, select the following options:
    1. Service receiver selected FOLDER AND FILES in FINDER.APP
  4. Copy the following apple script and save it.
  5. Voila! Test it and be happy ;)
@filipebarcos
filipebarcos / checking_ckeckboxes.js
Created October 29, 2012 16:21
Check all checkboxes in a form
$.each($('input:checkbox'), function(key, elem) {
$(elem).attr('checked', 'checked');
});