Skip to content

Instantly share code, notes, and snippets.

View kcliu's full-sized avatar

kcliu kcliu

View GitHub Profile
@kcliu
kcliu / gist:261093
Created December 21, 2009 17:30
combines several binary files
#!/usr/bin/python
import os
import string
import struct
img = ['partition.mbn','oemsblhd.mbn','appsboothd.mbn','qcsblhd_cfgdata.mbn','qcsbl.mbn','oemsbl.mbn','amss.mbn','appsboot.mbn','boot.img','system.img','userdata.img'];
class Combine(object) :
#constructor
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Show File Data</title>
<style type='text/css'>
body {
font-family: sans-serif;
}
</style>
@kcliu
kcliu / dbus-c++.rb
Created March 10, 2011 14:24
for homebrew
require 'formula'
class DbusCxx <Formula
#head 'git://gitorious.org/dbus-cplusplus/mainline.git'
head 'git://gitorious.org/~matlinuxer2/dbus-cplusplus/matlinuxer2s-mainline.git', :branch => 'forosx'
homepage 'http://sourceforge.net/projects/dbus-cplusplus/'
depends_on 'expat'
depends_on 'd-bus'
depends_on 'libxml2'
function adjustSize(&$crops, $frames, $ratio)
{
// adjust multi-frame height
foreach($frames as $frameNum) {
$crops[$frameNum - 1]->newSx *= $ratio;
$crops[$frameNum - 1]->newSy *= $ratio;
$crops[$frameNum - 1]->newW *= $ratio;
$crops[$frameNum - 1]->newH *= $ratio;
}
}
function resizeStuff() {
//Time consuming resize stuff here
}
var TO = false;
$(window).resize(function(){
if(TO !== false)
clearTimeout(TO);
TO = setTimeout(resizeStuff, 200); //200 is time in miliseconds
});
1. Introduction :
This project implements a comic viewer which adjusts the layout of the original page in order to fit the screen size.
The information of screen size will be sent by the front-end through AJAX to backend. The backend php calculates the best
layout for the current screen information by applying a dynamic programming algorithm. In addition, while adjsuting the size
of the browser, a layout re-calculation will be performed. This comic viewer supports keyboard browsing by pressing left/right
key and also has a images list in the bottom for fast switching between pages.
/*
support FullScreenMode
*/
var FullScn = {
enterFullScn: function()
{
var e = document.getElementById("fullscreen-wrapper");
if (FullScn.RunPrefixMethod(document, "FullScreen") || FullScn.RunPrefixMethod(document, "IsFullScreen")) {
FullScn.RunPrefixMethod(document, "CancelFullScreen");
db.open(function(err, db) {
db.collection('foo', function(err, collection) {
collection.find({"foo":foo}).toArray(function(err, data) {
return data;
});//end of collection.find
});//end of db.collection
});// end of db.open
err, db <- mongodb.Db.open
err, collection <- db.collection 'foo'
err, data <- collection.find({"foo":foo}).toArray
data
$entry[0] = array(
0 => 'foo',
1 => false,
2 => -1,
3 => null,
4 => ''
);
$entry[1] = '';
$entry[2] = array(
0 => '',