Skip to content

Instantly share code, notes, and snippets.

Avatar

Jake Bellacera jakebellacera

View GitHub Profile
@jakebellacera
jakebellacera / ICS.php
Last active Oct 25, 2020
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
View ICS.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 / disable-yoast-seo-automatic-og-image-lookup.php
Last active Oct 20, 2020
Force Yoast SEO to show the default open graph image in case a feature image isn't set.
View disable-yoast-seo-automatic-og-image-lookup.php
<?php
/**
* Plugin Name: Disable Yoast SEO Automatic Open Graph Images
* Plugin URI: https://gist.github.com/jakebellacera/c2aab8f786a0617b27dd4914c70463d4
* Description: Shows the default open graph image in case a feature image isn't set, rather than showing a random image on the page.
* Version: 0.0.0
* Author: Jake Bellacera
* Author URI: https://www.jakebellacera.com/
*/
@jakebellacera
jakebellacera / hubspot-adwords-gclid-tracking.js
Last active Oct 13, 2020
Simple HubSpot gclid tracking code integration
View hubspot-adwords-gclid-tracking.js
// 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 / mamp-mysql2-rbenv.md
Created Aug 22, 2012
Instructions on how to use MAMP with the mysql2 gem and Ruby 1.9.3-p194 via rbenv
View mamp-mysql2-rbenv.md

How to use MAMP with the mysql2 gem and Ruby 1.9.3-p194 via rbenv

Let's say you're a web developer who happens to work with both MAMP and Ruby when building different types of websites. Let's say you also like to keep your MySQL stuff in one place and don't like having to juggle both a local MySQL install as well as a MAMP MySQL install. Well, you can indeed connect your ruby apps to MAMP's MySQL. Here's a tutorial on how to do it.

Important! Before you do anything, download and install MAMP. MAMP Pro will work as well. At the time of this writing, MAMP 2.1.1 is the latest.

First, install Ruby via rbenv

  1. Install homebrew
  2. Install rbenv: brew install rbenv, follow any instructions homebrew gives you after the installation is complete.
@jakebellacera
jakebellacera / how-to-get-youtube-video-id.md
Last active Jul 2, 2020
Learn how to get the ID of any YouTube video.
View how-to-get-youtube-video-id.md

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 / ajax-send.js
Created Feb 22, 2011
JQuery validate form that submits via AJAX
View ajax-send.js
/*
ajax-send.js - copyright Jake Bellacera (http://jakebellacera.com)
This script uses JQuery & JQuery Validate (https://github.com/jzaefferer/jquery-validation)
For this example, we will have a form named '#ajaxform', you can of course change this to whatever you'd like.
*/
$(function(){
$('#submitbutton').click(function() {
@jakebellacera
jakebellacera / export-vscode-search-to-csv.js
Created Jun 11, 2020
Export VSCode search results to CSV
View export-vscode-search-to-csv.js
const fs = require("fs");
const path = require("path");
const readline = require("readline");
// Constants
const FILENAME_REGEX = /^([^\s+].*?):$/;
const LINE_REGEX = /^\s+(\d+):\s*(.*?)\s*$/;
const escapeString = (str) => `"${str}"`;
const logError = (msg, logType = console.error, code = 1) => {
logType(msg);
@jakebellacera
jakebellacera / multiple-gulp-streams.js
Created May 1, 2015
How to run multiple streams in a single gulp task.
View multiple-gulp-streams.js
var es = require("event-stream");
var gulp = require("gulp");
// Important! If these tasks need to be ran sequentially, then specify the
// task(s) that need to be ran prior to these ones as a dependency.
gulp.task("move-files", function() {
return es.merge([
gulp.src("foo").pipe(gulp.dest("dist/")),
gulp.src("bar").pipe(gulp.dest("dist/")),
gulp.src("baz").pipe(gulp.dest("dist/")),
@jakebellacera
jakebellacera / bootstrap-4-menu-wordpress-filters.md
Last active May 27, 2020
Bootstrap 4 menus in WordPress via filters. No walker needed!
View bootstrap-4-menu-wordpress-filters.md

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(); ?>">
View how-to-install-memcache-on-mamp-2.md

How To Install Memcache on MAMP 2

  1. Install memcached. I'd suggest using homebrew. brew install memcached
  2. Select your desired version of PHP that you'd like to use in MAMP. This dropdown is located in the PHP tab in MAMP PRO.
  3. Visit the Downloads Page on php.net and download the source code. If your release isn't listed, visit the Releases page.
  4. Extract the source into /Applications/MAMP/bin/php/[php version folder]/include/php.
  5. /Applications/MAMP/bin/php/[php version folder]/include/php/configure
  6. /Applications/MAMP/bin/php/[php version folder]/bin/pecl i memcache.
  7. Add extension=memcache.so to your php.ini
    • MAMP Pro: /Applications/MAMP\ Pro/MAMP\ PRO.app/Contents/Resources/php[your php version].ini
You can’t perform that action at this time.