Skip to content

Instantly share code, notes, and snippets.

@ph1ee
ph1ee / 0_reuse_code.js
Created January 23, 2014 01:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ph1ee
ph1ee / gist:130a0d33001d53696da2
Last active August 29, 2015 14:01
kernel command line parser
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
static int xread(int fd, void* buf, size_t len)
{
int r;
@ph1ee
ph1ee / fonts.conf
Created August 6, 2014 01:17
$XDG_CONFIG_HOME/fontconfig/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
</match>
@ph1ee
ph1ee / pipe_progress.c
Last active October 9, 2015 06:03
Progress Pipe: Read a block of data from stdin, write it to stdout. Activity is indicated by a '.' to stderr.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define PIPE_PROGRESS_SIZE 4096
/* Read a block of data from stdin, write it to stdout.
* Activity is indicated by a '.' to stderr
*/
@ph1ee
ph1ee / graycode.cc
Created June 4, 2015 09:49
Gray Code Generator
#include <bitset>
#include <iostream>
template <size_t N>
using GrayCode = std::bitset<N>;
// Construct the binary-reflected Gray code iteratively.
template <size_t N>
class GrayCodeGenerator {
public:
@ph1ee
ph1ee / apkgen.sh
Created June 16, 2015 02:35
APK Generator
#!/bin/bash
USERNAME=username
PASSWORD=password
REPO="svn://192.168.0.30/svn/trunk/android"
APK="pkg1 pkg2 pkg3 pkg4"
OUTDIR=$HOME/build.apk
BUILDLOG=buildlog
@ph1ee
ph1ee / chkrec.sh
Created June 16, 2015 02:37
Record various H264 video clips with different settings
#!/bin/sh
die() {
cat << EOF
usage: $(basename $0) secs [timezone]
30m = 1800s 1h = 3600s 4h = 14400s 7h = 25200s
90m = 5400s 2h = 7200s 5h = 18800s 8h = 28800s
120m = 7200s 3h = 10800s 6h = 21600s 9h = 32400s
@ph1ee
ph1ee / firmgen.sh
Created June 16, 2015 02:39
Firmware daily build helper script
#!/bin/bash
USERNAME=username
PASSWORD=password
REPO="svn://192.168.0.30/svn/trunk"
FW="project"
OUTDIR=$HOME/build.fw
BUILDLOG=buildlog
@ph1ee
ph1ee / pgm2array.c
Last active August 29, 2015 14:23
Convert 4-bit P5 format PGM file to C array
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int convert(const char *var, FILE *in, FILE *out) {
char buf[256];
char fmt[16] = { 0 };
int width = 0, height = 0, depth = 0;
fgets(buf, sizeof(buf), in); // format
@ph1ee
ph1ee / svn-clean
Created July 2, 2015 12:28
Remove untrakced files from Subversion working copy
#!/usr/bin/python
import os
import re
import shutil
def removeall(path):
if os.path.islink(path):
os.unlink(path)
return