Skip to content

Instantly share code, notes, and snippets.

View Quaese's full-sized avatar

Quaese

  • Javascript and Frontend Developer
  • Jena (Germany, Thuringia)
View GitHub Profile
@Quaese
Quaese / get_events.js
Last active December 24, 2015 07:16
Events eines Elements mit jQuery ermitteln
// http://stackoverflow.com/questions/2388030/accessing-functions-bound-to-event-handlers-with-jquery
// obj is an jQuery object, e.g.
var obj = $('body');
// jQuery < 1.8
obj.data('events');
// jQuery >= 1.8
$._data(obj[0], "events")
@Quaese
Quaese / vertical-align.css
Last active September 28, 2016 08:42
CSS3 - Elemente vertikal zentrieren
.vertical-align-class {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
@Quaese
Quaese / blob_to_file.html
Created December 8, 2016 16:55
Blob to File (from dataURL string)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blob to File (from DataURL-String)</title>
<script>
window.onload = function () {
var file,
@Quaese
Quaese / dataURL_to_blob_to_file.html
Created December 8, 2016 19:16
dataURL to Blob to File
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>DataURL to Blob to File (from DataURL-String)</title>
<script>
window.onload = function () {
var dataURL = 'data:image/gif;base64,R0lGODlhGAAYAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGx4eHh8fHyAgICEhISIiIiMjIyQkJCYmJicnJygoKCkpKSsrKywsLC4uLi8vLzAwMDIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD4+Pj8/P0BAQEREREVFRUZGRkhISElJSUpKSktLS01NTVBQUFJSUlRUVFZWVlhYWFlZWVtbW19fX2BgYGJiYmNjY2VlZWdnZ2lpaWtra2xsbG5ubnFxcXh4eHp6eoeHh4iIiImJiYyMjI6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJeXl5ubm5ycnJ6enp+fn6CgoKKioqWlpampqa2trbm5ub+/v8DAwMbGxsvLy8/Pz9TU1Nzc3OHh4ebm5szMzBISEh0dHSUlJSoqKi0tLUJCQkdHR1NTU1dXV1paWl1dXV5eXmRkZGpqanl5eXt7e319fYCAgIGBgYODg4aGhoqKiouLi42NjZ2dnaGhoaurq66urq+vr7GxsbS0tLq6ur29vefn5/Dw8PX19fr6+jExMT09PUNDQ21tbW9vb3BwcHJycnV1dXZ2dnd3d6ampqioqKysrLa2tr6+vtHR0ejo6O/v71FRUWhoaLu7u83NzdXV1RwcHIWFhbCwsLW1tbi4uE9PT5qamuXl5QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@Quaese
Quaese / jquery.deferred.js
Created February 8, 2017 06:42
Simple example for jQuery's Deferred object
(function($) {
var testAsyncDeferred = function() {
// create Deferred object
var deferredObject = $.Deferred();
setTimeout(function() {
var date = new Date().getTime();
if (date % 2 === 0) {
// resolve deferred => .done is executed
@Quaese
Quaese / preloader.js
Last active September 14, 2017 14:05
Native Image Preloader
(function() {
// extend object prototype
if (Object.extend === undefined) {
Object.prototype.extend = function(obj) {
var _key;
for (_key in obj) {
if (obj.hasOwnProperty(_key)) {
this[_key] = obj[_key];
}
.flexbox-vertical {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/* prefixed */
/*
.flexbox-vertical {
@Quaese
Quaese / is_object.js
Created March 28, 2018 07:00
isObject (Test, ob es sich um ein Objekt handelt)
// Test, ob es sich beim Argument tatsächlich um ein Objekt handelt
var isObject = function (obj) {
return obj === Object(obj);
}
/*
isObject(object1.d)
// true
isObject('horst')
@Quaese
Quaese / async_defer.md
Last active April 8, 2018 07:24
async und defer

async und defer

Beispiele

  1. <script src="/plugins.js" async></script>
  2. <script src="/plugins.js" defer></script>
  3. <script src="/plugins.js" defer async></script>

async und defer

  • Scripts beginnen unmittelbar mit dem Ladevorgang und zwar ohne die weitere Abarbeitung des HTML-Codes zu blockieren oder auf Fertigstellung des Ladevorgangs zu warten
@Quaese
Quaese / array_methods.js
Created April 10, 2018 05:58
Array methods
// Array.reduce
// convert array to object
["a", "b", "c"].reduce((acc, val, index) => {acc[index] = val; return acc}, {})
// {0: "a", 1: "b", 2: "c"}
["a", "b", "c"].reduce((acc, val, index) => {acc[val] = index; return acc}, {})
// {a: 0, b: 1, c: 2}