Skip to content

Instantly share code, notes, and snippets.

@packrat386
packrat386 / filter.jq
Created March 23, 2022 18:57
jq program to filter out specs from `snyk code test`
.runs[0].results |
map(
select(
.locations[0].physicalLocation.artifactLocation.uri |
contains("spec") |
not
)
) |
map(
.locations[0].physicalLocation.artifactLocation.uri as $filename |
@packrat386
packrat386 / autoremove.sh
Created February 25, 2022 21:54
autoremove ts-expect-error comments
grep TS2578 <<<$(yarn tsc --pretty false 2>/dev/null || true) |
cut -d ':' -f 1 |
tr "()," " " |
awk '{ files[$1] = files [$1] $2 "d;" } END { for (f in files) { print "sed -i \"\" \"" files[f] "\" " f } }' |
bash -ex
[ubuntu-s-1vcpu-1gb-nyc1-01] wtf > cat wtf.rb
hill = 0
speed = 20
gas = 20
puts "hill,speed,gas,diff_hill,diff_speed,diff_gas"
100.times do
new_hill = hill + [1, -1].sample
new_speed = gas - hill
@packrat386
packrat386 / wrtr.go
Created October 5, 2021 18:34
Fill up your disk and tell you when it's full
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
"io"
"os"
)
@packrat386
packrat386 / playtest.md
Last active October 7, 2021 21:19
playtest.md

h1

h2

h3

h4

h5
h6

plain text

@packrat386
packrat386 / debug.log
Created June 24, 2021 14:59
terraform debug log
[fg-386] tf_sqs_issue_repro > AWS_PROFILE=sandbox TF_LOG=DEBUG terraform apply
2021-06-24T14:57:13.379Z [DEBUG] Adding temp file log sink: /tmp/terraform-log988771105
2021-06-24T14:57:13.379Z [INFO] Terraform version: 0.15.5
2021-06-24T14:57:13.379Z [INFO] Go runtime version: go1.16.4
2021-06-24T14:57:13.379Z [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2021-06-24T14:57:13.379Z [DEBUG] Attempting to open CLI config file: /home/acoyle/.terraformrc
2021-06-24T14:57:13.379Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021-06-24T14:57:13.379Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021-06-24T14:57:13.379Z [DEBUG] ignoring non-existing provider search directory /home/acoyle/.terraform.d/plugins
2021-06-24T14:57:13.379Z [DEBUG] ignoring non-existing provider search directory /home/acoyle/.local/share/terraform/plugins
@packrat386
packrat386 / output.txt
Created January 5, 2021 23:12
YAML to JSON is harder than you might think
[acoyle01] wat > go run yamltojson.go
lets turn YAML into JSON
here's the naive data structure
(map[string]interface {}) (len=1) {
(string) (len=3) "top": (map[interface {}]interface {}) (len=4) {
(string) (len=5) "super": (map[interface {}]interface {}) (len=1) {
(string) (len=5) "duper": (map[interface {}]interface {}) (len=1) {
(string) (len=4) "deep": (string) (len=3) "map"
}
},
@packrat386
packrat386 / output.txt
Last active December 21, 2020 21:04
tricking sorbet
[acoyle01] wat > bundle exec srb tc
village.rb:13: This code is unreachable https://srb.help/7006
13 | raise "gtfo #{participant}"
^^^^^^^^^^^^^^^^^^^^^
Errors: 1
[acoyle01] wat > bundle exec ruby village.rb
time for the festival
#<Human:0x000055d9d0f03598> got wine
Traceback (most recent call last):
3: from village.rb:53:in `<main>'
@packrat386
packrat386 / namer.py
Created November 23, 2020 01:53
Unit test mocking example in python
def name_replay(we, they):
return timestamp()+ '_' + we + '_vs_' + they
def timestamp():
# not yet implemented
return
@packrat386
packrat386 / albert.cc
Created October 15, 2020 14:49
How to use remove_if
#include <iostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::remove_if;
using std::cout;
using std::endl;
bool smol(vector<int> vec);