This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createSetter<T extends Record<string, any>>(setState : Dispatch<SetStateAction<T>>) { | |
return <K extends keyof T>(key : K, value : SetStateAction<T[K]>) => setState((prev : T) => ({ | |
...prev, | |
[key]: tryCall(value, prev[key]) | |
})); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let r = 'αβσδεφγ῾ικλμνοπρστυξυζηω'.split('').reduce((o,curr,i) => {o['abcdefghiklmnoprstuxyzēō'[i]] = curr;return o}, {}) | |
function gr(s) { return s.replace('th','θ').replace('ch','χ').replace(/./gui, a=>r[a]||a).replace(/σ /g, 'ς ') } | |
// replace selected | |
s=window.getSelection() | |
t=s.toString() | |
p=s.focusNode.parentNode;p.innerHTML=p.innerHTML.replace(t, gr(t)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `.mt-10` for `margin-top: 10`, etc. | |
// like in bootstrap | |
a = { m: margin, p: padding } | |
b = { '': '', t: '-top', r: '-right', b: '-bottom', l: '-left' } | |
for x, xx in a | |
for y, yy in b | |
for n in 0 5 10 15 20 | |
.{x}{y}-{n} | |
{xx}{yy}: n px |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = express() | |
// browser sync | |
if (app.get('env') === 'development') { | |
var bs = require('browser-sync')({ | |
logSnippet: false, | |
files: ['pub/*.html', 'pub/css/*.css', 'views'] | |
}) | |
app.use(require('connect-browser-sync')(bs)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Media query mixins | |
mobile() | |
@media (max-width: 640px) | |
{block} | |
tablet() | |
@media (max-width: 800px) | |
{block} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<ul> | |
<li><a href="#">1</a></li> | |
<li><a href="#">2</a></li> | |
<li> | |
3 + | |
<ul class="drop-right"> | |
<li><a href="#">3.1</a></li> | |
<li><a href="#">3.2</a></li> | |
<li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>GitHub Users, A Selection</title> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
<style> | |
body { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on http://codepen.io/zitrusfrisch/pen/bJwhk | |
function easyParallax() { | |
var scrollPos = w.scrollTop(); | |
$('#banner').css({ | |
'background-position' : '50% ' + (-scrollPos/4)+"px" | |
}); | |
$('#bannertext').css({ | |
'margin-top': (scrollPos/4)+"px", | |
'opacity': 1-(scrollPos/250) | |
}); |
NewerOlder