Skip to content

Instantly share code, notes, and snippets.

View abachman's full-sized avatar
🙌
good times

Adam Bachman abachman

🙌
good times
View GitHub Profile
@abachman
abachman / 01_force_transaction_error.rb
Last active December 15, 2023 22:12
Google Cloud Spanner Emulator transaction hangup
# frozen_string_literal: true
##
# Force a stale-open transaction on the Spanner Emulator by running this script
# and then killing it with Ctrl-C.
#
# Rerunning the script will result in a hung process followed by the "one
# transaction at a time" error.
##
require_relative "emulator_util"
@abachman
abachman / .gitignore
Last active November 25, 2023 03:22
Rails vs Dates
Gemfile.lock
test.db*
@abachman
abachman / README.md
Last active January 26, 2024 17:26
git rebase --onto

I HAVE:

main     -- A -- B
                  \
staging            C -- D
                         \
feature                   E  
@abachman
abachman / db-joins.md
Last active November 3, 2022 14:59
DB Joins in MySQL

Given a database with two tables.

select * from users;
+----+------+
| id | name |
+----+------+
@abachman
abachman / jest.d.ts
Last active July 21, 2022 16:22
attempt at an all-in-one jest performance expectation
declare global {
namespace jest {
interface Matchers<R> {
toBeFasterThan(target: number): Promise<CustomMatcherResult>;
}
}
}
@abachman
abachman / passphrase-generator
Created September 7, 2021 13:32
passphrase generator
#!/usr/bin/env ruby
# ws=open('/usr/share/dict/words').readlines.map(&:strip).select{|w|/^[a-z]{7}$/=~w};100.times{p ws.sample(6).join(' ')}
ws=open('/usr/share/dict/words').readlines.select {|w|
/^[a-z]{5,7}\b/ =~ w
}.map(&:strip)
def n
(rand() * 89 + 10).floor.to_s
end
@abachman
abachman / index.js
Created January 25, 2021 02:35
Signaling Server
// npm install; npm start
const http = require('http'),
faye = require('faye');
const server = http.createServer(),
bayeux = new faye.NodeAdapter({mount: '/signal', timeout: 45});
bayeux.attach(server);
server.listen(8080);
@abachman
abachman / templates.md
Created January 5, 2021 02:27
new tab Template block demos

cat facts

url: https://cat-fact.herokuapp.com/facts

code:

<div style="border: 1px solid black;padding: 5px;">
  <h3 style="padding:0;margin:0">CAT FACTS</h3>
  {% for fact in data %}
 {{ fact.text }}
@abachman
abachman / colorWiring breakdown.md
Created October 17, 2020 15:04
turning RGB into GRB

pieces you asked about:

// translate the 24 bit color from RGB to the actual
// order used by the LED wiring.  GRB is the most common.
int colorWiring(int c) {
  int red = (c & 0xFF0000) >> 16;
  int green = (c & 0x00FF00) >> 8;
  int blue = (c & 0x0000FF);
  red = gammatable[red];
@abachman
abachman / textarea-bonanza.rb
Last active June 5, 2020 00:23
grid height bug?
#!/usr/bin/env ruby
#
# Demo of the "severe typing lag" layout bug we found.
#
# Things that fix the lag:
# - set textarea width to a non-percentage value
# - set .container grid-template-rows: to anything other than `auto`, e.g.,
# `100vh` or `100%` work; or remove the property
# - set .container height: to a fixed value or remove the property