Skip to content

Instantly share code, notes, and snippets.

View hkitago's full-sized avatar

hkitago hkitago

  • Kawasaki
View GitHub Profile
@hkitago
hkitago / install-pam_tid-and-pam_reattach.sh
Last active February 21, 2022 23:30 — forked from kawaz/install-pam_tid-and-pam_reattach.sh
sudo で TouchID が使えるようにする。tmux 内で使えるようにもする。TESTED: 12.2.1(21D62)
#!/bin/bash
set -e
set -o pipefail
# pam_tidの存在チェック(間違えてLinux環境などで実行されたら中断する)
test -f /usr/lib/pam/pam_tid.so.2 || exit 1
# sudoでTouchIDが使えるようにする
if ! grep -Eq '^auth\s.*\spam_tid\.so$' /etc/pam.d/sudo; then
( set -e; set -o pipefail
@hkitago
hkitago / ContentView.swift
Last active March 30, 2023 17:26
WKWebViewTemplate to display HTML with JavaScript
//
// ContentView.swift
// WKWebViewTemplate
//
// Created by Hiroyuki KITAGO on 2022/01/26.
//
import SwiftUI
import WebKit
struct ContentView: View {
@hkitago
hkitago / dark.js
Created October 31, 2021 02:58
Bookmarklet to call Dark Mode
javascript:(()=>%7BcssText='@media(prefers-color-scheme:dark){body{filter:invert(1) hue-rotate(180deg);background-color:#000}img{filter:invert(1) hue-rotate(180deg)}}';textNode=document.createTextNode(cssText);styleNode=document.createElement('style');styleNode.appendChild(textNode);document.getElementsByTagName('head')[0].appendChild(styleNode)%7D)()
@hkitago
hkitago / quickdarkmode.css
Last active October 28, 2021 18:23
add dark mode quickly.
@media (prefers-color-scheme: dark) {
body {
filter: invert(1) hue-rotate(180deg);
background-color:#000;
}
img {
filter: invert(1) hue-rotate(180deg);
}
}
(function() {
'use strict'
const newWindow = window.open('')
const newScript = document.createElement('script')
const injectScript = ()=>{
// The code to inject
}
newScript.innerHTML = injectScript.toString()
newWindow.document.body.appendChild(newScript)
})()
@hkitago
hkitago / checkMercari.scpt
Last active June 3, 2021 04:28
メルカリ検索結果一覧の個数の変化をメッセに通知
property BASE_URL : "https://www.mercari.com/jp/search/?sort_order=price_asc&keyword={検索語}&status_on_sale=1"
property itemsCnt : 0
set theTargetFile to ((((path to me as text) & "::") as alias) as string) & "checkMercari.txt"
set prevData to my read_from_file(theTargetFile)
try
set prevCnt to prevData as integer
on error
set prevCnt to itemsCnt
end try
@hkitago
hkitago / newTweet.js
Last active January 8, 2023 02:32
Bookmarklet to create a new tweet with a text selected and the URL.
javascript:(()=>%7Bd=document,w=window,t='"'+(w.getSelection?w.getSelection():d.getSelection?d.getSelection():d.selection.createRange().text)+'"';if(!t%7C%7Ct=='')%7Bvoid(t=prompt('Create new Tweet:',''));%7Dif(t)w.open('https://twitter.com/intent/tweet?text='+encodeURI(t+' '+location.href))%7D)()
@hkitago
hkitago / bookmarklet_Loader-Canvas.js
Last active April 6, 2021 03:21
Example for Bookmarklet_Loader.js
/**
* @summary Bookmarklet_Loader
* @description Loader for Bookmarklet - injects the required CSS and Javascript into a page
* @file Bookmarklet_Loader.js
* @author HKITAGO (hkitago.com)
* @license GPL v2
* @contact hkitago.com/contact/
*
* @copyright Copyright 2019- hkitago.com.
*
@hkitago
hkitago / MainActivity.kt
Last active December 7, 2022 04:44
Enabling Immersive Mode from JavaScript Event on WebView
/*****************************************************************************
* Put <uses-permission android:name="android.permission.INTERNET" /> in AndroidManifest.xml
* and <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent"/> in activity_main.xml
****************************************************************************/
package com.hkitago.enablingImmersiveMode
import android.annotation.SuppressLint
import android.app.Activity
import android.os.Build
import android.os.Bundle
const posFrom = { 'lat': 35.799465, 'lng': 138.356991 }
const posTo = { 'lat': 35.801618, 'lng': 138.355843 }
const frame = 110
let pathCoords = []
for(let i = 0; i < frame; i++) {
pathCoords.push({ 'lat': (posFrom.lat + ((posTo.lat - posFrom.lat) / frame) * i)
, 'lng': (posFrom.lng + ((posTo.lng - posFrom.lng) / frame) * i) })
}
/*