Skip to content

Instantly share code, notes, and snippets.

View maplethorpej's full-sized avatar

Jerad Maplethorpe maplethorpej

View GitHub Profile
@robmathers
robmathers / groupBy.js
Created October 25, 2018 23:18
A more readable and annotated version of the Javascript groupBy from Ceasar Bautista (https://stackoverflow.com/a/34890276/1376063)
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by
// reduce runs this anonymous function on each element of `data` (the `item` parameter,
// returning the `storage` parameter at the end
return data.reduce(function(storage, item) {
// get the first instance of the key by which we're grouping
var group = item[key];
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it
storage[group] = storage[group] || [];
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@tomraithel
tomraithel / gist:3852171
Created October 8, 2012 12:05
SASS: mixin for absolute center position
@mixin center($width, $height) {
position: absolute;
left: 50%;
top: 50%;
height: $height;
width: $width;
margin-left: - $width / 2;
margin-top: - $height / 2;
}