Skip to content

Instantly share code, notes, and snippets.

View BenBrostoff's full-sized avatar
💭
@klaviyo / DFS + stocks, options trading

Ben Brostoff BenBrostoff

💭
@klaviyo / DFS + stocks, options trading
View GitHub Profile
// UPDATE: don't use this. when it re-partitions the list when time moves forward, it does not correctly keep hashes
// Use a real merkle tree instead: https://gist.github.com/jlongster/f431b6d75ef29c1a2ed000715aef9c8c
import Timestamp from './timestamp';
// This is a compact data structure that keeps track of a list of
// hashes (representing messages) over a range of time in order to
// figure out what has changed between clients, kinda like a Merkle
// tree. It creates "buckets" that represent different time ranges,
// and divides time into smaller buckets the more recent they are. The
@BenBrostoff
BenBrostoff / easier-log.js
Created June 27, 2018 15:56
Log without removing immediate return
// thanks to @jnelson for showing me this technique
const original = () => process.env.someThing;
// you might be tempted to do this
const original2 = () => {
console.log(process.env.someThing);
return process.env.someThing;
};
@kendricktan
kendricktan / capsule_networks.py
Last active August 17, 2021 17:12
Clean Code for Capsule Networks
"""
Dynamic Routing Between Capsules
https://arxiv.org/abs/1710.09829
"""
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision.transforms as transforms
@posener
posener / go-shebang-story.md
Last active June 28, 2024 21:18
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@mattheworiordan
mattheworiordan / restart.sh
Created August 19, 2017 13:23
Heroku scheduled restarts
#!/bin/sh
# Set up the Heroku scheduler to run this command every hour. See example setup at https://goo.gl/nMCSH3
#
# Requires env vars to be set in Heroku with `heroku config:set`:
# - HEROKU_APP_NAME: this is just the app name in Heroku, i.e. `heroku apps` will list all apps you have access to
# - HEROKU_CLI_USER: Once Heroku CLI is authenticated (https://goo.gl/Qypr4x), check `cat .netrc` (or `_netrc` on Windows),
# look for `login` under `machine api.heroku.com`
# - HEROKU_CLI_TOKEN: As above, but use the `password` field
#
@jmeekhof
jmeekhof / Dockerfile
Last active January 17, 2019 00:08
quick and dirty docker for python-lambda
FROM amazonlinux
RUN yum update -y && \
yum install -y shadow-utils \
which \
gcc \
zlib \
zlib-devel \
openssl \
openssl-devel \
@klaaspieter
klaaspieter / ASS.md
Created June 22, 2017 07:59 — forked from anonymous/ASS.md
Acronyms Seriously Suck - Elon Musk

From time to time, Musk will send out an e-mail to the entire company to enforce a new policy or let them know about something that's bothering him. One of the more famous e-mails arrived in May 2010 with the subject line: Acronyms Seriously Suck:

There is a creeping tendency to use made up acronyms at SpaceX. Excessive use of made up acronyms is a significant impediment to communication and keeping communication good as we grow is incredibly important. Individually, a few acronyms here and there may not seem so bad, but if a thousand people are making these up, over time the result will be a huge glossary that we have to issue to new employees. No one can actually remember all these acronyms and people don't want to seem dumb in a meeting, so they just sit there in ignorance. This is particularly tough on new employees.

That needs to stop immediately or I will take drastic action - I have given enough warning over the years. Unless an acronym is approved by me, it should not enter the SpaceX glossary.

@javiersuazo
javiersuazo / merge.m
Created March 9, 2017 01:40
Merge videos on ios with audio and right orientation.
#import "MKOVideoMerge.h"
#import <AVFoundation/AVFoundation.h>
@implementation MKOVideoMerge
+ (void)mergeVideoFiles:(NSArray *)fileURLs
completion:(void(^)(NSURL *mergedVideoFile, NSError *error))completion {
NSLog(@"Start merging video files ...");

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@alexcasalboni
alexcasalboni / deploy.sh
Last active January 29, 2024 12:22
Simple AWS Lambda deployment script - Zip & upload Deployment Package with initial dependencies to S3
#!/bin/bash
BUCKET="YOUR_BUCKET_NAME" # bucket name
FILENAME="deployment-package.zip" # upload key
TMP_FOLDER="/tmp/lambda-env-tmp/" # will be cleaned
OUTPUT_FOLDER="/tmp/lambda-env/" # will be cleaned
HERE=${BASH_SOURCE%/*} # relative path to this file's folder
LAMBDA_FOLDER="$HERE/lambda/" # relative path