Skip to content

Instantly share code, notes, and snippets.

@smokinjoe
smokinjoe / gist:8979111dd90b2f2d0bd5
Created April 12, 2015 04:34
Amazing example of async waterfall and map for cheating in nested result queries
// Use waterfall so that you can easily disconnect at the end of your code.
// It also makes node.js callbacks less confusing.
async.waterfall([
function (wCb) {
connection.connect();
// wCB is a callback function. Call it when you want to move to the
// next function in the waterfall
wCb();
},
function (wCB) {
@rsandell
rsandell / bfa_categories.js
Created March 11, 2014 12:21
A Node.js script that aggregates Jenkins Build Failure Analyzer plugin statistics from MongoDB to Graphite, failure categories per hour
/*
The MIT License
Copyright 2014 Sony Mobile Communications AB. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
Attribute VB_Name = "ModStdIO"
Option Explicit
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, lpOverlapped As Any) As Long
@mlhaufe
mlhaufe / parameters.vbs
Created June 19, 2011 12:52
VBScript class constructor parameters
Class Person
Private m_Age
Private m_Name
Public Default Function Init(Name, Age)
m_Name = Name
m_Age = Age
Set Init = Me
End Function
@codepunkt
codepunkt / app.js
Created May 31, 2011 18:50
ExpressJS: set/delete cookies
// Dependencies.
var express = require('express')
app = module.exports = express.createServer(),
del = function(req, res) { res.clearCookie('login_token'); res.redirect('/'); },
set = function(req, res) { res.cookie('login_token', +new Date(), { maxAge: 3600000, path: '/' }); res.redirect('/'); };
// Config
app.configure(function() {
app.use(express.bodyParser());
app.use(express.cookieParser());