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];
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 |
// [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] |
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) |