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
/* 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 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
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 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
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 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
$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 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 | |
$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)) { |
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
// run from the index page of the course | |
(function () { | |
var urls = [], | |
videos = []; | |
// get lesson urls | |
$('.lesson-index__lesson-link').each( function () { | |
urls.push( $(this).attr('href') ); |
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
function scaleImage(ev) | |
{ | |
var data = ev.data, | |
editor = ev.editor; | |
var img = data.image; | |
// maximum size allowed for images | |
var maxX = 400; | |
var maxY = 300; |
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
// in User.php model add few checks | |
public function is_admin() | |
{ | |
return ($this->account_type === 'admin'); // account_type is ENUM field | |
} | |
public function has_rights($acc_type) | |
{ | |
if ($this->is_admin()) { // if admin always true | |
return true; |
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 | |
// filter je upit koji zavisi od toga sta je popunjeno u pretrazi | |
$filter = array('relation' => 'AND'); | |
// zavisno sta je od polja poslato u upitu kreiramo upit: | |
if ( ! empty($_GET['tip'])) { // ako pretrazujes po tipu nekretnine | |
$filter[] = array( | |
'key' => 'tip', // ovo je ime custom polja, recimo da je 'tip' |
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
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*" | |
} | |
parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ ' |
OlderNewer