Skip to content

Instantly share code, notes, and snippets.

View shootacean's full-sized avatar
🏠
Working from home

Shota Narisaka shootacean

🏠
Working from home
View GitHub Profile
@shootacean
shootacean / describe_rds_cluster_backup_info.py
Last active June 18, 2021 22:31
Amazon RDSのバックアップ設定を一覧で取得するPythonスクリプト
import sys
import time
import boto3
AWS_REGION = 'ap-northeast-1'
AWS_PROFILE = 'your-profile'
if __name__ == "__main__":
session = boto3.Session(profile_name=AWS_PROFILE, region_name=AWS_REGION)
@shootacean
shootacean / translate_blog_title.py
Created June 16, 2021 04:55
DeepL API Freeを使った日本語ブログ記事タイトルをブログURLに変換するPythonスクリプト
import sys7
import urllib.request
import json
DEEPL_AUTH_KEY = "key" #ここをAPIキーで置き換える
DEEPL_ENDPOINT_TRANSLATE = "https://api-free.deepl.com/v2/translate"
DEEPL_ENDPOINT_USAGE = "https://api-free.deepl.com/v2/usage"
def monitor_usage():
"""使用状況を確認する"""
@shootacean
shootacean / main.dart
Created September 7, 2020 14:20
Flutter - HTTP Request
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@shootacean
shootacean / ArticlesControllerTest.php
Created June 27, 2020 15:49
CakePHP3のユニットテストでテストデータを動的に用意する方法
<?php
namespace App\Test\TestCase\Controller;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
class ArticlesControllerTest extends TestCase
{
public $Articles;
@shootacean
shootacean / main.rs
Last active August 20, 2019 14:24
Rust 練習用
use std::io::{self};
fn main() {
hello();
loop_for();
loop_if();
}
@shootacean
shootacean / GoMakefile
Last active August 5, 2019 04:47
go makefile quick Start
# ref: https://frasco.io/golang-dont-afraid-of-makefiles-785f3ec7eb32
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=mybinary
BINARY_UNIX=$(BINARY_NAME)_unix
all: test build
@shootacean
shootacean / index.js
Last active June 12, 2019 04:00
JavaScriptで現在位置を取得する
const usableGeolocation = () => {
return "geolocation" in navigator;
};
window.onload = () => {
if (!usableGeolocation()) {
console.error('Cannot use geolocation');
return false;
}
const geoLocation = navigator.geolocation;
// sliceの重複要素を削除
func slimSlice(slice []int) []int {
m := make(map[int]int)
slim := make([]int, 0)
for _, element := range slice {
if _, ok := m[element]; !ok {
m[element] = 0
slim = append(slim, element)
}
}
func gcd(a, b int) int {
if b == 0 {
return a
}
return gcd(b, a%b)
}
@shootacean
shootacean / main.go
Last active February 14, 2019 04:40
Golangでデータベースに接続する
package main
import (
"database/sql"
)
func main() {
// open database
db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/my_database")
if err != nil {