Skip to content

Instantly share code, notes, and snippets.

View maxxscho's full-sized avatar
🏠
Working from home

Markus Schober maxxscho

🏠
Working from home
View GitHub Profile
@maxxscho
maxxscho / Vagrantfile
Created March 6, 2014 22:31
Vagrant base setup (for a All-In-One machine on your host system)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network :private_network, ip: "192.168.33.21"
config.vm.provision :shell, :path => "install.sh"
@maxxscho
maxxscho / Vagrantfile
Created March 20, 2014 10:25
Vagrant setup with forwarded port
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.provision :shell, :path => "install.sh"
@maxxscho
maxxscho / RegExTime24h
Created April 18, 2014 10:47
Regular Expression for match a time string in the 24h format (hh:mm)
/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/
@maxxscho
maxxscho / _validateDateDACH.js
Last active August 29, 2015 14:07
jQuery Validate additional validation for dates in the format dd.mm.yyyy
/* Additional method for jquery validate
Valiate dates in the format dd.mm.yyyy
------------------------------------- */
jQuery.validator.addMethod(
"dateDECH",
function(value, element) {
var check = false;
var re = /^\d{1,2}\.\d{1,2}\.\d{4}$/;
if( re.test(value)){
var adata = value.split('.');
@maxxscho
maxxscho / _font-size.scss
Created December 5, 2014 07:52
Font size mixin for rem values with pixel fallback for old browsers
// REM output based on the $em-base variable with pixel fallback
@mixin font-size($pxVal) {
@if not unitless($pxVal) {
$pxVal: strip-unit($pxVal);
}
font-size: $pxVal * 1px;
font-size: rem($pxVal);
}
@maxxscho
maxxscho / _center-block.scss
Created December 5, 2014 09:15
Centers a block element
// Center a block element
@mixin center-block {
display: block;
margin-right: auto;
margin-left: auto;
}
@maxxscho
maxxscho / change-browser-name.js
Created December 11, 2014 13:25
Change browser tab name on blur
window.onblur = function () { document.title = 'you went?'; }
window.onfocus = function () { document.title = 'you came back'; }
@maxxscho
maxxscho / SubmenFirstWalker.php
Created January 5, 2015 09:13
Menu Walker for wordpress, that changes the order of items, which have a submenu. The submenu is first (standard is anchor first)
<?php
/**
* Class SubmenuFirstWalker
* This walker changes the order of elements, if they have a submenu
* Standard is anchor than the submenu. Wth this walker, the submenu gets rendered first.
* There is one new filter 'walker_nav_menu_end_el'
* @author Markus Schober
*/
class SubmenuFirstWalker extends Walker_Nav_Menu {
@maxxscho
maxxscho / passwordGenerator.php
Last active August 29, 2015 14:13
Password generator method
<?php
/**
* Generate Password with a given length and strength
*
* @param int $length
* @param int $strength
* @return string
*/
function generatePassword($length = 9, $strength = 4)
@maxxscho
maxxscho / the_field_if.php
Created January 22, 2015 13:45
Echo a field of Advanced Custom Fields, if it is present. You may prepend and append it with custom strings (HTML ;) )
<?php
/**
* Echo an ACF Field if it is present
* @param bool|int $field Name of the field
* @param string $before prepend the field with this string. HTML for example
* @param string $after append the field with this string. HTML for example
* @param bool|int $post_id
*
* @return bool|void