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
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 / 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)) {
@eduardoromero
eduardoromero / dashboard.js
Created August 6, 2015 20:02
Prevent Default
$(document).on("click", ".eliminar", function (e) {
e.preventDefault();
var parent = $(this).parents().get(0);
$(parent).remove();
});
@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 / 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 / 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 / httpd-vhosts.conf
Created December 22, 2015 22:52
Hosts multpile wildcard vhosts, makes [somename].dev/webroot -> http://somename.dev
<Directory "/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Virtualhost *:80>
VirtualDocumentRoot "/Users/eromero/Workspace"
ServerName home.dev