Skip to content

Instantly share code, notes, and snippets.

View luizfonseca's full-sized avatar
💻
cargo run

Luiz Fonseca luizfonseca

💻
cargo run
View GitHub Profile
@luizfonseca
luizfonseca / sample.js
Created April 26, 2011 05:54
Sample code
$('form.simple_form').submit(function(e){
var textarea = $('textarea.text_required').val();
if (textarea == '')
{
e.preventDefault();
var msg = 'The comment field is a required field';
$('div.scroll > p').append(msg);
}
});
@luizfonseca
luizfonseca / send.php
Created March 16, 2011 21:21
"How to use" of the Sample Marketing Class
<?php
require_once('./class/lib/PHPMailer_Class.php');
require_once('./class/Marketing_Class.php');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$marketing = new Marketing;
$marketing->destination = dirname(__FILE__) . '/files/';
$marketing->type = 'html';
$marketing->file = $_FILES;
@luizfonseca
luizfonseca / Marketing_Class.php
Created March 16, 2011 21:18
Sample class that parse a CSV file, a HTML file and send it.
<?php
/**
* @author Luiz Fonseca
* Sample Class
*
*/
class Marketing {
public $destination = null;
Started POST "/noticias" for 200.163.80.113 at Mon Feb 21 22:03:21 -0300 2011
Processing by NoticiasController#create as HTML
Parameters: {"commit"=>"Create Noticia", "authenticity_token"=>"VpFKkGEMG6B4wphkvUVHhLuiLtO36EX/Bj6D9PJuKcU=", "utf8"=>"✓", "noticia"=>{"date(1i)"=>"2011", "author"=>"noticia[author]", "date(2i)"=>"2", "date(3i)"=>"22", "titulo"=>"noticia[titulo]", "text"=>"<p>asdasd</p>", "credits"=>"noticia[credits]", "link"=>"noticia[link]", "call"=>"noticia[call]", "image"=>#<ActionDispatch::Http::UploadedFile:0xa99456c @tempfile=#<File:/tmp/RackMultipart20110221-21964-14qe040-0>, @original_filename="xHCiT.jpg", @headers="Content-Disposition: form-data; name=\"noticia[image]\"; filename=\"xHCiT.jpg\"\r\nContent-Type: image/jpeg\r\n", @content_type="image/jpeg">}}
[paperclip] /usr/local/bin/identify -format %wx%h '/tmp/stream20110221-21964-lklkmy-0.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::CommandNotFoundError: Paperclip::CommandNotFoundError>
[papercli
@luizfonseca
luizfonseca / benchmark
Created February 11, 2011 16:42
Python vs Ruby vs PHP
~ luiz$ python -c "print(12345**54321)" > /dev/null
real 0m23.445s
user 0m22.524s
sys 0m0.152s
~ luiz$ time ruby -e "puts 12345**54321" > /dev/null
real 0m10.127s
user 0m9.932s
(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)
){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F
\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?
:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-
fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-
)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?
:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!
@luizfonseca
luizfonseca / gzip_pages.php
Created January 8, 2011 13:30
turnin on the gzip compression. Very useful when using a controller for your application (you only need to include once)
<?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
?>
@luizfonseca
luizfonseca / mysql_rubygem
Created January 2, 2011 06:42
How to install mysql/ruby gem on Snow Leopard.
sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include