Skip to content

Instantly share code, notes, and snippets.

View justjake's full-sized avatar
🎉
🎉

Jake Teton-Landis justjake

🎉
🎉
View GitHub Profile
@justjake
justjake / server-preload.js
Last active January 29, 2024 16:56
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See https://jake.tl/notes/2021-04-04-nextjs-preload-hack
// @ts-check
"use strict"
/**
* Set up datadog tracing. This should be called first, so Datadog can hook
* all the other dependencies like `http`.
*/
function setUpDatadogTracing() {
const { tracer: Tracer } = require('dd-trace')
const tracer = Tracer.init({
@justjake
justjake / README.md
Created December 9, 2015 23:27
find bad packages in sinopia

Wat

I noticed a bunch of packages triggering [this npm@3 issue] because our Sinopia instance cached a number of packages. I wrote this script to find the bad packages on our server.

Usage

  1. npm install
  2. change the dataDir variable on line 3 of index.js to point to your Sinopia data directory
  3. run node ./index.js | grep BAD to list the bad packages
  4. rm -r those packages
@justjake
justjake / style-props.tsx
Last active October 29, 2019 00:11
Exploring building a CSS-in-JS system in Typescript
import { CSSProperties, Component } from "react"
/**
* Base types.
*/
/**
* A SheetProducer makes a sheet based on a context.
* Right now, the context only contains a `theme`.
*/
@justjake
justjake / highlighted.md
Last active December 30, 2015 07:59
Power of anonymous functions

The relevent bits

Plotting from euclidean space to screen coordinates in Coffeescript, for my Spectrograph class

plot: (width, height, max_Y) ->
 # re-generate coeficceint functions
 if ! (@_width == width && @_height == height && @_max_Y == max_Y)
   w_coef = width / SIZE
   h_coef = height / max_Y # consider changing this to absolute w/height? nah
   # @X and @Y transform normal euclidean X, Y points into screen X Y points
@justjake
justjake / line_drawing.coffee
Last active December 30, 2015 05:38
Line drawing demo. Use with Coffeescript mode in Processing 2
setup: ->
# Processing.js setup
size(1600, 900)
noLoop()
class Point
constructor: (@x, @y) ->
sub: (other) ->
new Point(@x - other.x, @y - other.y)
magnitude: ->
@justjake
justjake / format.js
Last active December 16, 2015 22:29
update = {
/* Two basic sections. */
"Nodes": {
/* Nodes is a int->node map.
* nodes that already exist are updaasdted
* by the fields supplied in the Nodes section
* delete a node by passing `null` or a string as the value
*
* id, name, class fields required for new node creationjsdfA
* */
#!/usr/bin/env zsh
APP="/Applications/CrashPlan.app"
CONFIG="/Contents/Resources/Java/conf/ui.properties"
unlink-prop() {
rm "$APP/$CONFIG"
}
link-prop() {
@justjake
justjake / fib.py
Created November 28, 2012 00:19
Fibonocci CLI tool
#!/usr/bin/env python
"""Fibonacci calculator with better precision than Javascript"""
def main():
import argparse
parser = argparse.ArgumentParser(description='Show the Fibonacci series number')
# method to use
parser.add_argument('-r', '--recursive', action='store_true',
help="Use a recursive method")
@justjake
justjake / fizzbuzz.clj
Created November 25, 2012 01:46
Extensable and functional fizz-buzz in Clojure
(comment
Here is FizzBuzz written by a
first-day clojure bro)
(defn divisible-by [by-num]
(fn [num]
(= 0 (rem num by-num))))
(def tests-and-outputs
@justjake
justjake / zenburn.css
Created July 6, 2012 08:19
Bare Minimum CSS
/* search your feelings, you know it to be true */
body {
color: #dcdccc;
background: #292929;
font-family: sans-serif;
margin: 1em 5.55%;
}
/* optional: nice text spacing */
body { line-height: 1.5; }