Skip to content

Instantly share code, notes, and snippets.

Sam Goldman samwgoldman

Block or report user

Report or block samwgoldman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
samwgoldman / example.js
Last active Mar 14, 2019
Pure, stateless, type-checked React components with Immutable.js and Flow
View example.js
/* @flow */
var React = require("react")
var Immutable = require("immutable")
// In order to use any type as props, including Immutable objects, we
// wrap our prop type as the sole "data" key passed as props.
type Component<P> = ReactClass<{},{ data: P },{}>
type Element = ReactElement<any, any, any>
View a.diff
index 3ef907960..5de2e0e85 100644
--- a/runtime/compare.c
+++ b/runtime/compare.c
@@ -133,7 +133,8 @@ static intnat do_compare_val(struct compare_stack* stk,
return Long_val(v1) - Long_val(v2);
/* Subtraction above cannot overflow and cannot result in UNORDERED */
- if (Is_in_value_area(v2)) {
+ if (!Is_in_value_area(v2))
+ return LESS;
samwgoldman / Maybe.h
Created Mar 12, 2014
Maybe monad-alike in Objective-C using parts of ReactiveCocoa and libextobjc concrete protocols
View Maybe.h
#import <Foundation/Foundation.h>
#import <libextobjc/EXTConcreteProtocol.h>
@protocol Maybe <NSObject>
- (id<Maybe>)map:(id (^)(id value))block;
- (id<Maybe>)flattenMap:(id<Maybe> (^)(id value))block;
- (id<Maybe>)orElse:(id)defaultValue;
- (id)getOrElse:(id)defaultValue;
View gist:1fcceea36206e1544414
/* @flow */
type Maybe<T,U> = (pattern: {
some(x: T): U;
none(): U;
}) => U;
function map<A,B,C>(maybe: Maybe<A,C>, f: (a: A) => B): Maybe<B,C> {
return function(pattern) {
return maybe({
View jsbin.ucanam.html
<!DOCTYPE html>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script type="text/x-handlebars" data-template-name="application">
{{view Ember.Select content=options value=computed}}
View gist:6557156
class Foo
def bar
set_trace_func proc { |event, file, line, id, binding, classname|
if event == "call"
View gist:6458771
require "active_support/all"
now = Date.current
# => Thu, 05 Sep 2013
now - 2.months - 5.days + 2.months + 5.days == now
# => false
now - 2.months - 5.days + 5.days + 2.months == now
# => true
View gist:5789657
require "active_record" # 4.0.0.rc2
require "minitest/autorun"
class Migrate < ActiveRecord::Migration
self.verbose = false
def up
create_table(:memberships) do |t|
View ar_relation_scope.rb
require "active_record"
require "rspec/autorun"
class Migrate < ActiveRecord::Migration
self.verbose = false
def up
create_table(:tasks) do |t|
t.references :project, null: false
samwgoldman / jsverify.js
Created Nov 14, 2015
First pass at Flow interface file for jsverify
View jsverify.js
declare module "jsverify" {
// Either
declare interface Either<A,B> {
either<T>(l: (a: A) => T, r: (b: B) => T): T;
isEqual(other: Either<A,B>): boolean;
bimap<C,D>(f: (a: A) => C, g: (b: B) => D): Either<C,D>;
first<C>(f: (a: A) => C): Either<C,B>;
second<D>(g: (b: B) => D): Either<A,D>;
You can’t perform that action at this time.