axiosのdebug
axios.interceptors.request.use(request => { console.log('Starting Request: ', request); return request; }); axios.interceptors.response.use(response => { console.log('Response: ', response); return response; });
Selenimuのsession not created error と TCP connection error
問題
ひさしぶりにSeleniumを使うと下記のエラー
session not created: This version of ChromeDriver only supports Chrome version 103 (Selenium::WebDriver::Error::SessionNotCreatedError) Current browser version is 110.0.5481.177 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
原因
ChromeDriverとMacのchromeブラウザのバージョン違い
解決方法
$ brew upgrade chromedriver
下記から手動で落としているサイトもあるが、自分はbrewで管理しているので上記コマンドでOK
upgrade後実行しても、
Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515) (Errno::ECONNREFUSED)
というエラーが出るので、 Macの「システム環境設定」→「セキュリティとプライバシー」→「一般」タブ ダウンロードしたアプリケーションの実行許可を「このまま許可」
react_railsのTips(随時更新)
画像読み込み
config/webpacker.ymlに下記追加
resolved_paths: ['app/assets/images']
jsファイル
import SampleImage from 'sample.png';
<img src={SampleImage} />
expoでAdMobを導入する
使用するライブラリ
導入手順
インストール
$ expo install expo-ads-admob
Front
import { Platform } from 'react-native'; import { AdMobBanner } from 'expo-ads-admob';
const bannerError = () => { console.log("AdMob Fail error") }
<View style={styles.admobBanner}> <AdMobBanner adUnitID={ __DEV__ ? "ca-app-pub-3940256099942544/2934735716" // テスト広告 : Platform.select({ ios: "ca-app-pub-3940256099942544/2934735716" , // iOS android:"ca-app-pub-3940256099942544/2934735716" , // android }) } onDidFailToReceiveAdWithError={bannerError} /> </View>
style
admobBanner: { width:'100%', position:'absolute', bottom: 0, backgroundColor: '#fff', }
テスト用ID
参考サイト
市区町村以下のデータの整形方法
select name, deleted_at from m_area_4 where name like '%ビル%' select name, deleted_at from m_area_4 where name like '%タワー%' select name, deleted_at from m_area_4 where name like '%ビルを除く%' select name, deleted_at from m_area_4 where name like '%タワーを除く%' update m_area_4 set deleted_at='2019-11-22 06:18:47' where name like '%タワー%' update m_area_4 set deleted_at='2019-11-22 06:18:47' where name like '%ビル%'
gulp導入メモ
$ npm init -y $ npm install -D gulp gulp-sass gulp-sass-glob sass $ npx -p touch nodetouch gulpfile.js
bitnamiでwordpressが落ちる時のMySQL php-fpm周りのチューニングメモ
ログ内容
[26-Sep-2019 12:59:26] WARNING: [pool wordpress] server reached pm.max_children setting (5), consider raising it [26-Sep-2019 13:00:55] WARNING: [pool wordpress] server reached pm.max_children setting (5), consider raising it [26-Sep-2019 14:04:56] WARNING: [pool wordpress] server reached pm.max_children setting (5), consider raising it [26-Sep-2019 21:29:14] WARNING: [pool wordpress] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 2 idle, and 16 total children [26-Sep-2019 21:29:15] WARNING: [pool wordpress] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 3 idle, and 18 total children [26-Sep-2019 21:29:16] WARNING: [pool wordpress] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 19 total children [26-Sep-2019 21:30:50] WARNING: [pool wordpress] server reached pm.max_children setting (25), consider raising it
エラーログの場所
$ /opt/bitnami/php/var/log/php-fpm.log $ /opt/bitnami/mysql/data/mysqld.log $ /var/log/syslog
設定ファイル
$ /opt/bitnami/php/etc/php.ini $ /opt/bitnami/apps/wordpress/conf/php-fpm/php-settings.conf $ /opt/bitnami/php/etc/php-fpm.conf $ /opt/bitnami/mysql/bitnami/my.conf
再起動コマンド
$ sudo /opt/bitnami/ctlscript.sh restart apache $ sudo /opt/bitnami/ctlscript.sh restart php-fpm $ sudo /opt/bitnami/ctlscript.sh restart mysql
確認コマンド
$ free $ free -g $ top #負荷平均わかる
プロセス数確認
$ ps -ef | grep 'php-fpm: pool' | wc -l
$ ps ax | grep mysql
負荷テスト
$ ab -n 100 -c 100 http://3.113.234.85.xip.io/
n : リクエストの総数を数値で指定 c : 同時に発行するリクエストの数を数値で指定
参考サイト
背景がボーダー(とか単色ではない)の吹き出し
こんなやつ
・レスポンシブでもデザインの背景に切れ目が入らない
・複数行でも対応できる を満たす実装
html
<div class="title">背景がボーダーの吹き出しのタイトル</div> <br><br><br> <div class="title">背景がボーダーの吹き出しのタイトル改行が入っても大丈夫です。<br>背景がボーダーの吹き出しのタイトル改行が入っても大丈夫です。<br>背景がボーダーの吹き出しのタイトル改行が入っても大丈夫です。</div>
.title { position: relative; padding: 16px 10px 35px; font-weight: bold; text-align: center; background-image: linear-gradient(-45deg, #Fe4d40 25%, #ff978a 25%, #ff978a 50%, #Fe4d40 50%, #Fe4d40 75%, #ff978a 75%, #ff978a); background-repeat: repeat; background-position: center; background-size: 8px 8px; } .title::before, .title::after { position: absolute; content: ""; display: block; bottom: 0; border-bottom: 20px solid white; width: 50%; box-sizing: border-box; } .title::before { left: 0; border-right: 20px solid transparent; } .title::after { right: 0; border-left: 20px solid transparent; }
Railsにnpmでfullcalendarを導入
課題
- gemもあるけど公式から入れたい
- jqueryは未導入
方法
$ npm install jquery moment fullcalendar
application.jsに以下を追加
//= require jquery/dist/jquery //= require moment/moment //= require fullcalendar/dist/fullcalendar //= require fullcalendar/dist/locale/ja
$(document).ready(function() { $('#calendar').fullCalendar({ // オプションはここに追加 }) });
application.scssに以下を追加
@import 'fullcalendar/dist/fullcalendar';
表示させたいviewファイルに追加
#calendar
サーバー再起動すれば動く
Docs
MacbookをMojaveにアップデートしたらbundle installでこける
問題
MacbookをMojave 10.14にアップデートしたらbundle installでこける
(略) An error occurred while installing ffi (1.9.25), and Bundler cannot continue. Make sure that `gem install ffi -v '1.9.25' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: selenium-webdriver was resolved to 3.14.0, which depends on childprocess was resolved to 0.9.0, which depends on ffi
解決方法
$ sudo xcode-select --reset
今まで入ってたはずなのに
- パッケージのインストール
$ open /Library/Developer/CommandLineTools/Packages
でFinderにインストール用のパッケージがあるのでダブルクリックでインストール