Skip to content

Instantly share code, notes, and snippets.

@masterzorag
masterzorag / libpng_test.c
Created December 31, 2017 18:03 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng libpng_test.c
@masterzorag
masterzorag / argb_vector.c
Created November 13, 2017 18:26
An example of using Clang vector extension
/*
an example of using GCC/Clang vector extension
clang argb_vector.c
./a.out
0 ffffffff ffffffff
1 dde0e2e5 dddfe1e4
2 bbc0c5ca bbbfc4c9
3 99a1a8af 99a0a7ae
@masterzorag
masterzorag / cooling_policy
Created September 26, 2017 10:56
A simple bash script to get/set thermal cooling policy for each cpu
#!/bin/sh
# For all cpus, just report current states if no argument is passed
NCPU=$((`grep -c '^processor' /proc/cpuinfo`))
if [ $# -lt 1 ];
then
MAX=$((`cat /sys/devices/virtual/thermal/cooling_device0/max_state`))
echo "Current cooling policy for $NCPU cpus: [0-$MAX]"
for (( i=0; i<$NCPU; i++ ))
@masterzorag
masterzorag / FTPS4.elf_issue.log
Created September 5, 2017 14:01
FTPS4.elf issue
ps4sh> execuser ps4ftp.elf
log: [HOST][DEBUG]: [PS4SH] argc=1 argv=host0:ps4ftp.elf
log: [PS4][DEBUG]: [PS4LINK] commands listener received packet size (266)
log: [HOST][DEBUG]: [PS4SH] Opening ps4ftp.elf flags 0
log: [HOST][DEBUG]: [PS4SH] Open return 7
log: [PS4][DEBUG]: [PS4LINK] Received command execuserelf argc=1 argv=host0:ps4ftp.elf
log: [PS4][DEBUG]: [PS4LINK] file open req (host0:ps4ftp.elf, 0 0)
log: [PS4][DEBUG]: [PS4LINK] file open reply received (ret 7)
log: [HOST][DEBUG]: [PS4SH] 53024 result of lseek 0 offset 2 whence
log: [PS4][DEBUG]: [PS4LINK] file lseek req (fd: 7)
[root@g5 ~]# nvram --partitions
# Sig Chk Len Name
0 5a 82 0002 nvram
1 5f 45 003e system
2 70 bd 00c1 common
3 a0 1e 0052 APL,MacOS75
4 7f c6 00ad wwwwwwwwwwww
[root@g5 ~]# nvram --dump nvram
0x00000000 5a820002 6e767261 6d000000 00000000 |Z...nvram.......|
[root@fedora-24 SEM_001-ok]# hexdump -C hd.bin | head -4
00000000 c3 68 f3 d9 1c 6b 6f 05 20 9a 3f 94 ca 55 c0 e3 |.h...ko. .?..U..|
00000010 df 37 5d 80 63 0d 85 ad e4 ef 50 54 fe 2a f6 6b |.7].c.....PT.*.k|
00000020 8a 90 1b 80 10 e7 cd 7a c9 39 73 e3 6b ec a4 56 |.......z.9s.k..V|
00000030 93 3e c8 ab 86 17 a8 39 a9 ba bc 50 11 e1 1b f5 |.>.....9...P....|
[root@fedora-24 SEM_001-ok]# hexdump -C hd_3g.bin | head -4
00000000 c3 68 f3 d9 1c 6b 6f 05 20 9a 3f 94 ca 55 c0 e3 |.h...ko. .?..U..|
00000010 df 37 5d 80 63 0d 85 ad e4 ef 50 54 fe 2a f6 6b |.7].c.....PT.*.k|
00000020 8a 90 1b 80 10 e7 cd 7a c9 39 73 e3 6b ec a4 56 |.......z.9s.k..V|
00000030 31 87 52 81 83 a8 70 d1 5f b8 54 36 1b ff 9e a0 |1.R...p._.T6....|
@masterzorag
masterzorag / draw_png_scale2x.c
Last active December 18, 2015 21:12
C simple scale 2X, pixelate
/* gcc -o demo draw_png_2x.c
# ./demo 8
0000 00
0000 01
1000 02
0000 03
00000000000000000000000000000000 00
00000000000000000000000000000000 01
00000000000000000000000000000000 02
@masterzorag
masterzorag / urlenc.c
Created December 17, 2015 16:18
C URL encoding
/*
https://gist.githubusercontent.com/sudar/3404970/raw/3f085b750aaa2ff2f49b148827a19915a4857222/url-encode.c
gcc -o test urlenc.c -Wall
./test "[a b]"
%5ba%20b%5d
*/
#include <stdio.h>
@masterzorag
masterzorag / GO-DSL-AC750
Last active January 5, 2017 21:37
Collected infos
toolchain info from https://github.com/rusxakep/asuswrt-security/raw/master/release/src/router/email-3.1.3/config.log
---------------
PATH: /opt/trendchip/mips-linux-uclibc/usr/bin # (tbs-sdk missing piece)
PATH: /opt/brcm/hndtools-mipsel-uclibc/bin
PATH: /opt/brcm/hndtools-mipsel-linux/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
@masterzorag
masterzorag / qsort.c
Last active September 30, 2015 10:35
C scanning directory: qsort
/*
http://www.scs.stanford.edu/histar/src/pkg/uclibc/test/stdlib/qsort.c
gcc -o qsort qsort.c -Wall
*/
#include <stdio.h>
#include <dirent.h>
#include <stdlib.h> // /usr/include/stdlib.h:764:13: note: expected ‘__compar_fn_t’ but argument is of type ‘int (*)(const struct dirent **, const struct dirent **)’
#include <unistd.h>