Skip to content

Instantly share code, notes, and snippets.

View JuanitoFatas's full-sized avatar
🥑
Buildkite Engineering

Juanito Fatas JuanitoFatas

🥑
Buildkite Engineering
View GitHub Profile
@pda
pda / poorman
Last active September 4, 2024 05:39
poorman: a Procfile runner for tmux, in terrible bash
#!/bin/bash
set -e -o pipefail -u
# Launches each Procfile service as a tmux pane in a background window.
# The window is created if it doesn't already exist.
# Panes are created on demand, and existing panes are restarted if stopped.
WINDOW_NAME="poorman"
if [[ ${1:-} == "stop" ]]; then
@drbrain
drbrain / Many runs
Last active May 17, 2019 01:03
benchmark/ips can mislead you
Warming up --------------------------------------
range 60.821k i/100ms
args 63.056k i/100ms
Calculating -------------------------------------
range 774.236k (± 7.5%) i/s - 3.893M in 5.057747s
args 797.590k (± 6.0%) i/s - 3.973M in 5.000220s
Warming up --------------------------------------
range 64.468k i/100ms
args 65.528k i/100ms
Calculating -------------------------------------
@simpsoka
simpsoka / Leadership-CI.md
Last active December 20, 2023 15:40
This is a list of questions to check our decision making.

Do I want to die on this hill?

  • Pass: This is morally good and if not handled has long term consequences
  • Fail: This if self serving

Am I including everyone?

  • Pass: My ego is not driving this conversation
  • Fail: The people in this conversation will only tell me I'm right and not push back

WaniKani sent me this interview since I'd reached the program's max level. I figured I'd save my answers here for posterity.

Q: Why did you study Japanese?

I took German language in high school, but both its similarities to English and the near English fluency in every German person I've ever met conspired to discourage me from really taking it seriously.

I did, however, learn that the act of studying another language was a deeply perspective-altering activity. When you see how a language and a culture are inextricably linked, it triggers in me an introspection of my own ideology—what do I take for granted that's encoded into the English words I say or how I use them?

Ultimately, this led me to want to learn the most challenging language I could find, with a secondary priority for cultures that my own experience would relate to the least. Of Japanese, Chinese, and Russian, the emphasis on subtlety and harmony in Japanese culture put it over the top. Once I started studying,

@searls
searls / basketball.md
Created October 12, 2018 14:48 — forked from stevenjackson/basketball.txt
How I Learned to be a Better Technologist (by Coaching Youth Basketball)
- Giving it to the best player doesn't make the team better
- Positive reinforcement
- You can't play for them
- You're going to be ignored / Shared understanding takes forever
- The game is not the most important thing

I coached a rec team that had a huge range of talent. One young man was very talented and could have gone on to play junior college basketball. I had a couple that were a level below him and then varying levels all the way down to the kid who was surprised when the basketball was in his hands. I did focus on leveling up everyone in practice, but our in-game style quickly devolved to give it to the best kid and move around him. This was moderately successful, everyone got to contribute, and the games were competitive. Then that kid got sick. Then baseball season started and he wanted to focus on that. All of a sudden my team had no identity and no idea how to win. We couldn't just lean on the next best player, the talent gap was too wide. Before the team could r

require "active_support"
require "active_support/core_ext/string/output_safety"
require "objspace"
def assert_same_object(x, y)
raise unless x.object_id == y.object_id
end
def assert_not_same_object(x, y)
raise unless x.object_id != y.object_id
require 'benchmark/ips'
require 'redis'
class MethodProfiler
def self.patch(klass, methods, name)
patches = methods.map do |method_name|
<<~RUBY
unless defined?(#{method_name}__mp_unpatched)
alias_method :#{method_name}__mp_unpatched, :#{method_name}
def #{method_name}(*args, &blk)
unless prof = Thread.current[:_method_profiler]
@javan
javan / direct-uploads.md
Last active January 29, 2023 10:58
Active Storage direct uploads

direct-uploads

rails/activestorage#81

// direct_uploads.js

addEventListener("direct-upload:initialize", event => {
  const { target, detail } = event
  const { id, file } = detail

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

Links:
A Visual Introduction to Machine Learning
http://www.r2d3.us/visual-intro-to-machine-learning-part-1/
UC Berkeley CS188 Intro to AI -- Course Materials
http://ai.berkeley.edu/home.html
Eyeo 2016 – Gene Kogan
https://vimeo.com/180044029