Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
How to store Emojis like 🙄 in MySQL database?

https://mathiasbynens.be/notes/mysql-utf8mb4

#mysql #emoji #charset #database
If you have Axigen mail server, you probably know that it does not have any db backend and just logs everything into some files usually in the below path:

/var/opt/axigen/log


There is a script that you can use to parse these logs and see overall behaviour of your mail server and common errors that happen on your server.

To download the log-parser script head over to axigen link below:
- http://www.axigen.com/mail-server/download-tool.php?tool=log-parser.tar.gz

After downloading and extracting it, move the script and its data folder into your mail server. To run it first make sure it is executable:

chmod +x axigen-log-parser.sh


Now to run it you need to give a parameter to script like parse:

sudo ./axigen-log-parser.sh parse /var/opt/axigen/log/

The above script will generate some files in /var/log/axi-parser/. CD into that path and check the results.

Actions supported are parse, maillog, split, trace and clean.

#mail #mail_server #axigen #log_parser #log
ngxtop - real-time metrics for nginx server (and others)

ngxtop parses your nginx access log and outputs useful, top-like, metrics of your nginx server. So you can tell what is happening with your server in real-time. ngxtop tries to determine the correct location and format of nginx access log file by default, so you can just run ngxtop and having a close look at all requests coming to your nginx server. But it does not limit you to nginx and the default top view. ngxtop is flexible enough for you to configure and change most of its behaviours. You can query for different things, specify your log and format, even parse remote Apache common access log with ease. See sample usages below for some ideas about what you can do with it.


Installation:

pip install ngxtop


It is easy as pie, you just need to run it and look at the results:

nxtop

It will reports for total requests served and total bytes sent to client and will report requests based on their status code. At the pictures in the next post you can see sample usages.

#linux #nginx #top #nxtop #web_server
View top source IPs of clients #nxtop
Default output #nxtop
List 4xx or 5xx responses together with HTTP referer #nxtop
Did you know you can syntax highlight your codes in google docs using an add on?

This is code block! An addon that adds syntax highlighting to your documents. In order to download it, go to Add-ons menu in google docs and click on Get add-ons. Search for code block and install it.

After installation Code Block option will be added to Add-ons menu. Click it and hit Start. Now you will have a great syntax highlighting right in your toolbox. :)

Happy syntax highlighting! :D

#google #code #syntax_highlight #code_block #addon #google_doc
How to create a network scanner in python using socket?

socket library is used to work with network and here we use it to simulate a network scanner.

A network scanner iterates over all the possible IP addresses on the network and for every IP it tries to connect to one of the ports. If the connection was successful (ACK received) we know that this host is available at the given IP address. This is the philosophy of a network scanner.

For now we just try to connect to a specific port of the server and leave the other parts to you to iterate and check the status:

import socket

addr = '172.16.132.20'
port = 27017

socket_obj = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
socket.setdefaulttimeout(1)
result = socket_obj.connect_ex((addr,port))
print result
socket_obj.close()

The above code connects to the given address:port and returns a status code. If returned code is 0 then the
port is open otherwise the port is probably blocked/closed.

#python #socket #network #tcp #tcp_scanner
PostgreSQL: Up and Running: A Practical Guide to the Advanced Open Source Database #ebook #book #pdf
How to use regex in MongoDB?

I had a query that I had to find records that their numbers does not start with +98. For regex you need to use $regex in MongoDB find query:

db.my_collection.find({'destination_number': {'$regex': '^(?!\\+98)(\\+.*).*$'}})

The above regex says that the number should not start with +98 and then it says that it should start with + (to ignore non-standard numbers, strings, etc).

NOTE: ?! is used to negate the regex inside of parenthesis.

#mongodb #mongo #regex
What is CDN?

CDN is short for content delivery network. A content delivery network (CDN) is a system of distributed servers (network) that deliver pages and other Web content to a user, based on the geographic locations of the user, the origin of the webpage and the content delivery server.

This service is effective in speeding the delivery of content of websites with high traffic and websites that have global reach. The closer the CDN server is to the user geographically, the faster the content will be delivered to the user. CDNs also provide protection from large surges in traffic.


What are the benefits of using a CDN?

- Improving website load times
- Reducing bandwidth costs
- Increasing content availability and redundancy
- Improving website security


Telegram is an example of those services that use CDN in order to serve public channels media to end users with faster pace.

#cdn #content_delivery_network #telegram