Skip to content

Instantly share code, notes, and snippets.

View mcamiano's full-sized avatar

Mitch Amiano mcamiano

  • Rolesville, North Carolina, USA
View GitHub Profile
@mcamiano
mcamiano / gitconfig
Last active December 17, 2021 19:55
Some git aliases
[alias]
borkbork = !"git reset-public && (git diff --exit-code >/dev/null) && (git diff --cached --exit-code>/dev/null) && git checkout development && git fetch upstream && git reset --hard upstream/development && git push origin development && git prunebranches && git gl"
resync = borkbork
reset-public = !"rm -r $(git home)/public && git checkout $(git home)/public"
br = branch
co = checkout
hist = log --format='%Cgreen%h%Creset %ad %C(cyan)%an%Creset - %s%C(red)%d%Creset' --graph --date=short
histall = log --all --format='%Cgreen%h%Creset %ad %C(cyan)%an%Creset - %s%C(red)%d%Creset' --graph --date=short
aliases = config --get-regexp ^alias\\.
sdiff = diff --staged
@mcamiano
mcamiano / jest.function.bash
Created August 16, 2019 17:38
Jest command line menu
# Usage: stick it in your .bashrc or other startup file and then
# jest list
# jest [--updateSnapshot] {SomeTestNamePrefix}
# jest [--updateSnapshot]
#
# The list argument presents a selection list, from which you may pick one test to execute.
# The second form runs the tests whose name is a leftmost match to the given prefix.
# The unqualified jest cli executes all tests under ./jest/*
# The --updateSnapshot option will update the html snapshot, which is recommended as a basic regression case for each test.
#
@mcamiano
mcamiano / JsRouteHelper.php
Last active January 24, 2018 14:42
Laravel Javascript Route Helper
<?php
// app/Console/Commands/JsRouteHelper.php
namespace App\Console\Commands;
use Illuminate\Support\Facades\File;
use Illuminate\Routing\Router;
use Illuminate\Console\Command;
/**
* Class JsRouteHelper
@mcamiano
mcamiano / unloadshots.sh
Created November 29, 2015 14:43
Unload photos from flash card, reduce JPGs to roughly HD size, and apply watermarks; requires imagemagick; assumes OSX bash shell environment
#!/bin/bash
if test -f ~/.unloadshots
then
. ~/.unloadshots # Environment
fi
SOURCEMEDIAFOLDER=${UNLOADMEDIAFOLDER:-/Volumes/Untitled/DCIM}
TARGETMEDIAFOLDER=${LOADMEDIAFOLDER:-~/Pictures}
WATERMARK=${LOADWATERMARK:-© 2014 by Mitch C. Amiano}
@mcamiano
mcamiano / libmigrations.sh
Last active August 29, 2015 14:07
SQL migrations with bash
#!/bin/bash
test "$1" = "--rollback" || test "$1" = "down"
export is_rollback="$?"
if ${no_run_libmigrations_twice:-true}
then
no_run_libmigrations_twice=false
if [[ -z "$DATABASE" ]]; then read -p "Database? " DATABASE; fi
@mcamiano
mcamiano / Pfreinds.php
Last active January 19, 2024 20:44
Presenter handshakes to make Pfriendly Pfriends
<?php
class Pfriend {
private $bff="BFF";
private $allowed=array('A','B','C'=>'C');
private $notallowed=array('D','E','F'=>'G');
public function makePfriend(PfriendPresenter $pfriendpresenter) {
@mcamiano
mcamiano / gist:7582370
Last active December 28, 2015 23:58
Eloquent Collection Methods; these are the methods you'd see on a model 1:M or M:M relation.
public Illuminate\Database\Eloquent\Model find( mixed $key
 mixed $default = null )   # Find a model in the collection by key.
public load( )   # Load a set of relationships onto the collection.
public Illuminate\Database\Eloquent\Collection	add( mixed $item )   # Add an item to the collection.
public boolean	contains( mixed $key )   # Determine if a key exists in the collection.
public array	modelKeys( )   # Get the array of primary keys

Methods inherited from Illuminate\Support\Collection

@mcamiano
mcamiano / DebugRoutes.md
Created October 15, 2013 18:19
Laravel roots suddenly blow up
@mcamiano
mcamiano / inflates.html
Created August 4, 2013 22:33
A CSS transition effect to mimic slowly expanding/contracting movie titles.
<style>
hr {
margin-top: 2em;
}
.inflate, .deflate {
font-size: 4em;
width: 50%;
hideborder: solid thin red;
text-align: center;
margin-left: 25%;
@mcamiano
mcamiano / alternative.md
Last active December 20, 2015 14:39
ng-hide and ng-show do not modify the DOM so much as change a class. This attribute directive removes the contained content if the expression evaluates to true.

This is an improved alternative to the occlude directive. Suppose we want the occlude to happen dynamically, when a model changed. The other version of the occlude directive defined here would just be invoked once, at the time the link function is called on an instantiated template. Ideally, model changes should drive such DOM manipulations through watchers.

So let's set up a boolean select box. First some model driving the options in the controller:

  $scope.cfg={};
  $scope.cfg.boolean_options = [ {label: 'True', value:true}, {label: 'False', value:false} ];

  $scope.cfg.include_exclude = true;