Skip to content

Instantly share code, notes, and snippets.

Rich Snapp snapwich

View GitHub Profile
View reduce-spread-bad.js
// we'll call this "reduce ...spread"
let result = items.reduce((acc, item) => ({
...acc, [item.name]: item.value
}), {})
View reduce-spread-good.js
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;
View reduce-benchmarks.js
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;
View google-search.vue
<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>
View search-style.less
// 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;
View scan.js
"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 Oct 14, 2015 — forked from mzabriskie/checklist.md
Release Process
View checklist.md
  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 ./
View angular a11y
// 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"
});
View gist:cae05a08a9635a99a00f
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() {},
You can’t perform that action at this time.