Skip to content

Instantly share code, notes, and snippets.

@phpfunk
phpfunk / delete-old-branches.php
Last active August 29, 2015 14:23
Delete local branches not on remote
#!/usr/bin/php
<?php
define('REMOTE_NAME', 'jeff');
$branchesToKeep = array(
'cas', 'integration-sdk', 'saml-testing', 'new-authentication'
);
$branchCommands = array(
@phpfunk
phpfunk / mkv2mp4.sh
Last active August 29, 2015 14:10
ffmpeg mkv to mp4
#!/bin/sh
echo -n "MKV File: "
read mkv_file
filename="${mkv_file%.*}.mp4"
ffmpeg -i "$mkv_file" -c:v copy -c:a copy "$filename"
@phpfunk
phpfunk / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@phpfunk
phpfunk / pre-commit
Last active December 10, 2015 12:00
PHP Syntax Check on Git Commit
#!/usr/bin/php
<?php
// Set empty files array
$files = array();
// Get untracked files
// Get modified files
exec('git ls-files --others --exclude-standard', $untracked);
exec('git diff --cached --diff-filter=ACMRTUX --name-only', $modified);
@phpfunk
phpfunk / headers-only.php
Created May 20, 2014 13:48
cURL Headers Only
<?php
$url = 'https://camo.githubusercontent.com/2fae166c7f5cb63b11857915f94a9c094534b7bd/687474703a2f2f636c2e6c792f696d6167652f306c3368316c3079315130392f53637265656e25323053686f74253230323031342d30352d3134253230617425323031302e30302e3436253230414d2e706e67';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD');
@phpfunk
phpfunk / alfred-chrome.applescript
Last active August 29, 2015 14:01
Bypass Tribune Paywall
on alfred_script(q)
tell application "Google Chrome"
execute front window's active tab javascript "jQuery('div[class^=\"control-dialogContainer\"],div.dialog-overlay').remove();jQuery('html').css('overflow','scroll');void(0);"
end tell
end alfred_script
@phpfunk
phpfunk / backup-overview.md
Last active November 28, 2016 17:59
Back That Thang Up (Backing up Your Backups)

So you are making backups? That's good news, but are your backups backed up? As a good rule of thumb I back everything up to a network drive, then that network drive backs up to another drive and is also shipped to Backblaze for an offsite copy. Backblaze doesn't support network drives so I have them hooked up to an older mac mini that I use as a server. Backblaze is only $5/month for unlimited data, so you really can't lose there.

I always mirror my backup internally for when that drive fails and evenutally it will. That way I have a copy to swap out while I get another drive. Backblaze is used for total data loss. If all drives fail or burn up, are stolen, what have you; I will still have my data.

Yes I could use a RAID to mirror

@phpfunk
phpfunk / README.md
Last active December 24, 2015 10:39
Really easy folder action to automatically backup any mobile photos that hit your Dropbox folder.

Really easy folder action to automatically backup any mobile photos that hit your Dropbox folder. You will have to change the data to your liking. All of my network/shared drives in the house are named after hip-hop groups or rappers.

NOTE: You must enable camera uploads for Dropbox and this was only tested and used on a Mac.

  • First you see I create a variable that is the current year and month, that way rsync will keep mobile photos saved in folders by YYYYMM.
  • Then I check if a network drive is already mounted, if not it gets mounted.
  • Next I cd to my DROPBOX Camera Uploads folder.
  • Then rsync to your heart's galore to as many drives as you wish.

In this example I sync to a network drive, then to a local external HDD, then after that remove the source files. This way after my photos are backed up they are removed from Dropbox and I can spare any space at Dropbox. I have this set up as a folder action for the folder set after cd. As soon as Dropbox hits that folder, it mounts the drives, syncs

@phpfunk
phpfunk / alias.sh
Last active May 2, 2017 18:42
A command line PHP script to merge a git branch into multiple other git branches.
### Alias
alias gam='php /path/to/auto-merge.php'
@phpfunk
phpfunk / barley-form.html
Last active December 20, 2015 00:09
A quick sample form that can be used within Barley.
<div id="barley-form">
<input type="hidden" name="to" id="to" value="youremail@yourdomain.com" />
<input type="hidden" name="subject" id="to" value="Contact Form Submission" />
<input type="hidden" name="response_success" id="response_success" value="Thanks, we got it!" />
<input type="hidden" name="response_error" id="response_error" value="Sorry Chap, please try again." />
<div class="row collapse">
<div class="three columns"><label class="inline">Your Name:*</label></div>
<div class="nine columns"><input type="text" id="name" placeholder="Jane Smith (required)" data-required="true" /></div>
</div>