Skip to content

Instantly share code, notes, and snippets.

View m6w6's full-sized avatar

Michael Wallner m6w6

View GitHub Profile
@m6w6
m6w6 / uri.js
Created April 21, 2012 05:56 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.host; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
Derick, Release Managers, Rasmus!
I'm seriously concerned by the introduction of DateTimeImmutable extending DateTime, and despite not being the talking guy, I'll try to outline the reasons why I and obviously a lot of other people think so.
I can understand the frustration with a DateTime that should not have been modifiable in the first place and the wish to improve upon things and to lead users to the proper way. But, this is not the right way.
If interoperability was in mind, it will not be given, because every single API which has been written in the last seven years and has DateTime in it's signature is potentially broken. The code has "the right" to expect a modifiable instance of DateTime, which is no longer guaranteed.
The argument, that it was implemented this way, so that method signatures do not have to be changed, is very weak, because every method has to be reviewed, and a method signature change would actually be the right thing to accept a DateTimeImmutable, because it cannot act like a D
<?php
$async = new AsyncHttp;
for ($i = 1; $i < $argc; ++$i) {
$async->attach(new HttpRequest($argv[$i]), function ($req) use (&$state) {
$state = "";
printf("\n%d < %s\n", $req->getResponseCode(), $req->getUrl());
});
}
<?php
$key='MYKEY';
$memcached = new Memcached();
$memcached->addServer('127.0.1.2', 11211);
$memcached->addServer('127.0.2.2', 11211);
$memcached->addServer('127.0.3.2', 11211);
$memcached->addServer('127.0.4.2', 11211);
$memcached->addServer('127.0.5.2', 11211);
$memcached->addServer('127.0.6.2', 11211);
<?php
$client = new http\Client;
for ($i = 1; $i < $argc; ++$i) {
$client->enqueue($req = new http\Client\Request("GET", $argv[$i]),
function ($res) use ($req, &$state) {
$state = "";
printf("\n%d < %s\n", $res->getResponseCode(), $req->getRequestUrl());
// auto-dequeue
return true;
@m6w6
m6w6 / gist:6292641
Created August 21, 2013 10:03
pdo_mysql test failures
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #39858 (Lost connection to MySQL server during query by a repeated call stored proced) [ext/pdo_mysql/tests/bug_39858.phpt]
PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks future queries) [ext/pdo_mysql/tests/bug_41997.phpt]
MySQL PDO->__construct() - Generic + DSN [ext/pdo_mysql/tests/pdo_mysql___construct.phpt]
MySQL PDO->exec(), affected rows [ext/pdo_mysql/tests/pdo_mysql_exec.phpt]
MySQL PDOStatement->nextRowSet() [ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt]
MySQL Prepared Statements and different column counts [ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt]
=====================================================================
@m6w6
m6w6 / vg.log
Created September 26, 2013 12:46
==13241== Memcheck, a memory error detector
==13241== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==13241== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==13241== Command: php -n -d open_basedir=. -r $dir=getcwd();\ mkdir("foo",0777,true);\ chdir("foo");\ rmdir("$dir/foo");\ chdir("..");
==13241== Parent PID: 11074
==13241==
==13241== Conditional jump or move depends on uninitialised value(s)
==13241== at 0x5DFAA6: php_check_specific_open_basedir (in /usr/bin/php)
==13241== by 0x5DFE14: php_check_open_basedir_ex (in /usr/bin/php)
==13241== by 0x55524F: ??? (in /usr/bin/php)
@m6w6
m6w6 / gist:6896890
Created October 9, 2013 06:05
github pull merge status
var parts=window.location.pathname.split('/');
if(parts[3] == 'pull') {
var url='https://api.github.com/repos/'+parts[1]+'/'+parts[2]+'/pulls/'+parts[4];
var xhr = new XMLHttpRequest;
xhr.onload = function() {
switch (xhr.status) {
case 200:
case 304:
@m6w6
m6w6 / acx_debug_cflags.m4
Created November 7, 2013 06:57
--enable-debug for autoconf
# gcc default/debug CFLAGS handling respecting user's CFLAGS
# avoid AC_PROG_CC setting -O2 CFLAGS which will override DEBUG_CFLAGS' -O0
# must be used right after AC_INIT
AC_DEFUN([ACX_DEBUG_CFLAGS], [
# ensure CFLAGS are set
AS_IF([test "${CFLAGS+set}"], [
USE_DEFAULT_CFLAGS=false
], [
@m6w6
m6w6 / configure.ac
Created November 22, 2013 08:39
ACX_DEBUG_CFLAGS usage
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
# our own version constants
m4_define([VERSION_MAJOR], [1])
m4_define([VERSION_MINOR], [0])
m4_define([VERSION_PATCH], [0])
m4_define([VERSION_STATE], [dev])