Skip to content

Instantly share code, notes, and snippets.

View yeco's full-sized avatar

Jasson Cascante yeco

View GitHub Profile
@yeco
yeco / truncate.php
Created September 25, 2012 15:42
truncate.php
function truncate($text,$numb) {
$text = html_entity_decode($text, ENT_QUOTES);
if (strlen($text) > $numb) {
$text = substr($text, 0, $numb);
$text = substr($text,0,strrpos($text," "));
$etc = " ...";
$text = $text.$etc;
}
$text = htmlentities($text, ENT_QUOTES);
return $text;
@yeco
yeco / observable.js
Created August 16, 2012 19:37
Simple event emmitter / observable
function Observable() {
this.listeners = [];
}
Observable.prototype = {
constructor: Observable,
observe: function( fn ) {
this.listeners.push( fn );
@yeco
yeco / gist:2551711
Created April 29, 2012 16:30 — forked from padolsey/gist:2521471
Regular click event for touch devices [jQuery]
'createTouch' in document && (jQuery.event.special.click = {
setup: function(data, namespaces, eventHandle) {
var t;
$(this).bind('touchstart.touchClick', function() {
t = +new Date;
}).bind('touchend.touchClick', function(e) {
if (+new Date < t + 200) {
$(this).trigger('click', e);
}
})
@yeco
yeco / pubsub.md
Created April 29, 2012 07:16 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@yeco
yeco / hack.sh
Created April 25, 2012 20:13
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2492984/hack.sh | sh
#
@yeco
yeco / Job_Description.js
Last active October 13, 2015 21:14
We're hiring!
var skill_sets = {
creativity: 'Over 9000!',
front_end: ['JavaScript', 'Html', 'CSS preprocessors'],
back_end: ['Java', 'Ruby', 'PHP', 'NodeJS']
};
var we_give = {
benefits: ['Books or Courses subside', 'Beer', 'Snacks', 'Videogames', 'Yoga'],
laptop: {
'select': ['Mac Book Pro"', 'Mac Book Air"', "System 76"]
@yeco
yeco / Shake.js
Created January 19, 2012 14:38
Shake events handling on iOS
no need for plugin,
// Position Variables
           var x = 0;
           var y = 0;
           var z = 0;
           // Speed - Velocity
           var vx = 0;
           var vy = 0;
(bookshelf[book] || (bookshelf[book] == [])).push(details);
var bookshelf = {};
function addBook(book, details) {
// Prevent idiocy.
if(!book || !details){
throw "Missing a book and some details there...";
}
(!bookshelf[book] ? (bookshelf[book] = []) : bookshelf[book]).push(details);
}
@yeco
yeco / bookshelf-1.js
Created December 27, 2011 05:39
bookshelf object without conditional statement
var bookshelf = {};
function addBook(book, details) {
// Prevent idiocy.
if(!book || !details){
throw "Missing a book and some details there...";
}
if(!bookshelf[book]){
bookshelf[book] = [];
}