Skip to content

Instantly share code, notes, and snippets.

View ksafranski's full-sized avatar

Kent Safranski ksafranski

View GitHub Profile
// Client-side
io.connect({
forceNew: true,
transports: [ 'websocket' ]
});
// Server-side
var io = require('socket.io');
var app = require('express')();
var server = require('http').createServer(app);
@ksafranski
ksafranski / setup.sh
Last active February 3, 2016 01:59
Environement Setup
#!/bin/bash
# Run update
apt-get update
wait
# Install build-essentials
apt-get --yes --force-yes install build-essential
wait
@ksafranski
ksafranski / codio.sh
Last active August 29, 2015 14:01
Codio Setup
echo "zsh && exit 0" >> ~/.bash_profile &&
curl -L http://install.ohmyz.sh | sh
@ksafranski
ksafranski / deploy.js
Created May 20, 2014 12:47
Deploy to multiple environments on Nodejitsu with the same application
// Nodejitsu multiple environment deploy
//
// Prerequisits:
// Jitsu deploy CLI
//
// Usage:
// Include this file in root of project along with configured
// jitsu_conf.json file
// Run by calling:
// node deploy [ENV]
@ksafranski
ksafranski / Router.js
Last active June 15, 2020 11:59
Simple hash-based router with :params and 404
// Router object
var Router = function () {
var self = this;
// Watch hashchange
window.onhashchange = function () {
self.process();
};
// Run on load
@ksafranski
ksafranski / index.html
Created February 23, 2014 02:04
Demo UI for DozerJS TodoList App Tutorial
<!DOCTYPE html>
<html>
<head>
<title>DozerJS TodoList</title>
<link rel="stylesheet" href="screen.css">
</head>
var validate = function (data, model, cb) {
var failures = [];
var regEx;
var validJSON;
var processNode;
var result;
var traverseNodes;
// Define common regular expressions
@ksafranski
ksafranski / update.tcl
Created August 23, 2013 16:57
Update user example script for Tcl-Expect presentation
#!/usr/bin/expect
set timeout 3
log_user 0
# Define some variables
set user_prefix "user"
set server "echosec.com"
@ksafranski
ksafranski / adduser.tcl
Created August 23, 2013 16:55
Simple add-user example script for Tcl-Expect presentation
#!/usr/bin/expect
set timeout 3
# Define some variables
set user_prefix "user"
set server "echosec.com"
# Get arguments
@ksafranski
ksafranski / expecting.md
Last active November 11, 2023 23:00
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect