Skip to content

Instantly share code, notes, and snippets.

var tourApp = {
tabSteps: {
8: 'images',
12: 'users'
},
needsTweaking: function(i) {
return typeof tourApp.tabSteps[i] != 'undefined';
},
@beezee
beezee / param_call.php
Created July 1, 2012 18:55 — forked from maxpert/param_call.php
PHP named parameter calling
<?php
$x = function($bar, $foo="9") {
echo $foo, $bar, "\n";
};
class MissingArgumentException extends Exception {
}
function call_user_func_named_array($method, $arr){
@beezee
beezee / php-cs-fixer-pre-commit.php
Created September 8, 2012 16:04 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@beezee
beezee / gist:3831274
Created October 4, 2012 03:20
Mass assignment + custom setter which modifies value type
Class Task extends ActiveRecord\Model
{
public static $table = 'tasks';
public function set_history($history)
{
$this->assign_attribute('history', serialize($history));
}
<?php
class swDFPBaseModule
{
private function parent_or_child($tax, $query_key)
{
$slug = $wp_query->query_vars[$query_key]
$s = get_term_by('slug', $slug, $tax);
return ($s->parent>0) ?
'get_on_'.$tax.'_page' : 'get_on_child_'.$tax.'_page';
@beezee
beezee / ack-stream.scala
Created October 27, 2015 12:13
Akka Streams with acknowledgement using bcast ~> zip
package main
import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, ActorAttributes}
import akka.stream.scaladsl._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
object StreamProgram {
implicit lazy val system = ActorSystem("example")
@beezee
beezee / UploadedFileBehavior.php
Created January 29, 2013 16:46
Shows how to "extend" CUploadedFile (difficult to do classically because of private static $_files property) using a small Factory component and a behavior
<?php
//Class to provide factory methods for seamless use
class UploadedFile extends CComponent
{
public function init()
{
parent::init();
}
@beezee
beezee / gist:5521040
Created May 5, 2013 14:57
cpt extended class of post with virtual attributes based on meta
class Player extends Post
{
private $_points = false;
public static $after_save = array('update_points');
public function set_points($points)
{
$this->_points = $points;
}
@beezee
beezee / .vimrc
Created March 24, 2016 17:09
vimrc
execute pathogen#infect()
syntax on
set shiftwidth=2
set tabstop=2
set expandtab
set autoindent
set tags=~/tags
set backspace=2
let &colorcolumn=join(range(81,999),",")
highlight ColorColumn ctermbg=255 guibg=#b5baa9
@beezee
beezee / converter.scala
Created May 3, 2016 12:39
Untag and convert
package sample
import scala.language.implicitConversions
import shapeless._
import shapeless.Everywhere
import ops.hlist.{Align, Mapper, Prepend}
import poly._
import record._
import syntax.singleton._
import shapeless.tag