Skip to content

Instantly share code, notes, and snippets.

View succi0303's full-sized avatar

Takashi Sugimoto succi0303

View GitHub Profile
Parameters:
KeyName:
Description: The EC2 Pair to allow SSH access
Type: 'AWS::EC2::KeyPair::KeyName'
Resources:
Ec2Instance:
Type: 'AWS::EC2::Instance'
Properties:
SecurityGroups:
- !Ref InstanceSecurityGroup
{
"Parameters": {
"KeyName": {
"Description": "The EC2 Key Pair to allow SSH",
"Type": "AWS::EC2::KeyPair::KeyName"
}
},
"Resources": {
"Ec2Instance": {
"Type": "AWS::EC2::Instance",
Resources:
HelloBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
{
"Resources" : {
"HelloBucket" : {
"Type" : "AWS::S3::Bucket",
"Properties" : {
"AccessControl" : "PublicRead",
"WebsiteConfiguration" : {
"IndexDocument" : "index.html",
"ErrorDocument" : "error.html"
}
@succi0303
succi0303 / update-frontmatter-categories.py
Created July 7, 2019 04:55
Frontmatterのカテゴリーをフラットな文字列から配列に置き換える。
import os
import glob
import frontmatter
target_file = "*.markdown"
new_dir = "new/"
os.makedirs(new_dir, exist_ok=True)
for fname in glob.glob(target_file):
@succi0303
succi0303 / sd201903_1_4_list1.py
Last active March 1, 2019 13:05
『Software Design 2019 年 3 月号』の第1特集「IT エンジニアのための機械学習と微分積分入門」、第4章「微分でつなぐ、機械学習とニューラルネットワーク」のサンプルコードを写経したスクリプトです。
import torch
from torch import nn, optim
from torch.utils.data import TensorDataset, DataLoader
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_absolute_error
# データ読み込み、訓練データ/テストデータの分割
housing = fetch_california_housing()
@succi0303
succi0303 / edit-octopress-frontmatter-for-hugo.py
Created February 12, 2019 06:52
Octopressの記事のFrontmatterをHugoで使用するために編集する。
import os
import glob
import frontmatter
def create_url(fname):
return 'blog/' + fname.replace('-', '/', 3).replace('.markdown', '')
target_file = "*.markdown"
@succi0303
succi0303 / rename_octopress_posts_to_hugo_posts.rb
Created February 11, 2019 08:55
Octopressの記事ファイルをHugoに移行するためにリネームする。
require 'fileutils'
pattern = /\d{4}-\d{2}-\d{2}-(.*)\.markdown/
Dir.glob('./*.markdown').each do |file|
old_name = File.basename(file)
next unless (md = old_name.match(pattern))
new_name = "#{md[1]}.md"
FileUtils.mv(old_name, new_name)
@succi0303
succi0303 / git_change_ext_txt2md_under_this_dir_recursive.rb
Last active March 27, 2018 11:23
pwd配下(サブディレクトリ含む)のファイルの拡張子を`git mv`で一括変更する。txt -> md
Dir.glob("**/*.txt").each do |t|
src = File.expand_path(t)
dist = src.gsub(/txt$/, "md")
cmd = "git mv #{src} #{dist}"
puts "Execute '#{cmd}'"
`#{cmd}`
end
@succi0303
succi0303 / PasteImageFromFile.vba
Last active January 23, 2016 08:37
指定のセルの位置に画像ファイルのイメージを等倍で貼り付けるVBAのサブプロシージャ
' 指定のセルの位置に画像ファイルのイメージを等倍で貼り付ける
Private Sub PasteImageFromFile(targetRange As Range, imageFilePath As String)
Dim image As Shape
Dim startingSheet As Worksheet
' 処理開始前のシートを記録する
Set startingSheet = ActiveSheet
targetRange.Worksheet.Activate
targetRange.Select