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 / script.js
Last active August 29, 2015 14:14
jQuery Autoscroll on hashed links
// Auto scroll
// -------------------------------------
$('a[href^=#]').on('click', function(e) {
e.preventDefault();
var $this = $(this),
target = $this.attr('href');
if(target && target !== "#") {
$('html, body').animate({
@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
@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 / 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 / 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 / _center-vertical.scss
Last active January 7, 2016 14:58
Centering the unknown
// Center a block element width unknown
// height and width horizontally and vertically
// If it doesn't center vertically, play with the spacing.
// <div class="parent">
// <div class="child">....</div>
// </div>
//
// .parent {
// ... your styles here....
// text-align:center; // if you need horizontally spacing
@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 / _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 / _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 / homestead-base-setup.md
Last active February 19, 2020 10:36
Homestead Base Setup

Timezone

  1. Check your current timezone with date in the command line. You should get something like this. Fri Oct 3 10.32:13 UTC 2014 where UTC is your current timezone.
  2. To change your timezone just run sudo dpkg-reconfigure tzdata and follow the instructions. Easy!
  3. Check the timezone again with date. Now your timezone should be in this example CEST

Locale

Homestead provides an Ubuntu System and has by default only english locales installed. In PHP locales are important if you work for example with strftime. Check the currently installed locales with locale -a. To add a new locale, you have to generate it. For example for a german locale enter sudo locale-gen de_DE.UTF-8