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 | |
function new_excerpt_more($more) { | |
global $post; | |
//return '<a class="read-more" href="'. get_permalink($post->ID) . '">' . $more . '</a>'; | |
return '... <a class="read-more" href="'. get_permalink($post->ID) . '">></a>'; | |
} | |
add_filter('excerpt_more', 'new_excerpt_more'); | |
function improved_trim_excerpt($text) { |
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 | |
// https://gist.github.com/krava/6322195 | |
// Wordpress wp_query date range date_from date_to filter. | |
add_filter('posts_where', 'wapp_filter_posts_where'); | |
function wapp_filter_posts_where($where) { | |
global $wp_query; | |
if (isset($wp_query->query['date_from']) && isset($wp_query->query['date_to'])) { | |
$date_from = $wp_query->query['date_from']; | |
$date_to = $wp_query->query['date_to']; |
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 | |
// Wordpress JSON-API support for Sencha Ext.Store filters | |
// https://gist.github.com/krava/6683621 | |
add_action('json_api-core-get_recent_posts', 'wapp_customize_get_recent_posts'); | |
function wapp_customize_get_recent_posts() { | |
// filter: [{"property":"category","value":"1"},...] -> cat=:id, ... | |
global $wp_query; | |
if (isset($_GET['filter'])) { | |
$filter = json_decode(stripslashes($_GET['filter'])); |
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
a = data.customer.addresses | |
shipTo = if a.home.street and a.work.street | |
d = new Date | |
if 1 <= d.getDay() <= 5 and 9 <= d.getHours() <= 18 | |
a.work | |
else | |
a.home | |
else if a.home.street | |
a.home | |
else if a.work.street |
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 | |
COMMAND=$1 | |
HOST=$2 | |
case $COMMAND in | |
add) | |
shift;shift | |
if [[ ! $HOST ]]; then | |
echo No host specified. |
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
fallocate -l 1G /swapfile | |
chown root:root /swapfile | |
chmod 0600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
echo /swapfile none swap sw 0 0 >> /etc/fstab | |
echo vm.swappiness = 10 | tee -a /etc/sysctl.conf | |
echo vm.vfs_cache_pressure = 50 | tee -a /etc/sysctl.conf | |
sysctl -p |
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
# server sshd must not be at port 22 | |
IP=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}') | |
docker run -v=/var/run/docker.sock:/var/run/docker.sock -p=1113:1113 --name flynn-host -d flynn/host -external $IP | |
# give host time to initialize | |
sleep 10 | |
docker run -e=DISCOVERD=$IP:1111 flynn/bootstrap |
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/php | |
<?php | |
$oldDomain = $argv[1]; | |
$domain = $argv[2]; | |
$inputSQL = file_get_contents('php://stdin'); | |
$replacedDomainSQL = str_replace($oldDomain, $domain, $inputSQL); | |
$fixedSerializeSQL = preg_replace( |
OlderNewer