Skip to content

Instantly share code, notes, and snippets.

git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"'
git push origin master
@stephen-james
stephen-james / gist:6296221
Last active December 21, 2015 10:59
using Moq and Asserts on a saved object (saved via callback) after call, allows for nice seperation of Arrange,Act,Assert! from http://stackoverflow.com/questions/4956974/verifying-an-specific-parameter-with-moq
// Arrange
MyObject saveObject;
mock.Setup(c => c.Method(It.IsAny<int>(), It.IsAny<MyObject>()))
.Callback<int, MyObject>((i, obj) => saveObject = obj)
.Returns("xyzzy");
// Act
// ...
// Assert
@stephen-james
stephen-james / script
Created August 30, 2013 13:07
playing with mouse based paralax need to refine this
$(document).mousemove(function (event) {
console.log(event);
var offsetPercentageX = Math.floor(event.clientX / window.innerWidth * 20) + "%";
var offsetPercentageY = Math.floor(event.clientY / window.innerHeight * 20) + "%";
$("section.content").css("background-position", offsetPercentageX + " " + offsetPercentageY);
});
@stephen-james
stephen-james / resizeSVG
Created September 3, 2013 09:56
resize svg using debouncing and an event stack to render at a maximum of 60hz
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
// set refresh rate to 60hz
var refreshRate = 1000 / 60,
debounceThreshold = 500,
resizeEventStack = [],
@stephen-james
stephen-james / flexbox.less
Created September 9, 2013 09:54
flexbox.less provides universal support for 2009/2011 draft and standard versions of the flexbox specification.
// flexbox.less
// https://gist.github.com/stephen-james/6493651
.flexbox(@inline : false) when (@inline)
{
// support the 2009 Draft
display : -webkit-inline-box;
display : -moz-inline-box;
display : inline-box;
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_setDomainName', 'yoursite.com']);
_gaq.push(['_addIgnoredRef', 'yoursite.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
@stephen-james
stephen-james / resolveAppliedStyle.js
Last active December 23, 2015 23:59
resolveAppliedStyle, taken from http://stackoverflow.com/questions/7786972/how-to-determine-if-width-has-px-or/7787148 with a few variable name changes to suit my preferences.
(function(){
var documentElement = document.documentElement,
matchesSelector =
documentElement.matchesSelector ||
documentElement.mozMatchesSelector ||
documentElement.webkitMatchesSelector ||
documentElement.msMatchesSelector ||
documentElement.oMatchesSelector;
if (!matchesSelector) {
@stephen-james
stephen-james / .gitconfig
Last active December 24, 2015 16:19
using WebStorm as mergetool for command line git (updated to include vsdiffmerge as another option)
[merge]
tool = webstorm
[diff]
tool = webstorm
[difftool "webstorm"]
cmd = webstorm diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")
trustExitCode = false
[mergetool "webstorm"]
cmd = webstorm merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = false
@stephen-james
stephen-james / gothicarch.js
Created October 10, 2013 12:23
gothic arches anyone? answer to a stackoverflow question...
var GothicArchFactory = function() {
var _60degrees = 1.04719755, // radians for Math trig functions
_30degrees = 0.523598776,
_createArch = function(archWidth, archHeight) {
// this private method creates and returns the arch...
// the arch knows it's dimensions and can draw itself on
// a canvas
return {
archWidth : archWidth,
@stephen-james
stephen-james / jquery.throttledResize.js
Created October 17, 2013 16:47
throttled jquery resize, borrowing heavily from Underscore.js 's throttle method...
(function($,throttledResizeEvent){
var throttle = function (func, wait) {
var context,
args,
result,
timeout,
previous;
wait = wait || 1000 / 60;