Skip to content

Instantly share code, notes, and snippets.

View pwartbichler's full-sized avatar
🎯
Focusing

Patrik Wartbichler pwartbichler

🎯
Focusing
View GitHub Profile
@pwartbichler
pwartbichler / servertime.js
Last active August 14, 2019 08:08
Get correct server time and make a moment js object for further procedures
import moment from 'moment';
import 'moment/locale/de';
moment().locale(window.config.app.locale);
moment.defaultFormat = window.config.app.dateFormat;
const getServerTime = async () => {
const response = await fetch(window.location, {
method: 'HEAD'
});
@pwartbichler
pwartbichler / .htaccess
Created March 13, 2019 09:59
Header-Einstellungen für Cross-Origin-Requests
# ERLAUBTE_URL = foo.com (zB)
<IfModule mod_headers.c>
SetEnvIf Origin "^(http(s)?://(www\.)?(ERLAUBTE_URL))$" ORIGIN_SUB_DOMAIN=$1
Header set Access-Control-Allow-Origin: "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN
</IfModule>
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = '/static/css/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if ( el.addEventListener ) {
el.addEventListener(ev, callback, false);
} else if ( el.attachEvent ) {
@pwartbichler
pwartbichler / action.php
Last active August 29, 2015 13:58
Fileupload via Asset::create()
<?php
if ( $_FILES["fileupload"] ) {
$folder = Asset_Folder::getByPath("/uploads");
$asset = Asset::create(
$folder->getId(),
array(
"filename" => uniqid() . $_FILES["fileupload"]["name"],
"data" => file_get_contents($_FILES["fileupload"]["tmp_name"])
)
@pwartbichler
pwartbichler / tables.css
Created November 12, 2013 09:05
Globales Tabellenstyling via Bootstrap
table {
border-collapse: collapse;
border-spacing: 0;
max-width: 100%;
background-color: transparent;
width: 100%;
margin-bottom: 20px;
}
table > thead > tr > th,
@pwartbichler
pwartbichler / checkboxes.css
Last active December 22, 2015 23:49
CSS Styling for Checkboxes/Radio Buttons, works for IE9+ Look at the example: http://jsbin.com/AQoVENa/5/edit?html,css,output
input[type="checkbox"] {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
}
@pwartbichler
pwartbichler / Object.keys for IE8
Created August 19, 2013 12:07
Object.keys does not exist in IE8. This is a workaround.
Object.keys = Object.keys || (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
DontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
@pwartbichler
pwartbichler / getObjSize
Created July 29, 2013 13:00
Counts the length of the key-value entries of an object
getObjSize: function(obj) {
var size = 0, key;
for ( key in obj ) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
}