Skip to content

Instantly share code, notes, and snippets.

View joonassandell's full-sized avatar

Joonas Sandell joonassandell

View GitHub Profile
@joonassandell
joonassandell / Regex: Remove comments
Last active August 29, 2015 14:14
Remove single and multiline comments
(^\/\/.*)|(\s+\/\/.*)|((\/\*)(.|\n)+?(\*\/))
@joonassandell
joonassandell / JS: Detect touch
Last active September 13, 2016 14:46
Detect touch support
/**
* Detect "touch" support and act accordingly.
* Adds `touch` class and assumes there is `no-touch` class added in <html> element.
*/
let hasTouch = false;
const docEl = document.documentElement;
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch || navigator.msMaxTouchPoints) {
docEl.className = docEl.className.replace(/(^|\s)no-touch(\s|$)/, ' touch ');
hasTouch = true;
@joonassandell
joonassandell / JS: detect font-face support
Last active September 13, 2016 14:38
Detecting font-face support
var ua = navigator.userAgent,
doc = document,
docEl = doc.documentElement;
/**
* Detect mobile "font-face" support
*
* Doesn't check support on desktop browsers
* so you should use Modernizr in combination with this
* UA detection to get the most out of it.
@joonassandell
joonassandell / JS: Closest number
Last active September 13, 2016 14:38 — forked from vipickering/closestNumberArray.js
Find closest number in ES6
const closestNumber = (array, num) => {
const i = 0;
let minDiff = 1000;
let ans;
for (i in array){
const m = Math.abs(num - array[i]);
if (m < minDiff) {
minDiff = m;
(?:https?:\/\/)?(?:www\.)?youtu(?:.be\/|be\.com\/watch\?v=|be\.com\/v\/)(.{8,})
@joonassandell
joonassandell / Typo3: Comment
Last active November 3, 2016 09:20
Fluid comment
<f:comment>
</f:comment>
@joonassandell
joonassandell / Rb: Container
Last active November 3, 2016 09:21
Rebirth Container w/ wrap & grid snippet
<div class="Container">
<div class="Wrap">
<div class="Grid">
<div class="Grid-cell m-Width--6of12">
</div>
</div>
</div>
</div>
@joonassandell
joonassandell / SassMeister-input.scss
Last active September 14, 2015 12:50 — forked from pascalduez/SassMeister-input.scss
Some Sass string functions: capitalize, ucwords, camelize, ...
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// Capitalize string
// --------------------------------------------------------------------------------
// @param [string] $string
// --------------------------------------------------------------------------------
// @return [string]
@joonassandell
joonassandell / Typo3: Typekit
Last active October 4, 2017 08:14
Fluid TypeKit snippet
<v:asset.prefetch domains="use.typekit.net" />
<v:asset.script path="myscript.js" external="true" standalone="true" movable="false" />
<v:asset.script external="true" standalone="true" movable="false">try{Typekit.load({ async: true });}catch(e){}</v:asset.script>
@joonassandell
joonassandell / Typo3: Partial
Last active November 3, 2016 09:16
Fluid partial
<f:render partial="" arguments="{}" />