Easily Create DataTables For Unit Tests

.net « John Opincar’s Blue Corner

Easily Create DataTables For Unit Tests
August 22, 2008 — jopincar

Ideally, you have a data access layer that only returns domain objects or data transfer objects. The key is real, strongly-typed objects. One of the many reasons for this is to make unit testing easier. Unfortunately, sometimes you are stuck working with code that uses datatables. I’ve recently written a function that takes most of the pain out of creating datatables for unit testing. This function and the code that calls it takes advantage of several new c# features: lamda expressions, object initializers, list initializers, and auto-implemented properties. It also uses generics and reflection.

The first thing that stinks about creating datatables from scratch is that you have to manually define the columns which is tedious. The second thing that stinks is that you can only add rows to the datatable using an object array which means you have to count commas to keep track of which column you are populating. Or you have to do something awkward like obj[datatable.Columns[“FieldName"].Ordinal] = “somevalue”. To get around this, the first step is to define the structure of our rows by creating a simple class, EG:

AsyncSocket.cs

裏面有提到mono的lib
Koders Code Search: AsyncSocket.cs – C#

/* ————————————————————————– * Copyrights * * Portions created by or assigned to Cursive Systems, Inc. are * Copyright (c) 2002-2005 Cursive Systems, Inc. All Rights Reserved. Contact * information for Cursive Systems, Inc. is available at * http://www.cursive.net/. * * License * * Jabber-Net can be used under either JOSL or the GPL. * See LICENSE.txt for details. * ————————————————————————–*/ using System; using System.Diagnostics; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; using bedrock.util; #if NET20 using System.Security.Authentication; using System.Net.Security; using System.Security.Cryptography.X509Certificates; #elif __MonoCS__ using Mono.Security.Protocol.Tls; using System.Security.Cryptography.X509Certificates; #elif !NO_SSL using Org.Mentalis.Security.Ssl; using Org.Mentalis.Security.Certificates; #endif

Cacti:使用自訂 script 來繪製圖表

那年 今年 明年: Cacti:使用自訂 script 來繪製圖表

Cacti:使用自訂 script 來繪製圖表
一直以來都有在用 mrtg / cacti 來做主機監控,雖然 mrtg 可以用自己的 script 來抓資料繪製圖表,不過要設定的好我覺得難度有點高… 所以這次就把一些 mrtg 用的 script 改成 cacti 用得來試試看。
大概記一下流程。

就拿擷取 bbs 站上人數來當作範例好了。一般 Maple 3 itoc 版本的 bbs 都會在 login 畫面 show 出目前站上人數,因此我們只要寫個 script 去抓這個數字,再依照 cacti 要吃的參數格式輸出就好。

1. 首先建立擷取資料的 script
以下是我用 php 寫的 script:(當然你可以用 python、ruby、shell script 都可以~)
(在 Debian 下,是存在 cacti 目錄底下的 scripts:/usr/share/cacti/site/scripts)

C# Tutorial – Simple Threaded TCP Server

C# Tutorial – Simple Threaded TCP Server | Switch on the Code

C# Tutorial – Simple Threaded TCP Server

using System;

using System.Text;

using System.Net.Sockets;

using System.Threading;

using System.Net;

namespace TCPServerTutorial

{

  class Server

  {

    private TcpListener tcpListener;

    private Thread listenThread;

    public Server()

    {

      this.tcpListener = new TcpListener(IPAddress.Any, 3000);

      this.listenThread = new Thread(new ThreadStart(ListenForClients));

      this.listenThread.Start();

    }

  }

}

Asynchronous Socket Programming in C#: Part I

Asynchronous Socket Programming in C#: Part I – CodeGuru

Objective

The objective of this article is to demonstrate a socket-based client/server application that will allow two-way asynchronous communication between a server and multiple client applications. Because this example uses asynchronous methods, the server application does not use threads to communicate to multiple clients (although internally the asynchronous communication mechanism uses threads at the OS level).
The Difference Between Synchronous and Asynchronous Communication in Network Programming

PHP 5 Sockets with Flash 8

kirupa.com – PHP 5 Sockets with Flash 8, Page 1

PHP 5 Sockets with Flash 8
by obiAdmin (raymond): 30 September 2006

Ever wanted to build a real-time chat room or build a high speed multiplayer game but couldn’t figure out how to do that? Sockets are what your missing! PHP sockets are indeed very nice to use when creating real-time chat applications or to build an instantaneous multiplayer game. Unfortunately most people do not use them because they are hard to grasp. In this tutorial, I will be showing how to write a simple PHP5 socket shell script for Apache servers, and how to set up a Flash file to connect to it.

Here is a snap shot of the chat room you’ll be creating in this tutorial:

DataPush & Remoting in Flex with Java, .NET, PHP, Python, Ruby and more… « FLEXing My Muscle

DataPush & Remoting in Flex with Java, .NET, PHP, Python, Ruby and more… « FLEXing My Muscle

DataPush & Remoting in Flex with Java, .NET, PHP, Python, Ruby and more…

“Data Push” has been a top requirement for most people who build enterprise style RIAs. Being an evangelist who meets a lot of customers, the ability to do data-push was probably the top of the list for most of them. Datapush is so poular because there are no slew of requests flowing around, but only updates sent when required

The next on the list the ability to increase “performance” of connection with their respective backends. The key to this is to use a binary format (in the case of ActionScript it is AMF) which will then increases performance, allowing applications to load data up to 10 times faster than with text-based formats such as XML or SOAP.

Action Message Format (AMF) is a compact binary format to serialize ActionScript object graphs. Both data-push and remoting is made possible due to the AMF specification. But, data-push is achieved based on a Comet-like implementation with AMF3 over HTTP.

Many are clueless what options are there when it comes to interfacing their application to their backend technologies to achieve the above requirements. What many don’t realize is that, when Adobe has now opened up the AMF 3 specifiaction. People have been going out right implementing solutions on different platforms for AMF. So, here that the options available for you in the different technologies that I am aware of and I am going to tag the products with data-push capability, with a push button icon

你需要Flash Remoting嗎?

Flash 6新面貌
Flash Player 6執行Flash 5/6文件時,拆Array和XML Parsing的速度改善了很多很多,不過Data Type依舊是String,針對loadVariable()非同步延誤缺點,Flash 6加入了LoadVars Object,用它來處理和Server交換Data的工作,方便很多,LoadVars.onLoad更使Flash知道Data已經load入來。

XML Socket
Flash 5另外加入了XML Socket,其實通過是Server運行著的Socket Server,主動Push Data給Flash,這主要用來做Multiuser應用,或者股票即時報價等。Macromedia沒有出品Socket Server,要自己寫一個,或者使用其他人寫的Socket Server(例如:Unity、ElectroServer等),Socket Server要一直運行著,隨時接收Data。普通Hosting未必可以讓人Run Server,而且在Flash和Server交換Data上要再靠Socket Server,一般都很少會用在日常開發工作中。