Skip to content

Instantly share code, notes, and snippets.

View wellcaffeinated's full-sized avatar

Jasper wellcaffeinated

View GitHub Profile
@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"
}
@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 / 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 / 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 / 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 / fully canceled
Created February 26, 2018 15:23
Intellitix sent data examples
{
"source": "51",
"orderid": "5a7b92a6a28ee8467bc2dd2b",
"status": "canceled",
"miscfields": {
"25": "Piper",
"26": "Wendy",
"51": "[email protected]"
},
"tickets": [
@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 / 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 / math-utils.js
Created November 19, 2013 04:40
Very crude approximation to gaussian random number. It's fast, but it's NOT accurate.
// VERY crude approximation to a gaussian random number.. but fast
var gauss = function gauss( mean, stddev ){
var r = 2 * (Math.random() + Math.random() + Math.random()) - 3;
return r * stddev + mean;
};
@wellcaffeinated
wellcaffeinated / complex-expression.js
Created November 15, 2013 15:55
Complex expression parser (uses scratchpad.js)
!function(){
var orderOfOps = ['+', '-', '*', '/'];
var rules = {
'+' : 'add',
'-' : 'subtract',
'*' : 'multiply',
'/' : 'divide'
};