Skip to content

Instantly share code, notes, and snippets.

View tanaka-takayoshi's full-sized avatar

tanaka_733 tanaka-takayoshi

View GitHub Profile
@tanaka-takayoshi
tanaka-takayoshi / setup.ps1
Created August 16, 2013 11:07
Setup Windows Server 2012 for NAT instace on VPC (Amazon EC2)
Set-NetIPInterface -InterfaceIndex 12 -AutomaticMetric Disabled -InterfaceMetric 1
Get-NetFirewallProfile | Set-NetFirewallProfile -Enabled false
Install-WindowsFeature RemoteAccess -IncludeManagementTools
Add-WindowsFeature -name Routing -IncludeManagementTools
Restart-Computer
Get-NetIPInterface
Set-NetIPInterface -InterfaceIndex 12 -AutomaticMetric Disabled -InterfaceMetric 1
Get-NetFirewallProfile | Set-NetFirewallProfile -Enabled false
Install-WindowsFeature RemoteAccess -IncludeManagementTools
Add-WindowsFeature -name Routing -IncludeManagementTools
Restart-Computer
static void Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-License-Key", "YourLicenseKey");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var last = DateTime.Now;
while (true)
{
Thread.Sleep(60 * 1000);
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
@tanaka-takayoshi
tanaka-takayoshi / deploy.cmd
Created October 31, 2013 08:12
dirPath プロバイダーを使ってディレクトリの中身をMSDeployで同期するコマンド
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:dirPath="C:\Repository" -dest:computerName="http://ww.xx.yy.zz/MSDeployAgentService",userName="administrator",password="zeijaku",includeAcls="False",dirPath="C:\www\Image" -skip:objectName='dirPath',absolutePath='\\\.git'
@tanaka-takayoshi
tanaka-takayoshi / DateTimeExtensions.cs
Created December 7, 2013 11:20
DateTimeをUnixTimeに変換する拡張メソッドと、JSON.NET用の変換クラス
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Chatwork.Service
{
public static class DateTimeExtensions
using (var rs = RunspaceFactory.CreateRunspace())
{
rs.Open();
using (var ps = PowerShell.Create())
{
ps.Runspace = rs;
ps.AddCommand("Get-ChildItem");
foreach (var result in ps.Invoke())
{
Console.WriteLine("{0} {1}", result.Properties["Name"].Value, result.Properties["CreationTime"].Value);
var connectionInfo = new WSManConnectionInfo()
{
Scheme = "https",
ComputerName = "servername.cloudapp.net",
Port = 7654,
Credential = new PSCredential("username",
"syoboipassword".Aggregate(new SecureString(), (s, c) =>
{
s.AppendChar(c);
return s;