Skip to content

Instantly share code, notes, and snippets.

View wellcaffeinated's full-sized avatar

Jasper wellcaffeinated

View GitHub Profile
@wellcaffeinated
wellcaffeinated / strategies-1.js
Created December 6, 2013 21:05
PhysicsJS collision monitoring strategies
// If you want to subscribe to collision pairs
// emit an event for each collision pair
world.subscribe('collisions:detected', function( data ){
var c;
for (var i = 0, l = data.collisions.length; i < l; i++){
c = data.collisions[ i ];
world.publish({
topic: 'collision-pair',
bodyA: c.bodyA,
bodyB: c.bodyB
@wellcaffeinated
wellcaffeinated / renderer-pixi.js
Created January 8, 2014 16:21
Very rough implementation of a pixi.js renderer for PhysicsJS. Only supports circles right now.
Physics.renderer('pixi', 'canvas', function( parent ){
return {
init: function( options ){
// create an new instance of a pixi stage
this.stage = new PIXI.Stage(0xffffff);
// create a renderer instance.
this.renderer = PIXI.autoDetectRenderer(options.width, options.height);
@wellcaffeinated
wellcaffeinated / fully canceled
Created February 26, 2018 15:23
Intellitix sent data examples
{
"source": "51",
"orderid": "5a7b92a6a28ee8467bc2dd2b",
"status": "canceled",
"miscfields": {
"25": "Piper",
"26": "Wendy",
"51": "wendy.piper@blah.com"
},
"tickets": [
@wellcaffeinated
wellcaffeinated / RXJS Observable from mongoose (mongodb) cursor.js
Created May 30, 2018 21:35
Rx.Observable that can sequentially pull data from a mongoose (mongodb) cursor with fine control over concurrency
const Rx = require( 'rxjs/Rx' );
// This took me way too long to figure out. Hope this helps someone.
// <3 Well Caffeinated
function fromCursor( cursor ){
return new Rx.Observable((obs) => {
// is the connection closed
var closed = false
// get the next document
@wellcaffeinated
wellcaffeinated / slick-csb.js
Created January 18, 2022 01:52
Utilities for working in codesandbox that help workflow, especially when animations and loops are involved
const elCache = new Map()
// This helps fix the annoying disappearing of dom elements on csb save.
// Use $() or $$() to retrieve your dom elements in loops
const createQuerySelectorUtil = (qs) => (query) => {
let el = elCache.get(query)
if (el && document.body.contains(el)) {
return el
}
el = qs(query)
elCache.set(query, el)
@wellcaffeinated
wellcaffeinated / index.html
Created March 29, 2022 19:24
Redirect to wellcaffeinated.net
<!DOCTYPE html>
<html>
<head>
<title>Redirect to wellcaffeinated.net</title>
<meta http-equiv = "refresh" content = "1; url = https://wellcaffeinated.net" />
</head>
<body>
<p>Please visit: <a href="https://wellcaffeinated.net">https://wellcaffeinated.net</a></p>
</body>
</html>
@wellcaffeinated
wellcaffeinated / 01-README.md
Last active April 16, 2022 16:32
Helpers for automatic retrying of sketchy processes. Linear delay or exponential backoff. by @wellcaffeinated
@wellcaffeinated
wellcaffeinated / instructions.md
Created September 26, 2023 17:41
Setting iTerm2 tab name to shortened current directory in zsh

ensure that Profile -> Terminal -> Terminal may report title is checked

Then add the following to .zshrc

# set iterm title
iterm_title() {
  echo -ne "\e]1;$1\a"
}