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 February 16, 2023 05:14 — forked from lifepillar/24-bit-color.sh
Test 24 bit colors in terminals
#!/bin/bash
#
# This file echoes a bunch of 24-bit color codes
# to the terminal to demonstrate its functionality.
# The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
# The background escape sequence is ^[48;2;<r>;<g>;<b>m
# <r> <g> <b> range from 0 to 255 inclusive.
# The escape sequence ^[0m returns output to default
setBackgroundColor()
@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