Skip to content

Instantly share code, notes, and snippets.

View jfarmer's full-sized avatar
🐢

Jesse Farmer jfarmer

🐢
View GitHub Profile
@jfarmer
jfarmer / 01-truthy-and-falsey-ruby.md
Last active April 16, 2024 03:40
True and False vs. "Truthy" and "Falsey" (or "Falsy") in Ruby, Python, and JavaScript

true and false vs. "truthy" and "falsey" (or "falsy") in Ruby, Python, and JavaScript

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).

This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.

If you want to use or share this material, please see the license file, below.

Update

@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 / key.md
Created November 22, 2020 05:20
Twitter (un)official Consumer Key

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA

@jfarmer
jfarmer / README.md
Last active September 8, 2023 12:07
Given a linked list and a non-negative integer k, add k to every kth element from the end of the linked list
@jfarmer
jfarmer / README.md
Last active August 25, 2023 14:10
Sudoku solver in Ruby that uses recursive backtracking, with benchmark code + 200 unsolved puzzles

Ruby Sudoku

To run, clone this gist and run from the command line:

git clone https://gist.github.com/f10377abe32d7c0b01ac.git sudoku
cd sudoku
ruby sudoku.rb unsolved.200.txt
@jfarmer
jfarmer / python-hash.md
Created August 19, 2023 15:58
Explaining Python's hash() function and __hash__ magic method

Python's hash()

Authors's Note

This is an outline of how I'd explain hash to a novice programmer. I've given versions of this explanation hundreds of times to thousands of students, beginners and experts alike.

Students tell me they find it compelling because it helps them connect w/ what's really going on by emphasizing both the technical and human/design elements.

I'm assuming the student is comfortable with:

@jfarmer
jfarmer / theory_of_learning.md
Last active May 6, 2023 22:55
Dev Bootcamp's Theory of Learning

How Dev Bootcamp Teaches: ActiveRecord

I'm Jesse, one of the co-founders of Dev Bootcamp, and the acting curricular editor-in-chief. We get lots of questions about how Dev Bootcamp approaches teaching, what our curriculum is like, and how it differs from other schools and competitors. I thought I'd share some of that with you, starting with a brief overview of our theory of learning and then sharing our introduction to ActiveRecord.

This will be light on theory and heavy on ActiveRecord, so if you're not familiar with SQL or Ruby it might be hard to follow. Mea culpa.

Dev Bootcamp's Theory of Learning

At Dev Bootcamp, we believe that "modeling" is central to learning. The most effective students have a clear model of how the world works and are able to quickly integrate new information int

Scavenger Hunt

Every item below refers to a specific function built into the JavaScript language. For each item, find:

  1. The relevant page and section on MDN's official JavaScript documentation
  2. At least one online resource (tutorial, etc.) other than Stack Overflow, w3cshools, or geekforgeeks explaining the function

Scavenger Items

  1. Given two numbers, tell me how to get the remainder after dividing the former by the latter.

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.

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