Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / function-makecallbackable.js
Created April 14, 2012 15:52
JavaScript Function#makeCallbackable
/*
* Function#makeCallbackable
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
Function.prototype.makeCallbackable = function() {
var fn = this;
//document own properties
console.log(Object.keys(document).sort());
//document own properties & inherited properties
var documentPropertiesIncludeInherited = [];
for(var p in document) { documentPropertiesIncludeInherited.push(p); }
console.log(documentPropertiesIncludeInherited.sort());
//document inherited properties only
var documentPropertiesOnlyInherited = [];
@gsampaio
gsampaio / instagram_recent_feed.js
Created January 8, 2012 15:59
Instagram Recent Feed Javascript
/**
* A simple javascript script to get the lastest images from your instagram account.
* Require an app to acess instagram api in order to get the access_token and user_id
* Require jquery for the ajax and dom manipulation
*/
var settings = {
user : 'ENTER_YOUR_USER_ID_HERE',
access_token : 'ENTER_YOUR_USER_ACCESS_TOKEN_HERE'
};
@iros
iros / application.js
Created November 12, 2011 17:34
BackboneTraining-require.js
// Define whatever global space vars you might need.
var mbta = {
// application configuration parameters
app : {
server : "http://backbonetraining.bocoup.com:8000"
},
// application data
data : {
// station collection
lines : null
@1905
1905 / jsonToReadable.php
Created September 25, 2011 10:31
human readable json_encode output
function jsonToReadable( $jsonString)
{
$tabcount = 0;
$result = '';
$inquote = false;
$tab = " ";
$newline = "\n";
for($i = 0; $i < strlen( $jsonString); $i++)
@strackoverflow
strackoverflow / instagram-preview.php
Created August 22, 2011 15:53
Instagram Thumbnail
/* This is now available via the official instagram api. */
<?php
$url = $_GET['u'];
$r = file_get_contents($url);
$searchStr = 'meta property="og:image" content="';
$pos = strpos($r, $searchStr);
$s = substr($r, $pos + strlen($searchStr));
$img = substr($s, 0, strpos($s,'"'));
header('Location: '.$img);
exit;
@Jxck
Jxck / ecma5_on_v8.js
Created July 9, 2011 12:02
The sample usage of ECMA 5 Features Implemented in V8
/**
* The sample usage of ECMA 5 Mozilla Features Implemented in V8
* https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8
* You can use thease new feature of ECMA5 on Node.js as you like.
* because there is no IE :)
* Order is deferent form original wiki.
* Sources are Checked on Node.js v0.5.0(unstable), v0.4.9(stable)
*
* you can execute this file.
* $ node ecma5_on_v8.js
@jashkenas
jashkenas / gist:994057
Created May 26, 2011 20:53 — forked from steeleforge/gist:993924
SC 2.0a To-Do's coffee-script
Todos = SC.Application.create()
Todos.Todo = SC.Object.extend
title: null
isDone: false
Todos.todosController = SC.ArrayProxy.create
content: []
createTodo: (title) ->
@gadhra
gadhra / interview-questions.php
Created April 22, 2011 18:56
Some answers to some interview questions I've had
<?php
/** This may be one of the most useless files in the world, but it essentially encapsulates
* the answers to as many interview questions as I can remember over the years. Written in PHP
* because ... just because.
**/
/**
* Write me a program that can determine if something is a palindrome
* ex. A man, a plan, a canal - Panama! should count