Skip to content

Instantly share code, notes, and snippets.

View robertpenner's full-sized avatar

Robert Penner robertpenner

View GitHub Profile
@satomacoto
satomacoto / labeledarrow.html
Created August 18, 2012 06:56
labeled arrow w/ D3.js
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://d3js.org/d3.v2.js"></script>
<style>
line.arrow {
stroke: #666;
@binarymax
binarymax / canvasfloodfill.js
Created November 14, 2012 12:36
Javascript Canvas FloodFill functions
//MIT License
//Author: Max Irwin, 2011
//Floodfill functions
function floodfill(x,y,fillcolor,ctx,width,height,tolerance) {
var img = ctx.getImageData(0,0,width,height);
var data = img.data;
var length = data.length;
var Q = [];
var i = (x+y*width)*4;
@hisui
hisui / stream.ts
Last active August 21, 2020 21:20
Functional Reactive Programming (FRP) in TypeScript.
// stream.ts - A TypeScript module for FRP.
// - https://gist.github.com/hisui/6261547
// - tsc stream.ts -t es5 --sourcemap --noImplicitAny
module sf {
export class Packet<T> {
constructor(private _flags:number, private _value:any=void 0) {}
static next<A>(e:A):Packet<A> {
@mwhite
mwhite / git-aliases.md
Last active April 30, 2024 11:32
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@gordonbrander
gordonbrander / min-event-behavior.js
Last active August 21, 2018 11:57
Minimal FRP events and behaviors
// Minimal FRP Behaviors and Events.
// An event function is any function of shape `function (next) { ... }` where
// `next(value)` is a callback to be called by event function. Transformations
// of event are accomplished by wrapping event with another event function,
// and consuming original event within (CPS).
// A behavior is any function of shape `function (time) { ... }`, where
// `time` is current time. Behaviors may capture state, return value from time,
// or be constant. Behaviors must always return a value, but value may
@mattpodwysocki
mattpodwysocki / Promises-Observables.js
Last active November 3, 2018 09:33
New support for Promises in RxJS to include conversion to and from Promises, and operator support such as: flatMap/selectMany, mergeObservable/mergeAll, concatObservable/concatAll, switchLatest/switch, and startAsync
// Observable to Promise
var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
promise.then(console.log.bind(console));
// => 42
// Using config instead of argument
Rx.config.Promise = RSVP.Promise;
var promise = Rx.Observable.return(42).toPromise();
promise.then(console.log.bind(console));
// => 42
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@pgilad
pgilad / Instructions.md
Last active March 31, 2024 22:30
Git commit-msg hook to validate for jira issue or the word merge

Instructions

  • copy the file commit-msg to .git/hooks/commit-msg
  • make sure your delete the sample file .git/hooks/commit-msg.sample
  • Make commit msg executable. chmod +x .git/hooks/commit-msg
  • Edit commit-msg to better fit your development branch, commit regex and error message
  • Profit $$

Shell example

@bendc
bendc / functional-utils.js
Last active September 15, 2023 12:12
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@rolaveric
rolaveric / mixinSchema.json
Created March 28, 2015 02:29
Example of using "allOf" to make JSON Schema mixins
{
"definitions": {
"nameMixin": {
"type": "object",
"properties": {
"nameFirst": {"type": "string"},
"nameLast": {"type": "string"}
},
"required": ["nameFirst", "nameLast"]
},