Skip to content

Instantly share code, notes, and snippets.

View vwrs's full-sized avatar
🏠
Working from home

Hideaki Kanehara vwrs

🏠
Working from home
View GitHub Profile
# -*- coding: utf-8 -*-
import logging
import sys
from nvdloader import NVDLoader
def main():
argv = sys.argv
if len(argv) != 2 or argv[1] not in ['2', '3']:
print('Usage: $ python %s 2|3 (CVSS ver.)' % argv[0])
import sys
import os
import dotenv
from slackclient import SlackClient
dotenv.load_dotenv('/path/to/.env')
def post_slack(text: str, channel: str):
slack_token = os.environ['SLACK_API_TOKEN']
@vwrs
vwrs / ec2-stop-instance.sh
Last active February 22, 2019 08:11
Stop an AWS EC2 instance
#!/bin/bash -eu
DEFAULT_REGION=ap-northeast-1
INSTANCE_ID=`curl -fsSL http://169.254.169.254/latest/meta-data/instance-id/`
if [ $? = 0 ]; then
echo "instance-id:["$INSTANCE_ID"]"
else
echo "An unexpected error occurred when trying to get instance-id."
exit 1
fi
@vwrs
vwrs / proxy.pac
Last active November 27, 2018 08:49
Socks Proxy
function FindProxyForURL(url, host) {
return "SOCKS localhost:10080";
}
@vwrs
vwrs / counter-plot.py
Last active November 25, 2018 05:52
matplotlib utils
import matplotlib.pyplot as plt
import seaborn as sns
from collections import Counter
def counter_plot(values, max_count=len(set(values)),
figsize=(17,5), dpi=80,
fontsize=12, rotation=90,
xoffset=.05, yoffset=.1):
c = Counter(values)
l, v = zip(*c.most_common(max_count))
@vwrs
vwrs / slack-theme-material-dark
Created September 24, 2018 17:40
Slack Custom Sidebar Theme
#303E4D,#60a8cc,#0f658a,#64fcda,#546e7a,#eceff1,#40c4ff,#ff5252
@vwrs
vwrs / autodel.sh
Last active September 12, 2018 07:27
Delete old files in a folder automatically
#!/bin/bash -eu
# for crontab
FILEDIR=/path/to/dir
LOGFILE=/var/log/autodel.log
DAYS=200
PROCESSES=4
CHUNK=10
# delete files older than 200 days & parallelize
@vwrs
vwrs / crawler-with-tor.py
Created May 22, 2018 13:43
NIPS paper downloader
import os
import wget
import requests
from bs4 import BeautifulSoup
# use Tor
local_proxy = 'socks5://127.1:9050'
socks_proxy = {
'http': local_proxy,
'https': local_proxy
@vwrs
vwrs / download-disabled-dropbox.sh
Created April 9, 2018 13:46
download as pdf from Dropbox when the download option is disabled
#!/bin/bash -eu
# first, get the image URLs using such as Chrome DevTools
# The URLs is assumed to be "xxxxx?page={page number}"
URI=("https://path/to/file1" "https://path/to/file2")
PAGES=(10 20)
RED=""
GREEN=""
BLUE=""
NORMAL=""
@vwrs
vwrs / userChrome.css
Last active February 1, 2018 16:24
~/Library/Application Support/Firefox/Profiles/xxxxxx.default/chrome/userChrome.css
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* to hide the native tabs */
/* #TabsToolbar {
visibility: collapse;
} */
/* to hide the sidebar header */
#sidebar-header {
visibility: collapse;
}