Skip to content

Instantly share code, notes, and snippets.

View peace2048's full-sized avatar

naoki ochiai peace2048

View GitHub Profile
@peace2048
peace2048 / DbLoggingWrapper.vb
Last active August 29, 2015 14:19
IDbCommand にログ出力を追加
Imports System.Data
Imports System.Runtime.CompilerServices
Imports Common.Logging
Public Class DbLoggingWrapper
Private Shared _logger As ILog
Public Shared Property Logger As ILog
Get
If _logger Is Nothing Then
@peace2048
peace2048 / NewDesktop.cpp
Created March 4, 2015 02:47
デスクトップを作成した上でアプリケーションを起動する
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR commandLine[MAX_PATH] = { 0 };
HDESK hOldDesk, hInputDesk, hNewDesk;
STARTUPINFO si;
PROCESS_INFORMATION pi;
BOOL success;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
@peace2048
peace2048 / gdc.vb
Created April 4, 2014 03:16
最大公約数を求める
Module Module1
Sub Main()
' 1000,2500,5000 の最大公約数を求める
Dim n = {1000, 2500, 5000}.Aggregate(AddressOf GDC)
Console.WriteLine(n)
Console.ReadLine()
End Sub
@peace2048
peace2048 / RemotingSample.cs
Created February 20, 2014 06:17
Remoting の超簡単なサンプル
using System;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
if (args.Select(_ => _.ToUpper()).Any(_ => _ == "C"))
@peace2048
peace2048 / ReceiptPrinter.cs
Last active December 31, 2015 00:59
レシートプリンターに出力するのに使うつもり
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Printer.Sample
{
@peace2048
peace2048 / PropertyChain.vb
Last active December 29, 2015 17:19
ある `INotifyPropertyChanged` なオブジェクトのプロパティが変化したら 別のオブジェクトのプロパティも更新する
Enum PropertyChainMode
CopyOnly
RaiseOnly
CopyAndRaise
End Enum
Class PropertyChain(Of TSource As {Class, INotifyPropertyChanged}, TTarget)
Private WithEvents _source As TSource
Private _target As TTarget
@peace2048
peace2048 / Buffer.vb
Created November 27, 2013 10:54
T型のシーケンスを、任意サイズの配列のシーケンスに変える ref: http://qiita.com/peace2048/items/3ffd5dd1d5ddee4f6c06
Module EnumerableExBuffer
<Extension>
Public Function Buffer(Of T)(
ByVal source As IEnumerable(Of T),
ByVal count As Integer
) As IEnumerable(Of T())
If source Is Nothing Then Throw New ArgumentNullException("source")
@peace2048
peace2048 / gist:7560933
Created November 20, 2013 10:25
指定時間待機する。 Thread.Sleep の代わりに TaskCancellationSource を使ってみる
'例えば、30秒間隔で状態監視を実行する場合とか
Dim ループ = New CancellationTokenSource()
Dim 状態監視間隔の待機 As CancellationTokenSource
Dim 状態監視タスク = Task.Factory.StartNew(
Sub()
While True
' 状態を監視する処理を実行