Skip to content

Instantly share code, notes, and snippets.

View mu373's full-sized avatar

Minami Ueda mu373

View GitHub Profile
@mu373
mu373 / expandAllAccordion.md
Last active March 25, 2021 12:09
Bookmarklet: Expand all accordion boxes

Description

Usage

  • Add the following code as a bookmarklet
javascript:(function(f,s){s=document.createElement("script");s.src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js";s.onload=function(){f(jQuery.noConflict(true))};document.body.appendChild(s)})(function($){$('.st-postAccordion_body').css('display','block');});
@mu373
mu373 / filter_with_condition_from_other_sheet.md
Last active March 11, 2021 12:42
Filter data with condition from other sheet in Google Sheets

Filter data with condition from other sheet in Google Sheets

Description

  • Data is stored in a sheet named data
  • Column A has IDs in each cell (In this case, let's pretend it to be a list of alphabets: A, B, C, D, ...)
  • You want to extract data which has specific ID in Column A (Let's say A, C, and D)

image

Steps

@mu373
mu373 / regex_filter_spreadsheet.md
Last active March 9, 2021 12:49
Filter with regular expression in Google Sheets

Filter data with regular expression in Google Sheets

e.g. Column A NOT starting with Capital Alphabet

=not(REGEXMATCH(A2:A,"[A-Z].*"))
@mu373
mu373 / README.md
Last active December 19, 2020 11:48
Simplify Amazon URL

Simplify Amazon URL: Automator action for Safari

  • This is an Automator service/quick action that generates a clean and simple URL for Amazon product pages on Mac Safari
  • It removes all unnecessary parameters from URL, such as search queries and product names
  • Simplified link will be copied to the clipboard

Example

before

https://www.amazon.co.jp/Amazonベーシック-USB-AケーブルLightningコネクタ付き、プレミアムコレクション-10cm-、2点入りパック/dp/B07FGKRX7M/ref=sr_1_1_sspa?__mk_ja_JP=カタカナ&dchild=1&keywords=lightning&qid=1608376160&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExVUo0Wk9VTFVEMFQ1JmVuY3J5cHRlZElkPUEwMTcyMDYwR1ZGTlZTMDhZOEFNJmVuY3J5cHRlZEFkSWQ9QTJSMEtUNkszMDkwUlomd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl
@mu373
mu373 / unixtime.sh
Created November 11, 2020 05:56
Unix Time conversion from pipe
# echo <unixtimestamp> | xargs date -r
echo 1604677087 | xargs date -r
@mu373
mu373 / googlegroups.gs
Last active October 20, 2020 12:28
Bulk add members from one group to another (Google Groups)
// Execute main function from GAS script editor
function main() {
addGroupMembersToGroup('foo@example.com', 'bar@example.com')
}
// Get list of members in a group
// e.g. getMembers('foo@example.com')
function getMembers(groupAddress) {
var members = AdminDirectory.Members.list(groupAddress).members;
@mu373
mu373 / firewall.sh
Created April 23, 2020 11:53
EdgeRouter X Firewall Settings (excerpt)
set firewall ipv6-name WANv6_IN default-action drop
set firewall ipv6-name WANv6_IN description 'WAN to LAN'
set firewall ipv6-name WANv6_IN enable-default-log
set firewall ipv6-name WANv6_IN rule 10 action accept
set firewall ipv6-name WANv6_IN rule 10 description 'Allow established/related'
set firewall ipv6-name WANv6_IN rule 10 state established enable
set firewall ipv6-name WANv6_IN rule 10 state related enable
set firewall ipv6-name WANv6_IN rule 20 action drop
set firewall ipv6-name WANv6_IN rule 20 description 'Drop invalid state'
set firewall ipv6-name WANv6_IN rule 20 state invalid enable
@mu373
mu373 / filterCSV.md
Last active February 15, 2020 09:21
CSVからawkで条件に合致する行を抽出する

概要

シェルスクリプトでlist.csvというファイルから、「3列目の値が100」かつ「5列目の値が200」である行を抽出する

スクリプト

awk -F, '$3 ~ /100/ && $5 ~ /200/ {print $0}' list.csv > list2.csv

参考

'Grep to filter gigantic CSV file'

@mu373
mu373 / cdf.sh
Last active November 11, 2020 05:59
cd to current directory in Finder
# add this to .zshrc
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
@mu373
mu373 / gist:55a2e3a7ec1ba3da9f03837cdee2c1a0
Created August 9, 2018 06:45
ターミナルからFTPSサーバーにアクセスする
lftp user@server -p 21