Skip to content

Instantly share code, notes, and snippets.

Avatar

hkitago hkitago

  • Kawasaki
View GitHub Profile
@hkitago
hkitago / install-pam_tid-and-pam_reattach.sh
Last active Feb 21, 2022 — forked from kawaz/install-pam_tid-and-pam_reattach.sh
sudo で TouchID が使えるようにする。tmux 内で使えるようにもする。TESTED: 12.2.1(21D62)
View install-pam_tid-and-pam_reattach.sh
#!/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 Jan 26, 2022
WKWebViewTemplate to display HTML with JavaScript
View ContentView.swift
//
// ContentView.swift
// WKWebViewTemplate
//
// Created by Hiroyuki KITAGO on 2022/01/26.
//
import SwiftUI
import WebKit
struct ContentView: View {
@hkitago
hkitago / dark.js
Created Oct 31, 2021
Bookmarklet to call Dark Mode
View dark.js
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 Oct 28, 2021
add dark mode quickly.
View quickdarkmode.css
@media (prefers-color-scheme: dark) {
body {
filter: invert(1) hue-rotate(180deg);
background-color:#000;
}
img {
filter: invert(1) hue-rotate(180deg);
}
}
View gist:49b38f05d509c724a2398e0cb1813e40
(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 Jun 3, 2021
メルカリ検索結果一覧の個数の変化をメッセに通知
View checkMercari.scpt
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 Apr 23, 2021
Bookmarklet to create a new tweet.
View newTweet.js
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 Apr 6, 2021
Example for Bookmarklet_Loader.js
View bookmarklet_Loader-Canvas.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
Created Jan 29, 2021
Enabling Immersive Mode from JavaScript Event on WebView
View MainActivity.kt
package com.hkitago.enablingImmersiveMode
import android.annotation.SuppressLint
import android.app.Activity
import android.os.Bundle
import android.os.Handler
import android.view.View
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.webkit.WebViewClient
View getPathCoords.js
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) })
}
/*