Skip to content

Instantly share code, notes, and snippets.

View Shibly's full-sized avatar

Shibly

View GitHub Profile
@Shibly
Shibly / index.html
Created July 9, 2019 07:16
Smooth Scroll Using jQuery
<!DOCTYPE html>
<html>
<head>
<title>Smooth Scroll</title>
<style type="text/css">
hr {
height: 100vh;
}
</style>
</head>
public function search(Request $request) {
$query = trim(strip_tags($request->query('query')));
$items = DB::table('podcast_items')
->where('title', 'LIKE', "%$query%")
->orWhere('description', 'LIKE', "%$query%")
->get();
return view('podcasts.searchresults')->with([
'items' => $items,
@Shibly
Shibly / custom_product_loop.php
Created February 10, 2017 21:56
Get product details including add to cart button in custom product loop
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
@Shibly
Shibly / sweetalert.php
Last active March 3, 2021 11:38
Show Flash Message On Codeigniter View using sweetalert
<?php if ($this->session->flashdata('flash_message')): ?>
<script>
swal({
title: "Done",
text: "<?php echo $this->session->flashdata('flash_message'); ?>",
timer: 1500,
showConfirmButton: false,
type: 'success'
});
</script>
@Shibly
Shibly / carbon.php
Last active August 31, 2015 17:09
Carbon Date Differ and date based login validation
<?php
$subscription_date = new \Carbon\Carbon($user->subscription_ends_at);
$now = \Carbon\Carbon::now();
$difference = $subscription_date->diff($now)->days;
echo "You have " . "<strong>" . $difference . "</strong>" . " days to expire";
function create(array $data)
{
$date = strtotime("+30 day");
return User::create([
@Shibly
Shibly / au_post.php
Created July 14, 2014 21:39
This gist will display only author's post in WordPress
function display_authors_listing_only($wp_query)
{
if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/edit.php') !== false) {
if (!current_user_can('update_core')) {
global $current_user;
$wp_query->set('author', $current_user->id);
}
}
}
@Shibly
Shibly / gist:7694817
Last active December 29, 2015 15:59
Browser detection with modernizr.js Add modernizr.js library in your html file and use the following code snippet inside the <script> tag. In this example I use jQuery library too. Happy detecting :)
var BrowserDetect = {
init: function() {
this.browser = this.searchString(this.dataBrowser) || "Other";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
},
searchString: function(data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
this.versionSearchString = data[i].subString;
@Shibly
Shibly / github.js
Last active December 23, 2015 22:59
A simple node.js script to fetch all your github repositories and their description.
var https = require('https');
var username = 'Shibly';
var options = {
host: 'api.github.com',
path: '/users/' + username + '/repos',
method: 'GET'
};
var request = https.request(options, function (response) {
@Shibly
Shibly / gist:6061505
Created July 23, 2013 10:47
Enable colors in git in terminal.
Mac comes with git pre-installed but not pre-configured. The color coding is missing in git terminal when you are using it in mac. Use this sipmple command to enable color coding in Mac. Happy gitting :)
git config --global color.ui true
@Shibly
Shibly / drush_install
Last active December 19, 2015 13:19
Configure drupal drush in mountain lion
Download Drush to local folder (e.g. Downloads)
Launch Terminal and change directory (where drush is downloaded)

cd ~/Desktop
Extract it with

tar -zxf drush.tar.gz
Create /usr/local/lib (you can choose any location you want)
sudo mkdir drush /usr/local/lib/