Skip to content

Instantly share code, notes, and snippets.

View markdrake's full-sized avatar

Marco Patiño markdrake

View GitHub Profile
@markdrake
markdrake / Ignore modified files on git.bash
Last active August 29, 2015 13:56
Ignore changed files to being listed as modified in git. This is really useful if you have to modify a configuration locally but don't want to mess with remote configurations where you could potentially forget and push.
# To ignore a file or dir
git update-index --assume-unchanged <file>
#To revert that ignorance use the following command:
git update-index --no-assume-unchanged <file>

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()
@markdrake
markdrake / karma notifier.sh
Last active August 29, 2015 14:02
This code allows you to run karma and notify every time the console gets an update. This integrates nicely when running vagrant and growl notifications integrated.
karma start karma.conf.js | tee >( xargs -I {} notify-send {})
@markdrake
markdrake / grunt notifier task.js
Last active August 29, 2015 14:02
Grunt notifier task, useful to interact with notify-send in linux and growl in mac os x after grunt is run.
var exec = require('child_process').exec;
var notify = function(message) {
exec('notify-send "' + message + '"');
};
@markdrake
markdrake / ZF2-view-helpers-in-classes.php
Last active August 29, 2015 14:02
How to use a zend framework 2 view helper in any class:
<?php
// This will allow you to use any view helper in any class such as a controller //
// 1. Instantiate the view helper.
// 2. Configure it.
// 3. Use it.
// E.g. Use currency formatter
$currencyFormatter = new CurrencyFormat();
$currencyFormatter->setCurrencyCode('USD');
$currencyFormatter->setLocale('en_US');
@markdrake
markdrake / remove_nulls_in_array.php
Created July 10, 2014 05:06
Code to remove null elements from an array in php with array_filter
<?php
$array = [null, 1, null, 2, 3, 5];
var_dump(array_filter($array));
// This also works for numeric index values, notice how the null value indexes are stripped
$array = [
0 => null,
1 => 22,
2 => null,
3 => 1,
@markdrake
markdrake / notification.php
Created November 21, 2014 18:35
Ejemplo de como crear un correo dentro de un POST de php
<?php // formulario.php
// Para saber a donde apunta el formulario fijate en el atributo action del form:
<form action="server/script.php" name='nombre_formulario'>
</form>
?>
<?php /* server/script.php */ // Aquí es a donde llega el form anterior
if (isset($_POST['nombre_formulario'])) {
#!/usr/bin/env ruby
require 'json'
require 'fileutils'
include FileUtils
# Parses the argument array _args_, according to the pattern _s_, to
# retrieve the single character command line options from it. If _s_ is
# 'xy:' an option '-x' without an option argument is searched, and an
# option '-y foo' with an option argument ('foo').
@markdrake
markdrake / docker_ip
Created April 18, 2015 05:11
Obtain docker container ip
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container-id-or-name>