Skip to content

Instantly share code, notes, and snippets.

@aidiary
aidiary / ContentView.swift
Created Apr 24, 2022
NavigationLinkのList表示
View ContentView.swift
//
// ContentView.swift
// MyFirstSwiftUIApp
//
// Created by Koichiro Mori on 2022/04/24.
//
import SwiftUI
struct Data: Identifiable {
@aidiary
aidiary / ContentView.swift
Created Apr 23, 2022
2021 SwiftUI Tutorial for Beginners (3.5 hour Masterclass)
View ContentView.swift
//
// ContentView.swift
// war-challenge
//
// Created by Koichiro Mori on 2022/04/20.
//
import SwiftUI
struct ContentView: View {
@aidiary
aidiary / books.py
Created Nov 24, 2021
ISBNから書籍タイトルを取得する
View books.py
import json
import requests
url = 'https://www.googleapis.com/books/v1/volumes?q=isbn:'
with open('list.txt', 'r') as f:
for line in f.readlines():
isbn = line.rstrip()
res = requests.get(url + isbn, headers={"content-type": "application/json"}).json()
@aidiary
aidiary / passthrough_ringbuffer.py
Created Nov 8, 2021
リングバッファを用いたパススルー再生
View passthrough_ringbuffer.py
import numpy as np
import sounddevice as sd
import soundfile as sf
from ring_buffer import InputRingBuffer
input_device = 'Yeti Stereo Microphone'
output_device = 'MacbookProのスピーカー'
fft_size = 1024
@aidiary
aidiary / App.js
Last active Nov 25, 2021
[React] サーバからasync/awaitでデータをfetchする例
View App.js
import React, { useCallback, useEffect, useState } from 'react';
import './App.css';
import MoviesList from './components/MoviesList';
function App() {
const [movies, setMovies] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
const fetchMovieHandler = useCallback(async () => {
@aidiary
aidiary / App.js
Last active Nov 6, 2021
[React] サーバAPIからデータをfetchする
View App.js
import React, { useState } from 'react';
import './App.css';
import MoviesList from './components/MoviesList';
function App() {
const [movies, setMovies] = useState([]);
function fetchMovieHandler() {
fetch('https://swapi.dev/api/films/')
.then((response) => {
@aidiary
aidiary / UserFinder.js
Created Nov 3, 2021
[React] テキストボックスに入力して絞り込む機能
View UserFinder.js
import { Fragment, useEffect, useState } from 'react';
import classes from './UserFinder.module.css';
import Users from './Users';
const DUMMY_USERS = [
{ id: 'u1', name: 'Max' },
{ id: 'u2', name: 'Manuel' },
{ id: 'u3', name: 'Julie' },
];
@aidiary
aidiary / tutorial1.py
Last active Nov 1, 2021
asyncioのサンプルプログラム
View tutorial1.py
import asyncio
async def main():
print('tim')
# タスクを作成
task = asyncio.create_task(foo('text'))
# 別のタスクに処理を譲る => fooが動き出す
await asyncio.sleep(0.5)
print('finished')
@aidiary
aidiary / fft_overlap_add.py
Last active Nov 1, 2021
Phase Vocoderのサンプル1
View fft_overlap_add.py
import numpy as np
import sounddevice as sd
import soundfile as sf
sd.default.device = 'MacBook Proのスピーカー'
filename = '../slow-drum-loop.wav'
# filename = '../DIALOG_001_01.wav'
data, fs = sf.read(filename)
data = data[:, 0] # stereo -> mono
@aidiary
aidiary / realtime_sinewave.py
Created Oct 26, 2021
sounddeviceでリアルタイムにサイン波を出力
View realtime_sinewave.py
import numpy as np
import sounddevice as sd
samplerate = 44100
frequency = 440.0
amplitude = 0.6
sd.default.samplerate = samplerate
sd.default.device = 'MacBook Proのスピーカー'