Skip to content

Instantly share code, notes, and snippets.

View rajeebbanstola's full-sized avatar

Rajeeb rajeebbanstola

View GitHub Profile
function sumAll(arr) {
arr.sort(function(a,b) { return a - b } );
num1 = arr[0];
num2 = arr[1];
numbers = [];
@rajeebbanstola
rajeebbanstola / freecodecamp-basic-algorithm.js
Last active February 26, 2018 18:06
JavaScript Algorithms
function reverseString(str) {
splitted = str.split("");
reversed = splitted.reverse();
joined = reversed.join("");
return joined;
}
reverseString("hello");
@rajeebbanstola
rajeebbanstola / reboot-my-router.py
Created July 16, 2017 17:21
Reboot Router when internet stops working. P.S.: I only know a animal by the name of Python.
import requests
from requests.auth import HTTPBasicAuth
import httplib
def have_internet():
conn = httplib.HTTPConnection("www.google.com", timeout=5)
try:
conn.request("HEAD", "/")
conn.close()
return True
@rajeebbanstola
rajeebbanstola / googlefontslist.php
Last active May 19, 2017 05:09
Google Font List Array
<?php
return array(
'ABeeZee' => 'ABeeZee',
'Abel' => 'Abel',
'Abhaya Libre' => 'Abhaya Libre',
'Abril Fatface' => 'Abril Fatface',
'Aclonica' => 'Aclonica',
'Acme' => 'Acme',
'Actor' => 'Actor',
'Adamina' => 'Adamina',
@rajeebbanstola
rajeebbanstola / control.php
Created October 4, 2016 10:36
Simple Color Palette Control
<?php
class Flash_Color_Palette_Control extends WP_Customize_Control {
public function render_content() {
if ( empty( $this->choices ) )
return;
$name = '_customize-radio-' . $this->id;
?>
var comments_container = 'div#comments';
var content_container = 'div#content';
var nav_container = 'nav.post-navigation';
var post_title_selector = 'h1.entry-title';
var curr_url = window.location.href;
jQuery.noConflict();
jQuery(document).ready(function() {
@rajeebbanstola
rajeebbanstola / functions.php
Created April 25, 2016 11:47
Dequeue Scripts and Styles in child theme
<?php
// Dequeue Styles
function onepress_child_dequeue_unnecessary_styles() {
wp_dequeue_style( 'onepress-animate' );
wp_deregister_style( 'onepress-animate' );
}
add_action( 'wp_print_styles', 'onepress_child_dequeue_unnecessary_styles' );
// Dequeue JavaScripts
function onepress_child_dequeue_unnecessary_scripts() {
@rajeebbanstola
rajeebbanstola / product-from-category.php
Created January 5, 2016 11:27
Fetch products from specific category in WooCommerce
<?php
$args = array(
'post_type' => 'product',
'orderby' => 'title',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $category
),
@rajeebbanstola
rajeebbanstola / get-woocommerce-categories.php
Created December 28, 2015 11:15
Simple way to fetch WooCommerce Categories with Image and Description
<?php
$get_featured_cats = array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'hide_empty' => '0',
'include' => $cat_array
);
$all_categories = get_categories( $get_featured_cats );
$j = 1;
@rajeebbanstola
rajeebbanstola / functions.php
Created October 7, 2015 10:56
Enqueue Scripts Only if widget is active
<?php
add_action( 'wp_enqueue_scripts', 'colormag_scripts_styles_method' );
/**
* Enqueues styles and scripts.
*/
function colormag_scripts_styles_method() {
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
if(is_active_widget( '', '', 'colormag_category_post_slider')){