Skip to content

Instantly share code, notes, and snippets.

View laiso's full-sized avatar
☀️

laiso laiso

☀️
View GitHub Profile
@laiso
laiso / post.ts
Last active July 30, 2022 15:20
Read a parameter from POST body in Vercel Edge Functions
// api/post.ts
export const config = {
runtime: 'experimental-edge',
}
export default async (req: Request) => {
if (req.method !== 'POST') {
return new Response('Method not allowed', { status: 405 });
}
@laiso
laiso / CodePiece.js
Last active November 5, 2020 16:21
SSG+CSR #CodePiece
// pages/posts/[id].js
export default function Page(props) {
const router = useRouter()
const [post, setPost] = useState(props.post)
if (!post) {
return <Locading />
}
useEffect(async () => {
if (!post) {
const resp = fetch(`https://example.com/api/post/${router.params.id}`)
@laiso
laiso / CodePiece.js
Created October 14, 2020 17:19
useCounterの中身。injectしてるからVueインスタンス経由でアクセスしないといけない。アプリケーションコードは上流でprovide()してコンポーネント間で状態管理する #CodePiece
import { ref, inject, Ref } from 'vue';
export const CounterKey = Symbol()
export type Counter = {
count: Ref
increment(): void
}
export function useCounter(initialValue: number): Counter {
const count = inject(CounterKey, ref(initialValue));
return {
count,
@laiso
laiso / CodePiece.js
Created October 14, 2020 17:14
こんな感じの雛形を用意して useCounter 部分のテストを書くことにした #CodePiece
import {shallowMount} from '@vue/test-utils'
import {useCounter} from "@/composables/counter";
const Example = {
setup() {
return {
...useCounter(0),
}
},
template: `example`,
}
@laiso
laiso / CodePiece.sh
Last active September 11, 2020 16:41
findlist.bash #CodePiece
#!/bin/sh
# $ ./findlist.bash jack
id=$1
COUNTER=""
while [ true ]
do
name="list${COUNTER}"
curl -s "https://mobile.twitter.com/search?q=list%3A%40${id}%2F${name}&src=typed_query" | grep -s timeline > /dev/null && echo "list:@${id}/${name} HIT" || echo "list:@${id}/${name} MISS"
let COUNTER++
@laiso
laiso / toc.diff
Last active August 30, 2020 13:25
diff: Kubernetes完全ガイド 第2版 https://book.impress.co.jp/books/1119101148
第1章 Dockerの復習と「Hello, Kubernetes」
第2章 なぜKubernetesが必要なのか?
第3章 Kubernetes環境の選択肢
第4章 APIリソースとkubectl
第5章 Workloads APIsカテゴリ
第6章 Service APIsカテゴリ
第7章 Config&Storage APIsカテゴリ
第8章 Cluster APIsカテゴリとMetadata APIsカテゴリ
第9章 リソース管理とオートスケーリング
第10章 ヘルスチェックとコンテナのライフサイクル
@laiso
laiso / CodePiece.swift
Created July 17, 2020 18:44
VaporでJSONレスポンスを返す #CodePiece
import Vapor
struct MyResponse: Content {
let name: String
}
func routes(_ app: Application) throws {
app.get { req in
return MyResponse(name: "popo")
}
}
@laiso
laiso / Pulumi.md
Last active June 30, 2020 15:45
Pulumi メモ

https://www.pulumi.com/

  • アプリケーション開発の言語でIaCするCDKじゃないやつ

Define infrastructure in JavaScript, TypeScript, Python, Go, or any .NET language, including C#, F#, and VB.

関連ツール

@laiso
laiso / CodePiece.kt
Created April 14, 2020 06:19
a sample post by CodePiece #CodePiece
// (c) https://qiita.com/tasogarei/items/fea4d392dbd4449980f7
fun main(args: Array<String>) {
(1..100).forEach{
when {
it % 15 == 0 -> println("fizzbuzz")
it % 3 == 0 -> println("fizz")
it % 5 == 0 -> println("buzz")
else -> println(it)
}
}

Realm近況

モバイルDBのRealmっていう製品について、最近の動向を調べた

2016年

  • 初期のSQLite代替というよりFirestoreのようなクラウド同期型DBとして進化している
  • Realm Object Server