Skip to content

Instantly share code, notes, and snippets.

View nobuh's full-sized avatar

Nobuhiro Hatano nobuh

View GitHub Profile
@nobuh
nobuh / nakedhttp.js
Created September 1, 2011 05:48
Naked HTTP. a sample of http server in node.js
var http = require("http");
var port;
if (process.argv.length < 3) {
port = 8192;
} else {
port = process.argv[2];
}
http.createServer(function(requset, response) {
@nobuh
nobuh / n_color.js
Created September 16, 2011 08:40
node ncurses color sample
var nc=require('ncurses');
function pad(num) {
num = ''+num;
var digits = num.length;
if (digits < 3) num = '0' + num;
if (digits < 2) num = '0' + num;
return num;
}
@nobuh
nobuh / helloN.js
Created September 16, 2011 08:56
Hello World for Node Ncurses
// helloN.js
var c = require('ncurses'),
w = new c.Window(),
pairnum = 1,
msg = 'Hello. Press any key. !!!',
attr;
attr |= c.attrs.REVERSE;
attr |= c.attrs.BOLD;
attr |= c.attrs.UNDERLINE;
@nobuh
nobuh / tcp_server.pl
Created October 6, 2011 06:10
Perl TCP server
#!/usr/bin/perl -w
use IO::Socket;
use Net::hostent; # for OO version of gethostbyaddr
$PORT = 9000; # pick something not in use
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => SOMAXCONN,
Reuse => 1);
@nobuh
nobuh / check_username.php
Created April 6, 2016 06:42
Yo の API 練習
<?php
$url = 'http://api.justyo.co/check_username/';
$data = array('api_token' => '********KEY*********', 'username' => '*****');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'GET',
'content' => http_build_query($data),
),
@nobuh
nobuh / .minttyrc
Created April 27, 2016 03:09
My minttyrc
BoldAsFont=yes
FontHeight=14
Columns=80
Rows=40
Locale=ja_JP
Charset=UTF-8
FontSmoothing=default
BoldAsColour=yes
AllowBlinking=yes
Font=Consolas
@nobuh
nobuh / disable_tap.sh
Last active May 2, 2016 08:31
Disable tap on touchpad of Lubuntu
#!/bin/sh
# Disable tap on touchpad
synclient TapButton1=0
synclient TapButton2=0
synclient TapButton3=0
@nobuh
nobuh / readdir.js
Created September 14, 2011 06:58
readdir - node.js readdir sample
var fs = require('fs');
fs.readdir( process.argv[2], function (err, files) {
if (!err)
console.log(files);
else
throw err;
});
console.log("Fired callback.");
@nobuh
nobuh / python_cron.md
Created June 21, 2017 01:11
Python3 の ConfigParser を使うスクリプトを cron で使う場合

このようにかかれている python スクリプトを cron 実行すると config file が読めずにエラーになる

conf_file = "../settings.ini"
config = configparser.ConfigParser()

try:
    config.read(conf_file)

cron の実行時にカレントディレクトリをスクリプトの場所に変更してはくれないため .. が期待とは違う場所になる

@nobuh
nobuh / cool_techs.md
Created July 14, 2017 04:13
最近触ってみたいなと思ったクールなテクノロジ