Skip to content

Instantly share code, notes, and snippets.

View yeco's full-sized avatar

Jasson Cascante yeco

View GitHub Profile
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAJ2AAAADgCAMAAABkUQmGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowNDgwMTE3NDA3MjA2ODExOTJCMEMxMjRBQjJBQTk5QyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo5QzkwNjM2QkJBNzkxMUUyODNCNzg3MTA2NDlBOEUwNiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo5QzkwNjM2QUJBNzkxMUUyODNCNzg3MTA2NDlBOEUwNiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChNYWNpbnRvc2gpIj4gPHhtcE
@yeco
yeco / TinyPubSub.js
Last active December 17, 2015 14:38
TinyPubSub.js Library
var EventBus = function () {
this.NewsPaperList = {};
this.OrderList = [];
};
EventBus.prototype = {
subscribe: function (newsPaper, address) {
if ((typeof newsPaper !== "string") || (typeof address !== "function")) {
return -1;
@yeco
yeco / style_guide.md
Created May 17, 2013 04:48
Personal JavaScript Style Guide

JavaScript Style Guide

##Indentation

4 spaces for indent

##"Classes" and Variable names For "classes" and constructors, use UpperCaseClassNames.

@yeco
yeco / restapi.js
Last active April 27, 2017 11:18
Rest API Adapter for Titanium Alloy
/**
* Rest API Adapter for Titanium Alloy
*/
function S4() {
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
}
function guid() {
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
@yeco
yeco / $.js
Created May 14, 2013 18:56 — forked from potfur/$.js
// Based on https://github.com/james2doyle/saltjs
window.$ = function(s) {
return document[{
'#': 'getElementById',
'.': 'getElementsByClassName',
'@': 'getElementsByName',
'=': 'getElementsByTagName'}[s[0]]
|| 'querySelectorAll'](s.slice(1))
};
@yeco
yeco / gist:5297397
Last active December 15, 2015 17:38
function addIframeStyle(styleUrl) {
var ss = document.createElement("link");
ss.type = "text/css";
ss.rel = "stylesheet";
ss.href = styleUrl;
var iframe = document.getElementById('frame_content');
var idoc = iframe.contentDocument || iframe.contentWindow.document;
if(document.all) {
@yeco
yeco / ffmpeg_osx.sh
Created March 2, 2013 15:30
Downloads dependencies and compiles FFMpeg on Mac OS X.
# Create a temporary directory for sources.
SOURCES=$(mktemp -d /tmp/XXXXXXXXXX)
cd $SOURCES
# Download the necessary sources.
curl -#LO http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
curl -#LO http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.tar.gz
curl -#LO http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
curl -#LO http://pkg-config.freedesktop.org/releases/pkg-config-0.25.tar.gz
curl -#LO http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz
@yeco
yeco / Levenshtein.js
Created December 20, 2012 23:15
Levenshtein Distance Algorythm
levenshteinDistance = function(str1, str2) {
var l1 = str1.length,
l2 = str2.length;
if(Math.min(l1, l2) === 0) {
return Math.max(l1, l2);
}
var i = 0,
j = 0,
d = [];
@yeco
yeco / jquery.hasText.js
Created December 12, 2012 07:32
Simple jQuery pseudo-selector that matches only if the element has text in it.
jQuery.expr[':'].hasText = function(el, i) {
if(el.childNodes.length === 1 && el.firstChild.nodeType === 3) {
return jQuery.trim(el.innerHTML).length > 0;
}
return false;
};
(function ($) {
$.fn.between = function (elm0, elm1) {
var index0 = $(this).index(elm0);
var index1 = $(this).index(elm1);
if (index0 <= index1)
return this.slice(index0, index1 + 1);
else
return this.slice(index1, index0 + 1);
}