Skip to content

Instantly share code, notes, and snippets.

António P. P. Almeida perusio

  • Perusio LLC & UP42
  • Berlin, Germany
Block or report user

Report or block perusio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@perusio
perusio / clock_gettime
Created Nov 4, 2015 — forked from calio/clock_gettime
clock_gettime() via LuaJIT + FFI
View clock_gettime
local ffi = require("ffi")
ffi.cdef[[
typedef long time_t;
typedef int clockid_t;
typedef struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
} nanotime;
@perusio
perusio / gettimeofday.lua
Created Nov 4, 2015 — forked from joshthecoder/gettimeofday.lua
gettimeofday() via LuaJIT + FFI
View gettimeofday.lua
local ffi = require("ffi")
ffi.cdef[[
typedef long time_t;
typedef struct timeval {
time_t tv_sec;
time_t tv_usec;
} timeval;
int gettimeofday(struct timeval* t, void* tzp);
@perusio
perusio / access.lua
Last active Aug 29, 2015 — forked from josegonzalez/access.lua
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
View access.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 Aug 29, 2015 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
View cors-nginx.conf
#
# 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 Aug 29, 2015 — forked from leite/gist:9236fe3033d5779cdb05
Compatibility with Lua 5.2
View gist:e745cc08b554a14384f3
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 Aug 29, 2015 — forked from peterhel/nginx.conf
prerender.io service nginx configuration
View nginx.conf
# -*- 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"';
View 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;
View libmagic_example.c
#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);
View etc-init.d-ktserver
#! /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
View gitio
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
url = ARGV[0]
code = ARGV[1]
You can’t perform that action at this time.