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 | |
/** | |
* Create a new page in WordPress | |
*/ | |
function create_page($title, $content = '', $parent = 0, $page_template = '', $menu_order = 0) { | |
$args = array( | |
'post_title' => $title, | |
'post_content' => $content, | |
'post_parent' => $parent, | |
'menu_order' => $menu_order, |
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
grep -cv -P '\S' filename |
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
# Before starting | |
x = {} | |
# After line 1 | |
x = { | |
CTO => 1 | |
} | |
# After line 2 | |
x = { |
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
[Tue Dec 18 06:32:50 2012] [error] [client 10.66.180.194] File does not exist: /path/to/file/that/is/missing |
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 | |
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/ | |
//adjustments to wp-includes/http.php timeout values to workaround slow server responses | |
add_filter('http_request_args', 'bal_http_request_args', 100, 1); | |
function bal_http_request_args($r) //called on line 237 | |
{ | |
$r['timeout'] = 15; | |
return $r; | |
} | |
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
/** | |
* Retrieve posts ids given their title. | |
* Use this function if there are more than one post with the same title. | |
*/ | |
function get_multiple_posts_by_title($title) { | |
global $wpdb; | |
$posts_ids = array(); | |
$posts = $wpdb->get_results( $wpdb->prepare( “SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type=’post_type’”, $title), OBJECT ); | |
foreach ($posts as $post) { |
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
#define MAX_GPX 7 | |
#define MAX_RESET 8 |
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
int c; | |
char *hex = "0123456789abcdef"; | |
while( (c = getchar()) != EOF ){ | |
if( ('a' <= c && c <= 'z') | |
|| ('A' <= c && c <= 'Z') | |
|| ('0' <= c && c <= '9') ){ | |
putchar(c); | |
} else { | |
putchar('%'); |
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
// Select Photos that have the term Bike in them | |
select * from flickr.photos.search where text="Bike" and api_key="API_KEY" limit 10 | |
// Get info about a particular photo | |
select * from flickr.photos.info where photo_id=2439864402 and api_key="API_KEY" | |
// Get the url of the photo with id | |
select title, urls.url from flickr.photos.info where photo_id = '7751003932' and api_key = "API_KEY" | |
// Do a subquery to get the urls of all photos that have the term Bike in them |
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
{ | |
"query" : { | |
"count" : 1, | |
"created" : "2012-08-04T14:46:03Z", | |
"lang" : "en-US", | |
"results" : { | |
"item" : { | |
"title" : "Handling FTP usernames with @ in them" | |
} | |
} |