Skip to content

Instantly share code, notes, and snippets.

View dominikwilkowski's full-sized avatar
🤖
Working

Dominik Wilkowski dominikwilkowski

🤖
Working
View GitHub Profile
@dominikwilkowski
dominikwilkowski / get-first-image.liquid
Created February 13, 2014 01:36
This snippet takes HTML content from the Shopify editor and parses out the first image in all sizes.
{% comment %}
This snippet takes HTML content from the Shopify editor and parses out the first image in all sizes.
Usage:
{% include 'get-first-image' with page.content %}
Return:
{{ FirstImagePico }}
{{ FirstImageIcon }}
{{ FirstImageThumb }}
@dominikwilkowski
dominikwilkowski / make-image.liquid
Created February 13, 2014 01:52
This snippet lookes at its input string and returns either the input or a fallback image in a specific size, no path though
{% comment %}
This snippet lookes at its input string and returns either the input or a fallback image in a specific size, no path though
Usage:
{% assign newImageSize = "medium" %} (optional)
{% include 'make-image' with imageString %}
Return:
{{ newImageSize }} (either as input or fallback)
@dominikwilkowski
dominikwilkowski / for-looper.liquid
Created February 13, 2014 02:02
This snippet displays "is-first" or "is-last" within a loop for class names
{% comment %}
This snippet displays "is-first" or "is-last" within a loop for class names
Usage:
{% for p in collection.products %}
<li class="{% include 'for-looper' %}"> ... </li>
{% endfor %}
Return:
no return
@dominikwilkowski
dominikwilkowski / gist:8968451
Last active August 29, 2015 13:56
Simple MySQLi abstraction layer into associative array
<?php
/*****************************| MYSQLI CONNECTION FUNCTION |*****************************/
/**
* Simple MySQLi abstraction layer
*
* @param resource $mysqli The MySQLi connection link
* @param string $query The MySQL query for prepaired statement
* @param array $v The parameters to replace ? in $query. First element must be the type
* @param integer $o Option for more debug infos [0]=no infos(default) [1]=adding debug infos
*
@dominikwilkowski
dominikwilkowski / gist:8968459
Last active August 29, 2015 13:56
TINY SYSTEM MESSAGE GATHERER
<?php
/*****************************| SYSTEM MESSAGE FUNCTION |*****************************/
/**
* TINY SYSTEM MESSAGE GATHERER
*
* addMsg($msg,$o)
* @param string $msg Message to be added
* @param int $o Urgency [0](default)=normal [1]=warning [2]=error [3]=no HTML wrapper
*
* getMsg()
@dominikwilkowski
dominikwilkowski / gist:8968469
Last active August 29, 2015 13:56
TINY FILE UPLOAD ABSTRACTION LAYER
<?php
/*****************************| UPLOAD FILES |*****************************/
/**
* TINY FILE UPLOAD ABSTRACTION LAYER
*
* @param object $sysMsg System Message object
* @param string $el Name of _FILE element
* @param string $name Name of new file
* @param string $kind Kind of upload ["image"|"pdf"]
* @param array $dim Dimension of image [0]=width [1]=height
@dominikwilkowski
dominikwilkowski / gist:8968477
Last active August 29, 2015 13:56
TINY STING TO URL CLEANER (Handleizer)
<?php
/*****************************| STRING TO URL |*****************************/
/**
* TINY STING TO URL CLEANER
*
* @param string $t String to be converted
*
* @return string string stripped off of all characters but A-Za-z0-9 and dash, spaces are converted to dash
*/
function makeURL($t) { return strtolower(substr(preg_replace("/[^\w-]+/","",str_replace(" ","-",$t)),0,20)); }
@dominikwilkowski
dominikwilkowski / gist:8968493
Last active August 29, 2015 13:56
TINY TRUNCATE WORD FUNCTION
<?php
/*****************************| TRUNCATE WORDS |*****************************/
/**
* TINY TRUNCATE WORD FUNCTION
*
* @param string $t String to be shortened
* @param int $count Number of words to output
* @param boolen $dots Add dots at the end with string is larger than $count. (optional) [default=true]
*
* @return string of $count words with added dots
@dominikwilkowski
dominikwilkowski / runAdminer.php
Created February 25, 2014 23:01
Run Adminer with custom Session class (in database rather than file system)
<?php
include('php/ini.php'); //get mySQL settings
$SESSIONTAB = 'session'; //table for PHP sessions
/*****************************| MYSQLI CONNECTION FUNCTION |*****************************/
/**
* Simple MySQLi abstraction layer
*
* @param resource $mysqli The MySQLi connection link
* @param string $query The MySQL query for prepaired statement
@dominikwilkowski
dominikwilkowski / gist:68e8ab71952a235eb127
Last active August 29, 2015 14:01
JS animate to auto function
jQuery.fn.animateHeightAuto = function(speed, callback) {
var height;
return this.each(function(i, $element) {
var $this = $( $element );
var heightBackup = $this.css('height');
$this.css({