Last active
August 29, 2015 14:19
-
-
Save formula1/2b08e722ee04c76cb49e 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
// #! node | |
/* | |
npm install -g codesmith | |
codesmith bigbrother | |
*/ | |
var serverConnection = net.createConnection("codeSmithurl"); | |
var localServer = http.createServer(); | |
var user; | |
localServer.get("login",function(current_user){ | |
user = current_user; | |
serverConnection.emit("/currentUser", user); | |
}); | |
localServer.get("logout",function(old_user){ | |
user = void(0); | |
}); | |
localServer.get("help", function(request){ | |
if(!user) return; | |
serverConnection.get("/helpRequest", request, function(help){ | |
if(help.type === "remote"){ | |
displayDesktopNotification("TA "+help.TA.name+" will help you remotely, Go to "+help.help_url); | |
//Make the whole thing an anchor | |
} | |
if(help.type === "local"){ | |
displayDesktopNotification("TA"+help.TA.name+" is comming to you now, Yell at him, if he's taking too long"); | |
} | |
}); | |
}); | |
var kbs = checkForAvailableKeyboards(); | |
kbs.forEach(function(kb){ | |
kb.on("stroke", function(){ | |
kb.apmUpdate(); //pretty difficult | |
kb.lastStroke = Date.now(); | |
}); | |
}) | |
setInterval(function(){ | |
var main_and_helper = findCurrentMainAndHelper(kbs); | |
if(main_and_helper.helper.lastInteraction() > 30*1000*60){ | |
displayDesktopNotification("Should Switch Keyboard"); | |
} | |
}); | |
fs.watchDirectoryRecursive(process.cwd(),function(filename){ | |
var diff = git.diff(filename, "HEAD"); | |
serverConnection.send("saves",diff); | |
var res = runTest(); | |
serverConnection.send("results", results); | |
}); | |
git.watchForCommit(process.cwd(),function(){ | |
var diff = git.diff(filename, "HEAD^", "HEAD"); | |
serverConnection.send("commit", diff); | |
}); |
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
var team = []; | |
var reviewer; | |
var peer_review = { | |
disagrees:[], | |
added:[] | |
}; | |
var automated; | |
function ChangeReviewer(person){ | |
reviewer = person; | |
} | |
function beginCodeReview(){ | |
var code = BigBrother.get("/code"); | |
automated = TestCurrentCode(code); | |
var codeDisplay = displayCode(code); | |
displayIssuesOnCode(automated, codeDisplay); | |
var score = getScore(automated); | |
displayScore(score); | |
} | |
function endCodeReview(){ | |
BigBrother.send("/peer_review", { | |
reviewer:reviewer, | |
peer_review:peer_review, | |
automated:automated | |
}); | |
} | |
function peerDisagreeWithItem(issue){ | |
peer_review.disagree.push(issue); | |
} | |
function peerAddItem(issue){ | |
peer_review.added.push(issue); | |
} | |
function TestCurrentCode(code){ | |
//This can be done in big brother | |
var score = { | |
bad: { | |
global_scope: | |
file_size: | |
good_variableNames: | |
displays_sensitive_info: | |
too_many_arguments: | |
} | |
good:{ | |
filename_equal_to_export: | |
human_js_pass: humanJs(code) | |
js_lint_pass: jsLint(code) | |
has_gitignore: | |
} | |
}; | |
return score; | |
} |
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
function requestFeedBack(subject,message,otherthings){ | |
var feedback = feedbacks.add(new FeedBack(subject,message,otherthings); | |
students.broadcastOnEmail(feedback.formatForEmail()); | |
} | |
Central.on("email-response", function(response){ | |
var fb = feedbacks.find(response.feedback); | |
if(fb === null){ | |
feedbacks.add(new Feeback(response.feedback)); | |
if(response.sender.type === "TA"){ | |
TA.find(response.sender).addOriginal(response); | |
response.forwardTo("BigBrother"); | |
return | |
} | |
if(response.sender.type === "Student"){ | |
Students.find(response.sender).addOriginal(response); | |
if(response.subject.type === "TA"){ | |
TA.find(response.subject).addFeedBack(response); | |
response.forwardTo("BigBrother"); | |
return; //Important, TAs should not get messages about TAs | |
} | |
if(response.subject.type === "Challenges"){ | |
Challenges.find(response.subject).addFeedBack(response); | |
} | |
response.forwardTo(TAs.findLocalTo(response)); | |
} | |
}else{ | |
fb.addAnswer(response); | |
Students.find(response.student).addAnswer(respone); | |
} | |
}); | |
function createFeedBack(){ | |
} |
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
Button.onClick(function(){ | |
showPrompt().onSubmit(function(force){ | |
if(!force && !validate(this)) return Error(reason); | |
server.askForHelp(getReason); | |
}); | |
}); | |
DisplayQueue= function(list,me){ | |
displayNumberAhead(list.indexOf(me)) | |
} | |
Server.on("help_on_the_way", function(help){ | |
if(help.type === "in_person"){ | |
displayDesktopNotification("in_person"); | |
}else if(help.type === "remote"){ | |
displayDesktopNotification("remote"); | |
} | |
}); | |
PollingCode = function(){ | |
Bigbrother.request("/currentCode", function(data){ | |
server.sendToHelp(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
function signinWithGithub(){ | |
oAuth(); | |
} | |
function displayArchive(beforeDate){ | |
server.query("before",beforeDate).displayAsList(); | |
} | |
function displayBig(Item){ | |
displayCurrentDay() | |
displayRepository(); | |
displayForkInstructions() | |
displayEditor() | |
} | |
function displayForkInstructions(){ | |
this.onClick(autoClone); | |
} | |
function displayEditor(){ | |
displayAsCodeMirror(); | |
} | |
server.on("email", function(){ //Mostly serverside | |
displayMessage(); | |
}) | |
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
//Take a While | |
notification.subscribeToAQuery() | |
notification.on("toCentralize", function(notification){ | |
sendToEmail(notification); | |
sendToSlack(notification); | |
}); |
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
Issue = { | |
local_or_foreign:local|foreign, | |
number_of_denials: integer | |
currently_taken: Boolean | |
Subject: [tags] | |
} | |
Help_desk.listIssues = function(issues){ | |
issues.forEach(function(issue){ | |
if(issue.isLocal) displayAsLocal(issue); | |
if(issue.isForeign) displayAsForeign(issue); | |
if(issue.graduatedAtMe) displayAsImportant(issue); //Harder, | |
}); | |
} | |
HelpDesk.TakeOne(issue) | |
HelpDesk.cantTake = function(issue){ | |
server.graduateIssue(issue); | |
} |
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
var cache = []; | |
function changeRange(graph,start,end,cb){ | |
var reqs = {},startIndex=0,endIndex=cache.length-1; | |
if(start < cache[0].x){ | |
reqs.start = request("/graphData",{start:start, end:cache[0].x})); | |
}else{ | |
startIndex = cache.findClosest({x:start}); | |
} | |
if(end > cache[endIndex].x){ | |
reqs.end = request("/graphData",{start:cache[endIndex].x, end:end})); | |
}else{ | |
endIndex = cache.findClosest({x:start}); | |
} | |
Promise.allDone(reqs).then(function(values){ | |
if(values.start) cache = values.start.concat(cache); | |
if(values.end) cache = cache.concat(values.end); | |
cb(cache.slice(startIndex, endIndex-startIndex)); | |
}); | |
} | |
function histograms(data,){ | |
if(isBooleanData(data)) return booleanHistogram(); | |
if(isLinearData(data)) return linearHistogram(); | |
} | |
function scatterPlot(data){ | |
if(isBooleanData(data)) return oneDimensionalPlot(data); | |
if(isLinearData(data)) return twoDimensionalPlot(data); | |
} | |
function booleanData(data,precision,range){ | |
var num_bars = Math.ciel((range[1] - range[0])/precision); | |
var bars = {}; | |
for(var i = 0;i<num_bars;i++){ | |
bars[i] = {key:range[0]+i*precision, value:0}; | |
data.forEach(function(item){ | |
if( range[0]+(i-1)*precision<item.x <range[0]+(i+1)*precision ) | |
bars[i].value++; | |
}) | |
} | |
displayHistogram(bars); | |
} | |
function linearData(data,precision,range){ | |
var num_bars = Math.ciel((range[1] - range[0])/precision); | |
var bars = {}; | |
for(var i = 0;i<num_bars;i++){ | |
bars[i] = {key:range[0]+i*precision, value:false}; | |
data.forEach(function(item){ | |
if( range[0]+(i-1)*precision<item.x <range[0]+(i+1)*precision ){ | |
if(bars[i].value === false) bars[i].value = item.y; | |
else bars[i].value = (bars[i].value+item.y)/2; | |
} | |
}) | |
} | |
displayHistogram(bars); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment