Skip to content

Instantly share code, notes, and snippets.

View zhaofengli's full-sized avatar

Zhaofeng Li zhaofengli

View GitHub Profile
@zhaofengli
zhaofengli / Reflinks.i18n.php
Created January 10, 2015 02:15
Reflinks Intuition messages
@zhaofengli
zhaofengli / lrc2srt.php
Created January 16, 2015 15:21
Quick-and-dirty LRC-to-SubRip converter
<?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 / move.php
Created March 29, 2015 06:08
Moves MP3 files downloaded via Baidu Music
<?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;

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 / gs-criteria.pegjs
Created July 8, 2017 21:28
SNPedia genoset criteria syntax
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: [] } }
@zhaofengli
zhaofengli / simple-vm.nix
Created June 2, 2021 02:53
Simple script to start a riscv64 VM
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 / README.md
Created November 1, 2021 08:23
AOSP 12 Monet / Material You