Skip to content

Instantly share code, notes, and snippets.

Brasten Sager brasten

Block or report user

Report or block brasten

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
@brasten
brasten / README.md
Last active Jan 28, 2019
Default method for invoking objects in JavaScript
View README.md

Proposal: "Callable" objects via Symbol.apply function

Objects w/ default method can be invoked like a function.

Problem

Objects that are well constrained (single responsibility) can tend to end up with a single method, or at least a single method that is important to most consumers. These methods tend to be named by either verbing the class name (eg. UserCreator.create()) or with

@brasten
brasten / index.ts
Last active Jan 14, 2019
TypeScript - Less-permissive implementation of interface
View index.ts
// TypeScript v 3.2.2
//
// I feel like something along the way here should fail type-checking.
//
// The interface for Repository#saveFeed takes an attribute
// with an optional `feed` property. The implementation requires the
// `feed` property, and thus - I suppose - satisfies the requirement?
type FeedInfo = {
feed: {
@brasten
brasten / gist:732816
Created Dec 8, 2010
Using Ant from Rakefile in JRuby
View gist:732816
task :war do
ant.war :destfile => 'pkg/project.war' do |war|
war.fileset :dir => 'public'
war.webinf :dir => '.' do |wi|
wi.include :name => 'config/**/*'
wi.include :name => 'lib/**/*'
wi.include :name => 'app/**/*'
wi.include :name => 'vendor/**/*'
wi.include :name => 'config.ru'
wi.include :name => 'Rakefile'
You can’t perform that action at this time.