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 / file_exists.lua
Created February 14, 2012 05:29
Test if a file exists using Lua posix
-- Test if a file exists using Lua posix https://github.com/rrthomas/luaposix.
local posix = require('posix')
-- Test if a file exists.
-- @param fname string
-- filename
-- @return boolean
-- true if file exists, false otherwise
--
@perusio
perusio / gist:5813867
Created June 19, 2013 12:20
FastCGI parameters for Drupal 8. This is the fastcgi_drupal.conf file.
#-*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
### fastcgi configuration for Drupal8.
## 1. Parameters.
fastcgi_param QUERY_STRING q=$uri&$args;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
@perusio
perusio / file_exists.lua
Created February 14, 2012 05:36
Check if a file exists using nixio.
-- Playing with the nixio.fs library.
local nixiofs = require('nixio.fs')
-- Test if a file exists.
-- @param fname string
-- filename
-- @return boolean
-- true if file exists, false otherwise
--
@perusio
perusio / gist:4404063
Last active July 29, 2017 02:08 — forked from jpluscplusm/gist:4366287
A pirate bay proxy configuration for Nginx
server {
listen 80; # IPv4
listen [::]:80 ipv6only=on; # IPv6
server_name ~^(?<thishost>[^.]+\.)?subdomain\.example\.com$;
access_log off;
location / {
## Resolve the upstream address using this DNS server or any other.
## Choose the one that suits you.
@perusio
perusio / gist:1497464
Created December 19, 2011 14:32
How to have an "inline" robots.txt for development/private setups
## Here's the way to have Nginx return a robots.txt file that disallows all crawling by bots.
## This is useful for development and private sites.
location = /robots.txt {
return 200 "User-agent: *\nDisallow: /\n";
}
@perusio
perusio / cdlatex-pabbrev.el
Created March 27, 2017 11:05
Making pabbrev-mode completions work when cdlatex-mode is active
;; When we are in cdlatex mode then
;; rebind the TAB key so that pabbrev
;; -mode completions still work.
(when (and (boundp 'cdlatex-mode)
(boundp 'pabbrev-mode)
pabbrev-mode
cdlatex-mode)
(local-set-key '[f12] 'pabbrev-expand-maybe))
@perusio
perusio / sqlite3.lua
Created February 17, 2012 17:35
Lua SQlite handling via LuaSQL
-- Using LuaSQL for sqlite3 DB handling.
require('luasql.sqlite3')
local env = assert(luasql.sqlite3()) -- create the context
local conn = assert(env:connect("test.sqlite")) -- connect to the DB
-- Do some queries.
assert(conn:execute("CREATE TABLE IF NOT EXISTS tbl1(one varchar(10), two smallint)"))
assert(conn:execute("INSERT INTO tbl1 VALUES('hello!', 10)"))
@perusio
perusio / gist:5c1a7f765adbca15e365d04ec4a1d1f8
Created June 9, 2016 18:16
NodeMCU firmware 08.06.2016
Your NodeMCU custom build finished successfully. You may now download the firmware:
- float: http://nodemcu-build.com/builds/nodemcu-dev-10-modules-2016-06-09-18-06-12-float.bin
- integer: http://nodemcu-build.com/builds/nodemcu-dev-10-modules-2016-06-09-18-06-12-integer.bin
This was built against the dev branch and includes the following modules: cjson, dht, file, gpio, mqtt, net, node, tmr, uart, wifi.
The files are guaranteed to be available for download for 24h.
@perusio
perusio / index.js
Created May 15, 2016 02:08
Better code for the Tessel board
// Import the interface to Tessel hardware
var tessel = require('tessel');
//Install mqtt library using: npm install mqtt
var mqtt = require('mqtt');
var client = mqtt.connect({
servers:[{'host':'mqtt.relayr.io'}],
// Add your credentials here.
username: "<my device ID>", // add your own
@perusio
perusio / index.js
Created May 14, 2016 18:15
Example of using the Tessel Board with the relayr cloud
/*
* Property: isOn
* Returns: boolean (true or false) if led is on
*
* Checks the led to see if it is on or not.
*/
if (led.isOn)
{
console.log('The green LED is currently on.');
}