Skip to content

Instantly share code, notes, and snippets.

View mahiuchun's full-sized avatar

Hill Ma mahiuchun

  • Mountain View, CA
  • 22:55 (UTC -07:00)
View GitHub Profile
@mahiuchun
mahiuchun / void-aarch64-rpi4.md
Created April 24, 2021 04:59
Chroot install Void Linux aarch64 on Raspberry Pi 4

Introduction

There is no Pi 4 image to download from https://voidlinux.org/download/.

Turns out there is (experimental) support of EFI boot for Raspberry Pi 4, meaning we could boot operating systems (including Linux, Windows, etc.) using EFI just like we do on x86 PC. At the same time, mainline Linux support of Raspberry Pi 4 is being constantly improved, the use of Raspberry Pi specfic kernel is not required. Therefore, we can try install Void using EFI boot and generic mainline kernel.

Prerequisite

@mahiuchun
mahiuchun / gist:174595da1b39f5a3f921
Created June 6, 2014 03:51
Use Swift like Python
swift() {
local swift_=/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
if [[ -z $@ ]]
then
$swift_
else
$swift_ -i $@
fi
}
from unicodedata import name
bullets = list()
for i in range(0x10000):
try:
c = unichr(i)
if 'BULLET' in name(c):
bullets.append(c)
except:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/index.php [L]
</IfModule>
@mahiuchun
mahiuchun / main.cpp
Created December 12, 2013 16:49
img2bin
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <opencv2/opencv.hpp>
int main(int argc, const char * argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage: img2bin image-file\n");
exit(1);
dist = [0, 0, 0, 0]
isi = [-26, -10, 10, 26]
yn = [39, 21, -13, -29, -15, -19]
for i in range(0, 6):
dist2 = dist[:]
for j in range(0, 4):
lsb = j % 2
msb = j // 2
x0 = 0
if msb == 1:
@mahiuchun
mahiuchun / encoder.py
Created April 22, 2013 17:38
Simulation code for IERG3010 lecture notes, Figure 7.3
stages = [0, 0, 0]
input_seq = [1, 1, 0, 1, 0, 1, 1, 0, 0]
output_seq = []
for b in input_seq:
stages = [b] + stages[:2]
output_seq.append( (stages[0] + stages[2]) % 2 )
output_seq.append( (stages[0] + stages[1] + stages[2]) % 2 )
print(output_seq)
@mahiuchun
mahiuchun / convert_escaped_unicode.diff
Created November 12, 2012 07:30
Support Unicode Enabled ZIP Archives in File Roller
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index 32baf78..953a560 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -20,6 +20,7 @@
*/
#include <config.h>
+#include <stdio.h>
#include <stdlib.h>
@mahiuchun
mahiuchun / countdown.sh
Created October 29, 2012 00:05
Simple Shell Script to Count Down
#!/bin/sh
EVENT_DAY='2013-06-04'
INTERVAL=60
while true
do
S1=`date '+%s'`
S2=`date -d $EVENT_DAY '+%s'`
REMAINS=`expr '(' $S2 '-' $S1 ')' '/' 86400`
clear
@mahiuchun
mahiuchun / prob2.py
Created September 3, 2012 23:35
HW0 Problem2 Simulation
import random
import os
cnum = 1000000
total = 0
n = 6
random.seed(os.urandom(1024))
for i in range(cnum):