Last active
May 23, 2016 19:32
-
-
Save harageth/0160cab45cc28caf46d80315d397df49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul { padding: 0; margin: 0; } | |
li { list-style-type: none; font-family: sans-serif; padding: 0 1em; line-height: 2em;} | |
li:hover { background-color: #f95; } | |
.name { font-weight: bold;} | |
.type { opacity: 0.5; padding: 0 1em;} | |
.title { margin: 0.5em; font-size: 2em; } | |
.code { font-size: 16px; padding: 1em; font-family: "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", monospace;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(agent); | |
var $ = {}; | |
agent.container.appendChild(domBuilder([ | |
["ul$list", {onclick: onClick}], | |
[".title$name"], | |
[".code$data"] | |
], $)); | |
agent.scan(onEntry)(); | |
function onEntry(name, type) { | |
$.list.appendChild(domBuilder( | |
["li", { | |
"data-name": name, | |
"data-type": type, | |
}, | |
["span.name",name], | |
["span.type",type], | |
], $)); | |
} | |
function onClick(evt) { | |
agent.doStuff("/dev/sda1")(function (err, data) { | |
if (err) { throw err; } | |
console.log(data); | |
}); | |
var target = evt.target; | |
while (target.tagName !== 'LI') { | |
target = target.parentNode; | |
if (!target) { return; } | |
} | |
var name = target.dataset.name; | |
var type = target.dataset.type; | |
if (type === "file") { | |
agent.read(name)(function (err, data) { | |
if (err) { throw err; } | |
$.name.textContent = name; | |
$.data.textContent = ""; | |
$.data.appendChild(domBuilder( | |
["pre", | |
["code", data] | |
] | |
)); | |
// console.log(name, data); | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local root = "." | |
local exports = {} | |
-- some sample lua functions using callbacks to return values | |
function exports.scan(callback) | |
return scandir(root, callback) | |
end | |
function exports.read(name) | |
return readfile(root .. "/" .. name) | |
end | |
function exports.doStuff(fsSearch) | |
-- ok so we need to get the mounted dir from the mount name | |
local temp = exec("grep", {args={"-E", fsSearch}}, | |
exec("df", {args={"-h"}}, "") | |
) | |
print(temp) | |
local base = string.match(temp, "/%a+") | |
print(base) | |
local stat, err = pcall(writefile, base.."/testFile","") | |
if err then | |
print("we had issues writing to this location") | |
print(exec("umount", {}, fsSearch)) | |
print(exec("fsck", {}, "")) | |
mkdir("/mnt/cbsvolume") | |
exec("mount", {args={fsSearch}}, "/mnt/cbsvolume") | |
end | |
if(err and stat) then | |
print("failed to write the file") | |
--exec("unmount", {}, fsSearch) | |
--exec("fsck",{},"") -- we very well might need to stream these results back and ask the user to do something about it | |
--wait for solution to above | |
--mkdir("/mnt/cbsvolume") | |
--exec("mount", {args={fsSearch}}, "/mnt/cbsvolume") | |
end | |
-- lets split on whitespace and get the 1st and 5th values. | |
--temp = string.match(temp, "%d+%%") | |
--temp = exec("awk", {args={"print $5, $1"}}, temp) | |
print(temp) | |
return temp | |
end | |
exports.exec = exec | |
return exports |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment