Skip to content

Instantly share code, notes, and snippets.

View breim's full-sized avatar
:shipit:

Henrique Breim breim

:shipit:
  • Barcelona, Spain
View GitHub Profile
@breim
breim / ruby_installation.rb
Created May 20, 2014 12:15
Instalando o ambiente Ruby On Rails
# Atualizar o sistema
sudo apt-get update
# Instale o cú rl ( haha )
sudo apt-get install curl
# Agora vai a rvm :)
curl -L https://get.rvm.io | bash -s stable
@breim
breim / elasticsearch.sh
Last active August 29, 2015 14:01
Elastic Search as a service
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.2.deb
sudo dpkg -i elasticsearch-1.4.2.deb
@breim
breim / digital_ocean.sh
Last active August 29, 2015 14:02
Rails server on Digital Ocean
Rodar webbrick em todas as pastas da sua maquina ;)
ruby -run -ehttpd . -p8000
#processador de imagens => sudo apt-get install imagemagick
#mysql2 need => sudo apt-get install libmysql-ruby libmysqlclient-dev
#MYSQL SERVER => sudo apt-get install mysql-server
#Nood js => sudo apt-get install nodejs
#Lib Java Runtime => sudo apt-get install libv8-dev
require 'mechanize'
agent = Mechanize.new.get("http://www.mepergunte.com/index_novas_respostas.php")
total = agent.links.count
total.times do |i|
puts agent.links[i].href
agent2 = Mechanize.new.get("http://www.mepergunte.com/"+ agent.links[i].href )
agent2.links.count.times do |j|
a = agent2.links[j].href.to_s && j
t = a[0].scan('http://mepergunte.s3.amazonaws.com/usuarios/')
puts t if t != []
@breim
breim / matrix.sh
Created June 20, 2014 12:13
Matrix Terminal in linux
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
@breim
breim / vnstat.php
Created July 1, 2014 21:23
Bandwidth consumption on digital ocean with vnstat
<?php
// sudo apt-get install vnstat
// sudo vnstat -u -i eth0
// sudo vnstat -i eth0
$results = shell_exec("vnstat -m --oneline");
$resultsArray = explode("\n", trim($results));
$servidorArray = explode(";", $resultsArray[0]);
$data = $servidorArray[2];
@breim
breim / 0_reuse_code.js
Created July 10, 2014 04:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@breim
breim / erro.rb
Created July 10, 2014 16:13
Erro no sidekiq
deploy@VilaDeFabiano:~/viladefabiano$ bundle exec sidekiq
2014-07-10T16:12:28Z 2270 TID-45f4w INFO: Booting Sidekiq 2.17.7 with redis options {}
2014-07-10T16:12:28Z 2270 TID-45f4w INFO: Running in ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
2014-07-10T16:12:28Z 2270 TID-45f4w INFO: See LICENSE and the LGPL-3.0 for licensing details.
2014-07-10T16:12:28Z 2270 TID-45f4w INFO: Starting processing, hit Ctrl-C to stop
2014-07-10T16:12:28Z 2270 TID-ld0ss Sidekiq::Extensions::DelayedMailer JID-5642f1b11420d41d6a72ae42 INFO: start
2014-07-10T16:12:59Z 2270 TID-ld0ss Sidekiq::Extensions::DelayedMailer JID-5642f1b11420d41d6a72ae42 INFO: fail: 30.35 sec
2014-07-10T16:12:59Z 2270 TID-ld0ss WARN: {"retry"=>true, "queue"=>"default", "class"=>"Sidekiq::Extensions::DelayedMailer", "args"=>["---\n- !ruby/class 'UnsubscribeMailer'\n- :unsubscribe_confirmation\n- - !ruby/object:Subscriber\n attributes:\n id: 1\n email: henrique@breim.com.br\n verification: b8d7429816da0d522de0f707bea1fc47\n
@breim
breim / controller.rb
Created July 11, 2014 16:21
Carregar JS dentro do controller
# Controller
def nome_da_action
format.html {redirect_to :back, notice: "Enviado!"}
format.js
end
# Dentro da view do controle, o arivo nome_da_action.js.erb
package br.com.empresa.projeto;
public class Main {
public static void main(String[] args) {
for (int i = 1; i<=3000000; i++){
System.out.println(i);
}
}
}