Skip to content

Instantly share code, notes, and snippets.

sigparse () {
i=0
# bits="$(printf "16i 2o %X p" "0x$1" | dc)" # variant for busybox
bits="$(printf "ibase=16; obase=2; %X\n" "0x$1" | bc)"
while [ -n "$bits" ] ; do
i="$(expr "$i" + 1)"
case "$bits" in
*1) printf " %s(%s)" "$(kill -l "$i")" "$i" ;;
esac
bits="${bits%?}"
@tachang
tachang / unpacker.py
Created August 28, 2020 18:29
Extract Firmware Pieces from Dump of Flash for Lenovo C2E Camera
#!/usr/bin/env python
# coding=utf-8
import click
import os
CHECK_FOLDER = os.path.isdir("flash")
if not CHECK_FOLDER:
os.makedirs("flash")
@click.command()
@tachang
tachang / Notes.md
Created July 12, 2020 01:21
Flashing a new bootloader on WyzeCam V2

The first 128 bytes of the bootloader before flashing.

# dd if=/dev/mtd0 bs=128 count=1 status=none | hexdump -C -v
00000000  06 05 04 03 02 55 aa 55  aa 39 00 00 5c 30 00 00  |.....U.U.9..\0..|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
@tachang
tachang / libvirt-domain.log
Created June 29, 2020 03:37
libvirt domain log
2020-06-29 03:27:05.129+0000: starting up libvirt version: 6.0.0, package: 0ubuntu8.1 (Christian Ehrhardt <[email protected]> Wed, 20 May 2020 06:59:57 +0200), qemu version: 4.2.0Debian 1:4.2-3ubuntu6.2, kernel: 5.4.0-39-generic, hostname: tachang-desktop
LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin \
HOME=/var/lib/libvirt/qemu/domain-2-fedora-2 \
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain-2-fedora-2/.local/share \
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain-2-fedora-2/.cache \
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain-2-fedora-2/.config \
QEMU_AUDIO_DRV=none \
/usr/bin/qemu-system-x86_64 \
-name guest=fedora-2,debug-threads=on \
@tachang
tachang / Intel520PassthroughIssues.md
Last active July 13, 2023 12:24
Intel 520 Integrated Graphics Card Passthrough Issues on Proxmox

I am having issues getting my Intel 520 integrated graphics card passing through on qemu. I am using Proxmox Virtual Environment 6.2-4.

I am getting some type of fault code when starting up a virtual machine:

qemu-system-x86_64 -machine q35 -m 2G -accel kvm -cpu host \
-device vfio-pci,host=00:02.0 -nographic -vga none \
-cdrom /var/lib/vz/template/iso/Win10_2004_English_x64.iso
@tachang
tachang / smtpforwarder.py
Created August 31, 2018 08:42
SMTP Forwarding Script
import smtpd
import asyncore
class CustomSMTPServer(smtpd.SMTPServer, object):
def process_message(self, peer, mailfrom, rcpttos, data):
print 'Receiving message from:', peer
print 'Message addressed from:', mailfrom
print 'Message addressed to :', rcpttos
print 'Message length :', len(data)
@tachang
tachang / load_database.sh
Created December 19, 2017 18:13
Scripts that loads a database from S3
#!/bin/bash
# This script looks for a database container and reloads the database
# inside the container
DB_CONTAINER_ID=`docker ps --filter="ancestor=postgres:9.6" -q`
read -p "Enter Amazon Access Key: " AMAZON_ACCESS_KEY
read -p "Enter Amazon Secret Key: " AMAZON_SECRET_KEY
@tachang
tachang / ReactControlledInputWithState.jsx
Created December 14, 2017 20:02 — forked from markerikson/ReactControlledInputWithState.jsx
React controlled input with internal state example
class ControlledInputWithInternalState extends Component {
constructor(props) {
super(props);
this.state = {
isValid : true,
value : props.value
};
}
@tachang
tachang / gist:2117833a395504bae0bde9979f4e201e
Created March 10, 2017 20:34
How to install NodeJS without root
wget https://nodejs.org/dist/v6.10.0/node-v6.10.0-linux-x64.tar.xz
tar xvfJ node-v6.10.0-linux-x64.tar.xz
echo 'export PATH=$HOME/node-v6.10.0-linux-x64/bin:$PATH' >> ~/.bashrc
. ~/.bashrc