Skip to content

Instantly share code, notes, and snippets.

View 1Marc's full-sized avatar

Marc Grabanski 1Marc

View GitHub Profile
@1Marc
1Marc / ramdaprogram.js
Last active January 16, 2018 09:08
ramda program
var byMonth = R.groupBy(R.prop('Month'));
var byAuthor = R.groupBy(R.prop('Author'));
var royalty_key = 'Royalty (SUM)';
var months_keys = R.uniq(R.map(R.prop('Month'), data)).sort();
var monthly_revenue =
R.map((group) =>
R.reduce((acc, record) => acc + parseMoney(record[royalty_key]), 0, group),
byMonth(data));
Input:
{ 'Jon': { '7/2016': 11026, '8/2016': 10793, '9/2016': 5526 },
'Max': { '7/2016': 62911, '8/2016': 59902, '9/2016': 46801 },
'Phil': { '7/2016': 40233, '8/2016': 45060, '9/2016': 44902 },
'Tim': { '7/2016': 61083, '8/2016': 68584, '9/2016': 70511 }}
Output:
[ { 'Author': 'Jon, '7/2016': 11026, '8/2016': 10793, '9/2016': 5526 },
@1Marc
1Marc / webpack-setup.md
Created November 10, 2016 04:10
Webpack Setup

To set up the project you’ll need:

  • Node version 6 (you can install it with nvm)
  • npm version 3 (comes with Node 6)
  • git

Then run these commands:

git clone https://github.com/kentcdodds/es6-todomvc.git
@1Marc
1Marc / gist:b192b96639f82366a8600275fec91f7b
Created August 29, 2016 19:45
Tampermonkey remove ads
// ==UserScript==
// @name Remove Promoted Tweets and Activity Tab
// @namespace http://twitter.com
// @version 0.1
// @description Remove Twitter Garbage
// @author You
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
@1Marc
1Marc / keybase.md
Created April 18, 2016 21:23
Keybase

Keybase proof

I hereby claim:

  • I am 1marc on github.
  • I am 1marc (https://keybase.io/1marc) on keybase.
  • I have a public key ASCahPT39_ahT-X-9z74V38wRMy2PUCL_HHhuSMghV2PFAo

To claim this, I am signing this object:

@1Marc
1Marc / current-git-branch
Last active March 24, 2016 18:08
Reset to current branch
// replace # with the number of the step you are on
git fetch origin
git reset --hard
git branch --track fem-# origin/fem-#
git checkout fem-#
git clean -f
@1Marc
1Marc / emoji
Created December 3, 2015 15:17
Chatroom Emjoi
:+1: -> 👍
@1Marc
1Marc / express-2-to-4-x.txt
Created November 25, 2015 18:55
Express 2 to Express 4.x
Express 2 was used in the course and the current version is 4.x.
you can't just use 'urlencoded' anymore, you have to:
npm install body-parser
and
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
@1Marc
1Marc / distribute-prepaid-codes.js
Created September 25, 2015 17:20
Distribute prepaid codes via mailgun
var fs = require('fs');
// npm install csv-parse
var parse = require('csv-parse');
// CSV with ONLY the codes you want to give away
var prepaid_codes_file = 'giveaway-codes.csv';
var emails_file = 'giveaway-emails.csv';
var Mailgun = require('mailgun').Mailgun;
@1Marc
1Marc / randomdomnodes.js
Created August 12, 2015 13:04
random DOM nodes
var comments = document.querySelectorAll('#comment-list > li');
var commentsList = [];
var array = new Uint32Array(comments.length);
var randomIds = window.crypto.getRandomValues(array);
Array.prototype.forEach.call(comments, function(el, i){
if (el.id) commentsList.push({id: el.id, rand: randomIds[i]});
});