Skip to content

Instantly share code, notes, and snippets.

View Torxed's full-sized avatar

Anton Hvornum Torxed

View GitHub Profile
@Torxed
Torxed / File2.py
Last active August 29, 2015 14:03
from game import gamehandle
def givexp(ammount):
gamehandle.load_variables()
gamehandle.give_xp(ammount)
from game import gamehandle
from file2 import givexp
def main():
print('1) give xp')
print('2) give 500 xp')
donow = input()
if donow == '1':
givexp(200) #this is in File2.py
if donow == '2':
gamehandle.give_xp(500)
@Torxed
Torxed / filetegrity.spec
Created November 18, 2015 16:15
Used to "compile" C:\Users\anthvo\Desktop\filetegrity.py via pyinstaller.exe --onefile filetegrity.py
# -*- mode: python -*-
block_cipher = None
# > pyinstaller.exe --onefile filetegrity.py
a = Analysis(['filetegrity.py'],
pathex=['C:\\Users\\anthvo\\Desktop'],
binaries=None,
datas=None,
@Torxed
Torxed / keep_alive.py
Created January 12, 2016 15:32
A example where `Keep-Alive` is used in the HTTP/1.X protocol and Python
from urllib3 import HTTPConnectionPool
pool = HTTPConnectionPool('www.google.se', maxsize=1)
ret = pool.request('GET', '/')
print(ret.status)
ret_two = pool.request('GET', '/search', fields={'q' : 'python'})
print(ret_two)
@Torxed
Torxed / test.py
Created March 11, 2016 16:09
Short timing example between dict, list and set in python.
from time import time
from random import random
# Without checking the dictionary
x = {}
s = time()
for i in range(10000000):
x[round(random(), 6)] = True
e = time()
print(e-s, len(x), 'Using dict() for inserts')
@Torxed
Torxed / myscript.py
Last active March 25, 2016 20:03
simple login example
#Definerer databasene og
database = {'Andreas' : 'Password1',
'Andy' : 'Password2'}
#Definerer funksjonene
def godkjent():
print ('Halla ' +bruker)
def ikkegodkjent():
print ('Beklager ' +bruker+ ', du har ikke tilgang her')
from threading import *
from time import sleep
import uuid
class worker(Thread):
def __init__(self):
Thread.__init__(self)
self.start()
def run(self):
from time import time
theList = [1, 2, True, False, False]
for y in range(3):
start = time()
for i in range(1000000):
result = [x for x in theList if type(x) is bool]
end = time()
@Torxed
Torxed / 3d.py
Created June 12, 2016 11:53
Working custom pyglet class.
import pyglet, math
from pyglet.gl import *
key = pyglet.window.key
from pyglet import app
from pyglet.libs.win32 import _user32
from pyglet.libs.win32.constants import *
from pyglet.libs.win32.winkey import *
from pyglet.libs.win32.types import *
import pyglet
from pyglet.gl import *
# REQUIRES: AVBin
pyglet.options['audio'] = ('alsa', 'openal', 'silent')
key = pyglet.window.key
# xfce4-notifyd
class main(pyglet.window.Window):
def __init__ (self):