Skip to content

Instantly share code, notes, and snippets.

View chuckis's full-sized avatar
🔍
In the beginning was the Word,

Ruslan chuckis

🔍
In the beginning was the Word,
  • 20:55 (UTC +03:00)
View GitHub Profile
@chuckis
chuckis / 1.srp.py
Created May 14, 2023 16:51 — 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:
def __init__(self, name: str):
@chuckis
chuckis / gist:b7061e8c0c09a64c818bce62d0915f2a
Created May 11, 2021 18:03 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@chuckis
chuckis / 0. description.md
Created January 1, 2018 21:28 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

; http://www.algolist.com/Dijkstra's_algorithm
(defn dijkstra [g src]
(loop [dsts (assoc (zipmap (keys g) (repeat nil)) src 0)
curr src
unvi (apply hash-set (keys g))]
(if (empty? unvi)
dsts
(let [unvi (disj unvi curr)
nextn (first (sort-by #(% dsts) unvi))