Skip to content

Instantly share code, notes, and snippets.

@azechi
azechi / triangle.rb
Created July 20, 2015 04:38
三角形の形を求める
class Triangle
def self.hantei(a,b,c)
# 2辺を足した数が残り1辺"より小さい"
if(!(a < b + c && b < a + c && c < a + b))
return '三角形じゃないです><'
end
@azechi
azechi / Startup.cs
Created April 15, 2016 02:29
ASP.NET PreApplicationStartMethod
using System.Web;
[assembly: PreApplicationStartMethod(typeof(Startup), "PreApplicationStart")]
public static class Startup
{
public static void PreApplicationStart()
{
}
HttpContent content;
var context = Request.Properties["MS_HttpContext"] as System.Web.HttpContextWrapper;
if (context != null) {
content = new StreamContent(context.Request.GetBufferlessInputStream(disableMaxRequestLength: true));
content.Headers.ContentType = Request.Content.Headers.ContentType;
} else {
content = Request.Content;
}
await content.ReadAsMultipartAsync(provider);
@azechi
azechi / firewall.bat
Created July 25, 2016 01:19
windowsの設定
netsh advfirewall firewall set rule name="Windowsリモート管理(HTTP受信)",profile=public new remoteip=any
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
namespace WebApplication1
{
public class Run : HttpTaskAsyncHandler
net user administrator "password"
&(Read-S3Object -BucketName "bucketName" -Key "file.ps1" -File ([io.path]::GetRandomFileName() + ".ps1"))
@azechi
azechi / eventlog.ps1
Created December 31, 2016 01:04
PowerShell
$source = "なまえ"
if([System.Diagnostics.Eventlog]::SourceExists($source) -eq $false)
{
New-Eventlog -Logname Application -Source $source
}
Write-Eventlog -LogName Application -Source $source -EntryType Error -EventId 1 -Message "message"
@azechi
azechi / R53ResourceRecordSet.ps1
Created January 5, 2017 02:35
UPDATE_Route53_RecordSet_AWSEC2MetaData_PublicIP
$ip = (invoke-webrequest http://169.254.169.254/latest/meta-data/public-ipv4 -UseBasicParsing).content
$zoneId = "/hostedzone/[id]"
$name = "abc.example.com."
Import-Module AWSPowerShell
$c = new-object Amazon.Route53.Model.Change
$c.Action = "UPSERT"
$c.ResourceRecordSet = new-object Amazon.Route53.Model.ResourceRecordSet
$c.ResourceRecordSet.Name = $name
$c.ResourceRecordSet.Type = "A"
@azechi
azechi / file1.bat
Last active February 14, 2017 00:43
まるっとコピー
:: 管理者として実行する
robocopy C:\Source D:\Destination /E /R:0 /W:0 /NP /XJ /LOG:logfile.txt