Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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
};
Request = {
Dispatch: function(params, callback) {
setTimeout(function() {
callback()
}, params.waitSeconds || 0);
}
};
function sendRequest(waitSeconds) {
var timestamp = (new Date()).getTime();
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