This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ACCESS_TOKEN = "YOUR ACCESS TOKEN"; | |
const USER_ID = 'SEND USER'; | |
const APIKEY = "WEATHER MAP APIKEY"; | |
const LAT = 0; // 検索したい地点の緯度 | |
const LON = 0; // 検索したい地点の経度 | |
const fetchUrl = `https://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&units=metric&lang=ja&appid=${APIKEY}` | |
function myFunction() { | |
let url = "https://api.line.me/v2/bot/message/push"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CHANNEL_ACCESS_TOKEN = "YOUR ACCESS TOKEN"; | |
function doPost(e) { | |
var contents = e.postData.contents; | |
var obj = JSON.parse(contents) | |
var events = obj["events"]; | |
for(var i = 0; i < events.length; i++){ | |
if(events[i].type == "message"){ | |
reply_message(events[i]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def func(arg1, arg2): | |
"""概要 | |
詳細説明 | |
Args: | |
引数(arg1)の名前 (引数(arg1)の型): 引数(arg1)の説明 | |
引数(arg2)の名前 (:obj:`引数(arg2)の型`, optional): 引数(arg2)の説明 | |
Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jupyter nbconvert {ファイル名} --to=html --TemplateExporter.exclude_input=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update | |
sudo apt-get update | |
# Install | |
sudo apt -y install zip | |
# Install CUDA driver (CUDA Toolkit 11.5) | |
# (参考) https://developer.nvidia.com/cuda-11-5-0-download-archive | |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin | |
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
import numpy as np | |
import torch | |
import tensorflow as tf | |
def seed_everything(seed: int) -> None: | |
""" | |
seedの固定 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import MeCab | |
import neologdn | |
def normalize_text(text: str) -> str: | |
""" | |
neologdnによる文章正規化及び正規表現によるURL除去 | |
1. スイーツを食べに行ったよん♪ ちょーーーーーーーおいしかった💌 https://npb-visualization.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_logger(path: str) -> logging.Logger: | |
logger = logging.getLogger(__name__) # ロガーを取得 | |
logger.setLevel(logging.DEBUG) # 出力レベルを設定 | |
# 呼び出し元が異なる際に起こるloggerの重複を防ぐ | |
if not logger.hasHandlers(): | |
fmt = logging.Formatter( | |
'[%(levelname)s] - %(asctime)s - %(message)s' | |
) # フォーマッターを設定 | |
handler_s = logging.StreamHandler() # ストリームハンドラーを生成(標準出力) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("{}{: >25}{}{: >10}{}".format('|', 'Variable Name', '|', 'Memory', '|')) | |
print(" ------------------------------------ ") | |
for var_name in dir(): | |
if not var_name.startswith("_") and sys.getsizeof(eval(var_name)) > 10000: | |
print("{}{: >25}{}{: >10}{}{: >5}{}".format( | |
'|', var_name, '|', sys.getsizeof(eval(var_name)), '|', sys.getrefcount(var_name), '|')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Promise, async/awaitを使えば簡単にかける | |
/** | |
* msec: スリープさせる時間(秒) | |
* 戻り値はPromise | |
*/ | |
const sleep = (msec) => new Promise(resolve => setTimeout(resolve, msec * 1000)); | |
/** | |
* async/awaitでスリープ機能を実装 |
NewerOlder