Skip to content

Instantly share code, notes, and snippets.


Arnar Yngvason demux

View GitHub Profile
demux / NsCache.php
Last active Jun 8, 2017
I drafted this proposal to solve the problem of deleting all keys with a certain prefix from `memcached`, but we decided to go with `redis` instead, as I'd previously suggested. This is an incomplete Kohana Controller.
View NsCache.php
// If we hadn't gone with `redis` I would have implemented something like this
// for abstracing away the "complicated" stuff...
class NsCache() {
// ...
* Get cache from namespace
from schematics.models import Model
from schematics.types import BaseType, StringType, BooleanType, IntType
from schematics.types.compound import ListType, ModelType as _ModelType, DictType
from schematics.transforms import blacklist, export_loop
import ruamel.yaml as yaml
from ruamel.yaml.comments import CommentedMap
from ruamel.yaml.scalarstring import PreservedScalarString
from ruamel.yaml.compat import string_types, ordereddict
demux / common.js
Created Jan 28, 2016
Sort an expression like "abc(d)(ef)(ghi)"
View common.js
import {isArray, cloneDeep} from 'lodash'
export class ExtendableError extends Error {
constructor(message) {
super(message) =
this.message = message
class SimpleEventEmitter:
_events: []
_onceWrapper: (type) ->
wrapper = ~>
@off(type, wrapper)
fn.apply(this, arguments)
on: (type, fn, once=false) !->
@_events[type] = @_events[type]? or []
View findfilehosttest.js
var url = $("script[src$='findfilehosttest.js']").attr('src')
var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i)
var domain = matches && matches[1]
View request.php
function R($param, $default=null, $type='string') {
return $default;
$r = $_REQUEST[$param];
if($type === 'bool' || $type === 'boolean') {
if($r === 'false' || $r === 'no')
return false;
return !empty($r);
settype($r, $type);
View nearSort.js
function nearestInList(number, list, returnDistance) {
var distance = Infinity;
var n = null;
for(var i in list) {
var _distance = Math.abs(list[i] - number);
if(_distance < distance) {
distance = _distance;
n = list[i];
demux / 0_reuse_code.js
Created Oct 22, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
demux / exchange-rates.php
Created Jun 24, 2013
Convert XML exchange rates from to JSON or JSONP for money.js (
View exchange-rates.php
$xml_url = '';
$data = simplexml_load_file($xml_url);
$out = array(
'timestamp' => time(),
'base' => 'ISK',
'rates' => array()
demux /
Created Jun 15, 2012
Unit test for liveproject upload api
# -*- coding: utf-8 -*-
from django.utils import unittest
from django.test.client import Client
import simplejson as json
import hashlib
from settings import PROJECT_PATH
from main.models import Event
You can’t perform that action at this time.