Skip to content

Instantly share code, notes, and snippets.

View Skitionek's full-sized avatar

Dominik Maszczyk Skitionek

View GitHub Profile
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MessageCard",
"type": "object",
"required": [
"@type",
"@context"
],
"properties": {
"@type": {
@Skitionek
Skitionek / docker_run.sh
Created March 1, 2024 12:46
How to wrap docker run in bash script
#!/bin/bash
# region Load environment variables from .env file
if [ -f .env ]; then
set -a
source .env
set +a
fi
# endregion
@Skitionek
Skitionek / bootstrap-tooltip-on-tilted-text.scss
Last active March 11, 2021 00:11
Styles for bootstrap tooltip on tilted (rotated) text
.rotatedTooltip {
display: none;
&.show {
display: block;
}
.arrow {
position: absolute;
display: block;
@Skitionek
Skitionek / DateRangePicker.jsx
Last active January 30, 2020 04:01 — forked from RedHatter/DateMultiPicker.jsx
Range select for @mui-org/material-ui-pickers
import React, { useContext, useRef, useState } from 'react'
import { DatePicker, MuiPickersContext } from '@material-ui/pickers'
import withStyles from '@material-ui/core/styles/withStyles'
import clsx from "clsx";
import { useStyles as dayStyles } from '@material-ui/pickers/views/Calendar/Day';
function DateRangePicker({
classes,
value,
onChange,
@Skitionek
Skitionek / Linear interpolation.sql
Last active October 3, 2019 12:48
Linear interpolation of missing data points (sparse dataset)
-- 60 * 60 * 24 = 86400 // number of seconds in day
WITH range AS (SELECT *,
EXTRACT(EPOCH FROM min) min_e,
EXTRACT(EPOCH FROM max) max_e
FROM
(SELECT min(date) AS min, max(date) AS max FROM prices) s)
SELECT
CASE WHEN prev_d <> min_e AND date <> g
THEN ROUND((m * g + ((price + prev_p) - m * (date + prev_d)) / 2)::NUMERIC, 2)
ELSE price END price,
@Skitionek
Skitionek / simplify.js
Created September 10, 2019 11:10
Get n line representative points
/* DOCUMENT INFORMATION
- Author: Dominik Maszczyk
- Email: Skitionek@gmail.com
- Created: 2019-09-10
- Adapted from: https://bost.ocks.org/mike/simplify/
*/
const simplify = function(
points,
{ accessor_x = d => d.x, accessor_y = d => d.y, number_of_samples = 100 } = {}
@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
@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 / 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)')));
});
/*