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 / OrgProvider.java
Created May 21, 2013 10:20
OrgProvider.java
private enum UriType {
DEPARTMENT( "#/" + DB_Department.TABLE_NAME , DB_Department.TABLE_NAME, DB_Department.TYPE_ELEM_TYPE),
COLLEGUE("#/" + DB_Collegue.TABLE_NAME, DB_Collegue.TABLE_NAME, DB_Collegue.TYPE_ELEM_TYPE),
COLLEGUE_RELATION("#/" + DB_Collegue_relation.TABLE_NAME, DB_Collegue_relation.TABLE_NAME, DB_Collegue_relation.TYPE_ELEM_TYPE),
DEPARTMENT_RELATION("#/" + DB_Department_relation.TABLE_NAME, DB_Department_relation.TABLE_NAME, DB_Department_relation.TYPE_ELEM_TYPE),
DEPARTMENT_UIN( "#/" + DB_Department.TABLE_NAME + "/UIN/#", DB_Department.TABLE_NAME, DB_Department.TYPE_ELEM_TYPE),
COLLEGUE_CorpUIN("#/" + DB_Collegue.TABLE_NAME + "/UIN/#", DB_Collegue.TABLE_NAME, DB_Collegue.TYPE_ELEM_TYPE),
COLLEGUE_RELATION_UIN("#/" + DB_Collegue_relation.TABLE_NAME + "/UIN/#", DB_Collegue_relation.TABLE_NAME, DB_Collegue_relation.TYPE_ELEM_TYPE),
DEPARTMENT_RELATION_CorpUIN("#/" + DB_Department_relation.TABLE_NAME + "/UIN/#", DB_Department_relation.TABLE_NAME, DB_De
@simpleton
simpleton / RequestMaker.java
Last active December 18, 2015 09:19
build facebook signed request in hmac-sha256 method
//http://en.wikipedia.org/wiki/Base64#URL_applications
//http://stackoverflow.com/questions/11106393/url-safe-base64-in-objective-c
//http://stackoverflow.com/questions/10812140/facebook-signed-request-for-ios-hmac-sha256
public class RequestMaker {
private static final String KEY = "testkey";
private static final int BASE64_FLAG = Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING | Base64.NO_CLOSE;
public RequestMaker() {
}
public String getRequestPayload(String token, String user_id, String expires) {
//java code
public class MainActivity extends Activity {
private WebView webView;
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.webView = (WebView) findViewById(R.id.webview);
#btn_download {
background: url("../images/download-normal.png") no-repeat scroll center top transparent;
display: block;
height: 54px;
width: 190px;
margin-top: 50px;
}
#btn_download:active {
background: url("../images/download-down.png") no-repeat bottom;
public class RSAEncrypt {
private static final String DEFAULT_PUBLIC_KEY=
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChDzcjw/rWgFwnxunbKp7/4e8w" + "\r" +
"/UmXx2jk6qEEn69t6N2R1i/LmcyDT1xr/T2AHGOiXNQ5V8W4iCaaeNawi7aJaRht" + "\r" +
"Vx1uOH/2U378fscEESEG8XDqll0GCfB1/TjKI2aitVSzXOtRs8kYgGU78f7VmDNg" + "\r" +
"XIlk3gdhnzh+uoEQywIDAQAB" + "\r";
private static final String DEFAULT_PRIVATE_KEY=
"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKEPNyPD+taAXCfG" + "\r" +
user nobody;
worker_processes auto;
error_log logs/error.log notice;
worker_rlimit_nofile 65535;
pid /var/run/nginx.pid;
events {
accept_mutex off;
@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 / 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 / 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 / consumer.go
Last active October 19, 2023 05:17
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"