Skip to content

Instantly share code, notes, and snippets.

View hash-bang's full-sized avatar

Matt Carter hash-bang

View GitHub Profile
@hash-bang
hash-bang / memcached.js
Created September 22, 2016 04:19
Memcached demo
var _ = require('lodash');
var async = require('async-chainable');
var memcached = require('memcached');
var cache = new memcached('127.0.0.1:11211');
async()
.forEach(_.shuffle(_.times(1000, i => i)), function(next, i) {
cache.get('demo.' + i, function(err, res) {
console.log('Hello', i, res);
@hash-bang
hash-bang / app.js
Created September 20, 2016 20:56
Simple Conkie JS example
var electron = require('electron');
electron.ipcRenderer
// Tell Conkie that we want CPU and memory info
.send('statsRegister', ['cpu', 'memory'])
// Recieve module statistics when Conkie provides them
.on('updateStats', function(e, data) {
// Update local data
@hash-bang
hash-bang / dynamicClosureLimit.js
Created September 1, 2016 07:45
angular-q-limit Examples
// This example uses a dynamic array of items, creating a promise for each and finally executing them via $q.limitAll with a maximum of 3 items running concurrently
// Assumes SomeModel is a promise based structure like $http or ngResource
var stuff = [ // Very big array of things to request // ];
$q.limitAll(3,
stuff.map(function(item) {
return SomeModel.get({id: item}).$promise;
@hash-bang
hash-bang / gulp-tasks-scripts.js
Created February 12, 2016 01:12
Example Gulp task for scripts building using gulp-notify
/**
* Compile all JS files into the build directory
*/
var scriptBootCount = 0;
gulp.task('scripts', ['load:config'], function() {
var hasErr;
return gulp.src(paths.scripts)
.pipe(gplumber({
errorHandler: function(err) {
gutil.log(colors.red('ERROR DURING JS BUILD'));
@hash-bang
hash-bang / lodash-depreciated.sh
Created February 5, 2016 00:05
Simple script to scan a directory recursively for potentially altered Lodash v4 functions
#!/bin/bash
# Scans a project recursively for depreciated lodash functions
#
# Usage: lodash-depreciated [other grep options]
#
# Lodash changelog - https://github.com/lodash/lodash/wiki/Changelog#v400
grep \
--color=auto -r \
--exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=.git --exclude-dir=build --exclude-dir=data \
@hash-bang
hash-bang / exec-to-post
Created December 21, 2014 06:40
Exec() to Request.Post()
var exec = require('child_process').exec;
var request = require('request');
exec('echo hello world', function(err, stdout, stderr) {
request.post({
method: 'POST',
url: 'http://localhost/post/this/somewhere',
formData: {
myFile: {