Skip to content

Instantly share code, notes, and snippets.

@iftee
iftee / page-autoscroll-jquery.js
Created October 25, 2020 13:58
A tiny jQuery snippet for auto page scroll during video capture of prototype
var scrollSpeed = 30000; // how fast the the page will be scrolled down to bottom in millisecond, change it based on your page height
var offsetTime = 10000; // an delay in in millisecond after which the page will start scrolling, change it based on your time to change window and go full-screen after you turn on recording
function scrollDownForVideoCapture() {
setTimeout(function() {
$('html, body').animate({ scrollTop: $(document).height() }, scrollSpeed)
}, offsetTime);
return false;
}
@iftee
iftee / Canadian Zip Code Array
Created April 30, 2020 07:23
Canadian Zip Code Array
['A0E 2Z0', 'A0H 2J0', 'A0N 2G0', 'A1A 5T4', 'A1L 2T8', 'A1M 3S5', 'A1N 5J6', 'A1V 2V5', 'A1W 2A1', 'A1X 2A1', 'A2A 2Y5', 'A2H 7S9', 'A2N 3X6', 'B0C 1C0', 'B0E 3C0', 'B0E 1A0', 'B0E 3J0', 'B0E 2G0', 'B0E 3N0', 'B0E 3A0', 'B0E 1B0', 'B0H 1K0', 'B0H 1S0', 'B0H 1T0', 'B0H 1J0', 'B0H 1A0', 'B0H 1H0', 'B0H 1V0', 'B0H 1M0', 'B0H 1N0', 'B0H 1G0', 'B0H 1X0', 'B0H 1R0', 'B0H 1W0', 'B0H 1P0', 'B0J 1H0', 'B0J 2T0', 'B0J 2H0', 'B0J 2P0', 'B0J 2W0', 'B0J 1V0', 'B0J 2C0', 'B0J 1E0', 'B0J 2E0', 'B0J 3G0', 'B0J 2X0', 'B0J 1C0', 'B0J 3L0', 'B0J 1W0', 'B0J 3M0', 'B0J 1J0', 'B0J 1K0', 'B0J 1R0', 'B0J 1T0', 'B0J 3A0', 'B0J 1G0', 'B0J 1A0', 'B0J 2M0', 'B0J 1N0', 'B0J 1Y0', 'B0J 2L0', 'B0J 1P0', 'B0J 3H0', 'B0J 2J0', 'B0J 3B0', 'B0J 2R0', 'B0J 2G0', 'B0J 2K0', 'B0J 2A0', 'B0J 1M0', 'B0J 3C0', 'B0K 1T0', 'B0K 1C0', 'B0K 1B0', 'B0K 1P0', 'B0K 2A0', 'B0K 1W0', 'B0K 1S0', 'B0K 1A0', 'B0K 1Z0', 'B0K 1X0', 'B0K 1G0', 'B0K 1R0', 'B0K 1H0', 'B0K 1V0', 'B0K 1N0', 'B0K 1E0', 'B0K 1Y0', 'B0K 1J0', 'B0K 1K0', 'B0K 1L0', 'B0L 1G0', 'B0L 1A0',
@iftee
iftee / npx-Windows-10-username-space-fix
Created February 26, 2020 10:41
Fix npx throwing error issue in terminal due to Windows 10 usename has space with the following terminal command. Also, run the terminal or VSCode in admin mode if required.
npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global
@iftee
iftee / .htaccess
Created February 26, 2020 10:13
Fix React app Browser-Router routing issue in apache server. Copy this file in the same directory as the index.html of React app
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
@iftee
iftee / bootstrap-3-navbar-dropdown-slide-effect.css
Created March 8, 2017 11:05
Fix the style glitch for slide effect in Bootstrap 3 Navbar Dropdown items
@media (max-width: 767px) {
.navbar-nav .dropdown-menu {
position: static;
float: none;
width: 100%;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
@iftee
iftee / bootstrap-3-navbar-dropdown-slide-effect.js
Created March 8, 2017 10:55
Add a slide effect in Bootstrap 3 Navbar Dropdown items
$( document ).ready( function() {
$( '.dropdown' ).on( 'show.bs.dropdown', function() {
$( this ).find( '.dropdown-menu' ).first().stop( true, true ).slideDown( 150 );
} );
$('.dropdown').on( 'hide.bs.dropdown', function(){
$( this ).find( '.dropdown-menu' ).first().stop( true, true ).slideUp( 150 );
} );
} );
@iftee
iftee / responsive-YouTube-embed-with-max-width.js
Created January 23, 2017 12:27
Responsive YouTube embed with max-width for WordPress
( function( $ ) {
'use strict';
// Assumptions:
// 1. The post content (and the video) will be inside a wrapper with class .post-content
// 2. The video aspect ratio is 16:9
// 3. The video will take the full width of the .post-content but will not go beyond a certain width
$( window ).on( 'load resize', function() {
@iftee
iftee / responsive-YouTube-embed.js
Last active January 23, 2017 12:26
Responsive YouTube embed for WordPress
( function( $ ) {
'use strict';
// We'll assume that the post content (and the video) will be inside a wrapper with class .post-content
// and the video aspect ratio is 16:9
$( window ).on( 'load resize', function() {
// Take the width of the wrapper
var contentWidth = $( '.post-content' ).width();
@iftee
iftee / in_array_r.php
Created June 28, 2016 08:59
Since in_array() doesn't work for multidimensional arrays, this recursive in_array_r() does the trick
<?php
/* Check if an item $search_item is in the multidimensional array $items */
function in_array_r( $search_item, $items, $strict = false ) {
foreach ( $items as $item ) {
if ( ( $strict ? $item === $search_item : $item == $search_item ) || ( is_array( $item ) && in_array_r( $search_item, $item, $strict ) ) ) {
return true;
}
}
@iftee
iftee / wp-remove-default-image-sizes.php
Last active November 12, 2022 00:21
Custom filter to remove default image sizes (WordPress and WooCommerce) from your theme.
<?php
/*
* Custom filter to remove default image sizes from WordPress.
*/
/* Add the following code in the theme's functions.php and disable any unset function as required */
function remove_default_image_sizes( $sizes ) {
/* Default WordPress */
unset( $sizes[ 'thumbnail' ]); // Remove Thumbnail (150 x 150 hard cropped)