I hereby claim:
- I am gordjw on github.
- I am gordjw (https://keybase.io/gordjw) on keybase.
- I have a public key ASDt3_xzHZYux1RDUsBnOyZ8YRo5gzw46b1P4KcK-37Ajgo
To claim this, I am signing this object:
""" | |
Basic solution | |
Time: O(nlogn) | |
- The main loop iterates through the original list (n + k) times | |
- The inner loop iterates through the tail of the list (k * log(n)) | |
- In the worst case, k would be n/3, which means: | |
- main loop reduces to n + n/3 -> 4/3 * n -> n | |
- inner loop reduces to n/3 * log(n) -> log(n) | |
Space: O(n) |
""" | |
We can optimise by recognising that: | |
- max_dist will always be (last - first) | |
- min_dist will always be from one pair of adjacent critical points, so we can calculate it as we run through the list | |
Time: O(n) | |
- We only run through the linked list once | |
Space: O(n) | |
- We create only a handful of extra variables, none of which are iterables or callables | |
""" |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
# | |
# Panda | |
# | |
# Watches a directory for Markdown file (*.md) changes, and refreshes output formats (PDF, DOCX, RTF) | |
# | |
PANDOC=`/usr/bin/which pandoc` | |
PANDOC_IN=/tmp/pandoc/in/ |
add_filter( 'tss_analytics_events', 'add_my_analytics_events' ); | |
function add_my_analytics_events( $events ) { | |
$events['publish_post'][] = array( 'post', 'published', function( $args ) { return $args[0]; } ); | |
} |
<?php | |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') | |
$_SERVER['HTTPS'] = 'on'; | |
define('WP_CONTENT_DIR', '/data/www/web/wp-content'); | |
// is_ssl doesn't always work, e.g. behind load balancers | |
if((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || is_ssl()) | |
define('WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/wp-content'); | |
else |
server { | |
listen 443 ssl; | |
listen 80; | |
root /data/www/web/core; | |
server_name web; | |
server_name_in_redirect off; | |
client_max_body_size 100m; | |
index index.php index.html index.htm; | |
<?php | |
/* | |
Plugin Name: Quick and Dirty WP-Piwik Fixer | |
Description: Temporary WP-Piwik Fixer, tested with WP-Piwik 0.9.9.18 and Piwik 2.9.1. Fixes site ids stored in WP Option tables in case yours have become messed up. | |
*/ | |
// Quick and dirty, don't install if you don't have shell or FTP access. It will takeover your admin screens. | |
// Commented out the line below to stop people from accidentally installing and killing wp-admin | |
// Uncomment to enable, recomment to disable. You won't have wp-admin access while it's enabled. |
In which I run some pretty rudimentary tests to find the most efficient way to checkout/update WordPress with git, and compare it to SVN. | |
First, we'll try shallow cloning, because that's the path to the smallest local git repository. | |
$ git clone --depth 1 https://github.com/WordPress/WordPress.git --branch 4.1 | |
Cloning into 'WordPress'... | |
remote: Counting objects: 1421, done. | |
remote: Compressing objects: 100% (1276/1276), done. | |
remote: Total 1421 (delta 163), reused 982 (delta 118), pack-reused 0 | |
Receiving objects: 100% (1421/1421), 7.96 MiB | 1.35 MiB/s, done. |