Skip to content

Instantly share code, notes, and snippets.

View clarkli86's full-sized avatar

Clark Li clarkli86

  • Adelaide, Australia
View GitHub Profile
@clarkli86
clarkli86 / sort symbol
Created August 21, 2013 04:24
Print symbol names by size
arm-none-eabi-nm -S target.elf | sort -k2 > symbol-size-noprintf.txt
@clarkli86
clarkli86 / gist:6409307
Created September 2, 2013 04:56
Install hooks to all git submodules
git submodule foreach 'scp review:hooks/commit-msg $(git rev-parse --git-dir)/hooks'
@clarkli86
clarkli86 / gist:6445282
Created September 5, 2013 02:15
Rename all files
rename 's/old-name/new-name/' filespec
@clarkli86
clarkli86 / gist:6445290
Created September 5, 2013 02:16
find and replace in all files
find . -type f -print0 | xargs -0 sed -i 's/Application/whatever/g'
@clarkli86
clarkli86 / boost_regex_count
Created November 15, 2013 07:28
Count the pattern matches with boost regex
int FindPatternInFile(const char * file)
{
ifstream inFile;
inFile.open(file);//open the input file
stringstream strStream;
strStream << inFile.rdbuf();//read the file
string str = strStream.str();//str holds the content of the file
boost::regex e("m{1000000}");
@clarkli86
clarkli86 / redirect_stdout
Created November 15, 2013 07:29
Redirect the standard out to a file and restore it later
int f = open(CONSOLE_LOG_CONSOLE, O_CREAT | O_RDWR, 0666);
int out = dup(1);
close(1);
dup2(f, 1);
// Do something
fsync(f);
close(f);
dup2(out, 1);
@clarkli86
clarkli86 / upgrade_kernel_rootfs
Last active December 29, 2015 12:19
Program new kernel and rootfs
unzip -o pod.zip
flash_erase /dev/mtd3 0 0
nandwrite /dev/mtd3 linuximage -m -p
ubiformat /dev/mtd4 -y -f root.ubi
@clarkli86
clarkli86 / sort_symbols
Created January 11, 2014 12:28
Sort the symbols in ELF by size
arm-none-eabi-nm -S test.elf | sort -k2 > symbol-size-noprintf.txt
@clarkli86
clarkli86 / midicsv2frequency
Created April 1, 2014 14:14
Convert the midi csv to frequency/duration pair for embedded systems
# Convert the note on/off events to frequency/duration pair
# 1. Create the midi notes2frequency table. Tuning is based upon A=440
my $a = 440; # a is 440 hz...
my @midi;
for($x = 0; $x < 127; ++$x)
{
$midi[$x] = ($a / 32) * (2 ** (($x - 9) / 12));
}
# 2. Parse the channel events
@clarkli86
clarkli86 / 0_reuse_code.js
Created August 31, 2014 05:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console