Skip to content

Instantly share code, notes, and snippets.

View robbinhan's full-sized avatar
🏠
Working from home

robbin han robbinhan

🏠
Working from home
View GitHub Profile
@robbinhan
robbinhan / curry_function.js
Created October 3, 2015 07:21
柯里化函数接口
var multiple = function(a){
return function(b){
return +b*a + ''
}
}
var plus = function(a){
return function(b){
return (+b)+a + ''
}
Multipler.prototype.multiple = function(numbers){
return numbers.map((number) => number*this.inc);
};
console.log(new Multipler(2).multiple([1,2,3,4]));// => [ 2, 4, 6, 8 ]

#C语言学习 ##union ##__declspec

  • 用于指定所给定类型的实例的与Microsoft相关的存储方式

##memset

  • 主要用于批量初始化数组的每个元素

##memcpy

  • 从源src所指的内存地址的起始位置开始拷贝n个字节到目标dest所指的内存地址的起始位置中

#Zend引擎分析 ##基础变量类型(zend_value)

  • zend_long

typedef int64_t zend_long;64位有符号整型

  • zend_uchar

typedef unsigned char zend_uchar;无符号字符型

#Mysql Join

内连接

  • 内连接就是计算结果集的交集 SELECT * FROM table_a, table_b WHERE table_a.id = table_b.id ##左右外部连接(内连)
  • 左外部连接是计算左表全部数据以及和右表有交集的数据 SELECT * FROM table_a LEFT OUTER JOIN table_b ON table_a.id = table_b.id
  • 右外部连接是计算右表全部数据以及和左表有交集的数据 SELECT * FROM table_a RIGHT OUTER JOIN table_b ON table_a.id = table_b.id ##左右外部连接不内连

#定义的宏

  • ZTS - 用于判断是否开始线程安全模式
  • EG - Zend引擎全局变量结构体宏(zend引擎一些变量设置,包含runtime环境的函数表、类表、zend常量、加载过的文件、error_reporting等)
  • PG - PHP核心全局变量的结构体宏(内存限制、display_error、include_path等)
  • SG - sapi全局变量的结构体宏(包含server信息、请求信息、请求的参数等)
  • PS - php的session函数库的全局变量结构体宏(包含每个session的信息,保存路径、名称、id、cookie的信息)
function verify_app_store_in_app($receipt, $is_sandbox)
{
//$sandbox should be TRUE if you want to test against itunes sandbox servers
if ($is_sandbox)
$verify_host = "ssl://sandbox.itunes.apple.com";
else
$verify_host = "ssl://buy.itunes.apple.com";
$json='{"receipt-data" : "'.$receipt.'" }';
//opening socket to itunes
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
这三个配置组合构建服务端session的垃圾回收机制
session.gc_probability与session.gc_divisor构成执行session清理的概率,理论上的解释为服务端定期有一定的概率调用gc函数来对session进行清理,清理的概率为:
gc_probability/gc_divisor 比如:1/100 表示每一个新会话初始化时(session_start),有1%的概率会启动垃圾回收程序,清理的标准为session.gc_maxlifetime定义的时间。
@robbinhan
robbinhan / gist:5669167
Created May 29, 2013 09:43
链表迭代的代码写法
listNode *listIndex(list *list, long index) {
listNode *n;
if (index < 0) {
index = (-index)-1;
n = list->tail;
while(index-- && n) n = n->prev;
} else {
n = list->head;
while(index-- && n) n = n->next;
@robbinhan
robbinhan / gist:4247728
Created December 10, 2012 00:48 — forked from markbates/gist:4240848
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.