Skip to content

Instantly share code, notes, and snippets.

@naholyr
naholyr / BOOKLET.md
Last active September 19, 2023 11:45
How to print a booklet, the copy-pasta tables

Printing a booklet

Printing instructions:

  • Duplex
    • short edge for A5 booklet
    • long edge for A6 booklet
  • X pages per side, so if you're printing on A4 sheets:
    • 2 pages per side for A5 booklet (~21×15 mm)
  • 4 pages per side for A6 booklet (~10×15 mm)
UNIT=MM
BORDER=NONE,#000000,0,MARKDOT,#000000
GAP=5,5,ON
PAGE=210,297,PORTRAIT,HV
DPI=300
CARDSIZE=63,88
LINK=cards.xls,image
IMAGE=,[IMAGE],0,0,100%,100%,0,PTA
UNIT=MM
BORDER=NONE,#000000,0,MARKDOT,#000000
GAP=10,10,ON
PAGE=210,297,PORTRAIT,HV
DPI=300
CARDSIZE=40,55
LINK=cards.xls,image
IMAGE=,[IMAGE],0,0,100%,100%,0,PTA
@naholyr
naholyr / prerequisites-react.md
Created February 28, 2020 21:40
Prerequisites for React.js express training

React.js training prerequisites

const category = useSelector(state => state.app.currentCategory);
const asyncFunction = React.useCallback(
category ? () => getProducts(category) : null,
[category]
);
const [error, loading, products] = useAsync(asyncFunction, category);
import * as React from 'react';
// TODO inject counters
const Counter = () => {
const [value, setValue] = React.useState(1);
const incr = React.useCallback(() => setValue(value + 1), [value]);
return (
<button type="button" onClick={incr}>
Click to incr. ({value})
@naholyr
naholyr / run.js
Created June 21, 2018 08:05
Async pool
const { promisify } = require('util')
const delay = promisify(setTimeout)
const pad = (s, len = 4) => s.length >= len ? s : pad(`0${s}`, len)
// 300 tasks (id for log, run for action)
const tasks = []
for (let i = 0; i < 300; i++) {
const id = String(i)
const run = () => delay(2000 + Math.random() * 8000)
tasks.push({ id, run })
@naholyr
naholyr / test.jsx
Last active October 16, 2021 11:08
import React, { Fragment, Component } from 'react';
import ReactDOM from 'react-dom';
class ContextData {
watchers = []
constructor(initialState = {}) {
this.state = initialState

scan-dependencies

Usage : node scan-dependencies.js <path>

  • will find every root project inside <path> (a project is a folder with package.json file, himself not inside a node_modules directory)
  • will npm install then npm outdated from project
  • will list all *.js files and check for missing require(…) for every dependency
@naholyr
naholyr / README.md
Created November 4, 2016 15:30
Test Flow

Shitty code, version 1:

const concat = s => s.reduce((r,s) => r + s)
const mult = (a, b) => a * b
const foo = a => b => c => concat([c, ' = ', mult(a, b)])
const bar = a => Number(a) + 1
const baz = b => b ? 42 : 33
const res = foo(1)('bar')('baz')
console.log(res)