Skip to content

Instantly share code, notes, and snippets.

@Nunocky
Nunocky / 01.py
Created March 19, 2025 11:02
Claude tool use
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from itertools import count
import anthropic
from tool_text_revert import (
TOOL_TEXT_REVERT_NAME,
@Nunocky
Nunocky / EmailSignInViewModel.kt
Last active March 1, 2025 02:48
Android + Firebase
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@Nunocky
Nunocky / MainScreen.kt
Last active December 1, 2024 12:59
How to use AlertDialog in Jetpack Compose
// implementation(libs.androidx.lifecycle.viewmodel.ktx)
// implementation(libs.androidx.lifecycle.runtime.compose.android)
// implementation(libs.androidx.lifecycle.viewmodel.compose)
private suspend fun someAsyncFunction(): String {
delay(3000L)
// return "Hello"
throw Exception("error")
}
@Nunocky
Nunocky / app.build.gradle.kts
Last active February 23, 2025 12:16
Jetpack Composeでアプリを作るときのライブラリまとめ
# app
plugins {
...
alias(libs.plugins.google.services)
alias(libs.plugins.ksp)
alias(libs.plugins.hilt.android)
alias(libs.plugins.serialization)
}
@Nunocky
Nunocky / http_get.dart
Created February 23, 2024 09:00
http getを testで実行する
setUpAll(() => HttpOverrides.global = null);
test('http get', () async {
var url = Uri.https('official-joke-api.appspot.com', 'jokes/random');
var response = await http.get(url);
expect(response.statusCode, 200);
debugPrint(response.body);
});
@Nunocky
Nunocky / MessageNotifier.dart
Created February 23, 2024 03:45
AsyncNotifierの使い方
const sentenceList = {
'Your code transforms ideas into reality.',
'Each bug you fix makes you a stronger developer.',
'Your dedication to learning is inspiring.',
'You turn complex problems into elegant solutions.',
'Your creativity in app design is remarkable.',
'Every line of code you write is a step towards mastery.',
'You have a unique talent for making the complex understandable.',
'Your commitment to quality is evident in your work.',
'You\'re not just coding; you\'re crafting future technologies.',
@Nunocky
Nunocky / copy.sh
Created December 5, 2023 11:42
構成をそのままにシンボリックリンクを張る
#!/bin/bash
SRC="../../src"
DEST="."
# 現在のディレクトリからシンボリックリンクを検索し、削除
find . -type l -exec rm {} +
# 現在のディレクトリからディレクトリを検索し、削除
@Nunocky
Nunocky / docker-compose.yml
Last active July 28, 2023 02:28
gitbucket + jenkins
version: "3.9"
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
ports:
- "8080:8080"
- "50000:50000"
volumes:
@Nunocky
Nunocky / ExampleViewModel.kt
Last active June 25, 2023 01:41
ViewModelで実行されるコルーチンのテスト。 UIStateの変化を見る
package com.example.myapplication
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
@Nunocky
Nunocky / MainFragment.kt
Created June 25, 2023 00:57
Fragmentの値の保存と復元
package com.example.myapplication
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView