Skip to content

Instantly share code, notes, and snippets.

@jaggy
jaggy / ParseShell.php
Created February 12, 2014 05:26
Parse the PHPUnit watcher with the --testdox parameter and colorize the output
<?php
class ParseShell extends AppShell
{
function main()
{
$this->stdout->styles( 'pass', [ 'text' => 'green' ] );
$this->stdout->styles( 'fail', [ 'text' => 'red' ] );
@jaggy
jaggy / watch.rb
Last active August 29, 2015 13:56
Autorun PHPSpec with Observr [ https://github.com/kevinburke/observr ]
def run_phpspec
file = nil
unless ARGV[1].nil?
file = "spec/#{ARGV[1]}Spec.php"
end
command = "`which phpspec` run --format=pretty --no-code-generation -vv #{file}";
@jaggy
jaggy / barcode.sh
Created February 9, 2014 01:00
Generate a barcode from a string
#!/usr/bin/env bash
set -o errexit
set -o pipefail
filename=$1
string=$2
barcode -E -b "${string}" -o ${filename}.eps
convert ${filename}.eps ${filename}.jpg
@jaggy
jaggy / parallax.js
Last active August 29, 2015 13:55
Delay the element on scroll
$.fn.parallax = function( options ) {
if ( typeof options.opacity === 'undefined' ) options.opacity = false;
if ( typeof options.resistance === 'undefined' ) options.resistance = 1;
// determine the direction of the parallax thingy
if ( typeof options.inverse === 'undefined' ) options.inverse = true;
var element = $( this );
@jaggy
jaggy / sticky.js
Last active August 29, 2015 13:55
Just a snippet to make a bar fixed with a given breakpoint and lower element to adjust
$.fn.sticky = function( options ){
console.error( options );
var element = $( this );
var breakpoint = options.breakpoint;
var container = $( options.container );
.col-1
width: 28px
.col-2
width: 56px
.col-3
width: 84px
.col-4
@jaggy
jaggy / boilerplate.css
Last active December 31, 2015 02:58
My initial template for stylesheets.
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
}
@jaggy
jaggy / snapshot.php
Last active December 30, 2015 16:18
#!/usr/local/php5/bin/php
<?php
function testConnection()
{
$connected = @fsockopen("www.google.com", 80);
$response = false;
if ($connected) {
@jaggy
jaggy / gifify.sh
Created November 25, 2013 03:24
GIF-ify a video
#/bin/bash
FILE=$1
if [ -d /tmp/gifify ] mkdir /tmp/gifify
ffmpeg -i $FILE -r 10 -f image2 /tmp/gifify/%03d.png
convert -delay 1x10 `seq -f /tmp/gifify/%03g.png 1 13` -coalesce -layers OptimizeTransparency animation.gif
rm /tmp/gifify/*.png
@jaggy
jaggy / foundation-awesome.js
Created September 28, 2013 21:29
Snippet to make the Foundation 4 custom forms to work.
wrapSelects = function() {
$('form.awesome select:not(.is-wrapped)')
.addClass('is-wrapped')
.wrap('<div class="custom dropdown select" />')
.after('<span class="selector"></span>');
}
$(wrapSelects);