Software Abstractions の邦訳、抽象によるソフトウェア設計を読み始めた。 Part 2
適切な抽象は要だ。良い抽象は、柔軟さと理解しやすさを保つ。
| ; maps layout JIS -> Sun Type3 | |
| ; https://autohotkey.com/download/ahk-install.exe | |
| ; The keyboard hook monitors keystrokes for the purpose of activating hotstrings | |
| ; and any keyboard hotkeys not supported by RegisterHotkey | |
| ; (which is a function built into the operating system). | |
| ; It also supports a few other features such as the Input command. | |
| #UseHook | |
| sc03a:: |
| myTrue = (x, y) => x; | |
| myFalse = (x, y) => y; | |
| ifThen = (cond, whenTrue, whenFalse) => cond(whenTrue, whenFalse); | |
| ifThen(myTrue, 1, 2); | |
| ifThen(myFalse, 1, 2); | |
| cons = (elm, rest) => (c) => c(elm, rest); | |
| head = (lst) => lst(myTrue); | |
| tail = (lst) => lst(myFalse); | |
| mempty = (f) => myTrue; |
| import cv2, matplotlib | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| bgr_img = cv2.imread('images/landscape.jpg') | |
| img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2HSV) | |
| blue_min = np.array([100, 0, 0], np.uint8) | |
| blue_max = np.array([140, 255, 255], np.uint8) | |
| wh_min = np.array([0, 0, 180], np.uint8) | |
| wh_max = np.array([180, 60, 255], np.uint8) |
| ffmpeg -i audio.m4a -filter 'silenceremove=0:0:0:-1:3:-90dB' tmp.m4a |
| #include <stdio.h> | |
| #include <stdbool.h> | |
| typedef int (*Operator)(int a, int b); | |
| int add(int a, int b) { | |
| return(a + b); | |
| } | |
| int mult(int a, int b) { |
Software Abstractions の邦訳、抽象によるソフトウェア設計を読み始めた。 Part 2
適切な抽象は要だ。良い抽象は、柔軟さと理解しやすさを保つ。
| require 'rubygems' | |
| require 'bundler' | |
| Bundler.require | |
| require 'open-uri' | |
| aozora_uri = 'http://www.aozora.gr.jp/cards/000148/files/789_14547.html' | |
| file = 'sample.txt' | |
| unless File.exist?(file) | |
| html = open(aozora_uri, 'r:Shift_JIS').read.encode('utf-8', universal_newline: true) | |
| text = Oga.parse_html(html).css('.main_text').text.gsub(/(.*?)/, '') |
| variable "db_username" {} | |
| variable "db_password" {} | |
| variable "aws_key_name" {} | |
| provider "aws" { | |
| region = "ap-northeast-1" | |
| shared_credentials_file = "$HOME/.aws/credentials" | |
| profile = "default" | |
| } |
| [ | |
| "audioend", | |
| "audiostart", | |
| "end", | |
| "error", | |
| "nomatch", | |
| "result", | |
| "soundend", | |
| "soundstart", | |
| "speechend", |
| #!/bin/bash -eu | |
| # Dependencies: | |
| # npm install -g svg-term-cli | |
| # pip3 install asciinema | |
| cast_filename=$(mktemp -u) | |
| asciinema rec ${cast_filename} | |
| out_filename=$(mktemp -u) | |
| svg-term --in ${cast_filename} --out ${out_filename}.svg |