Skip to content

Instantly share code, notes, and snippets.

@jonchun
jonchun / Debug.gd
Last active June 15, 2020 12:00
Custom GDScript debug print statement that lets you know which file/line the print is being called from and also has a rate limit feature which is useful to use in _physics_process/_process(). I like to add Debug.gd as an Autoload script and name it "D". I can then just write D.print("Hello world", 1.0) in my code.
extends Node
var _rate_limits: = {}
func print(val, rate_limit: = 0.0):
# rate_limit is how often to print in seconds.
var stack = get_stack()
var source_file = stack[1].source
var source_function = stack[1].function
var source_line = stack[1].line
@jonchun
jonchun / AnimatedSpriteEffect.gd
Last active June 1, 2020 12:56
EffectManager
class_name AnimatedSpriteEffect
extends AnimatedSprite
signal effect_animation_finished(animated_sprite_effect)
var loop = false
var _owner = null
func _ready() -> void:
connect("animation_finished", self, "_on_Animation_finished")
+----------------+----------+---------------+---------+--------------+------------+-----------------+
| Distro | Telegram | Telegram Snap | Discord | Discord Snap | Mailspring | Mailspring Snap |
+----------------+----------+---------------+---------+--------------+------------+-----------------+
| KDE Neon 18.04 | Yes | Yes | No | No | No | No |
| Kubuntu 18.04 | Yes | Yes | No | No | No | No |
| Kubuntu 20.04 | Yes | Yes | No | No | No | No |
| Ubuntu 18.04 | Yes | Yes | Yes | No | Yes | No |
| Ubuntu 20.04 | Yes | Yes | Yes | No | Yes | No |
+----------------+----------+---------------+---------+--------------+------------+-----------------+
@jonchun
jonchun / change_name.py
Created March 28, 2020 18:24
recursively change names to all lowercase and replace spaces with _
import glob
from pathlib import Path
file_list = glob.glob('**/*', recursive=True)
file_list.sort(key=len, reverse=True)
def rename(file):
_name = file.name.replace(' ', '_').lower()
_name = file.parent / Path(_name)
file.rename(_name)

Keybase proof

I hereby claim:

  • I am jonchun on github.
  • I am jonathanchun (https://keybase.io/jonathanchun) on keybase.
  • I have a public key ASC60Hf-B5cNQROcIlO47FO-Eimf74npEzwl1aPw9tT7TAo

To claim this, I am signing this object: