Skip to content

Instantly share code, notes, and snippets.

View theneosloth's full-sized avatar

Stefan Kuznetsov theneosloth

View GitHub Profile
@theneosloth
theneosloth / Makefile
Created May 1, 2023 04:56
Use nix-shell in a makefile
SHELL := /bin/sh
export PATH := $(shell nix-shell -p openapi-generator-cli --run 'echo $$PATH')
output:
mkdir -p output && cd output && openapi-generator-cli generate -i $URL -g clojure
clean:
rm -r output
@theneosloth
theneosloth / dotCycler.js
Last active February 24, 2021 23:23
Dot Cycler
const dotCycler = (maxDots) => {
let dotCount = -1;
return () => {
dotCount = (dotCount + 1) % (maxDots + 1);
return '.'.repeat(dotCount);
}
}
@theneosloth
theneosloth / goggame-1454587428.info
Created January 7, 2019 06:24
Add NVSE as a launch option for Fallout: New Vegas in the GOG Galaxy launcher
{
"clientId": "50144443643664262",
"gameId": "1454587428",
"language": "English",
"languages": [
"en"
],
"name": "Fallout: New Vegas",
"overlaySupported": true,
"playTasks": [
@theneosloth
theneosloth / goggame-1409964317.info
Last active April 23, 2018 23:22
Add the special forces SWAT 4 mod to the GOG Galaxy launch options
{
"clientId": "49700451081649670",
"gameId": "1409964317",
"language": "English",
"languages": [
"en"
],
"name": "SWAT 4 Gold Edition",
"playTasks": [
{
@theneosloth
theneosloth / foobar.py
Created June 22, 2016 01:57
Returns a percentage difference between two sets of values. Used as a solution for the level 1 google foobar problem
def answer(y, x):
# Make sure we are always comparing the smaller list to the larger list.
if (sum(x) > sum(y)):
y,x = x,y
# The quotient of each one of the matching elements in an array
result = [b/a if a else 0 for a,b in zip(sorted(y), sorted(x))]
# Average percentage of increase, rounded up to one.
return int(100 - (sum(result) / float(len(result))) * 100)
@theneosloth
theneosloth / newtons_square.py
Created May 11, 2016 00:52
Estimates a square root using newton's method.
def mySqrt (a, precision):
curr_guess = a/2
last_guess = curr_guess*2
iterations = 1
while (abs(last_guess - curr_guess) > precision):
last_guess = curr_guess
curr_guess = (a/curr_guess + curr_guess)/2
iterations+=1
print("Square root for {0} is {1}".format(a, curr_guess))
@theneosloth
theneosloth / BotRunner.scala
Last active February 16, 2016 02:34
A simple wrapper for java.awt.Robot
import java.awt.Robot
import java.awt.event.{InputEvent,KeyEvent}
class SimpleBot extends Robot{
val lmb = InputEvent.BUTTON1_MASK
val rmb = InputEvent.BUTTON2_MASK
val min_delay = 200
def leftClick(){
this.mousePress(lmb)
@theneosloth
theneosloth / en_models.lua
Last active December 29, 2015 22:48
EnhancedDamage Model List
PlayerModels = {}
PlayerModels["female"] = {
"models/player/group01/female_01.mdl",
"models/player/group01/female_02.mdl",
"models/player/group01/female_03.mdl",
"models/player/group01/female_04.mdl",
"models/player/group01/female_05.mdl",
"models/player/group01/female_06.mdl",
"models/player/group01/female_07.mdl",
"models/player/group03/female_01.mdl",
@theneosloth
theneosloth / methods.py
Last active September 13, 2015 21:06
Import all methods from the files in a given directory.
import glob
import imp
from os.path import join, basename, splitext
def importModules(dir):
modules = []
methods = []
for path in glob.glob(join(dir, '[!_]*.py')):
name, ext = splitext(basename(path))
@theneosloth
theneosloth / zombie.cfg
Last active August 29, 2015 13:56
Counter Strike:Global Offensive Zombie Bot Config
//To run open a deathmatch server and run this script. Other modes work too but they sometime require a changelevel
game_type 3 // Setting the game to deathmatch (might need a changelevel if the server was running a non-dm mode)
game_mode 2
//mp_damage_scale_ct_body 0.25 //Couldnt get these settings to work
//mp_damage_scale_ct_head 2 //(Got them from the official valve wiki)
mp_teamname_1 "Zombies"