Skip to content

Instantly share code, notes, and snippets.

from __future__ import print_function
import os, os.path, sys, threading, signal, time, collections
from Queue import Queue
from SocketServer import UnixStreamServer, StreamRequestHandler, ThreadingMixIn
from click import command, option
from ldif import LDIFWriter
from uuid import UUID, uuid5
import oursql
class GenericPool(object):
@predakanga
predakanga / default.rb
Created August 5, 2014 08:16
Devbox cookbook's default recipe
#
# Cookbook Name:: devbox
# Recipe:: default
#
# Copyright 2013, Lachlan Pease
#
# All rights reserved - Do Not Redistribute
#
include_recipe 'nginx::commons_dir'
{ "elements": [ { "type": "bar_3d", "values": [ 35.7, 45, 9.1, 1.5, 8.6 ], "colour": "#D5282A", "alpha": 1, "tip": "#val#%" }, { "type": "tags", "values": [ { "x": 0, "y": 35.7 }, { "x": 1, "y": 45 }, { "x": 2, "y": 9.1 }, { "x": 3, "y": 1.5 }, { "x": 4, "y": 8.6 } ], "font": "Verdana", "font-size": 10, "colour": "#000000", "align-x": "center", "text": "#y#%" } ], "title": { "text": "Send younger14, natt14, sugar14 , lilo14 eller babes14 til 2030 for \u00e5 stemme", "style": "{font-size: 15px; font-family: Times New Roman; font-weight: bold; color: #000000; text-align: center;}" }, "bg_colour": "#FFFFFF", "x_axis": { "3d": 5, "colour": "#021840", "grid-colour": "#FFFFFF", "labels": { "colour": "#000000", "labels": [ "Stemmer: 346", "Stemmer: 436", "Stemmer: 88", "Stemmer: 15", "Stemmer: 83" ] } }, "y_axis": { "colour": "#021840", "grid-colour": "#FFFFFF", "min": 0, "max": 50, "steps": 10, "labels": { "colour": "#FFFFFF", "text": "#val#%" } } }
@predakanga
predakanga / context_closure.patch
Created July 22, 2013 08:40
Twig context closure support
diff --git a/lib/twig/twig/lib/Twig/Template.php b/lib/twig/twig/lib/Twig/Template.php
index a001ca0..1f3c04b 100644
--- a/lib/twig/twig/lib/Twig/Template.php
+++ b/lib/twig/twig/lib/Twig/Template.php
@@ -337,7 +337,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
{
// array
- if (Twig_TemplateInterface::METHOD_CALL !== $type) {
+ if (!is_object($object)) {
@predakanga
predakanga / duff.c
Created February 17, 2013 08:50
Duff's device in C
send(to, from, count)
register short *to, *from;
register count;
{
register n = (count + 7) / 8;
switch(count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
class A(object):
def id(self):
return "Hello"
class B(object):
def id(self):
return "Hi"
dict1 = {}
dict2 = {}
<?php
namespace Acme\UserBundle\Form\Type;
use JMS\DiExtraBundle\Annotation\FormType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\ORM\EntityRepository;
@predakanga
predakanga / gist:3487705
Created August 27, 2012 11:30
Calling command from controller
<?php
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
/**
* @Route("/test")
*/
@predakanga
predakanga / CommandRunCommand.php
Created August 27, 2012 10:51
Code for running commands
<?php
/**
* The actual command which is used to call other commands
*/
class CommandRunCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName("cmd:run")
@predakanga
predakanga / MemoryOutput.php
Created August 22, 2012 02:07
MemoryOutput
<?php
namespace Fusion\Framework\CronBundle\Command;
use Symfony\Component\Console\Output\Output;
/**
* MemoryOutput implements OutputInterface, writing to an internal buffer
*/
class MemoryOutput extends Output {
protected $backingStore = "";