Skip to content

Instantly share code, notes, and snippets.

View sofadesign's full-sized avatar

Fabrice Luraine sofadesign

  • http://www.lunaweb.fr
View GitHub Profile
<?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();
# 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
# Paperclip attachment, with sorting and special convert options
class PageAsset < ActiveRecord::Base
acts_as_list :scope => :page
has_attached_file :asset,
:styles => {
:small => "110x82#",
:thumb => "150x90#",
:large => "460x345>",
:original => "1600x1200>"
},
find your_project -type d -name .svn | xargs rm -rf
require 'find'
require 'fileutils'
dir = '/your_directory'
Find.find(dir) do |path|
if FileTest.directory?(path) && File.basename(path) == '.svn'
p 'rm directory:' + path
FileUtils.remove_dir(path)
else
echo `date "+%d %B %Y"` | awk '{ print substr(" ",1,(21-length($0))/2) $0; }'; cal | awk '{ getline; print " Mo Tu We Th Fr Sa Su"; getline; if (substr($0,1,2) == " 1") print " 1 "; do { prevline=$0; if (getline == 0) exit; print " "substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }' | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" "); a=$0; sub(" "fill int(cday)" ","*"fill int(cday)"*",a); print a }'
<?php
# LIMONADE URL REWRITING EXAMPLE
# In your .htaccess in your app folder
# <IfModule mod_rewrite.c>
# Options +FollowSymlinks
# Options +Indexes
# RewriteEngine on
<?php
// LIMONADE FLASH FEATURES EXAMPLES
require_once 'lib/limonade.php';
function configure()
{
option('env', ENV_DEVELOPMENT);
}
function before()
<?php
// LIMONADE SESSION FEATURES EXAMPLES
require_once 'lib/limonade.php';
function configure()
{
// by default, session is enable. It automaticaly start a session with LIM_SESSION_NAME as name
option('session', false); // disable
option('session', true); // enable