Skip to content

Instantly share code, notes, and snippets.

View franzenzenhofer's full-sized avatar

Franz Enzenhofer franzenzenhofer

  • http://www.fullstackoptimization.com/
  • Vienna, Austria
View GitHub Profile
@franzenzenhofer
franzenzenhofer / gist:1881270
Created February 22, 2012 04:10 — forked from endtwist/gist:1630834
Paste event in Google Chrome
$( 'body' ).bind( 'paste', function( evt ) {
var items = evt.originalEvent.clipboardData.items
, paste;
// Items have a "kind" (string, file) and a MIME type
console.log( 'First item "kind":', items[0].kind );
console.log( 'First item MIME type:', items[0].type );
// If a user pastes image data, there are 2 items: the file name (at index 0) and the file (at index 1)
// but if the user pastes plain text or HTML, index 0 is the data with markup and index 1 is the plain, unadorned text.
@franzenzenhofer
franzenzenhofer / get_barcode_from_image.js
Created September 2, 2012 16:00 — forked from tdegrunt/get_barcode_from_image.js
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@franzenzenhofer
franzenzenhofer / seo.user.js
Created September 5, 2012 08:02
greasmonkey / chrome - userscript -shows important SEO head information
// ==UserScript==
// @name shows important SEO head information
// @namespace http://www.facesaerch.com/
// @description show canonical, noindex, nofollow
// @include *
// ==/UserScript==
function trim12 (str) {
var str = str.replace(/^\s\s*/, ''),
ws = /\s/,
@franzenzenhofer
franzenzenhofer / jquery.bodysnatch.js
Created November 10, 2012 16:26
jquery plugin that replaces elements with absolute positioned clones of themselves, while hiding & silencing the originals
(function($){
isString = function (obj) {
return toString.call(obj) == '[object String]';
};
$.fn.bodysnatch = function() {
var collection = this;
return collection.each(function(a,b) {
var element = $(this);
var clone = element.clone();
d = function(msg) { console.log(msg); }
var _css_path_to_autocomplete_ = '#gsr > div.gstl_0.sbdd_a > div:nth-child(2) > div.sbdd_b > div > ul';
var _css_path_to_recommendations_ = '._e4b'; _css_path_to_autocomplete_;//'#brs > div > div:nth-child(1) > p:nth-child(1) > a';//'#brs';//'._e4b';
A = []
var arrayUnique = function(a) {
return a.reduce(function(p, c) {
if (p.indexOf(c) < 0) p.push(c);
_DEBUG_ = false
dlog = (m) -> console.log(m) if _DEBUG_
getFacebook = (u, cb) ->
jQuery.getJSON(
'http://api.facebook.com/restserver.php',
{
format:'json'
method:'links.getStats'
urls: u
@franzenzenhofer
franzenzenhofer / internal-prefetch-hints
Created March 25, 2015 13:05
injecting internal prefetch hints
var allreadyPrefetched = {};
var preFetcher = function(elem) {
if(elem && elem.href && !allreadyPrefetched[elem.href])
{
var hint;
hint = document.createElement("link");
hint.rel = "prefetch";
hint.href = elem.href;
document.head.appendChild(hint);
allreadyPrefetched[elem.href]=true;
var allreadyPrefetched = {};
var preFetcher = function(elem) {
if(elem && elem.href && !allreadyPrefetched[elem.href])
{
var hint;
hint = document.createElement("link");
hint.rel = "prefetch";
hint.href = elem.href;
document.head.appendChild(hint);
allreadyPrefetched[elem.href]=true;
;
window.shop_links_changed = false;
let doTheChange = (cc) =>
{
let o = 'https://shop.veganblatt.com';
let ccs =['AT','DE','CH'];
if(ccs.includes(cc))
var nonCriLoad = function nonCriLoad() {
var rps = document.getElementById('non-critical-css');
if (!(rps.relList && rps.relList.supports && rps.relList.supports("preload"))) {
rps.onload = "";
//rps.rel="stylesheet";
var ncs = document.createElement("link");
ncs.rel = "stylesheet";
ncs.href = rps.href;
rps.appendChild(ncs);