Skip to content

Instantly share code, notes, and snippets.

@schmidtsonian
schmidtsonian / gist:6049484
Last active December 20, 2015 01:29
Image sequence object
var doSequence = {
theInterval: null,
currentIndex: 0,
count: 0,
pictureCount: 0,
indexOffset: 1,
element: null,
isIncrement: false,
interval: 60,
loop: false,
@schmidtsonian
schmidtsonian / gist:6049509
Created July 21, 2013 18:45
Get hash url
function getHash(){
var hash = decodeURIComponent(window.location.hash);
var url = hash.split("/");
// alert(url)
return url[0];
}
@schmidtsonian
schmidtsonian / gist:6049517
Created July 21, 2013 18:48
Add class to active a menu
function setActiveMenu( element ){
$(element).click(function(){
$(element).removeClass('active');
$(this).addClass('active');
});
}
@schmidtsonian
schmidtsonian / sprite.js
Last active December 20, 2015 01:29
Animate sequence images
/*
* params: array
* params.interval int, milisegundos para intervalos
* params.element DOM, ejemplo: $('.contenedor img' )
* params.increment bool, true = +1
* params.onComplete
*/
function animateSequence( params ){
var index = 0;
@schmidtsonian
schmidtsonian / gist:6641367
Created September 20, 2013 18:00
vagrant speed
Vagrant.configure("2") do |config|
config.vm.box = 'precise32'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :private_network, ip: "10.11.12.13"
config.vm.synced_folder ".", "/vagrant", nfs: true
#inside vagrant box run the following line to activate NFS
@schmidtsonian
schmidtsonian / popup.js
Last active August 29, 2015 13:57
Open popup to share facebook/twitter
$( '.popup' ).on( "click", function( e ) {
e.preventDefault();
var width = 575,
height = 400,
left = ( window.screen.width / 2 ) - ( ( width / 2 ) + 10 ),
top = ( window.screen.height / 2 ) - (( height / 2 ) + 50 ),
url = this.href,
opts = 'status=1' +
@schmidtsonian
schmidtsonian / instagram.js
Last active March 27, 2025 19:22
Get the latest posts from instagram of a user or the last posts filtered by tag
/**
* get Instagram latest post.
*
* @params {object} args -
* @params {string} args.count - int
* @params {string} args.token - string, default: "12464375.5b9e1e6.2924280151d74a58a7e437a828decc37"
* @params {string} args.userId - string, default: "308301284"
* @params {string} args.tag - string, default: "slmf"
* @params {string} args.filter - string: "user" || "tags", default: "user"
@schmidtsonian
schmidtsonian / youtube.js
Last active August 29, 2015 13:57
Get latest post youtube
var Youtube = (function() {
'use strict';
function Youtube( args ) {
// enforces new
if (!(this instanceof Youtube)) {
return new Youtube( args );
}
this.settings = {
@schmidtsonian
schmidtsonian / truncate.js
Created April 2, 2014 18:07
Truncate text
String.prototype.trunc =
function( n, useWordBoundary ){
var toLong = this.length > n,
s_ = toLong ? this.substr(0,n-1) : this;
s_ = useWordBoundary && toLong ? s_.substr( 0, s_.lastIndexOf( ' ' ) ) : s_;
return toLong ? s_ + ' ...' : s_;
};
var s = "this is a text"
s.trunc( "6", true ); // "this ..."
@schmidtsonian
schmidtsonian / wordWrap.js
Last active August 29, 2015 13:58
Find character and wrap the word(s) containing it
/**
*
* Verifica si existe la funcion, sino la crea (solo existe en firefox)
*
**/
if(!('contains' in String.prototype)){
String.prototype.contains = function( str, startIndex ) {
return -1 !== String.prototype.indexOf.call( this, str, startIndex );
};
};