Skip to content

Instantly share code, notes, and snippets.

@tachang
tachang / fabfile.py
Created April 21, 2013 16:35
Fabfile to setup a new application server
from fabric.api import *
from fabric.context_managers import *
from fabric.contrib.files import *
import fabtools.require.git
import fabtools
def install_packages():
packages = ['build-essential','git-core','python-dev']
with settings(user='root', key_filename='./root-deploy.key'):
@tachang
tachang / gist:ad8c2d0548e59ce353773ca75a5006c1
Created July 26, 2016 19:41
Hacky way to get it to require js format
/**
* CSS conic-gradient() polyfill
* By Lea Verou — http://lea.verou.me
* MIT license
*/
var cg;
(function(){
@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 / 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 / CameraToMpegTest.java
Created June 17, 2014 17:43
CameraToMpegTest.java
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@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 / 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 <christian.ehrhardt@canonical.com> 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 / 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 / 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()
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%?}"