Skip to content

Instantly share code, notes, and snippets.

View chuckis's full-sized avatar
πŸ”
In the beginning was the Word,

chuckis

πŸ”
In the beginning was the Word,
  • 10:28 (UTC +03:00)
View GitHub Profile
@chuckis
chuckis / phaserstuff.js
Created January 23, 2025 11:08 — forked from veleek/phaserstuff.js
Phaser Tile/World/Object XY conversions for orthogonal maps.
/**
* Get the world XY position of a tile that takes into account the offset of the container with this map in it.
* This returns the origin of the tile sprite which is 64x64 whereas the actual tilemap tile size is only 64x32, so
* the world position is actually outside of the individual tile bounds. The tiles overlap in the isometric grid
* though so we only really care about the specific point.
* @param tileX
* @param tileY
*/
public tileToWorldXY(tileX: number, tileY: number): Phaser.Math.Vector2 {
const worldPos = this.map.tileToWorldXY(tileX, tileY, null, null, "floor");
@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))