Skip to content

Instantly share code, notes, and snippets.

@hexium310
hexium310 / disable-unfollow-button.css
Last active October 27, 2023 08:12
A style for disabling unfollow button at the user's bio and the more dropdown in Twitter
[data-testid$="unfollow"], [data-testid="Dropdown"]:has(> a[href$="/quotes"]) > :has(+ a[href="/i/lists/add_member"]) {
pointer-events: none;
}
@hexium310
hexium310 / bookmarklet.js
Last active July 10, 2023 10:07
A bookmarklet to save an image opening on Twitter
javascript:(async()=>{var[,t,e]=location.href.match(/\/status\/(\d+)\/photo\/(\d)/),a=document.querySelector('div[style*="transition-duration:"][style*="background-color:"]'),i=[...a.querySelectorAll("ul")].find(t=>[...t.style].includes("transform")),o='img[src^="https://pbs.twimg.com/media/"]',i=(void 0!==i?[...i.querySelectorAll(o)][e-1]:[...a.querySelectorAll(o)].find(t=>"tweetPhoto"!==t.parentNode.getAttribute("data-testid"))).src,a=await fetch(i).then(t=>t.blob()),o=a?.type;/^image\/.+$/.test(o)&&(await(i=await(await window.showSaveFilePicker({startIn:"downloads",suggestedName:`twitter_${t}_`+e,types:[{accept:{[o]:"."+o.match(/image\/(.+)/)[1]}}]})).createWritable()).write(a),await i.close())})();
@hexium310
hexium310 / bookmarklet.js
Last active April 17, 2022 10:38
Copy title and URL to clipboard
javascript:{const t=document.title+" "+location.href,o=t=>{window.prompt("",t)};navigator?.clipboard?.writeText(t).catch(()=>{o(t)})||o(t)}
@hexium310
hexium310 / make-docs.rs-latest.user.js
Last active May 13, 2022 10:29
Make docs.rs latest on Google Search
// ==UserScript==
// @name Make docs.rs latest on Google Search
// @namespace hexium310
// @version 0.0.1
// @author Hexin
// @include /^(http|https):\/\/www\.google\..+\/search.*/
// @downloadUrl https://gist.github.com/hexium310/774465f10e34740849d653c277cf9ab6/raw/make-docs.rs-latest.user.js
// @updateUrl https://gist.github.com/hexium310/774465f10e34740849d653c277cf9ab6/raw/make-docs.rs-latest.user.js
// ==/UserScript==
git revert $(git log --oneline | nl >&2; read -p '> ' num; git log --format='%h' --skip=$((num - 1)) -1)
@hexium310
hexium310 / head.zsh
Created September 30, 2021 06:43
Use `HEAD` in `git pull`, `git rebase` and so on
autoload -Uz add-zsh-hook
__set_head() {
if git rev-parse --show-toplevel > /dev/null 2>&1; then
alias -g HEAD=$(git symbolic-ref --short \HEAD)
fi
}
__set_head
add-zsh-hook chpwd __set_head
@hexium310
hexium310 / switch-plain-md-github.user.js
Last active September 25, 2021 13:38
This userscript adds a button for switching plain/rich for a Markdown blob on GitHub.
// ==UserScript==
// @name Switching Plain for Markdown on GitHub
// @namespace hexium310
// @version 0.3
// @description This userscript adds a button for switching plain/rich for a Markdown blob on GitHub.
// @author Hexin
// @match https://*.github.com/*/*
// @downloadURL https://gist.github.com/hexium310/76eda31e03f7bd09227133a26364bbe8/raw/switch-plain-md-github.user.js
// @updateURL https://gist.github.com/hexium310/76eda31e03f7bd09227133a26364bbe8/raw/switch-plain-md-github.user.js
// @grant none
@hexium310
hexium310 / .textlintrc generator
Last active June 11, 2021 09:41
A .textlintrc generator
cat <<< $(jq '{ rules: [{ key: .devDependencies | keys | map(match("(@textlint-.+/)?textlint-rule-.+").string | gsub("^textlint-rule-"; ""))[], value: true }] | from_entries }' package.json | jq -s '.[1] * .[0]' .textlintrc.json -) > .textlintrc.json
@hexium310
hexium310 / group-by-range.zsh
Last active June 9, 2021 16:48
group-by-range
group-by-range() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
local value
local values=(${(ps: :)1})
local separator=${2--}
local tmp_separator=,
local result=()
local positives=(${(no)${(M)values:#[[:digit:]]##}})
local negatives=(${(nO)${(M)values:#-[[:digit:]]##}})
@hexium310
hexium310 / a.zsh
Last active June 2, 2021 18:20
queryのみが書かれたファイルをgh api graphql --inputでつかうやつ
gh api graphql --input <(jq -n --arg owner hexium310 --arg name brew-uo --arg query "$(cat file | tr '\n' ' ')" '{ query: $query, variables: { owner: $owner, name: $name } }')