Skip to content

Instantly share code, notes, and snippets.

View josue's full-sized avatar
:shipit:
Crushing it from 1999 to Present

Josué Rodriguez josue

:shipit:
Crushing it from 1999 to Present
View GitHub Profile
@josue
josue / test_uploads.php
Last active October 13, 2015 03:08
Test Uploads - Creates temp files and enqueues them.
<?php
require_once('test_jobs.php');
if (php_sapi_name() === 'cli') {
$upload_options = getopt("",array(
'upload:', // --upload=5
));
}
else if (!empty($_GET['upload'])) {
$upload_options = $_GET;
@josue
josue / test_jobs.php
Last active October 13, 2015 02:26
Test Jobs - Send Resque Jobs to Redis
<?php
// check required Redis module
if (!class_exists('Redis')) {
throw new Exception("Requires PHP Redis extension. Install via: sudo apt-get install php5-redis");
}
class TestJobs {
private $redisInstance = null;
private $redisConfig = array();
@josue
josue / export_db_table_schemas.sh
Created October 10, 2012 22:14
Export DB Table Schemas: Creates an SQL schema file for each table without the table data.
#!/bin/bash
# Usage: ./export_db_table_schemas.sh {custom directory}
MYSQL_USER="{username}"
MYSQL_PWD="{password}"
MYSQL_DB="{database}"
[ "$1" != "" ] && SQL_DIR=$1 || SQL_DIR="schemas"
mkdir -p $SQL_DIR
@josue
josue / ui.filterlist.js
Created September 5, 2012 18:19
Filter an object for matching fields.
/*
Author: Josue Rodriguez <josue@josuerodriguez.com> -- MIT License -- (c) 2012
Purpose: Filter an object list
Usage:
<input type="text" id="filter_list">
<div id="my_list">
<div data-id="{id}">{label}</div>
<div data-id="{id}">{label}</div>
<div class="hide" id="list_empty">Non Available</div>
@josue
josue / jquery.onEnterKey.js
Created June 15, 2012 20:57
jQuery: onEnterKey trigger
$(function(){
$.fn.onEnterKey = function(opts,callback){
var opt = typeof target==="object" && target || {};
var target = opts.target || typeof opts===jQuery && opts || typeof opts==="string" && opts || null;
var callback = opt.callback || typeof opts==="function" && opts || typeof callback==="function" && callback || function(target){
$(target).trigger("click");
};
return this.live("keypress.onEnterKey",function(e){
if(e.keyCode==13) {
callback.call(this,target);
@josue
josue / ui.until.js
Created December 12, 2011 23:13
UI.until - wait until first function executes true then run callback.
// wait until first function executes true then run callback.
UI = ENV = {};
ENV._ui_until = {};
UI.until = function(before, after) {
var opt = typeof before == "object" && before || {};
opt.before = opt.before || opt.check || before;
opt.after = opt.after || opt.callback || after;
var u = {
id: opt.id || +(new Date),
@josue
josue / getInputs.js
Created November 18, 2011 22:03
getInputs - collects and serialize all tag fields (input,textarea,select) into jQuery object or JSON format.
// prerequisites: jQuery library.
getInputs = function(t,f){
var opt = typeof t==="object" && t || {};
var target = opt.target || (t===jQuery || typeof t==="string") && t;
var filter = opt.filter || f;
var A = {
serialized: {},
fields: $("input,textarea,select", target || document)
};
@josue
josue / jquery.opengraph.js
Created June 30, 2011 20:41
Collects OpenGraph tag data from markup into an object list.
/*
* Author: Josue Rodriguez <josue@josuerodriguez.com>
* Created: 2011-06-30
* License: MIT
* Description: Collects OpenGraph tag data from markup into an object list.
*/
var OpenGraph = function(opts){
var opt = opts || {};
var context = opt.DOM || typeof opts==="string" && opts || document;
@josue
josue / global.js
Created April 30, 2011 23:50
Common Javascript boot and usable methods for practical application development.
/* ===========================================================================
Copyright (c) 2011 - Josue Rodriguez <josue@josuerodriguez.com>
Permission is hereby granted, 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, and/or distribute copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@josue
josue / jquery.dummyimage.js
Created December 31, 2010 01:09
Display dynamic generated dummy image / placeholders.
$(function(){
// jQuery - DummyImage
// Josue Rodriguez (c) 2010-12-30, MIT License
$.fn.dummyImage = (function(options) {
var opt = {
'class' : 'dummyImage',
'display' : 'inline-block',
'position' : 'relative',