ubuntuの場合はこう書きます。
$ rename "s/image/photo/;" *.jpegvimのようなsubstitubeですね。
普通に検索したら他のlinuxでのやり方が出てきて、エラーが出ます。
$ rename image photo image*.jpegこれはUbuntuではエラー
Bareword "image" not allowed while "strict subs" in use at (user-supplied code).
$ rename "s/image/photo/;" *.jpegvimのようなsubstitubeですね。
$ rename image photo image*.jpegこれはUbuntuではエラー
Bareword "image" not allowed while "strict subs" in use at (user-supplied code).
:g/\w\s\?$\n[a-z]/ joinとします。
GLib-GIO-Message: 19:21:46.568: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
export GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/
$ vagrant up
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
$ vagrant up --provider=virtualbox
The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The
reason is shown below:
Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:
4.0, 4.1, 4.2, 4.3, 5.0, 5.1
A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.
sudo dpkg -i vagrant_2.2.6_x86_64.deb
# If ~/.inputrc doesn't exist yet: First include the original /etc/inputrcターミナルを再起動すれば適用されています。
# so it won't get overriden
if [ ! -a ~/.inputrc ]; then echo '$include /etc/inputrc' > ~/.inputrc; fi
# Add shell-option to ~/.inputrc to enable case-insensitive tab completion
echo 'set completion-ignore-case On' >> ~/.inputrc
https://askubuntu.com/questions/87061/can-i-make-tab-auto-completion-case-insensitive-in-bash
# format_json.pypprint(data)は結果のstdout出力なので、コメントアウトにしておいてもよいです。
import json
from pprint import pprint
with open('nopretty.json') as infile:
data = json.load(infile)
pprint(data)
with open('pprint.json', "w", encoding="utf-8") as outfile:
json.dump(data, outfile, ensure_ascii=False, indent=4)
function path(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}
for %a in ("%path:;=";"%") do @echo %~a
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS
FileNotFoundError
FileNotFoundError: [Errno 2] No such file or directory: '/app/redash/settings/../../client/dist/index.html'
Traceback (most recent call last)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/werkzeug/middleware/proxy_fix.py", line 232, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.7/site-packages/flask_login/utils.py", line 261, in decorated_view
return func(*args, **kwargs)
File "/app/redash/handlers/static.py", line 32, in index
return render_index()
File "/app/redash/handlers/static.py", line 16, in render_index
response = send_file(full_path, **dict(cache_timeout=0, conditional=True))
File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 629, in send_file
file = open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/app/redash/settings/../../client/dist/index.html'
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
$ docker-compose up -d
Couldn't connect to Docker daemon at http+docker://localhost - is it running?
TheThe authenticity of host '' can't be established.
ECDSA key fingerprint is SHA256:TER0dEslggzS/BROmiE/s70WqcYy6bk52fs+MLTIptM.
Are you sure you want to continue connecting (yes/no)?
$ python -m http.server 8000 --bind 127.0.0.1
http://127.0.0.1:8000/index.html
URL scheme must be "http" or "https" for CORS request.Fetch APIを使っているからhttp通信が必要とのこと。
blog-post.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/WepfD+(以前のサイト名)&m=1
Gehirn Managed Certification Authority - RSA DV | |
組織名 | Gehirn Inc. |
---|---|
部門名 | |
所在地 | Chiyoda-ku / Tokyo / JP |
$ nmap localhost
Starting Nmap 7.01 ( https://nmap.org ) at 2019-11-03 13:57 JST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000060s latency).
Not shown: 993 closed ports
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
631/tcp open ipp
3306/tcp open mysql
5000/tcp open upnp
5432/tcp open postgresql
8888/tcp open sun-answerbook
Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds
sudo netstat -antop | grep 8888
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN 5035/python off (0.00/0/0)
tcp 0 0 127.0.0.1:34432 127.0.0.1:8888 ESTABLISHED 27320/firefox keepalive (11.99/0/0)
Ubuntu 16.04 LTSを使用している場合は(※1),インストールの前にリポジトリのアップデートを行ってください。と書かれていました。
※1
ほとんどいらっしゃらないでしょうが……。
750 時間/月の Linux、RHEL、または SLES t2.micro インスタンスの使用
t2.micro | 1 | 変数 | 1 GiB | EBS のみ | 0.0116USD/時間 |
S3 標準ストレージ | |
---|---|
最初の 50 TB/月 | 0.023USD/GB |
PUT、COPY、POST、または LIST リクエスト | リクエスト 1,000 件あたり 0.0047USD |
GET、SELECT および他のすべてのリクエスト | リクエスト 1,000 件あたり 0.00037USD |
db.t2.micro | 0.028USD |
接続時間 2,250,000 分
メッセージ 500,000 件
レジストリまたはデバイスシャドウのオペレーション 225,000 回
トリガールール 250,000 件、実行アクション 250,000 件
例えば、50 台のデバイスを使うワークロードを実行する場合、無料利用枠では各デバイスを以下のように使用できます。
毎日 24 時間接続
1 日あたり 300 件のメッセージ交換 (メッセージサイズが 5 KB 以下の場合)
1 日あたり 130 回のレジストリまたはデバイスシャドウオペレーションの実行 (レジストリまたはデバイスシャドウのレコードサイズが 1 KB 以下の場合)
アクション 1 件を実行するルールの 1 日あたり 150 件の実行 (処理するメッセージサイズが 5 KB 以下の場合)
# これはNG
git reset --hard ORIG_HEAD
# これはNG
git revert b7cffe03b6e9b05b5b5e429e178e12b6f081f1a8
# これはNG
git revert HEAD
# こんなエラーが出ます
error: Commit b7cffe03b6e9b05b5b5e429e178e12b6f081f1a8 is a merge but no -m opti
on was given.
fatal: revert failed
# グラフィカルにログを見れる(分かり難いかも)この場合、6654f3a が親ですので、これに戻せばいいです。
git log --graph --oneline
# これで親がわかる
git show
commit 89e52f23917d1c4aa1e2e8c587139276014295ea
Merge: 6554f3a be99d45
git revert 6654f3a
git pull origin master
git push origin master
[color]
ui = true
[color "status"]
changed = red bold
untracked = red bold
added = green bold
nobranch = red bold
Options Indexes
IndexOptions Charset=utf-8
pd.date_range(start='1/1/2019', end='1/1/2020', freq='M')
DatetimeIndex(['2019-01-31', '2019-02-28', '2019-03-31', '2019-04-30',
'2019-05-31', '2019-06-30', '2019-07-31', '2019-08-31',
'2019-09-30', '2019-10-31', '2019-11-30', '2019-12-31'],
dtype='datetime64[ns]', freq='M')
となります。
# 日時を作る 2020年1月1日から4月1日までの水曜日の列
d = pd.date_range(start="1/1/2020", end="4/1/20", freq="W-WED")
v = np.linspace(1,10,len(d))
plt.plot(range(d.size), v, 'o')
# ticks, labelを作る
xticks = range(len(d))
xticklabels = [(d[0]+d[0].freq*x).strftime('%-m/%-d') for x in range(len(d))]
# xticksをセット
plt.xticks(xticks, xticklabels)
# x軸の左右のマージンをなくしている
plt.autoscale(True, axis='x', tight=True)
plt.show()
# 日時d の中身
DatetimeIndex(['2020-01-01', '2020-01-08', '2020-01-15', '2020-01-22',
'2020-01-29', '2020-02-05', '2020-02-12', '2020-02-19',
'2020-02-26', '2020-03-04', '2020-03-11', '2020-03-18',
'2020-03-25', '2020-04-01'],
dtype='datetime64[ns]', freq='W-WED')
instantRst -f test.rst
test.rst
WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance.
* Serving Flask app "instant_rst.server" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Some error/exception occurred.
(, TypeError('port must be an integer',), )
port = int(native(port))
if not isinstance(port, int):
raise TypeError("port must be an integer")
from future.utils import native
int(native(port))
Traceback (most recent call last):
File "....py", line 6, in
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
# 現状の名前を変えておく
cd anaconda
mv anaconda anaconda_orig
# sh ファイルをインストールする
wget Anaconda.shchmod a+x Anaconda.sh./Anaconda.sh # install to /opt/wakari/anaconda(Downloadしてから)
sh pathto/Anaconda_hoge.sh
# 新しいanacondaディレクトリに元のディレクトリと同期させる
rsync -a anaconda_orig/ anaconda/
# アップデートする
chmod -R a+rX anacondachown wakari:wakari anacondasudo /anaconda/bin/conda update conda
sudo /anaconda/bin/conda install -f conda-env
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:
- https://repo.continuum.io/pkgs/free/linux-64::path.py==10.0=py36_0
- defaults/linux-64::pycosat==0.6.3=py37h14c3975_0
- defaults/linux-64::pathlib2==2.3.4=py37_0
こういうエラーが延々と続きます。
Package setuptools conflicts for:
wurlitzer -> python[version='>=2.7,<2 .8.0a0="">=3.6,<3 .7.0a0="">=3.7,<3 -="" .8.0a0=""> pip -> wheel -> setuptools
pandas -> numpy[version='>=1.11.3,<2 .0a0="">=1.9,>=1.9.3,<2 -="" .0a0=""> mkl_random[version='>=1.0.2,<2 -="" .0a0=""> numpy-base[version='>=1.0.2,<2 -="" .0a0=""> python[version='>=2.7,<2 .8.0a0="">=3.5,<3 .6.0a0="">=3.6,<3 .7.0a0="">=3.7,<3 -="" .8.0a0=""> pip -> wheel -> setuptools3>3>3>2>2>2>2>2>3>3>2>
<2 .8.0a0=""><3 .7.0a0=""><3 -="" .8.0a0=""><2 .0a0=""><2 -="" .0a0=""><2 -="" .0a0=""><2 -="" .0a0=""><2 .8.0a0=""><3 .6.0a0=""><3 .7.0a0=""><3 -="" .8.0a0="">
3>3>3>2>2>2>2>2>3>3>2>
<2 .8.0a0=""><3 .7.0a0=""><3 -="" .8.0a0=""><2 .0a0=""><2 -="" .0a0=""><2 -="" .0a0=""><2 -="" .0a0=""><2 .8.0a0=""><3 .6.0a0=""><3 .7.0a0=""><3 -="" .8.0a0="">
3>3>3>2>2>2>2>2>3>3>2>
sh pathto/Anaconda_hoge.sh
でAnacondaを再インストールして
cp -ar dir_new dir_old
で全部をコピーします。
import time
from selenium import webdriver
try:
driver = webdriver.Firefox()
time.sleep(3)
except:
quit()
driver.get(target_url)
alert = driver.switch_to_alert()
WebDriverException: Message: User prompt of type promptUserAndPass is not supported
WebDriverException: Message: POST /session/..../alert/credentials did not match a known command
s = (size, size)
%%timeit -n1 -r1 m = np.zeros(s, dtype=np.int32)
mandelbrot_cython(m, size, iterations)
UsageError: Line magic function '%%timeit' not found.
import subprocess
import sys
p = subprocess.Popen(["python", "test.py"],
stdout=sys.stdout)
p.communicate()
Jupyter(ipython)上で実行するとこういうエラーが出ます。---------------------------------------------------------------------------
UnsupportedOperation Traceback (most recent call last)
in ()
3
4 p = subprocess.Popen(["python", "test.py"],
----> 5 stdout=sys.stdout)
6 p.communicate()
/home/shimo/anaconda3/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
665 (p2cread, p2cwrite,
666 c2pread, c2pwrite,
--> 667 errread, errwrite) = self._get_handles(stdin, stdout, stderr)
668
669 # We wrap OS handles *before* launching the child, otherwise a
/home/shimo/anaconda3/lib/python3.6/subprocess.py in _get_handles(self, stdin, stdout, stderr)
1182 else:
1183 # Assuming file-like object
-> 1184 c2pwrite = stdout.fileno()
1185
1186 if stderr is None:
/home/shimo/anaconda3/lib/python3.6/site-packages/ipykernel/iostream.py in fileno(self)
357
358 def fileno(self):
--> 359 raise UnsupportedOperation("IOStream has no fileno.")
360
361 def write(self, string):
UnsupportedOperation: IOStream has no fileno.
# from_commandline.py
import subprocess
import sys
p = subprocess.Popen(["python", "test.py"],
stdout=sys.stdout)
p.communicate()
$ python from_commandline.py
subprocess.Popen(["powershell.exe", ".....ps1"], stdout=sys.stdout)
. ~/.bashrc
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
fig = plt.figure(figsize=(11.69, 8.27))
plt.plot([1,2,3,4], 'o')
plt.show()
#set path
pp = PdfPages("pdf_test.pdf")
# save and close
pp.savefig(fig)
pp.close()
Heads up!
The resizer is a tool for viewing non-Google websites using material design responsive UI breakpoints. The resizer will not ask for account information—you don't need to enter it when using this tool.
45 8 * * * (cd /path/to/file/ && python file.py >> cronlog.log 2>&1)
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler("log/" + __file__ + ".log")
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter(
"%(asctime)s, %(levelname)s, %(message)s", "%Y-%m-%d %H:%M:%S"
)
fh.setFormatter(formatter)
logger.addHandler(fh)
def main():
1 / 0
if __name__ == "__main__":
try:
main()
except:
logger.exception("-" * 10)
ログファイルtestlog.py.logの中身
2021-02-19 18:09:01, ERROR, ----------
Traceback (most recent call last):
File "testlog.py", line 29, in
main()
File "testlog.py", line 23, in main
1 / 0
ZeroDivisionError: division by zero
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
now = datetime.datetime.now()
text = now.strftime("%Y/%m/%d %H:%M:%S\n")
with open('file.txt', 'a') as f:
f.write(text)
今回例として使うのは、時刻をテキストファイルに書き込むスクリプトです。
$ crontab -e
実行の時間やコマンドを記述するための、エディットモードが現れます。$ select-editor
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/vim.basic
4. /usr/bin/vim.gtk
5. /usr/bin/vim.tiny
Jul 14 17:45:01 XXXX CRON[23197]: (user) CMD (python /path/to/crontab_test.py)
30 8 * * * /../../..py >>log.log 2>>err.log
log.logの前の>> は1>> とも書けます。os.path.abspath(os.path.dirname(__file__))
ImportError: No module named numpy
html = urllib.request.urlopen(url).read().decode('utf-8')
AttributeError: 'module' object has no attribute 'request'
numpyがない、rullibでrequestがないとのことです。0 * * * * (. ~/.profile && cd /path/to/file/ && python file.py >> cronlog.log 2>> cronerr.log)これで毎時間0分に、/.profileを読み込んでからディレクトリ移動してpython実行となります。
適用される換算レートは、各地のVisaセンターまたはMastercardセンターから決済センターにデータが到着した時点で、Visaインターナショナル・Mastercardインターナショナルが交換するレートに、弊社が海外利用に係る事務処理コストとして2.00%(税抜き)を加えたものになります。実際にカードをご利用になった日のレートではありませんのでご注意ください。
for ( int i = 0; i < N; i++){
m += i;
}
をfor ( int i = 0; i < N; i++)
m += i;