Skip to content

Instantly share code, notes, and snippets.

View rybarix's full-sized avatar

Sandro Rybárik rybarix

View GitHub Profile
@rybarix
rybarix / simpledocs.py
Created December 12, 2021 21:04
Generate simplest documentation possible
# HERE import all functions/classes to generate documentation for
from covidseg.dataset_reduction import reduce_dataset
from covidseg.inference import inference
# Generate docstrings
def __docs(m):
"""
Generates simple docstring for python module.
"""
file = f"\nFILE: {m.__file__}" if hasattr(m, '__file__') else ""
@rybarix
rybarix / shadows.css
Created July 17, 2021 12:32
Cool animated deep shadows
.shadow1 {
box-shadow: inset 0 0 10px rgba(0,0,0,0.10);
background: #f1f1f1;
opacity: 0;
animation: 500ms show forwards;
animation-delay: 2s;
}
.shadow2 {
box-shadow: inset 0 0 10px rgba(0,0,0,0.25);
background: #e1e1e1;
@rybarix
rybarix / throttle.js
Last active July 15, 2021 21:20
Throttling Javascript events. Throttle dom events or any other events.
/**
* Throttle function to reduce number of events
* coming from event stream
*
* Useful for reducing number of updates coming from
* mousemove events or such.
*
* @param time - in miliseconds
* @param callback - event callback see example below.
*
@rybarix
rybarix / htmlelements.js
Created July 13, 2021 16:17
List of html elements. Array of html elements. Array of html tags. List of html tags. According to https://developer.mozilla.org/en-US/docs/Web/HTML/Element
const htmlelements = [
"html",
"base",
"head",
"link",
"meta",
"style",
"title",
@rybarix
rybarix / remapkeys.sh
Last active June 24, 2021 18:03
macOS remap § to `. Non US keyboards remap keys. (Macbook pro, Mac)
# Remap keys (macOS)
# remaps "§" to "`"
hidutil property --set '{"UserKeyMapping":[
{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064},
{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}
]}' > /dev/null 2>&1
# Store file at home directory.
# System Preferences > Users & Groups > Login Items > + button and add script
@rybarix
rybarix / ffmpeg_burn_subs.sh
Created December 21, 2020 18:12
Burns subtitles (srt) into video.
ffmpeg -i <input_video> -vf subtitles=<srt_path> <output_video_path>
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
main =
text
-- <| String.fromInt(length [1,2,3,4])
-- <| Debug.toString(member 10 [1,2,3])
@rybarix
rybarix / git_report.js
Created August 31, 2019 18:47
Reports hours spent on project from 7Am morning until now. Information about time is gathered from commit messages containing eg. `#1h20m` or `#20m` or `#1h`
const { exec } = require('child_process');
const Reset = "\x1b[0m"
const FgBlack = "\x1b[30m"
const FgRed = "\x1b[31m"
const FgGreen = "\x1b[32m"
const FgYellow = "\x1b[33m"
const FgBlue = "\x1b[34m"
const fs = require('fs')
const { exec } = require('child_process');
const re = /(?<width>[0-9]+)x(?<height>[0-9]+)/
function fileDims(fname) {
if (re.test(fname)) {
const { width, height } = re.exec(fname).groups
return {
@rybarix
rybarix / ApiTracer.js
Created October 24, 2016 21:38
Reducer for tracing all request from ajax requests
// --------------
// ACTIONS
// --------------
const API_CALL_RESPONSE_STATUS = 'API_CALL_RESPONSE_STATUS';
const API_CALL_RESPONSE_STATUS_200 = 'API_CALL_RESPONSE_STATUS_200';
const API_CALL_RESPONSE_STATUS_401 = 'API_CALL_RESPONSE_STATUS_401';
const API_CALL_RESPONSE_STATUS_422 = 'API_CALL_RESPONSE_STATUS_422';
const GENERAL_API_CALL = 'GENERAL_API_CALL';