Skip to content

Instantly share code, notes, and snippets.

View crakaC's full-sized avatar

K.SHIRAKASHI crakaC

View GitHub Profile
@crakaC
crakaC / Makefile
Last active October 2, 2024 16:39
テスト用のクライアント証明書を作ってAndroid端末にpushする
.PHONY: gen
gen:
@make clean
bash generate_test_client_cert.sh
adb push client.pfx /sdcard/Download/client.pfx
.PHONY: clean
clean:
@rm -rf tmp client.*
@echo cleaned up!
@crakaC
crakaC / readResouceAsText.kt
Created June 10, 2023 09:59
resources内のファイルを読み込むやつ
fun readResourceAsText(name: String): String {
return {}.javaClass.classLoader.getResource(name)!!.openStream().use {
it.readAllBytes().toString(Charsets.UTF_8)
}
}
@crakaC
crakaC / launch.json
Created December 25, 2022 17:23
launch.json for lldb debug
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb)Launch",
"type": "cppdbg",
"request": "launch",
@crakaC
crakaC / migrating.md
Created May 2, 2022 11:41
Mastodon用サーバーをUbuntu20.04からUbuntu22.04にアップデートしたときに踏んだものまとめ

事前にapt-get update && apt-get upgrade && apt-get autoremoveしておいてからの

$ sudo do-release-update -d

でUbuntu自体は22.04に上がる。

上がるタイミングで設定ファイルに変更があったやつどうする?更新する?と聞かれるが全部No。

Refused connection

よくわからない。resolv.confがなんか悪さしてそうということしかわからない。

@crakaC
crakaC / gist:378714d12c2de60f507ae3247fb0349a
Created April 11, 2022 00:19
GitHubにRelease作ったりするやつ
# Release内のAssets一覧
curl -v \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets
# Assets追加 こいつだけBaseURLが違う
curl -v \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
@crakaC
crakaC / PreviewDropDownMenu.kt
Last active December 11, 2021 16:27
DropDownMenuをPreviewする
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@crakaC
crakaC / crt.kt
Last active March 7, 2021 17:09
中国剰余定理
// https://qiita.com/drken/items/ae02240cd1f8edfc86fd
// https://github.com/NASU41/AtCoderLibraryForJava/blob/132179385293fd6c0d522d73f3f48435967fffcb/Math/MathLib.java
fun mod(a: Long, m: Long): Long {
val x = a % m
return if (x < 0) x + m else x
}
fun extGCD(a: Long, b: Long): LongArray {
if (b == 0L) {
@crakaC
crakaC / remove_account.rb
Created February 8, 2021 09:44
Mastodonでローカルユーザーからフォローされておらずトゥートが1つもローカルに保存されていないアカウントを削除する
Account.remote.where('id NOT IN (SELECT follows.target_account_id FROM follows WHERE follows.accoun
t_id IN (SELECT accounts.id FROM accounts WHERE accounts.domain IS NULL))').where('(SELECT COUNT(*) as c FROM status
es WHERE statuses.account_id = accounts.id) = 0').find_each{|e| DeleteAccountService.new.call(e,reserve_username: fa
lse, reserve_email: false)}
@crakaC
crakaC / template.kt
Last active February 8, 2021 08:08
競プロ用テンプレその2
import java.io.PrintWriter
import java.io.InputStream
fun main(){
flush()
}
fun println(any: Any?){stdout.println(any)}
fun flush(){stdout.flush()}
fun readLine() = stdin.readLine()
fun readInt() = stdin.readInt()
@crakaC
crakaC / bit.kt
Last active February 1, 2021 16:55
FenwickTreeまたはBinaryIndexedTree
//0-indexed
class BIT(val n: Int){
val bit = IntArray(n)
fun sum(i: Int): Int {
var i = i - 1
var s = 0
while(i >= 0){
s += bit[i]
//i+1(==1-indexedのときのi)の最も右の1が立っているbitを0にして-1する
i = i.and(i+1) - 1