Skip to content

Instantly share code, notes, and snippets.

View cesarmiquel's full-sized avatar

Cesar Miquel cesarmiquel

View GitHub Profile
@cesarmiquel
cesarmiquel / gist:1506893
Created December 21, 2011 17:33
Retrieve HTTP Get parameter from URL
/**
* Parse URL and retrieve a GET parameter
*
* @param variable Name of variable to retrieve from URL
* @returns Value of the variable or null if not present
*
* from: http://stackoverflow.com/questions/827368/use-the-get-paramater-of-the-url-in-javascript
*/
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
@cesarmiquel
cesarmiquel / gist:1506907
Created December 21, 2011 17:36
Return value of selected radio button using Prototype
/**
* Returns the value of the selected radio button in the radio group, null if
* none are selected, and false if the button group doesn't exist
*
* @param {radio Object} or {radio id} el
* OR
* @param {form Object} or {form id} el
* @param {radio group name} radioGroup
*
* From: http://xavisys.com/using-prototype-javascript-to-get-the-value-of-a-radio-group/
@cesarmiquel
cesarmiquel / gist:1506921
Created December 21, 2011 17:40
Cookie managing functions
// helpers to manipulate cookies. see: http://www.quirksmode.org/js/cookies.html
/**
* Create a cookie for site
*
* @param name Name for cookie
* @param value Value for cookie
* @param minutes Number of minutes this cookie will be valid for.
*/
function createCookie(name, value, minutes) {
@cesarmiquel
cesarmiquel / init-drupal.sh
Created September 14, 2012 03:17
My script to init a Drupal project
#!/bin/bash
# ---------------------------------------------------------------------------------------
# Configuration options
# ---------------------------------------------------------------------------------------
DEFAULT_ADMIN_THEME='rubik' # Other common options: seven - adaptivetheme_admin
DEFAULT_THEME='adaptivetheme' # Other common options: omega - zen - bartik
ADMIN_PASSWORD='<strong-password>'
@cesarmiquel
cesarmiquel / planet.py
Created September 20, 2012 06:11
Read Drupal planet RSS feed and show it on screen. Needs python and feedparser ($ sudo aptitude install python-feedparser)
import feedparser
def color(this_color, string):
return "\033[" + this_color + "m" + string + "\033[0m"
print
print color('34', '-' * 70)
print color('1;34', ' ' * 10 + 'D R U P A L / P L A N E T')
print color('34', '-' * 70)
@cesarmiquel
cesarmiquel / colors.py
Created September 21, 2012 02:37
Show console colors
def color(this_color, string):
return "\033[" + this_color + "m" + string + "\033[0m"
for i in range(30, 38):
c = str(i)
print('This is %s' % color(c, 'color ' + c))
c = '1;' + str(i)
print('This is %s' % color(c, 'color ' + c))
@cesarmiquel
cesarmiquel / deploy.sh
Created September 29, 2012 05:16
Compile a maven process and deploy exploded war
#!/bin/bash
# Execute a command and display command with colors in console
exec() {
CMD=$*
S="\033[37mExecuting [\033[32m$CMD\033[37m]"
echo -e $S
eval $CMD
}
@cesarmiquel
cesarmiquel / stylesheet.html
Created November 22, 2012 23:17
HTML Stylesheet
<html>
<head>
<title>Titulo</title>
</head>
<body><p>Titulo</p>
<h1>This is an h1 header</h1>
<h2>This is an h2 header</h2>
<h3>This is an h3 header</h3>
<h4>This is an h4 header</h4>
<h5>This is an h5 header</h5>
#!/bin/bash -x
#
# Script que actualiza el codigo en el ambiente a donde se hace push
#
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
@cesarmiquel
cesarmiquel / drupal_module_snippets.php
Last active December 10, 2015 06:28
This are drupal snippets I constantly use in my modules. Replace xxxxx with module name.
<?php
/**
* Implements hook_menu().
*/
function xxxxx_menu() {
$items['path'] = array(
'title' => '[Title]',
'access callback' => TRUE,
'page callback' => 'xxxxx_render_page',