祝 一周年

f:id:devdevdev:20160501003607p:plain

おかげ様をもちまして、私たち株式会社Arrvisは創業より1周年を迎えることができました。
これもひとえにお客様をはじめといたしまして、お取引先様各位、ご協力者の方々のご指導・ご支援の賜物と厚く感謝いたしております。
この一周年の節目は皆様への感謝の心と敬いをもって、当社の役割を見直し、実践していく最高の機会と考えております。
お客様のニーズを受け止めて、それを実践・ご提案していく企業であり続けるためにさらなる努力を続けてまいります。
今後とも株式会社Arrvisをお引き立てくださいますようお願い申し上げます。

株式会社Arrvis
代表取締役CEO 伊豆丸祐恭

・・・ちゃんとしたご挨拶とか書いてみようと思った結果コピペ。
まぁとりあえず1年経ったー!本日より2年目突入ー!
今後もお客様から選ばれ続ける企業であるよう社員一同がんばります!

なお、5/2は創立記念日振替の為、全社休日とさせていただきます。


【ASP.NET】メンテナンスページを表示する方法5選

ひさびさASP.NET
グ○シーに出てきそうなタイトル。

1. URL Rewrite

Web.configに以下追記。
ファイルの有無で判定する感じですね。
maintenance.txtが存在してればmaintenance.htmlの内容が表示されます。
まぁ実務じゃあんま使わないかと。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Maintenance" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="true"/>
          <conditions>
            <add input="{APPL_PHYSICAL_PATH}maintenance.txt" matchType="IsFile" />
          </conditions>
          <action type="Rewrite" url="maintenance.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>



2.IHttpModule + Web.config

おもむろにこんなクラスを用意します。

using System;
using System.Configuration;
using System.IO;
using System.Web;

namespace Hoge.Modules
{
    public class MaintenanceModule : IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += Context_BeginRequest;
        }

        private void Context_BeginRequest(object sender, EventArgs e)
        {
            if (!bool.Parse(ConfigurationManager.AppSettings[@"InMaintenance"]))
                return;
            
            var app = (HttpApplication)sender;
            app.Context.Response.ContentType = @"text/html";
            app.Context.Response.WriteFile(
                Path.Combine(app.Request.ApplicationPath, @"maintenance.html"));
            app.Context.Response.End();
        }
    }
}


で。Web.config
nameはてきとーでよさげ?typeにフルパス指定で

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="InMaintenance" value="true"/>
  </appSettings>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="MaintenanceModule" type="Hoge.Modules.MaintenanceModule"/>
    </modules>
  </system.webServer>
</configuration>

InMaintenanceがtrueに設定されてればmaintenance.htmlの内容が表示されます。
別にWeb.configじゃなくDBとか他のとこから値取ってきてもいいですね。



3.Global.asax Server.Transferバージョン

判定は2と同じですぜ。

using System;
using System.Configuration;
using System.IO;
using System.Web;

namespace Hoge.App
{
    public class MvcApplication : HttpApplication
    {
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (!bool.Parse(ConfigurationManager.AppSettings[@"InMaintenance"]))
                return;

            Server.Transfer(Path.Combine(Context.Request.ApplicationPath, @"maintenance.html"));
        }
    }
}


4.Global.asax Response.Redirectバージョン

3の

Server.Transfer(Path.Combine(Context.Request.ApplicationPath, @"maintenance.html"));

Response.Redirect("http://www.hoge.com/maintenance.html");

に書き換え。
1~3と違って書き換えではなくリダイレクトですねー。当たり前ですねー。



5.DelegatingHandler

おもむろにこんなクラスを用意しましょう。

using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.Dispatcher;

namespace Hoge.Handler
{
    public class MaintenanceHandler : DelegatingHandler
    {
        public MaintenanceHandler(HttpConfiguration configuration)
        {
            InnerHandler = new HttpControllerDispatcher(configuration);
        }
        
        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage requestMessage, CancellationToken cancellationToken)
        {
            if (bool.Parse(ConfigurationManager.AppSettings[@"InMaintenance"]))
            {
                var maintenanceFilePath = Path.Combine(HttpRuntime.AppDomainAppPath, @"maintenance.html");
                var response = requestMessage.CreateResponse(HttpStatusCode.ServiceUnavailable);
                response.Content = new StringContent(File.ReadAllText(maintenanceFilePath));
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(@"text/html");

                return Task<HttpResponseMessage>.Factory.StartNew(() => response);
            }

            return base.SendAsync(requestMessage, cancellationToken);
        }
    }
}



Global.asax.cs

using Hoge.Handler;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace Hoge.App
{
    public class MvcApplication : HttpApplication
    {
        protected void Application_Start()
        {           
            GlobalConfiguration.Configuration.Routes.MapHttpRoute(
                name: "Hoge",
                routeTemplate: "{group}/{controller}/{action}",
                defaults: new { action = UrlParameter.Optional },
                constraints: null,
                handler: new MaintenanceHandler(GlobalConfiguration.Configuration)
            );

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);       
        }
    }
}

いじょー
2か5が使いやすいかなー
つかれたー。





.exe.configをDebugとReleaseで切り替える Visual Studio 2015編

ひさびさ.NET
コンソールアプリケーションとかWindowsアプリケーションとかの場合ね。
Web.configは勝手にやってくれるのになぜ.exe.configはやってくれないのか
なお、.exe.configからの値の取得はWeb.configの時と一緒でございます。

参考:
devdevdev.hatenablog.com



1.おもむろにApp.config/App.Debug.config/App.Release.configをプロジェクトディレクトリ直下に作ります。
中身はこんな感じ



App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="foo" value="default" />
  </appSettings>
</configuration>



App.Debug.config - 特に書くことない

<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>



App.Release.config - Web.Release.configと同じ書き方でおk

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="foo" value="release" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
  </appSettings>
</configuration>

2..csproj編集
ソリューションエクスプローラーからプロジェクト右クリック→プロジェクトのアンロード
もっかい右クリック→編集XXXX.csproj



まずItemGroup

<None Include="App.config" />
<None Include="App.Debug.config" />
<None Include="App.Release.config" />

  <ItemGroup>
    <None Include="App.config" />
    <None Include="App.Debug.config">
      <DependentUpon>App.config</DependentUpon>
    </None>
    <None Include="App.Release.config">
      <DependentUpon>App.config</DependentUpon>
    </None>
  </ItemGroup>

に書き換え。



で、AfterCompileとAfterPublish追加。

  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
  <Target Name="AfterCompile" Condition="Exists('App.$(Configuration).config')">
    <TransformXml Source="App.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="App.$(Configuration).config" />
    <ItemGroup>
      <AppConfigWithTargetPath Remove="App.config" />
      <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
        <TargetPath>$(TargetFileName).config</TargetPath>
      </AppConfigWithTargetPath>
    </ItemGroup>
  </Target>
  <Target Name="AfterPublish">
    <PropertyGroup>
      <DeployedConfig>$(_DeploymentApplicationDir)$(TargetName)$(TargetExt).config$(_DeploymentFileMappingExtension)</DeployedConfig>
    </PropertyGroup>
    <Copy Condition="Exists('$(DeployedConfig)')" SourceFiles="$(IntermediateOutputPath)$(TargetFileName).config" DestinationFiles="$(DeployedConfig)" />
  </Target>

以上。



長々書いたけど、これ使ったら一発な模様。
プレビューもできるらしい。
visualstudiogallery.msdn.microsoft.com





【AWS】【Amazon Aurora】phpMyAdminでAmazon Auroraに接続

ひさしぶりすぎた
おーろらでびゅー

phpMyAdminはどっかにインストール済でAuroraも起動してるところから始めますよー
とりあえずね、Security Group作りましょう。
Inboundで「MYSQL/Aurora」を選択すればいいですね。

f:id:devdevdev:20160318091212p:plain

ModifyからSecurity Groupを今作ったものに変更。

f:id:devdevdev:20160318094258p:plain



で、phpMyAdminの設定画面に入ります。
URLは「phpMyAdminのURL/setup」ですよ。
「New server」をクリック

f:id:devdevdev:20160318100016p:plain



Verbose name of this server:任意の名前
Server hostname:Auroraのエンドポイント
Server port:3306

f:id:devdevdev:20160318100129p:plain

簡単ですねー
いじょー


【Unreal Engine 4】.gitignore

たぶんこれでおk

*.slo
*.lo
*.o
*.obj
*.gch
*.pch
*.so
*.dylib
*.dll
*.mod
*.lai
*.la
*.a
*.lib
*.exe
*.out
*.app
*.ipa
*.xcodeproj
*.sln
*.suo
*.opensdf
*.sdf
*.sln
SourceArt/**/*.png
SourceArt/**/*.tga
Binaries
Build
!Build/**/*.ico
Saved
Intermediate
DerivedDataCache





【VR】【Oculus Rift】【Unreal Engine 4】【C#】開発環境構築2016/01版

今年からVR入門しました。
とゆーわけで開発環境構築でも書きましょうかね。

Windows10 + Oculus Rift + Unreal Engine 4 + Visual Studio Community 2015です。開発はC++ですね。はい。

こいつらはインストール済ませておいてくださいねー。

Unreal Engine 4.10.2
Visual Studio Community 2015

なお、Oculus Rift持ってないので実機の動作は未確認でございます。

ではスタート。



1.Oculus Runtimeインストール

https://developer.oculus.com/downloads/

Oculus Runtime for Windows V0.8.0.0-beta
をダウンロードして
oculus_runtime_sdk_0.8.0.0_win.exeを実行してちょ。



2.Pluginチェック

Epic Games Launcherを起動します。
んで、左上にあるUnreal Engineの起動ボタンポチッと。
f:id:devdevdev:20160117033353p:plain

新規プロジェクト→C++→基本コードを選択。
設定はそのままフォルダと名前を指定して、「プロジェクトを作成」をポチッと。
f:id:devdevdev:20160117033549p:plain

しばらく待つとUNREAL EDITORとVisual Studioが起動します。
Visual Studioはまぁ置いときましょう。

メニューバーからEdit→Pluginsを選択
f:id:devdevdev:20160118231026p:plain

Virtual RealityOculus RiftのEnabledにチェックついてるのを確認しましょう。
ちなみにデフォルトでついてました。
f:id:devdevdev:20160118231255p:plain



3.実行
PlayからVR Previewを選択しましょう。
Oculus Runtimeのバージョンがあってなかったり、デバイスが接続されてないと押せないみたいです。

以上。





取りたい資格メモ

2年近く前のエントリーをTwitterでシェアしてくださってる方がいてびっくりしました
古すぎてもうあのソース使えない気がしますよ。

んで、本題。
受験日とか何も考慮してないので取れないのもありそう。
iOSの資格は変なのしかないから除外。
そしてオラクルはいらないかな。



MCSD: Windows Store Apps Using C#
MCSD: Web Applications
Androidアプリケーション技術者認定試験ベーシック
ORACLE MASTER Bronze Oracle Database 11g
・PHP5技術者認定上級試験
Javaプログラミング能力認定試験
AWS 認定デベロッパー – アソシエイト
技術士 情報工学部門



難しそうなのは技術士くらいですかね。
名称独占資格or業務独占資格のどっちか1つくらいは持っておきたいというだけの理由でノミネート。
せっかくJABEE認定の学科卒業したことだしね。なぜ卒業させてもらえたか謎なんだけどね。しかも応用理学部門らしいけどね。
なお、技術士情報工学部門の昨年度合格率19.2%。JABEE修了者は42.9%だそうで。
情報処理技術者試験でその年のプロマネ断トツ最年少合格者だった僕からしたら、合格率15%超える試験なんてザルですわwと自分にプレッシャーを与える。