Skip to content

Instantly share code, notes, and snippets.

View danielsneijers's full-sized avatar

Dan Sneijers danielsneijers

View GitHub Profile
@danielsneijers
danielsneijers / sw.js
Created December 20, 2018 08:20 — forked from ireade/sw.js
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}

Keybase proof

I hereby claim:

  • I am danielsneijers on github.
  • I am furryrobot (https://keybase.io/furryrobot) on keybase.
  • I have a public key ASDhqLqfVEpelarNq7RZt8KpmduxgbSd2HlvLtfk0-0Pjwo

To claim this, I am signing this object:

@danielsneijers
danielsneijers / youtube
Last active August 29, 2015 14:03
Youtube on-demand loading of videos
<!-- credit to Amit Agarwal for sharing this on http://ctrlq.org/code/19452-embed-youtube-with-javascript -->
<!-- You can embed multiple Youtube videos on a page -->
<div class="youtube" id="LcIytqkbdlo" style="width:560px; height: 315px;">
</div>
<div class="youtube" id="_Jmisv1Spck" style="width:560px; height: 315px;">
</div>
<!-- Include the JavaScript only once -->
@danielsneijers
danielsneijers / add-admin-bar-item.php
Created January 8, 2013 12:20
Add an item to the Wordpress admin bar. Useful for quick links to settings!
<?php
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'parent' => false, // use 'false' for a root menu, or pass the ID of the parent menu
'id' => 'cache_settings', // link ID, defaults to a sanitized title value
'title' => __('Cache Settings'), // link title
'href' => admin_url( 'options-general.php?page=wpsupercache'), // name of file
'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
));
@danielsneijers
danielsneijers / grayscale-class.css
Last active December 10, 2015 19:48
Usefull class to make images grayscale with css. And cross browser compatibility!
img.grayscale {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
}