Skip to content

Instantly share code, notes, and snippets.

View eyy's full-sized avatar

Etai Peretz eyy

  • Israel
View GitHub Profile
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])
}));
}
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))
@eyy
eyy / util.styl
Created May 8, 2021 12:12
stylus utilities classes
// `.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
@eyy
eyy / drop-right.html
Created May 28, 2019 08:12
Drop-right: a simple dropdown to the right
<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>
<!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 {
var arg = _.partial(_.includes, process.argv.slice(2))
@eyy
eyy / package.json
Last active August 29, 2015 14:27
My `package.json` scripts
{
"scripts": {
"start": "node ./server/www",
"test": "faucet",
"front": "npm run bs & npm run stylus",
"back": "npm run nodemon & npm run stylus",
"build": "npm run stylus-build",
"deploy": "npm run build && node tasks deploy",
"bs": "browser-sync start --server --no-online --startPath=\"pub/index.html\" --files=\"pub/*.html, pub/css/*.css\"",
"stylus": "stylus -w -u nib -u jeet -u autoprefixer-stylus --sourcemap-inline pub/css/*.styl",
@eyy
eyy / media-query-mixins.styl
Created August 4, 2015 13:13
Media query mixins for Stylus
// Media query mixins
mobile()
@media (max-width: 640px)
{block}
tablet()
@media (max-width: 800px)
{block}
@eyy
eyy / ftp-deploy.js
Created August 4, 2015 10:01
Deploy static site to FTP
console.log('connecting ftp...')
var FTP = require('jsftp'),
async = require('async')
var ftp = new FTP({
host: '',
port: 21,
user: '',
pass: '',
@eyy
eyy / tasks.js
Last active August 29, 2015 14:26
Takser – node task runner
function first () {
console.log(1)
}
function second () {
console.log(2)
}
function three (val) {