This file contains hidden or 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
# %% | |
def morse2Dot(in_filename, out_filename): | |
ROOT_LABEL = '(start)' | |
ROOT_CODE = 'START' | |
DUMMY = 'dummy' | |
DOT_SHAPE = 'shape=circle' | |
BAR_SHAPE = 'shape=rectangle' | |
ROOT_SHAPE = 'shape=diamond' | |
PROP_LINES = '\n\trankdir=TB;\n\tnodesep=0.5;\n\tpad=0.2;' | |
DUMMY_NODE_ATTR = ', label="(N/A)", margin=0' |
This file contains hidden or 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
def morse2Dot(fin, fout): | |
class m: | |
def __init__(self, l, c): | |
self.c, self.n, self.cms, self.eA, self.nL, self.l, self.p = c, c.count('.'), [], DOT_eA if c[-1] == '.' else '', f'"{NA+c if l == NA else l}" [shape={SC if c[-1] == "." else SR}{NA_nA if l == NA else ""}];', f'{NA}{c}' if l == NA else l, RC if len(c) == 1 else c[0:-1] | |
def eLines(n): | |
ret = [f'"{n.l}" -> "{c.l}"[penwidth=2{c.eA}];' for c in n.cms] | |
ret.extend([l for c in n.cms for l in eLines(c)]) | |
return ret | |
RL, RC, NA, SC, SR, NA_nA, DOT_eA, L1 = '(start)', 'START', 'DUMMY', 'circle', 'rectangle', ',label="(N/A)", margin=0', ', weight=1000, style=dashed', '{rank=same;' | |
L0, ms = f'rankdir=TB;msep=0.5;pad=0.2;"{RL}" [shape=diamond];', {RC: m(RL, RC)} |
This file contains hidden or 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
# %% | |
def read_morse_file(filename): | |
"""モールス信号データをファイルから読み込む""" | |
morse_data = {} | |
with open(filename, 'r', encoding='utf-8') as f: | |
for line in f: | |
char, code = line.strip().split('\t') | |
morse_data[char] = code | |
return morse_data |
This file contains hidden or 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
digraph MorseTree { | |
rankdir=TB; | |
bgcolor="white"; | |
nodesep=0.5; // 左右間隔を維持 | |
pad=0.2; // 余白を維持 | |
// ノード定義 | |
START [shape=rectangle]; | |
E [shape=rectangle]; A [shape=rectangle]; W [shape=rectangle]; J [shape=rectangle]; | |
I [shape=rectangle]; S [shape=rectangle]; H [shape=rectangle]; V [shape=rectangle]; |
This file contains hidden or 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 | |
import numpy as np | |
def modified_sin(frames, target_fs, delta, amp, freq, shift, fn): | |
hold_fs = [f for fs in [list(range(v-delta, v+delta)) for v in target_fs] for f in fs] | |
cycle = frames - len(hold_fs) | |
ny = [amp*fn(freq*2*np.pi/cycle*t)-shift for t in range(cycle)] | |
result = [] |
This file contains hidden or 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
<script type="module"> | |
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs'; | |
mermaid.initialize({ startOnLoad: true }); | |
</script> | |
<div class="mermaid"> | |
flowchart TB | |
A[Start] --> B{Is it?} | |
B -->|Yes| C[OK] | |
B -->|No| D[Not OK] | |
</div> |
This file contains hidden or 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
[[NSWorkspace sharedWorkspace] openURLs:@[url] | |
withApplicationAtURL:[NSURL fileURLWithPath:@"/Applications/Safari.app"] | |
configuration:nil | |
completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) { | |
[app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; | |
}]; |
This file contains hidden or 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
# %% | |
colors <- rainbow(length(1:5)) | |
bezier_poly <- function(a, b, c, d, t) { | |
return((1 - t)^3 * a | |
+ 3 * (1 - t)^2 * t * b | |
+ 3 * (1 - t) * t^2 * c | |
+ t^3 * d) | |
} | |
bezier_point <- function(ps, t) { | |
x <- bezier_poly(ps[1, 1], ps[2, 1], ps[3, 1], ps[4, 1], t) |
This file contains hidden or 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 <Cocoa/Cocoa.h> | |
@interface AppDelegate : NSObject <NSApplicationDelegate> | |
@end |
This file contains hidden or 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
# %% | |
# reference https://qiita.com/hibit/items/5a49bedaa826fddf0a33 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots() | |
ax.set(aspect=1) | |
theta = np.linspace(0, 2*np.pi, 100) | |
colorlist = ["r", "g", "b", "c", "m", "y"] |
NewerOlder