Skip to content

Instantly share code, notes, and snippets.

View scoates's full-sized avatar

Sean Coates scoates

View GitHub Profile
@scoates
scoates / 0_reuse_code.js
Created July 24, 2014 15:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

WHAT?

<?php

function machine_forget(&$data) {
    $data = null;
}

$answer = 42;
@scoates
scoates / salt_roots_sshd-mfa_init.sls
Created March 13, 2015 19:15
SSH + MFA (with Google Authenticator) on Debian Wheezy
include:
# for backports
- apt
openssh6.6:
pkg.installed:
# backports; this number *will* change
- pkgs:
- openssh-server: 1:6.6p1-4~bpo70+1
- openssh-client: 1:6.6p1-4~bpo70+1
@scoates
scoates / timeline
Created April 15, 2015 02:25
Measure the time delta between lines in stdout
#!/usr/bin/env python
import time
from sys import stdin, stdout, argv, exit
try:
if argv[1] == 'help' or argv[1] == '--help' or argv[1] == '-h':
print "%s: times each line of stdin." % argv[0]
print " Optional parameter is a float of a threshold. (defaults to 2.0)"
exit(255);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
based on https://raw.githubusercontent.com/saltstack/salt/develop/tests/eventlisten.py
'''
# Import Python libs
from __future__ import print_function
import optparse
var readline = require('readline');
module.exports = readline;
readline.Interface.prototype.cursorToEnd = function() {
// place the cursor at the end of the current line
this.output.write(
'\x1b[0G\x1b[' + (
this._promptLength + this.line.length
) + 'C'
sarcasm:~/src/tmp$ cat repl.js
repl = require("repl");
repl.start("testrepl> ");
sarcasm:~/src/tmp$ node repl.js
testrepl> 5+5
10
testrepl> sarcasm:~/src/tmp$ echo "5+5" | node repl.js
node.js:63
throw e;
browser
.chain
.session()
.and(function (browser) {
browser
.chain
.open('/')
.assertElementPresent('link=Log out')
.clickAndWait('link=Log out')
.assertElementPresent('link=Log in')
browser
.chain
.session()
.and(function (browser) { // log out
try {
browser
.open('/')
.assertElementPresent('link=Log out')
.clickAndWait('link=Log out')
.assertElementPresent('link=Log in')
var Step = require('./lib/step');
Step(
function () { console.log("one"); },
function () { console.log("two"); }
);