Skip to content

Instantly share code, notes, and snippets.

Mohammad Jangda mjangda

Block or report user

Report or block mjangda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@koral--
koral-- / ImageCaptureHelper.java
Last active Jan 16, 2019
Helper for sending ACTION_IMAGE_CAPTURE intent and retrieve its results. Handles all low level operations
View ImageCaptureHelper.java
//MIT License
//Copyright (c) 2015 Karol Wrótniak, Droids On Roids
package pl.droidsonroids.imagehelpers;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
@mjangda
mjangda / remove-post-terms.php
Created Jul 2, 2012
Remove multiple terms from a post
View remove-post-terms.php
<?php
/**
* Helper function since this function doesn't exist in core
*/
function remove_post_terms( $post_id, $terms_to_remove, $taxonomy ) {
$terms_to_remove = array_map( 'intval', $terms_to_remove );
array_filter( $terms_to_remove, function( $term ) { return ! empty( $term ); } );
// Get the existing terms and only keep the ones we don't want removed
@mjangda
mjangda / parent-child-css.php
Last active Oct 6, 2015
Properly queueing parent and child style.css, props Viper007Bond
View parent-child-css.php
<?php
add_action( 'wp_enqueue_scripts', function() {
wp_register_style( 'parent-theme', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-theme', get_stylesheet_uri(), array( 'parent-theme' ) );
} );
@tott
tott / gist:2572405
Created May 1, 2012
debugging WordPress rewrite rules
View gist:2572405
<?php
add_action( 'generate_rewrite_rules', 'debug_action_generate_rewrite_rules', 1, 1 );
// debug http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1592
// this should only be hit if the rewrite_rules option is empty.
// http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1616
function debug_action_generate_rewrite_rules( $rules ) {
global $debug_action_rules;
error_log( __FUNCTION__ . ' : ' . __LINE__ );
error_log( var_export( $_SERVER, true ) );
error_log( "Rules Option: " . var_export( get_option( 'rewrite_rules' ), true ) );
@mjangda
mjangda / query-killer.php
Created Feb 10, 2012
Kills WordPress search query
View query-killer.php
<?php
add_filter( 'posts_where', 'x_kill_search_query', 10, 2 );
function x_kill_search_query( $where, $query ) {
if ( ! is_admin() && $query->is_main_query() ) {
// this is a self-removing callback
remove_filter( current_filter(), __FUNCTION__, 10 );
if ( $query->is_search() ) // only kill the main query
$where = ' AND 1=0 /* Query killed */';
@Viper007Bond
Viper007Bond / gist:1297669
Created Oct 19, 2011
Determining if modifying the main query or not in WordPress
View gist:1297669
<?php
# See bigdawggi's comment below for a good combined example
// Pre-3.3
function cf_google_search_kill_wp_search( $where, $query ) {
global $wp_the_query;
if( ! is_admin() && $query->is_search() && $query === $wp_the_query ) {
$where = ' AND 1=0';
View plugin-deploy.sh
#!/usr/bin/env bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/svn/$DIR_NAME/$BRANCH
@westonruter
westonruter / gist:311373
Created Feb 22, 2010
jQuery fallback implementation of HTML5 placeholder attribute
View gist:311373
if(!jQuery('<input PLACEHOLDER="1" />')[0].placeholder){ //Uppercase attr for IE
jQuery(':input[placeholder]').each(function(){
var $this = $(this);
if(!$this.val()){
$this.val($this.attr('placeholder'));
$this.addClass('input-placeholder');
}
}).live('focus', function(e){
var $this = $(this);
if($this.hasClass('input-placeholder')){
You can’t perform that action at this time.