Skip to content

Instantly share code, notes, and snippets.

View bouveng's full-sized avatar

Johan Bouveng bouveng

View GitHub Profile
@bouveng
bouveng / gist:6ea86457738355a9ab30
Last active August 29, 2015 14:18
A box model that makes sense
This is my favorite CSS addition. Before the box-sizing property, if you had an element with
a defined width of 250px and added 25px padding (both left and right) to it, the actual width
would become 300px. This always seemed strange to me and when combined with making sites
responsive, it would really become a pain in the ass. Fortunately we can now change how the
box model calculates an element’s width and height. Using box-sizing: border-box will include
the element’s border and padding when calculating the height and width of an element. Using
our previous example, an element with box-sizing: border-box applied to it with a defined
width of 250px and padding of 25px will remain 250px wide.
To apply this behavior to all of your elements, include this at the top of your stylesheet:
@bouveng
bouveng / shader-loop.less
Created October 27, 2015 09:09
Less shader loop
@base: #03203a;
@shades: 15;
.shader-loop (@i) when (@i > 0) {
.strategy-chart svg path:nth-child(@{i}) {
@inc: @i;
fill: lighten(@base, @i * 100 / @shades);
}
.shader-loop(@i - 1);
@bouveng
bouveng / asciispinner.js
Created October 29, 2015 20:13 — forked from stefanocudini/asciispinner.js
ascii ajax spinner, jquery
$(function() {
var spins = [
"←↖↑↗→↘↓↙",
"▁▃▄▅▆▇█▇▆▅▄▃",
"▉▊▋▌▍▎▏▎▍▌▋▊▉",
"▖▘▝▗",
"┤┘┴└├┌┬┐",
"◢◣◤◥",
"◰ ◳ ◲ ◱",
@bouveng
bouveng / spinner.rb
Created October 29, 2015 20:36 — forked from ellemenno/spinner.rb
ascii spinner
#!/usr/bin/env ruby
# encoding: UTF-8
@dot_cycle = ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷']
#braille random: 0x2800 - 0x28ff
@z_arrow = ['←','↖','↑','↗','→','↘','↓','↙']
@z_b = ['b','ᓂ','q','ᓄ']
@z_d = ['d','ᓇ','p','ᓀ']
*[class*="sss"]:after {
content: "warning: css class name typo?"
color: f00;
}
// https://jsfiddle.net/hwt3fjL1/
@keyframes txt-load {
0% {content:".";}
50% {content:"..";}
}
body {
font-size: 30px;
}
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 )
@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;
}
@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;
}
$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;