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 / hook-views-api-skel.el
Created January 1, 2011 18:02
A Emacs Lisp skeleton for inserting a hook_views_api
(define-skeleton hook-views-api-skel
"Inserts a hook_views_api template in the current buffer."
nil
> "/**" \n
> -2 "* Implementation of hook_views_api().\n"
> "*/" \n
> "function " (setq v1 (skeleton-read "Module name: ")) "_views_api() {" \n
> "return array(" \n
> "'api' => " (setq v2 (skeleton-read "API version: ")) | "2" "," \n
> "'path' => drupal_get_path('module', '" v1 "') . " (setq v2 (skeleton-read "Path: ")) | "'/includes/views'" "," \n
@perusio
perusio / gist:1034475
Created June 19, 2011 16:57
How to prevent accidental iconification in Emacs
;;; This is taken from planet Emacsen: http://tsengf.blogspot.com/2011/06/prevent-accidental-iconify-of-emacs.html.
;;; I've added a check to see if we're on a graphic environment.
;;; Prevent acidental iconify/suspend.
(when (window-system)
(defun smart-iconify-or-deiconify-frame ()
"Present a confirmation before suspending/iconifying."
(interactive)
(if (yes-or-no-p (format "Are you sure you want to iconify/deiconify Emacs? "))
(iconify-frame)))
@perusio
perusio / local-kernel
Created June 20, 2011 17:18
Logcheck ignore rules for synaptics touchpad synchronization issues
kernel: \[[[:digit:]]+\.[[:digit:]]+\] psmouse\.c: TouchPad at isa[[:digit:]]+/serio[[:digit:]]/input[[:digit:]] lost sync.*
kernel: \[[[:digit:]]+\.[[:digit:]]+\] psmouse\.c: issuing reconnect request
kernel: \[[[:digit:]]+\.[[:digit:]]+\] psmouse\.c: TouchPad at isa[[:digit:]]+/serio[[:digit:]]/input[[:digit:]] - driver resynched
@perusio
perusio / gist:1043907
Created June 23, 2011 23:40
How to whitelist file extensions in Nginx
## This should be the first location in yout config.
location ~* \.(?:gif|html|jpe?g|png|ico|js|css|flv|swf|pdf|xml)$ {
(...)
# serve static files
}
# Put all other locations below
location / {
(...) # more stuff
}
@perusio
perusio / gist:1071894
Created July 8, 2011 14:02
How to have your files always tidy: no trailing spaces, no tabs and properly indented on emacs
;;; Clean up the current buffer: indent it, remove tabs and delete the
;;; trailing whitespace.
(defun tidy-up-buffer ()
" Do a cleanup of the current buffer: tabs, spaces and indent
it."
(interactive)
(indent-buffer)
(delete-trailing-whitespace)
(untabify-buffer))
@perusio
perusio / gist:1087950
Created July 17, 2011 19:13
Adding ronn to the emacs auto-mode-alist for enabling markdown-mode as the major-mode
;;; This is to enable ronn files https://github.com/rtomayko/ronn to be treated as markdown files.
(add-to-list 'auto-mode-alist '("\\.ronn$" . markdown-mode))
@perusio
perusio / gist:1154002
Created August 18, 2011 12:54
My ~/.config/lxterminal/lxterminal.conf with solarized colors
[general]
fontname=Terminus 9
selchars=-A-Za-z0-9,./?%&#:_
scrollback=0
bgcolor=#00002b2b3636
bgalpha=65535
fgcolor=#65657b7b8383
disallowbold=false
cursorblinks=false
cursorunderline=false
@perusio
perusio / apache_killer.pl
Created August 20, 2011 16:24
Apache Killer by KingCope exploits mod_deflate vulnerability
#Apache httpd Remote Denial of Service (memory exhaustion)
#By Kingcope
#Year 2011
#
# Will result in swapping memory to filesystem on the remote side
# plus killing of processes when running out of swap space.
# Remote System becomes unstable.
#
use IO::Socket;
@perusio
perusio / gist:1259095
Created October 3, 2011 13:23
SSL configuration for fixing BEAST SSL vulnerability
## BEAST http://vnhacker.blogspot.com/2011/09/beast.html SSL vuln server side workaround.
## This will break IE6 and below SSL handling. Works in all other browsers. Grabbed from:
## http://mailman.nginx.org/pipermail/nginx-devel/2011-October/001311.html.
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
@perusio
perusio / gist:1290446
Created October 16, 2011 02:52
Example microcache configuration
## Declare cache zone.
fastcgi_cache_path /opt/local/var/cache/nginx levels=1:2 keys_zone=microcache:5m max_size=1G;
map $http_cookie $no_cache {
default 0;
~_mcnc 1;
}
server {