Skip to content

Instantly share code, notes, and snippets.

View neuecc's full-sized avatar

Yoshifumi Kawai neuecc

View GitHub Profile
@neuecc
neuecc / HomeController.cs
Created May 19, 2013 08:07
FileSystemWatcher+SignalRでうまくいかにゃいんですー。最初Hubでやってうまくいかなかったので、とりあえずPersistentConnectionにしたけれどやっぱりうまくいかにゃい。一発目は発行してくれるんだけど、二発目以降はうんともすんともになってもげー。FileSystemWatcher自体は正常に動いていて、Changedイベントでデータ取って、までは行くけど、それをSignalRでBroadcastする、そのBroadcastが無反応系。
namespace MvcApplication4.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
// 後ろから30件、末尾から読んでるわけじゃないので割と手抜き
var initialData = System.IO.File.ReadLines(GlobalConfig.LogPath).Reverse().Take(30);
return View(initialData);
@neuecc
neuecc / ChatWorkClient.cs
Last active December 30, 2015 11:09
某クライアント
public class ChatWorkAuthenticationHandler : DelegatingHandler
{
readonly string apiToken;
public ChatWorkAuthenticationHandler(string apiToken)
: this(apiToken, new System.Net.Http.HttpClientHandler())
{
}
public ChatWorkAuthenticationHandler(string apiToken, HttpMessageHandler innerHandler)
@neuecc
neuecc / owin.cs
Last active January 2, 2016 04:59
Koa / Owin
using Microsoft.Owin.Hosting;
using Owin;
using System;
namespace ConsoleApplication43
{
class Program
{
static void Main(string[] args)
{
public class Startup
{
static Task emptyTask = Task.FromResult<object>(null);
public void Configuration(IAppBuilder app)
{
app.Run(context =>
{
var name = context.Request.Query.Get("name");
var x = int.Parse(context.Request.Query.Get("x"));
using Gumbo.Wrappers;
using Sgml;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Xml.Linq;
public enum RespType : byte
{
SimpleStrings = (byte)'+',
Erorrs = (byte)'-',
Integers = (byte)':',
BulkStrings = (byte)'$',
Arrays = (byte)'*'
}
public class RespClient : IDisposable
using UnityEngine;
using UniRx;
public class MyBehaviour : MonoBehaviour
{
void Start()
{
// https://github.com/jbevain/cecil/issues/241
// https://github.com/saynomoo/unetweaver_error
@neuecc
neuecc / msgpack.md
Last active January 31, 2016 07:42
Serialize derived class
[DataContract]
public class Hoge
{
    [DataMember(Order = 0)]
    public int MyProperty1 { get; set; }
}

[DataContract]
public class HogeHoge : Hoge
@neuecc
neuecc / ToDictionaryBatching.cs
Created March 4, 2016 03:39
ToDictionaryBatching
public static class DictionaryPerfomanceExtensions
{
public static void ToDictionaryBatching<T, TKey1>(this T[] array,
Func<T, TKey1> keySelector1, out Dictionary<TKey1, T> dictionary1
)
{
dictionary1 = new Dictionary<TKey1, T>(array.Length);
for (int i = 0; i < array.Length; i++)
{
async Task UseUniRxInBackground()
{
Debug.Log($"Start ThreadId:{ Thread.CurrentThread.ManagedThreadId}");
await Task.Delay(TimeSpan.FromMilliseconds(300));
Debug.Log($"From same thread, because UniRx installs UniRxSynchronizationContext.ThreadId:{ Thread.CurrentThread.ManagedThreadId}");
Debug.Log(this.transform.position); // show transform
}