Skip to content

Instantly share code, notes, and snippets.

set msg to ""
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN (PPTP)"
if exists VPNservice then
set isConnected to connected of current configuration of VPNservice
if isConnected then
disconnect VPNservice
set msg to "Disconnected"
else
function hostReachable() {
// Handle IE and more capable browsers
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
var status;
// Open new request as a HEAD to the root hostname with a random param to bust the cache
xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), false );
// Issue request and handle response
var fs = require('fs'),
zmq_sockets = require('./zmq_sockets'),
log4js = require('log4js');
log4js.loadAppender('file');
log4js.addAppender(log4js.appenders.file('/tmp/INode.log'));
var logger = log4js.getLogger("app");
function startKernel(configFile) {

##The Singleton Pattern

class SantaClaus {

	private static uniqueInstance : SantaClaus;
	
@hfeeki
hfeeki / redis.js
Last active August 29, 2015 14:06 — forked from yssk22/redis.js
/**
* retwis-js.js
*
* Description:
*
* redis tutorial program impelmented by node.js
*
* Usage:
*
* node redis.js
@hfeeki
hfeeki / app.js
Last active August 29, 2015 14:06 — forked from elranu/app.js
//app.js Socket IO Test
var app = require('express').createServer(),
redis = require('socket.io/node_modules/redis'),
io = require('socket.io').listen(app);
var pub = redis.createClient(port, "url");
var sub = redis.createClient(port, "url");
var store = redis.createClient(port, "url");
pub.auth('pass', function(){console.log("adentro! pub")});
sub.auth('pass', function(){console.log("adentro! sub")});
@hfeeki
hfeeki / randomStr.js
Last active August 29, 2015 14:06 — forked from aseemk/randomStr.js
var bases = require('bases');
var crypto = require('crypto');
// Returns a base-62 (alphanumeric only) string of the given length:
function randomStr(length) {
// We generate a random number in a space at least as big as 62^length,
// and if it's too big, we just retry. This is still statistically O(1)
// since repeated probabilities less than one converge to zero. Hat-tip to
// a Google interview for teaching me this technique! ;)
@hfeeki
hfeeki / LICENSE.txt
Created August 25, 2014 04:52 — forked from jed/LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hfeeki
hfeeki / gist:7100dc43321353ccca7c
Last active August 29, 2015 14:05 — forked from klovadis/gist:2549131
How to use optional arguments in node.js
// example function where arguments 2 and 3 are optional
function example( err, optionalA, optionalB, callback ) {
// retrieve arguments as array
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
// first argument is the error object
@hfeeki
hfeeki / app.js
Created August 21, 2014 01:32 — forked from elranu/app.js
//app.js Socket IO Test
var app = require('express').createServer(),
redis = require('socket.io/node_modules/redis'),
io = require('socket.io').listen(app);
var pub = redis.createClient(port, "url");
var sub = redis.createClient(port, "url");
var store = redis.createClient(port, "url");
pub.auth('pass', function(){console.log("adentro! pub")});
sub.auth('pass', function(){console.log("adentro! sub")});