Skip to content

Instantly share code, notes, and snippets.

@fre-sch
fre-sch / first.lua
Last active March 28, 2020 11:53
luabindingsexplore
-- scripts/first.lua
myvars = {}
Hooks.Init = function ()
print("first.lua Hooks.Init")
myvars.foo = "first foo"
end
Hooks.MonsterHit = function (e)
print("first.lua MonsterHit", e.monster.health)
garglebla()
@fre-sch
fre-sch / dnd.jsx
Created July 8, 2019 05:20
Dnd reorderable list in Preactjs
const lorem = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
class DndListItem extends Component {
render({onDragStart, children}) {
return (
<div class="dnd-list-item"
draggable="true"
onDragStart={onDragStart}>
{children}
</div>
from collections import defaultdict
class ObservableAttr:
class _unset: pass
def __init__(self, default=_unset):
self.default = default
self.name = "unnamed"
def __set_name__(self, cls, name):
@fre-sch
fre-sch / app.jsx
Created March 12, 2018 06:48
preact drag and drop
import {h, Component} from "preact"
const lorem = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
class DndListItem extends Component {
render({onDragStart, children}) {
return (
<div class="dnd-list-item"
draggable="true"
onDragStart={onDragStart}>
class DQNAgent:
default_options = dict(
replay_memory_size=10000,
batch_size=12,
action_count=0,
frame_stack=None
)
def __init__(self, **kwargs):
opts = self.default_options.copy()
@fre-sch
fre-sch / components.py
Last active October 24, 2016 06:03
IOC and DI service locator container implementation
from sslib import Registry
import sys
sys.modules[__name__] = Registry()
@fre-sch
fre-sch / README.md
Created June 10, 2016 14:51
Elite Dangerous Recipe Database
<!--
once for each <twitch-user-handle>, in this case 'time_of_chaos'.
id should be set as "shoco-twitch-channel-<twitch-user-handle>" but any unique string is fine.
data-channel must be set to <twitch-user-handle>
-->
<div class="shoco-twitch-channel"
id="shoco-twitch-channel-time_of_chaos"
data-channel="time_of_chaos"
style="display:none">
<h3><i class="shoco-twitch-channel-online shoco-twitch-channel-online-icon"></i><span class="shoco-twitch-display-name"></span></h3>
@fre-sch
fre-sch / selection_to_layer_cropped.py
Last active January 28, 2023 10:51
Gimp Python-Fu script that copies selection to new layer and autocrops layer.
#!/usr/bin/env python
from gimpfu import *
def python_selection_to_layer_cropped(image, drawable, layer_name):
pdb.gimp_image_undo_group_start(image)
prev_layer = image.active_layer
pdb.gimp_edit_copy(image.active_layer)
fsel = pdb.gimp_edit_paste(drawable, False)
@fre-sch
fre-sch / MultiDateFormat.groovy
Last active June 10, 2016 14:44
Parse multiple date string formats
import java.text.DateFormat
import java.text.FieldPosition
import java.text.NumberFormat
import java.text.ParsePosition
import java.text.SimpleDateFormat
class MultiDateFormat extends DateFormat {
private final SimpleDateFormat printer
private final List<SimpleDateFormat> parsers