Skip to content

Instantly share code, notes, and snippets.

View rcmachado's full-sized avatar

Rodrigo Machado rcmachado

View GitHub Profile
@rcmachado
rcmachado / jquery.unserialize.js
Created November 25, 2009 10:19
$.unserialize for jQuery
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array.
*
* Example:
*
* Input: param1=value1&param2=value2
* Return: { param1 : value1, param2: value2 }
*
@rcmachado
rcmachado / Makefile
Last active February 7, 2024 06:04
Add a help target to a Makefile that will allow all targets to be self documenting
.SILENT:
.PHONY: help
# Based on https://gist.github.com/prwhite/8168133#comment-1313022
## This help screen
help:
printf "Available targets\n\n"
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
@rcmachado
rcmachado / html5.vim
Created December 15, 2009 10:35
Vim syntax file for HTML 5
" Vim syntax file
" Language: HTML (version 5)
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
" URL: http://gist.github.com/256840
" Last Change: 2010 Aug 26
" License: Public domain
" (but let me know if you liked it :) )
"
" Note: This file just adds the new tags from HTML 5
" and don't replace default html.vim syntax file
@rcmachado
rcmachado / copy-db.sh
Last active April 3, 2021 01:54
Script to copy all tables from one database to another.
#!/bin/bash
#
# Script to copy all tables from one database to another.
#
# Requires:
# * MySQL 5.6
# * Percona xtrabackup tools (http://www.percona.com/software/percona-xtrabackup)
#
# Known caveats:
# * Will copy structure of all tables from one database to another, but only InnoDB
@rcmachado
rcmachado / cisco-decrypt.c
Created May 27, 2011 18:02
Decoder for password encoding of Cisco VPN client
/* Decoder for password encoding of Cisco VPN client.
Copyright (C) 2005 Maurice Massar
Thanks to HAL-9000@evilscientists.de for decoding and posting the algorithm!
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@rcmachado
rcmachado / main.py
Last active March 1, 2019 17:56 — forked from eduardocardoso/main.py
Generating a JWT token
from __future__ import absolute_import
#
# To run:
#
# $ pip install pyjwt
# $ python main.py
#
import jwt
@rcmachado
rcmachado / remove_hover_rule.js
Created November 4, 2013 14:21
Remove CSS :hover rules for touch devices to avoid iOS double-tap behavior. Copied and adapted from http://retrogamecrunch.com/tmp/hover (just a fix for sheet.cssRules)
// disable :hover on touch devices
// based on https://gist.github.com/4404503
// via https://twitter.com/javan/status/284873379062890496
// + https://twitter.com/pennig/status/285790598642946048
// re http://retrogamecrunch.com/tmp/hover
// NOTE: we should use .no-touch class on CSS
// instead of relying on this JS code
function removeHoverCSSRule() {
if ('createTouch' in document) {
try {

Keybase proof

I hereby claim:

  • I am rcmachado on github.
  • I am rcmachado (https://keybase.io/rcmachado) on keybase.
  • I have a public key whose fingerprint is 778C 615C C641 8517 3318 F0F5 02B6 97FD CCAF B437

To claim this, I am signing this object:

@rcmachado
rcmachado / error_reporting.php
Last active July 8, 2017 03:00
Script to verify PHP error_reporting settings. Adapted from http://us3.php.net/manual/en/errorfunc.constants.php#109430
<?php
$errorLevel = error_reporting();
print "Current error_reporting level: $errorLevel <br>\n";
print "E_ALL value: " . E_ALL . " <br>\n";
for ($i = 0; $i < 15; $i++) {
$errVal = $errLevel & pow(2, $i);
print FriendlyErrorType($errVal) . " ($errVal) <br>\n";
}
@rcmachado
rcmachado / install_phpunit.sh
Created September 20, 2010 13:29
Installs PHPUnit on a very old CentOS 5.3
#!/bin/bash
#
# Installs PHPUnit on a very old CentOS 5.3
#
pear upgrade --force http://pear.php.net/get/PEAR-1.8.1
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit