Skip to content

Instantly share code, notes, and snippets.

View lonekorean's full-sized avatar

Will Boyd lonekorean

View GitHub Profile
@lonekorean
lonekorean / gist:8755527
Last active July 2, 2023 14:33
Simple table
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
@lonekorean
lonekorean / gist:fc467f130d46f3cbde88
Created November 5, 2014 22:55
CSS counters, selection
body {
counter-reset: characters;
}
input:checked {
counter-increment: characters;
}
.total::after {
content: counter(characters);
@lonekorean
lonekorean / gist:47a3fe3925df79a14f67
Last active April 21, 2023 07:43
Track outbound clicks
function trackOutboundClick(e) {
var $link = $(e.currentTarget);
var url = $link.attr('href');
ga('send', 'event', 'outbound', 'click', url, {
'hitCallback': function() {
document.location = url;
}
});
}
@lonekorean
lonekorean / gist:8dcc292a8a54184cf4a6
Created May 30, 2015 00:39
Fluent jQuery, using .addBack()
$('.basket').find('.egg').addBack()
.show()
.addClass('open')
.attr('data-total', 0);
@lonekorean
lonekorean / file.js
Last active April 21, 2023 07:40
Registering custom properties
CSS.registerProperty({
name: '--tooth-width',
syntax: '<length>',
initialValue: '40px',
inherits: false
});
CSS.registerProperty({
name: '--tooth-height',
syntax: '<length>',
initialValue: '20px',
@lonekorean
lonekorean / gist:8757625
Last active April 21, 2023 07:40
Query string get with null coalescing
string city = Request.QueryString["city"] ?? "";
@lonekorean
lonekorean / file.js
Created March 2, 2018 21:26
Placeholder box paint worklet
class PlaceholderBoxPainter {
paint(ctx, size) {
ctx.lineWidth = 2;
ctx.strokeStyle = '#666';
// draw line from top left to bottom right
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(size.width, size.height);
ctx.stroke();
@lonekorean
lonekorean / file.scss
Created July 9, 2016 21:09
Sass hexagon math
// tweak this
$width: 200px;
// automatically computed
$side-length: ($width / 2) / cos(30deg);
$cap-y-scale: tan(30deg);
$cap-height: ($width / 2) * $cap-y-scale;
$cap-unscaled-side-length: $width / sqrt(2);
@lonekorean
lonekorean / file.js
Created February 7, 2016 17:28
String replace, escaped
var str = '1 + 1 + 1 = 3';
str.replace(/\+/g, 'plus');
// "1 plus 1 plus 1 = 3"
@lonekorean
lonekorean / gist:8278651
Last active April 21, 2023 07:36
Null coalescing
var obj = incomingObj || {};