Skip to content

Instantly share code, notes, and snippets.

View rafi's full-sized avatar

Rafael Bodill rafi

View GitHub Profile
@rafi
rafi / MongoDB install
Created April 14, 2010 20:56
MongoDB install
wget http://downloads.mongodb.org/linux/mong … -1.2.0.tgz
tar xvfz mongodb-linux-i686-1.2.0.tgz -C /usr/local/softnix/
mv mongodb-linux-i686-1.2.0/ mongodb
mkdir -p /data/db
ln -s /usr/local/softnix/mongodb/bin/mongod /sbin/mongod
ln -s /usr/local/softnix/mongodb/bin/mongo /bin/mongo
./mongod &
./mongo
@rafi
rafi / tree.php
Created April 15, 2010 10:33 — forked from shadowhand/tree.php
Tree view
<?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];
diff --git a/classes/kohana/exception.php b/classes/kohana/exception.php
index 7952a7b..657f661 100644
--- a/classes/kohana/exception.php
+++ b/classes/kohana/exception.php
@@ -23,6 +23,8 @@ class Kohana_Exception extends Exception {
*/
public function __construct($message, array $variables = NULL, $code = 0)
{
+ $variables = array_map(array('HTML', 'chars'), $variables);
+
# Changing all files dates recursively
find . -exec touch -t 201005050900 {} \;
@rafi
rafi / json.php
Created June 12, 2011 20:03 — forked from alkavan/json.php
JSON Helper for Kohana v3.x
<?php defined('SYSPATH') or die('No direct script access.');
/**
* JSON helper class
*
* Examples:
* $j = JSON::decode('{"Organization": "Kohana"}'); // Good
* $j = JSON::decode("{'Organization': 'Kohana'}"); // Invalid
* $j = JSON::decode('{"Organization": "Kohana"}', NULL, 1); // depth stack exceeded
*
* @package Kohana
@rafi
rafi / model
Created November 21, 2011 15:00
validation: model related with other models
class Model_Core_Account extends Abstract_Model_Base {
public $list_fields = array();
public function check()
{
// validate list fields if exist, here!
// call parent model validation
return parent::check();
@rafi
rafi / post-receive
Created March 25, 2010 19:34
Deploying with Git
mkdir ~/git/website.git && ~/git/cd website.git
git init --bare
mkdir ~/webapps/website
git config core.bare false
git config core.worktree /home/rafi/webapps/website ; NO TRAILING SLASH!!! Will screw up things real bad.
git config receive.denycurrentbranch ignore
; create a hook
cat > hooks/post-receive
#!/bin/sh
@rafi
rafi / gist:4626560
Created January 24, 2013 19:08
lightdm display setup
#!/bin/bash
# V-1.0 by Hanynowsky - April 2012.
# I am a very basic script that works around bug 874241 repprted in launchpad.
XCOM0=`xrandr -q | grep 'HDMI1 connected'`
XCOM1=`xrandr --output HDMI1 --primary --mode 1920x1080 --output LVDS1 --mode 1366x768 --below HDMI1`
XCOM2=`xrandr --output LVDS1 --mode 1366x768`
# if the external monitor is connected, then we tell XRANDR to set up an extended desktop
if [ -n "$XCOM0" ] || [ ! "$XCOM0" = "" ]; then echo $XCOM1
# if the external monitor is disconnected, then we tell XRANDR to output only to the laptop screen
<?php
Trait MethodDelegator
{
private $roles = array();
private $method_map = array();
public function delegate($class)
{
@rafi
rafi / gist:5706033
Created June 4, 2013 13:45
Goofing around with DCI, inspired by https://gist.github.com/Ikke/4075281
<?php
Trait MethodDelegator
{
private $roles = array();
private $method_map = array();
public function delegate($class)
{