Skip to content

Instantly share code, notes, and snippets.

View lcruz's full-sized avatar

Luis Cruz lcruz

View GitHub Profile
@lcruz
lcruz / rebuild_select_jqTransform.js
Created May 4, 2012 15:07
Rebuild a select wrapped with jqTransform
function fill_select(id, values) {
$select = $(id);
$select[0].options.length = 0;
$ul = $select.parent().find('ul');
$ul.html('');
$.each(values, function(i, v) {
var index = $select[0].options.length;
$select[0].options[index] = new Option(v.text, v.value);
@lcruz
lcruz / gist:2595418
Created May 4, 2012 15:15
Group a list of objects (django model) by a foreign model
def group_by_foreign_model():
"""
Example of the model:
class MyModel(Model):
foreign = models.ForeignKey(MyForeignModel)
"""
result = MyModel.objects.all()
@lcruz
lcruz / example.js
Created September 20, 2012 13:06
Ejemplo de uso de jsPDF y envio de PDF por correo en Titanim
/**
* Generar y enviar el PDF
*/
function generate_and_send() {
var file = generatePDF('comprobante.pdf');
sendPDF(file);
}
/**
* Generar el PDF
@lcruz
lcruz / agendar.js
Created September 20, 2012 13:13
Agregar un evento via Titanium (Solo IOS)
/**
* Ejemplo del modulo Ttiatium-Calenadar disponible en:
*
* https://github.com/stelford/Titanium-Calendar
*/
var btnAgendarCal = Titanium.UI.createButton({
backgroundImage: '/images/btnAgendarCal.png',
left: 10,
width: 144,
@lcruz
lcruz / ejemplo_tabla.js
Created September 20, 2012 14:46
Ejemplo de tabla con bordes redondeados y header con color en Android
function TableView() {
var self = Ti.UI.createView();
var data = [{title:"Row 1"},{title:"Row 2"}];
var table = createTable('Pagadores', self, data);
self.add(table);
return self;
}
@lcruz
lcruz / title.js
Created September 21, 2012 13:38
Agregar una ventana de titulo en android
function addTitleToWin(win, title) {
// Si es la pantalla del home no se agrega titulo
//Ti.API.info("title WIN : " + title);
if (typeof title == 'undefined') {
return;
}
var titleLabel = Ti.UI.createLabel({
text: title,
color: 'white',
@lcruz
lcruz / app.js
Created November 5, 2012 15:03
Generic picker for Android and iOs
var Picker = require("/commons/picker");
var oPicker = new Picker();
//
// create base UI tab and root window
//
var win = Titanium.UI.createWindow({
title:'Ejemplo',
backgroundColor:'#fff'
@lcruz
lcruz / app.js
Last active December 11, 2015 06:08
Ejemplo de scrollview y scrolleableView en Appcelerator SDK 3.0 (sin conflictos)
var win = Ti.UI.createWindow();
// Vistas de ejemplo
var view0 = Ti.UI.createView({ width: Ti.UI.FILL, height: 150, backgroundColor: 'red' });
var view1 = Ti.UI.createView({ width: Ti.UI.FILL, height: 150, backgroundColor: 'brown' });
var view2 = Ti.UI.createView({ width: Ti.UI.FILL, height: 150, backgroundColor: 'silver' });
var view3 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'blue' });
var view4 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'yellow' });
var view5 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'green' });
var view6 = Ti.UI.createView({ width: Ti.UI.FILL, height: 200, backgroundColor: 'magenta' });
@lcruz
lcruz / find.sh
Last active December 11, 2015 20:59
Find a class in all jars (Solaris version)
find . -name "*.jar" -exec sh -c 'unzip -l $1 | /usr/xpg4/bin/grep -q DESKeySpec' _ {} \; -print 2>/dev/null
@lcruz
lcruz / test.java
Created March 22, 2013 17:01
Calling an EJB from single program in Java
private EJBInterface getEJB() {
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://host:port");
Context context;
try {
context = new InitialContext(h);
EJBHome home =
(EJBHome) context.lookup("<jndi_name>");