Skip to content

Instantly share code, notes, and snippets.

View jaymcgavren's full-sized avatar

Jay McGavren jaymcgavren

View GitHub Profile
@jaymcgavren
jaymcgavren / diff.txt
Created April 13, 2023 21:36
A comparison of ChatGPT output when asked to write "in the style of" two different authors.
View diff.txt
$ wdiff gpt_as_jaymcgavren.txt gpt_as_dhh.txt
Hey there, fellow [-Rubyists! Today, we're going to-] {+Ruby enthusiasts! Let's+} talk about [-one of-] {+Hashes,+} the [-most powerful-] {+gloriously versatile+} data [-structures in Ruby: Hashes.
If you're new-] {+structure that's as essential+} to [-programming or just getting started with Ruby, you might be wondering what a Hash is. Simply put, a Hash-] {+Ruby as air+} is [-a collection-] {+to breathing.
Hashes, also known as associative arrays or dictionaries in other programming languages, are an integral part+} of {+the Ruby ecosystem. They let you group together+} key-value [-pairs, where each key maps to-] {+pairs that are easily accessible and modifiable using+} a [-corresponding value.-] {+key.+} Think of [-it-] {+them+} as [-a dictionary,-] {+an unordered list of items+} where {+each item has its own name that+} you [-look up a word (the key)-] {+can use+} to [-find its definition (the value).-] {+fetch it.+}
Here's a simple [-example:-] {+example t
@jaymcgavren
jaymcgavren / quote_page.txt
Last active November 4, 2022 19:14
This bookmarklet copies the selected text and current URL to the clipboard. Create a new bookmark and set the URL to the content below. The setTimeout allows it to be invoked from the Chrome "Open Location" bar.
View quote_page.txt
javascript:setTimeout(async()=>await navigator.clipboard.writeText('"'+window.getSelection().toString()+'"\n'+location), 50);
@jaymcgavren
jaymcgavren / head_first_go_outline.markdown
Last active October 16, 2022 06:07
Markdown conversion of a planning outline for my Head First Go book. It may be instructive to note there are substantial differences between this and the content of the final book.
View head_first_go_outline.markdown

Syntax basics

  • Compiled language

  • Who created Go, and why

    • Fast builds
    • Fast execution
    • Concurrency
    • Garbage collection
@jaymcgavren
jaymcgavren / LICENSE.txt
Last active August 31, 2022 02:42
A script to generate a grep-able list of tables in your Rails project's database.
View LICENSE.txt
Copyright 2022 Jay McGavren
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@jaymcgavren
jaymcgavren / good_xscreensaver.txt
Created June 19, 2022 05:23
The output of `ls '~/Library/Screen Savers/'` after I deleted all the XScreensaver modules I didn't like.
View good_xscreensaver.txt
Apple2.app
Apple2.saver
Atunnel.saver
BSOD.saver
Barcode.saver
BinaryRing.saver
BlockTube.saver
Bouboule.saver
BoxFit.saver
Braid.saver
@jaymcgavren
jaymcgavren / README.md
Last active February 2, 2022 17:14
Notes bookmarklet: Paste this into your browser's address bar (the separate lines will merge), then bookmark the resulting "page". You'll have a page with just a single, large textarea (which will have cursor focus). Just start typing whatever you want.
View README.md

Due to the ubiquitous problem of tab overload, I need a way to remind myself what a browser window is for. I tried labelling tab groups in Chrome, but that gives me almost no space to work with. I thought I was going to have to install (and trust) an extension. So I was pleased to find a hack at the top of https://www.makeuseof.com/tag/use-browser-notepad/ I customized it a bit though.

Paste this into your browser's address bar (the separate lines will merge), then bookmark the resulting "page".

You'll have a page with just a single, large textarea (which will have cursor focus). Just start typing whatever you want.

It'll all disappear when you close the tab, which for my use case is a feature, not a bug.

@jaymcgavren
jaymcgavren / cheesy_linux_screen_savers.txt
Created June 12, 2021 19:10
A list of screen savers I saw fit to delete from my Mac after running a collection of Linux screen saver ports for over a year. The worst ones aren't included in this list because I deleted them before now. And there may be some you don't agree with deleting. But I only want to show the best of the best, and some of these have not aged well.
View cheesy_linux_screen_savers.txt
Abstractile.saver
Apollonian.saver
Atlantis.saver
Attraction.saver
Boing.saver
BouncingCow.saver
Boxed.saver
Bumps.saver
Cage.saver
Circuit.saver
@jaymcgavren
jaymcgavren / games0.json
Last active March 9, 2021 06:33
Littlewood game save.
View games0.json
{
"title": "Mayor",
"playerName": "Jay",
"townName": "Littlewood",
"mapString": "00000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000000000000000000100001000000000000000000000000000000000000000000000000000000000000000000001100011000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000000000000000000100001100000000000000000000000000000000000000000000000000000000000000000001000010000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000
View games0.json
{"title":"Mayor","playerName":"Jay","townName":"Littlewood","mapString":"000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000100001000000000000000000000000000000000000000000000000000000000000000000001000010000000000000000000000000000000000000000000000000000000000000000000011000110000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000100001000000000000000000000000000000000000000000000000000000000000000000001000011000000000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@jaymcgavren
jaymcgavren / poodr_checklist.md
Last active November 7, 2019 22:03
A checklist to help you apply the principles described in Practical Object-Oriented Design in Ruby to your code.
View poodr_checklist.md

Class Cohesion (Single Responsibility Principle)

  • Pretend you're talking to a sentient instance of your class. Pretend each of its methods is a question you're asking it. Do those questions all make sense? ("Mr. Gear, what is your tire size?" probably does not.)
  • Describe the class's purpose in one sentence. If that sentence contains an "and" or an "or", it probably has more than one responsibility.
  • Classes should call their own attribute reader and writer methods instead of reading and writing instance variables directly. (Controllers might be an acceptable exception to this rule.)
  • Are there any complex data structures (2-dimensional arrays, etc.) that should be encapsulated in classes with named accessor methods?
  • Are there any methods with more than one responsiblity? If you break them down into smaller methods, the new methods may be self-documenting (through their names) and may reveal additional beneficial refactorings.

Managing Dependencies