Skip to content

Instantly share code, notes, and snippets.

@sizzlemctwizzle
sizzlemctwizzle / muExpress.js
Last active December 27, 2015 17:39
World's simplest Express view wrapper for [Mu](https://github.com/raycmorgan/Mu)
var mu = require('mu2');
exports.renderFile = function(path, options, response) {
mu.compileAndRender(path, options).pipe(response);
}
/* Usage:
app.engine('html', require('muExpress').renderFile);
app.set('view engine', 'html');
<sizzlemctwizzle> So the first question is what language/platform should we use?
<CletusC> Node.js IMO--we are a JS community so we may as well build on what we all know
<JoeSimmons> I'm really not too experience with the server-side aspect of things. Although I could learn
<JoeSimmons> Node.js would allow me to use what I basically already know though, right? (besides learning the API)
<CletusC> Node scales up really well and would probably eliminate one of the main issues of USO--the load. Obviously down the line, but thinking ahead here
<sizzlemctwizzle> Yup exactly what I was thinking. I makes easy for intreped people to add new features to the site and not have to hack them in with user scripts like we currently do.
<sizzlemctwizzle> Correct Joe.
<JoeSimmons> Cool
<JoeSimmons> I'm great at JS so if I learn Node then great
<JoeSimmons> Btw, I have a headache, so if anything I say sounds a little off, it's a combination of being tired and that :p
@sizzlemctwizzle
sizzlemctwizzle / Discussion.md
Last active December 27, 2015 08:39
Just some questions to think about before our discussion.

What server-side language/platform should we choose for our new site?

sizzle: Since we are building a site to host user scripts which are written in JavaScript, Node.js seems like the best choice. But node apis only provides basic web serving functionality. I personally use the Express framework because it makes things super simple (check the source of my site out to see for yourself).

sizzle: You also need some framework to build dynamic web pages. Although Express defaults to Jade templates, I find the amount of difference in syntax annoying and a barrier of entry to those who want to contribute. I use Mustache because its syntax is stupid simple. You just give it a JSON object and renders based on the values and structure. See my [user script updater](https://github.com/sizzlemctwi

// ==UserScript==
// @name Remember SignOn
// @namespace sizzlemctwizzle
// @description Sign on once and forever
// @include https://sso.queensu.ca/amserver/UI/Login
// @grant none
// @version 1
// ==/UserScript==
// Uncomment this if you fuck up.
@sizzlemctwizzle
sizzlemctwizzle / GMRMC.user.js
Created March 27, 2011 01:49
GM_registerMenuCommand Test Case
// ==UserScript==
// @name GM_registerMenuCommand Test Case
// @namespace sizzlemctwizzle
// @description Test GM_registerMenuCommand
// @include *
// ==/UserScript==
GM_registerMenuCommand("Test Command", function() { alert('Command selected'); });
var div = document.createElement('div');
div.textContent = "This text is added to the page when the script runs.";
@sizzlemctwizzle
sizzlemctwizzle / gist:882495
Created March 23, 2011 02:20
Pseudocode for how the Qdoba Rewards Program works
// Sometimes I get bored and write Psuedocode for how random things work
// The following is pseudocode for how the Qdoba Rewards Program works
// How much money customer owes
amountDue = 0;
// Customers with Qdoba Cards earn points
if (customer.hasCard()) {
totalPoints = customer.pointTotal;
pointAmount = customer.isSignatureMember() ? 125 : 100;
// ==UserScript==
// @name Reddit Uppers and Downers Enhanced
// @namespace mistercow
// @description Show up-votes and down-votes next to the total score on reddit comments.
// @require http://sizzlemctwizzle.com/updater.php?id=56641
// @include http://www.reddit.com/*/comments/*
// @include http://www.reddit.com/user/*
// ==/UserScript==
/*
@sizzlemctwizzle
sizzlemctwizzle / careless.user.js
Created February 10, 2011 17:31
An example of how a malicious script can target a careless script if the window object is shared between all scripts.
// ==UserScript==
// @name Careless Script
// @namespace http://test.free.fr
// @description A non-malicious script that saves and retrieves data carlessly.
// @include *
// ==/UserScript==
window.saveArray = function(name, array) {
GM_setValue(name, array.toString());
};
// ==UserScript==
// @name Script1
// @namespace http://test.free.fr
// @description Script1
// @include *
// ==/UserScript==
window.func = function(getter, setter) {
var val = getter('val');
++val;
GM_setValue('val', val);
// ==UserScript==
// @name test
// @namespace http://test.free.fr
// @description test
// @include *
// ==/UserScript==
eval("alert('bop');");