Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Script to easily create VHosts
echo "Enter URL [ENTER]:"
read url
echo "Enter folder path [ENTER]:"
read path
@ksafranski
ksafranski / PortProxyApache2
Created June 19, 2013 13:15
Port-based Apache proxy (good for nodejs apps) via VirtualHost
1. Run the following commands:
a2enmod proxy
a2enmod proxy_http
2. Setup a VirtualHost in /etc/apache2/sites-available/
<VirtualHost *:80>
ServerName something.mydomain.com
ProxyPass / http://something.mydomain.com:9999
@ksafranski
ksafranski / grunt-templates.js
Last active December 19, 2015 19:09
Grunt multitask for compiling tpl files into one source.
/*
Usage:
... grunt config ...
templates: {
main: {
header: '\n<!-- {{tplbasename}} -->\n<div data-tpl="{{tplbasename}}">\n',
footer: '\n</div>\n',
@ksafranski
ksafranski / expecting.md
Last active February 27, 2026 12:43
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
@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 / 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"
var validate = function (data, model, cb) {
var failures = [];
var regEx;
var validJSON;
var processNode;
var result;
var traverseNodes;
// Define common regular expressions
@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>
@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 / 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]