Skip to content

Instantly share code, notes, and snippets.

View biswajitpaul01's full-sized avatar
🎯
Focusing

Biswajit Paul biswajitpaul01

🎯
Focusing
View GitHub Profile
@biswajitpaul01
biswajitpaul01 / _ide_helper.php
Created July 18, 2020 20:42
Laravel IDE helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");
@biswajitpaul01
biswajitpaul01 / gravatar.php
Created March 7, 2020 05:36
Get avatar image from email address
<?php
if (!function_exists('get_avatar')) {
function get_avatar ($email, $size = 32, $default = 'mp') {
return 'https://www.gravatar.com/avatar/' . md5($email) . '?' . http_build_query( [ 's' => $size, 'd' => $default ] );
}
}
@biswajitpaul01
biswajitpaul01 / change-404-page.php
Created November 3, 2019 09:09
Helping Guides in Laravel
<?php
// File: app/Exceptions/Handler.php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
@biswajitpaul01
biswajitpaul01 / settings.json
Created October 3, 2019 15:57
VSCode WordPress & Delpoy Extention Setup
// Plugin URL: https://marketplace.visualstudio.com/items?itemName=mkloubert.vs-deploy
{
"files.exclude": {
"**/wp-admin": true,
"**/wp-includes": true
},
"deploy": {
"openOutputOnDeploy": false,
"showPopupOnSuccess": true,
@biswajitpaul01
biswajitpaul01 / url-params.php
Created August 31, 2019 17:59
Extract query parameters from url
<?php
$href = 'https://in.pinterest.com/bhagyashrijadhav51/happy/?utm_campaign=rdboards&e_t=5c7cb45aadb34115ba86ab4531b61a23&utm_content=733664664235398280&utm_source=31&utm_term=3&utm_medium=2004';
$query_str = parse_url($href, PHP_URL_QUERY);
parse_str($query_str, $query_params);
echo $query_params['utm_campaign'];
@biswajitpaul01
biswajitpaul01 / cache.js
Created August 31, 2019 16:46
Browser Cache API
// Source: https://blog.logrocket.com/beyond-cookies-todays-options-for-client-side-data-storage/
const apiRequest = new Request('https://www.example.com/items');
caches.open('exampleCache') // opens the cache
.then(cache => {
cache.match(apiRequest) // checks if the request is cached
.then(cachedResponse =>
cachedResponse || // return cachedReponse if available
fetch(apiRequest) // otherwise, make new request
.then(response => {
@biswajitpaul01
biswajitpaul01 / scroll-view.js
Created August 9, 2019 17:26
Using scrollIntoView() to show added elements to a container with overflow
/* list of characters */
let count = 0;
document.querySelector('button').addEventListener('click', (ev) => {
if (count < characters.length) {
let item = document.createElement('li');
item.innerText = characters[count];
document.querySelector('ul').appendChild(item);
item.scrollIntoView({behavior: 'smooth'});
@biswajitpaul01
biswajitpaul01 / script.js
Created August 3, 2019 11:50
Load js script from jQuery
$.getScript( "https://cdn.datatables.net/plug-ins/1.10.19/api/processing().js", function( data, textStatus, jqxhr ) {
$("#company_list").DataTable().processing( true );
});
@biswajitpaul01
biswajitpaul01 / wp-admin-add-posts-state.php
Created July 26, 2019 07:27 — forked from martijn94/wp-admin-add-posts-state.php
Snippet to add post state to a WordPress page
<?php
//======================================================================
// Add post state to the projects page
//======================================================================
add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 );
function ecs_add_post_state( $post_states, $post ) {
@biswajitpaul01
biswajitpaul01 / css.json
Last active March 7, 2020 06:43
VSCode User Snippets
{
"wp.theme": {
"prefix": "wp.theme",
"body": [
"/*",
"Theme Name: $1",
"Theme URI: $2",
"Author: $3",
"Author URI: $4",
"Description: $5",