Skip to content

Instantly share code, notes, and snippets.

View jaymcgavren's full-sized avatar

Jay McGavren jaymcgavren

View GitHub Profile
@jaymcgavren
jaymcgavren / fence.sh
Created August 3, 2018 21:33
Convert the current clipboard contents to a fenced code block
pbpaste | ruby -e 'puts "```"; puts ARGF.read; puts "```"' | pbcopy
@jaymcgavren
jaymcgavren / random_names.txt
Last active July 25, 2018 00:53
A list of random names, loosely based on data from the 1990 United States Census.
Mary Townzen
Patricia Gooden
Linda Spinelli
Barbara Luth
Elizabeth Blackmon
Jennifer Vanness
Maria Aricas
Susan Stepro
Margaret Galbavy
Dorothy Faull
class Mousetrap
attr_accessor :marble_count
def initialize(marble_count)
self.marble_count = marble_count
end
def press_button
print "presses the button which "
flip_bucket
end
def flip_bucket
class Recursor
attr_accessor :counter
def initialize
self.counter = 0
end
def a
return b + "a"
@jaymcgavren
jaymcgavren / simulate_typing_clipboard.txt
Last active April 29, 2019 04:18
Simulate typing out the clipboard contents! Save the below script as an AppleScript or a service in Automator.
set mytext to (the clipboard as text)
write_string(mytext)
on write_string(the_string)
tell application "System Events"
launch
repeat with the_character in the_string
keystroke the_character
delay (random number from 0.05 to 0.25)
@jaymcgavren
jaymcgavren / desert_golfing_hole_2866.md
Last active September 18, 2022 12:20
How to beat the "impossible" hole 2866 on Desert Golfing

Here's a picture of Desert Golfing Hole 2866, which even the developer believed was impossible at first.

Desert Golfing Hole 2866

And here it is together with a picture of the following hole, 2867.

Desert Golfing Hole 2866 and 2867, stitched together

As you probably know, even though the next hole is off the screen and invisible, you can still bounce the ball off of its landscape features and back into the playfield. You can do a hail-Mary shot from the tee on 2866, aiming for the offscreen hill on the far side of the water hazard (which technically belongs to hole 2867). It will bounce off the hill and straight into the hole.

Had one of the most intense experiences of my gaming career while playing
Skyrim. The Hearthfire expansion lets you build a house out in the country, and
also lets you adopt up to two orphaned children to live there. Your options for
interacting with the kids are pretty simple: "Go play outside," "I brought you
a present," "Time for bed," etc., but it's just enough to make you feel
responsible for their well being. So one day, I tell the kids to go play
outside while I'm working on remodeling the house. The afternoon slips by, and
I haven't heard a peep from the kids, so of course I feel compelled to step out
and check on them. They're just outside the front door. All seems well. Then I
round the corner, and staring straight back at me is a club-wielding giant.
@jaymcgavren
jaymcgavren / blog.rb
Created October 26, 2017 22:48
Set up Active Record with an in-memory database and model classes, all in a single file.
# Instead of loading all of Rails, load the
# particular Rails dependencies we need
require 'sqlite3'
require 'active_record'
# Set up a database that resides in RAM
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
@jaymcgavren
jaymcgavren / a_template.html.erb
Created October 26, 2017 18:39
A single-file Rails 5 application.
<!-- NOTE this file must be saved under a folder named "a_subfolder"! -->
<h1>a_template</h1>
<h1><%= @a_variable.an_attribute %></h1>
@jaymcgavren
jaymcgavren / shell_log.txt
Created October 11, 2017 18:47
With URL on clipboard, retrieve title from site and convert to Markdown link
$ pbpaste
https://www.ruby-lang.org/
$ pbpaste | ruby -e 'url = gets.chomp; puts "[#{$1}](#{url})" if `curl -s #{url}` =~ %r{<title>(.*)</title>}im' | pbcopy # Get Markdown link
$ pbpaste
[Ruby Programming Language](https://www.ruby-lang.org/)