Skip to content

Instantly share code, notes, and snippets.

View LukasGrebe's full-sized avatar

Lukas Grebe LukasGrebe

View GitHub Profile
@LukasGrebe
LukasGrebe / getQueryVariable.js
Last active February 17, 2016 09:34 — forked from reifman/Parse query string via javascript
Return the first value of a specified Querystring (location.search) field (variable). Handels '=','+' and URIComponent encoding
function getQueryVariable(variable) {
var query = window.location.search.replace("?", "");
for (var vars = query.split("&"), i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (decodeURIComponent(pair[0]).replace("+", " ") == variable) {
return decodeURIComponent(pair.slice(1).join("=")).replace("+", " ");
}
}
return void 0
}
@LukasGrebe
LukasGrebe / qr-code current page.js
Created February 28, 2014 16:18
Show a qr code for the current URL
window.location = 'https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl='+encodeURIComponent(window.location);
@LukasGrebe
LukasGrebe / performancestatistics.js
Created May 8, 2014 10:58
Performance Statistics
/* performancestatistics.js
*
* Calculate a series of timings from window.performance this will be one datapoint
* Save datapoint by location path & search to JSONfied array in local storage
* Take all datapoints, calculate mean & std. deviation, push to console
*
* Result: running this snippet after each "cach cleared" pageload, will give some simple
* Statistics on Pageload time
*/
@LukasGrebe
LukasGrebe / KVB QR to json.php
Last active August 29, 2015 14:02
KVB Stationen Parsen
<?php
function table2vehiclesJson($htmlResultTable)
{
$search = array();
$replace = array();
//Enclosing
$search[] = '/<table[^>]+><tr[^>]+>/';$replace[] = '[{';
$search[] = '/<\/tr[^>]*><\/table[^>]*>/';$replace[] = '}]';
@LukasGrebe
LukasGrebe / getNavigationTimings.js
Created December 10, 2014 14:55
Function to gather Navigation Timings reverse engeneered from Google Analytics' analytics.js
/**
* Function to gather Navigation Timings
* reverse engeneered from Google Analytics' analytics.js
*
* @param {Object} t The Object into wich the gathered Timings are Saved
* @param {Object} O The Useragent's window object from wich to gather O.performance Timings
* @return {Boolean} Returns True on success
*/
function getNavigationTimings(t, O) {
var b = O.performance || O.webkitPerformance, n = b && b.navigation, b = b && b.timing;
@LukasGrebe
LukasGrebe / sparhandy.de_TotalPrice.js
Last active October 27, 2017 11:21
Extracts Tarif Name, included Data, prices and fees, and creates a simple tab-seperated String to be copied to the keyboard, for further use in any spreadsheed application
copy($$('.filter-content .product-box').map(box=>[
box.querySelector('.product-box-header').innerText.trim(), //Tarif Name
box.innerText.match(/(\d+)\s+GB/)?box.innerText.match(/(\d+)\s+GB/)[1]:0 //{digits} GB Data
].concat(box.querySelector('.product-prices').innerText.match(/\d?.?\d{0,3}\,\d\d/g) //any prices (Device downpayment, monthly fees ect.)
).join("\t") // Tabseperated columns
).join("\n") //join rows by newline
)//copy to clipboard
@LukasGrebe
LukasGrebe / affiliateLinks.js
Created February 8, 2015 11:29
Create tracked etracker Links
@LukasGrebe
LukasGrebe / Confluence - Old pages.xml
Created October 26, 2016 08:04
Confluence - Macro of Pages not Modified for 6 months
<ac:structured-macro ac:macro-id="daee8bfc-97a3-4286-b145-ad544b8ace89" ac:name="contentbylabel" ac:schema-version="3">
<ac:parameter ac:name="max">200</ac:parameter>
<ac:parameter ac:name="showSpace">false</ac:parameter>
<ac:parameter ac:name="sort">modified</ac:parameter>
<ac:parameter ac:name="title">Seit 6 Monaten unbearbeitete Seiten</ac:parameter>
<ac:parameter ac:name="excerptType">simple</ac:parameter>
<ac:parameter ac:name="cql">space = "SPACE" and lastmodified &lt;= now('-6m') and type="page"</ac:parameter>
</ac:structured-macro>
@LukasGrebe
LukasGrebe / script.js
Last active January 8, 2019 20:26
Filter bda-bund.de architects by Zip and website
$$('.architect-item').filter(
//match first two zip digits, call node.remove() for non matches
(elm)=>["50","51","53"].indexOf(elm.innerText.match(/\s*(\d\d)\d{3,3}\s*\w+/)[1])>0?true:elm.remove()
).map(elm=>elm.querySelector(':not(a[href^="http"])')).forEach(elm=>elm.remove()) // remove elms that dont have an http a node
@LukasGrebe
LukasGrebe / Clean Chefkoch.user.js
Created January 10, 2019 12:07
Clean Chefkoch
// ==UserScript==
// @name Clean Chefkoch
// @namespace http://tampermonkey.net/
// @version 0.1
// @description remove some elements i never use
// @author Lukas Grebe
// @match https://www.chefkoch.de/rezepte/*
// @grant none
// ==/UserScript==