Skip to content

Instantly share code, notes, and snippets.

@appcove
appcove / cursor-move.py
Created August 16, 2020 04:00
A simple example of using ANSI escapes to move around the screen and draw
import sys
import tty
import termios
import os
s = os.get_terminal_size()
ROWS = s.lines
COLS = s.columns
print('\n'*ROWS)
SIZE_X = 20
SIZE_Y = 20
TOP_Z = 0.750
CUTTER_DIAMETER = 0.750
#This is just some misc setup stuff
from decimal import Decimal
def drange(start, stop, step):
value = Decimal(start)
@appcove
appcove / loop.py
Last active December 18, 2015 21:24
for x in range(-400,400,100):
for y in range(-400,400,100):
box(x,y,80,45)
# vim:encoding=utf-8:ts=2:sw=2:expandtab
from AppStruct.Util import *
from AppStruct.Web.Util import *
import AppStruct
import AppStruct.Util
import AppStruct.Web.Util
import FileStruct
@appcove
appcove / Admin.py
Created September 13, 2013 05:08
Sample AppStruct.Base.V1 code
# vim:encoding=utf-8:ts=2:sw=2:expandtab
from Project import *
from AppStruct.Base.V1 import *
from AppStruct.Security import SHA1, RandomHex
###############################################################################
class Admin(metaclass=MetaRecord):
# vim:encoding=utf-8:ts=2:sw=2:expandtab
from AppCove import *
import AppCove.Network
###############################################################################
@Expose
@appcove
appcove / sessiondictproxy.py
Created March 4, 2013 07:50
Illustrating the power of python.
###############################################################################
class SessionDictProxy():
'''
Emulates an aadict() object, but all has/get/set/del operations convert to/from
json objects stored in Redis.
'''
def __init__(self, Token, RedisKey):
object.__setattr__(self, '_Token', Token)
@appcove
appcove / FlagType.py
Last active December 11, 2015 22:18
AppStruct Examples
FlagType
An extended `int` type which implements a very convenient mechansim for
defining flags and operating on them.
One of the primary uses is the convenient syntax:
flags = +front -back +side -top
Calling the unary operator (__pos__, __neg__) by prefixing one of the
@appcove
appcove / Activity.py
Created September 12, 2012 01:53
Example database queries
# vim:encoding=utf-8:ts=2:sw=2:expandtab
from AppStruct.Util import *
from AppStruct.WSGI.Util import ML
from HomeSchool import App
from datetime import date
from . import Student
from . import Subject
@appcove
appcove / example.py
Created April 30, 2012 02:15
Examples of AppStruct DB Library
# vim:encoding=utf-8:ts=2:sw=2:expandtab
from AppStruct.Util import *
from AppStruct.WSGI.Util import ML
from HomeSchool import App
from datetime import date
from . import Student
from . import Subject