Skip to content

Instantly share code, notes, and snippets.

View ishikawa's full-sized avatar
🏠
Working from home

Takanori Ishikawa ishikawa

🏠
Working from home
View GitHub Profile
@ishikawa
ishikawa / openai-realtime-api-chat.py
Created October 6, 2024 05:01
A tiny chat client with OpenAI Realtime API
# LICENSE: MIT
# Copyright (c) 2024 Takanori Ishikawa
import asyncio
import base64
import json
import os
import sys
from pprint import pprint
from typing import Annotated, Any, Literal, Optional, Union
import json
import os
from pprint import pprint
from typing import Any
import websocket
from dotenv import load_dotenv
from websocket import WebSocket
load_dotenv()
@ishikawa
ishikawa / gist:47af9f5dd4040cd33bcdbace7c97f5b3
Last active November 20, 2022 08:29
Profiling whisper with English audio file (2.1 mb) / large model / cpu
Sun Nov 20 14:40:09 2022 whisper.prof
5912402 function calls (5549784 primitive calls) in 709.208 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1983/1 0.038 0.000 709.211 709.211 {built-in method builtins.exec}
1 0.086 0.086 709.195 709.195 prof_whisper.py:1(<module>)
1 0.024 0.024 673.748 673.748 transcribe.py:19(transcribe)
@ishikawa
ishikawa / solve.py
Created July 17, 2021 22:40
"The Art and Craft of Problem Solving" 1.1.3
combinations = set()
for x in range(1, 37):
for y in range(1, 37):
for z in range(1, 37):
if x * y * z == 36:
sisters = [x, y, z]
sisters.sort(reverse=True)
sisters = tuple(sisters)
if sisters not in combinations:
@ishikawa
ishikawa / enum_str.rs
Created July 17, 2021 22:39
Rust: Converting between Enums and Strings
pub enum Foo {
A,
B,
}
impl Foo {
pub fn variants() -> impl Iterator<Item = Foo> {
array::IntoIter::new([Self::A, Self::B])
}
}
@ishikawa
ishikawa / index.ts
Created January 29, 2021 00:53
The node implementation for expo-crypto
/*
MIT License
Copyright (c) 2021 Takanori Ishikawa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@ishikawa
ishikawa / index.ts
Created January 29, 2021 00:39
The node implementation for expo-random
/*
MIT License
Copyright (c) 2021 Takanori Ishikawa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
print('Hello, World!')
@ishikawa
ishikawa / map_helpers.ex
Last active July 27, 2020 12:48
submap?/3 for Elixir's map. It's useful for testing API response (see submap_usage_test.exs).
defmodule MapHelpers do
@doc """
Checks if `map1`'s entries are all contained in `map2`.
## Options
- `:recursive` - Recursively checks if a value is map (Default: `false`)
## Examples
@ishikawa
ishikawa / gist:3f340f1274b3eb384156355665559ed7
Created June 25, 2020 02:02
Login with the shell into the first matching pod returned from kubectl get pod
kubectl get pod | awk '{ print $1 }' | grep '^gateway-' | head -1 | xargs -o -I {} kubectl exec -it {} -- /bin/bash