Skip to content

Instantly share code, notes, and snippets.

View peace2048's full-sized avatar

naoki ochiai peace2048

View GitHub Profile
@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 / 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
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 / 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;
@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
open System.Net
open System.Net.Sockets
type IpMessenger (port: int) =
let client = new UdpClient(port)
let random = new Random(Environment.TickCount)
let nextId = fun () -> random.Next(0, 1000)
let sendBuffer (address: IPAddress, message: Byte[]) =
client.Send(message, message.Length, new IPEndPoint(address, 2425))
public static Class EnumerableEx
{
}
@peace2048
peace2048 / vs2015_vb_cs_futre.md
Created August 31, 2015 01:34
VS2015 での VB, C# の新機能

VB, C# の新機能

@peace2048
peace2048 / DropDownButton.cs
Created May 19, 2015 08:51
WPF DropDownBox
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace WpfApplication1
{
[TemplatePart(Name = PART_ContentPresenter, Type = typeof(ContentPresenter))]
[TemplatePart(Name = PART_DropDownButton, Type = typeof(ToggleButton))]
@peace2048
peace2048 / DatabaseExtensions.vb
Created September 24, 2013 01:19
IDbConnection 等の拡張メソッド
Imports System.Runtime.CompilerServices
Imports System.Dynamic
Module DatabaseExtensions
Sub Main()
Dim conn = New SqlClient.SqlConnection("Data Source=...")
Dim one = Convert.ToInt32(conn.ExecuteScalar("SELECT 1"))