Skip to content

Instantly share code, notes, and snippets.

View PetrGlad's full-sized avatar
🚶‍♂️
.

Petr Gladkikh PetrGlad

🚶‍♂️
.
  • 12:39 (UTC +04:00)
View GitHub Profile
@PetrGlad
PetrGlad / audatic.py
Last active March 5, 2024 19:30
Python test assignment coderbyte
import statistics
import ast
import math
import json
from typing import Callable
class ParseError(Exception):
pass
#!/bin/sh
diff --color <(yq -P 'sort_keys(..)' $1) <(yq -P 'sort_keys(..)' $2)
@PetrGlad
PetrGlad / idea-ultimate.desktop
Created November 21, 2021 19:11
IntelliJ Idea Gnome Desktop Launcher Example
# Shoulid be in ~/.local/share/applications/idea-ultimate.desktop
[Desktop Entry]
Version=1.0
Name=Idea Ultimate
GenericName=IDE
Terminal=false
Exec=/opt/idea-IU-212.5457.46/bin/idea.sh
Terminal=false
Type=Application
Icon=/opt/idea-IU-212.5457.46/bin/idea.svg
#!/bin/bash
# Fix for working in IntelliJ behind corporate firewall in Linux.
# Note that this makes your Idea's TLS communications monitored.
# Note that if you have a JetBrains license owned by your company,
# then better ask your IT support to fix cert problems instead.
# Howto:
# 0. Your company cert is expected to be in /usr/local/share/ca-certificates/extra/MyCompanyCA.crt
# 1. Launch Intellij.
# 2. Copy CA storage path from the "certificate problem" pop up dialog. Close IntelliJ.
@PetrGlad
PetrGlad / retest.sh
Created September 4, 2019 21:08
Continuous retest
while inotifywait -e modify -r . ;
do
lein test;
echo;
done
@PetrGlad
PetrGlad / dip.sh
Created August 6, 2019 14:56
Get IP of a docker container
#!/bin/bash
docker inspect $1 | jq -r ".[0].NetworkSettings.Networks.${2:-bridge}.IPAddress"
docker run --name=a-test-mysql --detach \
-e MYSQL_USER='blaser' \
-e MYSQL_PASSWORD='ok' \
-e MYSQL_DATABASE='dratabasss' \
mysql/mysql-server:5.7
@PetrGlad
PetrGlad / darktable-export.sh
Last active October 20, 2024 02:47
Darktable batch export example
# Some docs imly source can be a directory, but it does not work actually.
# Below is a workaround
for p in a-source-folder/*
do
# Note that uppercase JPG suffix is not recognized so adding "jpg" to output file name.
darktable-cli --width 3000 --height 3000 --hq true $p $(dirname $p)-export/$(basename ${p%.JPG}.jpg);
done
use std::net::TcpListener;
use std::net::UdpSocket;
use std::net::TcpStream;
use std::net::Shutdown;
use std::thread;
use std::io::BufReader;
use std::io::Write;
use std::io::BufRead;
fn session(mut ios: TcpStream) -> Result<(), std::io::Error> {
@PetrGlad
PetrGlad / dijkstra.py
Created September 2, 2018 16:42
Dijkstra shortest path
rom collections import defaultdict
from math import inf
def find_closest(dist, unvisited):
# Select node with the least distance to source
u = None
min_du = inf
for v in unvisited:
if dist[v] < min_du: