Skip to content

Instantly share code, notes, and snippets.

View yoshinari-nomura's full-sized avatar

Yoshinari Nomura yoshinari-nomura

View GitHub Profile
@yoshinari-nomura
yoshinari-nomura / adjust-akizukidenshi-url.el
Created January 26, 2024 06:05
秋月電子の URL 変更に追従するための browse-url 用 advice
;; 秋月電子の URL 変更に追従する browse-url
;; browse-url-at-point 等も browse-url を使っている
;;
;; Old: https://akizukidenshi.com/catalog/g/gI-04575/
;; New: https://akizukidenshi.com/catalog/g/g104575/
;; → Replace "M-" to "1"
;;
(defun adjust-akizukidenshi-url (url)
(if (string-match "https://akizukidenshi[.]com/catalog/g/g\\(.-\\)[0-9]+/" url)
(replace-match "1" nil t url 1)
@yoshinari-nomura
yoshinari-nomura / oauth2.el.diff
Created April 11, 2023 03:25
Dirty hack to make oauth2.el work with OOB-disabled providers
--- oauth2.el.orig 2022-12-21 05:13:00.000000000 +0900
+++ oauth2.el 2023-04-11 11:40:27.494107486 +0900
@@ -61,7 +61,7 @@
(if (string-match-p "\?" auth-url) "&" "?")
"client_id=" (url-hexify-string client-id)
"&response_type=code"
- "&redirect_uri=" (url-hexify-string (or redirect-uri "urn:ietf:wg:oauth:2.0:oob"))
+ "&redirect_uri=" (url-hexify-string (or redirect-uri "http://localhost:1/"))
(if scope (concat "&scope=" (url-hexify-string scope)) "")
(if state (concat "&state=" (url-hexify-string state)) "")))
sudo apt-get update
sudo apt-get upgrade
mkdir -p $HOME/var/log
alias mark='apt-mark showmanual > $HOME/var/log/apt-mark-showmanual-$(hostname --short)-$(date +%Y%m%d-%H%M%S).log; gsettings list-recursively > $HOME/var/log/gsettings-list-recursively-$(hostname --short)-$(date +%Y%m%d-%H%M%S).log'
mark
// Copyright (C) 2022 Takashi Kokubun
// Licence: GPLv2+
const { Gio } = imports.gi;
class Xremap {
constructor() {
}
enable() {
@yoshinari-nomura
yoshinari-nomura / mew-xoauth2.el
Created November 21, 2020 18:48
Mew to support IMAP XOAUTH2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mew XOAUTH2
;;
;; * Setup
;;
;; 1) Install oauth2.el and GnuPG
;;
;; 2) In your .emacs:
;;
;; (with-eval-after-load 'mew
@yoshinari-nomura
yoshinari-nomura / index.html
Last active October 31, 2020 03:07
Infinite loop in JavaScript event handler
<html>
<canvas id="canvas" width="300" height="300"></canvas>
<script>
let canvas = document.getElementById('canvas');
let ctx = canvas.getContext('2d');
ctx.strokeRect(0, 0, 300, 300);
canvas.addEventListener('click', ev => handle_click(ev));
@yoshinari-nomura
yoshinari-nomura / gmail-grabber.el
Last active February 5, 2020 07:34
Fetch Gmail article showed in web browser into local folder
;;; gmail-grabber.el --- Fetch Gmail article showed in web browser into local folder
;; Description: Fetch Gmail article showed in web browser into local folder
;; Author: Yoshinari Nomura <nom@quickhack.net>
;; Created: 2020-01-30
;; Version: 0.1.1
;; Keywords: Mew Gmail
;; URL:
;; Package-Requires:
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
# Please add INDEX to speedup the SQL queries which use LIKE clauses:
#
# sqlite3 "#{DICT_FILE}" 'CREATE INDEX dict_key ON dict (key COLLATE NOCASE);'
SQLITE = "sqlite3"
DICT_FILE = "'#{ENV['HOME']}/foo/bar/mouseoverdictionary.sqlite'"
(require 'popup)
(require 'stem)
(defun dic-find-first (word-list lookup-func)
(let ((result))
(catch 'ret
(while (car word-list)
(if (setq result (funcall lookup-func (car word-list)))
(throw 'ret result))
(setq word-list (cdr word-list))))))
#!/usr/bin/env ruby
require "./event.rb"
def filter(events, &block)
filtered = EventCollection.new
events.each do |ev|
filtered << ev if yield(ev)
end
return filtered