Skip to content

Instantly share code, notes, and snippets.

View loonies's full-sized avatar
👨‍💻
Working full time

loonies

👨‍💻
Working full time
View GitHub Profile
#!/bin/bash
# Destination: ~/.pomodoro/hooks/work.d/
# Goal: block access to Twitter and Facebook while in a Pomodoro
# Note: won't work if you use Chrome, as it maintains an internal (not flushable from CLI) DNS cache. Fuck it.
# This file must be able to touch "/etc/hosts":
# The best way would be to create a group able to modify the "/etc/hosts" file:
# $ sudo addgroup host-manager
# $ sudo chgrp host-manager /etc/hosts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@loonies
loonies / app-contract.md
Created December 6, 2012 16:58 — forked from lukemorton/app-contract.md
Application contract

Application contract

An application must keep to the following rules if it is to stay sane.

ActionController (POST Controller::action_*())

  • Must call one and only one UseCase
  • Must redirect to ViewController
@loonies
loonies / hierarchy.php
Created November 20, 2011 21:39 — forked from devi/hierarchy.php
MySQL "Closure Table" for Kohana based on Bill Karwin design.
<?php defined('SYSPATH') or die('No direct script access.');
/**
* MySQL "Closure Table" for Kohana based on Bill Karwin design.
*
* @link http://www.slideshare.net/billkarwin/models-for-hierarchical-data
* @TODO improve
*
* sql schema:
* CREATE TABLE `closures` (
* `id` int(11) NOT NULL AUTO_INCREMENT,
@loonies
loonies / list_targets.sh
Created July 30, 2011 09:33 — forked from pvdb/list_targets.sh
List all targets (sometimes incorrectly referred to as "goals") in a GNU Makefile
#
# this gist can be used to list all targets, or - more correctly - rules,
# that are defined in a Makefile (and possibly other included Makefiles)
# and is inspired by Jack Kelly's reply to a StackOverflow question:
#
# http://stackoverflow.com/questions/3063507/list-goals-targets-in-gnu-make/3632592#3632592
#
# I also found this script - http://www.shelldorado.com/scripts/cmds/targets - which does
# something similar using awk, but it extracts targets from the "static" rules from a single
# Makefile, meaning it ignores any included Makefiles, as well as targets from "dynamic" rules
@loonies
loonies / kohana-release.sh
Created July 21, 2011 07:55 — forked from zombor/kohana-release.sh
Kohana Release Script - Bash script to do a kohana release from git.
#!/bin/bash
MAJOR_VERSION=$1
MINOR_VERSION=$2
if [ $# -lt 2 ]
then
echo "Usage: $0 <MAJOR-VERSION> <MINOR-VERSION>"
exit
fi
<?php
/**
* Applys a function to a specific set of keys in an array
*
* @param array & $source_array the array to apply the callback to
*
* @return null
*/
public function apply( & $source_array, $callback, $keys)
<?php defined('SYSPATH') OR die('No direct access allowed.');
abstract class Jelly_Model_MPTT extends Jelly_Model {
protected static $_columns = array(
'left' => 'lft',
'right' => 'rgt',
'scope' => 'scope',
'level' => 'lvl',
'parent_id' => 'parent_id',
<?php defined('SYSPATH') or die('No direct script access.');
class Kohana_Exception extends Kohana_Kohana_Exception {
public static function handler(Exception $e)
{
if (Kohana::DEVELOPMENT === Kohana::$environment)
{
parent::handler($e);
}
@loonies
loonies / calc-lat-lng-php.php
Created January 23, 2011 21:41 — forked from mintbridge/gist:792388
Calculating distance using latitude and longitude
<?php
// http://www.movable-type.co.uk/scripts/latlong.html
// converted from JS to PHP
$d_lat = deg2rad($lat1 - $lat2);
$d_lon = deg2rad($lon1 - $lon2);
$lat1 = deg2rad($lat1);
$lat2 = deg2rad($lat2);