Skip to content

Instantly share code, notes, and snippets.

View dhkatz's full-sized avatar
🏠
Working from home

David Katz dhkatz

🏠
Working from home
View GitHub Profile
@dhkatz
dhkatz / curseforge.sh
Last active September 4, 2023 04:25
Script for installing modpacks on Linux
#!/bin/bash
# shellcheck disable=SC2155
#
# CurseForge Installation Script
#
# Server Files: /mnt/server
: "${SERVER_DIR:=/mnt/server}"
: "${PROJECT_ID:=}"
: "${VERSION_ID:=}"
@dhkatz
dhkatz / a3update.py
Last active July 1, 2022 20:27 — forked from Freddo3000/a3update.py
Arma 3 Linux server and mod updater (workshop)
#!/usr/bin/python3
# MIT License
#
# Copyright (c) 2017 Marcel de Vries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@dhkatz
dhkatz / README.md
Last active May 30, 2024 09:29
Sol2 + RTTR

Sol2 + RTTR Example

This isn't tested, but it's basically what I've gotten working in my own project as of now.

RTTR is really cool and will let you save type information for elsewhere in your project (maybe an editor if it's a game engine), but also using visitors will allow you to automatically integrate with other existing libraries like sol2, chaiscript, etc.

The biggest pain point I found was working with the usertypes generically. The documentation is kind of bad in this case.

I thought I could just do this:

@dhkatz
dhkatz / SteamUpdateMods.py
Created July 6, 2020 03:07 — forked from firefly2442/SteamUpdateMods.py
AlphaSquad Arma3 Server Update via Steam Workshop
#!/usr/bin/env python
import subprocess, sys, os
STEAM_USERNAME = "steamusername"
STEAM_PASSWORD = "steampassword"
WORKSHOP_IDS = [["843425103", "@rhsafrf"],
["843593391", "@rhsgref"],
@dhkatz
dhkatz / voicechat.lua
Created June 15, 2020 06:37
Garry's Mod Server Optimizations
timer.Create("CalculatePlayersHearing", 0.5, 0, function()
for index, ply in pairs(player.GetAll()) do
if !ply.Char then ply.CanHearTrue = nil ply.CanHear = nil continue end
ply.CanHearTrue = {}
ply.CanHear = {}
for index, pl in pairs(player.GetAll()) do
if !pl.Char then continue end
if pl == ply then ply.CanHear[#ply.CanHear + 1] = ply ply.CanHearTrue[pl] = true continue end
if ply:GetPos():DistToSqr(pl:GetPos()) < GetConVar("Voice.Range")^2 then
ply.CanHearTrue[pl] = true
@dhkatz
dhkatz / dependecies.lua
Created June 23, 2019 21:36
Directed Graph Execution Order in Lua
local ____symbolMetatable = {__tostring = function(self)
if self.description == nil then
return "Symbol()"
else
return "Symbol(" .. tostring(self.description) .. ")"
end
end}
function __TS__Symbol(description)
return setmetatable({description = description}, ____symbolMetatable)
end
@dhkatz
dhkatz / digraph.ts
Last active June 25, 2019 02:36
Directed Graph Execution Order
type VertexResolvable = string | Vertex;
class Vertex {
public edges = { from: new Set<Edge>(), to: new Set<Edge>() };
public name: string | undefined = undefined;
}
class Edge {
public constructor(public from: Vertex, public to: Vertex) {
@dhkatz
dhkatz / python-es7-comparison.md
Last active February 26, 2019 15:27
Python 3.7+ vs ES2018+ Syntax Comparison

Python 3.7+ vs ES2018+ Syntax Comparison

Introduction

This gist is meant to outline differences in syntax and performing common operations in both Python and Javascript (ES2018). This gist may not cover absolutely everything, so a quick double check with Google or StackOverflow can be a big help.

This gist will not cover the extreme basics of the language (i.e. array indexing) because many of these things are intuitive or just common across most languages.

Many of these newer ES2018+ language features might not be available in all browsers. It’s best to use a transpiler/compiler like Babel or Typescript to generate browser compatible code.

@dhkatz
dhkatz / checks.ts
Last active June 15, 2019 23:37
Create custom command permission checks using Typescript decorators.
// Decorator check example, similar to discord.py
// Requires Typescript with "experimentalDecorators": true and "emitDecoratorMetadata": true in tsconfig
// Also requires the "reflect-metadata" module
// in src/util/checks.ts
import { Command, CommandoMessage } from 'discord.js-commando';
export function customCheck(check: (message: CommandoMessage, args: object) => Promise<boolean> | boolean, reason?: string) {
return function <T extends ProxyCommand>(target: T, key: string, descriptor: PropertyDescriptor): PropertyDescriptor {
@dhkatz
dhkatz / msys2-visual-studio-code.md
Last active November 4, 2024 14:06
Using MSYS2 with Visual Studio Code

Using MSYS2 with Visual Studio Code is extremely easy now thanks to the Shell Launcher extension by Tyriar.

First, install the extension and reload Visual Studio Code.

Then, open the settings.json to edit your settings.

Add the field shellLauncher.shells.windows. I recommend using autocompletion here so that all the default shells are added.

You should having something like this now: