Skip to content

Instantly share code, notes, and snippets.

View claussni's full-sized avatar

Ralf Claussnitzer claussni

View GitHub Profile
$ php zendphy.php
Hello, World
@claussni
claussni / SnafuController.php
Created February 21, 2010 13:33
Zend_Rest_Route in Action
<?php
class SnafuController
extends Zend_Rest_Controller {
public function indexAction() {
// Zend Dispatcher routes to indexAction on every get request
// so pass over to getAction
$this->getAction();
}
@claussni
claussni / Generator.php
Created March 7, 2010 19:47
Annotations and code generation
<?php
// set include path to library
set_include_path(implode(PATH_SEPARATOR, array(
'/opt/ZendFramework-1.10.1/library',
get_include_path(),
dirname(__FILE__)
)));
require_once 'Zend/Loader/Autoloader.php';
@claussni
claussni / gist:894310
Created March 30, 2011 12:32
Source Control Management Bash Prompt Highlighting
##
## SCM info
##
scm_info() {
local bzr_info=`bzr revno --tree 2> /dev/null`
if [ ${bzr_info} ]; then
if [ "$(bzr st -S)" ]; then
local bzr_color='\033[1;31m'
else
local bzr_color='\033[1;36m'
@claussni
claussni / .vimrc
Last active September 25, 2015 19:38
my .vimrc file
set autoindent " automatic indentation
set expandtab " expand tabs to spaces
set hlsearch " highlight searches
set incsearch " do incremental searching
set ls=1 " allways show status line
set nobackup " disable leaving backup files around
set nocompatible " use vim defaults
set noignorecase " don't ignore case when searching
set nostartofline " don't jump to first character when paging
set novisualbell " turn off visual bell
@claussni
claussni / 52char_array_seek.php
Created July 29, 2011 08:53
Given a PHP array "$array" and a seek position "$pos", this sets the internal array pointer to $pos in only 52 chars
<?php
// the array
$array = array('foot', 'bike', 'my'=>'car', 'plane', 'roller');
// seek position
$pos="my";
// seek array pointer, behaves end($array) if $pos is no array key
for($a=&$array,reset($a);key($a)!==$pos&&each($a););
// should print "car"
echo ">".current($array)."<\n";
abstract class Tree
case class Leaf(value: String) extends Tree
case class Branch(left: Tree, right: Tree) extends Tree
def walk(t: Tree): Unit =
t match {
case Branch(Stub, _) => println("branch-with-stub-on-the-left")
case Branch(left, right) => {
println("\nbranch-leaf")
walk(left)