This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This code was written by Sergejs Kovrovs and has been placed in the public domain. */ | |
import QtQuick 2.0 | |
MouseArea { | |
property point origin | |
property bool ready: false | |
signal move(int x, int y) | |
signal swipe(string direction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOCAL_PATH := $(call my-dir) | |
android_sqlite_cflags := -DHAVE_USLEEP=1 \ | |
-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 -DSQLITE_THREADSAFE=1 -DNDEBUG=1 \ | |
-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_TEMP_STORE=3 \ | |
-DSQLITE_ENABLE_FTS3_BACKWARDS -DSQLITE_ENABLE_LOAD_EXTENSION \ | |
-DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_COLUMN_METADATA \ | |
-DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_ENABLE_RTREE \ | |
-DSQLITE_SOUNDEX -DSQLITE_ENABLE_STAT3 -DSQLITE_ENABLE_FTS4_UNICODE61 \ | |
-DSQLITE_THREADSAFE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import thread | |
import time | |
def real_add(a, b, cb): | |
def add(): | |
print("[LOG] count add (%d + %d)...." % (a, b)) | |
time.sleep(3) | |
c = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadData(["test</ul><img src='#' onerror='alert(1)'/><ul>test2"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# init.d script for single or multiple unicorn installations. Expects at least one .conf | |
# file in /etc/unicorn | |
# | |
# Modified by jay@gooby.org http://github.com/jaygooby | |
# based on http://gist.github.com/308216 by http://github.com/mguterl | |
# | |
## A sample /etc/unicorn/my_app.conf | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
使用 | |
view.layer.masksToBounds = YES; // slow | |
view.layer.cornerRadius = 4; | |
画圆角非常慢, 这个方法用来生成一张图片, 带圆角, 有背景色; | |
*/ | |
+ (UIImage *)buttonBgImageWithSize:(CGSize)size color:(UIColor *)color cornerRadius:(CGFloat)cornerRadius { | |
// 不要用 UIGraphicsBeginImageContext(size); | |
// 第三个参数 0 表示 scale是屏幕的scale, 即使 2; 否则默认的是 1 | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// same as [obj someSelector] | |
SEL selector = @selector(someSelector); | |
IMP imp = [obj methodForSelector:selector]; | |
void (*func)(id, SEL) = (void *)imp; | |
func(obj, selector); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIFont *)uifontFromCTFontRef:(CTFontRef)ctFont { | |
CGFloat pointSize = CTFontGetSize(ctFont); | |
NSString *fontPostScriptName = (NSString *)CFBridgingRelease(CTFontCopyPostScriptName(ctFont)); | |
UIFont *fontFromCTFont = [UIFont fontWithName:fontPostScriptName size:pointSize]; | |
return fontFromCTFont; | |
} | |
+ (CTFontRef)ctFontRefFromUIFont:(UIFont *)font { | |
CTFontRef ctfont = CTFontCreateWithName((__bridge CFStringRef)font.fontName, font.pointSize, NULL); | |
return CFAutorelease(ctfont); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Endianness { | |
kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h. | |
kBigEndian | |
}; | |
inline enum Endianness GetEndianness() { | |
// Constant-folded by the compiler. | |
const union { | |
uint8_t u8[2]; | |
uint16_t u16; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdlib.h> | |
// assert(RAND_MAX >= 0x7fff) | |
float | |
random_0_to_1() { | |
union { | |
uint32_t d; | |
float f; | |
} u; |