Skip to content

Instantly share code, notes, and snippets.

View Yoxem's full-sized avatar

Tan, Kian-ting Yoxem

View GitHub Profile
@Yoxem
Yoxem / system-autodetect-battery-and-hibernate.sh
Last active November 10, 2019 17:24
A shell script used to detect the battery power on Linux laptop and give a warning when the battey is low.
#!/bin/sh
# system-autodetect-battery-and-hibernate
# a shell script used to detect the battery power on Linux laptop and give a warning when the battey is low.
# License: MIT License
# Author: Yoxem Chen
# Date: 2019-11-10 (modified: 2019-11-11)
CRITICAL_PERCENTAGE=5 # in percentage
# !/usr/bin/env python3
from copy import copy
start_point = 1
'''graph_list = list of links represented by (orig, dest, value)'''
graph_list = [(1, 2, "a"),
(2, 3, "g"),
(2, 4, "c"),
(2, 5, ("SET", "F", "G", "H")),
(4, 2, ("NOT", ""))]
@Yoxem
Yoxem / example.svg
Last active July 27, 2019 14:47
Using SVG animation to simulating clicking and opening a window / 使用 SVG 動畫模擬開啟視窗的動作
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Yoxem
Yoxem / clousre.c
Last active April 11, 2019 16:57
implementing closure in C (incompleted)
/*
a = 5;
b = 6;
A = lambda(x){
return A + a;
}
*/
typedef struct closure_A
@Yoxem
Yoxem / bitwise_add.c
Last active April 2, 2019 16:01
addition of 2 unsigned int with bitwise operator in C
#include <stdio.h>
// add with bitwise operators
unsigned int add_binary(unsigned int x, unsigned int y){
unsigned int a = x ^ y;
unsigned int b = (x & y);
if (b == 0){
return a;
}
else{
b = b << 1;
@Yoxem
Yoxem / catagorize_flickr_file.py
Last active January 16, 2019 15:28
catagorize_flickr_file.py - catagorizing Flickr backup images/videos by album name.
#!/usr/bin/env python3
#-*-coding:utf-8-*-
'''
Author: Yoxem (yoxem.tem98 [A@T] nctu.edu.tw)
Date: 20190116
License: MIT License
DESCRIPTION
------------------------
catagorize_flickr_file.py -
@Yoxem
Yoxem / prime-sequence.scm
Last active August 4, 2018 13:44
prime-sequence.scm - find primes as a infinite sequence with lazy evaluation in Scheme R5RS
;; prime-sequence.scm - find primes as a infinite sequence with lazy evaluation in Scheme R5RS
;; license: public domain
(define call/cc call-with-current-continuation)
;; filter of a list of which items satisfy func(item) == #t.
;; eg. (filter (lambda (x) (> x 7)) '(2 10 3 7 16 8))
;; -> (10 16 8)
(define (filter func list)
(filter-iter func list '())
@Yoxem
Yoxem / Hexo scripts that I used - README.txt
Last active July 29, 2018 16:15
The script that I used with Hexo / 我使用於 Hexo 的 Script
English
--------
The gist contains the scripts used with Hexo. To install them, you just download them to [Hexo blog folder]/scripts.
Description:
- footnote.js: a footnote generator.
- furi.js: furigana.
- fuby.js: ruby characters. (add phonetic description)
The license(s) for them is/are shown in their source code file.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef enum {
STATE_start, //0
STATE_num1, //1
STATE_num2, //2
STATE_num3, //3
STATE_num4, //4
STATE_id1, //5
@Yoxem
Yoxem / parallel.sil
Last active April 6, 2018 09:34
parallel text (POJ Romanization ver. & Han Character ver.) of John 1:1-8 in Hokkien, a test of SILE (a layout engine)
\begin[class=diglot,papersize=a4]{document}
\script[src=packages/rules]
\define[command=left:font]{\font[family=Gentium Plus,size=10pt,language=zh]}
\define[command=right:font]{\font[family=Noto Serif CJK TC,size=10pt,language=zh]}
\define[command=bible:verse-number]{\raise[height=3pt]{\font[size=8pt]{\process}}}
\set[parameter=document.lineskip,value=1ex]
\set[parameter=document.parskip,value=12pt]
\set[parameter=document.parindent,value=2em]
\font[family=Noto Serif CJK TC,size=20pt]{約翰福音}