自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(62)
  • 收藏
  • 关注

原创 golang 基于epoll/kqueue的socket server

空余时间撸的项目,开源。 golang中使用epoll,代码如下:// +build linuxpackage aio// #include <errno.h>// #include <fcntl.h>// #include <sys/epoll.h>import "C"import ( "syscall" "time"..

2018-02-26 11:43:02 4436

原创 PHP通过Memcached协议连接Netty, 调用Java服务

1.Memcached协议定义:查看memached源码头文件:http://bazaar.launchpad.net/~tangent-trunk/libmemcached/1.2/view/head:/libmemcached/memcached/protocol_binary.h Memcached对操作类型定义了一个枚举类型,如下:typedef enum { PROTOC...

2018-02-06 10:53:39 1506

原创 阿里云限制

云数据库Memcache版提供实例规格如下:内存峰值QPS(次/秒)峰值吞吐量(MB/s)1G9000152G18000304G36000608G7200012016G14400024032G28800024064G

2016-08-17 15:32:06 1189

原创 php7 memcached getMulti

Seems like the signature changedWarning: Memcached::getMulti() expects at most 2 parameters, 3 givencode$results = $mc->getMulti($full_keys, $null, Memcached::GET_PRESERVE_ORDER);S

2016-07-18 18:41:01 1408

原创 Golang 处理Kafka消息

package mainimport ( "flag" "github.com/optiopay/kafka" "log" "net/http" "net/http/pprof" "strings" "time" "ooxx/config" "ooxx/lib" "ooxx/model")const LOG_CHANNEL_COUNT = 200const LOG_

2016-05-26 16:13:26 11958 2

原创 一个稍微复杂点的hive sql

with abc as(select substring(a.pay_time,1,10) dt,((if(mibi_consume>0,(mibi_consume*1.00/100), 0))+ (if(giftcard_consume>0,(giftcard_consume*1.00/100), 0)))pay_fee,a.xxx_id as uidfrom ord

2016-04-29 16:20:09 3173

原创 Ruby on Rails环境中的异步编程

一个老项目中用的还是ruby 1.8.7, 非常老的版本, 用不到coroutine等比较新的技术, 所以在项目中做一些异步的事情非常困难。当然了, 如果是最新版本的ruby,这些不是问题。ruby 1.8.7环境下要执行异步任务, 有2种方式, 这里只是简单记一下, 没有任何技术含量。1.  delayed  job, 用的github上的开源项目, https://github.c

2016-01-08 15:04:33 2031

原创 Ruby On Rails 环境中集成Slack

记录一下, 直接上代码:相关API文档:https://api.slack.com/ def self.add_ann(group, user, title, url, desc, slack_info_id= nil, color= '#ffba01') team_url= $HOST + "/team/#{group.g_name}" title= title

2015-12-25 15:46:18 691

原创 Ruby on Rails 项目里面字符串过滤html标签

    Ruby on Rails 项目里面字符串去掉html标签没有特别直接的办法, 需要借助第三方lib:1 . 比较简单的方式, 不支持换行:require 'nokogiri'item = Nokogiri::HTML('<a href="#">string</a>')puts item.to_html2. 第二种, 代码来自Github, 稍作修改:requ...

2015-12-25 15:37:14 1948

原创 python代码打包

python代码打包, 和java里面的jar一样方便:https://docs.python.org/3.5/library/zipapp.html#module-zipapp

2015-12-21 14:16:14 755

原创 Using Arel to Compose SQL Queries

https://robots.thoughtbot.com/using-arel-to-compose-sql-queriesThe Arel::Table object acts like a hash which contains each column on thetable. The columns given by Arel are a type ofNode, whic

2015-10-21 09:39:08 472

原创 Rails, ActiveRecord::Base.include_root_in_json

在rails 中object  to_json 之后是有问题的。解决办法有两种:1. ActiveRecord::Base.include_root_in_json = false这个设置是全局的,影响很大。2. 写一个通用的犯法处理数据. def obj_to_hash(obj) if obj.class.to_s == 'Array' h = []

2015-09-10 15:57:33 637

原创 一种很厉害的SQL注入攻击

explain select * from user where mail= 'IF(SUBSTR(@@version,1,1)以上SQL适应性,攻击性都非常强, 简单有效!

2015-08-30 23:25:03 1808

原创 PHP 5.6.10 编译安装

./configure --with-libdir=lib64 --enable-fpm --with-fpm-user=dog --with-fpm-group=www --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-opcache --enable-pcn

2015-06-23 22:58:22 1150

原创 ruby thin的配置

address: 0.0.0.0pid: /var/www/website/current/tmp/pids/unicorn.pidgroup: wwwport: 2101timeout: 30log: log/thin.logmax_conns: 1024require: []max_persistent_conns: 512environment:

2015-05-27 15:01:13 1342

原创 rvm

#!/usr/bin/env bash# modify the ruby string belowruby_string="ruby-1.8.7-p374@daemon"true ${rvm_path:="/usr/local/rvm"}if [[ -s "$rvm_path/scripts/rvm" ]] ; then  source "$rvm_pa

2015-05-27 11:20:02 652

原创 内核参数设置

# modprobe bridge  # /proc/sys/net/, sysctl -p, cat /proc/sys/net/unix/max_dgram_qlennet.unix.max_dgram_qlen = 100net.core.netdev_max_backlog = 262144net.core.somaxconn = 10240net.ip

2015-04-20 23:33:08 904 1

原创 S3图片跨域请求

先修改bucket跨域相关设置。Request 发送Origin 这个headerResponse返回Vary这个header。HTTP/1.1 200 OKx-amz-id-2: /I5dU6Px2xMubgiu8mxzUheMdnlHf7M9UPNAs0K1VY+MzUPGBupdFVbhEEnxrP5Ax-amz-request-id: F35821F96B2F4B2F

2015-03-27 17:58:54 2506

原创 Golang编程经验总结

如何选择web框架:首先Golang语言开发web项目不一定非要框架,本身已经提供了Web开发需要的一切必要技术。当然如果想要ruby里面Rail那种高层次全栈式的MVC框架, Golang里面暂时没有,但是不是所有人都喜欢这种复杂的框架。Golang里面一些应用层面的技术需要自己去组装,比如session,cache, log等等. 可选择的web框架有martini, goji等,都是

2015-02-03 16:38:05 11960 2

原创 php5.3,5.4,5.5,5.6 中新特性

http://blog.csdn.net/black_ox/article/details/21163193http://php.net/manual/zh/migration54.new-features.phphttp://php.net/manual/zh/migration55.new-features.phphttp://www.chinaz.com/news/2014/11

2015-01-29 23:20:48 594

原创 Golang gzip压缩的一个问题

func (b *MyBucket) Gzip(data []byte) []byte {    var res bytes.Buffer    gz, _ := gzip.NewWriterLevel(&res, 7)    _, err := gz.Write(data)    if err != nil {        Log4e(err)    } else {

2015-01-22 11:50:46 5001 1

原创 vmware 虚拟机vmware-tools安装

root@ubuntu:/mnt# mount -t iso9660 /dev/cdrom /mnt cd /mntcp -rf * /tmp umount /dev/cdromtar -zxvf VMwareTools-9.9.0-2304977.tar.gzcd  vmware-tools-distrib./vmware-install.pl

2015-01-21 22:06:35 1008

原创 GoForCPPProgrammers

https://code.google.com/p/go/source/browse/misc/cgo/gmp/gmp.go?r=releasehttps://github.com/golang/go/wiki/GoForCPPProgrammershttp://zacg.github.io/blog/2013/06/06/calling-c-plus-plus-code-from-go-

2015-01-15 23:12:10 905

原创 Amazon S3 api

https://raw.githubusercontent.com/chineking/CloudBackup/master/CloudBackup/lib/s3.py

2015-01-11 23:16:54 3150 1

原创 golang 守护进程(daemon)

package main import ( "fmt" "log" "os" "runtime" "syscall" "time") func daemon(nochdir, noclose int) int { var ret, ret2 uintptr var err syscall.Errno darwin

2015-01-07 14:53:15 8762

原创 浏览器缓存机制

看这两篇文章即可:http://www.51testing.com/html/43/434343-243768.htmlcache策略实现的原理(200、304返回码含义)http://www.laruence.com/2010/03/05/1332.html浏览器缓存机制

2015-01-03 22:01:37 636

原创 paypal IPN and PDT 2

当支付模式为快速支付(按钮)时,IPN 和PDT都会起作用, 当以Rest Api方式创建支付时, PDT是无效的,它应该是针对网站的,IPN依然起作用。调用Rest Api 付款的步骤是这样的:1. 注册paypal账号, 升级为高级或者企业账号;2. 登录开发者中心后台,注册app;3. 获取Client ID, Secret;4. 设置ipn通知地址(profile里面设置)

2014-12-08 14:33:36 1893 4

原创 paypal IPN and PDT

paypal IPN and PDT 相关文档说明:https://developer.paypal.com/docs/classic/ipn/gs_IPN/https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNPDTAnAlternativetoIPN/https://developer.paypal.c

2014-12-06 16:55:05 4827 1

原创 docker 常用命令

docker rm -f `sudo docker ps -a -q`sudo docker run ubuntu /bin/echo pwddocker run -i -t image_name /bin/bash

2014-12-01 23:30:20 790

原创 Handle inter-process communication between PhantomJS and Golang processes via hixie-76 websockets

Although PhantomJS version 1.9 does have WebSocket support, that support is limited to the hixie-76 draft of the protocol. PhantomJS 2.0 is scheduled to include the more modern RFC 6455 version of Web

2014-10-06 16:54:39 3203

原创 Mysql到Mongodb的数据转换程序

以前写的Mysql到Mongodb的数据转换程序,翻了出来,在数据量不大的情况情况完全够用。# -*- coding: utf-8 -*-import sys, osimport multiprocessingimport loggingimport randomimport time, datetimeimport MySQLdbfrom MySQLdb import curso

2014-09-28 21:45:40 1548 1

原创 ChartJs自定义tooltipTemplate

ChartJs是一款轻量级图表工具,采用html5实现画图,convas对象的fillText只支持纯文本, 所以连换行也不支持。如果要自定义tooltipTemplate,比如增加换行等,可以覆盖其原始方法draw,非常简单。如果要更复杂的,可能还得想其他办法,不采用convas实现。Chart.defaults.global.scaleBeginAtZero = true;Chart

2014-09-12 17:25:51 5147 5

原创 libPhenom 编译

安装 http://c-ares.haxx.se/安装 http://concurrencykit.org/\cp build/ck.pc  /usr/lib64/pkgconfig/$ ./autogen.sh$ ./configure$ make$ make check$ sudo make install错误1:修改cpplint.py, def

2014-06-23 17:16:16 2381 2

原创 golang coroutine 的等待与死锁

直接上代码:1. 第一种情况, 如果没有select{}, main 主线程不会等待coroutine运行,导致coroutine得不到机会运行。You are requesting eventual scheduling (using the two go statements) of two goroutines and then you exit main without g

2014-06-18 16:31:18 4911 1

原创 基于html5 localStorage , web SQL, websocket的简单聊天程序

new function() { var ws = null; var connected = false; var serverUrl; var connectionStatus; var sendMessage; var connectButton; var disconnectButton; var sendButton; var open = function(

2014-06-17 11:20:42 2626

原创 ocra 打包ruby应用

ocra blog/script/rails blog --output blog.exe --add-all-core --gemfile blog/Gemfile --no-dep-run --gem-full --chdir-first --dll libmysql.dll --dll zlib1.dll  --dll ssleay32.dll --dll libyaml-0-2.dll -

2014-06-11 21:26:37 2058

原创 golang text/template的用法: if, else, with

package mainimport "text/template"import "os"func main() { type Inventory struct { Material string Count int } sweaters := Inventory{"axe", 0} html := ` "test").Parse("{{.Count}} ite

2014-06-05 23:26:04 21352

原创 hibernate4 jpa 多对多映射

JPA的查询语言—JPQL的关联查询JPA的多对多映射http://www.cnblogs.com/luxh/archive/2012/05/30/2527123.html

2014-04-24 11:54:17 1244

原创 golang websocket的例子

最近写了一个chrome的websocket extension, server端用的是Netty, 后来发现golang 实现websocket 非常简单,高效, 下面是例子, 简单实现了用户登录,广播,相当于聊天室!package mainimport ( "code.google.com/p/go.net/websocket" "html/template" "log"

2014-04-22 17:19:52 7063 1

原创 Netty 5, websocket, websocket群发消息

/* * Copyright 2012 The Netty Project * * The Netty Project licenses this file to you under the Apache License, * version 2.0 (the "License"); you may not use this file except in compliance...

2014-04-21 17:54:09 383 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除