There are tons of these examples for
format()
, like thousand separator and so. Go for it and explore more.Having local git repository server is easy enough by using docker and open source git lab project:
docker pull gitlab/gitlab-ce
#gitlab #open_source #docker
docker pull gitlab/gitlab-ce
#gitlab #open_source #docker
Tech C**P
Having local git repository server is easy enough by using docker and open source git lab project: docker pull gitlab/gitlab-ce #gitlab #open_source #docker
After pulling image into docker repository run the image using the command below:
Reference:
https://docs.gitlab.com/omnibus/docker/README.html
#gitlab #docker #image #docker_run
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
Reference:
https://docs.gitlab.com/omnibus/docker/README.html
#gitlab #docker #image #docker_run
Communicate by Telegram bot API by using the most used python library:
Send file, message, audio, image and reply easily by using telegram python library:
https://github.com/python-telegram-bot/python-telegram-bot
#telegram #bot #python #library
python-telegram-bot
.Send file, message, audio, image and reply easily by using telegram python library:
https://github.com/python-telegram-bot/python-telegram-bot
#telegram #bot #python #library
GitHub
GitHub - python-telegram-bot/python-telegram-bot: We have made you a wrapper you can't refuse
We have made you a wrapper you can't refuse. Contribute to python-telegram-bot/python-telegram-bot development by creating an account on GitHub.
Tech C**P
Communicate by Telegram bot API by using the most used python library: python-telegram-bot. Send file, message, audio, image and reply easily by using telegram python library: https://github.com/python-telegram-bot/python-telegram-bot #telegram #bot #python…
A complete reference to the documentation on
https://python-telegram-bot.readthedocs.io/en/stable/
#reference #telegram #bot #readthedocs #python
readthedocs
:https://python-telegram-bot.readthedocs.io/en/stable/
#reference #telegram #bot #readthedocs #python
You may have used
If you want to query, create table, create partition and all the different operations on a database you can do now by using the below site without ever making a big mistake on your system:
https://www.db-fiddle.com/
#mysql #postgresql #database #fiddle #dbfiddle
JSFiddle
to interactively write JS code and get instant result. It is good to note that there is one for Database (MySQL, PostgreSQL, SQLite)!If you want to query, create table, create partition and all the different operations on a database you can do now by using the below site without ever making a big mistake on your system:
https://www.db-fiddle.com/
#mysql #postgresql #database #fiddle #dbfiddle
Db-Fiddle
DB Fiddle - SQL Database Playground
An online SQL database playground for testing, debugging and sharing SQL snippets.
When you commit to git, then you push and get rejected:
To prevent merging with your local and making your git history filthy, reset head to the latest commit (head~1):
Now git pull and the commit again and push. The world is cleaner now.
#git #reset_head #merge #repository
$ git push
To my_repo:~/my_project.git
! [rejected] dev -> dev (fetch first)
error: failed to push some refs to 'my_repo:~/my_project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
To prevent merging with your local and making your git history filthy, reset head to the latest commit (head~1):
$ git reset HEAD~1
Unstaged changes after reset:
M another_file_here.py
M some_file_here.py
Now git pull and the commit again and push. The world is cleaner now.
#git #reset_head #merge #repository
If you are working with #Cement, #Flask or other python frameworks that do not give ODM (Object Document Mapper) out of the box, you can use MongoEngine for MongoDB.
It has all the capabilities that you can almost imagine for an ODM to define schema and apply restrictions to it. You'll hear more about it later.
https://github.com/MongoEngine/mongoengine
#mongodb #mongoengine #ODM #python #ORM
It has all the capabilities that you can almost imagine for an ODM to define schema and apply restrictions to it. You'll hear more about it later.
https://github.com/MongoEngine/mongoengine
#mongodb #mongoengine #ODM #python #ORM
GitHub
GitHub - MongoEngine/mongoengine: A Python Object-Document-Mapper for working with MongoDB
A Python Object-Document-Mapper for working with MongoDB - MongoEngine/mongoengine
Merging 2 wave files using scipy, audiolab:
import audiolab, scipy
a, fs, enc = audiolab.wavread('file1.wav')
b, fs, enc = audiolab.wavread('file2.wav')
c = scipy.vstack((a,b))
audiolab.wavwrite(c, 'file3.wav', fs, enc)
Tech C**P
any and all in python #any #all #python
In couchDB you have to plan for views beforehand. As you go along, data will grow and it would be a cumbersome task to change views and wait for data reindexing.
In order to implement a view in couchDB you write JS code. For writing view you have to at least have a map function (reduce can be ignored).
An example of a view to get users by their corresponding uid:
Here we pass
#view #couchdb
In order to implement a view in couchDB you write JS code. For writing view you have to at least have a map function (reduce can be ignored).
An example of a view to get users by their corresponding uid:
function(doc) {
if (doc.type == "user")
emit(doc.user_id, doc);
}
Here we pass
doc
which is database documents to our function and check if type of document is user (type field is added it is not related to couchDB view), we will emit (let's say return) user document. It's key is user_id and it's value will be user document.#view #couchdb
You can create different hosts on your ssh config (~/.ssh/config) in order to prevent typing username and password all time and speedup working with remote servers.
A sample host on ssh config:
Now save the config file and exit. You can now ssh to server as below:
INSTEAD OF USING:
#linux #sysadmin #ssh
A sample host on ssh config:
Host your_server_name
HostName 192.168.12.182
User my_user_name_on_remote_server
Port 22
IdentityFile ~/.ssh/id_rsa
Now save the config file and exit. You can now ssh to server as below:
ssh your_server_name
INSTEAD OF USING:
ssh my_user_name_on_remote_server@192.168.12.182
#linux #sysadmin #ssh
InfluxDB is time series database that can store huge amount of data for different metrics like CPU, RAM, Storage usage. If you have Grafana in place, one of the databases that would work with it is InfluxDB.
If you setup InfluxDB you can type
Databases in InfluxDB are called well Database :) and tables are called
You are now on
Yes, it is almost similar to MySQL. The main point of such a database is to use monitoring tool in place and push metrics into influxDB, then make graphs by using Grafana.
#influxdb #grafana #measurement #time_series_db
If you setup InfluxDB you can type
influx
and hit enter to see InfluxDB console (like MySQL):infladmin@my_host:~$ influx
Connected to http://localhost:8086 version 1.2.2
InfluxDB shell version: 1.2.2
Databases in InfluxDB are called well Database :) and tables are called
Measurement
. To see list of all databases and make a database active do as below:> SHOW DATABASES
name: databases
name
----
_internal
my_db
monitoring
some_other_db
> USE my_db
Using database my_db
You are now on
my_db
database. To display list of measurements (table) and query it:> SHOW MEASUREMENTS
name: measurements
name
----
cpu_stat
mem_stat
> SELECT * FROM cpu_stat LIMIT 2;
name: cpu_stat
time my_tag metric value
---- ----------- ------ -----
1503999476000000000 CPU_CORE3 CORES 0
1503999476000000000 total 16
Yes, it is almost similar to MySQL. The main point of such a database is to use monitoring tool in place and push metrics into influxDB, then make graphs by using Grafana.
#influxdb #grafana #measurement #time_series_db
Display line numbers in vim. If a file is open with vim press ESC (if you are in insert mode) and then press colon (:) and type:
The above command will print line numbers in front of each line.
Now if you want to hide line numbers you just need to press colon again and type:
#vim #tricks #line_number #nonumber #number
set number
The above command will print line numbers in front of each line.
Now if you want to hide line numbers you just need to press colon again and type:
set nonumber
#vim #tricks #line_number #nonumber #number
Flask make_response():
Sometimes it is necessary to set additional headers in a view. Because
views do not have to return response objects but can return a value that
is converted into a response object by Flask itself, it becomes tricky to
add headers to it. This function can be called instead of using a return
and you will get a response object which you can use to attach headers.
If view looked like this and you want to add a new header::
def index():
return render_template('index.html', foo=42)
You can now do something like this::
def index():
response = make_response(render_template('index.html', foo=42))
response.headers['X-Parachutes'] = 'parachutes are cool'
return response
This function accepts the very same arguments you can return from a
view function. This for example creates a response with a 404 error
code::
response = make_response(render_template('not_found.html'), 404)
The other use case of this function is to force the return value of a
view function into a response which is helpful with view
decorators::
response = make_response(view_function())
response.headers['X-Parachutes'] = 'parachutes are cool'
Internally this function does the following things:
- if no arguments are passed, it creates a new response argument
- if one argument is passed, :meth:`flask.Flask.make_response`
is invoked with it.
- if more than one argument is passed, the arguments are passed
to the :meth:`flask.Flask.make_response` function as tuple.
#flask #make_response #helper #header #response
Sometimes it is necessary to set additional headers in a view. Because
views do not have to return response objects but can return a value that
is converted into a response object by Flask itself, it becomes tricky to
add headers to it. This function can be called instead of using a return
and you will get a response object which you can use to attach headers.
If view looked like this and you want to add a new header::
def index():
return render_template('index.html', foo=42)
You can now do something like this::
def index():
response = make_response(render_template('index.html', foo=42))
response.headers['X-Parachutes'] = 'parachutes are cool'
return response
This function accepts the very same arguments you can return from a
view function. This for example creates a response with a 404 error
code::
response = make_response(render_template('not_found.html'), 404)
The other use case of this function is to force the return value of a
view function into a response which is helpful with view
decorators::
response = make_response(view_function())
response.headers['X-Parachutes'] = 'parachutes are cool'
Internally this function does the following things:
- if no arguments are passed, it creates a new response argument
- if one argument is passed, :meth:`flask.Flask.make_response`
is invoked with it.
- if more than one argument is passed, the arguments are passed
to the :meth:`flask.Flask.make_response` function as tuple.
#flask #make_response #helper #header #response