Skip to content

Instantly share code, notes, and snippets.

@qvoid
qvoid / mediascan.py
Last active September 27, 2023 01:27
parse video or JPEG file under directory using mediainfo and format result to import to Excel
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import subprocess
import sys
import os
from os import listdir
import os.path
from os.path import isfile, join
import time
@qvoid
qvoid / convert_avcc_to_annexb.c
Created September 4, 2023 06:46
Convert H.264 bistream from AVCC to ANNEXB format
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#define AVCC_HEADER_OFFSET 4
#define AVCC_NALU_LEN_UINT_SIZE_MINUS_1_MASK 0x3
#define AVCC_HEADER_SPS_CNT_OFFSET 5
#define SPS_CNT_MASK 0x1f
#define START_CODE_SIZE 4
## resize
```shell
convert dragon_sm.gif -resize 64x64 resize_dragon.gif
```
## resize with ignoring sapect Raio
```shell
convert dragon_sm.gif -resize 64x64\! exact_dragon.gif
```
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import json
import yaml
import datetime
import os.path
import os
with open('./notes.json', 'r') as json_file:
## Reference
[Google doc](https://developer.android.com/reference/android/view/KeyEvent)
[stackoverflow](https://stackoverflow.com/questions/7789826/adb-shell-input-events)
## Keycode
```
0 --> "KEYCODE_UNKNOWN"
1 --> "KEYCODE_MENU"
2 --> "KEYCODE_SOFT_RIGHT"
  • list packages upgradable
sudo apt update
sudo apt list --upgradable
  • upgrade a specific package
sudo apt-get install --only-upgrade 
@qvoid
qvoid / launch.json
Last active October 21, 2020 07:25
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to arm64 linux",
@qvoid
qvoid / xkeyboard
Last active September 21, 2023 10:38
Disable laptop built-in keyboard
#!/bin/bash
INNER_KEYBOARD_ID=$(xinput list | grep "AT Translated Set 2 keyboard" | cut -f 2 | cut -d "=" -f 2)
INNER_KEYBOARD_STATUS=$(xinput list | grep "AT Translated Set 2 keyboard" | cut -f 3 | sed 's/\[//' |awk '{print $1}')
if [ $INNER_KEYBOARD_STATUS = "slave" ]; then
echo "floating..."
xinput float $INNER_KEYBOARD_ID
elif [ $INNER_KEYBOARD_STATUS = "floating" ]; then
echo "reattach..."
xinput reattach $INNER_KEYBOARD_ID 3
@qvoid
qvoid / rm_reverse
Last active September 21, 2023 10:13
remove file in reverse
## use grep
```
rm `ls | grep -v "file_name_wanted_to_be_kept"`
```
@qvoid
qvoid / screenrecord
Last active November 18, 2017 04:02
Record screen on an Androi device
screenrecord --size 1280x720 --bit-rate 3000000 --time-limit 10 /sdcard/demo.mp4