Skip to content

Instantly share code, notes, and snippets.

@javiertoledo
javiertoledo / config.ru
Created February 5, 2012 13:53
Using Rack iframe middleware to fix an issue on losing sessions inside iframes
require ::File.expand_path('../config/environment', __FILE__)
# Use the iframe Rack middleware
require 'rack/iframe'
use Rack::Iframe
run MyApp::Application
@javiertoledo
javiertoledo / magic_swap.c
Created October 24, 2010 00:31
Swap variable values without temp variables
/*Initializations*/
int a,b;
a=1;
b=2;
/*The swap code*/
a^=b^=a^=b;
/*That's all! Your variables swapped magically*/
@javiertoledo
javiertoledo / swap.c
Created October 24, 2010 00:26
Classic variable swap in C
/*Initializations*/
int a,b,temp;
a=1;
b=2;
/*The classic swap code*/
temp=a;
a=b;
b=temp;
/*Values have been happily swapped! (a==2 && b==1)*/
@javiertoledo
javiertoledo / glassfish
Created October 24, 2010 00:19
Init script for glassfish
#!/bin/sh
GLASSFISHPATH=/usr/share/glassfishv2/bin
GLASSFISHDOMAINHOME=/var/lib/glassfishv2/domains/domain1
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain --user admin --passwordfile ${GLASSFISHDOMAINHOME}/config/passwordfile domain1
;;
@javiertoledo
javiertoledo / enableMierderMode.js
Created May 1, 2010 19:10
The ultimate jQuery plugin
/**
Mierder-mode for jQuery
-------------------------
Cuando quieres evitar que un formulario sea enviado
automáticamente por el navegador, podrías pensar que
es suficiente con asignar un "return false;" al evento
onsubmit de tu formulario, y esto era así hasta que
los ingenieros de Microsoft pensaron que sería divertido
# Connection to SQLServer with activerecord-sqlserver-adapter (2000-2005) locally on Windows
development:
adapter: sqlserver
dsn: Database_DSN
mode: odbc
username: user
password: password
encoding: utf8
@javiertoledo
javiertoledo / Ext.ux.AutoColumnPanel.js
Created March 25, 2010 09:51
ExtJs Auto columns Panel
/* An Ext Panel which distribute items in equally-sized columns that fills all available width */
Ext.ns("Ext.ux");
Ext.ux.AutoColumnPanel = Ext.extend(Ext.Panel, {
layout: 'column',
initComponent: function() {
var columnWidth = 1/this.items.length;
Ext.each(this.items,function(item){
Ext.apply(item,{
columnWidth: columnWidth
@javiertoledo
javiertoledo / PlainWriter.js
Created March 6, 2010 17:59
DataWriter extension for writing a single Ext.data.Record object in plain format in preparation for executing a remote RESTful CRUD action.
/**
* @class Ext.ux.data.PlainWriter
* @extends Ext.data.DataWriter
* DataWriter extension for writing a single {@link Ext.data.Record} object in plain format in preparation for executing a remote RESTful CRUD action.
* @author Javier Toledo <javier at theagilemonkeys.com>
* @version 1.0
* @date March 6th, 2010
* @license http://www.gnu.org/licenses/lgpl-3.0.txt
*/
Ext.ns("Ext.ux.data")