Skip to content

Instantly share code, notes, and snippets.

View andresamayadiaz's full-sized avatar

Andrés Amaya Díaz andresamayadiaz

View GitHub Profile
@andresamayadiaz
andresamayadiaz / createPDFView
Created September 28, 2011 18:26
Titanium Appcelerator remote PDF with ProgressBar
/*
If you want to open a remote PDF (by remote i mean you have an PDF URL) and want to show a progressbar downloading the file, and at the end show the PDF in a webview
*/
// INIT Create PDF View
mw.ui.CreatePDFView = function(_args){
var win = Ti.UI.createWindow({
title: _args.title
@andresamayadiaz
andresamayadiaz / app_controller.php
Created September 28, 2011 22:45
Simple XLS Report in CakePHP 1.3.X
<?php
/*
This file should be in app/app_controller.php
Add the next function to app_controller.php
Thanks to Marco Tulio Santos for this simple XLS Report
*/
function export_xls($data=null, $titulo, $filename='Reporte') {
$this->set('rows',$data);
$this->set('titulo',$titulo);
@andresamayadiaz
andresamayadiaz / gist:1287342
Created October 14, 2011 14:57 — forked from ffub/gist:1084424
Balsamiq HTML export
#!/usr/bin/php
<?php
error_reporting(E_ALL);
if (count($argv) <= 1) {
print("usage createMockup src_dir dst_dir images_dir\n");
print("\tsrc_dir : dir where all bmml file are\n");
print("\tdst_dir : dir where write all html files\n");
print("\timages_dir : dir where all export mockup png are (will be copied to the \$dst_dir/images directory)\n");
exit(1);
}
@andresamayadiaz
andresamayadiaz / playframework
Created January 9, 2012 19:03 — forked from domdorn/playframework
Upstart Script for the PlayFramework 1.x
# Upstart script for a play application that binds to an unprivileged user.
# put this into a file like /etc/init/playframework
# you can then start/stop it using either initctl or start/stop/restart
# e.g.
# start playframework
# http://dominikdorn.com
description "Description of your app"
author "Dominik Dorn <dominik@studyguru.eu>"
version "1.0"
@andresamayadiaz
andresamayadiaz / Users
Created January 28, 2012 03:41
Play Password Change
public static void update(User entity, String repassword, boolean chgPassword) {
Gson gson = new Gson();
Logger.info("ENTITY 1: "+gson.toJson(entity));
// Validate Password Change
if(chgPassword){
if(!entity.password.equals(repassword)){
@andresamayadiaz
andresamayadiaz / gist:2149578
Created March 21, 2012 17:05
init.d script to launch Play framework under CentOS/RedHat
#!/bin/bash
# chkconfig: 345 20 80
# description: Play start/shutdown script
# processname: play
#
# Instalation:
# copy file to /etc/init.d
# chmod +x /etc/init.d/play
# chkconfig --add /etc/init.d/play
# chkconfig play on
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bfa2="http://www.buzonfiscal.com/ns/addenda/bf/2" xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital" LugarExpedicion="SAN PEDRO GARZA GARCIA Nuevo León" metodoDePago="No identificado" tipoDeComprobante="ingreso" total="1357.20" Moneda="MXN" TipoCambio="1" descuento="0.00" subTotal="1170.00" certificado="MIIEoTCCA4mgAwIBAgIUMDAwMDEwMDAwMDAyMDA0MjgzNDMwDQYJKoZIhvcNAQEFBQAwggGVMTgwNgYDVQQDDC9BLkMuIGRlbCBTZXJ2aWNpbyBkZSBBZG1pbmlzdHJhY2nDs24gVHJpYnV0YXJpYTEvMC0GA1UECgwmU2VydmljaW8gZGUgQWRtaW5pc3RyYWNpw7NuIFRyaWJ1dGFyaWExODA2BgNVBAsML0FkbWluaXN0cmFjacOzbiBkZSBTZWd1cmlkYWQgZGUgbGEgSW5mb3JtYWNpw7NuMSEwHwYJKoZIhvcNAQkBFhJhc2lzbmV0QHNhdC5nb2IubXgxJjAkBgNVBAkMHUF2LiBIaWRhbGdvIDc3LCBDb2wuIEd1ZXJyZXJvMQ4wDAYDVQQRDAUwNjMwMDELMAkGA1UEBhMCTVgxGTAXBgNVBAgMEERpc3RyaXRvIEZlZGVyYWwxFDASBgNVBAcMC0N1YXVodMOpbW9jMRUwEwYDVQQtEwxTQVQ5NzA3MDFOTjMxPjA8BgkqhkiG9w0BCQIML1Jlc3Bvb
@andresamayadiaz
andresamayadiaz / gist:4617778
Created January 24, 2013 04:57
Test Validation
def validate
# open("http://www.sat.gob.mx/cfd/3/cfdv32.xsd")
doc = Nokogiri::XML( File.read("/Users/andresamayadiaz/Documents/rails/receptorcfd/public/comp32.xml"), nil, "UTF-8", Nokogiri::XML::ParseOptions::RECOVER )
#puts "KEYS: " + doc.root.keys.to_s
#puts "Schema: " + doc.root["xsi:schemaLocation"]
schemata_by_ns = Hash[ doc.root["xsi:schemaLocation"].scan(/(\S+)\s+(\S+)/) ]
schemata_by_ns.each do |ns,xsd_uri|
// Tacit, Wrist mounted tactile feedback for the blind.
// By Steve Hoefer at Grathio Labs (http://grathio.com)
// Version 12.02.04
//
// Copyright (c) 2012 Steve Hoefer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
<?php
error_reporting(0);
@ini_set('display_errors', 0);
@ini_set('max_execution_time', 300);
@set_time_limit(0);
class CacheAPC {
var $iTtl = 600;
var $bEnabled = false;