Skip to content

Instantly share code, notes, and snippets.

View ZeroBugBounce's full-sized avatar

Richard Lowe ZeroBugBounce

View GitHub Profile
@ZeroBugBounce
ZeroBugBounce / commit-msg
Last active August 29, 2015 13:56
A git prepare-commit-msg hook to add Jira ID automatically to all feature branch commits
#!/usr/bin/env python
import re
import subprocess
import sys
f = open( sys.argv[1], "r" )
commit_msg = f.read();
f.close()
current_branches = subprocess.check_output(["git", "branch", "--no-color"])
@ZeroBugBounce
ZeroBugBounce / timelineAndProfile.js
Created March 20, 2014 14:09
Record both a timeline and profile your JS simultaneously
// just enter this on the console to record both for 3 seconds
(function() {
console.timeline();
console.profile();
setTimeout(function() {
console.timelineEnd();
console.profileEnd();
}, 3000);
})();
@ZeroBugBounce
ZeroBugBounce / fowardEvents.js
Created June 19, 2014 14:50
Forwarding of events from one UI element or set of elements to another
// this shows forwarding jQuery events to native events
// where the target is hard-coded
forwardEventTo: function(e) {
var iframeDocument = this.$el.find('iframe')[0].contentWindow.document;
var target = iframeDocument.elementFromPoint(e.offsetX, e.offsetY);
if (target) {
var props = _.extend(e.originalEvent, {
srcElement: target,
@ZeroBugBounce
ZeroBugBounce / track-focus.js
Created August 27, 2014 15:49
Track the current active element (focused) in 100ms intervals
storage = { }; setInterval(function() {
if(storage.activeElement !== document.activeElement) {
storage.activeElement = document.activeElement;
console.log('new active element: %o', document.activeElement);
}
}, 100);
@ZeroBugBounce
ZeroBugBounce / findCssPropForSelector.js
Last active August 29, 2015 14:06
Find a value of a specific CSS property in declared styles of a document
// requires underscore.js or lodash.js
function findCssPropForSelector(className, prop) {
var rule;
_.each(document.styleSheets, function(ss) {
_.each(ss.cssRules, function(r) {
if(r.cssText.indexOf(className) >= 0) {
console.log('%s: %s', ss.href, r.style[prop]);
}
});
@ZeroBugBounce
ZeroBugBounce / Find-Listeners.psh
Created September 10, 2014 15:12
Powershell: find listeners for a port
netstat -aon | where-object {$_ -like '*2222*'}
@ZeroBugBounce
ZeroBugBounce / findNameIn.js
Last active August 29, 2015 14:11
Find a property name in a JavaScript object tree
function findNameIn(obj, searchFor, ignoreCase, findPartial, parentPath, searched) {
var searchedObjects;
if(!searched) {
searchedObjects = [obj];
}
else {
searchedObjects = searched;
}
@ZeroBugBounce
ZeroBugBounce / feat.sh
Created December 18, 2014 17:33
Create a feature branch from current branch with descriptive name
feat() {
git checkout develop
git pull
git checkout -b feature/DEB-"${@// /-}"
}
@ZeroBugBounce
ZeroBugBounce / my-git-log.sh
Last active October 22, 2015 15:57
Various git log techniques
# This shows the git log in a color-coded one line format, excludes merge commits
# and omits (grep -v) commits that mention 'chef'. It also places line numbers
# in front of the commits that are listed, for squashing on HEAD~# purposes.
gitlog() {
(git log -${@-20} --pretty=format:'%C(yellow)%h%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --no-merges | grep -v 'chef') | awk '{printf("%3d %s\n", NR, $0)}'
}
@ZeroBugBounce
ZeroBugBounce / RedditUrlBuilder
Created March 29, 2013 21:28
Helps to create the URLs for the Reddit API in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ZeroBugBounce.ReddShift
{
public class RedditUrlBuilder
{
// http://www.reddit.com/top/?sort=top&t=week