[PR] カード 比較

bundle update mimemagic

Fetching gem metadata from https://rubygems.org/.......
Your bundle is locked to mimemagic (0.3.3), but that version could not be found
in any of the sources listed in your Gemfile. If you haven't changed sources,
that means the author of mimemagic (0.3.3) has removed it. You'll need to update
your bundle to a version other than mimemagic (0.3.3) that hasn't been removed
in order to install.


こんなのが出た時は

bundle update mimemagic

read more

Rails6 select2 導入

$ yarn add tempusdominus-bootstrap-4
$ yarn add jquery
$ yarn add jquery-ui
$ yarn add select2

・app/javascript/packs/application.js
require('jquery')
require('jquery-ui')
import 'bootstrap'
import "../stylesheets/application"
import 'jquery-ui/themes/base/core.css';
import 'jquery-ui/themes/base/menu.css';
import 'jquery-ui/themes/base/autocomplete.css';
import 'jquery-ui/themes/base/theme.css';
import 'select2/dist/css/select2.css';


・app/javascript/stylesheets/application.scss
@import 'bootstrap';
@import "~tempusdominus-bootstrap-4/src/sass/tempusdominus-bootstrap-4";


<select id="multiple" class="multiple" multiple="multiple">
<option value="value1">value1</option>
<option value="value2">value2</option>
<option value="value3">value3</option>
<option value="value4">value4</option>
<option value="value5">value5</option>
</select>


$(function () {
$('#multiple').select2({
placeholder: 'Please Select',
allowClear: true,
dropdownAutoWidth: true,
width: 'auto',
multiple: true
})
});

解除する場合は
$('#multiple').val(null).trigger('change');

read more

Ruby Devise 最終アクティブ時間の記録

Devise モデルじゃなくてもいいかもしれないけど・・・

カラム last_active_at datetime型をテーブルに追加


こんなふうにしてアクティ時間を更新させたいタイミングで touch メソッドを呼ぶ

class ApplicationController
before_filter :record_user_activity

private

def record_user_activity
if current_user
current_user.touch :last_active_at
end
end
end

read more

Apache Django連携

/etc/httpd/conf.d/django.conf


WSGIScriptAlias / path to project/project/wsgi.py
WSGIPythonPath path to project
WSGIPassAuthorization On

<Directory path to project/project/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Alias /static/ /path to project/app/static/
<Directory path to project/app/static>
Require all granted
</Directory>

read more

Django Basic 認証実装

# pip install wsgi-basic-auth
# pip install django_environ

.env ファイル作成してid, password を記述
WSGI_AUTH_CREDENTIALS=id:password

wsgi.py 修正

import os
from django.core.wsgi import get_wsgi_application
from wsgi_basic_auth import BasicAuth
import environ
env = environ.Env()
env.read_env('path to .env')

#application = get_wsgi_application()
application = BasicAuth(get_wsgi_application())

Apache 側には WSGIPassAuthorization On をつける

read more

ModuleNotFoundError: No module named 'six'

# firewall-cmd --add-port=8000/tcp --zone=public --permanent
Traceback (most recent call last):
File "/usr/bin/firewall-cmd", line 31, in
from firewall.client import FirewallClient, FirewallClientIPSetSettings, \
File "/usr/lib/python3.6/site-packages/firewall/client.py", line 29, in
import slip.dbus
File "/usr/lib/python3.6/site-packages/slip/dbus/__init__.py", line 8, in
from . import service
File "/usr/lib/python3.6/site-packages/slip/dbus/service.py", line 30, in
from six import with_metaclass

ModuleNotFoundError: No module named 'six'

こんなのが出た場合
cp /usr/local/lib/python3.6/site-packages/six.py /usr/lib/python3.6/site-packages/

read more

Python plotlyでのグラフPDF出力 前準備

plotly, psutil, electron, orca が必要

# pip install plotly psutil
# npm install -g electron@1.8.4 orca --unsafe-perm=true --allow-root


Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/.electron'
対策のため上記オプションをつけること

read more

Python Apache 連携

# dnf -y install python3-mod_wsgi
# pip install mod-wsgi
# pip install mod-wsgi-httpd
# vi /etc/httpd/conf/httpd.conf

AddHandler wsgi-script .py
AddHandler wsgi-script .wsgi


実行ディレクトリは
Options +ExecCGI にしておくこと

# systemctl restart httpd.service

こんなのをアップして確認
test.py

def application(environ, start_response):
status = '200 OK'
html = '<html>\n' \
'<body>\n' \
'<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n' \
'WSGI テストページ\n' \
'</div>\n' \
'</body>\n' \
'</html>\n'.encode("utf-8")
response_header = [('Content-type','text/html')]
start_response(status,response_header)
return [html]

read more

Swift Socket.IO サーバーに接続できない場合

node,js の sockect.io のバージョンが原因であるかもしれない。

3系よりも2系で試してみる。

npm install express@4.16.3
npm install socket.io@2.1.0

https://stackoverflow.com/questions/65394238/socket-io-client-swift-does-not-connect-to-nodejs-socket-io-server

read more

An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.4.10' --source 'https://rubygems.org/'` succeeds before bundling.

bundle install できない場合

$ brew info openssl
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"
$ bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"

$ bundle install --path vendor/bundle

read more

Recent entry

Search

Tag Cloud

Page Top