Skip to content

Instantly share code, notes, and snippets.

View eduardoromero's full-sized avatar
λ + µ = 💯

Eduardo Romero eduardoromero

λ + µ = 💯
  • Standard Metrics
  • Washington, USA
  • X @foxteck
View GitHub Profile
@eduardoromero
eduardoromero / Foundation.cake-paginator.ctp
Created January 24, 2013 22:17
Foundation flavored Pagination for CakePHP
<?php $current = $this->Paginator->counter(array('format' => '%page% ')); $Next = $current + 1; $Prev = $current - 1; ?>
<?php $numbers = $this->Paginator->numbers(array('separator' => '', 'tag'=>'li'));?>
<?php if($numbers): ?>
<div class="row">
<ul class="pagination">
<!-- prev -->
<?php if($this->Paginator->hasPrev()) : ?>
<li>
<?php echo $this->Paginator->link('&laquo;', array("page" => $Prev), array('escape' => false)); ?>
</li>
@eduardoromero
eduardoromero / Foundation.cake-flash-alert.ctp
Created January 25, 2013 03:52
Foundation formated divs for Cake's Flash message.
<div class="alert-box alert">
<?php echo $message ?>
<a href="" class="close">&times;</a>
</div>
@eduardoromero
eduardoromero / index.ctp
Created January 25, 2013 03:58
Foundation table layout / format
<div class="categorias index">
<h2><?php __('Categorias');?></h2>
<table class="twelve">
<thead>
<tr>
<th><?php echo $this->Paginator->sort('#','id');?></th>
<th><?php echo $this->Paginator->sort('categoria');?></th>
<th><?php echo $this->Paginator->sort('activo');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
@eduardoromero
eduardoromero / add.ctp
Created January 25, 2013 04:00
Foundation Form Sample
<?php
$formas_pago = array(
0 => 'No identificado',
1 => 'Transferencia',
2 => 'Cheque',
3 => 'Efectivo',
4 => 'Tarjeta',
);
?>
<script type="text/javascript">
@eduardoromero
eduardoromero / gist:4631636
Last active December 11, 2015 16:59
Foundation -> Cake Input dissected.
<?php echo $this->Form->create('Cliente', array('id' => 'empresa-add', 'class' => 'custom', 'inputDefaults' => array('div' => false, 'label' => false, 'class' => '', 'error' => array('wrap' => 'small', 'class' => '')))); ?>
<div class="row">
<?php $input_error = $this->Form->isFieldError('telefono') ? 'error': ''; ?>
<div class="six columns <?php echo $input_error ?>">
<?php echo $this->Form->input('telefono', array('type' => 'text', 'placeholder' => 'Teléfono', 'class' => '')); ?>
</div>
<?php $input_error = $this->Form->isFieldError('contacto') ? 'error': ''; ?>
<div class="six columns <?php echo $input_error ?>">
@eduardoromero
eduardoromero / separar_nombres_apellidos.php
Last active December 11, 2023 05:30
Tratando de separar nombres y apellidos de un campo. Se separa el nombre completo por palabras, se procesa cada palabra, si es una palabra que forma parte de un nombre o apellido compuesto se guarda para anexarla hasta el siguiente ciclo. Al final se tiene que tomar una decisión sobre que hacer para separar los nombres si son más de dos. Si son …
<?php
/* separar el nombre completo en espacios */
$tokens = explode(' ', trim($full_name));
/* arreglo donde se guardan las "palabras" del nombre */
$names = array();
/* palabras de apellidos (y nombres) compuetos */
$special_tokens = array('da', 'de', 'del', 'la', 'las', 'los', 'mac', 'mc', 'van', 'von', 'y', 'i', 'san', 'santa');
$prev = "";
DROP TABLE IF EXISTS `applications`;
CREATE TABLE `applications` (
`id` binary(36) NOT NULL,
`name` varchar(128) DEFAULT NULL,
`basename` varchar(32) DEFAULT NULL COMMENT 'URL BASENAME',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `applications` (`id`, `name`, `basename`) VALUES
(UNHEX('35343764663937662D653431632D343030302D613662322D343866313530333039333633'), 'ASDF', 'asdf.com')
@eduardoromero
eduardoromero / gist:bdc2552c2371cf06f40b
Last active August 29, 2015 14:22
Create DB from .SQL "import" via PHP
<?php
public function create_dbs() {
$db_skel = TMP .DS. 'create_dbs.sql';
$sql = file_get_contents($db_skel);
$config = $this->getDataSource()->config;
$sql = preg_replace('#/\*.*?\*/#s', '', $sql);
$sql = preg_replace('/^-- .*[\r\n]*/m', '', $sql);
@eduardoromero
eduardoromero / gist:da56697d9f0d013657eb
Created July 2, 2015 23:38
Uploadcare Multiplefiles
var widget = uploadcare.Widget('[role=uploadcare-uploader]');
widget.onUploadComplete(function (response) {
if(response) {
uploadcare.loadFileGroup(response.uuid)
.done(function(fileGroup) {
// Group creation completed successfully.
var files = fileGroup.files();
$.each(files, function(i, file) {
// Wait for file uploading.
@eduardoromero
eduardoromero / controllers.js
Last active August 29, 2015 14:26
Post to a Cake Controller with $this->data ala Cake.
$scope.enviar = function() {
if($('#contactar form').form('is valid')) {
$('#contactar form').addClass('loading');
var url = app_backend + '/contactar/post/' + id + '/post.json';
var data = {};
angular.forEach($scope.Contacto, function(field, value) {
console.log(field, value);
if(angular.isUndefined(value)) {