Skip to content

Instantly share code, notes, and snippets.

@hieuk09
hieuk09 / users.rb
Created November 28, 2020 07:07
ROM auto_struct does not respect struct configuration
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
end
class Users < ROM::Relation[:sql]

Display

  • 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
hieuk09 / nes.md
Last active March 1, 2017 18:08
Note on NES specification

Note on NES specification

Introduction

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.

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"])
end
it "bubbles up user validations" do
acceptance = build(:acceptance, password: "")
@hieuk09
hieuk09 / runner.sh
Last active August 29, 2015 14:23
Runner for json serializer benchmark
#!/bin/bash
array=("master" "acts_as_api" "active_model_serializers" "jbuilder" "jbuilder_with_partial" "rabl" "roar")
for i in "${array[@]}"
do
env -i git checkout $i
rspec
done
@hieuk09
hieuk09 / gist:09d485626911bdfd7c79
Created April 19, 2015 14:29
Download with progress bar
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 }
)
namespace :something do
task execute_patch: :environment do
# OtherClass is used in MyClass
OtherClass.class_eval do
def foo
'bar'
end
end
loop do
@hieuk09
hieuk09 / polymorphic_sample.rb
Last active August 29, 2015 14:07
Polymorphic sample
class Animal
def name
'animal'
end
end
class Cow < Animal
def name
'cow'
end

Sublime Text 2 – Useful Shortcuts (PC)

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

Editing

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
hieuk09 / gist:6745070
Created September 28, 2013 18:39
Auto unfriend facebook
// ==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 *.facebook.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js
// @version 3.6.1
// ==/UserScript==
// Developed by Cha(Muhammad Rafizan) - http://fb.com/cha.dae.woong.sunbae