Skip to content

Instantly share code, notes, and snippets.

View masuidrive's full-sized avatar

Yuichiro MASUI masuidrive

View GitHub Profile
@masuidrive
masuidrive / opus_raw_to_ogg.c
Last active January 11, 2024 14:02
opusをoggコンテナに入れるためのコード
#include <ogg/ogg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
// get_opus_raw関数のプロトタイプ
// この関数は外部で定義され、Opusエンコードされたraw binaryを提供します。
int16_t get_opus_raw(uint8_t *buffer);
@masuidrive
masuidrive / DelegateEnabledScrollView.swift
Last active January 1, 2024 16:43
DelegateEnabledScrollView with iOS 17 or lower.
import SwiftUI
@_spi(Advanced) import SwiftUIIntrospect
struct DelegateEnabledScrollView<Content: View>: View {
@State private var scrollViewDelegate: DelegateEnabledScrollViewDelegate?
@State private var scrollView: UIScrollView? = nil
let content: (UIScrollView?) -> Content
var onDidZoom: ((UIScrollView) -> Void)?
var onWillBeginDragging: ((UIScrollView) -> Void)?
@masuidrive
masuidrive / opencalm-7b-lora-train.ipynb
Created May 25, 2023 08:21
OpenCALM-7B-LoRA-train.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*
https://github.com/karpathy/llama2.c/blob/master/run.c
GPT-4による解説
このプログラムは、Transformerネットワークを実装し、トークン化されたテキスト入力から次の最も適したトークンを予測します。具体的には以下のようになります:
先頭の部分は、TransformerWeightsとRunStateという2つのデータ構造とそれらの関連するメモリの管理を含みます。
Configという構造体は、トランスフォーマーネットワークのパラメータを保持します。
次に、指定されたチェックポイントファイルから重みを初期化する関数があります。この関数は、チェックポイントファイルからトランスフォーマーネットワークの重みを読み込み、適切に配置します。
@masuidrive
masuidrive / opencalm-7b-lora-inference.ipynb
Last active June 6, 2023 13:44
opencalm-7b-lora-inference.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@masuidrive
masuidrive / main.js
Last active May 5, 2023 17:54
Google SpreadsheetからBigQueryを呼び出すスクリプト
/**
* Google Spreadsheet向けBigQuery取り込みスクリプト
* http://toreta.blog.jp/archives/20649904.html
* License: MIT 2014- Toreta, Inc.
*
* runAllQueries() をトリガーで毎日実行してください
* Queries, Single row queries, Dataの三つのシートを作って下さい
* Queries, Single row queriesのシートには実行するクエリを書きます
* A列にクエリ名、B列にクエリです。
* conuntなどの集約関数で1行しか返らないクエリは「Single row queries」、それ以外は「Queries」に書いて下さい
@masuidrive
masuidrive / gist:5231110
Created March 24, 2013 08:45
clang options
OVERVIEW: LLVM 'Clang' Compiler: http://clang.llvm.org
USAGE: clang -cc1 [options] <inputs>
OPTIONS:
-### Print the commands to run for this compilation
--analyze Run the static analyzer
--migrate Run the migrator
--relocatable-pch Build a relocatable precompiled header
--serialize-diagnostics <value>
@masuidrive
masuidrive / docker_rails.sh
Last active November 15, 2022 06:02
Docker ComposeでRails環境作成 mkdir -p railsapp && cd railsapp && curl -L http://bit.ly/rails6-docker | sh
#!/usr/bin/env bash
rails_version="${RAILS_VERSION:-7}"
ruby_version="${RUBY_VERSION:-3.0}"
node_version="${NODE_VERSION:-16}"
docker run --rm -v `pwd`:/usr/src/app ruby:$ruby_version sh -c "gem install rails --version $rails_version && rails new /usr/src/app --database mysql ${RAILS_OPTIONS} --git --force --version $rails_version"
cat << __EOT__ > Dockerfile
FROM ruby:$ruby_version
@masuidrive
masuidrive / gist:408e1991912f5166bbecef0860b68a9c
Created June 25, 2022 14:51
Arduino audio-tools settings for M5Stack Core2
// https://github.com/pschatzmann/arduino-audio-tools/ settings for M5Stack Core2
// Audio settings
const int sample_rate = 44100;
const int channels = 1;
// Speaker settings
I2SStream out;
auto config = out.defaultConfig(TX_MODE);
config.sample_rate = sample_rate;
@masuidrive
masuidrive / Install-FreeRTOS-dev-env-on-m1-mac.sh
Created April 29, 2021 15:07
M1 Mac環境でAmazon FreeRTOS on ESP32のビルドを行う
#/bin/sh
# M1 Mac環境でAmazon FreeRTOS on ESP32のビルドを行う
# FreeRTOSのソースはAWSコンソールのzipから落とさないで、
# https://github.com/aws/amazon-freertos から持ってくること
# 参考:
# https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html#setup-espressif-idf42
# https://github.com/SeanMollet/esp-idf/tree/esp-2020r3-aarch64
#
# ビルドは下記のコマンドで
# idf.py -DVENDOR=espressif -DBOARD=esp32_wrover_kit -DCOMPILER=xtensa-esp32 build