Skip to content

Instantly share code, notes, and snippets.

View guohai's full-sized avatar
🎱
Hey

Brent G guohai

🎱
Hey
View GitHub Profile
@guohai
guohai / AutoIncrementDemo.class
Created September 1, 2011 09:43
Java AutoIncrement Atomic Bytecode
// javap -c -l AutoIncrementDemo
Compiled from "AutoIncrementDemo.java"
public class AutoIncrementDemo extends java.lang.Object{
public AutoIncrementDemo();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
@guohai
guohai / ArcTranslateAnimation.java
Created April 3, 2012 16:55
Curved Path Animation in Android
import android.graphics.PointF;
import android.view.animation.Animation;
import android.view.animation.Transformation;
// http://www.math.ubc.ca/~cass/gfx/bezier.html
public class ArcTranslateAnimation extends Animation {
private int mFromXType = ABSOLUTE;
private int mToXType = ABSOLUTE;
#define DECLARE_ENUM(E) struct E { public: E(int value = 0) : _value((__Enum)value) { } E& operator=(int value) { this->_value = (__Enum)value; return *this; } operator int() const { return this->_value; } enum __Enum {
#define END_ENUM() }; private: __Enum _value; };
#include <iostream>
using namespace std;
class B {
B &operator=(const B &);
};
@guohai
guohai / rund
Created February 27, 2013 14:11
launcher script for Dalvik on X86 Linux
#!/bin/sh
# base directory, at top of source tree; replace with absolute path
base=`pwd`
# configure root dir of interesting stuff
root=$base/out/host/linux-x86
export ANDROID_ROOT=$root
# configure bootclasspath
@guohai
guohai / bitmap_gen_test.c
Created June 24, 2013 06:29
sample code for generate a bitmap image at x86_64 GNU/Linux
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// for Linux platform, plz make sure the size of data type is correct for BMP spec.
// if you use this on Windows or other platforms, plz pay attention to this.
typedef int LONG;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
typedef unsigned short WORD;
#include <stdio.h>
#include <stdlib.h>
struct SBinaryTreeNode // a node of the binary tree
{
int m_nValue; // value of node
struct SBinaryTreeNode *m_pLeft; // left child of node
struct SBinaryTreeNode *m_pRight; // right child of node
};