Skip to content

Instantly share code, notes, and snippets.

@jgke
jgke / index.ts
Created March 24, 2024 09:38
Show TypeDoc namespace members on the same page
// filename: ./typedoc-theme/index.ts
// compile with:
// npx tsc --target esnext --module commonjs --moduleresolution node --esmoduleinterop index.ts
import { Application, DeclarationReflection, DefaultTheme, ReflectionKind, UrlMapping } from 'typedoc';
export class Theme extends DefaultTheme {
buildUrls(reflection: DeclarationReflection, urls: UrlMapping[]): UrlMapping[] {
if (reflection.kind === ReflectionKind.Project) return super.buildUrls(reflection, urls);
if (reflection.kind === ReflectionKind.Namespace || reflection.kind === ReflectionKind.Module) {
const mapping = super['getMapping'](reflection);
@jgke
jgke / proto.ts
Created February 24, 2024 12:04
Generated code from ts-proto
/* eslint-disable */
import _m0 from "protobufjs/minimal";
export const protobufPackage = "levelformat";
export enum NullValue {
/** NULL_VALUE - Null value. */
NULL_VALUE = 0,
UNRECOGNIZED = -1,
}
@jgke
jgke / spam.py
Created July 1, 2021 09:14
Valuable contribution for the CS:GO community
n = 1
bindname = "bindnamehere"
print(f'alias "${bindname}" "${bindname}1"')
print(f'bind "l" "${bindname}"')
try:
while True:
s = input()
@jgke
jgke / no-mouse-sleep.c
Created March 26, 2021 08:58
Disable USB device autosuspend with setuid C binary
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
/*
Throw into Makefile & compile with sudo make:
no_mouse_sleep: no-mouse-sleep.c
#!/bin/bash
# Scrape license statistics from GitHub
OAUTH=youroauthkeyhere
LICENSES="afl-3.0 apache-2.0 artistic-2.0 bs1-1.0 bsd-2-clause bsd-3-clause bsd-3-clause-clear cc cc0-1.0 cc-by-4.0 cc-by-sa-4.0 wtfpl ecl-2.0 epl-1.0 eupl-1.1 agpl-3.0 gpl gpl-2.0 gpl-3.0 lgpl lgpl-2.1 lgpl-3.0 isc lppl-1.3c ms-pl mit mpl-2.0 osl-3.0 postgresql ofl-1.1 ncsa unlicense zlib"
LANGUAGES="Ada C C%2B%2B D Go Java JavaScript Rust TypeScript"
for lang in $LANGUAGES; do
@jgke
jgke / fibmodm.py
Last active August 29, 2015 14:18
Fibonacci modulo m
def _fibonacci(n, modulo):
if n == 0:
return (0, 1)
# get F(n/2) and F(n/2+1)
a, b = _fibonacci(n//2, modulo)
# F(n/2 + 1)*2 - F(n/2) might be negative because of the modulo
t = b*2 - a
if t < 0:
t += modulo
@jgke
jgke / twosat.py
Created March 9, 2015 13:12
2-SAT solver
def DFS(v, visited, graph):
"Depth-first search through graph, appending current node when returning"
if visited[v]:
return []
visited[v] = True
output = []
for w in graph[v]:
output += DFS(w, visited, graph)
output.append(v)
return output
@jgke
jgke / gist:b85bc03d163a63d0e3aa
Last active August 29, 2015 14:16
keybase.md

Keybase proof

I hereby claim:

  • I am jgke on github.
  • I am jgke (https://keybase.io/jgke) on keybase.
  • I have a public key whose fingerprint is 348A 793E 2A61 F984 AD2E BABC DBA1 C8DF C419 D4A0

To claim this, I am signing this object: