Skip to content

Instantly share code, notes, and snippets.

viz@mba:% ./fastboot flash recovery ~/Downloads/openrecovery-twrp-2.7.0.0-hammerhead.img
sending 'recovery' (13306 KB)...
OKAY [ 0.620s]
writing 'recovery'...
OKAY [ 1.045s]
finished. total time: 1.665s
@viz3
viz3 / enc.rb
Created March 7, 2014 23:20
split ts and encode.
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
class Runner
def initialize(argv)
@recorded_dir = '/chinachu/recorded'
@encoded_dir = ENV['HOME'] + '/encoded'
@work_dir = ENV['HOME'] + '/tmp'
@viz3
viz3 / mdv.sh
Created September 25, 2013 04:05
markdown viewer
#!/bin/bash
if [ "x" = "x$1" ]; then
echo "usage: `basename $0` [filename]"
exit 1;
fi
(echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(pandoc -s --toc < $1 | wc -c)\r\n\r\n"; pandoc -s --toc < $1) | nc -l 8888
@viz3
viz3 / mytop.sh
Created September 18, 2013 07:19
show most heaviest process command.
#!/bin/sh
while true; do
pid=`top -b -d 1 -n 1 | tail -n +8 | head -n 1 | awk '{print $1}'`
ps -efly | awk "{ if (\$3 == $pid) { print \$0 } }"
done
@viz3
viz3 / random_mac.py
Created September 17, 2013 07:44
generate random mac address for xen or qemu
#!/usr/bin/env python
import sys
import random
# this function is directly from xend/server/netif.py and is thus
# available under the LGPL,
# Copyright 2004, 2005 Mike Wray <mike.wray@hp.com>
# Copyright 2005 XenSource Ltd
def randomMAC(type="xen"):
@viz3
viz3 / Vagrantfile
Created September 8, 2013 07:38
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "precise32" do |precise32|
precise32.vm.box = "precise32"
precise32.vm.box_url = "http://files.vagrantup.com/precise32.box"
// gcc -Wall -g -O0 -lssl sha1test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
@viz3
viz3 / install_emacs.sh
Last active December 19, 2015 00:08
build my emacs environment.
#!/bin/sh
PREFIX="/opt/local"
DEPEND_PACKAGES="libncurses5-dev libncursesw5-dev"
EMACS_TARBALL="emacs-24.3.tar.gz"
EMACS_TARBALL_URL="http://ftp.gnu.org/gnu/emacs/emacs-24.3.tar.gz"
DDSKK_TARBALL="ddskk-15.1.tar.gz"
DDSKK_TARBALL_URL="http://openlab.ring.gr.jp/skk/maintrunk/ddskk-15.1.tar.gz"
SKK_JISYO="SKK-JISYO.L.gz"
SKK_JISYO_URL="http://openlab.jp/skk/dic/SKK-JISYO.L.gz"
@viz3
viz3 / gist:5403148
Created April 17, 2013 09:58
read from stdin and write to stdout.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUF_SIZE (256)
int main()
{
char buf[BUF_SIZE];
char *value = NULL;
@viz3
viz3 / read_urandom.php
Created April 3, 2013 02:18
generate random number from /dev/urandom
<?php
function main($argc, $argv)
{
$a = array();
if (($handle = fopen('/dev/urandom', 'rb')) === false) {
throw new Exception('/dev/urandom open failed.');
}
for ($i = 0; ; $i++) {
if (($s = fread($handle, 4)) === false) {