Skip to content

Instantly share code, notes, and snippets.

@zhaofengli
zhaofengli / README.md
Created Nov 1, 2021
AOSP 12 Monet / Material You
View README.md
@zhaofengli
zhaofengli / simple-vm.nix
Created Jun 2, 2021
Simple script to start a riscv64 VM
View simple-vm.nix
with builtins;
let
pkgs = import ./. {};
cross = pkgs.pkgsCross.riscv64;
kernel = cross.linuxPackages_5_12.kernel;
busybox = cross.busybox.override { enableStatic = true; };
memory = "1G";
smp = 4;
@zhaofengli
zhaofengli / gs-criteria.pegjs
Created Jul 8, 2017
SNPedia genoset criteria syntax
View gs-criteria.pegjs
Start
= Comment* fc:FunctionCall Comment* { return fc }
// Function names must be at least 2 characters and must start with a lowercase letter
FunctionName
= first:[a-z] rest:[a-z0-9]i+ { return first + rest.join('') }
FunctionCall
= Ws name:FunctionName '(' Ws args:ArgumentList Ws ')' { return { type: 'FunctionCall', name, args } }
/ Ws name:FunctionName { return { type: 'FunctionCall', name, arguments: [] } }
View keybase.md

Keybase proof

I hereby claim:

  • I am zhaofengli on github.
  • I am zhaofengli (https://keybase.io/zhaofengli) on keybase.
  • I have a public key whose fingerprint is 7F55 777C 745E A208 2DCA 2F5D 5040 FCD6 3E1C 6262

To claim this, I am signing this object:

@zhaofengli
zhaofengli / move.php
Created Mar 29, 2015
Moves MP3 files downloaded via Baidu Music
View move.php
<?php
// Moves MP3 files downloaded via Baidu Music
// By Zhaofeng Li - Public domain
$pattern = "/(?'artist'[^-]+)-(?'album'[^-]+)-(?'title'[^-]+)-/";
$dir = "/sdcard/Baidu_music/download";
$dest = "/sdcard/Music";
$files = scandir( $dir );
foreach ( $files as $file ) {
if ( preg_match( $pattern, $file, $m ) ) {
if ( strpos( $m['artist'], "," ) ) continue;
@zhaofengli
zhaofengli / lrc2srt.php
Created Jan 16, 2015
Quick-and-dirty LRC-to-SubRip converter
View lrc2srt.php
<?php
// Okay, the music player in CM12 only supports srt lyrics files (they must have watched too many films), so...
function lrc2srt( $lrc ) {
$lrc = explode( "\n", $lrc );
$srt = "";
$lines = array();
foreach ( $lrc as $lrcl ) {
if ( preg_match( "|\[(\d\d)\:(\d\d)\.(\d\d)\](.+)|", $lrcl, $m ) ) {
$lines[] = array(
'time' => "00:{$m[1]}:{$m[2]},{$m[3]}0", // convert to SubRip-style time
@zhaofengli
zhaofengli / Reflinks.i18n.php
Created Jan 10, 2015
Reflinks Intuition messages
View Reflinks.i18n.php