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 / gist:6966370
Created October 13, 2013 19:24
ELisp snippet for syntax checking using the Lua compiler
;;; Lua mode helpers.
;;; Lua syntax checker using the Lua compiler with the
;;; -c option: luac -p <file>. Buffer has to be saved.
(defun lua-check-syntax ()
"Check for Syntax errors using the Lua compiler."
(interactive)
(let ((msg nil))
(if (not (buffer-modified-p))
(setq msg
@perusio
perusio / calendar.lisp
Last active December 4, 2020 12:15
Implementation in Common Lisp of the algorithms for calendrical calculations from the book ¨Calendrical Calculations" by Dershowitz and Rheingold, 3rd edition, Cambridge University Press, 2007.
;; The following Lisp code is from ``Calendrical
;; Calculations'' by Nachum Dershowitz and Edward
;; M. Reingold, Software---Practice & Experience, vol. 20,
;; no. 9 (September, 1990), pp. 899--928 and from
;; ``Calendrical Calculations, II: Three Historical
;; Calendars'' by Edward M. Reingold, Nachum Dershowitz,
;; and Stewart M. Clamen, Software---Practice & Experience,
;; vol. 23, no. 4 (April, 1993), pp. 383--404.
;; This code is in the public domain, but any use of it
@perusio
perusio / cal.lua
Last active August 16, 2020 19:15
Implementation of a Calendrical calculation algorithm
-- -*- mode: lua -*-
--
-- Stolen from http://www.cs.tufts.edu/~nr/drop/lua/cal.lua
--
-- The following Lua code is adapted from ``Calendrical Calculations'' by Nachum
-- Dershowitz and Edward M. Reingold, Software---Practice & Experience,
-- vol. 20, no. 9 (September, 1990), pp. 899--928 and from
-- ``Calendrical Calculations, II: Three Historical Calendars'' by Edward M.
-- Reingold, Nachum Dershowitz, and Stewart M. Clamen, Software---Practice
-- \& Experience, vol. 23, no. 4 (April, 1993), pp. 383--404.
@perusio
perusio / clips-mode.el
Last active January 15, 2020 06:59
Emacs CLIPS mode
;;; clips-mode.el --- Clips editing mode.
;;;************************************************************************
;;; Basado en jess-mode.el de:
;; Copyright (C) 1999 by David E. Young.
;; Author: David E. Young <david.young@fnc.fujitsu.com>
;; Keywords: languages, clips
@perusio
perusio / gist:5950936
Created July 8, 2013 17:52
Turbo Ticket 48 Rule for calculating VAT that is fired after the coupon redemption
{ "commerce_tax_type_vat" : {
"LABEL" : "Calculate taxes: VAT",
"PLUGIN" : "reaction rule",
"WEIGHT" : "9",
"TAGS" : [ "Commerce Tax" ],
"REQUIRES" : [ "commerce_tax", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"DO" : [
{ "commerce_tax_calculate_by_type" : {
"commerce_line_item" : [ "commerce-line-item" ],
# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
### Nginx configuration for Drupal. This configuration makes use of
### drush (http:///drupal.org/project/drush) for site maintenance
### and like tasks:
###
### 1. Run the cronjobs.
### 2. Run the DB and code updates: drush up or drush upc followed by
### drush updb to run any DB updates required by the code upgrades
### that were performed.
### 3. Disabling of xmlrpc.xml, install.php (needed only for
@perusio
perusio / gist:5868568
Created June 26, 2013 15:47
Lua C implementation of an integer type taken from http://stackoverflow.com/questions/4484437/lua-integer-type
#include <math.h>
#include "lua.h"
#include "lauxlib.h"
/* get value of Integer userdata or Lua number at index, or die */
static int checkint (lua_State *L, int index) {
if (lua_isuserdata(L, index) && luaL_checkudata(L, index, "integer")) {
return *(int*)lua_touserdata(L, index);
} else if (lua_isnumber(L, index)) {
return lua_tonumber(L, index);
@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 / gist:5805062
Created June 18, 2013 12:49
hook_form alter to hide the giftwrap pane in the checkout review
<?php
/**
* @file
* Changes the visibility of the giftwrap pane.
*/
/**
* Implements hook_help().
*/
@perusio
perusio / gist:5798900
Created June 17, 2013 18:09
Shipping rule example for non-shippable items for flat rate shipping
{ "rules_test_shipping" : {
"LABEL" : "Test shipping",
"PLUGIN" : "reaction rule",
"TAGS" : [ "TT 43" ],
"REQUIRES" : [ "commerce_shipping_custom", "commerce_shipping" ],
"ON" : [ "commerce_shipping_calculate_rate" ],
"IF" : [
{ "NOT commerce_order_contains_non_shippable_products" : { "commerce_order" : [ "commerce-line-item:order" ] } }
],
"DO" : [