Skip to content

Instantly share code, notes, and snippets.

View BlaM's full-sized avatar

Dominik Deobald BlaM

View GitHub Profile
@BlaM
BlaM / uuidv4.js
Created October 10, 2018 10:05
UUID V4
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function jsonp(u,d,cb){
var rndKey = 'c' + Math.round(Date.now()) + '_' + jsonp.length;
jsonp.cb[rndKey] = function(data) {
cb(data);
}
d.callback = 'jsonp.cb.' + rndKey;
var p = [];
for (var e in d) {
if (d.hasOwnProperty(e)) {
p.push(encodeURIComponent(e) + '=' + encodeURIComponent(d[e]));
@BlaM
BlaM / showTwitterUserId.user.js
Created June 19, 2018 11:32
TamperMonkey - show Twitter User-IDs
// ==UserScript==
// @name Twitter UserID
// @namespace http://tampermonkey.net/
// @version 0.1
// @description show Twitter User-IDs
// @author You
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
@BlaM
BlaM / cookiebanner-go-away.user.js
Last active May 4, 2025 07:00
Get rid of EU Cookie Banners (Tampermonkey)
// ==UserScript==
// @name Get rid of EU Cookie Banners
// @namespace http://blog.deobald.org/
// @description Get rid of EU Cookie Banners
// @license http://creativecommons.org/licenses/by-nc-sa/3.0/
// @downloadURL https://gist.githubusercontent.com/BlaM/6d826d6e9d77d2d77bf9a92fdad55788/raw/cookiebanner-go-away.user.js
// @homepage https://gist.github.com/BlaM/6d826d6e9d77d2d77bf9a92fdad55788
// @version 0.3.4
// @author Dominik Deobald
// @match http*://*/*
@BlaM
BlaM / hiddenByOverflow.js
Created May 28, 2018 10:23
Detect if a DOM node is hidden by "overflow: hidden" on a parent node
function hiddenByOverflow(node) {
var parent = node.parentNode;
var visible = true;
var nodeRect = node.getBoundingClientRect();
var parentRect = null, parentStyle = null, errcount = 0;;
while (parent && visible && errcount < 10) {
try {
parentRect = parent.getBoundingClientRect();
@BlaM
BlaM / MicroMustache.js
Last active April 10, 2018 11:50
Micro Mustache JavaScript Function
function Mustache(template, placeholders) {
function isDef(x) { return typeof placeholders[key] === 'undefined'; }
var __tmpElement = document.createElement('span');
function htmlencode(x) { __tmpElement.innerText = x; return __tmpElement.innerHTML; }
function getValue(key) {
var obj = placeholders, keys;
try {
var autoset = null;
var isMoved = false;
$(document).on('mouseup', function() {
autoset = null;
isMoved = false;
});
$('#campaign-list').on('mousedown', 'input[type=checkbox]', function(e) {
autoset = !$(this).prop('checked');
$(this).prop('checked', autoset);
});
@BlaM
BlaM / url.php
Last active March 23, 2017 14:06
<?php
// $Id: URL.php,v 1.6.1 2003/07/15 23:38:15 k1m Exp $
// +----------------------------------------------------------------------+
// | URL Class 0.3.3 |
// +----------------------------------------------------------------------+
// | Author: Keyvan Minoukadeh - [email protected] - http://www.keyvan.net |
// | Contributor: Dominik Deobald - [email protected] |
// +----------------------------------------------------------------------+
// | PHP class for handling URLs |
// +----------------------------------------------------------------------+
@BlaM
BlaM / to-days.php
Created March 23, 2017 13:07
PHP implementation of mysql's TO_DAYS() and FROM_DAYS() functions
<?php
function TO_DAYS($date) {
if (is_numeric($date)) {
$res = 719528 + (int) ($date / 86400);
} else {
$TZ = date_default_timezone_get();
date_default_timezone_set('UTC');
$res = 719528 + (int) (strtotime($date) / 86400);
date_default_timezone_set($TZ);
@BlaM
BlaM / minify-html.php
Created March 23, 2017 13:05
Some old PHP code I use to minify HTML code.
<?php
function ob_end_flush_minified() {
$content = ob_get_contents();
ob_end_clean();
$content = minify_html($content);
echo $content;
}