Skip to content

Instantly share code, notes, and snippets.

@jaggy
jaggy / LookupTableBehavior.php
Last active December 24, 2015 03:19
CakePHP look-up table behaviour. Allows the user the `findOrCreate()` rails method≥
<?php
class LookupTableBehavior extends ModelBehavior{
/**
* Finds and returns the data or inserts it to the database
*
* @param Model $model
* @param string $value
* @param string $field
@jaggy
jaggy / sass-config.rb
Created September 27, 2013 23:35
This is the base necessity for scss production in my projects.
project_path = ""
http_path = "/"
css_dir = "webroot/css"
sass_dir = "webroot/scss"
images_dir = "webroot/img"
javascripts_dir = "webroot/js"
http_generated_images_path = "/img"
@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);
@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 / 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 / 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;
}
.col-1
width: 28px
.col-2
width: 56px
.col-3
width: 84px
.col-4
@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 );
@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 / 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