Skip to content

Instantly share code, notes, and snippets.

View justsml's full-sized avatar
🔥
Stealing fire

Dan Levy justsml

🔥
Stealing fire
View GitHub Profile
@justsml
justsml / cache.js
Created March 11, 2018 09:07
Debounce Promise Results using Naïve Timeout-based Expiration/Caching
module.exports = { createCachedPromise, cacheifyAll };
// TODO: Add Map/WeakMap cache isolation for arguments passed into cacheifyAll's methods
/**
* Extends all functions on an Object or Class with 'Cached' suffixed methods.
* Methods must return promises when called! Won't break existing functions/usage.
*
* -----
*
@justsml
justsml / setup_osx.sh
Last active October 20, 2020 03:00 — forked from rands0n/setup_osx.sh
setup_osx
#!/bin/sh
echo "Starting XCode Command Line Tools Setup... Continue using the GUI prompt..."
sleep 4s
xcode-select --install
echo "DONE: Installing XCode Command Line Tools\!"
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@chadwithuhc
chadwithuhc / declaring-values-in-function.js
Last active February 7, 2018 00:05
React Refactors for Clean Code
// Challenge: Refactor the `render()` method with declare all variables at top
render() {
return (
<li>
<div className="profile-card">
<header className="profile-header" onClick={this.toggleClass}>
<img src={this.props.profile.image} alt={this.props.profile.name} />
<h2>{this.props.profile.name}</h2>
</header>
@justsml
justsml / fetch-api-examples.md
Last active April 22, 2025 13:44
JavaScript Fetch API Examples
@justsml
justsml / mongodb-seeds-example-pattern.md
Last active January 15, 2020 22:17
Uses mongoose

Example Seeds Pattern for Mongodb/Mongoose

Example Schemas:

models.js
const mongoose = require('mongoose');

// Category Schema
@littledan
littledan / header.jsidl
Created December 4, 2017 18:12
Should JavaScript use a header file format (a la WebIDL) to define its standard library?
@namespace
class Math {
static abs(x: Number): Number; // Types optional; provide cast on input and assertion on ouptut
@nonwritable
static LOG10E: Number;
// ...
}
@getify
getify / 1.js
Last active June 2, 2021 15:41
Proposal: curried function declarations in javascript -- aka, making FP development in JS much much nicer
// Standard:
function fn(x) {
return function(y){
return function(z){
return x * y / z;
};
};
}
@tomdale
tomdale / bytecode.ts
Created October 20, 2017 16:45
Glimmer.js Application proposal
// This is the API for constructing a Glimmer.js application with
// precompiled binary bytecode templates and using an async renderer
// (via requestAnimationFrame, requestIdleCallback, etc).
import Application, { DOMBuilder, AsyncRenderer, BytecodeLoader } from '@glimmer/application';
import data from './__compiled__/data';
let bytecode = fetch('./__compiled__/templates.gbx')
.then(req => req.arrayBuffer());
@justsml
justsml / app.js
Last active February 4, 2018 17:17
DAN'S REFERENCE EXPRESS APP TEMPLATE:
// TODO: INSTALL PRE-REQS: `npm install express cors body-parser morgan monk`
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const app = module.exports = express()
const server = http.createServer(app)
const port = parseInt(process.env.PORT || 3000)
dialog {
position: fixed;
top: 50%;
left: 50%;
right: auto;
padding: 30px;
transform: perspective(500px) translate(-50%, -50%);
background: linear-gradient(to bottom, #FFF, #F4F4F4) #FFF;
border: none;
border-radius: 3px;