Skip to content

Instantly share code, notes, and snippets.

View Matts966's full-sized avatar
:octocat:
Coding

Matts966 Matts966

:octocat:
Coding
View GitHub Profile
@Matts966
Matts966 / open_cloud_tabs.bash
Last active June 3, 2023 23:01
Open all tabs in cloud tabs using sqlite3 on mac
#!/bin/bash
if [ "$#" == 0 ]; then
browser=Google\ Chrome
elif [ "$#" == 1 ]; then
browser=$1
else
echo "please pass me a browser name or run with no argument (default browser is 'Google\ Chrome')"
echo "e.g. './open_cloud_tabs.bash Safari'"
exit 1
fi
@Matts966
Matts966 / copy_tabs.bash
Last active November 1, 2019 15:52
Copy all tabs of some applications to others
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "please pass me 2 application names"
echo "e.g. './copy_tabs.bash Safari Google\ Chrome'"
exit 1
fi
from_browser=$1
to_browser=$2
osascript <<EOF | while read line; do open -a "$to_browser" $line; done
set urls to ""
@Matts966
Matts966 / open_safari_tabs_chrome.bash
Created November 1, 2019 05:47
Open all tabs in Safari for Chrome
#!/bin/bash
osascript <<EOF | tr ', ' '\n' | while read line; do open -a Google\ Chrome $line; done
tell application "Safari"
activate
windows's tab's URL
end tell
EOF
@Matts966
Matts966 / settings.json
Created September 3, 2019 09:19
$HOME/Library/Application\ Support/Code/User/settings.json
{
"go.formatTool": "goimports",
"editor.formatOnSave": true,
"go.useLanguageServer": true,
"files.autoSave": "afterDelay",
"terminal.integrated.shell.osx": "/usr/local/bin/bash",
"workbench.editor.enablePreview": false,
"go.gotoSymbol.includeImports": true,
"explorer.autoReveal": false,
}
@Matts966
Matts966 / readline-refsafe.sh
Created September 2, 2019 11:35
cat txt | awk '{print $1}' | ./readline-refsafe.sh みたいに使うやつ。refsafeのところは静的解析ツールに置き換える
#!/bin/bash
while read line; do
echo $line
go get $line
refsafe $line/...
done
@Matts966
Matts966 / lgo-makefile
Created September 2, 2019 10:57
lgo does not have top level makefile now but a PR is made (which I don't like so much). So I use my simple one.
.PHONY: up down url
up:
(cd docker/jupyter && ./up.sh)
down:
(cd docker/jupyter && ./down.sh)
url:
(cd docker/jupyter && docker-compose exec jupyter jupyter notebook list | grep http | sed -E 's/ .*//g')
@Matts966
Matts966 / listen_broadcast.py
Created August 12, 2019 05:25
Listen broadcast udp packet.
from socket import *
import sys
if len(sys.argv) != 2:
print("Please give me port number.")
else:
try:
port=int(sys.argv[1])
except ValueError:
print('Invalid port number.')
@Matts966
Matts966 / iterm-cmd-s-vim
Created July 20, 2019 10:42
Save file with cmd+s when using vim
Send: "\e:w\n"
@Matts966
Matts966 / checkSliceOrNot.go
Created March 25, 2019 02:13
Check the value is slice or not in golang.
package main
import (
"fmt"
"reflect"
)
func check(a interface{}) bool {
fmt.Println(a)
v = [0]; x = [100]; a = []
t = n = 0
T = 5
h = 1
output_required_t = []
while t < T:
a.append(-10)
if t % 1 == 0: