Skip to content

Instantly share code, notes, and snippets.

@mecab
mecab / osc52e.el
Last active December 20, 2023 14:10 — forked from AlexCharlton/osc52e.el
Copy text from emacs into xterm, hterm, trough screen and tmux, with support for graphical displays and multi-byte characters
;;;; This script can be loaded during emacs initialization to automatically
;;;; send `kill-region' and `kill-ring-save' regions to your system clipboard.
;;;; The OSC 52 terminal escape sequence is used to transfer the selection from
;;;; emacs to the host terminal.
;;;; It is based off of the osc52.el copyright the Chromium OS authors, but
;;;; was modified to add support for tmux, graphical displays, and
;;;; multi-byte strings.
;;;; It works in hterm, xterm, and other terminal emulators which support the
@mecab
mecab / background.ts
Last active May 26, 2022 17:18
executeScript polyfill PoC that supports both of Chrome and Firefox (manifest v3 and v2)
type AnyFunc = (...args: any[]) => any;
function wrapFuncToCode<T extends () => any>(func: T): string;
function wrapFuncToCode<T extends AnyFunc>(func: T, args: Parameters<T>): string;
function wrapFuncToCode<T extends AnyFunc>(func: T, args: any[] = []): string
{
return `(${func.toString()}).apply(this, ${JSON.stringify(args)})`;
}
async function executeScript<T extends () => any>(tabId: number, injection: { func: T }): Promise<ReturnType<T>>;
window.addEventListener('message', function(e) {
const data = e.data || {};
if (data.type !== 'item')
return;
const message = data.message || {};
const obj = { detail: { command: message.command, body: message.body, from: message.from }};
const synth = window.speechSynthesis;
if (obj.detail.command === 'PRIVMSG') {
var utter = new SpeechSynthesisUtterance(obj.detail.body);
const API_KEY = 'ここにAPIキーを貼る';
const url = `https://api.apigw.smt.docomo.ne.jp/aiTalk/v1/textToSpeech?APIKEY=${API_KEY}`;
document.addEventListener('onEventReceived', async function(obj) {
if (obj.detail.command == 'PRIVMSG') {
play(obj.detail.body, 'maki');
}
});
async function play(text, who) {
#!/usr/bin/env node
// Needs `npm install yargs connect request superstatic firebase-tools` as prerequisites.
const stream = require('stream');
const yargs = require('yargs');
const connect = require('connect');
const request = require('request');
const superstatic = require('superstatic');
@mecab
mecab / chia-wrapper.sh
Last active May 9, 2021 04:46
Chia utility script to copy the finished plot to the destination directory by rsync in background. Remove original plot after verifying the destination file size.
#!/bin/bash
set -e
atexit() {
[[ -n ${temp_file1-} ]] && rm -f "$temp_file1"
[[ -n ${temp_file2-} ]] && rm -f "$temp_file2"
}
trap atexit EXIT
trap 'rc=$?; trap - EXIT; atexit; exit $?' INT PIPE TERM
@mecab
mecab / .eslintrc.js
Created April 23, 2020 14:56
.eslintrc.js
module.exports = {
'extends': [
'plugin:@typescript-eslint/recommended'
],
'plugins': ['@typescript-eslint'],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
},
@mecab
mecab / change-font-size.el
Created August 5, 2019 09:31
Emacs lisp interactive function to change font size in GUI easily.
(defun change-font-size (size)
"Change font size (clearly `:height` in `face-attribute`) to given SIZE."
(interactive
(list
(read-number
(format "Input font size (current=%d): " (face-attribute 'default :height))
nil)))
(set-face-attribute 'default nil :height size)
#!/bin/bash
set -e
# PROJECT_FROM="firebase-project-from"
# PROJECT_TO="firebase-project-to"
function getParam() {
echo $(cat .hashParameter | grep ${1}: | sed 's/.*: \(.*\),/\1/')
}

Keybase proof

I hereby claim:

  • I am mecab on github.
  • I am mecab (https://keybase.io/mecab) on keybase.
  • I have a public key ASAdthX1dzIg-LfZ57mQTBw9Ej1x0jvebfuntkBt7qe6Xgo

To claim this, I am signing this object: