Skip to content

Instantly share code, notes, and snippets.

@tracker1
tracker1 / package.json
Created Aug 20, 2012
Setting the current date/time in windows.
View package.json
{
"name":"update-dtm"
,"version":"0.1.0"
,"dependencies":{
"request":"2.x.x"
}
,"devDependencies":{}
}
@tracker1
tracker1 / sqltext.coffee
Created Sep 14, 2012
Module exports in coffeescript
View sqltext.coffee
# Without the anonymous function wrapper, it seemed to only export the first value.
(->
exports.getTopOfQueue = """
SELECT TOP 10
[Id],[CreatedOn],[LastAttemptOn],[Application],[Class],[From],[To],[Subject],[BodyUrl],[BodyHtml],[JsonDetails]
FROM [EmailQueue]
WHERE [LastAttemptOn] < DATEADD(m, -15, SYSUTCDATETIME())
ORDER BY [Id]
"""
@tracker1
tracker1 / CardReader.js
Created Nov 29, 2012
Wrapping an external service...
View CardReader.js
var EventEmitter = require("events").EventEmitter;
var util = require("util");
module.exports = CardReader;
//the export is essentially a self-healing wrapper around the external interface...
function CardReader() {
var that = this, someProc = null;
loadProc();
function loadProc() {
@tracker1
tracker1 / _Layout.cshtml
Created Apr 29, 2013
CSHTML Layout to get model/view/controller names into the document...
View _Layout.cshtml
@functions{
string currentController = null;
string currentAction = null;
string currentModel = null;
private void InitVars() {
ViewBag.Phone = phone;
currentController = ViewContext.RouteData.Values["Controller"].ToString().ToLower();
currentAction = ViewContext.RouteData.Values["Action"].ToString().ToLower();
@tracker1
tracker1 / UnityUtil.cs
Created May 30, 2013
Below is an example of creating a generic WCF Service Client from the interface base, as well as an extension method for Unity.
View UnityUtil.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Runtime.Serialization;
@tracker1
tracker1 / TestUtility.cs
Last active Dec 19, 2015
Create an Entity Framework context bound to a model against an empty SQL Compact Edition (SQL CE) database file, for purposes of repository testing.
View TestUtility.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Data.EntityClient;
using System.Data.Metadata.Edm;
using System.Data.SqlServerCe;
using System.IO;
using System.Linq;
using System.Reflection;
@tracker1
tracker1 / DockerCheatSheet.sh
Last active Dec 28, 2015
DockerCheatSheet - update for docker 0.7.0
View DockerCheatSheet.sh
base image tracker1/nodejs -- ubuntu 12.04 w/ python 2.7, build tools and nodejs 0.10.22
build docker app, from app dir :tagname
sudo docker build -t tracker1/nodejs-demo:1 .
run docker app in bg / -p ### will create random forward for port X
-d is daemon mode, or & at the end for background
sudo docker run -d -name demo1 tracker1/nodejs-demo:1
@tracker1
tracker1 / router-admin-scripts.sh
Created Nov 26, 2013
Tomato Router - Limit Guest Wifi
View router-admin-scripts.sh
#Setup bridge for guest wifi (br1) with separate subnet/dhcp
# setup virtual wifi wlan0.1
#the following rules go under administration -> scripts -> firewall then reboot after saving
#NOTE: -I inserts at the beginning be default, so restrictive rules at the top, permissive at the bottom.
#default deny guest
iptables -I FORWARD -i br1 -j DROP
#Removes guest access to physical network
@tracker1
tracker1 / etc-network-interfaces
Created Feb 7, 2014
network config, multiple ips for a single interface.
View etc-network-interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0