$ system_profiler SPHardwareDataType|grep "Chip\|Memory"
Chip: Apple M1
Memory: 16 GB
$ brew install ollama
| # %% | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from matplotlib.collections import PolyCollection | |
| from sklearn.decomposition import PCA | |
| from scipy.spatial import Voronoi | |
| from scipy.spatial import ConvexHull | |
| import colorsys | |
| // clang -fobjc-arc -framework Foundation lockfile.m -o lockfile | |
| #import <Foundation/Foundation.h> | |
| int main(int argc, const char * argv[]) { | |
| @autoreleasepool { | |
| // ロックファイルのパス | |
| NSString *lockFilePath = @"/tmp/lockfile"; | |
| // NSFileManagerのインスタンス | |
| NSFileManager *fileManager = [NSFileManager defaultManager]; |
| # %% | |
| 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' |
| 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)} |
| # %% | |
| 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 |
| 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]; |
| # %% | |
| 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 = [] |
| <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> |
| [[NSWorkspace sharedWorkspace] openURLs:@[url] | |
| withApplicationAtURL:[NSURL fileURLWithPath:@"/Applications/Safari.app"] | |
| configuration:nil | |
| completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) { | |
| [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; | |
| }]; |