Skip to content

Instantly share code, notes, and snippets.

View Akiyamka's full-sized avatar
🏠
Working from home

Alexander CherryTea Akiyamka

🏠
Working from home
View GitHub Profile
@Akiyamka
Akiyamka / Techs.md
Last active December 5, 2018 14:11
Перевод Event Brief / RVA
@Akiyamka
Akiyamka / extractListFrom.js
Created January 10, 2019 15:01
Create array of unique entries in dataset (not deep)
/**
* Create array of unique entries in dataset (not deep)
* @Example
* const data = [ { regionId: 123, indicatorId: 345 }, { regionId: 123, indicatorId: 345 }, { regionId: 678, indicatorId: 910 }]
* extractListFrom('regionId', 'indicatorId')(data);
*/
export function extractListFrom(...args) {
const accum = args.reduce((ac, arg) => { ac[arg] = new Set(); return ac }, {});
return data => data.reduce((acc, m) => {
Object.keys(acc).forEach(key => acc[key].add(m[key]))
const data =
[
{
"val": 30,
"children": [
{
"val": 123,
"children": [
{
@Akiyamka
Akiyamka / dataset.json
Last active January 18, 2019 15:36
Fold Childrens (playground: https://stackblitz.com/edit/js-rskhjq)
{
"childrens": [
{
"name": "foo_lvl_1",
"childrens": [
{
"name": "foo1_lvl_2",
"value": 13
},
{
/**
* Find branch in tree by omen pair - key-value
* @param {Object} omen - how to find branch. Example - { id: 123456 }
* @param {Object} options [{children: 'children', returnChild: true}];
* @param {Boolean} options.returnChild -
* if true return branch started from found child,
* else return whole branch where child founded
*/
function findBranchByOmen(omen, options) {
const [[omenProp, omenValue]] = Object.entries(omen);
export function chainQueries(queries) {
const defaultOptions = { errorPolicy: 'all' };
const checkLoadingAndError = allData => allData.loading || allData.error;
const maybeFunction = (t, args) => typeof t === 'function' ? t(args) : t;
const findQueryName = query => query.definitions[0].selectionSet.selections[0].name.value;
const queryNamesBuffer = [];
const pipeline = queries.map((q, i)=> {
if (q.kind === 'Document') { // Not sure about this way for detect query
@Akiyamka
Akiyamka / bumblebee.bash
Created March 11, 2019 07:06
Linux usefull commands
bumblebeed -vv --driver nvidia # start demon in debug mode
optirun -vvv glxgears # start optirun in debug mode
grep -i glx /var/log/Xorg.0.log # glx loading log
@Akiyamka
Akiyamka / no-cors requst
Created March 18, 2019 11:43
CORS ERRORS
Cross-Origin Read Blocking (CORB) blocked cross-origin response http://0.0.0.0:8612/graphql with MIME type application/json.
See https://www.chromestatus.com/feature/5629709824032768 for more details.
export default class Watcher {
constructor() {
this._mem = [];
}
_compareFunction(val1, val2) {
return Object.is(val1, val2);
}
setCallbacks(callbacks) {