Skip to content

Instantly share code, notes, and snippets.

@albertpark
albertpark / keybase.md
Last active August 29, 2015 14:21
keybase gist

Keybase proof

I hereby claim:

  • I am albertpark on github.
  • I am albertpark (https://keybase.io/albertpark) on keybase.
  • I have a public key whose fingerprint is CCC9 BFCD B7F4 4E35 E303 5055 5E34 5DF2 FCAF 82F7

To claim this, I am signing this object:

@albertpark
albertpark / orlando.geojson
Last active November 5, 2015 16:31
GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<?php
/**
* PHP CLI Colors – PHP Class Command Line Colors (bash)
*
* $str = "This is an example ";
*
* foreach (ColorCLI::$foregroundColors as $fg => $fgCode) {
* echo ColorCLI::$fg($str);
*
* foreach (ColorCLI::$backgroundColors as $bg => $bgCode) {
@albertpark
albertpark / junit.php
Last active November 11, 2015 18:57
Parse JUnit xml log generated by PHPUnit (phpunit ---log-junit build/logs/junit.xml) and print elapsed time each test case. If you want to color time at certain threshold time, get ColorCLI class (see https://gist.github.com/albertpark/985d39b759f356cdbbeb).
<?php
function run($path) {
$xml = simplexml_load_file($path);
$project = $xml->testsuite;
echo sprintf("total: %s msec", formatMsec($project['time'])) . PHP_EOL;
foreach ($project->testsuite as $testsuite) {
echo sprintf(" suite: %s msec : %s", formatMsec($testsuite['time']), $testsuite['name']) . PHP_EOL;
@albertpark
albertpark / pmd.php
Last active November 11, 2015 19:00
Parse pmd.xml generated by PHPMD (phpmd src xml pmd.xml) and print violation messages. If you want to color messages at priority, get ColorCLI class (see https://gist.github.com/albertpark/985d39b759f356cdbbeb).
<?php
function run($path) {
$xml = simplexml_load_file($path);
foreach ($xml->file as $file) {
echo sprintf("file: %s", $file['name']) . PHP_EOL;
foreach ($file->violation as $violation) {
echo " " . printMessage($violation) . PHP_EOL;
echo sprintf(
@albertpark
albertpark / checkstyle.php
Last active November 11, 2015 19:02
Parse checkstyle.xml generated by PHP_CodeSniffer (phpcs --report=checkstyle --report-file=checkstyle.xml src) and print violation messages. If you want to color messages at severity, get ColorCLI class (see https://gist.github.com/albertpark/985d39b759f356cdbbeb).
<?php
function run($path) {
$xml = simplexml_load_file($path);
foreach ($xml->file as $file) {
echo sprintf("file: %s", $file['name']) . PHP_EOL;
foreach ($file->error as $violation) {
echo " " . printMessage($violation) . PHP_EOL;
echo sprintf(

Clone into a Non Empty Directory

Navigate to the desired directory you wish to work on and type the following commands in a terminal.

$ git init
$ git remote add origin PATH_TO_REPOSITORY # i.e. git@github.com:username/repository-name.git
$ git fetch origin
$ git reset origin/master  # Required when the versioned files existed in path before "git init" of this repo.
$ git checkout -t origin/master

Recover Deleted Files in My Local Repository using Git

You can view a list of all the deleted files using the command.

$ git ls-files --deleted

Use this this command to restore your deleted file. Replace the <deleted-file> with the deleted filename.

$ git checkout -- 

SSH Getting Started for a Repository

This guide all started because of the infamous Permission Denied (publickey) when trying to push code to my repository. Before we can start using repositories intensively there are prequisties that we must complete in order to get our work flowing.

We will be using git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. You can also use the default Windows Command Prompt by installing git from git-scm.
Tip: You can use any *nix based command prompt

1. SSH Agent

First thing is first, we must first identify if the ssh-agent is enabled and running properly. If this is not an issue go to step 2.

Linux