Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
JoshCheek / run.sh
Created December 17, 2023 08:32
CT36 banners and relics
curl -s 'https://sciplypandora.github.io/static/json/configs/CT36.json' |
ruby -r json -e '
puts JSON.parse($stdin.read, symbolize_names: true)
.[](:tiles)
.reject { |code, tile| tile[:tile_type] == "regular" }
.map { |code, tile|
tile_type = tile[:tile_type]
game_type = tile[:game_type].sub("least_cash", "lc").sub("least_tiers", "lt")
boss = tile[:boss] || " "
relic = tile[:relic]
@JoshCheek
JoshCheek / authenticated_field.go
Last active March 16, 2023 23:03
Example of how we can prob use resolvers in graphql-go so that you only need to be authenticated if you are asking for fields that require it.
package main
import (
"context"
"encoding/json"
"fmt"
gql "github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/directives"
)
@JoshCheek
JoshCheek / README.md
Last active March 7, 2023 10:06
A program that is both a palindrome and a quine, made with hearts for Joe

A program that is a palindrome (if you reverse its source code, you get the same program) and is a quine (if you run it, it prints out its own source code). Verify like this:

ruby palindrome_quine.rb | tee output
diff palindrome_quine.rb output # the output is the same as the source program
ruby -e 'puts $stdin.read.reverse' < palindrome_quine.rb > reversed
diff palindrome_quine.rb reversed # the reversed program is the same as the source program
@JoshCheek
JoshCheek / golang_type_system_failing_me.go
Created February 24, 2023 08:44
Golang's type system failing me, tests passed the values, but prod passed pointers to them, the type system didn't care, but staging broke b/c of a type error.
package main
import (
"fmt"
)
type Objs []Obj
type Obj interface{ GetType() string }
type IntObj struct{ Int int }
type StrObj struct{ Str string }
@JoshCheek
JoshCheek / test.cpp
Created January 17, 2023 03:29
c++ value/pointer/reference example
#include <iostream>
using namespace std;
void print_by_value(string message) { cout << message << endl; }
void print_by_pointer(string *message) { cout << *message << endl; }
void print_by_reference(string &message) { cout << message << endl; }
int main() {
string message = "whatever";
print_by_value(message);
@JoshCheek
JoshCheek / btd6_survey_responses.txt
Last active December 22, 2022 19:07
BTD6 are you better than the youtubers survey
quiz video: https://www.youtube.com/watch?v=nacAv7XMOIE
solution video: https://www.youtube.com/watch?v=lbyRTowoQDE
1. dies (WRONG)
lvl1 Sauda tends to leak on like... r4 or something, and that's a bad position for her
2. dies (WRONG)
I don't think they'll be able to take the ceramics at the end
3. wins (RIGHT)
quincy is good under alchemy, the cannon is good cleanup
4. wins (WRONG)
@JoshCheek
JoshCheek / btd6-thoughts-on-v34.0-update-notes.md
Created December 7, 2022 01:52
Thoughts on BTD6 v34.0 Update Notes

BTD6 v34.0 update notes

"New Boss Bloon: Dreadbloon!"

I guess I need to get into bosses, b/c they do make sense for me in CT, but outside of CT, god, they're so fkn tedious. I'm basically indifferent.

Team banners 9 and 10

Sweet, lets hold off and get one of these since none of the other teams will have them... unless they suck, in which case screw that.

@JoshCheek
JoshCheek / split_path_slashes_but_not_url_slashes.rb
Last active November 22, 2022 14:38
Split slashes in paths, but not URLs
def split_path(path)
slash = Regexp.escape File::SEPARATOR
match = path.match(%r~ # regex that is delimited by tildes so I can use slashes, quotes, backticks, etc in the comments
( # capture whatever the path_slash group matches
(?<path_slash> # a named group that matches slashes in paths, but not urls, eg will not match "http://example.com"
# don't match first slash in "://"
(?: # don't capture this group
(?<!:) # not preceeded by ":"
(?!#{slash}#{slash}) # not succeeded by "//" (we haven't matched the slash yet, so it's in front of the cursor)
)
@JoshCheek
JoshCheek / semicolon-at-the-beginning.js
Created November 15, 2022 13:48
Example of putting the semicolon at the beginning of the line in JS
// https://twitter.com/josh_cheek/status/1592514535789060101
console.log(1)
// this line will "continue" the previous one so
// it gets a semicolon to stop it from doing that
// JS would otherwise consider it a function call,
// ie `console.log("hello")(function() { ... })
;(function() {
console.log(2)
@JoshCheek
JoshCheek / whydoesntgowork.go
Last active November 10, 2022 02:55
whydoesntgowork.go
package main
import ("fmt")
// Real A (I cannot change this)
type RealA struct{}
func NewRealA() *RealA { return &RealA{} }
func (a *RealA) M() string { return "real a" }
// Fake A (I can change this)
type FakeA struct{}