Skip to content

Instantly share code, notes, and snippets.

@kaka-go
kaka-go / dijkstra.py
Created November 2, 2019 00:07
dijkstra algorithm adjecent graph
# https://www.youtube.com/watch?v=Ub4-nG09PFw
# https://gist.github.com/amitabhadey/37af83a84d8c372a9f02372e6d5f6732#file-dijkstraalgorithm-py-L85
class Graph:
def dijkstra(self, graph, start, goal):
shortest_dist = {}
predecessor = {}
unvisited = graph.copy() # copy graph
track_path = []
for node in unvisited:
@kaka-go
kaka-go / es_request
Last active October 28, 2019 03:44
Elasticsearch API request
GET _cat/indices?v
GET _cat/indices?v&index=index_name-*
GET _cat/allocation?v
GET _cat/nodes?v&h=name,disk*,ram*
GET _cluster/stats?human&pretty
GET /index_name-2019.09.*/_search
{
"size" : 0,
@kaka-go
kaka-go / mail_domain_count.sql
Created October 4, 2019 01:05
select mail domain count from table
select
SUBSTRING_INDEX(mail_addr,'@',-1) as mail_domain,
count(1) as mail_count
from mail_table
group by SUBSTRING_INDEX(mail_addr,'@',-1)
order by mail_count desc;
@kaka-go
kaka-go / wait_for_win.applescript
Created August 7, 2019 02:35
check name in window title
on waitForWin(check_name, time_out)
set wait_time to 0
tell application "System Events"
repeat while (wait_time < time_out)
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
tell process frontAppName
tell (1st window whose value of attribute "AXMain" is true)
set windowTitle to value of attribute "AXTitle"
@kaka-go
kaka-go / split.awk
Created July 30, 2019 01:13
split files by date column
# sales_report.csv -> 20190730_sales.csv, 20190729_sales.csv
sales_date, price, item_id, item_name,....
"20190730", 100, A01, "sample item xxx"
"20190729", 200, B01, "sample item yyy"
# OSX
awk -F, '{ print >>(substr($1, 2, 8) "_sales.csv");close(substr($1,2,8)"_sales.csv")}' sales_report.csv
@kaka-go
kaka-go / vscode_integrated_cmd.applescript
Created May 28, 2019 16:04
Run code in integrated terminal of vscode
tell application "Visual Studio Code"
delay 1
tell application "System Events"
keystroke "`" using control down
delay 1
keystroke "sudo some command"
keystroke return
keystroke "password"
keystroke return
end tell
@kaka-go
kaka-go / find_line_not_contain_word.md
Last active April 4, 2019 01:00
Regex patterns & tricks
@kaka-go
kaka-go / playlist.js
Created November 4, 2018 13:55
get all video link from playlist on youtube
vlist = document.getElementsByClassName("yt-simple-endpoint style-scope ytd-playlist-video-renderer");
for(i=0;i<vlist.length;i++) {
console.log("https://www.youtube.com" + vlist[i].getAttribute("href"));
}
@kaka-go
kaka-go / split_keyboards.md
Created October 3, 2018 16:05 — forked from itod/split_keyboards.md
Every "split" mechanical keyboard currently being sold that I know of
@kaka-go
kaka-go / show_biggest_files.sh
Created July 5, 2018 02:10
find the biggest files and directories
# 容量をくっているトップ20を表示(ファイル)
du -mah | sort -rn | head -20
# 容量をくっているトップ20を表示(ディレクトリのみ)
du -mh | sort -rn | head -20