Skip to content

Instantly share code, notes, and snippets.

@petermenocal
petermenocal / gist:1a32a75688aefd763695668d8f324fd1
Created October 12, 2018 15:54
group by key and sum a value
var prjMgrValues = [
{"proj_mgr":"Jack ProjManager","submitted_dollars":12000},
{"proj_mgr":"Jack ProjManager","submitted_dollars":750000},
{"proj_mgr":"Joe ProjManager","submitted_dollars":45000}
];
var output =
_(prjMgrValues)
.groupBy('proj_mgr')
.map((objs, key) => ({
@petermenocal
petermenocal / gist:451b386c2fd86749b18796626da99c7b
Created October 12, 2018 15:54
group by key and sum a value
var prjMgrValues = [
{"proj_mgr":"Jack ProjManager","submitted_dollars":12000},
{"proj_mgr":"Jack ProjManager","submitted_dollars":750000},
{"proj_mgr":"Joe ProjManager","submitted_dollars":45000}
];
var output =
_(prjMgrValues)
.groupBy('proj_mgr')
.map((objs, key) => ({
@petermenocal
petermenocal / PlanetsList.js
Created October 11, 2018 15:24 — forked from spencerfeng/PlanetsList.js
For tutorial: How to get resources from paginated REST API
import * as Utils from '../utilities'
class PlanetsListTable extends Component {
componentDidMount() {
new Promise((resolve, reject) => {
Utils.getPlanets('https://swapi.co/api/planets', [], resolve, reject)
})
.then(response => {
this.props.loadPlanetsSuccess(response)
})
powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61
@petermenocal
petermenocal / min.html5boilerplate.html
Created April 12, 2018 15:19
barebones html boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>/title>
<link rel="stylesheet" href="css/style.css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
@petermenocal
petermenocal / .gitignore
Created February 21, 2018 17:08
gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
@petermenocal
petermenocal / generate-pushid.js
Created February 19, 2018 17:36 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@petermenocal
petermenocal / yml
Created November 9, 2017 17:06
cypress + circleci config
version: 2
jobs:
build:
working_directory: ~/app
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: cypress/base:8
environment:
TERM: xterm
steps:
@petermenocal
petermenocal / tmux-cheatsheet.markdown
Created October 26, 2017 18:48 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@petermenocal
petermenocal / gist:71d3536f58fa8cf587e8f70f9dd9cd08
Created September 30, 2017 15:19
set forever process with UID
forever start --uid "custom-name" server.js