Skip to content

Instantly share code, notes, and snippets.

@feeela
feeela / function.passwordHash.php
Created November 7, 2013 14:33
passwordHash() – generate salted passwords Simple password hashing function without recursion using a salt, that is stored together with the password.
/**
* Generate salted password, using new salt or exiting one from the password itself.
*
* @param string $plainTextPassword
* @param string $salt default = NULL (create new salt)
* @param int $saltLength default = 9 (the salt is the first X chars of the password hash)
* @return string password-hash
*/
function passwordHash( $plainTextPassword, $salt = null, $saltLength = 9 )
{
@feeela
feeela / multilanguage-citation-quotes.css
Created November 7, 2013 14:37
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.
: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; }
@feeela
feeela / function.wrap-scripts-and-styles-into-cdata.php
Last active August 21, 2018 15:28
Add CDATA to script- and style-tags via regex using PHPs output buffering
<?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 / change-magento-host.sql
Last active December 27, 2015 16:39
change the Magento host (e.g. after moving the shop to another domain)
-- 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 / php.ini
Created November 7, 2013 16:39
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())
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.func_overload = 7
@feeela
feeela / label-hover-focus.htm
Last active December 28, 2015 05:48
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`.
<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
SELECT `COL1`, `COL2`, `COL3`, `COL4`
FROM `TABLENAME`
INTO OUTFILE '/tmp/export.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
<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;
@feeela
feeela / component-animations.less
Created June 6, 2014 09:17
CSS slide classes for Twitter Bootstrap
/* 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" );
@feeela
feeela / recursivePromiseWithDelay.js
Last active December 4, 2023 16:20
Recursive JS promises with delay
#!/usr/bin/nodejs
var Promise = require( 'promise' );
/**
*
* @param {Array} list
* @param {int} delay
*/
function recursivePromiseWithDelay( list, delay ) {