Skip to content

Instantly share code, notes, and snippets.

View hibariya's full-sized avatar

Hibariya hibariya

View GitHub Profile
@hibariya
hibariya / break_terminal.c
Created June 25, 2015 15:02
Update self termios and break the terminal.
#include <unistd.h>
#include <termios.h>
int
main() {
struct termios orig_termios;
tcgetattr(STDIN_FILENO, &orig_termios);
orig_termios.c_oflag &= ~(OPOST);

Borrow and AsRef

Rust of Us - Chapter 3

Borrow and AsRef について調べたことをまとめた資料です。一部のコードは参照している文書から引用しています。

Borrow と AsRef は似ている

API Doc の Examples を見ても差分がよく分からない。

@hibariya
hibariya / application.controller.js
Last active January 10, 2016 05:17
Container returns falsy value as undefined on 2nd or later lookup
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
inspectLookup() {
return Ember.inspect(this.container.lookup('falsy:false'));
},
firstLookup: Ember.computed(function() {
return `1st lookup: ${this.inspectLookup()}`;
import Ember from 'ember';
window.list = null;
export default Ember.Controller.extend({
appName:'Ember Twiddle',
list: [Ember.Object.create({name: 'alpha'}), Ember.Object.create({name: 'bravo'}), Ember.Object.create({name: 'charlie'})],
cmp: Ember.computed('[email protected]', function() {
@hibariya
hibariya / Makefile
Last active November 11, 2022 10:35
Calling c function from x86 assembly code (cdecl)
OBJECTS = func.o main.o
CC = gcc
CFLAGS = -std=c11 -m32 -Wall -Wextra -Werror -c
AS = nasm
ASFLAGS = -f elf
all: $(OBJECTS)
gcc -m32 $(OBJECTS) -o main
run: all
@hibariya
hibariya / Makefile
Created June 19, 2016 06:17
Calling c function from x86-64 assembly code (System V AMD64 ABI)
OBJECTS = func.o main.o
CC = gcc
CFLAGS = -std=c11 -m64 -Wall -Wextra -Werror -c
AS = nasm
ASFLAGS = -f elf64
all: $(OBJECTS)
gcc -m64 $(OBJECTS) -o main
run: all
@hibariya
hibariya / Makefile
Last active May 1, 2021 21:22
Trying to get 4KB paging in long-mode...
all: bootable.bin
bootable.bin:
nasm boot.s -o $@
clean:
rm -rf *.bin
run: bootable.bin
qemu-system-x86_64 -monitor stdio bootable.bin
@hibariya
hibariya / UNI-VGA2C.rb
Last active June 12, 2018 18:23
Convert font (bdf) file to c file
File.write 'font.c', "const UINTN[][16] = {\n" + (Array.new(31) + File.read('u_vga16.bdf').split(/\nENCODING\s+/).tap(&:shift))[32..126].map {|char| " {\n" + char.match(/BITMAP[0-9A-F\n]+ENDCHAR/)[0].scan(/\n[0-9A-F]{2}+/).map(&:strip).map {|e| r = e.each_char.map {|a| "%04d" % Integer("0x#{a}").to_s(2) }.join; " 0b#{r}" }.join(",\n") + "\n }" }.join(",\n") + "\n};"
@hibariya
hibariya / hi.rb
Created August 30, 2016 03:41
I never knew 'literal'.freeze is compiled in 1 instruction (not 2)
# 1 instruction
puts RubyVM::InstructionSequence.compile(%('hi')).disasm
# == disasm: #<ISeq:<compiled>@<compiled>>================================
# 0000 trace 1 ( 1)
# 0002 putstring "hi"
# 0004 leave
# 1 instruction
puts RubyVM::InstructionSequence.compile(%('hi'.freeze)).disasm
# == disasm: #<ISeq:<compiled>@<compiled>>================================
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
DESCRIPTION="Fast, reliable, and secure dependency management. https://yarnpkg.com"
HOMEPAGE="https://yarnpkg.com/"
LICENSE="BSD"
KEYWORDS="amd64"
SRC_URI="https://github.com/yarnpkg/yarn/releases/download/v${PVR}/yarn-v${PVR}.tar.gz"