Skip to content

Instantly share code, notes, and snippets.

@sashtown
sashtown / thumbs.php
Created August 24, 2014 08:50
Thumbnails in Kirby 2
<?php
// return thumb and set width + height
echo thumb($image, array('width' => 400, 'height' => 250));
// return thumb and set width + height + crop
echo thumb($image, array('width' => 400, 'height' => 250, 'crop' => true));
// return thumb and set width + height + upscale
echo thumb($image, array('width' => 400, 'height' => 250, 'upscale' => true));
@sashtown
sashtown / rem-px.scss
Created May 28, 2014 15:29
simple rem/px Sass mixin
html {
font-size: 62.5%; // setting the doc base as 10px = 1.0rem
}
@mixin rem($property, $value) {
#{$property}: $value * 1px;
#{$property}: $value * .1rem;
}
@sashtown
sashtown / tooltip.html
Created April 24, 2014 04:58
tooltips with pure CSS
<a class="tooltip" href="#">Item<b>Item help</b></a>
@sashtown
sashtown / disable-shadow
Created March 18, 2014 17:26
Disable shadow on systemwide screencaptures.
defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer
@sashtown
sashtown / auth.template.php
Created September 2, 2013 09:56
Kirby Auth Plugin: Stuff to redirect to the last page before the login/logout.
<?php snippet('header') ?>
<main role="main">
<article class="content">
<h1><?php echo html($page->title()) ?></h1>
<?php echo kirbytext($page->text()) ?>
<?php if($user = Auth::user()): ?>
<?php echo kirbytext($page->auth()) ?>
@sashtown
sashtown / piwik.getUniqueVisitors.php
Created July 25, 2013 16:25
Piwik stats: Display unique visitors
<?php
// this token is used to authenticate your API request.
// You can get the token on the API page inside your Piwik interface
$token_auth = 'your_fancy_piwik_token';
$url = "http://stats.your-domain.com/";
$url .= "?module=API&method=VisitsSummary.getUniqueVisitors";
$url .= "&idSite=1&period=week&date=today";
$url .= "&format=PHP";
@sashtown
sashtown / dabblet.css
Created June 15, 2013 14:00
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
aside, div {
background: #f06;
width: 500px;
height: 200px;
margin: 5%;
position: relative;
}
@sashtown
sashtown / grayscale.css
Created June 10, 2013 16:53
CSS grayscale filter
.gs {
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 */
transition: all 1s ease;
}
.gs:hover {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
-webkit-filter: grayscale(0%);
}
@sashtown
sashtown / gradient-button.css
Created April 29, 2013 10:20
A nice gradient button with smooth transition.
.button {
display: inline-block;
padding: 10px 20px;
font-size: 20px;
font-weight: bold;
color: #6c3021;
border: 1px solid #8a4231;
background-color: #9F513E;
background: -webkit-linear-gradient(top, #bd6853, #9F513E);
background: -moz-linear-gradient(top, #bd6853, #9F513E);