Skip to content

Instantly share code, notes, and snippets.

View Torxed's full-sized avatar

Anton Hvornum Torxed

View GitHub Profile
import subprocess
import signal
import os
import sys
import time
import termios
old_settings = termios.tcgetattr(sys.stdin)
import readchar
@Torxed
Torxed / test.c
Created November 15, 2016 14:07
test.c
public static T[] RemoveAt<T>(this T[] source, int index)
{
T[] dest = new T[source.Length - 1];
if( index > 0 )
Array.Copy(source, 0, dest, 0, index);
if( index < source.Length - 1 )
Array.Copy(source, index + 1, dest, index, source.Length - index - 1);
return dest;
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):
@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 *
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()
from threading import *
from time import sleep
import uuid
class worker(Thread):
def __init__(self):
Thread.__init__(self)
self.start()
def run(self):
@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')
@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 / 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 / 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,