Skip to content

Instantly share code, notes, and snippets.

@mmazer
mmazer / macos.sublime-keymap
Created October 4, 2019 12:34
Sublime Text MacOS keybindings
[
// Vintage
{ "keys": ["ctrl+["],
"command": "exit_insert_mode",
"context": [
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
},
{ "keys": ["j","j"],
@mmazer
mmazer / init.vim
Created January 29, 2016 14:18
Vim mapping to re-indent buffer and return to current cursor position
" re-indent buffer and return to current position
nnoremap g= gg=G``
@mmazer
mmazer / transducers.js
Created January 28, 2016 15:30
Transducers in JavaScript
function compose(f, g) {
if (arguments.length === 2) {
return function() {
return f(g.apply(null, arguments));
};
}
var args = [];
for (var i = 0, len = arguments.length; i < len; i++) {
args[i] = arguments[i];
@mmazer
mmazer / tags.md
Last active December 17, 2015 02:19
Git: Working with tags

Delete local and remote tag

git tag -d 12345

git push origin :refs/tags/12345

@mmazer
mmazer / nonnumeric.js
Created April 18, 2013 01:58
JavaScript - replace all non-numeric chars
var re = /[^0-9]/g;
"416 345-3333".replace(re, ''); // returns 4163453333
@mmazer
mmazer / regex.js
Created April 18, 2013 01:56
Regex - password
/(?=.*\d.*)(?=.*[a-zA-Z].*)(?=.*[!#\$%&\?].*).{8,}/
@mmazer
mmazer / git-submodules.md
Created April 17, 2013 13:33
Git - using submodules

Add a submodule

git submodule add <repository> <directory>

Update submodules

git pull --recurse-submodules
git submodule update --recursive

Remove a submodule

@mmazer
mmazer / parseheaders.js
Created April 17, 2013 13:30
JavaScript - parse XmlHttpRequest.getAllResponseHeaders into a key value pair.
/**
* XmlHttpRequest's getAllResponseHeaders() method returns a string of response
* headers according to the format described here:
* http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders-method
* This method parses that string into a user-friendly key/value pair object.
*/
function parseResponseHeaders(headerStr) {
var headers = {};
if (!headerStr) {
return headers;
@mmazer
mmazer / iemin.css
Created April 17, 2013 13:29
CSS - IE min-height fix
[selector] {
min-height:500px;
height:auto !important;
height:500px;
}