Skip to content

Instantly share code, notes, and snippets.

View abackstrom's full-sized avatar

Annika Backstrom abackstrom

View GitHub Profile
@abackstrom
abackstrom / gist:1301756
Created October 20, 2011 17:37
Determine if a table exists (MySQL)

On a WordPress MU install that contains 21,511 tables.

Table does exist (DESCRIBE)

mysql@delphinus:~$ time printf "DESCRIBE wp_users ; %.0s" {1..100} | mysql -P 3308 wordpress -f &>/dev/null

real    0m0.094s
user    0m0.005s
sys     0m0.004s
@abackstrom
abackstrom / wordpress.dev.sql
Created November 18, 2011 22:00
Update WordPress Network URLs
UPDATE wp_blogs SET domain = 'www.example.dev';
UPDATE wp_site SET domain = REPLACE(domain, 'example.com', 'example.dev');
UPDATE wp_sitemeta SET meta_value = REPLACE(meta_value, 'example.com', 'example.dev') WHERE meta_key = 'siteurl';
UPDATE wp_domain_mapping SET meta_value = REPLACE(meta_value, 'example.com', 'example.dev');
DROP PROCEDURE IF EXISTS wploop;
DELIMITER $$
CREATE PROCEDURE wploop()
BEGIN
DECLARE done INT DEFAULT 0;
@abackstrom
abackstrom / functions.php
Created January 4, 2012 17:10
Support Markdown syntax in P2 posts and comments
<?php
// http://michelf.com/projects/php-markdown/extra/
require_once( dirname(__FILE__) . '/markdown-extra/markdown-extra.php' );
/**
* Format posts/comments with Markdown at display time. Only process
* blocks starting with \^md\s+.
**/
function p2mis_comment_markdown( $text ) {
@abackstrom
abackstrom / gist:1601019
Created January 12, 2012 15:07
P2 jQuery.animate() fixes: transparency and callback
Index: js/p2.js
===================================================================
--- js/p2.js (revision 8687)
+++ js/p2.js (working copy)
@@ -141,9 +141,10 @@
var cnt = newComment.contents();
newComment.children('li.newcomment').each(function() {
if (isElementVisible(this) && !showNotification) {
- $(this).animate({backgroundColor:'transparent'}, {duration: 1000}, function(){
- $(this).removeClass('newcomment');
@abackstrom
abackstrom / GitHub_URL.php
Created January 19, 2012 16:54
Fetch short URL using git.io
<?php
class GitHub_URL {
protected $long;
public function __construct( $url ) {
$this->long = $url;
}
public function long() {
@abackstrom
abackstrom / .bashrc
Created January 24, 2012 03:34
Adam's Environment
#
# adam's .bashrc file.
#
#
# See also:
#
# - [Subversion: Missing Features](http://sixohthree.com/972/subversion-missing-features)
# only run if we have an interactive shell.
@abackstrom
abackstrom / gist:1668119
Created January 24, 2012 05:10
wTerm launch fail
adam@fsck:~:0$ palm-log us.ryanhope.wterm -f
following logs for application us.ryanhope.wterm on device "topaz-linux" {d838c86b826af29b280165c5ec607572dc78bb7b} usb 60618
[20120124-00:10:16.732978] error: Not allowed to load local resource: file:///opt/PalmSDK/0.1/share/framework/enyo/1.0/framework/enyo.js
[20120124-00:10:16.737886] error: Uncaught ReferenceError: enyo is not defined, index.html:
@abackstrom
abackstrom / nginx
Created January 31, 2012 16:47
choo configuration
./configure \
--prefix=/usr/local/server/nginx \
--conf-path=/usr/local/etc/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
#!/usr/bin/env node
/*
Send UDP packets to the daemon listening on port 8888,
and they will be echoed to the configured IRC channel:
echo "my hovercraft is full of eels" | nc -w1 -u 127.0.0.1 8888
create a config.js file in the same directory as this
@abackstrom
abackstrom / mu.sixohthree.com.conf
Created March 26, 2012 14:36
Nginx + php-fpm for WordPress Network
server {
listen 69.164.216.5:80;
listen 69.164.216.5:443 default ssl;
server_name _;
ssl_certificate ssl/sixohthree.com.cert.pem;
ssl_certificate_key ssl/sixohthree.com.key.pem;
root /var/www/mu.sixohthree.com/html;