Skip to content

Instantly share code, notes, and snippets.

View snapwich's full-sized avatar

Rich Snapp snapwich

View GitHub Profile
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() {},
// 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"
});
@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 ./
"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);
// 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;
<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>
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;
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;
// we'll call this "reduce ...spread"
let result = items.reduce((acc, item) => ({
...acc, [item.name]: item.value
}), {})