Skip to content

Instantly share code, notes, and snippets.

View fjarrett's full-sized avatar

Frankie Jarrett fjarrett

View GitHub Profile
@natelandau
natelandau / .bash_profile
Last active April 30, 2024 18:07
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@fjarrett
fjarrett / .bash_profile
Last active September 3, 2017 23:22
Frankie's OS X Bash Profile
# ------------------------------------------------------------
# Set paths
# ------------------------------------------------------------
export PATH=/usr/local/bin:$PATH
export WP_CLI_PHP="/Applications/MAMP/bin/php5.2/bin/php"
# ------------------------------------------------------------
# Add color to the terminal
# ------------------------------------------------------------
export CLICOLOR=1
@fjarrett
fjarrett / gist:3d5095fcfd39b55f639e
Last active August 29, 2015 14:04
Detect and format music chords in a document
<?php
function fjarrett_format_chords( $content ) {
$new_content = null;
$pattern = '/\b[A-G](?:##?|bb?)?(?:min|m)?(?:maj|add|sus|aug|dim)?[0-9]*(?:\/[A-G](?:##?|bb?)?)?(?!\S)/';
// Iterate over each line in the document
foreach ( preg_split( '/((\r?\n)|(\r\n?))/', $content ) as $line ) {
// Find chords on this line
preg_match_all( $pattern, $line, $matches );
@kelvinn
kelvinn / cmd.sh
Created July 24, 2014 02:55
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@jobsamuel
jobsamuel / readme.md
Last active January 19, 2024 18:26
Run NodeJS as a Service on Ubuntu 14.04 LTS

Run NodeJS as a Service on Ubuntu 14.04 LTS

With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?

  • Go to /etc/init/
  • $ sudo vim yourapp.conf
  • Paste script.conf
  • $ sudo start yourapp
  • And when you wanna kill the process $ sudo stop yourapp
@jtsternberg
jtsternberg / db.php
Last active October 20, 2022 19:12
Simplified WordPress DB drop-in replacement for persistent database connections
<?php
/**
* Simplified WordPress DB drop-in replacement for persistent database connections
* (If https://core.trac.wordpress.org/attachment/ticket/31018/31018-2.diff gets into core)
*
* Actual working version right now would look like: https://gist.github.com/jtsternberg/eec4ab95e11ce9be4807
*
* WordPress Trac Ticket {@link https://core.trac.wordpress.org/ticket/31018}
*/
@stelabouras
stelabouras / loadAssetToInstagram.m
Last active March 18, 2021 22:38
Loads a Camera Roll Asset to Instagram (works for both photos & videos)
- (void)loadCameraRollAssetToInstagram:(NSURL*)assetsLibraryURL andMessage:(NSString*)message
{
NSString *escapedString = [assetsLibraryURL.absoluteString urlencodedString];
NSString *escapedCaption = [message urlencodedString];
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@", escapedString, escapedCaption]];
[[UIApplication sharedApplication] openURL:instagramURL];
}
@fjarrett
fjarrett / sample.html
Last active June 13, 2016 16:16
HTML Sample Page Content
<div id="top"></div>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
@fjarrett
fjarrett / unautop-func.php
Last active April 6, 2022 16:57
Inverse behavior to the wpautop() function found in WordPress
<?php
/**
* Replaces paragraph elements with double line-breaks.
*
* This is the inverse behavior of the wpautop() function
* found in WordPress which converts double line-breaks to
* paragraphs. Handy when you want to undo whatever it did.
*
* @see wpautop()
@jimmyrolando
jimmyrolando / Cors.php
Last active October 24, 2020 23:28
Cors/Preflight Middleware for Laravel 5.2
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\Response;
class Cors
{
/**