A Dropbox script that can be used in ComputerCraft. Also provides an FS like API which could be wrapped like a virtual file system.
The syntax is quite simple:
using System; | |
using MathNet.Numerics.LinearAlgebra; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace Testing | |
{ | |
[TestClass] | |
public class UnitTest1 | |
{ | |
[TestMethod] |
Fun stuff with AST trees in python.
pow
and min
into max
tuple
s into list
sprint
statements into list
sreturn x,y,z
into _ = [x,y,z]
This is based of the Type hinting for scalar variables with some optimisations for for strings.
##Loose/weak values
This are values that represent that type. For instance 2
is an integer as is 2.0
and '2.0'
. This is similar for floats.
from functools import wraps | |
class NotifyProperty(property): | |
def __init__(self, Get, Set = None, Del = None, Doc = None): | |
Setter = None | |
if Set != None: | |
@wraps(Set) | |
def Setter(self, Value): | |
Set(self, Value) | |
self.Notify(Set.__name__, Value) | |
local Args = {...} --Read Args | |
local Files = { } --All Files to include | |
local OutHandle = nil --File Handle to write to | |
local getDir = fs.getDir or function(str) | |
return str:match("(.*/)") | |
end |
--JSON functions | |
--Credit goes to http://www.computercraft.info/forums2/index.php?/topic/5854-json-api-v201-for-computercraft/ | |
------------------------------------------------------------------ utils | |
local controls = {["\n"]="\\n", ["\r"]="\\r", ["\t"]="\\t", ["\b"]="\\b", ["\f"]="\\f", ["\""]="\\\"", ["\\"]="\\\\"} | |
local whites = {['\n']=true; ['r']=true; ['\t']=true; [' ']=true; [',']=true; [':']=true} | |
function removeWhite(str) | |
while whites[str:sub(1, 1)] do | |
str = str:sub(2) |
import time, hashlib | |
def GenRGBColour(string): | |
md=hashlib.md5() | |
md.update(string) | |
HexColour=md.hexdigest() | |
return [int(HexColour[0:2], 16), int(HexColour[2:4], 16), int(HexColour[4:6], 16)] | |
def GenRandomColour(): | |
return GenRGBColour(str(time.time())) |