This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
#! /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 |
// Orientado a Objeto (Ruby) | |
class Evento | |
def consumir | |
puts "Estou consumido" | |
end | |
end |
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' |
# 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: '[email protected]' | |
password: '12345' |
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; |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
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 |
# 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 => "[email protected]", | |
:to => "[email protected]") | |
server.tick([Newman::Examples::SimpleList,Newman::Examples::PingPong]) |
module Newman | |
module ActAsPingPong | |
def self.extended(klass) | |
klass.instance_eval do | |
to(:tag, "ping") do | |
respond(:subject => "pong") | |
end | |
end | |
end | |
end |