Skip to content

Instantly share code, notes, and snippets.

View lifthrasiir's full-sized avatar

Kang Seonghoon lifthrasiir

View GitHub Profile
@lifthrasiir
lifthrasiir / ip-address.go
Last active January 14, 2016 00:41
BitBar plugin for external IP addresses
//usr/bin/env go run $0 $@; exit
package main
import (
"time"
"fmt"
"net"
"net/http"
"io/ioutil"
"encoding/json"
@lifthrasiir
lifthrasiir / jsonpp.cpp
Created March 29, 2016 15:44
JSON preprocessor for converting redundant string escapes
#include <string>
#include <cstdio>
#include <cstddef>
using namespace std;
int from_xdigit(char c) {
if ('0' <= c && c <= '9') return static_cast<int>(c - '0');
if ('a' <= c && c <= 'f') return static_cast<int>(c - 'a') + 10;
return 0x10000;
}
@lifthrasiir
lifthrasiir / keybase.md
Created May 5, 2016 19:53
Keybase proof

Keybase proof

I hereby claim:

  • I am lifthrasiir on github.
  • I am lifthrasiir (https://keybase.io/lifthrasiir) on keybase.
  • I have a public key ASAndI2FTJiHlek_hU48ZYrs1cOb4RWFf5kNUO9PAB3Fywo

To claim this, I am signing this object:

@lifthrasiir
lifthrasiir / leap.rs
Created May 27, 2016 07:31
Next leap second information via DNS
// next leap second information via DNS
// http://phk.freebsd.dk/time/20151122.html
// 2016-05 Kang Seonghoon, public domain
use std::io;
use std::net::{SocketAddr, Ipv4Addr, ToSocketAddrs};
#[derive(Debug, Clone, PartialEq, Eq)]
struct NextLeapSecond {
year_valid: u32,
@lifthrasiir
lifthrasiir / why-large.md
Last active September 27, 2017 14:17
Why is a Rust executable large? (DRAFT)

Suppose that you are a programmer primarily working with compiled languages. Somehow you’ve got tired of those languages, there may be multiple valid reasons, and heard of a trendy new programming language called Rust. Looking at some webpages and the official forum, it looks great and you decides to try it out. It seems that Rust was a bit cumbersome to install in the past, but thanks to rustup the problem seems gone by now. Cargo seems to be great, so you follow the first sections of the Book and put a small greeting to the new language:

fn main() {
    println!("Hello, world!");
}

Amazingly cargo run runs without a hassle. It is kind of a miracle as you used to configure the build script, Makefile, projects or whatever before building things. Impressed, you realize that the executable is available in target/debug/hello. You instinctively type ls -al out (or is it dir?) and

target
Cargo.lock
@lifthrasiir
lifthrasiir / .gitignore
Created August 27, 2016 05:15
Demonstrates the use of conditional attributes for proper documentation
target
Cargo.lock
@lifthrasiir
lifthrasiir / .gitignore
Last active December 10, 2022 21:44
Precision wall clock benchmark in Rust
target
Cargo.lock
| / Antidiagonals
|/_
Horizontals m l k j i h g
\ ,-------------. f Clues:
---} a / . . . . . . . \ e Ha .*H.*H.* Aa .*SE.*UE.* Da .*G.*V.*H.*
/ b / . . . . . . . . \ d Hb (DI|NS|TH|OM)* Ab .*LR.*RL.* Db [CR]*
c / . . . . . . . . . \ c Hc F.*[AO].*[AO].* Ac .*OXR.* Dc .*XEXM*
d / . . . . . . . . . . \ b Hd (O|RHH|MM)* Ad ([^EMC]|EM)* Dd .*DD.*CCM.*
e / . . . . . . . . . . . \ a He .* Ae (HHX|[^HX])* De .*XHCR.*X.*
f / . . . . . . . . . . . . \ Hf C*MC(CCC|MM)* Af .*PRR.*DDC.* Df .*(.)(.)(.)(.)\4\3\2\1.*
@lifthrasiir
lifthrasiir / temporenc.c
Created January 28, 2017 16:33
Example implementation for the proposed Temporenc byte format
// Example implementation for the proposed Temporenc byte format
// Kang Seonghoon, 2017-01-29, public domain
#include <stdint.h>
#include <stddef.h>
#include <string.h>
struct temporenc {
int has_date: 1, has_year: 1, has_mon: 1, has_day: 1;
int has_time: 1, has_hour: 1, has_min: 1, has_sec: 1, has_nsec: 1;