extern crate diesel;
use diesel::prelude::*;
table! {
users (id) {
id -> Int4,
first_name -> Nullable<Varchar>,
last_name -> Nullable<Varchar>,

Hi guys, So in episode 7 you were asking about where and how the puts method connects to the computer’s display and writes the output. And in episode 8 you were asking about the times method, how that worked and why it wasn’t implemented with YARV instructions. In both cases, I didn’t go into detail about this in the book because it would have distracted you from the topic at hand, which is how YARV executes your code. (Or in this case, my example Ruby code from the book.)

Both the puts and times methods were written by the Ruby code team, and not by you or me. Both of them are implemented in C code. So when you’re writing a Ruby program, some of the methods you write yourself, but you get many other methods for free because they are part of the Ruby language. Many of the these built in methods are part of the standard library, which means they are Ruby code written by the Ruby core team, while other built in methods are written directly in C code by the Ruby team.

As you know, the puts method tak

View hello_world.s
# Prepare a new stack frame (save the old base pointer, and set
the new base pointer to the current stack pointer)
pushq %rbp
movq %rsp, %rbp
# Get the address of your string (lea = load effective address)
# and put it into the rdi register as a parameter to printf.
leaq L_.str(%rip), %rdi
# Not sure why this is needed - I believe it sets eax to zero.
View gist:70519495343412504686
This note explains how to build Postgres from source and setup to debug it using LLDB on a Mac. I used this technique to research this article:
1. Shut down existing postgres if necessary - you don’t want to mess up your existing DB or work :)
$ ps aux | grep postgres
pat 456 0.0 0.0 2503812 828 ?? Ss Sun10AM 0:11.59 postgres: stats collector process
pat 455 0.0 0.0 2649692 2536 ?? Ss Sun10AM 0:05.00 postgres: autovacuum launcher process
pat 454 0.0 0.0 2640476 304 ?? Ss Sun10AM 0:00.74 postgres: wal writer process
pat 453 0.0 0.0 2640476 336 ?? Ss Sun10AM 0:00.76 postgres: writer process
View gist:81b40188214259678541
With regard to this twitter conversation:
Hi Pericles,
This morning I took a quick look at how ActiveRecord converts the query result
back into Ruby objects.
Here’s where it happens:
View gist:a6b2c53a56d288f8dbf6
This weekend Ashley Williams (@ag_dubs), Jeff Casimir (@j3) and I had a brief
discussion on Twitter about teaching programming to kids. We thought this would
be a topic that many other people might be interested in too, so I setup this
page in case anyone else wants to join the discussion.
We're not sure where this will lead - as a next step we could setup a Google
group, Discourse site, Basecamp or some other forum for a longer discussion.
Here's the original Twitter conversation:
View gist:b99dbf5dfbe40095d76b
Wow Justin, I really loved this! My only criticism is that it’s too bad you
used CoffeeScript instead of Ruby :)
I especially loved the top-down approach you used in your example. I’ve started
to use this all the time myself. I actually wrote about this recently:
For me, the biggest benefit of the top-down (“Ask, Don’t Tell” - apologies to
Dave Thomas) style is how it encourages a functional coding style. There are
just so many benefits of doing this. Since I’ve been doing this at a micro
View gist:8934664
after :: String -> [String] -> [String]
after _ [] = []
after target (x:xs)
| isInfixOf target x = [x] ++ xs
| otherwise = after target xs
main = do
contents <- readFile "the-lake-isle-of-innisfree.txt"
putStr . unlines . after "glimmer" . lines $ contents
View gist:8239185
-- Change RTEST:
//#define RTEST(v) !(((VALUE)(v) & ~Qnil) == 0)
#define RTEST(v) ((VALUE)(v) != Qnil && (VALUE)(v))
-- Recompile with -S flag:
clang -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -Werror=division-by-zero -Werror=extra-tokens -pipe -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin12.0 -I./include -I. -S -o object.o -c object.c
-- And here's the new assembly language - it's longer with a condition in the middle (See: je LBB7_2)
View gist:8239149
_rb_obj_not: ## @rb_obj_not
.loc 1 185 0 ## object.c:185:0
## BB#0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16