Skip to content

Instantly share code, notes, and snippets.

@michaelesmith
michaelesmith / git-log2json.sh
Created May 12, 2017 19:06 — forked from textarcana/git-log2json.sh
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features :)
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@michaelesmith
michaelesmith / gist:ffd978f2f13d191418107a6a97918cfb
Created May 3, 2017 18:21 — forked from javiereguiluz/gist:a5514ec6cde2a63be441
How to add a deprecation note about Symfony features

In order to generate and log a warning message about a deprecated Symfony feature, use the trigger_error() function as follows:

trigger_error('The enctype method of the form helper was removed. You should use the new method start instead.', E_USER_DEPRECATED);

Please, be as explicit as possible in the deprecation message and always explain the alternative way to use that feature, property, method or class.

@michaelesmith
michaelesmith / README.md
Created April 1, 2017 02:21 — forked from brunogaspar/README.md
Install wkhtmltopdf on Ubuntu 14.04 64-bit

Install wkhtmltopdf on Ubuntu

This was tested on:

  • Ubuntu 14.04 x64
  • Ubuntu 16.04 x64

Step 1

Install the xvfb server by running

html { transition: transform 1s ease-out; }
html:hover { transform: rotate(360deg); }
html { transform: scaleX(-1); }
Actually, you don't need to do that. GitHub provides a special pulls remote "namespace" on the upstream repo, so you can add it as a fetch pattern to your .git/config like so:
[remote "upstream"]
url = https://github.com/neovim/neovim.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull/*/head:refs/pull/upstream/*
Then when you `git fetch --all`, you will have ALL pull requests available in your local repo in the local pull/ namespace. To check out PR #42:
git checkout -b foo refs/pull/upstream/42
@michaelesmith
michaelesmith / gist:ee1d82d09e1d28d2c314
Last active August 29, 2015 14:06
Retry a network app max tries and wait
n=0
until [ $n -ge 5 ] || ./symfony syn:cams-import --force --quiet; do
echo Tansfer disrupted, retrying...
n=$[$n+1]
sleep 120
done
if [ $? -eq 0 ]
then
echo Command completed successfully
[alias]
co = checkout
ec = config --global -e
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
cob = checkout -b
cm = !git add -A && git commit -m
save = !git add -A && git commit -m 'SAVEPOINT'
wip = !git add -u && git commit -m "WIP"
undo = reset HEAD~1 --mixed
amend = commit -a --amend
@michaelesmith
michaelesmith / form_collection.js
Last active August 29, 2015 14:03
Symfony2 Form Collection Script
jQuery(document).ready(function() {
$("ul.collection").each(function(index, collection){
var prototype = $(collection).find(".item.prototype").remove().removeClass('hidden');
$(collection).data('prototype', prototype.prop('outerHTML'));
});
$("body").on('click', "ul.collection .add", function(e){
e.preventDefault();
var collection = $(this).parents("ul.collection");
<?php
class FeatureContext extends MinkContext {
/**
* Take screenshot when step fails. Works only with Selenium2Driver.
* Screenshot is saved at [Date]/[Feature]/[Scenario]/[Step].jpg
*
* @AfterStep
*/
#/etc/init/logstash.conf
description "logstash collector server"
#start on runlevel [5]
#stop on runlevel [!5]
# tell upstart we're creating a daemon
# upstart manages PID creation for you.
expect fork
respawn