Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

David Katz dhkatz

🏠
Working from home
View GitHub Profile
@dhkatz
dhkatz / a3update.py
Last active July 1, 2022 20:27 — forked from Freddo3000/a3update.py
Arma 3 Linux server and mod updater (workshop)
View a3update.py
#!/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 March 11, 2022 03:07
Sol2 + RTTR
View README.md

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
View SteamUpdateMods.py
#!/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
View voicechat.lua
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
View dependecies.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
View digraph.ts
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
View python-es7-comparison.md

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.
View checks.ts
// 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 March 24, 2023 07:23
Using MSYS2 with Visual Studio Code
View msys2-visual-studio-code.md

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:

@dhkatz
dhkatz / door_attach_debug.lua
Last active September 20, 2018 05:30
Debug Door Attaching
View door_attach_debug.lua
CreateClientConVar("pd2_drill_debug", "0", true, false, "Draw Payday 2 Drill debug information.")
local doors = { ["prop_door_rotating"] = true, ["func_door"] = true, ["func_door_rotating"] = true }
hook.Add("PostDrawTranslucentRenderables", "DoorPos", function()
if not cvars.Bool("pd2_drill_debug") then return end
-- Find the drill we're working with
local drill = NULL
for _, e in ipairs(ents.FindInSphere(LocalPlayer():GetPos(), 500)) do
if e:GetClass() == "pd2_drill" then