Skip to content

Instantly share code, notes, and snippets.

@azechi
azechi / LINQ_Method_QueryExp.csx
Last active June 22, 2018 03:17
Programming in Scala S23.2 The n-queens problem
Func<(int, int), (int, int), bool> inCheck = (q1, q2) => q1.Item1 == q2.Item1 || q1.Item2 == q2.Item2 || Math.Abs(q1.Item1 - q2.Item1) == Math.Abs(q1.Item2 - q2.Item2);
Func<(int, int), IEnumerable<(int, int)>, bool> isSafe = (queen, queens) => queens.All(q => !inCheck(queen, q));
Func<int, IEnumerable<IEnumerable<(int, int)>>> queens = n => {
Func<int, IEnumerable<IEnumerable<(int, int)>>> placeQueens = null;
placeQueens = k => {
if (k == 0){
return Enumerable.Repeat(Enumerable.Empty<(int, int)>(), 1);
} else {
@azechi
azechi / Clip_URLShortcut.bat
Created January 19, 2018 08:37
WindowsのSendToでWebページのショトートカットファイルを"[title url]"の文字にしてクリップボードに保存する
@fsi --exec %HOME%\bin\Clip_URLShortcut.fsx %* | clip
@pause
@azechi
azechi / Decrypt_AuthenticationTicket.csproj
Last active October 3, 2018 19:47
.Net Core Decrypting Legacy FormsAuthenticationTicket (mode=Framework20SP2, SHA1, AES)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RootNamespace>App</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.3.0" />
@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
@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 / 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"
&(Read-S3Object -BucketName "bucketName" -Key "file.ps1" -File ([io.path]::GetRandomFileName() + ".ps1"))
net user administrator "password"
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
@azechi
azechi / firewall.bat
Created July 25, 2016 01:19
windowsの設定
netsh advfirewall firewall set rule name="Windowsリモート管理(HTTP受信)",profile=public new remoteip=any