Skip to content

Instantly share code, notes, and snippets.

View RangerMauve's full-sized avatar
💜
Decentralizing

Mauve Signweaver RangerMauve

💜
Decentralizing
View GitHub Profile
@campadrenalin
campadrenalin / main.md
Created January 25, 2012 18:56
Getting started with Meshnet

Getting started with Meshnet

This document is for people who want to help but have no technical knowledge. It assumes you won't be getting involved in squabbles over which relay technology to use, etc.

Step 1: Set up CJDNS

One of the few things widely agreed upon at the time of this writing is the use of CJDNS. Currently Windows is not supported, but if you have Linux or can run Linux in a virtual machine, you can follow the step-by-step instructions lower on that page to install and start up an instance of CJDNS on your system. If you're using Ubuntu 11.10 (latest version), you can follow these simplified instructions.

One thing you should know is cjdns currently isn't a wireless meshnet. A physical meshnet consisting of nodes geographically close to each other is a long way off. Instead, cjdns offers a "mixnet"-like system. cjdns is routable over the current Internet, so this means right now its like a giant VPN (virtu

@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@P4
P4 / default.reg
Last active April 13, 2024 05:23
Color schemes for Windows Command Prompt
Windows Registry Editor Version 5.00
; Default color scheme
; for Windows command prompt.
; Values stored as 00-BB-GG-RR
[HKEY_CURRENT_USER\Console]
; BLACK DGRAY
"ColorTable00"=dword:00000000
"ColorTable08"=dword:00808080
; BLUE LBLUE

Namespacing

The concept of namespacing keys will probably be familiar if you’re used to using a key/value store of some kind. By separating keys by prefixes we create discrete buckets, much like a table in a traditional relational database is used to separate different kinds of data.

It may be tempting to create separate LevelDB stores for different buckets of data but you can take better advantage of LevelDB’s caching mechanisms if you can keep the data organised in a single store.

Because LevelDB is sorted, choosing a namespace separator character can have an impact on the order of your entries. A commonly chosen namespace character often used in NoSQL databases is ':'. However, this character lands in the middle of the list of printable ASCII characters (character code 58), so your entries may not end up being sorted in a useful order.

Imagine you’re implementing a web server session store with LevelDB and you’re prefixing keys with usernames. You may have entries that look like this:

@akhoury
akhoury / handlebars-helper-x.js
Last active February 17, 2024 13:25
Handlebars random JavaScript expression execution, with an IF helper with whatever logical operands and whatever arguments, and few more goodies.
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " name == 'Sam' && age === '12' " }}
BOOM
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@constantology
constantology / process.logger.js
Created July 24, 2014 09:39
using node's process to emit events to log stuff from anywhere
// use like this:
// process.emit( 'app:log', module, arg1, arg2, ..., argN );
var Module = require('module');
function logConsole(method, module) {
var args = [(new Date()).toJSON(), method];
var index = 1;
if (module instanceof Module) {
@jessehattabaugh
jessehattabaugh / gulpfile.js
Last active August 23, 2016 19:31
Gulp task for changing values in PhoneGap's config.xml file
/* Config - set the right values in the PhoneGap config.xml
******************************************************************************/
gulp.task('config', function () {
return gulp.src([srcDir + '/config.xml'])
.pipe(cheerio({
run: function ($) {
// get the version number from package.json
$('widget').attr('version', require('./package').version);
// in development launch the app with a different html file
@netgusto
netgusto / pegjs-htmlish.peg
Last active April 26, 2024 08:04
PEG.js grammar for parsing simple HTML-ish balanced markup language - use it on http://pegjs.majda.cz/online
Content = (DocType / Comment / BalancedTag / SelfClosingTag / Text)*
DocType = "<!doctype " doctype:[^>]* ">" {
return {
type: 'DocType',
content: doctype.join('')
};
}
Comment = "<!--" c:(!"-->" c:. {return c})* "-->" {
@jarrodirwin
jarrodirwin / storagePolyfill.js
Last active June 21, 2022 14:27 — forked from remy/gist:350433
LocalStorage/SessionStorage Polyfill with Safari Private Browsing support.
// Refer to https://gist.github.com/remy/350433
try {
// Test webstorage existence.
if (!window.localStorage || !window.sessionStorage) throw "exception";
// Test webstorage accessibility - Needed for Safari private browsing.
localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {