Skip to content

Instantly share code, notes, and snippets.

View moaible's full-sized avatar

Hiromi Motodera moaible

View GitHub Profile
#!/bin/sh
# shellcheck shell=dash
# This is just a little script that can be downloaded from the internet to
# install rustup. It just does platform detection, downloads the installer
# and runs it.
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
@moaible
moaible / aws_ssh.sh
Created September 11, 2020 01:38
Generate AWS SSH Setting
mkdir -p ~/.ssh
echo $GP_AWS_SSH_KEY_RSA | base64 -d > ~/.ssh/id_rsa
echo $GP_AWS_SSH_KEY_RSA_PUB | base64 -d > ~/.ssh/id_rsa.pub
echo -e "\n\
Host git-codecommit.*.amazonaws.com\n\
User $GP_AWS_SSH_KEY_ID\n\
IdentityFile ~/.ssh/id_rsa\n\
" > ~/.ssh/config
chmod 0600 ~/.ssh/id_rsa
chmod 0600 ~/.ssh/id_rsa.pub
@moaible
moaible / .sh
Last active September 9, 2020 14:28
[AWS CLI - CodeCommit - create-repository] AWS CLI - CodeCommit - create-repository #AWS_CLI #AWS_CodeCommit
aws codecommit create-repository \
--repository-name :リポジトリ名 \
--repository-description ":リポジトリの説明"
@moaible
moaible / .Dockerfile
Created September 9, 2020 14:19
[Dockerfile - AWS CLI] Configure AWS CLI command #Dockerfile
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN sudo ./aws/install
@moaible
moaible / main.go
Last active August 19, 2020 21:49
go2go: Optional
package main
import (
"fmt"
"github.com/moaible/goptional" // yet not repository
)
func main() {
var baseValue = 1
var var1 *int = nil
@moaible
moaible / AmplifyAPI+Promise.swift
Last active August 10, 2020 02:39
Swift - Hydra with AmplifyAPI
import Foundation
import Amplify
import Hydra
enum RequestOperation<M: Model> {
case create(_ model: M)
case update(_ model: M, where: QueryPredicate? = nil)
case delete(_ model: M, where: QueryPredicate? = nil)
}
@moaible
moaible / AmplifyApiClient.ts
Last active July 30, 2020 01:19
Amplify API Wrapper
import { API, Logger } from 'aws-amplify';
// NOTE: もしAmplify関連で問題を調査したい場合 'DEBUG' にすると細かい挙動が確認できます
Logger.LOG_LEVEL = 'WARN';
export type Headers = object | undefined; // TODO: 適切な型にする
export type QueryParams = object | undefined; // TODO: 適切な型にする
export type Body = object | undefined; // TODO: 適切な型にする
export interface ApiRequest {
import Foundation
extension Array {
public func chunked(into size: Int) -> [[Element]] {
guard size > 0 else {
fatalError("Chunk size must not be zero")
}
return stride(from: 0, to: count, by: size).map {
Array(self[$0 ..< Swift.min($0 + size, count)])
@moaible
moaible / TabViewController.swift
Last active June 25, 2019 13:08
tap tab to change element view controller
import UIKit
class ButtonViewController: UIViewController {
var tapAction: (() -> Void)?
private lazy var button: UIButton = {
let v = UIButton.init(frame: .init(x: 0, y: 0, width: 60, height: 60))
v.backgroundColor = .orange
v.addTarget(self, action: #selector(didTapAction), for: .touchUpInside)
return v
}()
@moaible
moaible / ScrollViewObserver.swift
Last active June 17, 2019 09:07
ScrollViewObserver
import Foundation
import RxSwift
import RxCocoa
/// スクロール対象
public class ScrollContent {
// MARK: - Property
// MARK: Content info