Yesterday I found some people on my [favorite reddit][lolphp] wonder about the output of the following code:
<?php
$a = 1;
$c = $a + $a++;
#!/usr/bin/env php | |
<?php | |
$paths = array(); | |
if (isset($_SERVER['argv'])) | |
{ | |
$paths = $_SERVER['argv']; | |
array_shift($paths); | |
if (!$paths) |
/* | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See the COPYING file for more details. | |
*/ | |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
<?php | |
class TailRecursion | |
{ | |
public $func; | |
public $acc; | |
public $recursing; | |
public function tail() | |
{ | |
return call_user_func_array($this->func, func_get_args()); |
function dessertRank(dessert) { | |
return dessert === "muffins" ? "good" | |
: dessert === "brownies" ? "pretty good" | |
: dessert === "cupcakes" ? "great" | |
: dessert === "cookies" ? "amazing" | |
: dessert === "cake" ? "omg" | |
: dessert === "ice cream" ? "dying" | |
: "probably pretty great" |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import com.google.auto.value.AutoValue; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.Target; | |
import static java.lang.annotation.ElementType.TYPE; | |
import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
/** | |
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization. | |
* <p> |
export const load = (id) => { | |
load.buffer = load.buffer || []; | |
load.buffer.push(id); | |
return (dispatch, getState) => { | |
if (load.flush) clearTimeout(load.flush); | |
load.flush = setTimeout(() => { | |
}, 0); | |
}; |
import { FluidRatio } from './FluidRatio'; | |
<FluidRatio> | |
{(width, height) => ( | |
<div style={{ width, height }}>This will be a ratio of 3/4 with a width of whatever container it is rendered into.</div> | |
)} | |
</FluidRatio> |