Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aercolino's full-sized avatar

Andrea Ercolino aercolino

View GitHub Profile
@aercolino
aercolino / $.proxyGet.js
Last active August 29, 2015 14:02
A jQuery plugin for accessing any URL, using YQL or another proxy.
$.proxyGet = function ( url, callback, options ) {
// reject anything that doesn't resemble a "plain" URL or a null (see below)
if (! (url === null || /^(https?:|\/\/)/.test(url))) {
throw new SyntaxError('Expected a URL.');
}
// allow detection of current SSL mode by starting the url with '//'
if (url && url.indexOf('//') === 0) {
url = window.location.protocol + url;
@aercolino
aercolino / $.equals.js
Created June 7, 2014 12:08
A jQuery plugin for equality comparisons of JavaScript scalars and objects.
$.equals = function( a, b, options ) {
options = $.extend({
// if true, in case of inequality, a trace of the first difference is logged to the console
verbose: false,
// use 'strict' for ===, 'abstract' for ==
comparison: 'strict',
@aercolino
aercolino / $.news.js
Last active August 29, 2015 14:02 — forked from cowboy/HEY-YOU.md
jQuery.news = (function($) {
var broker = $({});
return {
subscribe: function() {
$.fn.on.apply(broker, arguments);
},
unsubscribe: function() {
@aercolino
aercolino / flickr_feed.php
Created June 30, 2014 11:34
Small changes to make "Garees Flickr Feed" WordPress plugin survive Flickr https only API.
//...
if(!defined('GAREE_MUSTACHEPHP')) {
include_once('Mustache.php');
define('GAREE_MUSTACHEPHP', true);
}
function flickr_api($path = '') {
return 'https://api.flickr.com' . $path;
}
@aercolino
aercolino / enzymes-hello-world.php
Last active August 29, 2015 14:11
This is a test for exploring Gists as Enzymes
<?php
echo 'Hello World!';
@aercolino
aercolino / checked_overloading.php
Last active August 29, 2015 14:13
Proof of concept for WordPress bug #30891: Unchecked property overloading is detrimental to OOP.
// Proof of concept for WordPress bug #30891: Unchecked property overloading is detrimental to OOP.
class CheckedOverloading {
public $legacy_public = 'legacy_public';
protected $legacy_protected = 'legacy_protected';
private $legacy_private = 'legacy_private';
//...
public $fresh_public = 'fresh_public';
@aercolino
aercolino / php_lint.php
Created January 23, 2015 11:53
A function for checking the syntax of PHP code.
/**
* Check the syntax of a code snippet.
*
* @param $code
*
* @return mixed|null|string
*/
function php_lint( $code )
{
$result = null;
@aercolino
aercolino / gist:5301378
Created April 3, 2013 13:53
Shuffle option added to the Flickr Feed plugin.
//...
'date_format' => get_option('date_format'),
'count' => 10,
'shuffle' => 0,
'sort' => null,
//...
else
return garees_flickr_feed_error("please enter your flickr-api-key in the settings!");
$amount = $shuffle >= $count ? $shuffle : $count;
function IndentationToList(options) {
'use strict';
return Main(options);
function Interpolate(template, variables) {
var names = Object.keys(variables);
var result = template;
for (var i = 0, iTop = names.length; i < iTop; i++) {
@aercolino
aercolino / 0_reuse_code.js
Created March 14, 2016 13:34
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console