Skip to content

Instantly share code, notes, and snippets.

$ curl -O ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
$ tar -xzvf ncurses-5.9.tar.gz
$ cd ./ncurses-5.9
$ ./configure --prefix=/usr/local \
--without-cxx --without-cxx-binding --without-ada --without-progs --without-curses-h \
--with-shared --without-debug \
--enable-widec --enable-const --enable-ext-colors --enable-sigwinch --enable-wgetch-events \
&& make
$ sudo make install
@xophiix
xophiix / parseCombinedPropertyStr
Created April 2, 2015 12:51
parseCombinedPropertyStr.js
/** 简易属性解释
@param object 访问对象
@param propertyStr 访问属性字符串,仅限于包含若干.或[]的组合,如"p1.p2[3][4].p5"
@param [newValue] 如果不为undefined,则执行 object.propertyStr = newValue
@return value of object.propertyStr if newValue !== undefined
*/
function parseCombinedPropertyStr(object, propertyStr, newValue) {
if (!propertyStr) {
return undefined;
}
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
@xophiix
xophiix / print.cpp
Last active August 29, 2015 14:19
c++11 template
void printf(const char *s)
{
while (*s)
{
if (*s == '%' && *(++s) != '%')
throw std::runtime_error("invalid format string: missing arguments");
std::cout << *s++;
}
}
@xophiix
xophiix / align4.cpp
Last active August 29, 2015 14:19
solve pointer alignment bug on ios device
// see http://www.galloway.me.uk/2010/10/arm-hacking-exc_arm_da_align-exception/
// force size to align 4 byte
if ((dataSize & 0x3) != 0) {
dataSize += 4 - (dataSize & 0x3);
}
@xophiix
xophiix / renderbuffer_create_on_MIUI3_failed.cpp
Last active August 29, 2015 14:19
my own android gles bug fix and tricks
// MIUI3 not support GL_OES_packed_depth_stencil workaround
glGenRenderbuffers(1, &m_pDepthStencil);
glBindRenderbuffer(GL_RENDERBUFFER, m_pDepthStencil);
static bool supportedPackedDepthStencil = strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OES_packed_depth_stencil") != NULL;
GLenum internalFormat = supportedPackedDepthStencil ? GL_DEPTH24_STENCIL8 : GL_DEPTH_COMPONENT16;
glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, nWidth, nHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_pDepthStencil);
@xophiix
xophiix / digital_glitch_f.glsl
Last active March 25, 2016 09:02
screen signal distort .shader
uniform int byp;
uniform sampler2D tDiffuse;
uniform sampler2D tDisp;
uniform float amount;
uniform float angle;
uniform float seed;
uniform float seed_x;
uniform float seed_y;
uniform float distortion_x;
uniform float distortion_y;