Skip to content

Instantly share code, notes, and snippets.

View mkanenobu's full-sized avatar

Kanenobu Mitsuru mkanenobu

View GitHub Profile
@mkanenobu
mkanenobu / unam.bash
Last active April 7, 2017 06:16
Extract multiple archive file contents with unar command
#!/bin/bash
### unarchve multiple files with unar
set -Cue
if test $# -gt 0; then
for i in "$@"; do
unar $i
done
fi
#!/bin/bash
# This script can use in macOS or Linux
# Change [proxy] and [port]
# Execute $ source proxy_switch.bash
proxy=""
port=""
if [ -z $http_proxy ]; then
echo "Enable"
export http_proxy="http://${proxy}:${port}/"
else
#!/bin/bash
## $1=format
set -Cue
generate_file=`basename "$(pwd)" | sed -e "s/\$/.m3u/g"`
echo '#EXTM3U' >> "$generate_file"
if [ -z "$1" ]; then
format=wav
else
format="$1"
cat "$HOME"/.bash_history | sort | uniq -c | sort -rn | head
@mkanenobu
mkanenobu / pushCurrentBranch.bash
Created May 14, 2018 00:52
git push current branch
#!/bin/bash
current_branch="$(git branch | grep \* | sed -e "s/\*\ //")"
echo "Push to $current_branch"
if [ "$current_branch" = "master" ]; then
read -rp "Are you sure?:" confirm
if [ "$confirm" = "y" ]; then
git push origin master
else
echo ""
fi
@mkanenobu
mkanenobu / convert_aliases.bash
Created September 14, 2018 07:03
.bashrcに書いてあるエイリアスをxonshの構文に変換するスクリプト ref: https://qiita.com/mkanenobu/items/7ba1c238ad4fb20a47f8
#!/bin/bash
while read line; do
if [[ $line =~ ^alias ]]; then
echo -n aliases\[\""$(echo "$line" | cut -d'=' -f 1 | sed -e "s/alias //g" )"\"\] =
echo " $(echo "$line" | cut -d'=' -f 2-)"
fi
done < ~/.bashrc
javascript:(function(){let url=location.href;let title=document.title;url=encodeURIComponent(url);title=encodeURIComponent(title);window.open('https://twitter.com/intent/tweet?url='+url+'&text='+title,'_blank');})();
(function() {
let c = window.getSelection().toString();
if (c == ""){
c = window.prompt("Input character.", "");
}
let a = [];
for (let i of c) {
a.push(i.charCodeAt());
}
alert(a);
@mkanenobu
mkanenobu / pbcopy
Created January 30, 2019 05:10
pbcopy for Cygwin, MSYS2
### append to .bashrc
alias pbcopy="iconv -f UTF-8 -t CP932 | /c/Windows/System32/clip.exe"
@mkanenobu
mkanenobu / translate_in_new_tab.js
Last active April 24, 2020 05:02
send selection to Google Translate
// japanese to english
(function() {
var text = window.getSelection();
var url = "https://translate.google.co.jp/?hl=ja#view=home&op=translate&sl=ja&tl=en&text=" + text;
window.open(url);
})();
// compiled with Google Closure Compiler
// javascript:window.open("https://translate.google.co.jp/?hl=ja#view=home&op=translate&sl=ja&tl=en&text="+window.getSelection());
// english to japanese