This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const OpenAI = require('openai') | |
// APIキーを設定する(以下は書き換えが必要です★★★) --- (*1) | |
const API_KEY = 'xxx' | |
// APIキーを設定したオブジェクトを生成 | |
const openai = new OpenAI({ | |
apiKey: (API_KEY === 'xxx') ? process.env['OPENAI_API_KEY'] : API_KEY | |
}); | |
// ChatGPT APIを呼び出す --- (*2) | |
async function callChatgpt(msg) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// メイン関数 --- (*1) | |
fn main() { | |
// コマンドライン引数が足りない場合は使い方を表示 --- (*2) | |
if std::env::args().len() < 2 { | |
println!("[Usage] markown [input.md]"); | |
return; | |
} | |
// コマンドライン引数からファイル名を取得する --- (*3) | |
let filename = std::env::args().nth(1).unwrap(); | |
// ファイルを読み込む --- (*4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rand; | |
use rand::seq::SliceRandom; | |
use rand::thread_rng; | |
use std::io::{stdout, Result}; | |
use crossterm::{ | |
cursor, execute, ExecutableCommand, terminal, | |
style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor}, | |
event::{read, Event, KeyCode}, | |
}; | |
#[derive(Clone, Copy, PartialEq, Eq)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from PIL.ExifTags import TAGS | |
from reportlab.lib.pagesizes import A4, landscape, portrait | |
from reportlab.pdfgen import canvas | |
import tempfile, os | |
# フォルダ内のJPEGファイルを列挙 --- (*1) | |
image_folder = 'pdf-in' | |
output_pdf = 'images.pdf' | |
image_files = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imageio, glob, os | |
from PIL import Image | |
import numpy as np | |
# ロゴファイルや入出力フォルダを指定 --- (*1) | |
LOGO_FILE = './logo.png' # ロゴ | |
INPUT_DIR = './in_dir' # 入力フォルダ | |
OUTPUT_DIR = './out_dir' # 出力フォルダ | |
# 背景透過したロゴを読み込む --- (*2) | |
logo = Image.open(LOGO_FILE) | |
logo = logo.convert("RGBA") # RGBAモードに変換 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
商品コード | 商品名 | 数量 | |
---|---|---|---|
DA-3567 | --- | 1 | |
PP-0987 | --- | 1 | |
JJ-9876 | --- | 1 | |
UU-9876 | --- | 3 | |
NI-46-478D | --- | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ cargo add rustysynth@1.2.0 | |
// $ cargo add tinyaudio@0.1.1 | |
use rustysynth::{SynthesizerSettings, Synthesizer, SoundFont, MidiFile, MidiFileSequencer}; | |
use tinyaudio::prelude::*; | |
// 定数の指定 --- (*1) | |
const FILE_SOUNDFONT: &str = "TimGM6mb.sf2"; // サウンドフォントのパス | |
const FILE_MIDI: &str = "sakura2.mid"; // 入力MIDIファイルのパス | |
const SAMPLE_RATE: usize = 44_100; // サンプリング周波数(CD音質) | |
fn main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// cargo add rustysynth | |
// cargo add wav_io | |
use rustysynth::{SynthesizerSettings, Synthesizer, SoundFont, MidiFile, MidiFileSequencer}; | |
use wav_io; | |
// 定数の指定 --- (*1) | |
const FILE_SOUNDFONT: &str = "TimGM6mb.sf2"; // サウンドフォントのパス | |
const FILE_MIDI: &str = "sakura2.mid"; // 入力MIDIファイルのパス | |
const FILE_WAV: &str = "sakura2.wav"; // 出力WAVファイルのパス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
use std::sync::Arc; | |
use rustysynth::{SynthesizerSettings, Synthesizer, SoundFont}; | |
use wav_io; | |
fn main() { | |
// サンプリング周波数(CD音質)を指定 --- (*1) | |
const SAMPLE_RATE: u32 = 44_100; | |
const SAMPLE_LEN: usize = (SAMPLE_RATE * 2) as usize; // 2秒分のデータ | |
// データの書き込み先を準備 --- (*2) | |
let mut samples:Vec<f32> = vec![]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
file: Cargo.tml | |
[dependencies] | |
rustysynth = "1.2.0" | |
tinyaudio = "0.1.1" | |
*/ | |
use rustysynth::{SoundFont, Synthesizer, SynthesizerSettings}; | |
use std::fs::File; | |
use std::sync::Arc; |