IntelliJ IDEA系IDEで正規表現置換文字列に$を使う場合
\\$ で $ に置換できる
(\$ ではダメ)
$_POST["hogehoge1"]; $_POST["hogehoge2"]; $_POST["hogehoge11"];
を
$_POST["hugahuga1"]; $_POST["hugahuga2"]; $_POST["hugahuga11"];
に置換したい
検索
\$_POST\["hogehoge(\d\d?)"\];置換
\\$_POST["hugahuga$1"];
Tweetbot3 macOSのURLスキームについて
tweetbot: のURLスキームを指定するとTweetbot2が起動してしまうケースに対応する
Tweetbot3はまだリリースされて間もないせいか軽微なバグや機能縮小が目立つ
なのでTweetbot2をまだ手放せない人も多いと思う
2と3を共存させつつURLスキームを分けたいケースにも対応できる
tweetbot: を com.tapbots.Tweetbot3 に変えれば起動すると言う情報があるがデマ
あるいは既に過去のバージョンで現在の最新版では使えない可能性が極めて高い
確実に起動させる方法はまずURLスキームを調べる方が早いし確実
以下のコマンドをターミナルに入力する(最初の $ は不要)
$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | egrep "bindings.+:" | sort|grep tweetbot
バージョンや環境によって多少内容が変わると思うが,以下のように2行表示される
bindings: tweetbot:, tweetbot.mac:, com.tapbots.tweetbot3mac:, com.tapbots.tweetbot3mac.30200: bindings: tweetbot:, tweetbot.mac:, com.tapbots.tweetbotmac:, com.tapbots.tweetbotmac.25500:
tweetbot3 の文字を含む行がTweetbot3のURLスキームだ
実は1つのアプリでもURLスキームが複数あることもある
これを見ると tweetbot: が競合しているのがわかる
恐らく古い方(Tweetbot2)が優先される仕組みになっているので競合しないモノを使う
tweetbot: を com.tapbots.tweetbot3mac: に書き換えれば解決
これでショートカットやランチャー,ブックマークレットからTweetbot3が起動できる
Tweetbot3のURLスキームで使えるオプションは以下の通り
tweetbot://<screenname>/timelinetweetbot://<screenname>/mentionstweetbot://<screenname>/retweetstweetbot://<screenname>/direct_messagestweetbot://<screenname>/liststweetbot://<screenname>/favoritestweetbot://<screenname>/searchtweetbot://<screenname>/search?query=<text>tweetbot://<screenname>/status/<tweet_id>tweetbot://<screenname>/user_profile/<profile_screenname>tweetbot://<screenname>/posttweetbot://<screenname>/post?text=<text>tweetbot://<screenname>/post?text=<text>&callback_url=<url>&in_reply_to_status_id=<tweet_id>tweetbot://<screenname>/search?query=<text>&callback_url=<url>tweetbot://<screenname>/status/<tweet_id>?callback_url=<url>tweetbot://<screenname>/user_profile/<screenname|user_id>?callback_url=<url>tweetbot://<screenname>/follow/<screenname|user_id>tweetbot://<screenname>/unfollow/<screenname|user_id>tweetbot://<screenname>/favorite/<tweet_id>tweetbot://<screenname>/unfavorite/<tweet_id>tweetbot://<screenname>/retweet/<tweet_id>tweetbot://<screenname>/list/<list_id>?callback_url=<url>
macOSのターミナルでUSBフラッシュメモリを扱う
名前の確認
$ diskutil list /dev/disk0 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *1.0 TB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 999.3 GB disk0s2 3: Apple_Boot Recovery HD 650.0 MB disk0s3 /dev/disk1 (external, physical): #: TYPE NAME SIZE IDENTIFIER 0: USBFlash *63.3 GB disk1
ここでは,USBフラッシュメモリの IDENTIFIER が disk1 となっているのでこれがターゲット名になる
マウント場所を調べる
$ diskutil info disk1 | grep Mount
ファイルコピー
$ cp hogehoge.zip /Volumes/USBFlash
アンマウント(USBフラッシュメモリを安全に抜く為のアレ)
$ diskutil umount /dev/disk1 Vulume USBFlash on disk1 unmounted
JavaScript(jQuery)でロングタップさせる
ロングタップのイベントハンドラはググれば直ぐ見つかるが,
ロングタップをさせる方法がなかったので適当に書いた.
gist73259b8979db7b4f12c28639af011f0d
setTimeout の 800ミリ秒 は 750 とかでも良いかもしれない.
標準の機能として欲しい
unknown error: call function result missing 'value'の対処方法
chromedriverのバージョンが古いのでバージョンアップすると多分直る.
ここから最新版のディレクトリへ移動して,対応OSのzipファイルをダウンロード
https://chromedriver.storage.googleapis.com/index.html
あるいは,ここ
解凍したらmacOSの場合, chromedriver 2 を chromedriver2に改名して
(スペースがファイル名に入ってると不便なので)
/usr/local/bin/ に設置する
~/.bash_profile に export PATH=$PATH:/usr/local/bin を追記
Terminalで source ~/.bash_profile を実行(Terminal再起動でも可)
Terminalで
chromedriver --version
と入力した結果と
chromedriver2 --version
と入力した結果が違う事を確認
また,後者コマンドでエラーやワーニングが出ていない事を確認する.
出る場合,違うバージョンを試してみる(最新過ぎるとワーニングが結構出るかも)
てか,macOSならHomebrewでchromedriver入れた方が管理が楽かも…
以下はPythonでchromedriver使う例
# coding: UTF-8
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
#chrome_options.add_argument("--headless")
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
#wd = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"), chrome_options=chrome_options)
# chromedriverのバージョンが古い所為で上手く動かなかったので新しいバージョンを指定してる
wd = webdriver.Chrome(executable_path="chromedriver2", chrome_options=chrome_options)
wd.set_window_size(1020,680)
wd.get('http://www.google.co.jp')
Selenium webdriverをChrome headless modeでPythonから使う
PhantomJSがSeleniumのサポートをやめてしまったため,
これからはヘッドレスブラウザはFireFoxかChromeになるみたいです.
macOSのGoogle Chrome Canaryだと起動場所は
/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary
になります.
Aliasに登録しても良いしコードにゴリゴリパスを書いても良いです.
起動オプションで --headless を付ければTerminalからヘッドレスブラウザが立ち上がります.
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --headless https://www.google.co.jp
*Terminal等から実行する場合,スペースの前に\ を忘れないように!
# coding: UTF-8
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
wd = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"), chrome_options=chrome_options)
wd.set_window_size(1020,680)
wd.get('http://www.google.co.jp')
time.sleep(3)
wd.save_screenshot("_____screenshot.png")
wd.quit()