Skip to content

Instantly share code, notes, and snippets.

@stuartloxton
stuartloxton / gist:652483
Created October 28, 2010 22:35
Closure Memoization in PHP
<?php
function Memoize($function) {
$cache = array();
return function() use (&$cache, $function) {
$args = func_get_args();
$serialized = serialize($args);
if( isset($cache[$serialized]) )
return $cache[$serialized];
@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@hertsch
hertsch / kitframework_list_routing_patterns.php
Last active April 26, 2017 08:28
Silex: get a list of all routing URI patterns
// get all routing objects
$patterns = $app['routes']->getIterator(); // seems to be changed in Silex 1.1.0 !!! ... ->current()->all();
// walk through the routing objects
foreach ($patterns as $pattern) {
$match = $pattern->getPattern();
echo "$match<br />";
}
function Dispatcher(subscribe){
var subscriptions = [];
this.push = function(e){
subscriptions.forEach(function(s){
s(e);
});
};
this.subscribe = function(sink){
@pocketberserker
pocketberserker / AsyncInCSharpAndFSharp.ja.rst
Last active October 6, 2022 02:53
Async in C# and F#: Asynchronous gotchas in C# (Japanese translation)

C# と F# の Async: C# の非同期の落とし穴

原文

Async in C# and F#: Asynchronous gotchas in C#

原文著者

Tomas Petricek (@tomaspetricek)

翻訳者

@pocketberserker

2月に、私は毎年恒例のMVPサミット ── Microsoft が MVP のために主催するイベント ── に出席しました。私はボストンとニューヨークを訪問する機会を利用して、二つの F# に関する講演と Channel9 lecture about type providers の収録を行いました。他のすべての活動(しばしばパブで他の F#er を議論に巻き込んだり、朝まで長い睡眠)にもかかわらず、私はいくつかの講演に参加し果せました。

@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active May 23, 2022 12:28
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
@joepie91
joepie91 / delay-promise.js
Last active July 29, 2022 20:02
ES6 Promise.delay
module.exports = function(duration) {
return function(){
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve();
}, duration)
});
};
};
@azu
azu / Incremental DOM.md
Last active July 13, 2022 16:07
Incremental DOM ざっと見たやつ。追記: 初期バージョンのコードなので最新では異なる場合があります。

Incremental DOM

Introducing Incremental DOM — Google Developers — Medium

Reactやvirtual-dom、Glimmer(Ember)などVirtual DOMの実装は色々あるが、これらのVirtual DOM実装には2つの問題がある

  • 既存のテンプレート言語を利用していない(しにくい)
  • モバイルでのパフォーマンス、特にメモリに関しては大きすぎる

これらを解決するためにIncremental DOMと言うものを作っている(WIP)

@staltz
staltz / tiny-cycle-1.js
Created December 10, 2015 18:53
Tiny Cycle.js 1
function main() {
return {
DOM: Rx.Observable.timer(0, 1000)
.map(i => `Seconds elapsed ${i}`)
};
}
const drivers = {
DOM: function DOMDriver(sink) {
sink.subscribe(text => {
@Zenexer
Zenexer / escapeshellrce.md
Last active November 2, 2023 06:09
Security Advisory: PHP's escapeshellcmd and escapeshellarg are insecure

Paul Buonopane paul@namepros.com at NamePros
PGP: https://keybase.io/zenexer

I'm working on cleaning up this advisory so that it's more informative at a glance. Suggestions are welcome.

This advisory addresses the underlying PHP vulnerabilities behind Dawid Golunski's [CVE-2016-10033][CVE-2016-10033], [CVE-2016-10045][CVE-2016-10045], and [CVE-2016-10074][CVE-2016-10074]. It assumes prior understanding of these vulnerabilities.

This advisory does not yet have associated CVE identifiers.

Summary