Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
class 牛めし
{
public string 大きさ { get; set; }
public int カロリー { get; set; }
@jsakamoto
jsakamoto / allow.ps1
Created January 26, 2017 06:51
Create/Delete Azure Database server firewall rule by Microsoft Azure CLI 2.0 ("az" command)
$serverName = "<server name>"
$resourceGroupName = "<resource group name>"
$ruleName = "<rule name>"
$globalIPAddress = curl.exe -s http://inet-ip.info
echo "Global IP Address of this site: $globalIPAddress"
az sql server firewall create --firewall-rule-name $ruleName --server-name $serverName -g $resourceGroupName --start-ip-address $globalIPAddress --end-ip-address $globalIPAddress > $null
az sql server firewall list --server-name $serverName -g $resourceGroupName -o table
@jsakamoto
jsakamoto / Script1.fsx
Created November 10, 2016 23:04
Learn F# - mastering “Seq.map” – decode to ASCII art
let code = "f8f8f8f8f7b2f8f63181f8f5c1318131f8f401318101f8f3c10131810131f8f202318102f8f1c10231810231f803718103f7c10211f1e10331f6810271f28103f5e10211f1b1f1e10331f40371c131f28103f3c10211f10131f2e10331f2810271e10131f38103f1e103f1810131f3c10371f1810211e10131f3810211f2e103f18131f2e10331f3810231e131f28103f4e103f1b1f1e10371f5810231f2810211f6e103f1e10331f7810231810211f8e10231810271f8f1810131810111f8f2e10131810131f8f381318111f8f4c1318171f8f53191f8f7b1f8f8f8f8f07"
let decodeIt (code:string) =
let data =
[0..(code.Length/2)-1]
|> Seq.map (fun n -> code.Substring(n*2, 2))
|> Seq.map (fun s -> new String(s.[0], Convert.ToInt32(string s.[1], 16)))
|> Seq.toArray |> (fun a -> String.Join ("", a))
@jsakamoto
jsakamoto / _README.md
Last active November 18, 2018 04:15
Jasmine による TypeScript/JavaScript 単体テストを実行する環境を作る - karma 編

基本ステップ

OS 環境の整備

  1. node.js をインストールしておく (Windows ならここからインストーラをダウンロード)

プロジェクトごとの環境構築

  1. 作業フォルダ(プロジェクトフォルダ)に移動。
  2. &gt; npm init で作業場所を準備、package.json を生成。
@jsakamoto
jsakamoto / .gitignore
Last active September 2, 2016 13:01
オレの gulp
node_modules
@jsakamoto
jsakamoto / RestoreContextMenuZip.bat
Last active July 27, 2016 05:46
エクスプローラの「送る」の中に、「圧縮フォルダー」を復活させる、及び、Zipファイルの右クリックメニューを復活させる
@echo off
rem [注意] 日本語含んでいるので、SHIFT-JIS エンコードでこのバッチファイルを作成すること。
openfiles > NUL 2>&1
if NOT %ERRORLEVEL% EQU 0 goto NotAdmin
reg add HKCR\.zip /f /ve /d "CompressedFolder" > NUL
reg add HKCR\.zip /f /v "Content Type" /t REG_SZ /d "application/x-zip-compressed" > NUL
reg add HKCR\.zip /f /v "DontCompressInPackage" /t REG_SZ /d "" > NUL
reg add HKCR\.zip /f /v "PerceivedType" /t REG_SZ /d "compressed" > NUL
reg add HKCR\.zip\OpenWithProgids /f /v "CompressedFolder" /t REG_SZ /d "" > NUL
@jsakamoto
jsakamoto / pre-build.bat
Created July 20, 2016 14:09
pre-build script for create "custom.appSettings.config"
if exist "$(ProjectDir)custom.appSettings.config" goto SKIP
echo ^<?xml version="1.0" encoding="utf-8" ?^> > "$(ProjectDir)custom.appSettings.config"
echo ^<appSettings^> >> "$(ProjectDir)custom.appSettings.config"
echo ^<add key="(key)" value="(value)"/^> >> "$(ProjectDir)custom.appSettings.config"
echo ^</appSettings^> >> "$(ProjectDir)custom.appSettings.config"
:SKIP
@jsakamoto
jsakamoto / ExceptionLoggerTraceRedirector.cs
Created December 25, 2015 02:05
How to logging unhandled exceptions in ASP.NET Web API 2 running on Azure Web Apps
public class ExceptionLoggerTraceRedirector : ExceptionLogger
{
public override void Log(ExceptionLoggerContext context)
{
var logtext = new StringBuilder();
logtext.AppendLine($"Request: {context.Request}").AppendLine();
logtext.AppendLine($"Exception: {context.Exception}");
Trace.TraceError(logtext.ToString());
}
}
# LICENSE - [The Unlicense](http://unlicense.org/UNLICENSE)
cd (Split-Path ( & { $myInvocation.ScriptName } ) -Parent)
$now = [DateTime]::Now
for ($counter = 1; ; $counter++) {
$dirName = "{0:yyyy-MM-dd}-{1:D3}" -f $now, $counter
if (-not (Test-Path $dirName)) {
md $dirName > $null
break;
}
@jsakamoto
jsakamoto / .ps1
Last active December 22, 2015 22:57
Enable .ps1 file in "New" items on Windows Explorer folder context menu.
# Enable .ps1 file in "New" items on Windows Explorer folder context menu.
# LICENSE - [The Unlicense](http://unlicense.org/UNLICENSE)
New-PSDrive -name HKCR -PSProvider Registry -root HKEY_CLASSES_ROOT
New-Item HKCR:\.ps1\ShellNew
New-ItemProperty HKCR:\.ps1\ShellNew NullFile -propertyType String