Skip to content

Instantly share code, notes, and snippets.

View markdown
# This is an h1
## This is an h2
Here is a paragraph with *some bold italics* and some **bold text**.
This paragraph is a little harder because it had **a bold sentence *with some italics* to make it more difficult.**
And finally a [link to shopify](
View show-sprite.asm
.segment "HEADER"
.byte "NES", $1A ; Constant
.byte 2 ; 2 x 16KB PRG ROM
.byte 1 ; 1 x 8KB CHR ROM
.segment "CHARS"
; The following creates one sprite. The following two bitmaps

Memoize memoizes function return values based on class name, method name, and arguments. This means that this only works for functions that use state / have side effects.

module Memoize
  def memoize(definition)	
    self.send(:alias_method, "__original_#{definition}", definition)

    define_method definition, { |*args|
      @__memo ||= {}

Is this a bad idea?

module Decorate
  def decorate(definition, options)	
		self.send(:alias_method, "__original_#{definition}", definition)
		define_method definition, { |*args|
			send(options.fetch(:with), *args, & { |args|
				send("__original_#{definition}", *args)
wkjagt /
Last active Aug 29, 2015
A readable way to express percentage calculations

Adds a readable way of expressing percentage calculations.


200 - 15.percent # 170


wkjagt / 2048.rb
Last active Aug 29, 2015
2048 in Ruby, because my daughter was sick, and I stayed in bed with her.
View 2048.rb
require 'io/console'
class Board
X, Y = 0, 1
COLORS = [:red, :green, :brown, :magenta, :cyan]
HOR_LINE = "-" * 29
EMPTY_COL = "| " * 4 + "|"
def initialize
@score = 0
View net_http_debug.rb
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
wkjagt /
Last active Jun 28, 2020
How I built an audio book reader for my nearly blind grandfather

#How I built an audio book reader for my nearly blind grandfather

Tweet this - Follow me

Last year, when visiting my family back home in Holland, I also stopped by my grand-parents. My grand-father, now 93 years old, had always been a very active man. However, during the presceding couple of months, he'd gone almost completely blind and now spent his days sitting in a chair. Trying to think of something for him to do, I suggested he try out audio books. After finally convincing him -- he said audio books were for sad old people -- that listening to a well performed recording is actually a wonderful experience, I realized the problem of this idea.

####The problem with audio devices and the newly blind. After my first impulse to jump up and go buy him an

View twig-example.php
// setup a template loader used by Twig to load the template strings. Most common is loading
// templates from the file system. This loader needs takes a template path or an array of
// template paths as argument to its constructor.
$templatePath = __DIR__.'/templates';
$loader = new Twig_Loader_Filesystem($templatePath);
// setup the twig environment. This is used for the actual rendering. The Twig environment takes
// the loader and an array of options as its arguments. In this example I use the twig environment
View snake6502.asm
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)