Skip to content

Instantly share code, notes, and snippets.

@bhaveshxrawat
bhaveshxrawat / index.html
Last active March 1, 2024 16:21
Intersection Observer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Intersection Observer</title>
<link rel="stylesheet" href="style.css">
<script defer src="script.js"></script>
</head>
<body>
@rachids
rachids / settings.json
Last active May 11, 2024 19:49
Integrate Laragon's terminal (CMDer) to Visual Studio Code
{
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
@zackpyle
zackpyle / *Best Snippets*
Last active May 1, 2024 20:05
Best PHP/JS Snippets
This is a collection of my most used or most useful PHP and JS snippets
**Disclaimer, I didn't write most of these - I just curated them over the years**
@mrmartineau
mrmartineau / HowToTest.md
Created March 28, 2020 23:16 — forked from tkrotoff/HowToTest.md
How I structure my tests

File structure

  • src/fooBar.js
  • src/fooBar.html
  • src/fooBar.scss
  • src/fooBar....
  • src/fooBar.test.js => npm run test
  • src/fooBar.test.e2e.js (if I have E2E tests - Puppeteer, Playwright...) => npm run test:e2e

Tests should not be separated from the source code (think autonomous modules).

Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
@itsjusteileen
itsjusteileen / functions.php
Created January 15, 2020 21:05
Lists all SSP plugin podcast custom post type on the home page
<?php
/*
Plugin Name: SSP Customizations
Plugin URI: https://github.com/TheCraigHewitt/Seriously-Simple-Podcasting
Description: Customizations for the Seriously Simple Podcasting Plugin
Version: .1
Author: itsjusteileen
Author URI: https://github.com/itsjusteileen
*/
@codearryaas
codearryaas / detect-ios.js
Created November 17, 2019 17:00
JavaScript: How to detect if device is iOS?
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (isIOS) {
console.log('This is a IOS device');
} else {
console.log('This is Not a IOS device');
}
@neckerson
neckerson / theme.js
Last active June 10, 2019 03:47
Expose jQuery $ in the window so it can be accessed by jQuery plugins
// In the root directory of the theme, install your plugin:
//
// > yarn add jquery-zoom
//
// Add the line below to the top of scripts/layout/theme.js
import $ from 'jquery';
// Below your imports, set up jQuery so that it can be accessed
// from the HTML
@kmwalsh
kmwalsh / gist:b02acf86d05ccd1767ea9fc4c261bff5
Last active May 12, 2022 17:50
Redirect single post to external link - WordPress
/**
* =============================================================
* Redirect single post to external link
* =============================================================
*/
// this checks to make sure that the function doesn't already exist
// if something else in your WP uses a function named redirect_cpt_to_external_link
// this check to see whether it exists or not will keep your site from crashing
if ( ! function_exists('redirect_cpt_to_external_link') ) {
@mrmartineau
mrmartineau / dev-resources.md
Last active March 23, 2023 00:20
My go-to resources for working on the web.