Skip to content

Instantly share code, notes, and snippets.

View moriya9n's full-sized avatar

Seiji MORIYA moriya9n

View GitHub Profile
@moriya9n
moriya9n / gist:3b618810b4b499dc17c8f4020ea30c67
Created November 22, 2021 19:18
Amazon paapi を golang で直接呼び出す時の signature 生成方法
// reqJson に json.Marshal したものが入っているとする
// APIHost = "webservices.amazon.co.jp"
// APIRegion = "us-west-2"
// APITarget = "com.amazon.paapi5.v1.ProductAdvertisingAPIv1.SearchItems"
// APIService = "ProductAdvertisingAPI"
bodyReader := bytes.NewReader(reqJson)
req, err := http.NewRequest("POST", "https://" + APIHost + "/paapi5/searchitems", bodyReader)
log.Println("request:", req)
@moriya9n
moriya9n / gist:d0317ee7545083252518f9570bb562be
Last active May 14, 2018 01:29
しょうもないTIPS: 英語版のwindows serverでopenjdk+tomcatを立ち上げる時に日本語関係で悩まされないための設定
setenv.bat に以下のように書いて、startup.bat を実行する。
JAVA_OPTS=の後ろには "" 不要。
set JAVA_OPTS=-Duser.language=ja -Duser.country=JP -Dspring.profiles.active=dev -Dfile.encoding=UTF-8
@moriya9n
moriya9n / gist:0137b88391896e939128859aad601bd6
Last active October 9, 2019 09:38
さくらのレンタルサーバで django / python 3.6 を動かす (速度は期待できないかも)
1. [python 3.6 をインストール](https://gist.github.com/moriya9n/22daf53cae550fa91e365e1acd4d7f8a)する。 venv で仮想環境を作っておく。
2. pip install django
3. django-admin startproject hogehoge
4. レンタルサーバの仕様上、cgi でしか動作しないので、 django-cgi(https://github.com/chibiegg/django-cgi/blob/master/django-python3.cgi)
を取ってくる。(速度は期待できない)
5. cgi の先頭の python パス名は変更。sys.path.append でプロジェクトディレクトリを追加。
6. index.cgi などにリネームして、好きなところに配置。
7. /home/your_account/static などを作って、settings.py に STATIC_ROOT = '/home/your_account/static' を追加。python manage.py collectstatic
を実行。
8. ln -s /home/your_account/static /home/your_account/www/site_name/static
@moriya9n
moriya9n / gist:22daf53cae550fa91e365e1acd4d7f8a
Last active October 3, 2018 02:05
さくらのレンタルサーバーに python3.6 をインストール
さくらのレンタルサーバーに python3.6 をインストールする方法
===================================================
そのままコンパイルすると pip が使えない(SSLバージョンエラー?)ので、openssl を入れる。
openssl のコンパイル
----------------------------------
wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
tar xvf openssl-1.0.2o.tar.gz
cd openssl-1.0.2o
@moriya9n
moriya9n / loto6_latest.py
Last active May 5, 2018 04:20
loto6 最新
#!/usr/bin/env python
import requests
import csv
# list
r = requests.get('https://www.mizuhobank.co.jp/retail/takarakuji/loto/loto6/csv/loto6.csv')
r.encoding='cp932'
loto6_list = [i[1:5] for i in r.text.splitlines() if i.startswith('第')]
#!/usr/bin/env python
import requests
import csv
# list
r = requests.get('https://www.mizuhobank.co.jp/retail/takarakuji/loto/loto6/csv/loto6.csv')
r.encoding='cp932'
loto6_list = [i[1:5] for i in r.text.splitlines() if i.startswith('第')]
@moriya9n
moriya9n / awsmonero.md
Last active April 29, 2018 01:40
aws monero cpu mining on spot instance without installation
@moriya9n
moriya9n / gist:69e38ad7c09a70fb0b2691f68741a9b3
Created January 22, 2018 06:55
spring / static メソッドから MessageSource などにアクセスする
class 何かのクラス implements xxxAware {
public static 型 なんちゃらメソッド();
}
xxx には ApplicationContext / Environment / MessageSource など
https://stackoverflow.com/questions/2751603/how-to-get-error-text-in-controller-from-bindingresult
考え方(私見)
Javascriptを多用するページには合わないかもしれないが。。。
作成、表示、更新、削除(CRUD)
URL
http[s]://なんたらかんたら/id
GET http[s]://なんたらかんたら/new
GET http[s]://なんたらかんたら/id