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 / 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 / MAMP-DOCK-INVISIBLE.sh
Created March 27, 2012 03:53
Hide or show the MAMP Pro dock icon.
#!/bin/bash
# Place this script in dir: /usr/bin
# Change permissions: sudo chmod +x /usr/bin/MAMP-DOCK-INVISIBLE
#
# Ensure the MAMP 'Info.plist' file has the following entry:
# <key>LSUIElement</key>
# <string dock-visible="1">NO</string>
#
# Usage:
@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.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 / 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 / cs-error.sh
Last active December 11, 2015 14:18
#!/usr/sh
curl -s http://pastebin.com/raw.php?i=gWHNJQyE
say "Happy Birthday to You, Happy Birthday to You"
say "Happy Birthday Dear Andre Castillo, Happy Birthday to You."
say "From good friends and true,"
say "From old friends and new,"
say "May good luck go with you,"
say "And happiness too."
echo "\n\nHappy Birthday Peter :)\n"
@josue
josue / gonna.learn.today.js
Last active December 16, 2015 15:28
MESSING WITH DAVID TO SEE IF HE IS REALLY TESTING
(function(){
if(window.console && (Math.round(Math.random() * 10))<7) {
var a = (Math.round(Math.random() * 2)) % 2 ? 'background-image:url(http://i.imgur.com/hHcgxw9.gif); padding:0 0px 185px 45px; color:red;' : 'background-image:url(http://i.imgur.com/67qDKDC.gif); padding:0 0px 225px 355px; color:red;';
console.log("%c Here is a bug for you\n\n"+(new Array(18)).join("\n"),a);
}
})();
@josue
josue / diff-uniq
Created December 30, 2013 16:42
Output unique lines not common in two files.
#!/bin/sh
FILE1=$1
FILE2=$2
grep -n -v "`cat $FILE1`" $FILE2
@josue
josue / dump-resque-failed-jobs
Last active August 29, 2015 13:57
Dump all resque-web failed jobs from IP address
#!/bin/sh
# To extract from localhost '127.0.0.1:6379', you can quickly do:
# usage: curl -L http://git.io/dump-resque-failed-jobs-test | sh
[ "$1" != "" ] && IP=$1 || IP=127.0.0.1
[ "$2" != "" ] && PORT=$2 || PORT=6379
redis-cli -h $IP -p $PORT LRANGE resque:failed 0 -1
@josue
josue / nginx_s3_proxy.conf
Last active March 7, 2023 07:31
Simple Nginx Proxy to S3 Bucket Asset
server {
listen 80;
listen 443 default_server ssl;
ssl on;
ssl_certificate /etc/ssl/certs/myssl.crt;
ssl_certificate_key /etc/ssl/private/myssl.key;
server_name *.example.com;
root /var/www/vhosts/website;