Skip to content

Instantly share code, notes, and snippets.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Request = {
Dispatch: function(params, callback) {
setTimeout(function() {
callback()
}, params.waitSeconds || 0);
}
};
function sendRequest(waitSeconds) {
var timestamp = (new Date()).getTime();
@sagnitude
sagnitude / mysql.js
Last active November 21, 2015 16:31
a simple mysql transaction wrapper for node.js using node-mysql.
var mysql = require('mysql');
var mysqlConfig = {
connectionLimit : 100,
host : 'hostname',
user : 'username',
password : 'password',
database : 'database',
acquireTimeout : 30000
};
@sagnitude
sagnitude / extract_chars.cpp
Last active January 31, 2016 08:16
find pattern 'answer="$1"', print all $1 out
#include <stdlib.h>
int main() {
system("cat text.txt | grep -Po 'answer=\"\\K[^\"]*'");
return 0;
}
@sagnitude
sagnitude / build_nginx.sh
Created February 20, 2016 10:18 — forked from MattWilcox/build_nginx.sh
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/usr/bin/env bash
# names of latest versions of each package
export VERSION_PCRE=pcre-8.38
export VERSION_OPENSSL=openssl-1.0.2d
export VERSION_NGINX=nginx-1.9.7
# URLs to the source directories
export SOURCE_OPENSSL=https://www.openssl.org/source/
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
@sagnitude
sagnitude / test.conf
Created May 11, 2016 14:38
nginx_lua_test
location /test {
content_by_lua_block {
local arg = ngx.var.arg_upload
local method = ngx.req.get_method()
if method == "POST" then
if arg then
ngx.exec("@flash")
else
ngx.exec("@post")
end
@sagnitude
sagnitude / Base.java
Created May 17, 2016 12:22
test reflection
package com.test;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
class Base {
void testReflection() {
try {
Method method = this.getClass().getDeclaredMethod("subMethod", Integer.TYPE);
class K {
private int c;
public int getC() {
return c;
}
public void setC(int c) {
this.c = c;
}
@sagnitude
sagnitude / test_gpu_js.js
Created July 18, 2017 11:03
Test gpu.js
var b64Str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var b64Table = {};
var b64Chars = [];
var b64LookupTable = [];
for (var i = 0; i < b64Str.length; i++) {
var ch = b64Str.charCodeAt(i);
b64Table[ch] = i;
b64Chars[i] = ch;
b64LookupTable[ch] = i;
function ieee754_read(buffer, offset, isLE, mLen, nBytes) {
var e, m;
var eLen = (nBytes * 8) - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = -7;
var i = isLE ? (nBytes - 1) : 0;
var d = isLE ? -1 : 1;
var s = buffer[offset + i];