Skip to content

Instantly share code, notes, and snippets.

View benjameep's full-sized avatar

Benjamin Earl benjameep

View GitHub Profile
@benjameep
benjameep / ShowQuestionAnswers.PNG
Last active April 18, 2017 21:22
Regex Recipe
ShowQuestionAnswers.PNG
@benjameep
benjameep / names.txt
Created October 24, 2017 23:46
US-census-names-gender
mary,F
anna,F
emma,F
elizabeth,F
minnie,F
margaret,F
ida,F
alice,F
bertha,F
sarah,F
@benjameep
benjameep / displayReqTree.js
Created October 24, 2017 23:50
Displays the course req tree in the given container
var levels = [],
cellWidth = 0,
padding = 5,
spaceForEachRow, canvas, container
var ctx = canvas.getContext('2d')
var dir = n => n / Math.abs(n) || 0
function createCanvas() {
var canvas = document.createElement('canvas')
container.appendChild(canvas)
@benjameep
benjameep / moomoohack.js
Last active November 2, 2017 18:41
Auto heal on moomooio
var ws
var me = {
health: 100
}
var mouseIsDown = false
WebSocket.prototype.oldSend = WebSocket.prototype.send;
WebSocket.prototype.send = function (m) {
onSend(m)
this.oldSend(...arguments);
if (!ws) { // First Time
@benjameep
benjameep / cookie-trail.md
Last active December 21, 2017 01:07
Lularoe Queue-it cookie trail
@benjameep
benjameep / pseudo-words.js
Created November 28, 2017 18:00
Gets a list of pseudo-words
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Typical action to be performed when the document is ready:
var words = xhttp.responseText.match(/<b>\w+<\/b>/g).map(n => n.slice(3,-4).capitalize())
console.log(words.join(' '))
}
@benjameep
benjameep / d2l-login-cookies.js
Created January 22, 2018 21:53
Make d2l api calls from the command line using account creds, use this function to get the cookies
var request = require('request').defaults({jar: true})
function login(username, password, cb){
request.post({
// This is the first url sent when you press login
url: 'https://byui.brightspace.com/d2l/lp/auth/login/login.d2l',
form: {
userName: username,
password: password,
@benjameep
benjameep / d2lapi.js
Created February 7, 2018 21:46
Shortcut for testing d2l api call, while reading the documentation
// Wrap all of the 'GET' words in an a tag which fires the function
$('dt > .descname:contains("GET")').get().map(n => $(n)).map($n => $n.wrap('<a onclick="d2lapi(`'+$n.parent().text().replace(/(GET|[^\w/()])/g,'')+'`)"></a>'));
window.d2lapi = function(ref){
// The things you need to look up every single time
var version = {lp:'1.20',le:'1.27',LR:'1.2',ep:'2.5',ext:'1.3',rp:'1.5',lti:'1.1.1'};
// inject the version number
ref = ref.replace(/(\w+)\/\(version\)/,(m,p) => `${p}/${version[p]}`);
// just set a variable in the console called 'subdomain' if you want a different subdomain
["time","year","people","way","man","day","thing","child","government","part","life","case","woman","work","system","group","number","world","area","course","company","problem","service","hand","party","school","place","point","house","country","week","member","end","word","example","family","fact","state","percent","home","month","side","night","eye","head","information","question","business","power","money","change","interest","order","book","development","room","water","form","car","other","level","policy","council","line","need","effect","use","idea","study","lot","job","name","result","body","friend","right","authority","view","report","bit","face","market","hour","rate","law","door","court","office","war","reason","minister","subject","person","term","sort","period","society","process","mother","voice","police","kind","price","action","issue","position","cost","matter","community","figure","type","research","education","few","programme","minute","moment","girl","age","centre","control","value","health",
@benjameep
benjameep / newGradebook.js
Created March 20, 2018 00:16
Turn on the new Gradebook feature
const canvas = require('canvas-wrapper')
const benify = func => {
return async function(){
while(queue.queue > 10) await new Promise(res => setTimeout(res,100))
return queue(() => util.promisify(func)(...arguments))
}
}
async function main(){