Skip to content

Instantly share code, notes, and snippets.

View jatubio's full-sized avatar

Juan Antonio Tubio jatubio

View GitHub Profile
@jatubio
jatubio / clonelndir.bat
Last active August 29, 2015 14:23
Clone first level subdirectories to destination using ln.exe
@echo off
setlocal enabledelayedexpansion
SET DestinationDrive=Z
call :source "%~1"
rem echo source set to %source% from %~1
call :destination "%~2" %source%
rem echo destination set to %destination% from %~2 and %source%
@jatubio
jatubio / cdir.bat
Last active August 29, 2015 14:23
Compare directories first level names
@echo off
setlocal enabledelayedexpansion
SET DestinationDrive=Z
SET TotalDuplicated=0
call :source "%~1"
rem echo source set to %source% from %~1
call :destination "%~2" %source%
rem echo destination set to %destination% from %~2 and %source%
@jatubio
jatubio / gitlaravel.bat
Created June 16, 2015 00:08
git post-commit hook to run PHP-CS-Fixer on windows after one commit
@Echo off
REM ADD PHP TO PATH See PHP-CS-Fixer bug on https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/1253
set PATH=%PATH%;"D:\DevApps\PHP5.6.6"
IF "%LARAVEL%"=="1" (
SET LARAVEL=0
echo "End commit of PHP-CS-Fixer"
) ELSE (
SET LARAVEL=1
echo "PHP-CS-Fixer"
"D:\DevApps\PHP5.6.6\php.exe" "%~dp0php-cs-fixer.phar" --verbose fix --config-file=.php_cs
@jatubio
jatubio / prepare-commit-msg
Last active December 30, 2022 07:36
prepare-commit-msg git hook to add branch name to commit message
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
@jatubio
jatubio / .php_cs
Created June 13, 2015 11:51
Config file to pass PHP-CS-Fixer with Laravel 5.1 custom and PSR-2 styles coding
<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
@jatubio
jatubio / helper.php
Created May 24, 2015 18:11
array_change_key_case for stdClass Objects
// Works withs stdClass Objects
static function array_change_key_case($input, $case )
{
$array = array_change_key_case((array)$input, $case );
return (object) $array;
}
@jatubio
jatubio / DatabaseTransactions.php
Last active August 29, 2015 14:21
Laravel 5.1 - Using DatabaseTransactions with custom connections on Testing
<?php namespace JaTubio\Testing;
trait DatabaseTransactions {
protected function getConnectionName()
{
$model = $this->getModel();
if ( null !== $model )
{
@jatubio
jatubio / .gitconfig
Last active January 11, 2022 22:20
Alias to amend and move git tags
### Tags
# Return date of tag. (To use in another alias)
tag-date = "!git show $1 | awk '{ if ($1 == \"Date:\") { print substr($0, index($0,$3)) }}' | tail -2 | head -1 #"
# Show tag message
tag-message = "!git show $1 | awk -v capture=0 '{ if(capture) message=message\"\\n\"$0}; BEGIN {message=\"\"}; { if ($1 == \"Date:\" && length(message)==0 ) {capture=1}; if ($1 == \"commit\" ) {capture=0} }; END { print message }' | sed '$ d' | cat -s #"
# Get hash of tag commit
tag-commit = "!git show $1 | awk '{ if ($1 == \"commit\") { print $2 }}' #"
@jatubio
jatubio / .gitconfig
Created May 20, 2015 22:24
Alias to find files on Git repositories.
### Files
# Find if one file ever had into repository
ff = "!git log --pretty=format: --name-status --all -M -B | sort -u | grep $1 -i #"
# The same as above but showing copied files
ffc = "!git log --pretty=format: --name-status --all -C -M -B | sort -u | grep $1 -i #"
# Show Untracked files on stash
sfu = "!git rev-list -g stash | git rev-list --stdin --max-parents=0 | xargs git show --stat"
@jatubio
jatubio / github-solarized.css
Created May 20, 2015 16:28
GitHub Solarized stylesheet for MarkdownPad
/* GitHub Solarized stylesheet for MarkdownPad (http://markdownpad.com) */
/* Author: Juan Antonio Tubio - jatubio@gmail.com */
/* Source: https://gist.github.com/jatubio/75d85817208972f951ef */
/* RESET
=============================================================================*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;