Skip to content

Instantly share code, notes, and snippets.

View tzkmx's full-sized avatar
🎉
estrenando repositorios privados

Jesus Franco tzkmx

🎉
estrenando repositorios privados
View GitHub Profile
@tzkmx
tzkmx / SetClass.coffee
Last active August 29, 2015 14:19
Jasmine custom class Test
class Set
set = {}
col = []
has: (item) ->
set.hasOwnProperty item
refresh: (item, opt_) ->
col = Object.keys set
@tzkmx
tzkmx / init_namespace.coffee
Last active August 29, 2015 14:19
Init Namespace with Jasmine Tests (+extend)
extend = (inject, template) ->
(template[prop] = inject[prop]) for own prop of inject
null
init_namespace = (nameString, obj, container) ->
container ?= window
names = nameString.split('.')
(container[name] or= {} ;
container = container[name]) while name = names.shift()
extend(obj, container)
@tzkmx
tzkmx / dump_schemas.bat
Created July 6, 2015 15:58
MySQL dump schemas as CSV, a directory per schema
@ECHO OFF
REM DANGER: Erase subdirectories without prompting user previously!
FOR /D /R %%D IN (*) DO (
ECHO erasing %%D
RD /S /Q %%D
)
REM We use the output of SHOW DATABASES to build our list
FOR /F "usebackq tokens=1-2 delims=| " %%D in (`mysql -h %BackupHost% -u %BackupUser% -p%BackupPass% -e "show databases;"`) DO (
REM Nested if's to exclude unwanted entries in list
IF NOT "%%D" == "Database" (
@tzkmx
tzkmx / create_dated_log_file.bat
Created July 6, 2015 16:42
Creates empty log file dated using mysql output
@ECHO OFF
REM mysql DATE_FORMAT tokens: %W (weekday name) %M (month name) %d (month day) %Y (year)
SET timeformatstring='%%W_%%M-%%d-%%Y'
REM FOR /F takes output from `time /t` and tokenizes it in %A %B and %C
FOR /F "usebackq tokens=1-4 delims=: " %%A IN (`time /t`) DO (
REM takes localized output from mysql NOW() string built with tokens in %timeformatsring%
FOR /F "usebackq tokens=1-2 skip=1 delims=| " %%H IN (`mysql -h %dbHost% -u %dbUser% -p%dbPass% -e "SET @@lc_time_names='es_MX'; SELECT UPPER(DATE_FORMAT(NOW(), %timeformatstring%));"`) DO (
ECHO Creating log file with date: %%H and time: %%A%%B%%C
REM CMD equivalent of Unix touch? http://superuser.com/a/764725
TYPE NUL >> %%H_%%A%%B%%C && COPY %%H_%%A%%B%%C +,,
@tzkmx
tzkmx / backups_agent.bat
Created July 6, 2015 23:00
MySQL backup of multiple schemas to CSV with logging and 7zip compression
@ECHO OFF
SET timeformatstring='%%W_%%M-%%d-%%Y'
FOR /F "usebackq tokens=1-4 delims=: " %%A IN (`time /t`) DO (
FOR /F "usebackq tokens=1-2 skip=1 delims=| " %%H IN (`mysql -h %dbHost% -u %dbUser% -p%dbPass% -e "SET @@lc_time_names='es_MX'; SELECT UPPER(DATE_FORMAT(NOW(), %timeformatstring%));"`) DO (
ECHO Creating log in %dbBackDir% for backup job started at: %%H and time: %%A%%B%%C
:: Getting output from script called through new shell: http://superuser.com/a/661678
START "" /B /WAIT /HIGH CMD /C %dbBackDir%\backups_worker.bat ^> %dbBackDir%\%%H_%%A%%B%%Clog 2^>^&1
:: CMD equivalent of Unix touch? http://superuser.com/a/764725
COPY %dbBackDir%\%%H_%%A%%B%%Clog +,,
)
@tzkmx
tzkmx / DateRange.php
Created July 13, 2015 18:03
Form Class for Silex
<?php
namespace Forms;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Builds a form to select a date range
*
* @author Jesús Franco Martínez
*/
@tzkmx
tzkmx / 0. page.html
Last active August 29, 2015 14:27
Sections with checkbox hack + yellow fade animation https://jsfiddle.net/0eaLm968
<body>
<div class="radio_panels">
<h1>Demo of checkbox hack for panelized sections</h1>
<input type="radio" name="selecta" id="section1_chkbox" />
<label for="section1_chkbox">My first section</label>
<input type="radio" name="selecta" id="section2_chkbox" />
<label for="section2_chkbox">My second section</label>
<div id="section1" class="panel">
<h2>My first section</h2>
<p>The content for my awesome panel 1</p>
@tzkmx
tzkmx / DBStream.php
Created October 3, 2015 19:29
Mixing Stream Wrappers & filters to create custom and lightweight views of database
<?php
/**
* @author Jesus Franco Martinez <jefrancomix@gmail.com>
*/
class DBStream {
/**
*
* @var mysqli
*/
@tzkmx
tzkmx / AbstractClassReflectable.php
Last active October 16, 2015 16:30
Abstract Class enabling examination of private properties and @var annotations.
<?php
class AbstractClassReflectable
{
/**
* @var \ReflectionClass
*/
private $_reflector;
private $_reflectedProperties;
public function getProperties()
@tzkmx
tzkmx / test.php
Last active November 27, 2015 00:55
Test Symfony Events, modify event with Reflection
<?php
require 'vendor/autoload.php';
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\EventDispatcher\Event;
class EventSubscriber implements EventSubscriberInterface