Skip to content

Instantly share code, notes, and snippets.

View keldin-coding's full-sized avatar

Jon Anderson keldin-coding

View GitHub Profile
require "yaml"
require "json"
str = <<~DOC
{
"banana": "dog",
# We can do the thing
"aardvark": [
1, 2, # we need the next
3,
mercerTable = mercerTable or {}
function mercerTable.whatTheTimerDoes()
local sound1 = HoweverSoundsWork()
play(sound1)
end
function mercerTable.makeATimer()
if type(mercerTable.thisCoolTimer) == "number" then
# My least favorite valid Ruby code
"abc" "xyz"
# => "abcxyz"
# Truly cursed reminder that whitepsace doesn't matter for method invocation
# and that ary[index] syntax is just a fancy way to do ary.[](index)
[1] [2]
# => nil
foo = "abc"
class MyComponent extends React.Component {
this.handleClick = (event) => {
console.log(event); // do something
}
function render() {
<input onClick={this.handleClick} />
}
function coolCallback(event) {
console.log(event);
}
function iAcceptACallback(callback) {
callback("GOTCHA")
}
iAcceptACallback(coolCallback);
@keldin-coding
keldin-coding / replaceslash.rb
Created June 20, 2019 04:54
Escape backslashes in text
lines = File.readlines('./foo.txt', 'r')
File.open('./foo_formatted.txt', 'w') do |f|
lines.each do |line|
newline = line.gsub("\\", "\\\\\\\\")
f << newline
end
end