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 / 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.
@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
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
/**
* 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);
@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
},
{
const data =
[
{
"val": 30,
"children": [
{
"val": 123,
"children": [
{
@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]))
@Akiyamka
Akiyamka / Techs.md
Last active December 5, 2018 14:11
Перевод Event Brief / RVA
@Akiyamka
Akiyamka / example.js
Last active December 3, 2018 10:01
svg path parser
function createSVG(d) {
const xmlns = "http://www.w3.org/2000/svg";
const boxWidth = 300;
const boxHeight = 300;
const svgElem = document.createElementNS(xmlns, "svg");
svgElem.setAttributeNS(null, "viewBox", "0 0 " + boxWidth + " " + boxHeight);
svgElem.setAttributeNS(null, "width", boxWidth);
svgElem.setAttributeNS(null, "height", boxHeight);
svgElem.setAttributeNS(null, "fill", "none");
@Akiyamka
Akiyamka / googleSheetJSON.js
Last active November 23, 2018 21:34
fetchGoogleSheet
const https = require('https');
const { StringDecoder } = require('string_decoder');
/**
* Simple Node.js script to turn a specific page on a Google Sheet
* into a JSON object for the main purpose of HTML Templating.
*
* @author jonobr1 / http://jonobr1.com
* @author akiyamka / [email protected]
*