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 / bin-example.lua
Created July 23, 2015 14:58
Parsel Operators
local parsel = setmetatable({}, {__index = _G})
setfenv(assert(loadfile("lib/parsel.lua") or loadfile("../lib/parsel.lua"), "Cannot find parsel"), parsel)()
local textutils = assert(loadfile("lib/pprint.lua") or loadfile("../pprint.lua"), "Cannot find pprint")()
local a = parsel.symbol "a"
local abtest = (a/"b"/"test"):many()
local braces = abtest:between("{", "}")
local p = (abtest .. braces) % function(res) return { outer = res[1], inner = res[2]} end
@SquidDev
SquidDev / LASM.JSON-tmLanguage
Last active August 29, 2015 14:10
Sublime Language for LuaAssemblyTools (https://github.com/mlnlover11/LuaAssemblyTools)
// [PackageDev] target_format: plist, ext: tmLanguage
{
"name": "Lua Assembly",
"scopeName": "source.lasm",
"fileTypes": ["lasm"],
"uuid": "3507f71d-f02d-4af7-ab7d-027c8e7313de",
"patterns": [
{
"beginCaptures": {
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)