Skip to content

Instantly share code, notes, and snippets.

Xのデスクトップ環境をヘッドレスで実行する
Linux/UNIXサーバとは、sshでログインさえ出来れば大抵の管理作業が出来るものであるが、GUIもあればあったで意外と便利な時があるものである。また、プロプライエタリなソフトウェアなどは GUIでのインストールを前提としているものもよくある。
しかしながら、サーバ機の前までノコノコ歩いていってキーボード・マウス・画面をわざわざ接続して作業をするなどというまるで原始人のようななことは、当該機で障害が起こりネットワークに接続できなくなった時だけにしたいものである。
Macユーザなら、OSに標準で含まれているX11を起動し、xtermからssh に -Xなり -Yなりのオプションを付けて対象にログインすればリモートの Xアプリケーションを手元のMac上で利用することが出来るものの、誰もが Macを持っていて(もしくはWindowsにcygwinが入れてあって) UNIXの操作をした経験があり sshを含めコマンドラインツールの使い方を分かっているというわけでもないため他人に仕事を振りづらい(こともある)。
というわけで、ここでは比較的名の知れたプロトコルである VNCを使ってネットワーク経由で Xのデスクトップ環境にログイン出来るようにする。ただし、実コンソール(つまり対象ホストに接続されている画面)には Xが表示されていると操作にマウスが必要だったりしてうざったいので(vcを切り替えればいいんだけどさ)、そちらはテキストログインのままとする。
USE="server" emerge vnc
/*
* Mclarens Bar: Redis based Instant Messaging
* Nikhil Marathe - 22/04/2010
* A simple example of an IM client implemented using
* Redis PUB/SUB commands so that all the communication
* is offloaded to Redis, and the node.js code only
* handles command interpretation,presentation and subscribing.
*
* Requires redis-node-client and a recent version of Redis
@Ciantic
Ciantic / keyboardlistener.cs
Created July 11, 2010 17:33
C# Keyboard listener
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Collections.Generic;
namespace Ownskit.Utils
{
@llj098
llj098 / Makefile
Created December 23, 2010 01:36
a sample tcp server runs in kernel
obj-m += tcp_svr_sample.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clea
@TooTallNate
TooTallNate / starttls.js
Created March 1, 2011 01:40
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@adammw
adammw / README.md
Created August 3, 2012 06:30
Node.js for Raspberry Pi

Node.js for Raspberry Pi

Pre-built binaries

Recent releases have been pre-built using cross-compilers and this script and are downloadable below.

If you have found these packages useful, give me a shout out on twitter: @adammw

@wofeiwo
wofeiwo / gist:3634357
Created September 5, 2012 10:00
Golang daemonize
/* ivan(a.t)mysqlab.net */
package main
import (
"syscall"
"os"
"log"
)
func daemon(nochdir, noclose int) int {
@mike-zhang
mike-zhang / udpProxy.go
Created October 8, 2012 15:58
Implementation of a UDP proxy in Golang
// Implementation of a UDP proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
@74hc595
74hc595 / gist:6111097
Last active December 20, 2015 09:49
Instructions for setting up an ARM toolchain for the LPC1114 microcontroller on Mac OS X.

Getting Started with the LPC1114 on Mac OS X

July 30, 2013

The LPC1114FN28 is an exciting piece of hardware--a 32-bit ARM Cortex-M0 micro controller capable of 50MHz operation in a DIP-28 package. Unfortunately, getting your development environment set up on a Mac can be confusing.

You'll need the following: