Skip to content

Instantly share code, notes, and snippets.

JoshCheek / test.cpp
Created Jan 17, 2023
c++ value/pointer/reference example
View test.cpp
#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";
JoshCheek / btd6_survey_responses.txt
Last active Dec 22, 2022
BTD6 are you better than the youtubers survey
View btd6_survey_responses.txt
quiz video:
solution video:
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 /
Created Dec 7, 2022
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 / split_path_slashes_but_not_url_slashes.rb
Last active Nov 22, 2022
Split slashes in paths, but not URLs
View split_path_slashes_but_not_url_slashes.rb
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 ""
# 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 / semicolon-at-the-beginning.js
Created Nov 15, 2022
Example of putting the semicolon at the beginning of the line in JS
View semicolon-at-the-beginning.js
// 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() {
JoshCheek / whydoesntgowork.go
Last active Nov 10, 2022
View 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{}
JoshCheek /
Last active Nov 9, 2022
Looking up users on github
# imgcat is this program, it works with iTerm2:
# not sure how to make it responsive, you'd need a way to figure out how wide a character is, which may exist
# this number of spaces was determined experimentally and sadly it changes as you resize the terminal :shrug:
ruby -rshellwords -rjson -e ' { `curl --silent{_1.shellescape}` }
.map { JSON.parse _1 }
.map { <<USER.chomp }.join("\n").display
JoshCheek / what_even_is_a_class_method.rb
Created Nov 4, 2022
What even is a "class method"?
View what_even_is_a_class_method.rb
class A
def self.b # we all agree this is a class method
A.b # => "A.b"
class << A
def c # but what about this? it's the same thing, but we define it differently
JoshCheek / interactive-grep.rb
Created Nov 2, 2022
Example of how you could create an interactive grep interface without a GUI
View interactive-grep.rb
ruby -r io/console -e '
h, w = $stdout.winsize
options = ""
loop do
command = "grep -r #{options} ." # DO NOT INTERPOLATE INTO BASH SCRIPTS IN PROD!
results = `echo -n | #{command} | head -n #{h-3}`
print "\e[H\e[J\e[2B#{results}\e[H> #{command}\e[K\e[2D"
c = $stdin.getch
break puts "\e[H\e[J#{command}" if c == ?\C-c || c == "\r"
options += c # the basic-est of input processing
View bad_ideas.rb
$**?$ # => ""
$**%$*$ # => ""
$**%** # => ""
$**%$$ # => ""
$_ = {}
alias $*$_
public def *(*) = itself
alias ** *