Skip to content

Instantly share code, notes, and snippets.

hieuk09 / users.rb
Created Nov 28, 2020
ROM auto_struct does not respect struct configuration
View users.rb
require 'rom'
require 'rom-repository'
rom = ROM.container(:sql, 'sqlite::memory') do |conf|
conf.default.create_table(:users) do
primary_key :id
column :name, String, null: false
class Users < ROM::Relation[:sql]


  • PPU has 3x cycle speed compare to CPU
  • PPU can render upto 64 sprite
  • Sprite could be 8x16 or 8x8
  • Color is specified by 2 bit in the pattern table, and 2 bit in the attribute table

Instruction set

  • Instruction set is based on addressing mode
  • The opcode is a 4 byte number
hieuk09 /
Last active Mar 1, 2017
Note on NES specification

Note on NES specification


NES is Nintendo Entertainment System, a gaming console which is popular in 1980s

Hardware Overview

Since I'm reading the specification while implementing the emulator for Chip8, there will be some comparison between them.

View acceptance_no_let_spec.rb
describe "validations" do
it "validates presence of github_username" do
acceptance = build(:acceptance, github_username: "")
expect(acceptance).to be_invalid
expect(acceptance.errors[:github_username]).to eq(["can't be blank"])
it "bubbles up user validations" do
acceptance = build(:acceptance, password: "")
hieuk09 /
Last active Aug 29, 2015
Runner for json serializer benchmark
array=("master" "acts_as_api" "active_model_serializers" "jbuilder" "jbuilder_with_partial" "rabl" "roar")
for i in "${array[@]}"
env -i git checkout $i
hieuk09 / gist:09d485626911bdfd7c79
Created Apr 19, 2015
Download with progress bar
View gist:09d485626911bdfd7c79
require 'open-uri'
require 'fileutils'
require 'ruby-progressbar'
progress_bar = ProgressBar.create(
starting_at: 0,
total: nil,
format: "%a %B %p%% %r KB/sec",
rate_scale: lambda { |rate| rate / 1024 }
View something.rake
namespace :something do
task execute_patch: :environment do
# OtherClass is used in MyClass
OtherClass.class_eval do
def foo
loop do
hieuk09 / polymorphic_sample.rb
Last active Aug 29, 2015
Polymorphic sample
View polymorphic_sample.rb
class Animal
def name
class Cow < Animal
def name
View gist:8143930

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.


Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+ insert line after
hieuk09 / gist:6745070
Created Sep 28, 2013
Auto unfriend facebook
View gist:6745070
// ==UserScript==
// @name Unfriend In Single-Click on Facebook by Cha
// @description This script is useful if you don't want to delete each friends one by one.
// @namespace Cha
// @include **
// @require
// @version 3.6.1
// ==/UserScript==
// Developed by Cha(Muhammad Rafizan) -