Skip to content

Instantly share code, notes, and snippets.

View ivanleoncz's full-sized avatar
🔬
Bjarne Stroustrup is someone to admire.

ivanleoncz ivanleoncz

🔬
Bjarne Stroustrup is someone to admire.
View GitHub Profile
@ivanleoncz
ivanleoncz / 1_SOLID_srp.py
Last active September 26, 2023 10:06 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
@ivanleoncz
ivanleoncz / threads_writing_same_file.py
Last active July 31, 2020 03:12 — forked from rahulrajaram/.md
Writting to a same file via multiple Threads, using primitive lock.
import threading
import time
global_lock = threading.Lock()
def write_to_file():
while global_lock.locked():
# Give 100ms in order to execute a next loop, if locked.
time.sleep(0.1)
continue
@ivanleoncz
ivanleoncz / createdb.js
Last active March 26, 2019 01:24 — forked from loic-moriame/index.js
Building SQLite models with Sequelize.js.
const Sequelize = require('sequelize');
var sequelize = new Sequelize({
dialect:"sqlite",
storage:"./db.sqlite",
});
// DB Connection
sequelize.authenticate().then(
function (err) {console.log("Connection established!");},
function (err) {console.log("Unable to connect!", err);}
@ivanleoncz
ivanleoncz / youtube2mp3.py
Last active November 25, 2018 15:24 — forked from benzap/youtube2mp3.py
Youtube to MP3 Downloader Script
#!/usr/bin/python3
#
# Requires: youtube_dl module
# Requires: ffmpeg
# Usage:
#
# python youtube2mp3.py <URL>, ...
#
# Example:
#