Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

David Katz dhkatz

🏠
Working from home
View GitHub Profile
@dhkatz
dhkatz / SteamUpdateMods.py
Created Jul 6, 2020 — 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 Jun 15, 2020
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 Jun 23, 2019
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 Jun 25, 2019
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 Feb 26, 2019
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 Jun 15, 2019
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 May 6, 2021
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 Sep 20, 2018
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
@dhkatz
dhkatz / boss_framework.lua
Last active Sep 14, 2018
Garry's Mod Boss Framework
View boss_framework.lua
-- Put in either addons/boss_framework/lua/autorun/boss_framework.lua or just lua/autorun/boss_framework.lua
if SERVER then
local BossEnabled = CreateConVar("boss_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable/disable the boss system.")
local BossCooldown = CreateConVar("boss_cooldown", "300", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Cooldown between when a boss can even possibly spawn.")
local BossThreshold = CreateConVar("boss_threshold", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Number of players required for a boss to spawn.")
AddCSLuaFile()
--------------------
@dhkatz
dhkatz / App.vue
Last active Jun 27, 2019
Garry's Mod Vue.js Example
View App.vue
<template>
<div id="app">
<Vitals ref="vitals" id="vitals"></Vitals>
</div>
</template>
<script>
import Vitals from './components/Vitals.vue';
export default {
name: 'app',