View change-case.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertToPascalCase([Parameter(ValueFromPipeline)] [string] $text) { | |
($text -split '-' | ForEach-Object { | |
"$($_.ToCharArray()[0].ToString().ToUpper())$($_.Substring(1))" }) -join '' | |
} | |
function ConvertToKebabCase([Parameter(ValueFromPipeline)] [string] $text) { | |
([regex]"^-*").Replace(([regex]"[A-Z]").Replace($text, { "-" + $args[0].Groups[0].Value.ToLower() }), "") | |
} |
View join-sql.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[parameter(mandatory)][String]$outputFile | |
) | |
$divider="-- $("=" * 100)" | |
$files = Get-ChildItem .\*.* -Include *.sql -Exclude $outputFile | |
if (Test-Path $outputFile) { Clear-Content $outputFile } | |
function output { | |
process { | |
Out-File -Encoding UTF8 -FilePath $outputFile -Append -InputObject $PSItem |
View aws-mfa.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CACHE_FILE=~/.aws/aws-mfa-cache | |
OTHER="other" | |
function input_account () { | |
read -p "Account ID? " AWS_ACCOUNT_ID | |
read -p "Username? " AWS_USERNAME | |
read -p "Profile? " AWS_PROFILE | |
} |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GITHUB_API_URL = 'https://api.github.com'; | |
const GITHUB_TOKEN = '<GitHub API Token>'; | |
// Prepare axios for GitHub API | |
const axiosBase = require('axios'); | |
const github = axiosBase.create({ | |
baseURL: GITHUB_API_URL, | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': `token ${GITHUB_TOKEN}`, |
View TextFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.IO; | |
using System.Text; | |
/// <summary> | |
/// Provides iterators to read lines in a file. | |
/// </summary> | |
public static class TextFile | |
{ | |
/// <summary> |
View GetSHA256HashedString_net5.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .NET 5 まで | |
using System.Linq; | |
using System.Security.Cryptography; | |
using System.Text; | |
public static class StringExtensions | |
{ | |
static readonly SHA256CryptoServiceProvider hashProvider = new SHA256CryptoServiceProvider(); | |
public static string GetSHA256HashedString(this string value) | |
=> string.Join("", hashProvider.ComputeHash(Encoding.UTF8.GetBytes(value)).Select(x => $"{x:x2}")); |
View Env.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.CompilerServices; | |
/// <summary> | |
/// 環境変数を管理します。 | |
/// </summary> | |
public static class Env | |
{ | |
/// <summary> | |
/// デフォルトの .env ファイルのファイル名 | |
/// </summary> |
View LocalizedPropertyGridAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; | |
namespace YourApplication | |
{ | |
internal class LocalizedCategoryAttribute : CategoryAttribute | |
{ | |
public LocalizedCategoryAttribute(string resourceKey) | |
: base(LocalizedResources.GetString(resourceKey)) { } | |
} |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const AWS = require('aws-sdk'); | |
// EC2 インスタンスを起動する | |
function startEC2Instance(region, instanceId) { | |
const ec2 = new AWS.EC2({ region: region }); | |
const params = { | |
InstanceIds: [instanceId], | |
DryRun: false, |
View GenerateRandomPassword.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string PWS_CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
/// <summary> | |
/// 指定した長さの文字からなるランダムなパスワードを返します。 | |
/// </summary> | |
/// <param name="length">生成するパスワードの長さ</param> | |
/// <param name="availableChars">使用可能な文字の一覧</param> | |
/// <returns>生成されたパスワード</returns> | |
public static string GenerateRandomPassword(int length, string availableChars = PWS_CHARS) | |
{ | |
if (string.IsNullOrEmpty(availableChars)) availableChars = PWS_CHARS; |
NewerOlder