Skip to content

Instantly share code, notes, and snippets.

View simonsmith's full-sized avatar

Simon Smith simonsmith

View GitHub Profile
@simonsmith
simonsmith / hotkeys.md
Created May 16, 2014 11:05
List of Bash hotkeys for Mac

Bash Keyboard Shortcuts - Mac

Enable Option Key as Meta in iTerm. Set as Esc+ - http://stackoverflow.com/a/438892

Moving the cursor

  • Ctrl + a Go to the beginning of the line (Home)
  • Ctrl + e Go to the End of the line (End)
  • Ctrl + p Previous command (Up arrow)
  • Ctrl + n Next command (Down arrow)
@simonsmith
simonsmith / jasmine-type-matchers-lodash.js
Last active August 29, 2015 14:00
Jasmine type matchers (native and underscore/lodash)
/**
* Add matchers for different types
* Note that Function.prototype.bind is not supported in PhantomJS
* Uses underscore/lodash
*
* Usage: expect('test').toBeString();
*/
!function() {
'use strict';
(function(context) {
var factories = {}, loaded = {};
var isArray = Array.isArray || function(obj) {
return obj.constructor == Array;
};
var map = Array.map || function(arr, fn, scope) {
for (var i = 0, len = arr.length, result = []; i < len; i++) {
result.push(fn.call(scope, arr[i]));
}
Running "suitcss:component" (suitcss) task
component-resolver remote not set - defaulting to remotes's defaults +0ms
component-resolver:locals resolving local at "/Users/simonsmith/Sites/grunt-suitcss/test/fixtures/component" +0ms
component-resolver resolving "component-test" +5ms
component-resolver:dependencies resolving dependency suitcss/[email protected] +0ms
component-resolver:dependencies searching ["local","github","bitbucket"] for suitcss/[email protected] +0ms
component-resolver remaining dependencies: 1 +6ms
component-resolver remaining semver: 0 +0ms
component-resolver finished resolving locals +0ms
component-resolver:dependencies found suitcss/[email protected] from remote "local" +3ms
@simonsmith
simonsmith / gist:9410249
Created March 7, 2014 12:01
Some bash profile functions
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
python -m SimpleHTTPServer "$port"
}
# grunt
function gi() {
npm install --save-dev grunt-"$@"
}
var Component = React.createClass({
render: function() {
return (
<div className="Component">
// More content here
</div>
)
}
});
@simonsmith
simonsmith / git-log-graph
Last active December 24, 2015 09:49
Awesome detailed git log.
git log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''%C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit --all
Alias it to something like:
git config alias.graph = log --graph ..etc..
For a quick way to get an overview of your current branches etc, use a bash alias
alias gl='git graph -10'
Looks like: http://cl.ly/Ri9R
@simonsmith
simonsmith / vertical-spacing.scss
Created August 29, 2013 16:01
Vertical spacing classes for Sass. Useful with Bootstrap
// Vertical spacing classes
// ------------------------------------
@for $i from 1 through 30 {
$val: $i + 0px;
.mb#{$i} {
margin-bottom: $val;
}
.mt#{$i} {
margin-top: $val;
}
function deparam(str) {
var o = {};
var reg = /\\?([^?=&]+)(=([^&#]*))?/g;
str.replace(reg, function($0, $1, $2, $3) {
if (typeof $3 == 'string') {
o[decodeURIComponent($1)] = decodeURIComponent($3);
}
});
@simonsmith
simonsmith / jquery.measure.js
Created March 11, 2013 17:23
Re-make of MooTools Element.measure for jQuery. Taken from - http://stackoverflow.com/a/7351956/617615
!function(global) {
function definition($) {
$.fn.measure = function(fn) {
var clone = $(this).clone(), result;
clone.css({
visibility: 'hidden',
position: 'absolute'
});
clone.appendTo(document.body);