Skip to content

Instantly share code, notes, and snippets.

#!/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])
@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
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 / 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
@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()
#

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 / 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
@Canorus
Canorus / tootcounter.py
Created November 30, 2019 14:36
툿 수 세서 k 단위로 발표해주는 스크립트
import requests # install requests package
import json
import re
h = {'Authorization': 'Bearer [access_key_here]'}
inst = 'https://[instance_address_here]'
r_user = requests.get(inst + '/api/v1/streaming/user', headers=h, stream=True)
def sendtoot(message):
@Canorus
Canorus / kkma test #1
Created December 5, 2019 06:08
kkma 형태소 분석 시 문장 통째로 분석 넣은 산출값과 어절 단위로 분절해서 입력한 산출값의 비교
>>> l = []
>>> t = '일단 자물쇠는 풀어두고 싶은데 그런데 그렇다고 로컬탐라를 포기할 수 없어'
>>> kkma.pos(t)
[('일단', 'MAG'), ('자물쇠', 'NNG'), ('는', 'JX'), ('풀', 'VV'), ('어', 'ECD'), ('두', 'VXV'), ('고', 'ECE'), ('싶', 'VXA'), ('은데', 'ECD'), ('그런데', 'MAC'), ('그렇', 'VA'), ('다고', 'EFN'), ('로컬', 'NNG'), ('탐', 'NNG'), ('라', 'NNG'), ('를', 'JKO'), ('포기', 'NNG'), ('하', 'XSV'), ('ㄹ', 'ETD'), ('수', 'NNB'), ('없', 'VA'), ('어', 'ECD')]
>>> for i in t.split(' '):
... l.extend(kkma.pos(i))
...
>>> l
[('일단', 'MAG'), ('자물쇠', 'NNG'), ('는', 'JX'), ('풀', 'VV'), ('어', 'ECD'), ('두고', 'NNP'), ('싶', 'VXA'), ('은데', 'ECD'), ('그런데', 'MAC'), ('그렇', 'VA'), ('다고', 'EFN'), ('로컬', 'NNG'), ('탐', 'NNG'), ('라', 'NNG'), ('를', 'JKO'), ('포기', 'NNG'), ('하', 'XSV'), ('ㄹ', 'ETD'), ('수', 'NNG'), ('없', 'VA'), ('어', 'ECD')]
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/live/app/services/activitypub/process_collection_service.rb:32:in `each'
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/live/app/services/activitypub/process_collection_service.rb:32:in `map'
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/live/app/services/activitypub/process_collection_service.rb:32:in `process_items'
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/live/app/services/activitypub/process_collection_service.rb:19:in `call'
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/live/app/workers/activitypub/processing_worker.rb:9:in `perform'
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:192:in `execute_job'
Dec 18 20:53:25 canors_ubuntu bundle[7872]: /home/mastodon/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/sidekiq-5.2.7/lib/sidekiq/processor.rb:165:in `block (2 levels) in process'
Dec 18 20:53:25