Skip to content

Instantly share code, notes, and snippets.

View NewAlexandria's full-sized avatar
🍄
My responses are limited; you must ask the right questions.

NewAlexandria

🍄
My responses are limited; you must ask the right questions.
View GitHub Profile
@NewAlexandria
NewAlexandria / redshift-skew-finder.sql
Created February 19, 2020 17:58
Find Redshift tables with large skew
# this was provided by AWS reps
WITH base_skew AS (
SELECT id as tbl FROM stv_tbl_perm GROUP BY id
HAVING SUM(rows) > (SELECT 1000000 * ( MAX(node) + 1) FROM stv_slices)
AND (MAX(rows) / (MIN(rows) + 1.0)) >= 2.0
AND SUM(rows) <> (MAX(rows) * (SELECT MAX(node) + 1 FROM stv_slices))
),
table_slices AS (
SELECT t.slice, t.id, COUNT(b.blocknum) s_mb, COUNT(DISTINCT col) * COUNT(DISTINCT unsorted) ss_mb
@NewAlexandria
NewAlexandria / bisect_test.rb
Last active November 12, 2023 18:52
Bisect class to decompose the diff history to be per-file
# Ruby class for automating 'git bisect' with Rails tests
class BisectTest
def initialize(files_to_test: , last_good_commit: )
@files_to_test = files_to_test.is_a?(Array) ? files_to_test : [files_to_test]
@last_good_commit = last_good_commit
end
# Function to run the test suite and return true if the test passed, false if it failed
def test_command
"bundle exec rails test #{@files_to_test.join(' ')}"
@NewAlexandria
NewAlexandria / ytdlp-howtube.rb
Last active August 30, 2023 19:17
POC code for extracting segment data from a HowTube.com HAR session.
#!/usr/bin/ruby
require 'json'
seg_rx = /segment[0-9]+\.ts/
file_num_rx = /^segment([0-9]+)/
pwd = "#{`pwd`.strip}"
clean_sources = false
clean_joins = false
@NewAlexandria
NewAlexandria / machine.js
Last active March 16, 2021 18:11 — forked from wildersachin/machine.js
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@NewAlexandria
NewAlexandria / machine.js
Last active April 16, 2020 03:38
Generated by XState Viz: https://xstate.js.org/viz
//
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
#!/usr/bin/python
"""AWS EC2 SSH config Generator."""
# edit these:
# * path_to_config
# * path_to_ssh_key
# remember the path_to_config must be write-able by the script
# before running, install aws_cli and login with your credentials
# then move to your .ssh folder and in your .ssh/config file
@NewAlexandria
NewAlexandria / keybase.md
Created January 3, 2017 14:18
keybase prove github newalexandria

Keybase proof

I hereby claim:

  • I am newalexandria on github.
  • I am newalexandria (https://keybase.io/newalexandria) on keybase.
  • I have a public key ASC1Scdtf-36b4jiLY8AvgvFFqjVow1-Cnbiw43f6vzmjgo

To claim this, I am signing this object:

@NewAlexandria
NewAlexandria / alias_fixer.rb
Last active November 30, 2016 03:25
This script takes a directory of files ./A with broken aliases in ./A/B and fixes all those aliases by finding the associated file in ./[A-B] and calling `ln -sf`. It will not handle dir aliases, and can be confused when a the source tree contain multiple files with the target filename. As a bonus, this script will reduce the size of directories…
#!/usr/bin/env ruby
require 'fileutils'
# these are the folders containing all your images
if ARGV.size == 2
#!/usr/bin/python
# from https://www.reddit.com/r/technology/comments/43fi39/i_set_up_my_raspberry_pi_to_automatically_tweet/
import os
import sys
import csv
import datetime
import time
import twitter