Skip to content

Instantly share code, notes, and snippets.

View jakebellacera's full-sized avatar

Jake Bellacera jakebellacera

View GitHub Profile
@jakebellacera
jakebellacera / mamp-mysql2-rbenv.md
Created August 22, 2012 20:29
Instructions on how to use MAMP with the mysql2 gem and Ruby 1.9.3-p194 via rbenv

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 / multi-line-lists-in-markdown.md
Last active April 25, 2022 15:58
How to write multi-line lists in Markdown

Perhaps you're writing an ordered list in markdown and you need to add a list item or two with multiple lines. You try to write it, but your numbers keep resetting! What gives?

What you need to do is add a space after each additional line in a list item.

Quick example

1. Item number one

 Second line in item number one.
@jakebellacera
jakebellacera / userscript-github-pull-request-autofocus.js
Last active November 3, 2021 16:50
Quickly review files in Github pull requests by pressing spacebar on your keyboard with this userscript.
// ==UserScript==
// @name Github Pull Request Autofocus
// @description Helps you quickly review files in Github pull requests.
// @author Jake Bellacera
// @match https://github.com/*/pull/*/files
// ==/UserScript==
// HOW TO USE
// ==========
// 1. Open a Github pull request.
@jakebellacera
jakebellacera / how-to-install-memcache-on-mamp-2.md
Last active July 4, 2021 16:09
How To Install Memcache on MAMP 2

How To Install Memcache on MAMP 2

Note: This is an old guide and may not work for newer versions of macOS. Please see comments below for additional steps.

  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.
@jakebellacera
jakebellacera / ajax-send.js
Created February 22, 2011 19:03
JQuery validate form that submits via AJAX
/*
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 / disable-yoast-seo-automatic-og-image-lookup.php
Last active October 20, 2020 19:27
Force Yoast SEO to show the default open graph image in case a feature image isn't set.
<?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 / multiple-gulp-streams.js
Created May 1, 2015 02:25
How to run multiple streams in a single gulp task.
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 / DiffView.js
Created November 20, 2019 17:41
A component for visualizing diffs on objects
import React from "react";
const groupDiffs = (from, to, parseValue, parseKey) => {
return mergeKeys(from, to).reduce((groups, key) => {
const group = groupFn(key, from[key], to[key]);
const name = parseKey ? parseKey(key) : key;
const from = parseValue ? parseValue(key, from) : from;
const to = parseValue ? parseValue(key, to) : to;
@jakebellacera
jakebellacera / gmail-fluidapp-userscript.js
Last active September 16, 2019 17:08
An updated Fluidapp Userscript for Gmail
// use for patterns:
// *gmail.com*
// *mail.google.com*
// *google.com*mail*
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 15000);
function updateDockBadge() {
@jakebellacera
jakebellacera / floodlight-click-handler.js
Last active June 26, 2019 21:31
Floodlight click handler
document.getElementById("button").addEventListener("click", function(e) {
e.preventDefault();
var url = this.getAttribute("href", 2);
createFloodlightTag("source", "type", "cat", function() {
window.location = url; // Redirect the user after the tag successfully fires
});
});
function createFloodlightTag(source, type, cat, callback) {