Skip to content

Instantly share code, notes, and snippets.

View wkjagt's full-sized avatar

Willem van der Jagt wkjagt

  • Shopify
  • Oka (Montreal area)
View GitHub Profile
@wkjagt
wkjagt / brkout.lua
Last active November 27, 2025 14:46
Simple breakout game for picolua on the PicoCalc
local splash={
[[ ____________________ ____ __.]],
[[ \______ \______ \ |/ _|]],
[[ | | _/| _/ < ]],
[[ | | \| | \ | \ ]],
[[ |______ /|____|_ /____|__ \]],
[[ \/ \/ \/]],
[[ ________ ____ ______________]],
[[ \_____ \ | | \__ ___/]],
[[ / | \| | / | | ]],
# 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](http://shopify.com).
.segment "HEADER"
.byte "NES", $1A ; Constant
.byte 2 ; 2 x 16KB PRG ROM
.byte 1 ; 1 x 8KB CHR ROM
.segment "CHARS"
;-------------------------------------------------------------
; CREATE SPRITES
;-------------------------------------------------------------
; The following creates one sprite. The following two bitmaps
@wkjagt
wkjagt / ruby-memoize.md
Last active September 29, 2015 17:45
Ruby Memoize

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, Proc.new { |*args|
 @__memo ||= {}

Is this a bad idea?

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

Adds a readable way of expressing percentage calculations.

TL;DR

200 - 15.percent # 170

PercentageSupport

@wkjagt
wkjagt / 2048.rb
Last active August 29, 2015 14:19
2048 in Ruby, because my daughter was sick, and I stayed in bed with her.
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
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)
instance.set_debug_output($stderr)
@wkjagt
wkjagt / audio-book-reader.md
Last active December 2, 2025 04:10
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

<?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