Skip to content

Instantly share code, notes, and snippets.

View a-x-'s full-sized avatar
🛩️

Alexander a-x-

🛩️
View GitHub Profile
@a-x-
a-x- / rm-initClass.js
Created February 9, 2019 20:29
rm initClass AST based post-processor for decaffeinate
#!/usr/bin/env node
// fixes the decaffeinate result: rm all the static initClass functions
// node scripts/coffee2es6jsx/rm-initClass.mjs files
// todo: rm Search.initClass();
const fs = require('fs');
const Glob = require('glob');
const parser = require("@babel/parser");
@a-x-
a-x- / stable-separation-sort.js
Last active November 16, 2018 18:51
Stable Separation Sort. Move items below and above the pivot
const arr = [
14418,
584,
1108,
1020,
363,
7073,
]
const max = Math.max(...arr)
@a-x-
a-x- / app-example.js
Last active November 13, 2018 11:08
react hooks on getters/setters — useStateObj
import React from "react";
import ReactDOM from "react-dom";
import useStateObj from "use-state-obj";
function App() {
var state = useStateObj({a:1})
function handleClick() {
++state.a
}
@a-x-
a-x- / interpose.coffee
Created November 9, 2018 13:27
interpose like join, but returns an array
# like join, but returns an array
interpose = (array, glue) ->
array.reduce (res,x) -> [].concat res, glue, x
export default interpose
@a-x-
a-x- / react-temporal-state.js
Last active July 17, 2018 18:16
react temporal state
// Временное выставление статуса
class Foo extends React.PureComponent {
// ...
foo () {
// ...
this.setState({
triggered: setTimeout(() => this.setState({ triggered: null }), 500)
})
}
componentWillUnmount () {
[core]
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol,space-before-tab
quotepath = false # Чтобы не упячилась кириллица в путях
editor = mvim -v
excludesfile = ~/.gitignore
[merge]
tool = vscode
conflictstyle = diff3 # 3 side
// Place your settings in this file to overwrite the default settings
{
"editor.fontLigatures": true,
"editor.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
"editor.fontSize": 14,
"files.autoSave": "onFocusChange",
"editor.formatOnPaste": true,
"files.trimTrailingWhitespace": true,
"workbench.activityBar.visible": false,
"terminal.integrated.copyOnSelection": true,
@a-x-
a-x- / scroll-in-flex.md
Last active March 7, 2024 15:54
`overflow: scroll` in the `display: flex` 👿😳🤔🤯

Как поместить scroll-контейнер во flexbox и не облажаться.

overflow-flex-grid-hack

Столкнулись с проблемой: блок со скролом распепячивает flex. Давайте разбираться.

4 месяца назад показалось, что хак найден, о чём мы поспешили рассказать в твиттере, но потом стало ясно что таки поспешили.

Помотрели в спеку и mdn, но ключей к решению не нашли.

@a-x-
a-x- / building-css-modules-library.md
Last active March 1, 2018 15:08
Building css-modules library

🚫 Approach 1: converted plain css

pros:

  • much simple lib build

cons:

  • additional requirements to service build config (style-loader, css-loader for node_modules)
  • bug: every library's css file got style tag in a project 😨
  • bug: postcss-icss-selectors rule.parent is undefined — UPD fix
  • bug: css-modules-transform generateScopedName does not work — UPD fix
  • bug: generateScopedName does not apply to postcss optimized selectors — issue
@a-x-
a-x- / timer.js
Last active February 26, 2018 13:46
simple delayed timer with onExpire callback
const SEC = 1000
const MIN = SEC * 60
/** @param time, Δ ms */
function getMinSec(time) {
return {
sec: Math.floor((time % MIN) / SEC),
min: Math.floor(time / MIN)
}
}