Skip to content

Instantly share code, notes, and snippets.

@fre-sch
fre-sch / App.svelte
Last active May 15, 2024 05:51
Svelte 4 single visible menus/popover/tooltip
<script>
import Popover from "./popover.svelte"
</script>
<div>
<p>
Some text here and show a <Popover label="popover(1)">First popover</Popover> and some more text.
</p>
<p>
Another <Popover label="popover(2)">second popover</Popover> and some more text.
@fre-sch
fre-sch / new_ship_part_guide.md
Last active April 10, 2024 14:25
Starfield guide for creating new ship parts.

Adding New ship part to Starfield using xEdit

Tools

To edit ESM files you need compatible xEdit build. That means version 1.4.4r or later (October 2023). Do NOT use versions 1.4.4c or older.

After downloading extract the ZIP file, then rename the EXE file "xEdit64.exe" to "SF1xEdit64.exe". 64-bit version is recommended, and to work on Starfield files executable needs to start with "SF1".

Double click the "SF1xEdit64.exe" then let it work on first run to index the data, this will take 10 minutes or little bit more. It will let you know in the bottom status bar when it's done. Following starts will take 10-40 seconds.

@fre-sch
fre-sch / points-lines-on-circle.js
Created January 2, 2023 08:55
Given a number of colors, calculate points on a circle centered on a canvas, draw lines between all points and then draw points over the lines using the colors.
const canvas = document.querySelector("#thecanvas")
const context = canvas.getContext("2d")
const midpoint = {x: canvas.width / 2, y: canvas.height / 2}
const colors = ["red", "green", "blue", "cyan", "magenta", "orange"]
const padding = 20
const radius = (Math.min(canvas.width, canvas.height) - padding) / 2
const d = Math.PI * 2 / colors.length
const points = colors.map((color, index) => {
const x = Math.cos(d * index) * radius
const y = Math.sin(d * index) * radius
@fre-sch
fre-sch / preact-hooks-utils.js
Last active November 21, 2022 09:31
Some utils for dealing with preact/hooks
/*
Add some structure to the `[state, dispatch]` pattern of `useReducer`.
`useActionReducer` provides `dispatch(action: str, data: any)`, and wraps
it to call `handler[action](state, data)`
Example object based handler:
const todoListHandler = {
text: (state, {text}) => {
@fre-sch
fre-sch / h.js
Last active August 27, 2022 09:21
parser for alternative syntax to use preact h
@{%
// Moo lexer documention is here:
// https://github.com/no-context/moo
const moo = require("moo")
const lexer = moo.compile({
ws: {match: /\s+/, lineBreaks: true},
literal_id: {
match: /#[a-zA-Z_-][a-zA-Z_0-9_-]*/,
value: s => s.slice(1)
@fre-sch
fre-sch / h.js
Created August 27, 2022 09:13
trying syntax simplifications for using preact h without jsx
function (type, props, children) {
// placeholder for preact h
return {type, props, children}
}
var ElementPropSetter = {
get: function(target, name, proxy) {
return function(...values) {
if (name == "class")
target.props.class = values.join(" ")
@fre-sch
fre-sch / Program.cs
Created April 23, 2022 15:07
Space Engineers Toggle Block on amounts
class Program {
// item name that has to be taken into account for level check
// string itemNameToCheck = "MyObjectBuilder_Ore/Ice";
string itemNameToCheck = "Ice";
// tag for blocks that will be switched off and on
string tag = "[TOGGLE_LEVEL]";
// do not change below
@fre-sch
fre-sch / Inventory-Mover.ahk
Last active January 2, 2022 19:05
Autohotkey script to make moving inventory items in Star Citizen (3.16) easier
#NoEnv
#Warn
SetWorkingDir %A_ScriptDir%
SendMode, Input
SetMousedelay, 20
SetMousedelay, 20, Play
;MoveXOffset := 43
@fre-sch
fre-sch / maybe.py
Created February 24, 2021 08:30
Chainable None-Aware Wrapper
from dataclasses import dataclass
class Maybe:
def __init__(self, value):
self.value = value
def bind(self, f):
if self.value is None:
return self
@fre-sch
fre-sch / showmodal.reds
Created February 5, 2021 14:22
Cyberpunk 2077 - Showing some (debug) information in redscripts
let evt = new NotifyShardRead();
evt.title = "Title for modal";
evt.text = "Text for modal;
/* NotifyShardRead has other properties that can be left unset */
let gi: GameInstance = player.GetGame(); /* any GameObject provides GetGame() -> GameInstance */
GameInstance.GetUISystem(gi).QueueEvent(evt);