Skip to content

Instantly share code, notes, and snippets.

View ryanwebjackson's full-sized avatar

Ryan Jackson ryanwebjackson

View GitHub Profile
@tute
tute / intention-revealing-message.md
Last active August 31, 2021 14:54
Notes/Patterns for Refactoring Code

Intention Revealing Methods

Intention revealing method is simple and yet I see it frequently slip through programmers' code. Developers don't like lengthy methods, or find it inconvenient to read through chubby if-else branches, and if they are nice enough they'll leave comments like those.

If we change spaces by underscores in the comments, delete the comment characters, and define the resulting methods in the same file (as private helpers for example), we get code that explains itself, instead of through verbose long methods, or human code comments which get stale.

Intention revealing methods is the most basic, no brain-teaser, easiest rule that I know. Combine it with Sandi Metz's rule of a maximum of 5 lines per method and you'll get simple code that explains itself, that is a pleasure to read, improving communication and productivity of the team (even when it's only yourself).

Sample Code

@jeremy-w
jeremy-w / Working Effectively with Legacy Code.md
Last active April 17, 2025 09:46
Notes on Michael Feathers' *Working Effectively with Legacy Code*.

Working Effectively with Legacy Code

Notes by Jeremy W. Sherman, October 2013, based on:

Feathers, Michael. Working Effectively with Legacy Code. Sixth printing, July 2007.

Foreword:

  • Software systems degrade into a mess.
  • Requirements ALWAYS change.
  • Your goal as a software developer: Create designs that tolerate change.
@jwood803
jwood803 / FSharpBankAccount.fs
Last active November 1, 2017 21:01
Code examples for F# in the Enterprise blog post.
type BankAccount() =
member val Balance = Option<float>.None with get, set
member this.openAccount() =
this.Balance <- Some 0.0
this.Balance.Value
member this.closeAccount() =
this.Balance <- None
#Development Machine v1.0b
cmd START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/ThaddParker/543228b70fdafcee8183/raw/640f03295ce3274f870ee6f1754e9c13c070f0a6/webdev1
#create the Temp directory
$checkDir = Test-Path -PathType Container Temp
if($checkDir -eq $false){
New-Item 'Temp' -type Directory
}
# create the projects directory
@jgarber623
jgarber623 / delicious.html
Created December 2, 2014 06:07
A sample of the Netscape Bookmark File Format as exported from Delicious.
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><A HREF="https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508" ADD_DATE="1414706885" PRIVATE="0" TAGS="javascript,mac,osx,yosemite">JavaScript for Automation Release Notes</A>
<DD>This article describes JavaScript for Automation, a new feature in OS X Yosemite.
@ericelliott
ericelliott / essential-javascript-links.md
Last active June 14, 2025 18:43
Essential JavaScript Links
@WebReflection
WebReflection / one.js
Created March 7, 2015 19:42
A simple one file technique to bring JS on the client and the server
/** server */
var
port = 3000,
server = require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<!DOCTYPE html>'.concat(
'<html>',
'<head>',
'<script>(', client, ').call(this);</script>',
'</head>',
var launchArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData ?? args
@JoshCheek
JoshCheek / quiz.md
Last active August 29, 2015 14:17
HTTP quiz!

Quiz time!

  • What does the dot mean in in StringIO.new, what does the hash mean in StringIO#puts?
  • How do you make a String literal?
  • How do you make a String without using a literal?

This is an HTTP request, it is a String that is sent across a Socket, which your program can read from as if it were a file or $stdin.

01 POST /users/5?omg=wtf&amp;bbq=lol HTTP/1.1\r\n
git stash
git stash list
git stash apply
git stash drop