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 / additional-methods.js
Created August 24, 2012 14:17
RegEx for decimal numbers with 'commas' or 'dots'
/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:(\.|,)\d+)?$/
@maxxscho
maxxscho / widget_base.php
Created October 2, 2012 10:13
WORDPRESS: Widget base structure
<?php
class YourClassName extends WP_Widget {
public function YourClassName()
{
// Widget Options
$widget_ops = array(
'classname' => 'yourclassname',
'description' => 'Your description'
@maxxscho
maxxscho / firstday_of_week.php
Created October 24, 2012 14:37
PHP - Get first day of a given week
$week = 43;
$timestamp = mktime(0, 0 ,0, 1, 1, $this->year) + ($week * 7 * 24 * 60 * 60);
$timestamp_for_monday = $timestamp - 86400 * ( date( 'N', $timestamp) - 1 );
$first_day_of_week = date('d.m.Y', $timestamp_for_monday);
@maxxscho
maxxscho / index.html
Created October 31, 2012 14:02
Responsive embeded video
<!DOCTYPE html>
<!-- Add classes for each IE to the HTML Tag -->
<!--[if lt IE 7 ]><html class="ie ie6 no-js"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7 no-js"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8 no-js"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html class="no-js"> <!--<![endif]-->
<head>
<title>Responsive Video</title>
@maxxscho
maxxscho / safari_legend_margin_fix.less
Created November 7, 2012 13:35
LESS: Safari margin bugfix
// Legend Safari fix
.legend-margin-fix(@selector, @margin) {
(~"@{selector}") {
margin-bottom: @margin;
}
(~"@{selector} + *") {
-webkit-margin-top-collapse: separate;
margin-top: @margin;
}
@maxxscho
maxxscho / target_ie10
Created May 8, 2013 07:54
Target IE10 and add class .ie10 to the HTML Element. IE10 doesn't read conditional comments!!!
if(Function('/*@cc_on return document.documentMode===10@*/')()){
document.documentElement.className+=' ie10';
}
@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 / 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