Skip to content

Instantly share code, notes, and snippets.

View bouveng's full-sized avatar

Johan Bouveng bouveng

View GitHub Profile
@bouveng
bouveng / loadImage.js
Created August 29, 2020 21:42
loadImage.js
export function loadImage(url) {
return new Promise(resolve => {
const image = new Image();
image.addEventListener('load', () => {
resolve(image);
});
image.src = url;
});
}
import Entity from '../Entity.js';
import Trait from '../Trait.js';
import Killable from '../traits/Killable.js';
import {loadSpriteSheet} from '../loaders/sprite.js';
export function loadCheepSlow() {
return loadSpriteSheet('cheep-gray')
.then(createCheepSlowFactory);
}
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|webp|svg|gif|woff|woff2|js|css)$">
Header set Cache-Control "max-age=31536000, public"
Header append Vary: Accept-Encoding
Header set Access-Control-Allow-Origin “*”
</filesMatch>
<ifmodule mod_deflate.c>
<ifmodule mod_mime.c>
AddType application/x-font-ttf .ttf
AddType application/font-woff .woff
function createTileCandidateLayer(tileResolver) {
const resolvedTiles = [];
const tileSize = tileResolver.tileSize;
const getByIndexOriginal = tileResolver.getByIndex;
tileResolver.getByIndex = function getByIndexFake(x, y) {
resolvedTiles.push({x, y});
return getByIndexOriginal.call(tileResolver, x, y);
}
$jq_integrity = 'sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=';
$jq_crossorigin = 'anonymous';
$jq_cdn = 'https://code.jquery.com/jquery-3.5.0.min.js';
$jq_version = '3.5.0';
if(! is_admin()){
function add_cdn_attrs( $tag, $handle, $src ) {
global $jq_integrity, $jq_crossorigin;
@bouveng
bouveng / functions.php
Created April 26, 2020 15:06
exclude pages from wp search
// exclude pages from wp search
if ( !is_admin() ) {
function exclude_pages( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', 'post' );
}
return $query;
}
@bouveng
bouveng / functions.php
Created April 15, 2020 16:16
add webp mime to wp
add_filter( 'upload_mimes', 'add_webp', 1, 1 );
function add_webp( $mime_types ) {
$mime_types['webp'] = 'image/webp';
return $mime_types;
}
add_action('wp_footer', 'add_partner_id');
function add_partner_id() {
echo '
<script>
( function( $ ) {
$("a[href*=\'thomann.de\']").each(function() {
$(this).attr("href", $(this).attr("href") + "?partner_id=XXXX");
});
} )( jQuery )
// https://jsfiddle.net/hwt3fjL1/
@keyframes txt-load {
0% {content:".";}
50% {content:"..";}
}
body {
font-size: 30px;
}
*[class*="sss"]:after {
content: "warning: css class name typo?"
color: f00;
}