Skip to content

Instantly share code, notes, and snippets.

View robinedwards's full-sized avatar

Robin Edwards robinedwards

View GitHub Profile
use Class::MOP;
use Config::ApacheFormat;
my $meta Class::MOP::Class->initialize(
'Config::ApacheFormat',
);
$meta->add_around_method_modifier('get', sub {
my $meth = shift;
my $self = shift;
# test.pl >>
use Config::ApacheFormat;
use Data::Dump 'dump';
my $cfg = Config::ApacheFormat->new(
include_support => 1,
expand_vars => 1,
fix_booleans => 1,
duplicate_directives => "last",
);
@robinedwards
robinedwards / Methods.pm
Created April 17, 2011 09:19
Keyword::API demo
package Methods;
use strict;
use warnings;
use Keyword::API;
sub import {
my ($class, %params) = @_;
my $name = %params && $params{-as} ? $params{-as} : "method";
@robinedwards
robinedwards / Person.c
Created March 4, 2012 16:44
Re-learning C, very much enjoying it with OO style.
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
char *name;
int age;
int height;
int weight;
@robinedwards
robinedwards / extendedappliance.java
Created March 8, 2012 19:27
extended appliance class
public abstract class ExtendedAppliance implements Appliance {
protected Double demand;
protected String name;
protected Integer id;
protected boolean turnedOn = false;
public Double demandUsedFor(Long seconds) {
if (turnedOn)
return (demand * (seconds / (3600)));
@robinedwards
robinedwards / vim
Created March 14, 2012 17:42
python settings for vim
augroup filetype python
set softtabstop=4
set shiftwidth=4
set tabstop=4
set smarttab
set expandtab
set autoindent
augroup END
" show hardcoded tabs and trailing ws
@robinedwards
robinedwards / foo.py
Created April 2, 2012 09:06
creating an object from a class name
from pprint import pprint as pp;
import sys
class Foo(object):
def __init__(self, name):
print "building a Foo"
self.name = name
def sayhi(self):
@robinedwards
robinedwards / gitworkflow.sh
Created May 4, 2012 11:21
git workflow rfc
### Features ###
# Create new feature branch
$ git feature new admin_html_pruning
# this executes the following for you
$ git checkout -b feature_admin_html_pruning
# create a new remote branch
git push -u origin feature_admin_html_pruning:feature_admin_html_pruning
set backspace=indent,eol,start
set incsearch
set noshowmatch
nohlsearch
set ruler
set smartcase
syntax on
set softtabstop=4
set shiftwidth=4
@classmethod
def lookup(cls, uid=None):
lang = translation.get_language().replace('-', '_')
query = """
START lang = node:Language(code:{lang}),
node = node:%s(uid:{uid})
MATCH (node)-[:LANGUAGE]->(lang)
RETURN node
""" % (cls.__name__)
r = cls.category().cypher(query, {'uid': uid, 'lang': lang})[0]