Skip to content

Instantly share code, notes, and snippets.

View RobertoBarros's full-sized avatar

Roberto Barros RobertoBarros

View GitHub Profile
@RobertoBarros
RobertoBarros / foreman.sh
Last active August 29, 2015 13:57
Executando foreman export para um usuário que não é root
sudo env PATH=$PATH foreman export upstart /etc/init -f Procfile-name -a app-name -u deployer
#https://github.com/sstephenson/rbenv/issues/127
#!/bin/bash
VERSION="0.90.1"
PORT="9200"
PWD=`pwd`
mkdir -p ~/elasticsearch/
cd ~/elasticsearch/
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${VERSION}.zip
https://thrift.apache.org/
https://avro.apache.org/
https://github.com/google/protobuf
http://msgpack.org/
https://capnproto.org/
@RobertoBarros
RobertoBarros / README.md
Last active August 29, 2015 14:20
Instalando Elasticsearch 0.90.3 com o Homebrew

#Instalando elasticsearch 0.90.3 com o Homebrew

####1. Unload e Unlink da versão atual

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist

brew unlink elasticsearch

####2. Vai para o repositório do Homebrew

@RobertoBarros
RobertoBarros / gist:07a02ffb566631ddebe9
Created October 23, 2015 16:24
Install Puma in OSX El Captain
gem install puma -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
#http://stackoverflow.com/a/32061171/8581
def validate_item_exist?(products, item)
!products[item].nil?
end
def validate_item_stock?(products, item, quant)
stock = products[item].first
return stock >= quant
end
def add_item_cart(carrinho, item, quant)
@RobertoBarros
RobertoBarros / ssn.rb
Created July 11, 2016 21:22
regex livecode
require "date"
def sex(cod)
if cod.to_i == 1
return "it's a man"
else
return "it's a woman"
end
end
@RobertoBarros
RobertoBarros / cvs.rb
Created July 12, 2016 14:50
Parsing and Storing
require 'csv'
file = 'data/alunos.csv'
options = {headers: true, col_sep: ',', encoding: 'utf-8', force_quotes: true}
CSV.open(file, 'w', options) do |csv|
csv << ['Nome', 'Email', 'Hobby']
csv << ['Roger,', 'rogerpscott@gmail','coding']
csv << ['Lincoln', 'antoniolincoln@live.com','eletrônica']
require_relative 'cookbook' # You need to create this file!
require_relative 'controller' # You need to create this file!
require_relative 'router'
require 'pry'
csv_file = File.join(__dir__, 'recipes.csv')
cookbook = Cookbook.new(csv_file)
controller = Controller.new(cookbook)
router = Router.new(controller)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>--- TODO ---</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">