Skip to content

Instantly share code, notes, and snippets.

View tracker1's full-sized avatar

Michael J. Ryan tracker1

View GitHub Profile
@tracker1
tracker1 / fizzbuzz.js
Created December 11, 2014 19:40
Fizz Buzz - JavaScript
function fb(num) {
var fizz = !(num % 3) ? 'Fizz' : ''
,buzz = !(num % 5) ? 'Buzz' : '';
return fizz + buzz || num;
}
for (var i=1; i<101; i++) console.log(fb(i));
@tracker1
tracker1 / SocketDescriptorStream.cs
Created January 28, 2015 18:09
SharpDoorKit - start of a ,Net based door kit - C wrapper for socket descriptor
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace SharpDoorKit {
public class SocketDescriptorStream : Stream {
@tracker1
tracker1 / get-mssql-connection.js
Created January 28, 2015 21:46
get-mssql-connection.js
//get-connection.js
'use strict';
require('promisify-patch').patch();
var _ = require('lodash')
,cfg = require('./config')
,sql = require('mssql')
,Promise = require('i-promise')
,pools = {}
@tracker1
tracker1 / mac-and-cheese.txt
Created January 28, 2015 22:22
Mac And Cheese
Tools:
Cheese grater
strainer (for pasta)
1.5 gallon + pot (for pasta)
2 quart sauce pan (for sauce)
2 quart casserole dish (for baking)
1 whisk for mixing
2 medium bowls (one for topping mix, the other for mixing the wet ingredients)
Ingredients:
@tracker1
tracker1 / getcookies.js
Created February 19, 2015 20:09
getcookies.js
//requires ES5, or a shimmed browser for map/reduce
module.exports = function getCookies() {
if (!(this.document && this.document.cookie)) return {}; //no cookies for you
return this.document.cookie.split(/;\s+/g)
.map(function(x){
var kv=x.match(/([^\=]*)\=(.*)/);
return [kv[1]||'',kv[2]||''].map(decodeURIComponent);
})
.reduce(
function(v,kv){
@tracker1
tracker1 / README.md
Last active August 29, 2015 14:16
environment variables for npm to use VS 2013

Building node.js / io.js binary modules in Windows

  • You will need the latest Python 2.7.x installed (Should install to C:\Python27\ and will set environment variables). You will need to close your command prompt and re-open for this change to take effect.
  • You should have a recent version of Visual Studio installed.
  • Because node-gyp defaults to expecting VS 2010, you can save your version configuration via npm...
    • npm config set msvs_version 2013
  • Alternatively, you can specify the version via the following environment variables
    • SET GYP_MSVS_OVERRIDE_PATH=true
  • SET GYP_MSVS_VERSION=2013
@tracker1
tracker1 / filter-etcd-config.js
Last active August 29, 2015 14:16
This is functional JavaScript - composition first
require('cc-globals'); //establishes fetch and R (ramda library) globally
//regular expression for valid etcd address
var address = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:\d{1,5}$/;
//if the input is a string, makes it an array containing the string, otherwise returns the original input
var fixStr = (v) => typeof v === 'string' ? [v] : v;
//converts collection input to an array, returns empty array otherwise
var fixArray = (v) => v && v.length && Array.prototype.slice.call(v) || [];
@tracker1
tracker1 / keybase.md
Created March 13, 2015 18:27
keybase.md

Keybase proof

I hereby claim:

  • I am tracker1 on github.
  • I am tracker1 (https://keybase.io/tracker1) on keybase.
  • I have a public key whose fingerprint is A61A A793 9795 B51D 33FF C8DD 94C6 BAE3 A095 6216

To claim this, I am signing this object:

@tracker1
tracker1 / .eslintrc
Created March 24, 2015 00:43
ES6 Testing With Mocha and BabelJS
{
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": false,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
@echo off
set batchdir=%~d0%~p0
:start
"%batchdir%pngquant.exe" --ext .q.png --force --verbose 256 %1
"%batchdir%optipng.exe" -force -o4 -out "%~dpn1.opt.png" "%~dpn1.q.png"
del "%~dpn1.q.png"