Skip to content

Instantly share code, notes, and snippets.

Hello World

Sim Sun simpleton

Hello World
Block or report user

Report or block simpleton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
simpleton / stack_traces.c
Created Feb 2, 2019 — forked from jvranish/stack_traces.c
An example of catching exceptions and printing stack traces in C on Windows, Linux and OS X
View stack_traces.c
/* compile with:
on linux: gcc -g stack_traces.c
on OS X: gcc -g -fno-pie stack_traces.c
on windows: gcc -g stack_traces.c -limagehlp
#include <signal.h>
#include <stdio.h>
#include <assert.h>
simpleton / consumer.go
Last active Aug 29, 2019
Golang auto-reconnect rabbitmq consumer
View consumer.go
package base
import (
simpleton / gist:c2c1c15bd0bba78bff49
Created Oct 22, 2015 — forked from amichaelgrant/gist:90d99d7d5d48bf8fd209
failed (104: Connection reset by peer) while reading response header from upstream, client:
View gist:c2c1c15bd0bba78bff49
failed (104: Connection reset by peer) while reading response header from upstream, client:
If you are getting the above error in nginx logs running in from of upstream servers you may consider doing this as it worked for me:
check the ulimit on the machines and ensure it is high enough to handle the load coming in. 'ulimit' on linux, I am told determines the maximum number of open files the kernel can handle.
The way I did that?
modifying limits: for open files:
add or change this line in /etc/systcl.conf
fs.file-max = <limit-number>
View Android插件相关
1. 更改proguard函数生成算法,用更长的签名来做作用域,给每个命名空间留出足够的空间来填充增加的函数;
2. 抽象出sdk类函数,保证这一部分函数的对下一致。不保证插件函数可以keep。

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

View sentry-nginx.conf
user nobody;
worker_processes auto;
error_log logs/error.log notice;
worker_rlimit_nofile 65535;
pid /var/run/;
events {
accept_mutex off;
public class Main {
public static void main(String[] args) {
try {
System.out.println(encrypt("12345678", "abc", "12345678"));
System.out.println(encrypt("12345678", "ABC", "12345678"));
System.out.println(decrypt("12345678", "9YR6ZPdZufM=", "12345678"));
System.out.println(decrypt("12345678", "6rtTnrF34mPkJ5SO3RiaaQ==", "12345678"));
View Just a nice
private List<WeakReference<IFileDownloader.IFileDownloadCallBack> > callbackList
= Collections.synchronizedList(new ArrayList<WeakReference<IFileDownloader.IFileDownloadCallBack>>());
public void addCallback(IFileDownloader.IFileDownloadCallBack cb) {
if (cb != null) {
for (int i=0; i < callbackList.size(); ++i) {
IFileDownloader.IFileDownloadCallBack callback = callbackList.get(i).get();
if (callback == cb) {
from xml.etree import ElementTree as ET
import glob
import sys
import os
class ManifestMerger(object):
def __init__(self, app_manifest, filenames):
assert len(filenames) > 0, 'No filenames!'
ET.register_namespace("android", "")
print app_manifest
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
You can’t perform that action at this time.