Skip to content

Instantly share code, notes, and snippets.

View Skitionek's full-sized avatar

Dominik Maszczyk Skitionek

View GitHub Profile
@Skitionek
Skitionek / d3+angularjs_directive_template.js
Last active June 19, 2017 09:57
Lovely template for embbeding d3 element to AngularJS
(function() {
'use strict';
/**
* @ngdoc directive_template
* @name app.controller:d3Directive
* @author Dominik Maszczyk
* @email Skitionek@gmail.com
* @description
* # d3Directive
@Skitionek
Skitionek / SplitPane.js
Created November 6, 2017 07:37
Amazingly simple yet powerful, flex based Split Pane implementation (draggable!)
/**
* Created by Dominik Maszczyk (https://www.linkedin.com/in/dominik-maszczyk/)
* on 30/10/17.
*/
import React, {Component, PureComponent} from "react";
import "./style.css";
class Resizer extends PureComponent {
onDrag = (e) => {
let horizontal = this.props.orientation === "horizontal",
@Skitionek
Skitionek / git-status
Last active March 16, 2018 13:08
Recursive traverse folders finding the git repositories and listing the uncommitted changes. Additionally, if the pair with the same name was found compare them with git diff.
#!/usr/local/bin/bash
clear
# just for formatting
b=$(tput bold)
n=$(tput sgr0)
declare -A reppos
@Skitionek
Skitionek / Invert.js
Created November 16, 2018 06:53
Invert website lightness
function rgbToHsl([r, g, b]) {
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if (max == min) {
h = s = 0; // achromatic
} else {
var d = max - min;
@Skitionek
Skitionek / ZoomableTreemap.js
Created February 6, 2019 07:27
Neat *D3 v4 & React* Zoomable Treemap template
import React, {Component} from 'react';
import {format as d3format} from 'd3-format';
import {scaleLinear} from 'd3-scale';
import {hierarchy, treemap} from 'd3-hierarchy';
import styled from 'styled-components';
import {select} from "d3-selection";
import {sum} from 'd3-array';
import {nest} from 'd3-collection';
const StyledSVG = styled.svg`
const { spawn } = require('child_process');
const args = process.argv.slice(2);
const child = spawn('tree',['-f', '--', args[0] || '.']);
child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
const lines = chunk.split(/\n/g).filter(line=>line!==''&&!line.match(/^\d/));
lines.forEach(line=>console.log(line.replace(/([^ \n]*?)([^ /\n]*)$/,'[$2]($1$2)')));
});
@Skitionek
Skitionek / GitMarkdownTree.js
Last active April 19, 2019 15:03
Add Github markdown links to tree output
const { spawn } = require('child_process');
const args = process.argv.slice(2);
const child = spawn('tree',['-f', '--', args[0] || '.']);
child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
const lines = chunk.split(/\n/g).filter(line=>line!==''&&!line.match(/^\d/));
lines.forEach(line=>console.log(line.replace(/([^ \n]*?)([^ /\n]*)$/,'[$2]($1$2)')));
});
/*
@Skitionek
Skitionek / Build_jest_expectation_from_schema.js
Created April 29, 2019 13:10
Sketchy form of jest query matcher against endpoint schema
function traverseSchema(node) {
// schema.getQueryType().getFields().Stock.type.getFields().data.type.ofType.getFields().adjustedClose.type.name
if (node instanceof GraphQLSchema) {
return {
query: traverseSchema(node.getQueryType())
}
}
if (node instanceof GraphQLList) {
const check = traverseSchema(node.ofType);
// console.log(check);
@Skitionek
Skitionek / lastCommitAffectingDockerImage.sh
Created August 30, 2019 09:26
As filename says - useful to skip build stage in deployment pipeline
#!/usr/bin/env bash
#source :https://stackoverflow.com/questions/57006043/get-the-git-commit-hash-of-the-last-commit-which-affected-files-not-listed-in-a
#maintain :Dominik Maszczyk
#date :2019-07-31
#email :Skitionek@gmail.com
#==============================================================================
DIR=$(mktemp -d)
pushd $DIR > /dev/null
# Set up a temporary git repository so we can use
# git check-ignore with .dockerignore