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 inspect import signature | |
from typing import Callable | |
import datetime | |
def print_time(text="this is"): | |
print(text, datetime.datetime.now()) | |
def print_time_with_self(self, text="this is"): |
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 bpy | |
from mathutils import Vector | |
# 球を作成 | |
bpy.ops.mesh.primitive_uv_sphere_add(location=(0, 0, 0)) | |
# 球オブジェクトを取得 | |
sphere = bpy.context.active_object | |
# 移動先の座標を定義 |
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 numpy as np | |
import matplotlib.pyplot as plt | |
def fftTest(): | |
x = np.linspace(0, 2 * np.pi, 100) | |
f = -0.1 + np.sin(x) - np.cos(2 * x) # 元関数 | |
F = np.fft.rfft(f) # 実数離散FFT | |
for i, Fi in enumerate(F): # FFT結果の複素数を表示 | |
print(i, "{:2.2f}".format(Fi)) |
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 numpy as np | |
import matplotlib.pyplot as plt | |
def generate(a, b, c, n=1000): | |
print("傾き {}, 切片 {}, 誤差標準偏差 {}".format(a, b, c)) | |
x = np.arange(n) | |
y = a * x + b + c * np.random.normal(size=n) | |
return x, y |
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 glob | |
import os | |
const_filename_out = "out.mp4" | |
const_filename_list = "mylist.txt" | |
def print_mylist(): | |
with open(const_filename_list, "wt") as flist: | |
for f in [flist, None]: |
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
// 参考 | |
// https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/esp32/include/driver/include/driver/i2s.h | |
#include <driver/i2s.h> | |
static const int sample_rate=44100; | |
static const i2s_port_t i2s_num = I2S_NUM_0 ; // i2s port number | |
static const int wave_hz = 441; // 100hzは男性の声に近い周波数 | |
static const int sample_per_cycle=sample_rate/wave_hz; | |
static const int max_volume=15000; | |
uint16_t samples_data[sample_per_cycle]; |
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
int main(void){ | |
const char mes[] = "hello, world\n\0"; | |
asm volatile( | |
"movq %0, %%rsi \n\t movq %1, %%rdx \n\t movq $1, %%rax \n\t movq $1, %%rdi \n\t syscall" | |
: | |
:"r"(mes),"r"(sizeof(mes)) | |
: | |
); | |
} |
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
<!DOCTYPE html> | |
<html lang="jp"> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="480" | |
height="480"> | |
<filter id="myFilter"> | |
<feGaussianBlur stdDeviation="5"> |
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
package main | |
import ( | |
"golang.org/x/image/draw" | |
"golang.org/x/image/font" | |
"golang.org/x/image/font/opentype" | |
"golang.org/x/image/math/fixed" | |
"image" | |
"image/color" | |
"image/jpeg" |
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
package main | |
import ( | |
"fmt" | |
"golang.org/x/image/font" | |
"golang.org/x/image/font/opentype" | |
"golang.org/x/image/math/fixed" | |
"image" | |
"image/color" | |
"image/png" |