Skip to content

Instantly share code, notes, and snippets.

@noqisofon
noqisofon / MulticastingSample.cs
Created December 15, 2010 06:08
740092 を簡潔にした感じ。
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace demo.multicasting {
@noqisofon
noqisofon / init.rb
Created December 15, 2010 08:40
bit.ly/hsUTKm の「差集合で関係除算を表現する」チャプターで使うテーブルを Ruby/SQLite3 で作成してみました。
#!c/bin/ruby/bin/ruby
# -*- encoding: cp932 -*-
# file: testinit.rb
require 'sqlite3'
# データベースを作成します。
# 直ぐに空のデータベースファイル employees.db ができます。
# 既に存在する場合は、読み込むだけです。
db = SQLite3::Database.new( "employees.db" )
@noqisofon
noqisofon / MulticastGuestSample.cs
Created December 17, 2010 00:14
"How are you?" で始める UDP マルチキャスト通信。マルチキャスト要らないけど…
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace demo.multicasting.client {
@noqisofon
noqisofon / AsyncUDPGuestSample.cs
Created December 17, 2010 08:26
"How are you?" で始まる UDP 非同期通信。
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace demo.asyncudp.guest {
@noqisofon
noqisofon / HistoriyDiffForm.cs
Created December 18, 2010 05:46
gist.github.com/721182 の重複チェック + GUI 版。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
@noqisofon
noqisofon / testtweet.rb
Created December 19, 2010 15:34
Ruby で つぶやいてみるテスト。
#!/opt/local/bin/ruby
# -*- encoding: utf-8 -*-
require 'twitter'
APP_TAKEN = [ "あぷりのとーくん", "あぷりのしーくれっと" ]
PIN_CODE = 42
def get_atoken(oauth)
request_token = oauth.customer.get_request_token
@noqisofon
noqisofon / StartupAnswerGuestSample.cs
Created December 20, 2010 08:32
コンピューターが起動しているかどうかを調べたい感じ。
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using spaghetti.util;
using groan.util;
@noqisofon
noqisofon / init.el
Created December 21, 2010 00:10
現在の init.el。
;;; init.el
;(setq debug-on-error t)
;; ===============================================================================
;;
;; Environmental discrimination(環境識別)
;;
;; ===============================================================================
(defvar *run-unix-like-p*
(or (equal system-type 'gnu/linux)
@noqisofon
noqisofon / gist:749577
Created December 21, 2010 06:28
パイプとフレームバッファ。
struct pipe_t {
handle_t output;
handle_t input;
};
int pipe_init(pipe_t* pipe, security_attributes_t* attributes)
{
boolean ret;
@noqisofon
noqisofon / gist:749678
Created December 21, 2010 08:49
複数のゲストから受信するためにスレッド内で実行する関数。
void receivePart(object param) {
pair<TcpClient, ManualResetEvent> tmpair = (pair<TcpClient, ManualResetEvent>)param;
TcpClient client = tmpair.first;
ManualResetEvent receive_complete = tmpair.second;
NetworkStream stream = null;
// ループカウンタ。
int loop_count = 0;
// 待機時間。
TimeSpan waiting_time = TimeSpan.FromMilliseconds( 100 );