Skip to content

Instantly share code, notes, and snippets.

View jdreesen's full-sized avatar

Jacob Dreesen jdreesen

View GitHub Profile
@ezzatron
ezzatron / clean-use.php
Created May 9, 2011 12:10
Script to clean unnecessary PHP use statements
#!/usr/bin/env php
<?php
$paths = array();
if (isset($_SERVER['argv']))
{
$paths = $_SERVER['argv'];
array_shift($paths);
if (!$paths)
@gre
gre / easing.js
Last active June 27, 2024 15:37
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* 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 = {
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
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"
@beberlei
beberlei / tailrecursion.php
Created November 25, 2012 21:25 — forked from pkriete/gist:2425817
PHP Tail Recursion
<?php
class TailRecursion
{
public $func;
public $acc;
public $recursing;
public function tail()
{
return call_user_func_array($this->func, func_get_args());
@nikic
nikic / php_evaluation_order.md
Last active October 19, 2021 05:47
Analysis of some weird evaluation order in PHP

Order of evaluation in PHP

Yesterday I found some people on my [favorite reddit][lolphp] wonder about the output of the following code:

<?php

$a = 1;
$c = $a + $a++;
@1000hz
1000hz / nested_ternaries.js
Created April 18, 2014 20:21
Nested ternaries can be nice if you do it right...
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"
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
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);
};
@iammerrick
iammerrick / Consumer.js
Created May 25, 2016 17:06
A React component that computes the ratio based on the width or height of a given container.
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>