Skip to content

Instantly share code, notes, and snippets.

View jakebellacera's full-sized avatar

Jake Bellacera jakebellacera

View GitHub Profile
@jakebellacera
jakebellacera / ICS.php
Last active April 19, 2024 09:06
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@jakebellacera
jakebellacera / export-vscode-search-to-csv.js
Last active April 4, 2024 09:23
Export VSCode search results to CSV
// How to use:
// 1. In VS Code, perform a search.
// 2. Click "Open in editor" to open the search results in a `.code-search` file
// 3. Save the file
// 4. In terminal, run `node export-vscode-search-to-csv.js path/to/results.code-search path/to/exported.csv`
const fs = require("fs");
const path = require("path");
const readline = require("readline");
@jakebellacera
jakebellacera / how-to-get-youtube-video-id.md
Last active February 25, 2024 11:24
Learn how to get the ID of any YouTube video.

How to get the ID of any YouTube Video

This article walks you through how to get the ID of any YouTube video.

How to get a YouTube video ID from a youtube.com page URL

You may be watching the video or just happened to visit a link to a video. The video ID will be located in the URL of the video page, right after the v= URL parameter.

@jakebellacera
jakebellacera / http-auth-basic.md
Created January 9, 2012 21:18
How to secure a folder with Basic HTTP Authentication

Basic HTTP Authentication is when a user is required to log in to access a directory. This isn't meant to be secure by any means, but it's useful for locking out a majority of users from accessing a folder (e.g. staging a website).

To start, you must add this into your .htaccess:

AuthUserFile "/var/www/full/path/to/your/folder/.htpasswd"
AuthName "Message to go on user's login screen"
AuthType Basic
Allow from all
Require valid-user

Options +Indexes

@jakebellacera
jakebellacera / how-to-enable-sourcemaps.md
Last active March 13, 2023 13:01
How to enable source maps for your browser.

How to enable source maps

Source mapping is a technique that "maps" your browser inspector's line numbers to the source file. This is useful when working with assets that are compiled from LESS, SASS, Coffeescript and so on. Source maps can also be used with minified assets that would normally have their line numbers removed. If you're curious, here's some more information regarding source maps.

Chrome

  1. Open Developer Tools.
    • Mac users: View > Developer > Developer Tools.
  2. Click the Settings cog icon in the upper-right corner of the Developer Tools window.
  3. Under the Sources section, check the box(es) for the source maps you want to enable.
@jakebellacera
jakebellacera / convertSvgPathsToCsv.js
Created February 16, 2023 22:47
Converts folders of SVGs into a CSV of paths to be used in an icon library.
import fs from "node:fs/promises";
const camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
const getPathsFromSvg = async (path) => {
const svg = await fs.readFile(path, { encoding: "utf-8" });
const paths = svg.match(/d="(.*?)"/);
if (!paths) {
throw new Error(`No paths in file ${path}`);
@jakebellacera
jakebellacera / basic-meta-tags.html
Created August 17, 2016 20:29
Basic example of SEO-friendly HTML meta tags.
<!DOCTYPE html>
<html>
<head>
<title>My Page's Title - Site Name</title>
<meta name="description" content="My page's description. This should be no more than 155 characters or else it may be truncated.">
<meta name="og:title" content="My Page's title">
<meta name="og:description" content="My page's description. This should be no more than 155 characters or else it may be truncated.">
<meta name="og:image" content="http://mywebsite.com/default-og-thumbnail.png">
</head>
<body>
@jakebellacera
jakebellacera / hubspot-adwords-gclid-tracking.js
Last active December 21, 2022 00:56
Simple HubSpot gclid tracking code integration
// The script below will ensure that gclid parameters are associated with
// contacts in HubSpot.
//
// A few things are required before this script will work:
//
// * You will need to have the HubSpot tracking code installed on the page. A
// few modifications will be required if you don't have the tracking code
// installed. Additionally, you will lose out on the built-in cross-domain
// features that the hubspot tracking code uses to store cookies.
// * You will need to have this script installed on every page.
@jakebellacera
jakebellacera / bootstrap-4-menu-wordpress-filters.md
Last active October 18, 2022 21:20
Bootstrap 4 menus in WordPress via filters. No walker needed!

Bootstrap 4 menus in WordPress with filters

No walker needed!

This snippet allows you to create Bootstrap 4 menus without the use of a Walker. Instead, we're using filters to leverage WordPress core functionality as much as possible. Basically, all you need to do is this and you're done:

<nav class="navbar navbar-expand-lg fixed-top">
  <div class="container">
    <a class="navbar-brand" href="<?php echo home_url(); ?>">
@jakebellacera
jakebellacera / jquery.placeholder.js
Created July 15, 2011 18:00
jQuery Placeholder Plugin - Fixes the placeholder attribute on non-supported browsers.
/*
* Placeholder plugin for jQuery
* @author Daniel Stocks (http://webcloud.se)
*/
(function($) {
function Placeholder(input) {
this.input = input;
if (input.attr('type') == 'password') {
this.handlePassword();
}