Skip to content

Instantly share code, notes, and snippets.

@orangain
orangain / cdk-auto-mapper.ts
Created October 21, 2023 12:03
cdk-auto-mapper.ts: Deno script to fill CDK's import mapping file using result of `aws cloudformation list-stack-resources`
if (Deno.args.length !== 2) {
console.error(
"Usage: deno run --allow-read cdk-auto-mapper.ts <resource-file-path> <mapping-file-path>"
);
Deno.exit(1);
}
const [resourcePath, mappingPath] = Deno.args;
const resourceFileContent = await Deno.readTextFile(resourcePath);
@orangain
orangain / adjust_splits.py
Created September 15, 2019 08:07
pandasで株式分割・併合に伴う株価調整
import pandas as pd
dfs = pd.read_html('https://srbrnote.work/archives/2338')
df_splits = dfs[0] # 株式分割・併合データ
df_stocks = dfs[2] # 株価データ
df_splits['分割日'] = pd.to_datetime(df_splits['分割日'])
df_splits['係数'] = df_splits['分割前'] / df_splits['分割後']
df_stocks['日付'] = pd.to_datetime(df_stocks['日付'])
@orangain
orangain / amazon_order_history.py
Created November 14, 2017 10:26
werkzeug.exceptions.BadRequestKeyErrorになる問題に対応したamazon_order_history.py
import sys
import os
from robobrowser import RoboBrowser
# 認証の情報は環境変数から取得する。
AMAZON_EMAIL = os.environ['AMAZON_EMAIL']
AMAZON_PASSWORD = os.environ['AMAZON_PASSWORD']
# RoboBrowserオブジェクトを作成する。
@orangain
orangain / README.md
Last active June 26, 2017 00:35
テーブルからのスクレイピング

準備

$ python3 -m venv scraping
$ . venv/bin/activate
(venv) $ pip install scrapy

実行

@orangain
orangain / README.md
Last active June 18, 2016 10:27
Difference of extracted contents between Python 2 and 3

Command to extract contents

$ python2 --version
Python 2.7.11
$ python3 --version
Python 3.5.1
$ git checkout master
$ python2 WikiExtractor.py --lists --links -b 100M in/jawiki-20150805-pages-articles.xml.bz2 -o out-py2-master
$ git checkout support-python3
@orangain
orangain / README.md
Last active March 16, 2016 08:28
Testing non-ASCII URLs with simple spiders.

In my environment these spiders work well.

Environment:

(venv) $ python -V
Python 3.4.2
(venv) $ scrapy version
Scrapy 1.1.0rc3
@orangain
orangain / 01 - Mac OS X script to automatically start docker vm on system boot.md
Last active January 22, 2016 04:09
Mac OS X script to start Docker VM automatically on system boot

Setup

  1. Download com.docker.vm.plist and save it into ~/Library/LaunchAgents/.

    $ curl -sL https://git.io/vz2Y9 -o ~/Library/LaunchAgents/com.docker.vm.plist
    
  2. (Optional) Change <string>default</string> line if you are using different name of docker machine.

@orangain
orangain / 0_reuse_code.js
Created January 13, 2016 14:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
from __future__ import print_function
import scrapy
class TestSpider(scrapy.Spider):
name = 'test'
allowed_domains = ['capybala.com']
start_urls = (