Skip to content

Instantly share code, notes, and snippets.

Avatar

hkitago hkitago

  • Kawasaki
View GitHub Profile
@hkitago
hkitago / createSlide.JS
Created March 13, 2023 01:01
Create Overlay Slideshow for 4 Photos by receiving the first photo ID number.
View createSlide.JS
const createSlide = (imgId) => {
const divE = document.createElement('div')
divE.innerHTML = '<div></div>'
divE.id = 'slide'
screenE.appendChild(divE)
const slideE = document.querySelector('#slide > div')
const slideUL = document.createElement('ul')
for(let i = 0; i < 4; i++) {
const liE = document.createElement('li')
@hkitago
hkitago / displaySomePropertyOnRightTopCorner.JS
Created January 30, 2023 08:26
Display Some Property On Right Top Corner
View displaySomePropertyOnRightTopCorner.JS
const displaySomePropertyOnRightTopCorner = (SomeProperty) => {
if (!SomeProperty) { return false }
const divE = document.createElement('div')
divE.textContent = SomeProperty
divE.style.width = '5vw'
divE.style.height = '5vh'
divE.style.backgroundColor = 'rgb(255 255 255/.5)'
divE.style.zIndex = [...document.querySelectorAll`*`].reduce((a,e,i,t,z=+window.getComputedStyle(e).zIndex||0) => z>a ? z:a ,0) + 1
divE.style.position = 'fixed'
divE.style.right = '0'
@hkitago
hkitago / duckduckgoBookmarklet.js
Created November 17, 2022 20:19
DuckDuckGo Search Bookmarklet
View duckduckgoBookmarklet.js
javascript:(()=%3E%7Bd=document,w=window,Qr=(w.getSelection?w.getSelection():d.getSelection?d.getSelection():d.selection.createRange().text);if(!Qr%7C%7CQr==%27%27)%7Bvoid(Qr=prompt(%27DuckDuckGo%20search%20word:%27,%27%27));%7Dif(Qr)w.open(%27https://duckduckgo.com/?q=%27+encodeURI(Qr))%7D)()
@hkitago
hkitago / functions.php
Last active September 30, 2022 05:33
Get user description for WordPress Shortcodes
View functions.php
// use [user_description] in a block, get $user_ID echo '<script>console.log("'.$user_ID.'")</script>'; in function.php before.
function get_user_description() {
$user_ID = get_current_user_id();
return get_user_meta({$user_ID}, 'description', true);
}
add_shortcode('user_description', 'get_user_description');
View OpenChrome.scpt
try
tell application "BBEdit" to set theFile to file of document 1
tell application "Finder" to open theFile using (path to application "Google Chrome")
on error
try
return theFile
on error errorMessage
return errorMessage
end try
end try
View detectScrollEnd.js
scrolledElement.addEventListener('scroll', (e) => {
if (e.tareget.offsetHeight + e.tareget.scrollTop >= e.tareget.scrollHeight) {
// Do something.
}
}, { passive: true })
@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)
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 January 26, 2022 06:09
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 October 31, 2021 02:58
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 October 28, 2021 18:23
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);
}
}