Skip to content

Instantly share code, notes, and snippets.

View ozcanyarimdunya's full-sized avatar
🌍

ÖZCAN YARIMDÜNYA ozcanyarimdunya

🌍
View GitHub Profile
@ozcanyarimdunya
ozcanyarimdunya / multiprocess.bash
Created June 14, 2023 13:26
multiprocess.bash
for i in {1..5} ; do
(sleep "$i" && echo "worker $i finished") &
(sleep "$i" && echo "worker -$i finished") &
(sleep "$i" && echo "worker --$i finished") &
done
@ozcanyarimdunya
ozcanyarimdunya / spinner.py
Last active January 7, 2023 10:24
itertools cycle example
import itertools
import time
cycle = itertools.cycle(['-', '/', '|', '\\'])
for i in range(5):
print("Loading", next(cycle), end="\r")
time.sleep(.5)
print("Finished!")
cycle = itertools.cycle(['.', '..', '...', '....'])
@ozcanyarimdunya
ozcanyarimdunya / didyoumean.py
Created January 7, 2023 10:01
did you mean ?, n closest match
import difflib
matches = difflib.get_close_matches(
word="ozc",
possibilities=[
"ozcan",
"ozca",
"zcan",
"stat",
],
@ozcanyarimdunya
ozcanyarimdunya / yaml_constructor.py
Created December 15, 2022 13:11
Yaml construction
import pathlib
import yaml
from yaml.constructor import Constructor
class CustomConstructor(Constructor):
def construct_yaml__secret(self, node):
values = self.construct_mapping(node)
username = values["username"]
@ozcanyarimdunya
ozcanyarimdunya / html.py
Last active May 15, 2022 21:56
Build html with python
class Element:
tag = None
def __init__(self, *elements, **attrs):
self.elements = elements
self.attrs = attrs
assert self.tag is not None, "Set tag property!"
def html(self):
@ozcanyarimdunya
ozcanyarimdunya / wordle.py
Last active March 21, 2022 14:58
Wordle sample
import os
import random
import string
import sys
PY2 = sys.version_info.major == 2
if PY2:
input = raw_input # noqa
random.choices = random.sample # noqa
@ozcanyarimdunya
ozcanyarimdunya / pipe.sh
Created December 26, 2021 13:37
Bash | read from pip
#!/bin/bash
:'
USAGE
-----
1) cat test.txt | ./pipe.sh
2) ./pipe.sh < test.txt
'
while read line; do
@ozcanyarimdunya
ozcanyarimdunya / utils.sh
Last active January 4, 2022 10:04
Utility for bash
#!/usr/bin/env bash
success() {
echo -e "\e[1;32m$1\e[0m"
}
info() {
echo -e "\e[1;34m$1\e[0m"
}
#!/usr/bin/env bash
letters=('A' 'B' 'C')
line1=('oxxo' 'xxxx' 'xxxx')
line2=('xoox' 'xoox' 'xooo')
line3=('xxxx' 'xxxo' 'xooo')
line4=('xoox' 'xoox' 'xooo')
line5=('xoox' 'xxxx' 'xxxx')
@ozcanyarimdunya
ozcanyarimdunya / jaydebeapi_connect.py
Created November 3, 2021 11:34
Connect database via jaydebeapi
import pathlib
import jaydebeapi as jdbc
# Create a dir 'jars' and download related jar files
jars = pathlib.Path(__file__).parent.joinpath("jars")
databases = [
{
"classname": "org.sqlite.JDBC",