Skip to content

Instantly share code, notes, and snippets.

// we'll call this "reduce ...spread"
let result = items.reduce((acc, item) => ({
...acc, [item.name]: item.value
}), {})
let items = [
{name: "something", value: true},
// ...
];
// use reduce to build the new map into an accumulator
// we'll refer to this as "reduce mutate"
let result = items.reduce((acc, item) => {
acc[item.name] = item.value;
return acc;
let _ = global._ = require("lodash");
let Benchmark = global.Benchmark = require("benchmark");
let Promise = require("bluebird");
let { Map } = require("immutable");
let { produce } = require("immer");
function getItems(count) {
let id = 1;
<template>
<div class="google-search">
<button @click="search(text)">
<i class="fa fa-search"></i>
</button>
<input ref="input"
title="Site Search"
v-on:keyup.13="search(text)"
v-model="text" />
</div>
// Just a little bit of styling...
.search-box {
margin-right: 0;
color: @gray-dark;
position: relative;
display: inline-block;
width: 200px;
border-bottom: 2px solid @gray-lighter;
min-height: 30px;
line-height: normal;
"use strict";
let request = require("request"),
cheerio = require("cheerio"),
querystring = require("querystring"),
sendgrid = require("sendgrid");
let config = require("./config.json");
let mail = sendgrid(config.sendgrid.api_user, config.sendgrid.api_key);
@snapwich
snapwich / checklist.md
Created October 14, 2015 00:51 — forked from mzabriskie/checklist.md
Release Process
  1. npm test
  2. npm run build
  3. Update package.json & bower.json version
  4. Update Changelog.md
  5. git commit -am"Releasing x.x.x"
  6. git push
  7. git tag -a vx.x.x -m"version x.x.x"
  8. git push origin --tags
  9. npm publish ./
// keyboard and accessibility directive
.directive("ngClick", function() {
var KEY_ENTER = 13,
KEY_SPACE = 32;
return {
restrict: "A",
link: function(scope, elem, attrs) {
elem.css({
cursor: "pointer"
});
angular.module("xhr", [])
.factory("xhr", function($window, $q) {
return function(opts) {
var deferred = $q.defer(),
XHR_DONE = 4; // can't use XMLHttpRequest.DONE since some awful libraries overwrite window.XMLHttpRequest
// defaults
opts = angular.extend({
// url: www.google.com,
// success: function() {},