This file contains hidden or 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 | |
/** | |
* WP Redix Index | |
* | |
* Redis caching system for WordPress. Inspired by Jim Westergren. | |
* | |
* @author Jeedo Aquino | |
* @see http://www.jeedo.net/lightning-fast-wordpress-with-nginx-redis/ | |
* @see http://www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/ | |
*/ |
This file contains hidden or 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 | |
# This script creates a compressed backup archive of the given directory and the given MySQL table. More details on implementation here: https://theme.fm | |
# Feel free to use this script wherever you want, however you want. We produce open source, GPLv2 licensed stuff. | |
# Author: Konstantin Kovshenin exclusively for Theme.fm in June, 2011 | |
# Set the date format, filename and the directories where your backup files will be placed and which directory will be archived. | |
NOW=$(date +"%Y-%m-%d-%H%M") | |
FILE="example.org.$NOW.tar" | |
BACKUP_DIR="/home/username/backups" |
This file contains hidden or 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 | |
/** | |
* Remove the slug from published post permalinks. | |
* Only affect to our custom post type, though. | |
*/ | |
add_filter("post_type_link", "wphdlr_remove_post_type_slug", 10, 3); | |
function wphdlr_remove_post_type_slug($post_link, $post, $leavename) | |
{ | |
if (!in_array("users", $post->post_type)) |
This file contains hidden or 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 get_encrypt($string, $key) | |
{ | |
srand((double) microtime() * 1000000); | |
$key = md5($key); | |
$td = mcrypt_module_open("des", "", "cfb", ""); | |
$key = substr($key, 0, mcrypt_enc_get_key_size($td)); | |
$iv_size = mcrypt_enc_get_iv_size($td); | |
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
This file contains hidden or 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
/*! | |
* JavaScript function to calculate the geodetic distance between two points specified by latitude/longitude using the Vincenty inverse formula for ellipsoids. | |
* | |
* Original scripts by Chris Veness | |
* Taken from http://movable-type.co.uk/scripts/latlong-vincenty.html and optimized / cleaned up by Mathias Bynens <http://mathiasbynens.be/> | |
* Based on the Vincenty direct formula by T. Vincenty, “Direct and Inverse Solutions of Geodesics on the Ellipsoid with application of nested equations”, Survey Review, vol XXII no 176, 1975 <http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf> | |
* | |
* @param {Number} lat1, lon1: first point in decimal degrees | |
* @param {Number} lat2, lon2: second point in decimal degrees | |
* @returns {Number} distance in metres between points |
This file contains hidden or 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
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | |
/* Latitude/longitude spherical geodesy tools (c) Chris Veness 2002-2017 */ | |
/* MIT Licence */ | |
/* www.movable-type.co.uk/scripts/latlong.html */ | |
/* www.movable-type.co.uk/scripts/geodesy/docs/module-latlon-spherical.html */ | |
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | |
'use strict'; | |
if (typeof module!='undefined' && module.exports) var Dms = require('./dms'); // ≡ import Dms from 'dms.js' |
This file contains hidden or 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 | |
add_action("init", "wprl_add_endpoints"); | |
function wprl_add_endpoints() | |
{ | |
add_rewrite_rule('^book/([^/]+)/([^/]+)/?', 'index.php?post_type=book&name=$matches[1]&tab=$matches[2]', 'top'); | |
} | |
add_filter("query_vars", "wprl_query_vars"); | |
function wprl_query_vars($vars) |
This file contains hidden or 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
def mapping(value, leftMin, leftMax, rightMin, rightMax): | |
# Figure out how 'wide' each range is | |
leftSpan = leftMax - leftMin | |
rightSpan = rightMax - rightMin | |
# Convert the left range into a 0-1 range (float) | |
valueScaled = float(value - leftMin) / float(leftSpan) | |
# Convert the 0-1 range into a value in the right range. | |
return rightMin + (valueScaled * rightSpan) |
This file contains hidden or 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
def mapping(value, leftMin, leftMax, rightMin, rightMax): | |
# Figure out how 'wide' each range is | |
leftSpan = leftMax - leftMin | |
rightSpan = rightMax - rightMin | |
# Convert the left range into a 0-1 range (float) | |
valueScaled = float(value - leftMin) / float(leftSpan) | |
# Convert the 0-1 range into a value in the right range. | |
return rightMin + (valueScaled * rightSpan) |
This file contains hidden or 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
#Threaded UDPServer with threadpool | |
import SocketServer | |
from Queue import Queue | |
import threading, socket | |
class ThreadPoolMixIn(SocketServer.ThreadingMixIn): | |
''' | |
use a thread pool instead of a new thread on every request | |
''' |
NewerOlder