Skip to content

Instantly share code, notes, and snippets.

@ph1ee
ph1ee / buildlog-825be5d.txt
Last active June 30, 2016 09:00
libubox and uci buildlog
/v/t/uci ❯❯❯ git co 825be5d0cd699919fbad15901c63044f0efffe82
Note: checking out '825be5d0cd699919fbad15901c63044f0efffe82'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
@ph1ee
ph1ee / konsole.txt
Created June 29, 2016 07:30
ambakshi/docker-perforce buildlog
/t/d/perforce-server ❯❯❯ cat Makefile
.PHONY: all build run push
IMAGE=perforce-server
NAME=perforce
HOST=perforce.c7-titan.localdomain
all: build
build:
@ph1ee
ph1ee / Test.java
Created February 16, 2016 11:48
convert InputStream to byte array #java
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
class Test
{
public void convertInputStreamToByteArray() throws IOException
{
InputStream is = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); // not really unknown
@ph1ee
ph1ee / common.sh
Last active February 16, 2016 02:10
common shell script tasks #sh
is_root() {
if [[ $EUID -ne 0 ]]; then
printf "Hi $USER, please run this script as root or with sudo\n"
exit 1
fi
}
@ph1ee
ph1ee / color-log-marker.sh
Created February 16, 2016 02:04
log marker with color #sh
#!/bin/bash
# Define log levels, the prefix strings are inspired from xorg-server
ERROR="\e[1;41m!!\e[0m"
WARNING="\e[1;43m**\e[0m"
INFO="\e[1;42m--\e[0m"
DEBUG="\e[1;44m++\e[0m"
# Declare tbl to be an associative array
declare -A tbl
@ph1ee
ph1ee / find-nal-unit.cc
Created January 30, 2016 07:21
Extract H.264 NAL unit from byte stream
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std;
uint32_t zeroNum = 0;
typedef uint8_t byte;
vector<byte> buf;
@ph1ee
ph1ee / RateStatistics.java
Created January 30, 2016 07:13
WebRTC's RateStatistics in Java
package com.simplo.netapp;
public class RateStatistics {
private int num_buckets_;
private long[] buckets_;
private long accumulated_count_;
private long oldest_time_;
private int oldest_index_;
@ph1ee
ph1ee / matrix.cc
Created January 13, 2016 03:04
2-dimensional array using std::array and std::vector
#include <iostream>
#include <array>
#include <vector>
template <size_t M, size_t N, class T>
using Matrix = std::array<std::array<T, N>, M>;
template <size_t M, size_t N, class T>
std::ostream& operator<<(std::ostream& os, Matrix<M, N, T>& matrix) {
for (auto row = matrix.begin(); row != matrix.end(); row++) {
@ph1ee
ph1ee / tlvid.sh
Last active December 17, 2015 08:05
creating a video from time-lapse images
#!/bin/bash
infile="mylist.txt"
verbose="warning"
true > ${infile}
for photo in *.JPG; do
tag=$(exiv2 -K Exif.Image.ImageDescription pr "${photo}" 2>/dev/null | cut -b60-)
case "${tag}" in
@ph1ee
ph1ee / sort2count.cc
Created December 7, 2015 11:25
convert sorted numbers to counted numbers
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
using namespace std;
/**
* This program helps to convert sorted numbers to counted numbers.
*