Skip to content

Instantly share code, notes, and snippets.


Andrew Buchan andyhasit

View GitHub Profile
# A shell function you can use to:
# - ls a dir
# - tail a file
# - edit a file
# - remove a file or directoty
lp () {
if [[ -z $1 ]]; then
View gist:7aadacb655938ae9146925d6ff1cbc35
Here's a suggested revision with following changes:
1) Renamed field "message" as that is a reserved keyword in some dbs (must remember to change form.vars.message to form.vars.form_message in the call to send or it will be null and you get a nasty error, in 2.14.6 at least)
2) Checks if email actually sent, as otherwise the notification is erroneous.
3) Added reply_to, which helps.
3) Changed to use modern string formatting, just because.
4) Changed to not use flash message unless there's an error, because I think its nicer, but you may disagree :-)
# append to scaffoling models/
Place this in a controller and call it, either by url or directly from code.
An email(or multiple) with the correct settings will be sent to the
test address.
def test_mail():
bases = ['', '']
prefixes = ['smtp.', 'mail.', '']
ports = [':25' ':465', ':993', ':587', '']
sender = ''
Script for creating past dated git commits. For the github green dots.
>>> cheat 27/2 "my commit message"
will trigger:
>>>git commit -m "my commit message"
View QueuedResponseDb.js
Wraps a db object such as PouchDB instance (currently just: post put get remove)
And ensures those actions, which are promises, resolve in the order they were called.
Essentially creates a synchronous interface to a db.
app.factory('QueuedResponseDb', function($q, ValueRegister) {
var QueuedResponseDb = function(db) {
var self = this;
andyhasit / wtf.spec.js
Last active Mar 1, 2016
$q promise breaking loop
View wtf.spec.js
c = console;
angular.module('Test', []);
angular.module('Test').factory('Collection', function($q) {
var Collection = function() {var self = this;
self.__items = {};
self.__relationships = [];
var def = Collection.prototype;
View gist:131acfebde60fe03f0b0
angular.module('turboshell').factory('MyWebSocket', function() {
This only exists so I can mock it. You can mock it too. Haha, look at it! It's so tiny! Hahahahhha!
return WebSocket;
View MicroTest
namespace DataTransferScript # ThirtyLineTestFramework
import System
import System.Reflection
import System.Runtime.Serialization
def RunTests():
passCount = 0
failCount = 0
previousConsoleColour = Console.ForegroundColor