Skip to content

Instantly share code, notes, and snippets.

Willem van der Jagt wkjagt

Block or report user

Report or block wkjagt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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](http://shopify.com).
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"
;-------------------------------------------------------------
; CREATE SPRITES
;-------------------------------------------------------------
; The following creates one sprite. The following two bitmaps
View ruby-memoize.md

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 ||= {}
View ruby-decorate.md

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 Aug 29, 2015
A readable way to express percentage calculations
View percentage_support.md

Adds a readable way of expressing percentage calculations.

TL;DR

200 - 15.percent # 170

PercentageSupport

@wkjagt
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)
instance.set_debug_output($stderr)
@wkjagt
wkjagt / audio-book-reader.md
Last active Sep 16, 2019
How I built an audio book reader for my nearly blind grandfather
View audio-book-reader.md

#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
<?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 http://skilldrick.github.io/easy6502/ 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 :-)
You can’t perform that action at this time.