Skip to content

Instantly share code, notes, and snippets.

View thejhh's full-sized avatar
💭
Excellence isn't believing you're best; It's about always striving to get better

Jaakko Heusala thejhh

💭
Excellence isn't believing you're best; It's about always striving to get better
View GitHub Profile
@thejhh
thejhh / git-publish.md
Created August 7, 2011 01:38
How to update files at remote website by running 'git publish'

Alias for git is configured into the file .git/config:

[alias]
	publish = !sh ./scripts/publish.sh

The script file ./scripts/publish.sh looks like this:

#!/bin/sh
set -e
@thejhh
thejhh / page.html
Created August 23, 2011 13:41
A slow HTTP server for testing web clients
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
<p>This is content for development test tool.</p>
</body>
</html>
@thejhh
thejhh / README.md
Created August 25, 2011 18:56
Unmake iSCSI targets

This script only prints the commands needed to uninitialize a iSCSI target in OpenSolaris based OS.

Run it like ./unsharedataset.sh storage/iscsi/nor-atlas:

+ test -n storage/iscsi/nor-atlas
+ test -n 600144F06FD5CE0000004DC06C000003
+ test -n iqn.1986-03.com.sun:02:55514a4d-a70c-c4ae-a26d-f9a7a665e8ef
+ test xiqn.1986-03.com.sun:02:55514a4d-a70c-c4ae-a26d-f9a7a665e8ef != x-
----
@thejhh
thejhh / js.nanorc
Created August 27, 2011 02:25
Nanorc for javascript
## JavaScript
##
syntax "JS" "\.js$" "\.sjs$"
# Reserved Keywords
color yellow "\b(instanceof|typeof|break|do|new|var|case|else|return|void|catch|finally|continue|for|switch|while|this|with|debugger|function|throw|default|if|try|delete|in)\b"
# Future Reserved Words
color brightblue "\b(class|enum|extends|super|import|const|export|implements|let|private|public|yield|static|interface|package|protected)\b"
@thejhh
thejhh / README.md
Created August 27, 2011 02:30
My nano settings

My nanorc settings.

Save js.nanorc to /opt/nano/js.nanorc etc.

Then use it with:

include "/opt/nano/js.nanorc"

Sample ~/.nanorc is in file nanorc.

@thejhh
thejhh / app.js
Created August 29, 2011 16:54
Configuring socket.io
var express = require('express');
var app = module.exports = express.createServer();
var io = require('socket.io').listen(app);
io.configure('development', function(){
io.set('log level', 1);
io.set('transports', ['xhr-polling', 'websocket']);
});
io.configure('production', function(){
@thejhh
thejhh / example.js
Created September 7, 2011 01:45
SQL middleware framework
/* Run SQL query group */
var move_player = sql.group(
sql.query(['next_number'], 'SELECT MAX(number)+1 AS number FROM reg WHERE game_id=:game_id'),
sql.query(['old_user_id'], 'SELECT user_id FROM reg WHERE number=:old_number AND game_id=:game_id'),
sql.query(['new_user_id', 'new_reg_id'], 'SELECT user_id, reg_id FROM reg WHERE number=:new_number AND game_id=:game_id'),
sql.query('DELETE FROM player WHERE reg_id=:new_reg_id AND game_id=:game_id LIMIT 1'),
sql.query('DELETE FROM reg WHERE reg_id=:new_reg_id AND game_id=:game_id LIMIT 1'),
sql.query('DELETE FROM auth WHERE user_id=:old_user_id AND game_id=:game_id LIMIT 1'),
sql.query('UPDATE reg SET user_id=:new_user_id WHERE user_id=:old_user_id AND game_id=:game_id'),
sql.query('UPDATE auth SET user_id=:new_user_id WHERE user_id=:old_user_id AND game_id=:game_id')
@thejhh
thejhh / README.md
Created September 9, 2011 15:20
Building Freeciv 2.3.0 on Debian-based system
@thejhh
thejhh / freeciv-T40L20S40-T50L10S40.diff
Created September 29, 2011 19:59
Difference of Trade-Lux-Science 40-20-40 and 50-10-40 in my four cities
--- T40L20S40.txt 2011-09-29 23:00:22.000000000 +0300
+++ T50L10S40.txt 2011-09-29 23:32:00.000000000 +0300
@@ -7,9 +7,9 @@ Plymouth:Production+:2
Plymouth:Production-:0
Plymouth:Trade+:1
Plymouth:Trade-:0
-Plymouth:Gold:0
+Plymouth:Gold:+1
Plymouth:Lux:0
-Plymouth:Science:1
@thejhh
thejhh / README.md
Created October 6, 2011 23:38
Example of node.js shell script

This is how to run it:

$ node hello.js 
Hello world