Skip to content

Instantly share code, notes, and snippets.

@Canorus
Canorus / grab.scpt
Created September 24, 2019 04:04
Grab all Safari tab
tell application "Safari"
--Variables
set windowCount to number of windows
set docText to ""
--Repeat for Every Window
repeat with x from 1 to windowCount
set tabCount to number of tabs in window x

Keybase proof

I hereby claim:

  • I am canorus on github.
  • I am canor (https://keybase.io/canor) on keybase.
  • I have a public key ASDFDKhWYyTugRjvVtSfl9JU0Tv1gKGS97k8zboXePOaqwo

To claim this, I am signing this object:

@Canorus
Canorus / read_file_over_ssh.py
Created April 10, 2019 04:58
read file over ssh connection
import paramiko
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.connect('host',port=port_number_if_not_default_22,username='username',passphrase='ssh_key_passphrase',look_for_keys=False)
channel = ssh.get_transport().open_session()
channel.exec_command('cat /path/to/file')
t = channel.recv(1024).decode('utf-8')
ssh.close()
#
@Canorus
Canorus / trash.rb
Created March 14, 2019 07:27
#maid rules for cleaning .Trash with ruby on macOS, including apps and dirs
Maid.rules do
def remove_dir(path) # via https://stackoverflow.com/a/40346738
if File.directory?(path)
Dir.foreach(path) do |file|
if ((file.to_s != ".") and (file.to_s != ".."))
remove_dir("#{path}/#{file}")
end
end
Dir.delete(path)
else
Maid.rules do
rule 'Updating Brew' do
`brew update`
end
rule 'Updating Brews' do
`brew upgrade -all`
end
rule 'Cleaning Brew' do
`brew cleanup`
end
@Canorus
Canorus / vimrc for macbook air
Created September 18, 2018 06:42
my .vimrc
set autoindent
"set cindent
set smartindent
set nowrapscan
set visualbell
set ruler
set shiftwidth=4
set number
set fencs=ucs-bom,utf-8,euc-kr.latin1
set fileencoding=utf-8
#!/usr/local/bin/python3
old = ['a','b','c','d','e','f','1','2','6','7']
new = ['1','2','3','4','5','6','a','b','f','g']
total = old+new
for a in old:
for b in new:
if(old[a]==new[b]):
total.remove(old[a])