Skip to content

Instantly share code, notes, and snippets.

View kanru's full-sized avatar

Kan-Ru Chen kanru

View GitHub Profile
@kanru
kanru / logserver.c
Created September 4, 2014 09:58
task tracer logserver
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#!/bin/sh
set -x
DBUS_NAME="org.freedesktop.login1"
DBUS_PATH="/org/freedesktop/login1"
DBUS_INTERFACE="org.freedesktop.login1.Manager"
DBUS_SIGNAL="PrepareForSleep"
INHIBITOR_PID=
install_background_inhibitor() {
@kanru
kanru / csv2prop.py
Last active August 29, 2015 13:57
Convert Gaia l10n repository to a CSV file and convert back
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import sys
import csv
def info(log):
@kanru
kanru / ipdlgraph.py
Last active August 29, 2015 13:57
Output IPDL graph using graphviz dot format
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import ipdl
import sys
import os
def files_match(suffixes, topdir, excludes):
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<selectfont>
<acceptfont>
<pattern>
<patelt name="family"><string>terminus</string></patelt>
</pattern>
</acceptfont>
<!-- we want the unicode version -->
(defun eshell-last-argument (n)
(let* ((input (substring-no-properties
(eshell-previous-input-string (1- n))))
(parse (with-temp-buffer
(insert input)
(car (reverse (eshell-parse-arguments
(point-min) (point-max)))))))
(eval parse)))
(defun eshell-insert-last-word (n)
@kanru
kanru / jschewing.js
Created January 17, 2013 02:07
npapi-chewing example
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
(function() {
var debugging = true;
var debug = function(str) {
if (!debugging)
@kanru
kanru / bench.c
Created November 7, 2012 07:59
Little benchmark
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* Compile using |gcc -O0 bench.c -o bench|
*/
#include <stdio.h>
#include <sys/time.h>
#define TIMES 10000000
@kanru
kanru / Makefile
Created September 28, 2012 11:08
X11 EGL
all: egl
egl: egl.cpp
g++ -lX11 -lEGL -lGLESv2 egl.cpp -o egl
@kanru
kanru / .userconfig
Last active October 11, 2015 03:48
B2G user config
# -*- mode: sh -*-
GECKO_PATH=/home/kanru/zone2/mozilla/b2g18
export REMOTE_DEBUGGER=1
#export B2G_DEBUG=y
#export B2G_NOOPT=y
#export B2G_PROFILING=1
GECKO_OBJDIR=${GECKO_OBJDIR}-`basename $GECKO_PATH`