Skip to content

Instantly share code, notes, and snippets.

View theneosloth's full-sized avatar

Stefan Kuznetsov theneosloth

View GitHub Profile
@theneosloth
theneosloth / ticker.py
Last active December 10, 2015 12:19
Facepunch Ticker Checker (Unfinished)
import urllib2,json,time,urllib2,getpass,hashlib,sys
from datetime import datetime
try:
f = open ("date.txt", "r")
date = json.load(f)
print "Date loaded is " +str(datetime.utcfromtimestamp(1356645899))
f.close()
except IOError:
print "File not found"
@theneosloth
theneosloth / tf2gen.py
Created January 3, 2013 02:19
Tf2 random item generator
import random
weapon_nouns = ["Bat","Bottle","Fists","Launcher","Knife","Axe","SMG","Kukri","Syringe Gun","Flame Thrower","Sticky Launcher","Huntsman","Saw","Shotgun","Revolver"]
weapon_adjectives = ["Pain","Direct","Charging","Power","Eternal","Black","Crusader's","Back","Steel","Volcano","Persian","Family","Disciplinary","Atomic"]
hat_nouns = ["Hat","Cap","Helmet","Beanie","Fedora","Beard","Earbuds","Bucket","Mask","Head","Gasmask"]
hat_adjectives = ["Fancy","Mining","Football","Towering","Expensive","Detective","Splendid","Last"]
class Item:
def __init__(self):
@theneosloth
theneosloth / randomChoice.js
Last active December 13, 2015 22:19
Random choice from an array in javascript
function randomChoice(array)
{
var random = Math.random();
random *= array.length;
random = Math.floor(random);
return array[random]
}
@theneosloth
theneosloth / TextReader.py
Created February 24, 2013 02:30
Text file reader
import sys,time,os
try:
file = open(sys.argv[1])
except IndexError:
print "Error: please provide a file"
raw_input( "Press any key to exit")
print "Opened {0}".format(sys.argv[1])
lines = ""
@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"
@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 / 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 / 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 / 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 / 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)