Skip to content

Instantly share code, notes, and snippets.

// Consider "applicationFrame" also with status bar.
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
} else {
// code for 3.5-inch screen
}
//or
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# axelbrz@gmail.com
#
# References:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
#traverse all the directory and subdirectory
define walk
//
// UIView+frameAdjust.h
// fenbi
//
// Created by Tang Qiao on 12-5-31.
// Copyright (c) 2012年 Fenbi.com . All rights reserved.
//
#import <Foundation/Foundation.h>
@kerasking
kerasking / dh.c
Created February 9, 2014 10:22 — forked from cloudwu/dh.c
// The biggest 64bit prime
#define P 0xffffffffffffffc5ull
#define G 5
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
// calc a * b % p , avoid 64bit overflow
--[[ config
root = "./"
listen = "127.0.0.1:8786"
redisaddr = "127.0.0.1:6379[1]"
dbfile = root .. "backup.db"
thread = 4
logger = nil
harbor = 1
--langdef=MYLUA
--langmap=MYLUA:.lua
--regex-MYLUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+):([a-zA-Z0-9_]+).*$/\2/f/
--regex-MYLUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+).*$/\2/f/
--regex-MYLUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+)\s*\(.*$/\1/f/
--regex-MYLUA=/^[ \t]*([a-zA-Z0-9_]+)[ \t]*=.*$/\1/e/
--regex-MYLUA=/^[ \t]*module[ \t\(]*\"([a-zA-Z0-9_]+)\".*$/\1/m,module/
ctags lua 规则增强,将以上部分保存至目录:
local skynet = require "skynet"
local mongo = require "mongo"
skynet.start(function()
local db = mongo.client { host = "127.0.0.1" , username = "user", password = "pass" }
local r = db:runCommand "listDatabases"
for k,v in ipairs(r.databases) do
print(v.name)
end
#include "lua.h"
#include "lauxlib.h"
#include <stdio.h>
int
dylib_add(lua_State* L) {
int a = lua_tonumber(L,1);
int b = lua_tonumber(L,2);
int c = a+b;
local skynet = require "skynet"
local socket = require "socket"
local mode = ...
if mode == "agent" then
skynet.start(function()
skynet.dispatch("lua", function(_,_,id)
socket.start(id)