Skip to content

Instantly share code, notes, and snippets.

View SquidDev's full-sized avatar
🦑
Under the sea

Jonathan Coates SquidDev

🦑
Under the sea
View GitHub Profile
@SquidDev
SquidDev / 00-Dropbox.md
Last active December 28, 2016 21:54
CC-Dropbox

ComputerCraft-Dropbox

A Dropbox script that can be used in ComputerCraft. Also provides an FS like API which could be wrapped like a virtual file system.

Usage

The syntax is quite simple:

using System;
using MathNet.Numerics.LinearAlgebra;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Testing
{
[TestClass]
public class UnitTest1
{
[TestMethod]
@SquidDev
SquidDev / 00-ReadMe.md
Created August 26, 2014 12:37
Sub-domain parsing

Sub-domain parsing

Sometimes you have domains like a.really.long.url.thing.com and you need to get the base domain name. Yes, you could run:

$domains = explode('.', $host_name);
$target = array_slice($domains, -2, 1);
$root = $target[0];
@SquidDev
SquidDev / 00-ReadMe.md
Created August 19, 2014 16:08
Fun stuff with AST trees

Fun stuff with AST trees in python.

  • Converts pow and min into max
  • Converts tuples into lists
  • Converts print statements into lists
  • Converts return x,y,z into _ = [x,y,z]
@SquidDev
SquidDev / 00-ReadMe.md
Created August 19, 2014 11:50
Scalar Type checking

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.

@SquidDev
SquidDev / 00-Notify.py
Last active August 29, 2015 14:02
Property Change Notify
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
@SquidDev
SquidDev / SEE Downloader.lua
Last active August 29, 2015 14:01
Installer for SEE
--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)
@SquidDev
SquidDev / HashColour.py
Created August 6, 2013 10:29
Some colour functions to generate a function from the current time or from a string.
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()))