Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
jtadeulopes / localhost.conf
Last active September 15, 2016 07:09
Default nginx server
upstream project {
server unix:///var/tmp/project.sock;
}
server {
listen 80;
server_name localhost;
root /var/www/project/current/public;
@jtadeulopes
jtadeulopes / nginx.conf
Last active December 9, 2019 11:37
Nginx settings
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
@jtadeulopes
jtadeulopes / nginx.conf
Created October 30, 2013 17:57
Upstart Nginx
description "nginx webserver"
start on startup
stop on shutdown
respawn
expect fork
exec /opt/nginx/sbin/nginx
@jtadeulopes
jtadeulopes / gist:5041735
Created February 26, 2013 20:13
Ruby 2.0 with rbenv
# https://github.com/sstephenson/rbenv
#
# I'm using rbenv-build to install ruby
# https://github.com/sstephenson/ruby-build
cd ~/.rbenv/
git pull
cd plugins/ruby-build/
git pull
rbenv install 2.0.0-p0
#include <stdio.h>
#define LIMITE 50
int main(void)
{
int A=0, B=0, C=0, soma;
printf("Digite um número inteiro: \n");
scanf("%d", &A);
@jtadeulopes
jtadeulopes / gist:3085890
Created July 10, 2012 20:07
Mac OSX Lion - mysql instaled with brew and gem mysql already installed
$ rake db:create
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /Users/jtadeulopes/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Users/jtadeulopes/.rvm/gems/ruby-1.8.7-p370/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_init
Referenced from: /Users/jtadeulopes/.rvm/gems/ruby-1.8.7-p370/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
@jtadeulopes
jtadeulopes / gist:2705477
Created May 15, 2012 21:59
rails upgrade
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
$ rake stats
Code LOC: 1969 Test LOC: 3407 Code to Test Ratio: 1:1.7
$ time bundle exec rails runner "puts 'hello'"
rails real user sys
3.0.11 12.087 7.673 2.236
@jtadeulopes
jtadeulopes / elastic.rb
Created November 30, 2011 15:59
elasticsearch sort
# encoding: utf-8
require "tire"
users = [
{ :id => '1', :type => 'user', :name => 'Jesus Lopes', :email => 'jl@zigotto.com' },
{ :id => '2', :type => 'user', :name => 'Alfredo', :email => 'alfredo@email.com' },
{ :id => '3', :type => 'user', :name => 'Éder Costa', :email => 'ec@zigotto.com' }
]
Tire.index("users") do
@jtadeulopes
jtadeulopes / gist:1302661
Created October 20, 2011 23:02
permalink patch
it "should always update permalink" do
model.permalink :title, :always_update => true
record = model.create(:title => "Some nice post", :permalink => " ")
record.permalink.should == "some-nice-post"
record.title = "another title"
record.save
record.permalink.should == "another-title"
@jtadeulopes
jtadeulopes / mask.rb
Created August 30, 2011 23:24
ruby exercícios
#
# Deve completar a máscara de acordo com o número informado
#
mask("125")
=> "00012-500"
mask("385002")
=> "38500-200"