Skip to content

Instantly share code, notes, and snippets.

View jrobertson's full-sized avatar
🏠
Working from home

James Robertson jrobertson

🏠
Working from home
View GitHub Profile
@jimfoltz
jimfoltz / tw5-server.rb
Last active February 26, 2024 02:18
A local server for TiddlyWiki5 that allows saving wiki.
require 'webrick'
require 'fileutils'
if ARGV.length != 0
root = ARGV.first.gsub('\\', '/')
else
root = '.'
end
BACKUP_DIR = 'bak'
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end
@reality
reality / snippets.js
Created August 24, 2011 02:23
Javascript Snippets file
/*** Array ***/
Array.prototype.random = function() {
return this[Math.floor((Math.random()*this.length))];
};
Array.prototype.each = function(fun) {
for(var i=0;i<this.length;i++) {
fun(this[i]);
}
#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else