Skip to content

Instantly share code, notes, and snippets.

View woxtu's full-sized avatar

woxtu

View GitHub Profile
@woxtu
woxtu / gist:7bff7d1338fa9ca3ec5744569e4262f8
Created November 3, 2023 11:33
async UIImageWriteToSavedPhotosAlbum(_:_:_:_:)
private final class UIImageWriteToSavedPhotosAlbumCompletion: NSObject {
var continuation: CheckedContinuation<Void, any Error>?
@objc func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error {
continuation?.resume(throwing: error)
} else {
continuation?.resume()
}
continuation = nil
@woxtu
woxtu / ocr.js
Last active February 29, 2024 16:29 — forked from doraTeX/ocr.sh
A JavaScript (JXA) to perform OCR on images/PDFs using macOS built-in OCR engine
#!/usr/bin/osascript -l JavaScript
ObjC.import("stdlib");
ObjC.import("AppKit");
ObjC.import("PDFKit");
ObjC.import("Vision");
const scriptName = $.NSProcessInfo.processInfo.arguments.objectAtIndex(3).lastPathComponent.js;
console.error = (obj) => {
@woxtu
woxtu / main.js
Last active January 26, 2023 21:07
Twitter インプレッション アクセスカウンター
const id = "kiriban-fuminige-kinshi";
const conversions = [
{ unit: "K", rate: 1000 },
{ unit: "M", rate: 1000000 },
{ unit: "B", rate: 1000000000 },
{ unit: "万", rate: 10000 },
];
function run(target) {
@woxtu
woxtu / eslint.config.js
Created September 9, 2022 15:28
ESLint with flat config + Prettier + TypeScript
// Install the following packages:
// - @eslint/eslintrc
// - @typescript-eslint/eslint-plugin
// - eslint-config-prettier
import { FlatCompat } from "@eslint/eslintrc";
import prettierConfig from "eslint-config-prettier";
const compat = new FlatCompat();
@woxtu
woxtu / gist:6b214ea9cef53e246beb9fc31c5295fe
Last active October 9, 2022 14:38
Qiitadon 新着 読み上げ ブックマークレット
(() => {
ws = new WebSocket("wss://streaming.qiitadon.com:4000/api/v1/streaming/?stream=public:local");
ws.addEventListener("message", (ev) => {
const { event, payload } = JSON.parse(ev.data);
if (event === "update") {
const status = JSON.parse(payload);
speechSynthesis.cancel();
speechSynthesis.speak(new SpeechSynthesisUtterance(status.account.display_name || status.account.username));
speechSynthesis.speak(new SpeechSynthesisUtterance(status.content.replace(/<\/?[^>]+(>|$)/g, "")));
}
@woxtu
woxtu / background.js
Last active December 30, 2020 08:02
Qiitadon 新着 通知
const ws = new WebSocket("wss://streaming.qiitadon.com:4000/api/v1/streaming/?stream=public:local");
ws.addEventListener("message", (ev) => {
const { event, payload } = JSON.parse(ev.data);
if (event == "update") {
const status = JSON.parse(payload);
chrome.notifications.create(status.id, {
type: "basic",
iconUrl: status.account.avatar || status.account.avatar_static || "icon.png",
@woxtu
woxtu / deps.edn
Last active July 13, 2020 12:26
Object detection in Clojure using Deep Java Library
{:deps
{ai.djl/api {:mvn/version "0.4.1"}
ai.djl.mxnet/mxnet-model-zoo {:mvn/version "0.4.1"}
ai.djl.mxnet/mxnet-native-auto {:mvn/version "1.6.0"}
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.13.0"}}}
@woxtu
woxtu / gist:af71481beeace4995f95c6ef0f2166ef
Created September 26, 2019 04:47
Vue starter with 8 lines html
<div id=root />
<script type="module">
import Vue from 'https://dev.jspm.io/vue@2.6.10'
new Vue({
el: '#root',
render: (h) => h('h1', null, 'hello'),
})
</script>
@woxtu
woxtu / bsconfig.json
Last active April 3, 2017 17:42
Conway's Game of Life in Facebook/Reason
{
"name": "lifegame",
"sources": [
"./"
]
}
@woxtu
woxtu / Cargo.toml
Last active July 10, 2021 03:35
Write bash builtin command in Rust
[package]
name = "hello_world"
version = "0.1.0"
authors = []
[lib]
name = "hello_world"
path = "./lib.rs"
crate-type = ["cdylib"]