Skip to content

Instantly share code, notes, and snippets.

View andyhasit's full-sized avatar

Andrew Buchan andyhasit

View GitHub Profile
#!/bin/bash
# pre-commit script to prevent merge markers from being committed.
# Adapted from here:
# https://jondowdle.com/2015/02/block-merge-conflicts-in-commits/
#
# This simply searches the files that you are about to commit for seven <, >, or
# = at the beginning of a line, followed by a space or the end of the line.
changed=$(git diff --cached --name-only --diff-filter=ACM)
# 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
path=.;
else
path=$1;
'''
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/db.py
'''
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 = ['yourdomain.com', 'yourhosting.company.net']
prefixes = ['smtp.', 'mail.', '']
ports = [':25' ':465', ':993', ':587', '']
sender = 'someone@yourdomain.com'
"""
Script for creating past dated git commits. For the github green dots.
Usage:
>>> cheat 27/2 "my commit message"
will trigger:
>>>git commit -m "my commit message"
/*
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
andyhasit / wtf.spec.js
Last active March 1, 2016 15:33
$q promise breaking loop
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;
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;
});
@andyhasit
andyhasit / MicroTest
Created October 26, 2014 17:12
MircoTest
namespace DataTransferScript # ThirtyLineTestFramework
import System
import System.Reflection
import System.Runtime.Serialization
def RunTests():
passCount = 0
failCount = 0
previousConsoleColour = Console.ForegroundColor