Skip to content

Instantly share code, notes, and snippets.

View jfarmer's full-sized avatar
🐢

Jesse Farmer jfarmer

🐢
View GitHub Profile
@jfarmer
jfarmer / README.md
Last active February 15, 2024 19:23
A demonstration of the power of the command line

The Power Of The Command Line

If you all want to learn more about the command line, one thing we didn't really touch on is input/output redirection, which is ultimately what makes the command line so powerful. On the command line, you can take the output of one program and feed it as input to another program.

The power of the command line lies in its composability. The command line has general mechanisms for taking existing programs and combining them to produce new programs.

Think of this as a system-wide API that you get "for free" by using the command line. You can chain a sequence of programs together, each one feeding its output as the input to the next one in the chain, to produce a "new" program. None of the programs involved need to know they're being used in this way.

This kind of "composability" is much harder with a GUI, so programs tend to be monolithic and only interact with other programs in pre-defined, pre-sanctioned ways.

@jfarmer
jfarmer / index.html
Last active February 25, 2020 00:46 — forked from keithjng/css
todos
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="./main.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TODO List</title>
</head>
<body>
<section>
@jfarmer
jfarmer / README.md
Created February 21, 2019 18:20
Fibonacci implementations in Ruby

Fibonacci in Ruby

Here's a benchmark for four Ruby implementations of a method to calculation the nth Fibonacci number. The implementations:

  1. fib_recursive - A memoized recursive version
  2. fib_iterative - An iterative version
  3. fib_phi - A version using Binet's formula via an implementation of the arithmetic of ℚ(φ)
  4. fib_matrix - A version using Matrix exponentiation

While fib_phi is slower than fib_matrix, you can see that it has the same rate of growth.

Casual Raiding and Deliberate Learning

Note: I wrote this in 2015 when I was raiding with a casual guild in WoW.

de·lib·er·ate (adj.)

  • done consciously and intentionally: a deliberate attempt to provoke conflict.

  • fully considered; not impulsive: a deliberate decision.

    synonyms: intentional, calculated, conscious, intended, purposeful

@jfarmer
jfarmer / fib_bench.rb
Created February 5, 2015 18:43
Fibonacci!
require "benchmark"
# Basic iterative version
def fib_iterative(n)
return 0 if n == 0
return 1 if n == 1
fibs = [0,1]
2.upto(n) do |i|
# Method name: item_counts
# Input: An arbitrary array
#
# Returns: A hash where every item is a key whose value is the number of times
# that item appears in the array
#
# Prints: Nothing
# Version 0.1
# ====================================================
SELECT p.*
FROM projects AS p
JOIN genres_projects AS gp
ON (gp.project_id = p.id)
JOIN genres AS g
ON (gp.genre_id = g.id)
WHERE g.name IN ('Drama', 'Comedy')
GROUP BY p.id
@jfarmer
jfarmer / rot_n_jesse.rb
Last active August 29, 2015 14:05 — forked from Katzy/ROTN
def rot_n_char(char, rot_by)
fail ArgumentError, "First argument must be a 1-letter String (got `#{char}')" unless char.length == 1
case char
when ('a'..'z')
((char.ord - 'a'.ord + rot_by) % 26 + 'a'.ord).chr
when ('A'..'Z')
((char.ord - 'A'.ord + rot_by) % 26 + 'A'.ord).chr
else
char
def textalyzer (string)
file_name = ARGV[0]
string = open(file_name).read
histogram(freq(count(str_char(sanitize(string)))))
return
end
def count (string)

Jesse's Notes

I carry around a little notebook with me all the time. When I'm teaching or meeting with someone I use it as my "extended working memory." I don't save the notebooks or revisit them. Once a notebook is filled I simply throw it away.

Well, with on exception: when I left DBC, I flipped through my most recent notebook, tore out any pages that grabbed my attention, and threw the rest away. These are those notes.