Skip to content

Instantly share code, notes, and snippets.

View jslatts's full-sized avatar

Justin Slattery jslatts

View GitHub Profile
@jslatts
jslatts / gist:8758791
Created February 1, 2014 21:01
config.hdf for drupal + hhvm
Log {
Level = Error
NoSilencer = false
AlwaysLogUnhandledExceptions = true
RuntimeErrorReportingLevel = 8191
Header = false
InjectedStackTrace = true
NativeStackTrace = true
MaxMessagesPerRequest = -1
# error log settings
@jslatts
jslatts / user_add.sls
Created April 7, 2014 20:58
SaltStack Custom Python State to Add Users
#!py
def run():
'''
Manage sudo enabled user adds/removes
'''
# temp fix for regression https://github.com/saltstack/salt/issues/7693
if '__pillar__' in globals():
globals()['pillar'] = globals()['__pillar__']
@jslatts
jslatts / Dockerfile
Last active August 29, 2015 14:05
Dockerfile for node.js app
# Dockerfile to run node app
# VERSION 1 - EDITION 2
# Base image used is Ubuntu 14.04 LTS
FROM ubuntu:14.04
MAINTAINER me
# Install wget
RUN apt-get update && apt-get install -y \
@jslatts
jslatts / CommentStore.js
Last active August 29, 2015 14:17
Example RefluxJS Store
'use strict';
//External
var Reflux = require('reflux');
//Local
var CommentActions = require('./CommentActions');
var CommentStore = Reflux.createStore({
@jslatts
jslatts / gist:902715
Created April 4, 2011 23:36
Calling functions for redis callback example
function purgatory() {
var inPurgatory = true;
return {
tryToGetOut: function (message, client, cb) {
auth.authenticateUserByHash(message.user, message.hash, function(err, data) {
if (err) {
winston.info('[purgatory] Bad auth. Client still in purgatory');
inPurgatory = true;
}
else {
@jslatts
jslatts / gist:902705
Created April 4, 2011 23:30
Redis callback example
exports.authenticateUserByHash = function(name, hash, fn) {
winston.info('[authenticateUserByHash] Starting hash auth for ' + name + ' with hash ' + hash);
var rKey = 'user:' + name;
rc.get(rKey, function(err, data){
if(err) return fn(new Error('[authenticateUserByHash] GET failed for key: ' + rKey + ' for value: ' + name));
if (!data) {
fn(new Error('[authenticateUserByHash] user: ' + name + ' not found in store.'));
}
@jslatts
jslatts / gist:938781
Created April 23, 2011 17:08
Events won't bind.
var NodeChatView = Backbone.View.extend({
initialize: function (options) {
var main, that;
_.bindAll(this, 'addUser', 'removeUser', 'addChat', 'removeChat', 'triggerAutoComplete', 'suggestAutoComplete', 'sendMessage');
this.model.users.bind('add', this.addUser);
this.model.users.bind('remove', this.removeUser);
this.model.chats.bind('add', this.addChat);
this.model.chats.bind('remove', this.removeChat);
this.newMessages = 0;
@jslatts
jslatts / gist:1001829
Created June 1, 2011 05:32
testing question
<snipped>
var watchFolderTree = function (fPath, fn) {
if (typeof fn !== 'function') {
throw {
name: 'TypeError',
message: 'fn must be a function'
};
}
//Do lots of things to watch the folder tree
@jslatts
jslatts / gist:1008072
Created June 4, 2011 17:06
Example of using connect session cookies with socket.io
socket.on('connection', function(client){
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
if (!client.request || !client.request.headers || !client.request.headers.cookie) {
disconnectAndRedirectClient(client,function() {
console.log('Null request/header/cookie!');
});
return;
}
@jslatts
jslatts / gist:1034914
Created June 19, 2011 23:46
vows.js async callback state example
'file remove in watched dir': {
topic: function () {
var lPath = tPath + '/t2';
try {
fs.mkdirSync(lPath, '0755');
}
catch (Exception) {}
return lPath;
},
'calling stalker.watch': {