Skip to content

Instantly share code, notes, and snippets.

View perusio's full-sized avatar

António P. P. Almeida perusio

View GitHub Profile
@perusio
perusio / access.lua
Last active August 29, 2015 14:27 — forked from josegonzalez/access.lua
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@perusio
perusio / cors-nginx.conf
Last active August 29, 2015 14:27 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@perusio
perusio / gist:e745cc08b554a14384f3
Last active August 29, 2015 14:22 — forked from leite/gist:9236fe3033d5779cdb05
Compatibility with Lua 5.2
cd /opt
sudo wget http://www.openssl.org/source/openssl-0.9.8y.tar.gz
sudo tar zxf openssl-0.9.8y.tar.gz
sudo wget http://zlib.net/zlib-1.2.8.tar.gz
sudo tar zxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
sudo ./configure
sudo make -j4 && sudo make install && cd ..
@perusio
perusio / nginx.conf
Last active August 29, 2015 14:14 — forked from peterhel/nginx.conf
prerender.io service nginx configuration
# -*- mode: nginx; mode: flyspell-prog; mode: autopair; ispell-local-dictionary: "american" -*-
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
@perusio
perusio / nginx.conf
Last active August 29, 2015 14:14 — forked from thoop/nginx.conf
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
#include <stdio.h>
#include <magic.h>
int main(void)
{
char *actual_file = "/file/you/want.yay";
const char *magic_full;
magic_t magic_cookie;
/*MAGIC_MIME tells magic to return a mime of the file, but you can specify different things*/
magic_cookie = magic_open(MAGIC_MIME);
#! /bin/sh
#
# description: Kyoto Tycoon is a lightweight database server.
# processname: ktserver
# config: /usr/local/etc/ktserver.conf
# pidfile: /var/run/ktserver.pid
# Source function library.
. /etc/init.d/functions
@perusio
perusio / gist:77779624f9c6114bb189
Created November 18, 2014 09:51
Using Murmurhash2
-- Require the library.
mmh2 = require "murmurhash2"'
-- Returns a hex representation of the hash.
string.format('%x', mmh2('<string>'))
extension=apc.so
; Set the shared memory segment size.
apc.shm_size = 256M
; Optimize the require_once and include_once calls.
;apc.include_once_override = 1
; Change the TTL.
apc.ttl = 7200
@perusio
perusio / strict.lua
Created March 24, 2014 13:30
Verify the usage of global variables previously undeclared from http://www.lua.org/extras/5.2/strict.lua.
-- strict.lua
-- checks uses of undeclared global variables
-- All global variables must be 'declared' through a regular assignment
-- (even assigning nil will do) in a main chunk before being used
-- anywhere or assigned to inside a function.
-- distributed under the Lua license: http://www.lua.org/license.html
local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
local mt = getmetatable(_G)