Skip to content

Instantly share code, notes, and snippets.

@risent
risent / # gcc - 2018-03-07_09-59-22.txt
Created March 7, 2018 02:03
gcc on macOS 10.13.3 - Homebrew build logs
Homebrew build logs for gcc on macOS 10.13.3
Build date: 2018-03-07 09:59:22
@risent
risent / WXBizMsgCrypt.py
Last active April 20, 2017 07:24
对公众平台发送给公众账号的消息加解密示例代码,使用cryptography替代pycrypto,兼容PyPy
#!/usr/bin/env python
# -*- encoding:utf-8 -*-
""" 对公众平台发送给公众账号的消息加解密示例代码.
@copyright: Copyright (c) 1998-2014 Tencent Inc.
"""
# ------------------------------------------------------------------------
import base64
@risent
risent / tensorflow_cuda_osx.md
Created February 9, 2017 15:13 — forked from Mistobaan/tensorflow_cuda_osx.md
How to enable cuda support for tensor flow on Mac OS X (Updated on April:2016 Tensorflow 0.8)

These instructions will explain how to install tensorflow on mac with cuda enabled GPU suport. I assume you know what tensorflow is and why you would want to have a deep learning framework running on your computer.

Prerequisites

Make sure to update your homebrew formulas

brew update
@risent
risent / latency.markdown
Created November 16, 2016 03:07 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@risent
risent / query explain
Created May 21, 2016 03:30
limit parameter effect PostgreSQL query plan
bazaar4_13=# explain SELECT "store_snpool"."id", "store_snpool"."event_id", "store_snpool"."code" FROM "store_snpool" WHERE "store_snpool"."event_id" = 9967 ORDER
BY "store_snpool"."id" ASC LIMIT 1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------
Limit (cost=0.43..61.15 rows=1 width=12)
-> Index Scan using store_snpool_pkey on store_snpool (cost=0.43..118529.70 rows=1952 width=12)
Filter: (event_id = 9967)
(3 rows)

Uber从 PostgreSQL 迁移到 MySQL

  1. PostgreSQL从9.2升级到9.5/9.6 的难度跟不比 从 PostgreSQL切换到MySQL容易多少
  2. PostgreSQL的replication比起MySQL的复杂度还是高很多,同时由于直接基于磁盘位置的信息replication比起MySQL的基于逻辑的replication 更新操作产生大量的数据需要同步,对于同机房使用GB级别带宽相连的机器不会成为什么大问题。但是对于像Uber这样规模大后需要异地多数据中心之间的同步就几乎无法正常工作了。
  3. 关于两者之间的索引,PostgreSQL直接索引的是磁盘位置信息,而MySQL只有主键索引中有磁盘位置信息,其他的索引都是指向主键,相当于是主键这里做了一层抽象。单纯在这个地方上看MySQL通过抽象层换取了数据的隔离,减少了不同层面之间的耦合,算是一个很不错的设计。
  4. 在内存管理上PostgreSQL完全是交给操作系统去处理,所以对于创建一个完全存储在内存中的表这样的需求是没法实现的。二MySQL在存储层面做了抽象,可以采用不同的存储引擎,内存是其支持的存储引擎之一。
@risent
risent / gist:616a812f3a7c582d903526a47bf76dfc
Created July 18, 2016 05:42 — forked from knu/gist:111055
How to mass-rename tags and push them with Git
# Rename tags named foo-bar-#.#.# to v#.#.# and push the tag changes
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done
title description date categories slug
QQ协议分析
QQ协议分析
2014-04-16
protocol
qq-protocol

一. 文字聊天协议族(TCPF, Text Chatting Protocol Family)

@risent
risent / js2coffee.sh
Created June 13, 2016 11:07
Convert all .js to .coffee
for f in `ls *.js`; do js2coffee $f > ${f%.js}.coffee;done
@risent
risent / update_field.sql
Created January 2, 2016 08:24
update hstore field with function
update store_product set attributes=attributes || hstore('详细参数', replace(attributes->'详细参数', '\', '')) where id=272609;