Skip to content

Instantly share code, notes, and snippets.

View Langmans's full-sized avatar

Langmans Langmans

  • Netherlands
  • 03:36 (UTC +02:00)
View GitHub Profile
@Langmans
Langmans / bootstrap.validator.invisible-elements.js
Last active August 29, 2015 14:13
bootstrap.validator.invisible-elements.js
//autocompress:no
/*!
* Disables invisible (non focusable elements) form fields inside forms while validating.
*
* @author Ruben Vincenten <[email protected]>
* @see https://github.com/1000hz/bootstrap-validator
*/
jQuery(function ($) {
var
dataKey = 'validate.bs.skip',
@Langmans
Langmans / example.js
Last active August 29, 2015 14:14
input type checking (datetime, email, etc)
jQuery(function ($) {
if (!inputsupport('datetime-local')) {
$('[type=datetime-local]').each(function () {
var $input = $(this), placeholder = $input.attr('placeholder');
$input.attr({
type: 'text',
placeholder: this.hasAttribute('placeholder') ? placeholder + ' (JJJJ-MM-DD UU:MM)' : 'JJJJ-MM-DD UU:MM',
pattern: '20\\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]))(T|\\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9])(:([0-5][0-9]))?'
});
});
var textualRatio = (function () {
var
isInteger,
greatestCommonDivisor;
/**
*
* @param value
* @returns {boolean}
*/
@Langmans
Langmans / composer.json
Last active August 29, 2015 14:14
dbal test
{
"require": {
"doctrine/dbal": "~2.5"
}
}
@Langmans
Langmans / language_detection.php
Created February 17, 2015 09:58
detect language with Willdurand\Negotiation and slim framework
<?php
use Negotiation\LanguageNegotiator;
// example array
$languages = array(
1=>array('name'=>'english', 'lang_id'=>'en'),
2=>array('name'=>'dutch', 'lang_id'=>'nl')
);
@Langmans
Langmans / .gitattributes
Last active September 7, 2018 11:57
MWB diff
# if you use git gui/cmd shell...
# *.mwb diff=mwb
<?php
function nl2p($string, $class = '')
{
$class_attr = ($class != '') ? ' class="' . $class . '"' : '';
return '<p' . $class_attr . '>' . preg_replace('#(<br\s*?/?>\s*?){2,}#', '</p>' . "\n" . '<p' . $class_attr . '>', nl2br($string, true)) . '</p>';
}
@Langmans
Langmans / array_insert.php
Created April 29, 2015 11:46
array insert php funciton (insert indexed or associative array into another)
<?php
/**
* @param array $array
* @param string|integer $position numeric key
* @param array $insert_array
* @param string $at
*/
function array_insert(array &$array, $position, array $insert_array, $at = 'after')
{
<?php
function strftime_win32($format, $ts = null) {
if (!$ts) $ts = time();
$mapping = array(
'%C' => sprintf("%02d", date("Y", $ts) / 100),
'%D' => '%m/%d/%y',
'%e' => sprintf("%' 2d", date("j", $ts)),
'%h' => '%b',
jQuery(function ($) {
var sku_fields = '[name^="variable_sku"]',
display_class = 'variation_sku_display',
warning_display = true;
$('body').on('input', sku_fields, function () {
var $input = $(this), sku = this.value,
$variation = $input.closest('.woocommerce_variation'),
$display = $('.' + display_class, $variation);
if (!$display.length) {