Skip to content

Instantly share code, notes, and snippets.

View adamkdean's full-sized avatar

Adam K Dean adamkdean

View GitHub Profile
@gaearon
gaearon / slim-redux.js
Last active April 25, 2024 18:19
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@MathewReiss
MathewReiss / phone.js
Created June 4, 2015 17:09
Pokedex phone.js File
var DEBUG = true;
//var name = "name", type = "type", stage = "stage", caught = "caught";
var grass = "grass", water = "water", fire = "fire", bug = "bug",
psychic = "psychic", flying = "flying", ghost = "ghost", fighting = "fighting",
normal = "normal", poison = "poison", electric = "electric", ground = "ground",
fairy = "fairy", rock = "rock", ice = "ice", dragon = "dragon";
var Pokemon = [
{ name : "MissingNo", type : "blank", stage : 100, caught : 0, species : "Glitch Pokemon"},
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@mikeal
mikeal / gist:9242748
Last active June 23, 2020 05:17
Response to Nodejitsu NPM Trademark

I've known people at nodejitsu for years, since before the company even existed. I still consider many of them friends. That said, somebody over there has lost their mind.

Trademarks are an important part of open source. They protect the integrity of the trust that is built by any project. A classic example of why this is the case is Firefox. Suppose that a malware producer takes the Firefox codebase, which is free and open source, packages up their malware with it and then releases it as "Firefox". Then they buy search advertising and suddenly their bad and malicious version of Firefox is the first result on search engines across the web. This is clearly a bad thing for Firefox and open source everywhere, but what can Mozilla do to protect their community of users?

They can't enforce a software license since the use is permitted under the Mozilla Public License. They can, however, enforce on these hypothetical bad actors using their trademark on the word "Fi

@grantslatton
grantslatton / fizzbuzz.c
Last active August 19, 2022 11:20
FizzBuzz solved using only bit twiddling. It essentially uses two deterministic finite automata for divisibility testing.
#include <stdio.h>
int f0(unsigned int x) { return x? (x&(1<<31)? f1(x<<1) : f0(x<<1)) : 1; }
int f1(unsigned int x) { return x? (x&(1<<31)? f3(x<<1) : f2(x<<1)) : 0; }
int f2(unsigned int x) { return x? (x&(1<<31)? f0(x<<1) : f4(x<<1)) : 0; }
int f3(unsigned int x) { return x? (x&(1<<31)? f2(x<<1) : f1(x<<1)) : 0; }
int f4(unsigned int x) { return x? (x&(1<<31)? f4(x<<1) : f3(x<<1)) : 0; }
int t0(unsigned int x) { return x? (x&(1<<31)? t1(x<<1) : t0(x<<1)) : 1; }
int t1(unsigned int x) { return x? (x&(1<<31)? t0(x<<1) : t2(x<<1)) : 0; }
int t2(unsigned int x) { return x? (x&(1<<31)? t2(x<<1) : t1(x<<1)) : 0; }
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
$(function() {
// Tweaked from: https://gist.github.com/mattstauffer/3835881
// No guarantees
// 1. include Isotope.js
// 2. include this file
// 3. customize Isotope options at the bottom of this file
// 4. add "margin: 0 auto" to the isotope container
$.Isotope.prototype._getMasonryGutterColumns = function() {
@beausmith
beausmith / isotope-centered-masonry-and-masonry-gutters.js
Last active November 6, 2019 04:24 — forked from mattstauffer/gist:3835881
Isotope with Centered Masonry and Masonry Gutters.
$(function() {
// Tweaked from: https://gist.github.com/mattstauffer/3835881
// No guarantees
// 1. include Isotope.js
// 2. include this file
// 3. customize Isotope options at the bottom of this file
// 4. add "margin: 0 auto" to the isotope container
$.Isotope.prototype._getMasonryGutterColumns = function() {
@nazgob
nazgob / gist:2367583
Created April 12, 2012 14:13
vagrant cheatsheet
# setup vagrant
gem install vagrant
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
mkdir my_vagrant_test
cd my_vagrant_test
vagrant init lucid32
vim Vagrantfile
vagrant up
vagrant ssh
@wjrogers
wjrogers / dfhack_workflow.txt
Created March 4, 2012 20:18
dfhack configuration
# enable the plugin
workflow enable drybuckets auto-melt
# farming
workflow amount FOOD 120 30
workflow amount DRINK 300 50
workflow amount THREAD//GRASS_TAIL_PIG:THREAD 30 20
workflow count LIQUID_MISC//POD_SWEET:EXTRACT 20 10
# storage