Skip to content

Instantly share code, notes, and snippets.

@sunils34
sunils34 / youtubeIDExtractor.js
Created December 27, 2011 08:07
Extract Youtube ID from Youtube URL
//Given a youtube url, return the youtube id.
//There are several versions of youtube urls that work.
//http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
//http://www.youtube.com/embed/0zM3nApSvMg?rel=0
//http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
//http://www.youtube.com/watch?v=0zM3nApSvMg
//http://youtu.be/0zM3nApSvMg
//http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
@sunils34
sunils34 / gist:1522686
Created December 27, 2011 04:12
base58_decode. - Decode Flickr shortened URLs
//Given a base58 encoded string, obtain the base 10 number.
//This is useful for decoding shortened flickr urls.
function base58_decode( snipcode )
{
var alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' ;
var num = snipcode.length ;
var decoded = 0 ;
var multi = 1 ;
for ( var i = (num-1) ; i >= 0 ; i-- )
{
@sunils34
sunils34 / imageloader.js
Created December 24, 2011 00:41 — forked from whs/imageloader.js
libimageloader loads image from photo upload services
/**
* @license The imageloader.js library is licensed under GNU Lesser General Public License v3 or later
*/
(function(){
/**
* TwitPic Image Loader
* Example: ldr = new TwitPicLoader("http://twitpic.com/asdf123");
* @param {string} URL of the TwitPic page. Eg. http://twitpic.com/asdf123
* @constructor
*/
@sunils34
sunils34 / moveItem.js
Created November 6, 2011 22:15
moveItem - Repositioning an element within a Javascript array
/**
* moveItem
*
* Remove the element positioned at oldIdx,
* and insert this back into the array positioned at newIdx
*
* This does not do any bounds checking on the inputs
*
* @param array
* @param integer old index