Skip to content

Instantly share code, notes, and snippets.

@evert
evert / sabredav demo server
Created March 18, 2011 12:46
SabreDAV demo server sourcecode
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors',1);
$publicDir = '/home/groups/s/sa/sabredav/persistent/public';
$pdo = new PDO('sqlite:/home/groups/s/sa/sabredav/persistent/db/db.sqlite');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@evert
evert / Router_example.php
Created October 8, 2011 00:21
My router idea
<?php
$router = new \My\Router();
$router->add('GET /blog/(?P<postId>[\d]+)', function($postId) {
return new \My\Blog\Controller($postId);
});
@evert
evert / server.php
Created February 1, 2012 12:52
sabredav demo server
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors',1);
$publicDir = '/path/to/public/directory';
$pdo = new PDO('sqlite:/path/to/sqlite/database');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@evert
evert / yourmom.js
Created March 30, 2012 19:56
Greasemonkey script to change every utm_source link attribute value to 'Your mom'
// ==UserScript==
// @name Referral: your mom
// @namespace yourmom
// @description This script changes every utm_source variable in links to 'Your mom'.
// @include *
// ==/UserScript==
var links = document.getElementsByTagName('a');
for(var i=0; i<links.length; i++) {
links[i].href = links[i].href.replace(/([&|?])utm_source=(.*)([&|?|^])/,"$1utm_source=Your+mom$3");
@evert
evert / alarmexpand.php
Created April 13, 2012 09:32
Expanding events manually based on alarm range
<?php
function alarmExpand(Sabre_VObject_Component_VCalendar $calendar, DateTime $start, DateTime $end) {
// You should adjust these to be more reasonable
$startScan = new DateTime('1995-01-01');
$endScan = new DateTime('2030-01-01');
$newEvents = array();
$tree = array(
new Sabre_DAV_SimpleCollection('principals' , array(
new Sabre_CalDAV_Principal_Collection($backend, 'principals/projects'),
new Sabre_CalDAV_Principal_Collection($backend, 'principals/users'),
));
);
@evert
evert / wordstuff.php
Created November 21, 2012 12:30
Words With Enemies
<?php
if ($argc < 2) {
echo "Usage: \n";
echo "\n";
echo "1. Wait till you get an invite for a silly wordgame\n";
echo "2. execute $argv[0] [letters]\n";
echo "3. Win\n";
die();
@evert
evert / hr.html
Created May 29, 2013 19:33
My whole life has been leading up to this moment.
<!DOCTYPE html>
<head>
<title>This is it</title>
<meta charset="utf-8" />
<style type="text/css">
hr {
border: 0px;
}
<?php
$a = 1;
$b = 2;
$c = 3;
list($a, $b, $c) = false;
var_dump([
$a, $b, $c
@evert
evert / gist:6058362
Last active December 20, 2015 02:39
CURLOPT_POSTREDIR
--- original.xml 2013-07-23 00:42:13.000000000 +0200
+++ next.xml 2013-07-23 00:37:10.000000000 +0200
@@ -580,6 +580,26 @@
</entry>
</row>
<row>
+ <entry valign="top"><constant>CURLOPT_POSTREDIR</constant></entry>
+ <entry valign="top">
+ <para>
+ Set the behavior for following redirects with