Skip to content

Instantly share code, notes, and snippets.

View simpleton's full-sized avatar
👷‍♂️
Hello World

Sim Sun simpleton

👷‍♂️
Hello World
View GitHub Profile
@simpleton
simpleton / android-logcat.json
Created November 13, 2019 01:58
android-logcat.json
{
"android_logcat_time": {
"title": "Android logcat with time",
"description": "logcat generated by command 'adb logcat -v time'",
"url": "https://developer.android.com/studio/command-line/logcat.html",
"timestamp-format": [
"%m-%d %H:%M:%S.%L"
],
"regex": {
"std-logcat-time": {
@simpleton
simpleton / android-logcat.json
Created November 1, 2019 03:54
android-logcat.json for .lnav/formats/installed
{
"android_logcat_time": {
"title": "Android logcat with time",
"description": "logcat generated by command 'adb logcat -v time'",
"url": "https://developer.android.com/studio/command-line/logcat.html",
"timestamp-format": [
"%m-%d %H:%M:%S.%L"
],
"regex": {
"std-logcat-time": {
@simpleton
simpleton / stack_traces.c
Created February 2, 2019 00:25 — forked from jvranish/stack_traces.c
An example of catching exceptions and printing stack traces in C on Windows, Linux and OS X
/* 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
simpleton / consumer.go
Last active August 21, 2024 10:05
Golang auto-reconnect rabbitmq consumer
package base
import (
"errors"
"fmt"
"github.com/manucorporat/try"
"github.com/simpleton/beego"
"github.com/streadway/amqp"
"math/rand"
"model/helper"
@simpleton
simpleton / gist:c2c1c15bd0bba78bff49
Created October 22, 2015 14:22 — forked from amichaelgrant/gist:90d99d7d5d48bf8fd209
failed (104: Connection reset by peer) while reading response header from upstream, client:
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>
@simpleton
simpleton / Android插件相关
Last active August 29, 2015 14:20
Android plugin
Android插件化
===================
[TOC]
Proguard
-------------------
proguard是原生支持keepmapping的,可以直接导入一个mapping文件,保证混淆的一致性,但是我当时做犯了一个错误,就是试图保证所有的mapping文件都一致,但是proguard混淆函数的算法是顺序的,后续导致会有不可避免的冲突发生。现在我想到有2种方法可以避免这个发生:
1. 更改proguard函数生成算法,用更长的签名来做作用域,给每个命名空间留出足够的空间来填充增加的函数;
2. 抽象出sdk类函数,保证这一部分函数的对下一致。不保证插件函数可以keep。
@simpleton
simpleton / introrx.md
Last active August 29, 2015 14:19 — forked from staltz/introrx.md

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.

user nobody;
worker_processes auto;
error_log logs/error.log notice;
worker_rlimit_nofile 65535;
pid /var/run/nginx.pid;
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"));
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) {
return;
}