Skip to content

Instantly share code, notes, and snippets.

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. [email protected]: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
@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(
@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 / 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;
<?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 / orlando.geojson
Last active November 5, 2015 16:31
GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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: