Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am faishal on github.
  • I am faishal (https://keybase.io/faishal) on keybase.
  • I have a public key whose fingerprint is F3B7 DD16 C029 8066 AC92 0164 62E4 69AA 0DF4 86C5

To claim this, I am signing this object:

@faishal
faishal / upgrade-openssh-7.3p1-centos-6.7.sh
Created October 6, 2016 14:02
Upgrade OpenSSH to 7.3p1 in Cent OS 6
#!/bin/bash
# Copyright © 2016 Faishal Saiyed
cd
timestamp=$(date +%s)
if [ ! -f openssh-7.3.zip ]; then wget https://github.com/faishal/openssh-portable/releases/download/cent.os.6.7.openssh.7.3p1/openssh-7.3.zip; fi;
unzip -o openssh-7.3.zip -d openssh-7.3p1
cd openssh-7.3p1/
cp /etc/pam.d/sshd pam-ssh-conf-$timestamp
rpm -U *.rpm
yes | cp pam-ssh-conf-$timestamp /etc/pam.d/sshd
@faishal
faishal / force-no-ssl.php
Created April 1, 2016 15:41
Force WordPress front end to http instead of https
add_action( 'template_redirect', 'wpmu_ssl_template_redirect', 1 );
function wpmu_ssl_template_redirect() {
if ( is_ssl() && ! is_admin() ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
exit();
} else {
@faishal
faishal / wpdb-in-query-prepare.php
Last active April 11, 2016 13:07
WPDB In Query Prepare
<?php
global $wpdb;
if ( is_array( $ids ) ) {
$in_str_arr = array_fill( 0, count( $ids ), '%d' );
$in_str = join( ',', $in_str_arr );
$form_id_where = $wpdb->prepare( "ID IN ($in_str)", $ids );
} else {
$form_id_where = $ids> 0 ? $wpdb->prepare( 'ID=%d', $ids ) : '';
}
@faishal
faishal / wp-mu-cron.sh
Created October 23, 2015 08:13
Wordpress Multisite Crontab using WP-CLI
WP_PATH="/var/www/site_path"
for SITE_URL in = $(wp site list --fields=domain,path,archived,deleted --format=csv --path="$WP_PATH" | grep ",0,0$" | awk -F ',' '{print $1 $2}')
do
echo $SITE_URL
for EVENT_HOOK in $(wp cron event list --format=csv --fields=hook,next_run_relative --url="$SITE_URL" --path="$WP_PATH" | grep 'now$' | awk -F ',' '{print $1}')
do
echo $EVENT_HOOK
wp cron event run "$EVENT_HOOK" --url="$SITE_URL" --path="$WP_PATH" > /dev/null 2>&1
done
done
<?php
add_action( 'widgets_init', 'nbclatino_top_posts_widget_init' );
function nbclatino_top_posts_widget_init() {
// Check if our vip stats function is available
if ( !function_exists( 'wpcom_vip_get_stats_array' ) && ! function_exists( 'stats_get_csv' ) )
return;
unregister_widget( 'Jetpack_Top_Posts_Widget' );
@faishal
faishal / remove-kernal.sh
Created March 9, 2015 14:27
Remove unused kernels in ubuntu
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge
@faishal
faishal / README
Last active August 29, 2015 14:13 — forked from westonruter/README
Moved to https://github.com/xwp/vip-quickstart/pull/3
@faishal
faishal / auto-crop-image.php
Created January 9, 2014 06:13
Auto crop image using image magic
//Calculate frame ratio
$frame_ratio = ( float ) $frame_w / ( float ) $frame_h ;
//Calculate image ratio
$image_ratio = ( float ) $image_w / ( float ) $image_h ;
//Checking if both ratio are same
if ( round ( $frame_ratio , 2 ) != round ( $image_ratio , 2 ) ) {
@faishal
faishal / bp_latest_update_fix.php
Created September 2, 2013 06:36
User latest update Fix. add this code in theme/plugin and then call yoursite.com/?bp_latest_update_fix=true
if( ! function_exists ("bp_latest_update_fix" )){
function bp_latest_update_fix () {
global $wpdb;
$sql = "select * from $wpdb->usermeta where meta_key like 'bp_latest_update'";
$results = $wpdb->get_results ( $sql );
foreach ( $results as $row ) {
if ( $meta_value = maybe_unserialize ( $row->meta_value ) ) {
if ( is_array ( $meta_value ) ) {
if ( isset ( $meta_value[ "content" ] ) && strpos ( $meta_value[ "content" ], "update_txt" ) !== false ) {
$data_up = json_decode ( $meta_value[ "content" ] );