Skip to content

Instantly share code, notes, and snippets.

@feeela
feeela / app.js
Last active Oct 8, 2015
Require.js: use app.js?... cache-busting URL parameter for loaded modules
View app.js
(function( libFileName ) {
var scripts = document.getElementsByTagName( 'script' ),
i, src, parts, len = scripts.length;
for( i = 0; i < len; i++ ) {
src = scripts[i].src;
if( src.indexOf( libFileName ) != -1 ) {
parts = src.split( '?' );
if( parts[1] ) {
/* set requiresjs config */
@feeela
feeela / recursivePromiseWithDelay.js
Last active Jul 13, 2021
Recursive JS promises with delay
View recursivePromiseWithDelay.js
#!/usr/bin/nodejs
var Promise = require( 'promise' );
/**
*
* @param {Array} list
* @param {int} delay
*/
function recursivePromiseWithDelay( list, delay ) {
@feeela
feeela / component-animations.less
Created Jun 6, 2014
CSS slide classes for Twitter Bootstrap
View component-animations.less
/* The slide mixin.
*
* It makes use of Twitter Bootstrap mixins, but those
* are mostly in use for browser compatibility and could
* be rewritten without a TB dependency.
*/
.slide(@distance: 100%, @direction: right) {
.transition-transform( ~"500ms ease-out" );
View pure CSS, accessable, tabbed content
<style>
dl.tabs {
position: relative;
width: 50%;
}
dl.tabs dt {
display: inline-block;
cursor: pointer;
border-bottom: 1px dashed transparent;
transition: border-bottom-color .5s linear;
View export-into-csv-file.sql
SELECT `COL1`, `COL2`, `COL3`, `COL4`
FROM `TABLENAME`
INTO OUTFILE '/tmp/export.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
@feeela
feeela / label-hover-focus.htm
Last active Dec 28, 2015
Set focus to an input when hovering the assigned label using plain JS. If you need IE8 support, you'll have to include a polyfill for `forEach`.
View label-hover-focus.htm
<form>
<label for="test1" data-hover-focus>Test 1</label>
<input type="search" id="test1" /><br />
<label for="test2" data-hover-focus>Test 2</label>
<input type="search" id="test2" />
</form>
<script>
var hoverLabels = document.querySelectorAll( 'label[data-hover-focus]' );
for( var i = 0, len = hoverLabels.length; i < len; i++ ) {
if( hoverLabels[i].control ) { // make sure this is a label with an assigned input
@feeela
feeela / php.ini
Created Nov 7, 2013
using PHP string functions as multibyte functions; following mbstring-variables should be set via php.ini or vhost-configuration (httpd.conf; doesn't work per directory [via .htaccess]) to let the normal string functions (e.g. strpos()) works as if they were a mb_* string function (e.g. mb_strpos())
View php.ini
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.func_overload = 7
@feeela
feeela / change-magento-host.sql
Last active Dec 27, 2015
change the Magento host (e.g. after moving the shop to another domain)
View change-magento-host.sql
-- move Magento to another server
SET @shop_domain = 'SOME_VHOST.local.de/',
@secure_protocol = 'https://'; -- set to 'http://' if no certificate is available
UPDATE `core_config_data` SET `value` = CONCAT('http://', @shop_domain, '/') WHERE `path` = 'web/unsecure/base_url';
UPDATE `core_config_data` SET `value` = CONCAT(@secure_protocol, @shop_domain, '/') WHERE `path` = 'web/secure/base_url';
UPDATE `core_config_data` SET `value` = CONCAT('http://', @shop_domain, '/media/') WHERE `path` = 'web/unsecure/base_media_url';
UPDATE `core_config_data` SET `value` = CONCAT(@secure_protocol, @shop_domain, '/media/') WHERE `path` = 'web/secure/base_media_url';
UPDATE `core_config_data` SET `value` = @shop_domain WHERE `path` = 'web/cookie/cookie_domain';
@feeela
feeela / function.wrap-scripts-and-styles-into-cdata.php
Last active Aug 21, 2018
Add CDATA to script- and style-tags via regex using PHPs output buffering
View function.wrap-scripts-and-styles-into-cdata.php
<?php
/* do this if MIME type is 'application/xhtml+xml' */
ob_start(function ($buffer) {
$replacer = array(
'/(<script[^<>]*>)([^<>]+)(<\/script>)/' => '$1<![CDATA[ $2 ]]>$3',
'/(<style[^<>]*>)([^<>]+)(<\/style>)/' => '$1<![CDATA[ $2 ]]>$3',
/* more replaces may follow, like:
* replace ampersand-characters, which are not part of an entity or within a CDATA-block
@feeela
feeela / multilanguage-citation-quotes.css
Created Nov 7, 2013
Citation Quotes For Different Languages; This snippets includes quotation marks around each , based on the language set in the HTML lang-attribute (e.g. ) and utilizes Unicode points to set the grammar-correct quotation marks.
View multilanguage-citation-quotes.css
:lang(de), :lang(de-de) { quotes: "\201E" "\201C" "\201A" "\2018"; }
:lang(de-fr) { quotes: "\00BB" "\00AB" "\203A" "\2039"; }
:lang(de-ch) { quotes: "\00AB" "\00BB" "\2039" "\203A"; }
:lang(en) { quotes: "\201C" "\201D" "\2018" "\2019"; }
:lang(fr) { quotes: "\00AB\00A0" "\00A0\00BB" "\2039\00A0" "\00A0\203A"; }
q:before { content: open-quote; }
q:after { content: close-quote; }
q q:before { content: open-quote; }
q q:after { content: close-quote; }