Skip to content

Instantly share code, notes, and snippets.

View kariya-mitsuru's full-sized avatar

Mitsuru Kariya kariya-mitsuru

  • NTT DATA Corporation
View GitHub Profile
@kariya-mitsuru
kariya-mitsuru / 24-bit-color.sh
Last active January 16, 2025 11:51 — forked from lifepillar/24-bit-color.sh
Test 24 bit colors in terminals
#!/bin/bash
color() {
echo -en "\e[48;2;$1;$2;$3m "
}
reset() {
echo -e "\e[m"
}
@kariya-mitsuru
kariya-mitsuru / fizzbuzz.s
Created May 8, 2020 01:45
x64 Assembly FizzBuzz(236bytes version, Thanks @fujitanozomu for using stack instead of sbrk)
# vim: ts=8 sw=8
# build and execute
# $ gcc -mx32 -nostdlib -static -s -Wl,--build-id=none,-Ttext,0x400074 fizzbuzz.s
# $ dd if=a.out of=fizzbuzz count=236 bs=1
# $ chmod +x fizzbuzz
# $ ./fizzbuzz
.text
.Sfizzbuzz:
.ascii "Fizz"
@kariya-mitsuru
kariya-mitsuru / fizzbuzz.s
Last active May 6, 2020 16:50
x64 Assembly FizzBuzz(258bytes version)
# vim: ts=8 sw=8
# build and execute
# $ gcc -mx32 -nostdlib -static -s -Wl,--build-id=none,-Ttext,0x400074 fizzbuzz.s
# $ dd if=a.out of=fizzbuzz count=258 bs=1
# $ chmod +x fizzbuzz
# $ ./fizzbuzz
.text
.Sfizzbuzz:
.ascii "Fizz"
@kariya-mitsuru
kariya-mitsuru / fizzbuzz.s
Created May 6, 2020 15:25
x64 Assembly FizzBuzz(272bytes version)
# vim: ts=8 sw=8
# build and execute
# $ gcc -mx32 -nostdlib -static -s -Wl,--build-id=none,-Ttext,0x400094 fizzbuzz.s
# $ dd if=a.out of=fizzbuzz count=272 bs=1
# $ chmod +x fizzbuzz
# $ ./fizzbuzz
.bss
.ds.b 15
.Snumber:
@kariya-mitsuru
kariya-mitsuru / fizzbuzz.s
Created May 6, 2020 07:37
x64 Assembly FizzBuzz(286bytes version)
# vim: ts=8 sw=8
# build and execute
# $ gcc -mx32 -nostdlib -static -s -Wl,--build-id=none,-Ttext,0x400094 fizzbuzz.s
# $ dd if=a.out of=fizzbuzz count=286 bs=1
# $ chmod +x fizzbuzz
# $ ./fizzbuzz
.bss
.ds 15
.Snumber:
@kariya-mitsuru
kariya-mitsuru / fizzbuzz.s
Last active May 6, 2020 06:17
x64 Assembly FizzBuzz(nostdlib version)
// vim: ts=8 sw=8
// build and execute
// $ gcc -nostdlib -static -s fizzbuzz.s -o fizzbuzz
// $ ./fizzbuzz
.section .rodata
.Sfizz:
.asciz "Fizz\n"
.Sbuzz:
.asciz "Buzz\n"
@kariya-mitsuru
kariya-mitsuru / listenertest.rs
Created December 14, 2018 00:18
TcpListener Test
use std::net::TcpListener;
use std::io::Write;
fn main() {
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
for stream in listener.incoming() {
match stream {
Ok(mut stream) => {
let _ = stream.write(b"test\n");
@kariya-mitsuru
kariya-mitsuru / varargs.scm
Created July 6, 2016 16:24
variable length arguments in scheme
gosh> (define x (lambda (x y . z) (print "x = " x) (print "y = " y) (print "z = " z)))
x
gosh> (x 10 20)
x = 10
y = 20
z = ()
#<undef>
gosh> (x 10 20 30 40 50)
x = 10
y = 20