SAT solverとは
ある論理式がsatisfiableかどうかを確認してくれるソフトウェアです。
つまり、trueとなる解があるかどうを判定し、ある場合はその1パターンを出力してくれます。
例えば、(x or y) and (x or not y)の場合はxがtrueの場合のみ全体がtrueとなることが分かると思います。よってこの論理式をSAT
solverに食わせるとsatisfiableと判定しくれます。
> a SAT solver is a computer program
[https://en.wikipedia.org/wiki/Computer_program] which aims to solve the
Boolean
satisfiability problem
[https://en.wikipedia.org/wiki/Boolean_satisfiability_problem]. On input a
formula over Boolean [https://en.wikipedia.org/wiki/Boolean_data_typCloud RunとLitestream、GCSを使用して、SQLiteを使用したGoアプリケーションを格安運用していこうと思います。
FirestoreなどのNoSQL DBを使っても安く運用できますが、RDB使いたいというときもあるということで。
作ったもの
GitHub - kooooohe/litestream-cloud-runContribute to
kooooohe/litestream-cloud-run development by creating an account on GitHub.
GitHubkooooohe [https://github.com/kooooohe/litestream-cloud-run]\]簡単な構成
Litestream
LitestreamLitestream is an open-source, real-time streaming replication tool
that lets you safely run SQLite applications on a single node.Litestream
[ht巷で噂になっているtRPCを触ってみたいと思い、せっかくなんでDenoで動かしてみました。
普段はOpenaAPIを使用している。そこからClient,Sever両方にコードを生成し、ClientからはSever側で実行される同じ名前の関数を実行してリクエストを飛ばしているため、RPCっぽい挙動になっている。
※ ClientはReactで動かそうと思いましたが、それはまた次回。
RPCとは
> >Remote Procedure Call is a software communication protocol that one program can
use to request a service from a program located in another computer on a network
without having to understand the network's details. RPC is used to call other
processes on the remote systems like a local system. A prStable Diffusion
今何かと話題なStable Diffusionをローカルで動かしてみたい。
商用利用も可能とのことで、広告素材にも使えたら熱いと思い試してみる。
※GPUを使って動かそうとすると少し準備が大変そうだったので、また次回
GitHub - CompVis/stable-diffusionContribute to CompVis/stable-diffusion
development by creating an account on GitHub.GitHubCompVis
[https://github.com/CompVis/stable-diffusion]作ったもの
GitHub - kooooohe/stable-diffusionContribute to kooooohe/stable-diffusion
development by creating an account on GitHub.GitHubkooooohe
[https://github.com/kooooohe/stable-diffusion]環境
Ubuntu
Codespacesとは
クラウド上で、開発ができる機能。
VSCodeやブラウザを使って開発が可能。
ブラウザで開発可能なので、自身のPCのスペックに関係なく(タブレットでも)スムーズに開発ができます。(PWA化もされているので、Vimのプラグインなどを入れても、ブラウザのショートカットキーとかぶらず、快適に開発ができます)
CodespacesYour instant dev environmentGitHub
[https://github.co.jp/features/codespaces]※2022/07/03時点でβ版の機能です。
このように、開発環境のスペックをそのつど選ぶことができます。
重い処理をする際に気軽にスペックを上げることができるのは非常に魅力的。
料金はこちら
Codespaces の支払いについて - GitHub Docs
価格を見て、OrganizationでのCodespacesの支払いの管理方法を確認してください。GitHub Docs
[https://docs.github.com/ja/billing/managing-Caddyとは
Caddy 2 - The Ultimate Server with Automatic HTTPSCaddy is a powerful,
enterprise-ready, open source web server with automatic HTTPS written in GoThe
Ultimate Server with Automatic HTTPSCaddy Web Server [https://caddyserver.com/]
HTTPSを簡単に自動的に使えるようにしてくれる唯一のweb server (2022/05/03)
証明書を自動更新してくれる機能があり、defaultではLet's Encryptを使用。
A(AAAA)レコードを設定したあとに、Caddyfileに下記を書いておけば、あとはよろしくやってくれるというすぐれもの。
※ちなみにGo製
example.com
respond "Hello, kohe!"
Amazon EC2 (Amazon Linux2) & Let's Encrypt
で試してみた
いつの間にか、Secret ManagerとCloud Runの連携がPublic Previewではなくなっていたので、触ってみた。
Secret Manager | Google CloudSecurely store API keys, passwords, certificates,
and other sensitive data with Google Cloud’s Secret Manager.Google Cloud
[https://cloud.google.com/secret-manager]せっかくなので前からちょいと気になっていた ko を使ってbuild,pushをしていこうと思う。
ko を使用して Go アプリケーションを Cloud Run に迅速にデプロイ | Google Cloud Blog※この投稿は米国時間 2021 年 2
月 17 日に、Google Cloud blog
に投稿されたものの抄訳です。開発者がコンテナを使用して作業することが多くなるに従い、ソースコードからアプリケーションがデプロイされるまでの時間を短縮することの
動機
10年前から使っているデスクトップPCがある。いろいろガタが来ていたがBTOなので、OSの変更(windows7→Ubuntu20.04)、電源の交換(750w)、メモリの増設16GB→32GBによりパッチを当てて使っていたが、ついにPCの起動はまだしもcd
がめちゃくちゃ遅いことがきにってきたので、HDD から SSDへのcloneを行うことにした。
※おそらくfish shellでのgit情報の読み込みの兼ね合い
0からセットアップするのがめんどくさいためcloneを選択
移行前の起動時間は約127秒。遅い…
注意:
2TB HDD → 512GB SSDですが、実際にHDDに入っているデータが200GB程度とSSDの容量よりも少ないので今回の方法でいけます。
準備するもの
* USB 16GB以上 (UbuntuのLive USB用)
Amazon | バッファロー【国内メーカー】 USBメモリ 32GB USB3.2(Gen1)/3.1(Gen 1)/3.0/2.0 充実サポート
RUF3-K32GA-BK/N【Amazon.co.jp限定】 | バッフ※まだプレビュー版です(2021/09/18)
Cloud Run gets always-on CPU allocation | Google Cloud BlogNew always-on CPU
allocation for Cloud Run opens the doors to running workloads that use
background processes.Google Cloud BlogSteren Giannini Senior Product Manager
[https://cloud.google.com/blog/products/serverless/cloud-run-gets-always-on-cpu-allocation]
今まではRequestがきてからResponseを返すまでCPUの割当がされていました。しかしそれでは下記のSlackのような3秒以内レスポンスを返す必要があるケースにて困ることが多々有りました。基本的にこのようなAPIはレスポンスを先に返してしまい、あとで別途非同期で処理を実行するという形で対応していましたが、そプロダクト開発の全体的な流れは以下の記事に書いてありますので、今回はGitHubを活用したカンバン方式の詳細を書いて行こうと思います。
Anti-Pattern Inc. Engineering Blog - Anti-Pattern Inc. Engineering Blog
Anti-Pattern Inc.(株式会社アンチパターン)のエンジニアブログです。Anti-Pattern Inc. Engineering Blog
[https://tech.anti-pattern.co.jp/anti-pattern-inc-dev-knowledge-202107/]
アンチパターン社における非同期的なプロダクト開発のナレッジ(202107スナップショット)
また、開発メンバーの半数以上が副業です。優秀な方々であれば豊富な知識と思考を持っているため、短時間でも十分な成果を出せます。
重要なのはいかに、そういった方々が働きやすい仕組みを作るか、となります。
ちょうどスポットインスタンスをいかにうまく使うかと似ていると思っています。活用にコツがいりますが、扱えれば絶大なパフォーマ皆さんご存知の二分探索。この応用について今回は書いていきたいと思う。
二分探索の一般化
二分探索とはつまり、範囲を特定することである。
例億マス計算
そこで今回は二分探索を使う下記問題を解いていく
C - 億マス計算AtCoder is a programming contest site for anyone from beginners to
experts. We hold weekly programming contests online.AtCoderAtCoder Inc.
[https://atcoder.jp/contests/arc037/tasks/arc037_c]
愚直に2重ループで解くと
O(N²)になるため、時間が足りなくなる
blog-binary_search_2blog-binary_search_2. GitHub Gist: instantly share code,
notes, and snippets.Gist262588213843476
[https://gist.github.com/kooooohe/8cc33e0f1e目次
* きっかけ
* Two’s complement(2の補数)
* 累積和
* BIT(binary indexed tree)
* 転倒数
きっかけ
先日友人から下記の結果についての質問がきた。
package main
import (
"fmt"
)
func main() {
const a = ^0
fmt.Println(a)
}
皆さんも予想してみてほしい。
実行は↓から
The Go Playground [https://play.golang.org/p/qpWRExXsJ8E]
^0 はNOTでbit反転なのだが、値はintegerのmax値になることなく
`-1` となる。
これは、ご存知Signed Integer で全bitが1の場合はTwo’s complement(2の補数)となり `-1`が出力される。
そして、Goのconstは数値が右辺に来た場合はSigned Integer Typeとデフォルトで解釈する。
では uintのmaxの値をbit反転で取りたい場合はというと
package