Skip to content

Instantly share code, notes, and snippets.

View maurobringolf's full-sized avatar
⛰️

Mauro Bringolf maurobringolf

⛰️
  • Zürich, Switzerland
View GitHub Profile
<?php
function get_remote_data( $slug ) {
$key = 'some-key-string';
if( !wp_cache_get( $key ) ) {
$response = wp_remote_get( $url );
//error handling
<?php
echo "Running full GET requests... \n";
$sum = 0;
for( $i = 1; $i <= 100; ++$i ) {
$start = microtime(true);
@maurobringolf
maurobringolf / url-ebnf.txt
Last active January 15, 2017 13:07
A first try at a EBNF for URLs
lowercase_letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
uppercase_letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
letter = lowercase_letter | uppercase_letter
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
alphanumeric = letter | digit
lowercase_alphanumeric = lowercase_letter | digit
hyphen = "-" | "_"
lowercase_word = lowercase_alphanumeric { lowercase_alphanumeric }
//defining a pseudo-private property o.x using getters and setters
var o = {
__c: 1,
get x() { return this.__c; },
set x(y) { this.__c = y; }
}
//Make the property o.__c non-enumerable
Object.defineProperty(o, '__c', { enumerable: false });
//Defining a restricted access property o.x using getters and setters
var o = {
c: 0,
get x() { return this.c; },
set x(y) { this.c = Math.max(y,0); }
}
o.x = 3;
o.x; //3
//defining a normal property o.x using getters and setters
var o = {
c: 1,
get x() { return this.c; },
set x(y) { this.c = y; }
}
o.x; //1
o.x = 3;
o.x; //3