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 | |
/** | |
* Convert | |
* http://stackoverflow.com/questions/12516842/convert-psd-and-ai-to-png-jpg-with-imagick | |
* @param string $dir Directory to save to. | |
* @param string $tmpName The name to name the file excluding the extension. | |
* @param string $fileType | |
* @param string $size Large or small. | |
*/ |
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
<html> | |
<head></head> | |
<body> | |
<div> | |
<div id="carousel"> | |
<!-- | |
<div> | |
<a href="images/dog-1.png" title="Dog" data-hover="Sandy the west highland terrier" data-toggle="lightbox" class="lightbox"> | |
<img src="images/dog-1.png" alt="Dog" /> | |
</a> |
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 | |
/** | |
* Resize all thumbs in WP when thumbnail settings are updated | |
*/ | |
function update_thumbnails() { | |
set_time_limit(0); // can help if lot of images | |
$attachments = get_children( array('post_type' => 'attachment', 'post_mime_type' => 'image') ); |
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 | |
// From http://wordpress.stackexchange.com/questions/76209/custom-image-size-with-new-media-manager-in-wordpress-3-5 | |
/* | |
* Add custom thumb sizes to Wordpress media dialog | |
*/ | |
function my_insert_custom_image_sizes( $sizes ) { | |
// get the custom image sizes | |
global $_wp_additional_image_sizes; | |
// if there are none, just return the built-in sizes |
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
/* Produces a dump on the state of WordPress when a not found error occurs */ | |
/* useful when debugging permalink issues, rewrite rule trouble, place inside functions.php */ | |
ini_set( 'error_reporting', -1 ); | |
ini_set( 'display_errors', 'On' ); | |
echo '<pre>'; | |
add_action( 'parse_request', 'debug_404_rewrite_dump' ); | |
function debug_404_rewrite_dump( &$wp ) { |
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
if ( !class_exists( 'HijackMe' ) ) { | |
class HijackMe { | |
public function hijack_menu($objects) { | |
/** | |
* If user isn't logged in, we return the link as normal | |
*/ | |
if ( !is_user_logged_in() ) { | |
return $objects; | |
} | |
/** |
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 | |
if (preg_match('!!u', $string)) | |
{ | |
// this is utf-8 | |
} | |
else | |
{ | |
// definitely not utf-8 | |
} |
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
This gist contains two files for simple indexing of PDF files. | |
== requirements == | |
First you need to install Solr (which requires a Java JDK): Download a tar or zipfile at http://www.apache.org/dyn/closer.cgi/lucene/solr/ and unpack it to a directory of your choice. Go into this directory and start solr running in jetty by: | |
$ cd example | |
$ java -jar start.jar | |
Then locate your browser to http://localhost:8983/solr/ |
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
$mock = Mockery::mock('SceneMongo'); | |
$mock->shouldReceive('where')->with('visible', 1)->once()->andReturn($mock); | |
$mock->shouldReceive('where')->with('published_at', '<=', Mockery::type('int'))->once()->andReturn($mock); | |
$mock->shouldReceive('take')->with($limit)->once()->andReturn($mock); | |
$mock->shouldReceive('orderBy')->with('rating', 'DESC')->once()->andReturn($mock); | |
$mock->shouldReceive('get')->once()->andReturn($collection); |
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 | |
$split_on_column = 150; // on which column we split | |
$fp = fopen('big.csv', 'r'); // input | |
$f1 = fopen('out1.csv', 'w'); // output1 | |
$f2 = fopen('out2.csv', 'w'); // output2 | |
while ($row = fgetcsv($fp)) { |
OlderNewer