Skip to content

Instantly share code, notes, and snippets.

View rafi's full-sized avatar

Rafael Bodill rafi

View GitHub Profile
@greut
greut / fotd.php
Created September 19, 2008 12:08
<?php
// See: http://blog.liip.ch/archive/2008/09/18/fotd-reflectionclass-newinstanceargs-args-is-slow.html
/* Results on my box:
$ php -v
PHP 5.2.6-pl7-gentoo (cli) (built: Sep 22 2008 08:13:50)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
$ php test.php
@nzjrs
nzjrs / FooThread.py
Created January 25, 2009 04:43
PyGtk threading example
# Demo application showing how once can combine the python
# threading module with GObject signals to make a simple thread
# manager class which can be used to stop horrible blocking GUIs.
#
# (c) 2008, John Stowers <[email protected]>
#
# This program serves as an example, and can be freely used, copied, derived
# and redistributed by anyone. No warranty is implied or given.
import gtk
import gobject
@madx
madx / git-dot
Created February 4, 2010 18:16
Generate graphs from a git repository
#!/usr/bin/env ruby
class Grapher
class << self
Props = {
:branch => '[shape=box,style=filled,fillcolor="#ccffcc",color="#003300"]',
:commit => '[style=filled,fillcolor="#ffffcc",color="#663333"]',
:ref => '',
:relation => '[dir=back,color="#545443"]',
<?php
$depth = 0;
echo '<ol class="tree">';
foreach ($children as $i => $child)
{
// Get the last and next nodes
$last = isset($children[$i-1]) ? $children[$i-1] : $children[0];
$next = isset($children[$i+1]) ? $children[$i+1] : $children[0];
<?php defined('SYSPATH') or die('No direct script access.');
class Date extends Kohana_Date {
public static function format($date,$format='U',$offset=NULL)
{
if (empty($date) || $date == '0000-00-00 00:00:00' || $date == '0000-00-00') return NULL;
try
{
<?php
$data = Validate::factory($_POST)
// CSRF protection
// ->rule('security_token', 'Security::check')
// Real name
->filter('name', 'trim')
->rule('name', 'not_empty')
->rule('name', 'regex', array('/^[\pL .,]++$/u'))
// Email address
<?php defined('SYSPATH') or die('No direct script access.');
/**
* User to user communication wrapper. Uses Swift Mailer for email transport.
*
* @package Communicate
* @category Base
* @author Woody Gilk <[email protected]>
* @copyright (c) 2010 Woody Gilk
* @license MIT
*/
@HenrikJoreteg
HenrikJoreteg / JS Util solution using underscore.js
Created October 22, 2010 21:20
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
@adamli
adamli / gist:668204
Created November 8, 2010 20:25
Creating a virtual directory in Apache server
in httpd-vhosts.conf append:
Alias /crm/[app_name]/media/ "D:/xampp/htdocs/crm/_core/modules/crm/media/"
<Directory "D:/xampp/htdocs/crm/_core/modules/crm/media">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables