Skip to content

Instantly share code, notes, and snippets.

/**
* This function analyses every DOM element
* that uses rules specified in the css stylesheet
* in the current document matching `cssFilename`
*
* @author Campbell Morgan, 2017
* @example
*
* // 1. either load this code with the document or paste it into Chrome Dev Tools
* // 2. Instantiate the analyser
@campbellwmorgan
campbellwmorgan / facebookPoliticsFilter.js
Last active May 22, 2017 11:46
Filter UK/US Politics from facebook
// ==UserScript==
// @name Facebook Politics Filter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove As Many politics posts as possible from your facebook feed
// @author Campbell Morgan @camsmorgan
// @match https://www.facebook.com/
// @grant none
// ==/UserScript==
#!/bin/bash
# Changes all spaces to tabs in a javscript project
# run at project root
files=`find . -path ./node_modules -prune -o -name "*.js"`
for file in $files; do
echo "Processing $file"
cat "$file" | unexpand -t 2 > "$file.new"
rm -f "$file"
// drop this file into maya where your
// fully rigged (by AdvancedSkeleton 5.1 +) model is open
// disable effect of faceupper and facelower fk
// keep elements so that "go to build pose" doesn't break
delete FaceUpper_M_parentConstraint1;
delete FaceUpper_M_scaleConstraint1;
delete FaceLower_M_parentConstraint1;
delete FaceLower_M_scaleConstraint1;
/**
* Module for abstracting pub sub
* across all scopes
* @example
*
* var events = PubSub($scope, 'MyModule:');
* events.on('AnotherModule:Update', function(e, data) {
* console.log(data, 'from Update');
* });
* events.emit("Change", {myData:'data'});
@campbellwmorgan
campbellwmorgan / post-checkout
Created October 25, 2015 16:16
Custom Sitechef config files for different git branches
#!/bin/bash
#######
# Enables branch-specific sitechef config files
# my moving data.json and .sitechef/.conf to subdirectories
# named after the branch name
#
# Installation
# Copy this file to your .git/hooks/ folder
######
@campbellwmorgan
campbellwmorgan / gist:e305cc36365fa2d052a7
Last active December 29, 2016 09:59
Model Mock for unit testing Sails.js applications
var Waterline, count, memory, _;
_ = require('lodash');
// sails-memory stores the adapter as a
// variable and it needs a different version for each instance
count = 0;
Waterline = require('waterline');
/**
* This goes in the api/hooks folder
* and uses the so-far unstable sails events
* works in sails 0.10.x
*/
var generator = require('password-generator');
module.exports = function(sails) {
return {
@campbellwmorgan
campbellwmorgan / shutdownscript
Created February 28, 2014 15:03
A template for a shutdown init.d script (tested on RHEL)
#!/bin/bash
# shutdownscript - a template for a script that will run on shutdown
# chkconfig 2345 99 01
# write the name of the file (which will be the daemon here)
scriptname="shutdownscript"
# installation instructions:
# - save this script in /etc/init.d/[yourscriptname]
# - chown root:root [yourscriptname]