Skip to content

Instantly share code, notes, and snippets.

View mohsinrasool's full-sized avatar
💪

Mohsin Rasool mohsinrasool

💪
View GitHub Profile
@mohsinrasool
mohsinrasool / wp_body_class.php
Created August 19, 2015 11:58
Add Page slug to the body_class function
// Add to the body_class function
function condensed_body_class($classes) {
global $post;
// add a class for the name of the page - later might want to remove the auto generated pageid class which isn't very useful
if( is_page()) {
$pn = $post->post_name;
$classes[] = "page-".$pn;
}
@mohsinrasool
mohsinrasool / loadAdaptiveBackground.js
Created July 29, 2015 13:54
Javascript function to load the corresponding image based on window resolution.
/**
* Javascript function to load the corresponding image based on window resolution.
*
* Usage:
* <div id='story' data-adaptive-bg='{
* "desktop": "/static/img/banners/press/press-1920x1080.jpg",
* "tablet": "/static/img/banners/press/press-992x500.jpg",
* "mobile": "/static/img/banners/press/press-768x400.jpg"
* }'>
* </div>
/** Angular JS datepicker fix for mssql dates
*
*/
app.directive('datepickerLocaldate', ['$parse', function ($parse) {
var directive = {
restrict: 'A',
require: ['ngModel'],
link: link
};
@mohsinrasool
mohsinrasool / wp-db-fix-weird-chars.sql
Last active August 29, 2015 14:24
WP Queries to fix weird characters (i.e., – = em dash, and — = en dash) in posts and pages
-- Try 1:
-- Change DB_CHARSET from utf-8 to latin1 in wp-config.php
-- define('DB_CHARSET', 'latin1');
-- Try 2:
-- Clean up post_content
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’');
@mohsinrasool
mohsinrasool / month-directive.js
Created July 9, 2015 12:40
An AngularJS directive to generate dropdown of months
/**
* Usage <year-select range=10 offset=0 />
*
*
*/
app.directive('monthSelect',function(){
return {
@mohsinrasool
mohsinrasool / year-directive.js
Created July 9, 2015 12:38
An AngularJS directive to create a dropdown of years
/**
* Usage: <year-select offset=0 range=10 />
*
*/
app.directive('yearSelect',function(){
var currentYear = new Date().getFullYear();
return {
restrict: 'AE',
replace: true,
@mohsinrasool
mohsinrasool / file_auto_loader.php
Created July 9, 2015 12:32
Function recursively includes all the files in the specified directory $dir and skips the ones in $skipFiles array
<?php
/**
* It recursively includes all the files in the specified directory $dir and skips the ones in $skipFiles array
* Usage:
* include_files(dirname(__FILE__)."/models", $skipFiles);
*
* @return void
* @author Mohsin Rasool
*
@mohsinrasool
mohsinrasool / MultiDimArrayPost.class.php
Last active February 27, 2024 19:57
Post multi-dimensional array using PHP Curl.
/**
* Post multi-dimensional array to a URL using PHP Curl.
* Usage:
* $req = new MultiDimArrayPost();
* $req->postToURL('http://xyz.com/post',$_POST);
*
* @package default
* @author Mohsin Rasool
*
**/
@mohsinrasool
mohsinrasool / Cleverness-Todos-in-WP-Full-Calendar
Created March 27, 2015 12:39
Displays Assigned Cleverness todos in WP Full Calendar
/**
* Displays Assigned Cleverness todos in WP Full Calendar
*
* @return $items
* @author Mohsin Rasool
**/
add_filter( 'wpfc_events', 'wpfc_add_tasks' );
add_filter( 'wpfc_ajax', 'wpfc_add_tasks' );
@mohsinrasool
mohsinrasool / ftp-delete-files.php
Created February 4, 2015 15:27
This script deletes all the provided files from FTP server. It helps when server is being compromised and several malicious files has been detected. It happend to one of my hosting on iPage
<?php
/**
* This script deletes all the provided files from FTP server.
*
* Application: This script helps when server is being compromised and several malicious files has detected. Some common spams are
*
* HG.PHP.Shell.25968.UNOFFICIAL
* JCDEF.Obfus.CreateFunc.BackDoorEval-23
* JCDEF.Obfus.CreateFunc.BackDoorEval-26
* JCDEF.Obfus.CreateFunc.BackDoorEval-21