Skip to content

Instantly share code, notes, and snippets.

View yukin01's full-sized avatar

Yuji Kinjo yukin01

  • Tokyo / Japan
View GitHub Profile
@yukin01
yukin01 / IAMCredentials.json
Created December 20, 2023 16:50 — forked from ServerlessBot/IAMCredentials.json
Minimum credential set for Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@yukin01
yukin01 / convert.go
Created May 6, 2020 16:20
Convert json struct to map in Go
import "encoding/json"
func structToMap(s interface{}) map[string]interface{} {
m := make(map[string]interface{})
b, _ := json.Marshal(s)
json.Unmarshal(b, &m)
return m
}
@yukin01
yukin01 / spawn.js
Last active December 14, 2019 16:22
Promisify child_process.spawn
const childProcess = require("child_process");
const spawn = (command, args) => {
return new Promise((resolve, reject) => {
const p = Array.isArray(args)
? childProcess.spawn(command, args, { stdio: "inherit" })
: childProcess.spawn(command, { stdio: "inherit" });
p.on("close", code => resolve(code));
p.on("error", err => reject(err));
});
@yukin01
yukin01 / rezip.ts
Last active October 12, 2019 18:33
Remove root directory from zip file
import { readFile, writeFile } from 'fs'
import { promisify } from 'util'
import * as JSZip from 'jszip'
const main = async () => {
const oldPath = 'old.zip'
const oldBuf = await promisify(readFile)(oldPath)
const oldZip = await JSZip.loadAsync(oldBuf)
const files = oldZip.files
@yukin01
yukin01 / sharp-sample01.js
Last active May 23, 2019 06:33
1024 * 1024 を超えないようにリサイズ(トリミングなし、拡大なし)
const sharp = require('sharp')
const path = require('path')
const filePath = './image.png'
const fileName = path.basename(filePath, path.extname(filePath))
sharp(filePath)
.resize(1024, 1024, {
fit: sharp.fit.inside,
withoutEnlargement: true
var inputLines = [String]()
while let line = readLine() {
inputLines.append(line)
}
let rows = inputLines.dropFirst()
rows.forEach { print($0) }
@yukin01
yukin01 / Slackfile
Created April 13, 2019 12:33
Custom Slack Action for Fastlane
# vim: syntax=ruby
private_lane :custom_slack do |options|
ENV["TZ"] = "Asia/Tokyo"
slack(
message: options.fetch(:message, "No messages"),
success: options.fetch(:success, true),
slack_url: "hoge",
payload: {
"Build Date" => Time.new.to_s,
@yukin01
yukin01 / DesignableView.swift
Last active February 23, 2021 05:11
Add @IBDesignable and @IBInspectable to UIView, UIButton, UIImageView and UITextField
import UIKit
protocol Roundable {
var cornerRadius: CGFloat { get set }
}
protocol Borderable {
var borderWidth: CGFloat { get set }
var borderColor: UIColor? { get set }
}
protocol Shadowable {
@yukin01
yukin01 / ClipToRoundView.swift
Created April 4, 2019 15:40
ClipToRoundView
@IBDesignable
final class ClipToRoundView: UIView {
@IBInspectable
var fillColor: UIColor = .white {
didSet {
shapeLayer.fillColor = fillColor.cgColor
}
}
@yukin01
yukin01 / SingleSectionModel.swift
Created March 4, 2019 10:18
RxDataSources+SingleSectionModel
import Foundation
import Differentiator
struct SingleSectionModel<ItemType: Equatable> {
var items: [ItemType]
init(items: [ItemType]) {
self.items = items
}
}