This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mysql-python + snow leopard + mysql build with macports # | |
# Because on Snow Leopard macports installs the 64bits version of Mysql Server, | |
# you can't simply make a `python easy_install mysql-python` | |
# So we need to download sources and build it with correct flags. After fetching sources [MySQL-python-1.2.3c1](http://sourceforge.net/projects/mysql-python/): | |
tar xzf MySQL-python-1.2.3c1.tar.gz | |
cd MySQL-python-1.2.3c1 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function before($route) | |
{ | |
# Authentication if required | |
$uri = request_uri(); | |
$is_admin = preg_match('%^/admin(/.+)?$%', $uri); | |
$auth_required = $is_admin && $uri != "/admin/login" && $uri != "/admin/logout"; | |
if($auth_required) authentication_is_required(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function autoload_controller($callback) | |
{ | |
$path = option('controllers_dir'); | |
if(strpos($callback, 'admin_') === 0) | |
{ | |
$path = file_path($path, 'admin'); | |
} | |
require_once_dir($path); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Returns the result of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS `scores`; | |
CREATE TABLE `scores` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`value` char(1) DEFAULT NULL, | |
`level` int(11) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; | |
LOCK TABLES `scores` WRITE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
function foo(){ | |
function bar() {return 3;} | |
return bar(); | |
function bar() {return 8;} | |
} | |
alert(foo()); // 8 | |
// mais | |
// 2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# smart_label_form_builder.rb | |
# | |
# original code from: | |
# http://openmonkey.com/articles/2010/03/rails-labels-with-blocks | |
# | |
# -- | |
# adding HAML compatibility (fabrice AT sofa-design DOT net) | |
# | |
class SmartLabelFormBuilder < ActionView::Helpers::FormBuilder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
SIX (UNIMPRESSIVE) # Markdown version: | |
REASONS CAMPING IS BETTER # 1) Download this email | |
THAN YOU WOULD IMAGINE # 2) ruby email.rb | |
reasons.push(COMMUNITY) do %% | |
Yes, Sinatra has a big community, but Camping definitely has a great | |
community too. Size doesn't always matter. Because there are so few users, | |
it means every single issue gets full attention. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user app; | |
worker_processes 2; | |
error_log /home/app/logs/nginx.error.log info; | |
events { | |
worker_connections 1024; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# des Headers HTTP personnalisés dans Rails: | |
class MyController | |
before_filter :custom_response_headers | |
def custom_response_headers | |
response.headers["X-Luna-Mood"] = ";-)" | |
# … | |
end | |
end |