Skip to content

Instantly share code, notes, and snippets.

@CNG
CNG / test.c
Created February 27, 2016 02:56
volatile int bufn,obufn;
uint16_t buf[5][128];
q15_t out[640];
q15_t outsq[1280];
void ADC_Handler(){
int f=ADC->ADC_ISR;
if (f&(1<<27)){
bufn=(bufn+1);if(bufn==5)bufn=0;
ADC->ADC_RNPR=(uint32_t)buf[bufn];
@CNG
CNG / keybase.md
Created April 26, 2016 21:05
keybase.md

Keybase proof

I hereby claim:

  • I am cng on github.
  • I am charlieg (https://keybase.io/charlieg) on keybase.
  • I have a public key ASDYS0iSzU2DXRIFcr_WM29EwqGxVP328Smd3RgYzs5nbAo

To claim this, I am signing this object:

@CNG
CNG / sample.sh
Created May 16, 2016 04:13
Concatenate GoPro MP4 videos
name=$(ls G* | head -1);
ls G* | while read line; do echo file \'$line\'; done | ffmpeg -f concat -i - -c copy "${name%%.*}-all.${name#*.}"
@CNG
CNG / main.sh
Created March 16, 2017 11:03
Movable Type: Backup DB and app, set up publish queue, logging and PQManager plugin
MT=/var/www/cgi-bin/mt
ADMIN="arck"
if test -L $MT; then
# dereference symlink
TEMP=$(pwd)
cd -P "$MT"
MT=$(pwd)
cd $TEMP
fi
@CNG
CNG / gist:afd970322a1a5d8c85fddecc3ff3e232
Created April 12, 2017 20:13
TCPDump of SSH connection over ADB forwarded port to Android
➜ ~ sudo tcpdump -i any -nNvXS port 2224
tcpdump: data link type PKTAP
tcpdump: listening on any, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes
03:57:35.194103 IP6 (flowlabel 0x02af8, hlim 64, next-header TCP (6) payload length: 44) ::1.53458 > ::1.2224: Flags [SEW], cksum 0x0034 (incorrect -> 0x1f6a), seq 857046338, win 65535, options [mss 16324,nop,wscale 5,nop,nop,TS val 717826078 ecr 0,sackOK,eol], length 0
0x0000: 1e00 0000 6000 2af8 002c 0640 0000 0000 ....`.*..,.@....
0x0010: 0000 0000 0000 0000 0000 0001 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0001 d0d2 08b0 ................
0x0030: 3315 7d42 0000 0000 b0c2 ffff 0034 0000 3.}B.........4..
0x0040: 0204 3fc4 0103 0305 0101 080a 2ac9 281e ..?.........*.(.
0x0050: 0000 0000 0402 0000 ........
@CNG
CNG / gist:436264df4bff6d99208d67ce1f42a2c5
Created April 12, 2017 20:15
Socket listen to failed SSH connection (Protocol mismatch) over ADB forwarded socket to Android
➜ ~ sudo mv /var/folders/jk/3fltf9vx0n15p2qhkpjx2zk80000gn/T/adb-channel.O3qvO2/sock /var/folders/jk/3fltf9vx0n15p2qhkpjx2zk80000gn/T/adb-channel.O3qvO2/sock.original
sudo socat -t100 -x -v UNIX-LISTEN:/var/folders/jk/3fltf9vx0n15p2qhkpjx2zk80000gn/T/adb-channel.O3qvO2/sock,mode=777,reuseaddr,fork UNIX-CONNECT:/var/folders/jk/3fltf9vx0n15p2qhkpjx2zk80000gn/T/adb-channel.O3qvO2/sock.original
< 2017/04/12 03:20:06.995969 length=21 from=0 to=20
53 53 48 2d 32 2e 30 2d 4f 70 65 6e 53 53 48 5f SSH-2.0-OpenSSH_
37 2e 31 0d 0a 7.1..
--
> 2017/04/12 03:20:07.014937 length=1432 from=0 to=1431
00 00 05 94 0b 14 08 12 e0 64 0b 32 7c d3 0d ce .........d.2|...
42 da 73 55 13 46 00 00 01 30 63 75 72 76 65 32 B.sU.F...0curve2
@CNG
CNG / .sh
Created April 22, 2017 07:33
2017-04-22 00:30:46 execCom:executing: "/system/bin/id"
2017-04-22 00:30:46 execCom::stdout result: uid=10058(u0_a58) gid=10058(u0_a58) groups=10058(u0_a58),3002(net_bt),3003(inet),9997(everybody),50058(all_a58) context=u:r:untrusted_app:s0:c512,c768
2017-04-22 00:30:46 execCom::exit value: true
2017-04-22 00:30:46 generateNewKey:Check: dsa key is present.
2017-04-22 00:30:46 generateNewKey:Check: rsa key is present.
2017-04-22 00:30:46 generateNewKey:Check: ecdsa key is present.
2017-04-22 00:30:46 execCom:executing: "bin/pidof","sshelper_sshd","ssh"
2017-04-22 00:30:46 execCom::exit value: false
2017-04-22 00:30:46 LogServer: restarting server on port: 8080
2017-04-22 00:30:46 ClipboardServer: restarting server on port: 8081
2017-04-22 01:18:56 execCom:executing: "/system/bin/id"
2017-04-22 01:18:56 execCom::stdout result: uid=10058(u0_a58) gid=10058(u0_a58) groups=10058(u0_a58),3002(net_bt),3003(inet),9997(everybody),50058(all_a58) context=u:r:untrusted_app:s0:c512,c768
2017-04-22 01:18:56 execCom::exit value: true
2017-04-22 01:18:56 generateNewKey:Check: dsa key is present.
2017-04-22 01:18:56 generateNewKey:Check: rsa key is present.
2017-04-22 01:18:56 generateNewKey:Check: ecdsa key is present.
2017-04-22 01:18:56 execCom:executing: "bin/pidof","sshelper_sshd","ssh"
2017-04-22 01:18:56 execCom::exit value: false
2017-04-22 01:18:56 ClipboardServer: restarting server on port: 8081
2017-04-22 01:18:56 LogServer: restarting server on port: 8080
2017-04-22 01:43:03 execCom:executing: "/system/bin/id"
2017-04-22 01:43:03 execCom::stdout result: uid=10058(u0_a58) gid=10058(u0_a58) groups=10058(u0_a58),3002(net_bt),3003(inet),9997(everybody),50058(all_a58) context=u:r:untrusted_app:s0:c512,c768
2017-04-22 01:43:03 execCom::exit value: true
2017-04-22 01:43:03 generateNewKey:Check: dsa key is present.
2017-04-22 01:43:03 generateNewKey:Check: rsa key is present.
2017-04-22 01:43:03 generateNewKey:Check: ecdsa key is present.
2017-04-22 01:43:03 execCom:executing: "bin/pidof","sshelper_sshd","ssh"
2017-04-22 01:43:03 execCom::exit value: false
2017-04-22 01:43:03 LogServer: restarting server on port: 8080
2017-04-22 01:43:03 ClipboardServer: restarting server on port: 8081
def print_rangoli(size):
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' # from string import ascii_lowercase
width = size*4-3
chars = ascii_lowercase[:size]
#for line in range(1,size+1):
# line_chars = chars[size-1:size-line:-1] + chars[-line:]
# print(('-'.join(line_chars)).center(width, '-'))
#for line in reversed(range(1,size)):
# line_chars = chars[size-1:size-line:-1] + chars[-line:]