Skip to content

Instantly share code, notes, and snippets.

View guilherme's full-sized avatar
🤔

Guilherme Campos guilherme

🤔
View GitHub Profile
@guilherme
guilherme / calc.c
Created May 31, 2011 01:28
parser de calculadora simples
#include <stdio.h>
#include <stdlib.h>
int main() {
// inicializacao das variavieis
char string[100];
char numero_char[6];
int numero = 0;
int i = 0; // utilizado para andar pela string digitada pelo usuario
int j = 0; // utilizado para andar pelo numero capturado dentro da string
@guilherme
guilherme / php-fpm.sh
Created July 11, 2011 14:51
php-fpm start file
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
<?php
// This function extract the rows of arrays like $_FILE when using the option 'multiple'
// For ex.
// Array
// (
// [name] => Array
// (
// [0] => uploaded_file1
// [1] => uploaded_file2
// [2] => uploaded_file3
@guilherme
guilherme / exemplo
Created July 18, 2011 02:30
exemplo de tipos de paradigma de programacao
// Orientado a Objeto (Ruby)
class Evento
def consumir
puts "Estou consumido"
end
end
@guilherme
guilherme / gist:1121188
Created August 2, 2011 20:48
Encoding problem.
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:69:in `join'
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:69:in `visit_Arel_Nodes_Values'
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/visitor.rb:15:in `visit'
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:59:in `visit_Arel_Nodes_InsertStatement'
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/visitor.rb:15:in `visit'
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/visitor.rb:5:in `accept'
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:18:in `block in accept'
[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:111:in `with_connection'
@guilherme
guilherme / gist:1236160
Created September 22, 2011 21:57
ActionMailer with more than one SMTP Account
# this is my action mailer setup and can be improved
# based on http://broadcast.oreilly.com/2009/03/using-multiple-smtp-accounts-w.html
# config/initializer/action_mailer.yml
development:
default:
address: "smtp.provider.com"
port: 25
domain: 'mywebsite.com'
user_name: 'mailer@mywebsite.com'
password: '12345'
@guilherme
guilherme / myapp.com.conf
Created October 7, 2011 17:34
nginx with ssl and rewrite rule
server {
listen 80;
server_name www.myapp.com myapp.com;
rewrite ^.* https://myapp.com$request_uri permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/sslchain.crt;
@guilherme
guilherme / about.md
Created January 23, 2012 01:39 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@guilherme
guilherme / refresh_in_batches.rb
Created January 24, 2012 20:52
monkey patch for a more light approach to rake paperclip:refresh
module Paperclip
class << self
def each_instance_with_attachment(klass, name)
unscope_method = class_for(klass).respond_to?(:unscoped) ? :unscoped : :with_exclusive_scope
class_for(klass).send(unscope_method) do
class_for(klass).find_in_batches(:batch_size => 20) do |instance_batches|
instance_batches.each do |instance|
yield(instance) if instance.send(:"#{name}?")
end
end
@guilherme
guilherme / gist:1732428
Created February 3, 2012 20:48
functional error
# acid_tests.rb
# Add another case:
# as you may see it not raises a logical error. it accepts multiple applications
describe "Two applications on the same server" do
it "emulates a simple mail list and respond to ping pongs" do
mailer.deliver_message(:from => "tester@test.com",
:to => "test@test.com")
server.tick([Newman::Examples::SimpleList,Newman::Examples::PingPong])