Skip to content

Instantly share code, notes, and snippets.

@cliftonc
cliftonc / gist:2652981
Created May 10, 2012 13:27
Delete lots of redis keys
var smartDelete = function(clientName, queryKey, cb) {
var client = redis.getClient(clientName), noneRemaining = false, numDeleted = 0, lastK, duration;
async.whilst(
function () { return !noneRemaining; },
function (callback) {
client.spop(queryKey, function(err, key) {
@cliftonc
cliftonc / gist:3864516
Created October 10, 2012 10:05
Sample message
{
"date": "20121010",
"hour": 9,
"minute": 59,
"data": {
"readCount": 1,
"timeOnSite": 0,
"landingPage": "home"
},
"article": "http://www.dailymail.co.uk/news/article-2215324/Jimmy-Savile-allegations-Unmask-OTHER-BBC-child-abusers-Police-reveal-shocking-scale-Savile-abuse-launch-hunt-accomplices.html",
/**
* Include selector
*/
var request = require('request');
/**
* Handler to take any data-url marked elements and replace the innerHTML with the destination content
*/
module.exports = function dataurl(selectorConfig, options) {
@cliftonc
cliftonc / fifo
Last active September 22, 2022 06:13
Simple LIFO and FIFO queue in Redis
var redis = require("redis"),
client = redis.createClient(),
exitProcessor = false,
queueNext = function() {
process.nextTick(function() {
// Messages are pushed with RPUSH, making this a FIFO queue
client.blpop('queue', 1, queueFn);
})
},
queueFn = function(err, msg) {

Page Composer Service

Composition proxy replacement for ESI, uses node-trumpet.

Installation

git clone git@github.com:TSLEducation/service-page-composer.git
cd service-page-composer
npm install
Verifying myself: My Bitcoin username is +cliftonc. https://onename.io/cliftonc
@cliftonc
cliftonc / gist:daf8df18f1abf756a86c
Created October 1, 2014 18:51
Example rabbitmq stuff
var queueService = require('module-tsl-rabbit/Queue');
var exchangeService = require('module-tsl-rabbit/Exchange');
var resourceHandler = {
onMessage: function (data, message, ackFn, nackFn) {
console.dir(data); // expect {hello:"world"}
ackFn();
}
}
@cliftonc
cliftonc / gist:7d1ab455d5ed895a1cd8
Created November 21, 2014 07:07
Statehood broken cookie
var Statehood = require('statehood');
var definitions = new Statehood.Definitions({ strictHeader: false });
var brokenCookie = "__gads=ID=5217e5ce98e5a5f6:T=1413059056:S=ALNI_MZDmTo6sr27tzMt9RUR65K4xSUWzw; s_fid=79BC0100183D81BE-2708D64605382DEA; TSLCookie=585108831577993685E2ADCF228581BE11AD0DA8B9E378FB8C33DF9B01E21E48C8991D75B61F24E8D7CA2A6A04B2F64B67A6D53A6A375B00EEE705EEADB6ED3FBE04E19D385F5DC89793ADB6978BC6EC17D52A7ED4740D3266C3EDDFCAC2AD881762439AD0485C24B5511984A9D21387921B85193D2689CF6A9B3CCA8CEA4E8939D187CC7327ABC47111A1840C251B1C49DB823713CB866BE0D9958BAAD8CF06D05762525DAD7741272E479BC07CA3D2B35DA1EC2FF8C9284C2996811D4E704573AF8A9E1D4BE609B50A6AC5B29FDC31DCA8460164A44EAB83B730BE565DCC7470EA6C66; TESCookie=XynqF84fIQqO6TMaKPbxsVTGdTQ48cl3KrcYfm0DYZX6eVdcjL9ySX0YHGtk4pqaIJG7TqCiS0%2b6J0bUJgfQR2B7b4AfikEDSl6lrxOdFL9jZQ0vNZuHz9f3Gzr%2f5wu6FSvssSUjGS1paLLxB1UH0idMUHD6RqydZQDVxWpo0BeYg6ZsuSv9XeksslbTqs7FbMetUqSC0JwIRkXsFb6tve7YkunuEg%2fYvrW%2fcsNb1p%2bHXQTWXCKFEa10PMCpXo%2fNw5fV5ofp4svALCnLWUlpO4TDMopHrAD
@cliftonc
cliftonc / ports.js
Created December 3, 2014 06:49
Example project specific bosco command (ports @ TES)
'use strict';
var _ = require('lodash');
var async = require('async');
var fs = require('fs');
var path = require('path');
var Table = require('cli-table');
var repoList = [], repoTable = [];
module.exports = {
name:'ports',
@cliftonc
cliftonc / gist:6d869b41e30b592664d9
Created April 24, 2015 00:13
Getting Started at TES

Getting Started at TES

At TES our approach to building technology is focused on enabling individuals and small teams to deliver small, iterative change to our products quickly, without fear.

Like any simple statements, it hides a lot of complexity, twists and turns that have been taken trying to get us here. We're not there yet, with your help we will get closer day by day.

First things first, we need to get you to the point that you can commit code and deploy to production.

Pre-requisites