IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

ysql-connector-java-6.0.6のサンプル実行

$javac -cp .:mysql-connector-java-6.0.6-bin.jar DevApiSample.java

$java -cp .:mysql-connector-java-6.0.6-bin.jar:lib/protobuf-java-2.6.0.jar DevApiSample
Connected!
Default schema is: Schema(foo)
Currently reading Effi Briest on page 42
Currently reading Effi Briest on page 42
Number of books in collection: 0

作業ログ

haskell

Haskell 文字列変換入門 - Qiita

Example of streaming data from the database using Persistent and Conduit libraries in Haskell

Smart Data with Conduits — Monday Morning Haskell

作業ログ

VIM

vim-plugin NERDTree で開発効率をアップする! - Qiita

Vim split line command - Stack Overflow

haskell

ストリーム処理ライブラリはなぜ必要なのか // Speaker Deck

MySQL

Streaming MySQL Results Using Java 8 Streams and Spring Data JPA

RealWorld Example を触ってみる

Haskell Servant RealWorld Example App

リポジトリの場所

Haskell Servant RealWorld Example App

インストー

サイトの手順の通り

データベース

>sqlite3 /tmp/haskell-servant-test.db <  {your_path}/haskell-servant-realworld-example-app/scripts/schema.sql 

処理

登録

xxx$ curl --verbose -H "Content-Type: application/json" -X POST -d '{"user" : {"email":"aaa@a.com", "username":"aaa", "password": "aaa"} }' http://127.0.0.1:8081/api/users
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> POST /api/users HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 70
>
* upload completely sent off: 70 out of 70 bytes
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:32:50 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"user":{"bio":null,"email":"aaa@a.com","image":null,"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI","username":"aaa"}}

認証

成功

xxx$ curl --verbose -H "Content-Type: application/json" -X POST -d '{"user" : {"email":"aaa@a.com", "username":"aaa", "password": "aaa"} }' http://127.0.0.1:8081/api/users/login
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> POST /api/users/login HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 70
>
* upload completely sent off: 70 out of 70 bytes
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:39:33 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"user":{"bio":null,"email":"aaa@a.com","image":null,"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI","username":"aaa"}}

失敗

xxx$ curl --verbose -H "Content-Type: application/json" -X POST -d '{"user" : {"email":"aaa@a.com", "username":"aaa", "password": "xxx"} }' http://127.0.0.1:8081/api/users/login
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> POST /api/users/login HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 70
>
* upload completely sent off: 70 out of 70 bytes
< HTTP/1.1 401 Unauthorized
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:39:42 GMT
< Server: Warp/3.2.11.2
<
* Connection #0 to host 127.0.0.1 left intact
Incorrect login or password

ユーザ取得

成功

xxx$ curl --verbose -H "Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI"  http://127.0.0.1:8081/api/user
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/user HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:28:27 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"user":{"bio":null,"email":"aaa@a.com","image":null,"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI","username":"aaa"}}

失敗

xxx$ curl --verbose -H "Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuX"  http://127.0.0.1:8081/api/user
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/user HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuX
>
< HTTP/1.1 401 Unauthorized
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:37:18 GMT
< Server: Warp/3.2.11.2
<
* Connection #0 to host 127.0.0.1 left intact
Wrong 'Authorization' token

プロファイル取得

成功

xxx$ curl --verbose -H "Authorization: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI" -X GET  http://127.0.0.1:8081/api/profiles/aaa
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/profiles/aaa HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Authorization: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:41:39 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"profile":{"bio":null,"image":null,"username":"aaa","following":false}}

失敗

xxx$ curl --verbose -H "Authorization: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI" -X GET  http://127.0.0.1:8081/api/profiles/xxx
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/profiles/xxx HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Authorization: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:42:11 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"profile":null}
xxx$

記事作成

xxx$ curl --verbose -H "Content-Type: application/json" -H "Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI" -X POST -d '{"article": {"title" : "aaa_title_1", "description" : "aaa_description_1", "body" : "aaa_body_1", "tag" : "aaa_tag_1"} }' http://127.0.0.1:8081/api/articles
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> POST /api/articles HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6eyJ1c2VyIjoiYWFhIn19.2_OPvQfqSdJfqftP-4ovSzv6zLFcyaMHPK6XdV1NuuI
> Content-Length: 120
>
* upload completely sent off: 120 out of 120 bytes
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:47:30 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"article":{"createdAt":"2017-06-03T02:47:30Z","slug":"aaa_title_1","body":"aaa_body_1","favorited":0,"tagList":null,"favoritesCount":0,"author":{"bio":null,"image":null,"username":"aaa","following":false},"updatedAt":"2017-06-03T02:47:30Z","title":"aaa_title_1","description":"aaa_description_1"}}
xxx$

記事一覧

xxx$ curl --verbose -X GET  http://127.0.0.1:8081/api/articles
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/articles HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:50:09 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"articlesCount":1,"articles":[{"createdAt":"2017-06-03T02:47:30Z","slug":"aaa_title_1","body":"aaa_body_1","favorited":0,"tagList":null,"favoritesCount":0,"author":{"bio":null,"image":null,"username":"aaa","following":false},"updatedAt":"2017-06-03T02:47:30Z","title":"aaa_title_1","description":"aaa_description_1"}]}

記事取得

成功

root)blender:servant03 ogawanaoto$ curl --verbose -X GET  http://127.0.0.1:8081/api/articles/aaa_title_1
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/articles/aaa_title_1 HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:54:31 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"article":{"createdAt":"2017-06-03T02:47:30Z","slug":"aaa_title_1","body":"aaa_body_1","favorited":0,"tagList":null,"favoritesCount":0,"author":{"bio":null,"image":null,"username":"aaa","following":false},"updatedAt":"2017-06-03T02:47:30Z","title":"aaa_title_1","description":"aaa_description_1"}}

失敗

xxx$ curl --verbose -X GET  http://127.0.0.1:8081/api/articles/aaa_title_x
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8081 (#0)
> GET /api/articles/aaa_title_x HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Sat, 03 Jun 2017 02:54:35 GMT
< Server: Warp/3.2.11.2
< Content-Type: application/json
<
* Connection #0 to host 127.0.0.1 left intact
{"article":null}

Preview版のVisual Studio for Mac の削除

下記を参考にしました。

Uninstalling Visual Studio for Mac | Microsoft Docs

How to uninstall Visual Studio for Mac Preview version?

Uninstalling Visual Studio for Mac | Microsoft Docs

自分の場合は下記で削除しました(それぞれの環境で異なると思いますので参考までです。)。

sudo rm -rf /Applications/Visual\ Studio.app
sudo rm -rf /Applications/Xamarin\ Profiler.app
sudo rm -rf /Developer/MonoTouch
sudo rm -rf /Developer/MonoAndroid
sudo rm -rf /Library/Frameworks/Mono.framework
sudo rm -rf /Library/Frameworks/Xamarin.Mac.framework
sudo rm -rf /Library/Frameworks/Xamarin.Interactive.framework
sudo rm -rf /Library/Frameworks/Xamarin.Android.framework
sudo rm -rf /Library/Frameworks/Xamarin.iOS.framework
sudo rm -rf ~/Library/Caches/VisualStudio
sudo rm -rf ~/Library/Caches/com.microsoft.visual-studio
sudo rm -rf ~/Library/Caches/com.xamarin.fontconfig
sudo rm -rf ~/Library/Logs/VisualStudio
sudo rm -rf ~/Library/Preferences/VisualStudio
sudo rm -rf ~/Library/Preferences/Xamarin
sudo rm -rf ~/Library/Preferences/com.microsoft.visual-studio.plist
sudo rm -rf ~/Library/Saved\ Application\ State/com.microsoft.visual-studio.savedState
sudo rm -rf ~/Library/Application\ Support/XamarinStudio-6.0
sudo rm -rf ~/Library/Developer/Xamarin
sudo rm -rf ~/Library/Developer/Xamarin
sudo rm -rf ~/Library/Logs/VisualStudio/
sudo rm -rf ~/.local/share/Xamarin/
sudo rm -rf /private/var/db/receipts/com.xamarin.*
sudo rm -rf /private/var/db/receipts/xamarin.*
sudo rm -rf ~/.local/share/MonoForAndroid
sudo rm -rf ~/.config/.mono
sudo rm -rf ~/Library/Caches/XamarinInstaller/
sudo rm -rf ~/Library/Logs/XamarinInstaller/

私の場合sudo pkgutil --forgetは必要ありませんでした。

Basic認証のユーザIDとパスワードを削除する方法がわからない

Web検索をしても情報が見つからず。。。

  • Safari
    • バージョン 9.0.3 (10601.4.4)
  • 試したこと
    • メニュー -> Safari -> 環境設定 -> パスワード
      • 該当のサイトの情報なし
    • メニュー -> Safari -> 環境設定 -> 自動入寮
      • 該当のサイトの情報なし
    • メニュー -> Safari -> 環境設定 -> プライバシー -> Cookie と Webサイトのデータ -> 該当サイトの情報削除
      • 削除されていない(もとのユーザIDとパスワードが残ったまま)
    • メニュー -> Safari -> 履歴の消去 -> すべての履歴を消去
      • 削除されていない(もとのユーザIDとパスワードが残ったまま)
    • キーチェーンアクセス -> ログイン
      • 該当のサイトの情報なし
  • 回避策

  • Firefox

    • 52.0.1
  • 試したこと
    • メニュー -> Safari -> 環境設定 -> セキュリティ -> 保存されているログイン情報
      • 該当のサイトの情報なし
    • メニュー -> Safari -> 履歴 -> 最近の履歴を消去 -> すべての履歴を消去 -> 今すぐ消去
      • 消えた。

なぜトーラスやメビウスの輪が重要かわかる動画

トポロジーの入門書をみると、必ずトーラスやメビウスの輪が出てきます。しかし、そもそも論として「なぜトーラスやメビウスの輪を考察することが重要か?」ということはほとんど述べられていないと想います。その疑問に答える一つの回答の動画が下記です。 コメントをみると、"the video of the year"と言っている人もいますね。

www.youtube.com