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 / swe_spawner.lua
Last active September 24, 2017 05:32
Spawn NPCs with a custom class and/or playermodel using a tool. Install to "garrysmod\lua\weapons\gmod_tool\stools"
TOOL.Category = "Event"
TOOL.Name = "Spawner"
TOOL.ClientConVar["type"] = "npc_citizen"
TOOL.ClientConVar["health"] = "500"
TOOL.ClientConVar["weapon"] = "none"
TOOL.ClientConVar["model"] = ""
TOOL.ClientConVar["proficiency"] = "AVERAGE"
TOOL.Information = {
{
### Keybase proof
I hereby claim:
* I am doctorjew on github.
* I am dhkatz (https://keybase.io/dhkatz) on keybase.
* I have a public key ASCNnx3FjHuOII6TLsvslaLS7wHc2lreiygot-r0LS9zygo
To claim this, I am signing this object:
@dhkatz
dhkatz / boss_framework.lua
Last active September 14, 2018 05:13
Garry's Mod Boss Framework
-- 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 / door_attach_debug.lua
Last active September 20, 2018 05:30
Debug Door Attaching
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 / guide.md
Last active October 6, 2018 21:30
Improved A-Wing on the new SWVR Base

Star Wars Vehicles: Redux

Introduction

With SWVR, all your code is designed to be put inside ENT:Initialize() and there only. If you find yourself having to write code elsewhere (such as overriding functions), then the base is missing a feature! Message me to get it added ASAP.

Because of this, assume ALL code examples below are inside of ENT:Initialize()

Setting Up

@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 / 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 / App.vue
Last active June 27, 2019 19:31
Garry's Mod Vue.js Example
<template>
<div id="app">
<Vitals ref="vitals" id="vitals"></Vitals>
</div>
</template>
<script>
import Vitals from './components/Vitals.vue';
export default {
name: 'app',