Skip to content

Instantly share code, notes, and snippets.

@cowboyd
cowboyd / 1-click-to-load.js
Last active April 11, 2023 10:54
Handle a stream of clicks by canceling the latest one
/**
* Implements an operation to fetch the data as described in https://twitter.com/BenLesh/status/1455597411385098242
* The "winner" is unambiguous. It is the request corresponding to the latest click, guaranteed.
* Other important things to note:
*
* 1. The HTTP request is cancelled every time along with its containing task
* 2. click listener is removed automatically at the end of the `clickToLoad` operation
* 3. The cancellation logic is explicit here to demonstrate the concept, but it can easily be abstracted into a separate
*. function. See the `click-to-load-HOF` example below
*/
@cowboyd
cowboyd / async-function-typeclasses.js
Last active October 11, 2018 15:42
Funcadelic typeclass implementations for AsyncFunction
/**
* There's some pretty awesome low-level composition that you can do with async functions:
* Check out funcadelic! https://github.com/cowboyd/funcadelic.js
*/
import { Functor, Semigroup, Monoid } from 'funcadelic';
const AsyncFunction = (async function() {}).constructor;
/**
* It's a Functor!
@yelouafi
yelouafi / multishot-callcc.js
Created September 21, 2018 17:05
multi shot continuations
function isGenerator(x) {
return x != null && typeof x.next === "function"
}
function isFrame(x) {
return x != null && x._type_ === 'call_frame'
}
function call(genFunc, ...args) {
@machty
machty / gist:68afad4c03109f36d4f4cffaae3c170b
Last active February 7, 2017 17:45
embercommunity.slack.com #topic-forms discussion
joined #topic-forms, and invited @machty
locks [11:05 AM]
thar you go
machty [11:06 AM]
thank you!
[11:07]
@samselikoff @cowboyd
@parmentf
parmentf / GitCommitEmoji.md
Last active November 15, 2024 20:33
Git Commit message Emoji
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active November 5, 2024 18:44
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@thommahoney
thommahoney / gist:2491946
Created April 25, 2012 18:27
RailsConf 2012 Lightning Talks
5 min:
~ Objective-C + Rails: Communicating with Rails from iOS / Mac OS
Dan Hassin
1 min:
~ Painless Javascript
koting hatduklgg
with wind tunnel
5 min:
@cowboyd
cowboyd / gist:1045642
Created June 24, 2011 20:41
Restart racoon on OSX
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.racoon.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.racoon.plist
@cowboyd
cowboyd / JenknsCI JRuby Meeting Details.mdown
Created March 28, 2011 14:28
Meeting Details for Jenkins + JRuby

JenkinsCI Ruby Plugins

Date: Every Thursday, from Thursday, January 5, 2012 to no end date Time: 10:00 am, Central Standard Time (Chicago, GMT-06:00) Meeting Number: 336 439 792 Meeting Password: (This meeting does not require a password.)

#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else