Skip to content

Instantly share code, notes, and snippets.

View albertnetymk's full-sized avatar

Albert Yang albertnetymk

  • Uppsala, Sweden
View GitHub Profile
@adamcooke
adamcooke / dsl.rb
Created November 7, 2014 15:20
The complete code from my DSL tutorial at http://blog.atechmedia.com/ruby-dsls-for-fun/
class AddressBook
def contacts
@contacts ||= []
end
def self.load_from_path(path)
# Create a new AddressBook instance
address_book = self.new
# Create a new AddressBookDSL instance
@XVilka
XVilka / TrueColour.md
Last active March 24, 2024 11:07
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This code resolves the problem described in
http://xahlee.info/perl-python/python_construct_tree_from_edge.html
"""
import collections
# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'
@luikore
luikore / hat-cache-miss.md
Last active May 5, 2016 15:22
Comparing cache-miss of triez, fast_trie and hash reads

To test out the cache miss behavior of read operations, run a program building the index (30k entries) then another program building then reading the index (30k queries), and find their diff.

Here's how to generate the test script cmd.sh

3.times do |i|
  %w[triez hash da].each do |ty|
    puts "valgrind --tool=cachegrind --cachegrind-out-file=tmp/#{ty} ruby t.rb #{ty}"
    puts "valgrind --tool=cachegrind --cachegrind-out-file=tmp/#{ty}.read ruby t.rb #{ty} read"
    puts "cg_diff tmp/#{ty} tmp/#{ty}.read > tmp/#{ty}#{i}.diff"