Skip to content

Instantly share code, notes, and snippets.

View Arlen22's full-sized avatar

Arlen Beiler Arlen22

View GitHub Profile
@Arlen22
Arlen22 / mydev-color.js
Created February 16, 2017 20:41
Morgan loggers
morgan.format('mydev', function developmentFormatLine(tokens, req, res) {
// get the status code if response written
var status = res._header
? res.statusCode
: 0
var path = req.path.split('/');
path = path[1] === 'col';
// get status color
var color = status >= 500 ? 31 // red
@Arlen22
Arlen22 / Console output with Debug
Created October 17, 2016 20:25
Puzzling problem with express app
express:router dispatching GET /arlen/status +1s
express:router query : /arlen/status +1ms
express:router expressInit : /arlen/status +1ms
express:router logger : /arlen/status +2ms
express:router trim prefix (/arlen/status) from url /arlen/status +3ms
express:router router /arlen/status : /arlen/status +1ms
express:router dispatching GET / +8ms
express:router jsonParser : /arlen/status +2ms
express:router <anonymous> : /arlen/status +2ms
webexp path / +1ms
@Arlen22
Arlen22 / Hosting multiple tiddlywikis on Express.md
Last active May 21, 2021 13:08 — forked from anonymous/index.js
A file to allow running multiple TiddlyWikis as seperate folders of an Express JS application. Made with 5.1.9. Amended for 5.1.14-Prerelease. My part is released into the Public Domain.
  • Download the NodeJS version of TiddlyWiki from GitHub or NPM. If you use NPM, do not use the global option (-g).
  • Put web.js beside tiddlywiki.js.
  • Require web.js from the Express application and call it on every matching request (see below).
  • For TiddlyWiki before 5.1.14-Prerelease: In core/modules/commands/server.js, seperate out the requestHandler function that is passed to http.createServer so it is on the SimpleServer prototype. Add the self variable to the first line of the requestHandler as shown.
SimpleServer.prototype.listen = function(port,host) {
	http.createServer(this.requestHandler.bind(this)).listen(port,host);
};
SimpleServer.prototype.requestHandler = function(request,response) {
@Arlen22
Arlen22 / electron.js
Last active November 12, 2019 21:56
Another way to run the TiddlyWiki GitHub version
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const shell = electron.shell;
var mainWindow = null;
var arg2 = process.argv[2];
app.on('ready', function() {
global.file = arg2 ? arg2 : electron.dialog.showOpenDialog({ properties: [ 'openFile' ]});
if(!file) process.exit(0);
mainWindow = new BrowserWindow({
@Arlen22
Arlen22 / index.htm
Last active August 29, 2015 14:13
How to use node-webkit with tiddlywiki GitHub code.
<!doctype html>
<html>
<head></head>
<body class="tc-body">
<script>process.mainModule.exports.boot();</script>
</body>
</html>
/*\
title: NodeWebKitSaver.js
type: application/javascript
module-type: saver
Handles saving changes via node.js in the browser (node-webkit).
\*/
(function(){
@Arlen22
Arlen22 / StaticTagMacro
Created January 8, 2015 22:31
Static Tag Macro demonstration
\define tag-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
\end
\define tag-body-inner(colour,fallbackTarget,colourA,colourB)
<$set name="foregroundColor" value=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>>
<$set name="backgroundColor" value="""$colour$"""><!--popup=<<qualify "$:/state/popup/tag">>-->
<$button popup=<<qualify "$:/state/popup/tag">> class="tc-btn-invisible tc-tag-label" style=<<tag-styles>> static="yes">
this.stateTitle = this.state;
this.readState();
// Construct the child widgets
- var childNodes = this.isOpen ? this.parseTreeNode.children : [];
- this.hasChildNodes = this.isOpen;
+ if(this.hasVariable("tv-static-output", "yes")) {
+ this.alwaysRender = true;
+ } else {
+ this.alwaysRender = false;
+ }
@Arlen22
Arlen22 / gist:11149813
Last active August 29, 2015 14:00
macrodef - macro definition tiddler
/*\
title: $:/core/modules/parsers/wikiparser/rules/macrodef.js
type: application/javascript
module-type: wikirule
Wiki pragma rule for macro definitions
```
\define name(param:defaultvalue,param2:defaultvalue)
definition text, including $param$ markers
@Arlen22
Arlen22 / gist:11149776
Created April 21, 2014 17:31
macrodef changes for external macro body
/*\
title: $:/core/modules/parsers/wikiparser/rules/macrodef.js
type: application/javascript
module-type: wikirule
Wiki pragma rule for macro definitions
```
\define name(param:defaultvalue,param2:defaultvalue)
definition text, including $param$ markers