This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"io" | |
"log" | |
"os" | |
"os/exec" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns a callable which is the composition of all the arguments, | |
* which should be callable themselves. | |
*/ | |
function fn_compose( $fn ) { | |
$funcs = func_get_args(); | |
$last = array_pop( $funcs ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__ . '/threads.php'; | |
$commands = array(); | |
for ( $i=0; $i<10; $i++ ) { | |
$commands[] = "bash -c 'sleep `shuf -i 1-5 -n 1`; echo $i'"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Fixes the annoying "You can't push to X. Use Y" git error. | |
while read -r line | |
do | |
read -a array <<< "$line" | |
remote="${array[0]}" | |
url="${array[1]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Iterates over results of a query, split into many queries via LIMIT and OFFSET | |
*/ | |
class QueryIterator implements Iterator { | |
var $limit = 500; | |
var $query = ''; | |
var $global_index = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# author: sdls | |
# source: http://wordpress.org/support/topic/p2p-admin-view-sort-by-drop-down#post-3446538 | |
function restrict_posts_by_relation() { | |
global $typenow; | |
$post_type = 'yourfirstposttype'; // change HERE | |
$related_post = 'yoursecondposttype'; // change HERE | |
$related_post_drop_down = 'related_'. $related_post. '_post'; | |
if ($typenow == $post_type) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ( P2P_Connection_Type_Factory::get_all_instances() as $p2p_type => $ctype ) { | |
$post_types = array(); | |
foreach ( $ctype->side as $direction => $side ) { | |
if ( 'post' == $side->get_object_type() ) { | |
$post_types[ $direction ] = $side->query_vars['post_type']; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We have several database replicas and want to minimize latency by querying them | |
# all and returning the first response to arrive. | |
# | |
# http://concur.rspace.googlecode.com/hg/talk/concur.html#slide-54 | |
class Connection | |
constructor: (@name) -> | |
query: (query, continuation) -> | |
@op = setTimeout(=> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$root = $_SERVER['DOCUMENT_ROOT']; | |
chdir( $root ); | |
$path = '/'.ltrim( parse_url( $_SERVER['REQUEST_URI'] )['path'],'/' ); | |
if ( file_exists( $root.$path ) ) | |
{ | |
if ( is_dir( $root.$path ) && substr( $path,strlen( $path ) - 1, 1 ) !== '/' ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# LEMP | |
apt-get -y install nginx mysql-server php5-mysql php5-fpm | |
# extra php packages | |
apt-get -y install php5-cli php5-gd php5-curl php5-xdebug | |
# change user from www-data to scribu | |
sed -i 's/www-data/scribu/g' /etc/nginx/nginx.conf /etc/php5/fpm/pool.d/www.conf |