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-image.liquid
Last active August 29, 2015 14:01
Get first image from content
{% comment %}
This snippet gets the first image from the parameter text
Usage:
{% include 'get-image' with page.content %}
Return:
{{ imageSrc }} is the string of the original image
Required:
@dominikwilkowski
dominikwilkowski / shop.js
Last active October 27, 2021 16:12
Convert variant dropdown into swatches, multiple-option-sollution
/**************************************************************| CONVERT VARIANT TO SWATCHES |*/
$(function() {
if($(".single-option-selector").length) {
$(".single-option-selector").each(function(i) {
var $thisSelect = $(this);
var $newClass = "js-option-selector-" + i;
var $newOptions = '<ul class="new-variant-swatchs">';
var $currentOption = $thisSelect.val();
@dominikwilkowski
dominikwilkowski / show-sizes.liquid
Last active August 29, 2015 14:01
Convert variant dropdown into swatches, one-option-sollution
{% comment %}
This snippet displays sizes
Usage:
{% include 'show-sizes' with product %}
Return:
no return
Required:
@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({
@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: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 / 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: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: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: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
*