Array and loop in bash script
To define an array you can use a structure like below, be careful that we don't use comma in between:
dbs=( 'test1' 'test2' 'test3' )
Now to loop over the array elements use
for
:for your_db in ${dbs[@]}
do
echo $your_db
done
This is it!
#bash #scripting #for #loop #array
How to check python code correctness?
- http://pychecker.sourceforge.net/
It's usage:
Read more about the provided options in the provided link.
#python #pychecker #compiler
pychecker
is the man! :)- http://pychecker.sourceforge.net/
It's usage:
pychecker [options] file1.py file2.py ...
Read more about the provided options in the provided link.
#python #pychecker #compiler
Tech C**P
There is a mechanism in firefox that you can record some user activities on your site in order to test it from 0 to hero! Katalon Recorder (Selenium IDE for Firefox 55+) is an add-on that can be used to record tests on firefox and export it into a file.…
Previously we have talked about
that google changes ids per login, and sometimes per refresh! Therefore
Some examples:
Locate the h2 tag element that has text matching exactly
Locate any element that contains the text
Locate the a tag element that has the ID starting with
#katalon #xpath
Katalon
. Today I had a problem that I couldn't record user flow in Google Sheets
. The problem wasthat google changes ids per login, and sometimes per refresh! Therefore
Katalon
failed to replay the recorded suite.Katalon
uses xpath
in order to follow deep inner divs and elements and records those elements hierarchy. To deal with these challenges, automation testers should not set fixed XPaths for elements in test cases, but instead scripting XPaths dynamically based on certain patterns.Some examples:
Locate the h2 tag element that has text matching exactly
Make Appointment
:.//h2[text()=’Make Appointment’]
Locate any element that contains the text
Login
://*[contains(text(),’Login’)]
Locate the a tag element that has the ID starting with
LoginPanel
://a[starts-with(@id=’LoginPanel’)]
#katalon #xpath
If you have space problems on a server that hosts
In order to compress data on a table:
The output in my case squeezed data 4X:
After compression:
#mysql #innodb #compression #alter #row_format #compressed
MySQL
database, it's good idea to use compression. Make sure you are using InnoDB
storage engine.In order to compress data on a table:
alter table YOUR_DB_NAME.YOUR_TABLE_NAME ROW_FORMAT=COMPRESSED;
The output in my case squeezed data 4X:
ls -lh users.ibd | awk '{print $5}'
16G
After compression:
ls -lh users.ibd | awk '{print $5}'
3.9G
NOTE:
you have to use innodb_file_per_table
in your configuration. We have previously talked about this procedure step by step.#mysql #innodb #compression #alter #row_format #compressed
In
Now if you want to set an attribute called name on
With a little bit of code you can automatically get data from a source and set dynamic attributes.
#python #setattr
Python
you can use setattr
to set an attribute on a class. Let's say we have a very simple class like below:class User:
def register(self, key, val):
setattr(self, key, val)
Now if you want to set an attribute called name on
User
class:>>> user = User()
>>> user.register('name', 'alireza')
>>> user.name
'alireza'
With a little bit of code you can automatically get data from a source and set dynamic attributes.
#python #setattr
What is
Returns a list of tuples, where each tuple contains the i-th element from each of the argument sequences. The returned list is truncated in length to the length of the shortest argument sequence.
So the syntax is:
The real world example:
If number of elements differ:
As you can see from above, list is truncated to the length of the shortest argument sequence
You can also use
The output:
#python #zip #unzip #iterators
zip
function in Python
?zip
function gets iterables
as input and returns a tuple as output, it actually aggregates data:zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]
Returns a list of tuples, where each tuple contains the i-th element from each of the argument sequences. The returned list is truncated in length to the length of the shortest argument sequence.
So the syntax is:
zip(*iterables)
The real world example:
numberList = [1, 2, 3]
strList = ['one', 'two', 'three']
# Two iterables are passed
result = zip(numberList, strList)
{(2, 'two'), (3, 'three'), (1, 'one')}
If number of elements differ:
numbersList = [1, 2, 3]
numbersTuple = ('ONE', 'TWO', 'THREE', 'FOUR')
result = zip(numbersList, numbersTuple)
print(set(result))
{(2, 'TWO'), (3, 'THREE'), (1, 'ONE')}
As you can see from above, list is truncated to the length of the shortest argument sequence
numbersList
.You can also use
zip
to actually unzip
data:coordinate = ['x', 'y', 'z']
value = [3, 4, 5, 0, 9]
result = zip(coordinate, value)
resultList = list(result)
print(resultList)
c, v = zip(*resultList)
print('c =', c)
print('v =', v)
The output:
[('x', 3), ('y', 4), ('z', 5)]
c = ('x', 'y', 'z')
v = (3, 4, 5)
#python #zip #unzip #iterators
If your
#python #pycharm #file_types #syntax_highlighting
pyCharm
does not recognize specific python files as a Python
file and does not provide syntax highlighting for you, you need to navigate to File > Settings > Editor > File Types > Text
and Under Registered Patterns, you can see the new myfilename.py
in the list. Remove it from the list with the - button and click OK at the end.#python #pycharm #file_types #syntax_highlighting
How to start a jetbrains license server on your own host using
There are many env variables you can set as
`80 : Jetbrains License Server HTTP port
- https://github.com/crazy-max/docker-jetbrains-license-server
#docker #license_server #jetbrains #crazymax
Docker
:docker run -d -p 8000:80 --name jetbrains-license-server \
-e TZ="Europe/Paris" \
-e JLS_VIRTUAL_HOSTS=jetbrains-license-server.example.com \
-v $(pwd)/data:/data \
crazymax/jetbrains-license-server:latest
There are many env variables you can set as
JLS_VIRTUAL_HOSTS
above:TZ : The timezone assigned to the container (default UTC)
JLS_VIRTUAL_HOSTS : Virtual hosts where license server will be available (comma delimited for several hosts)
JLS_CONTEXT : Context path used by the license server (default /)
JLS_ACCESS_CONFIG : JSON file to configure user restrictions (default /data/access-config.json)
JLS_STATS_RECIPIENTS : Reports recipients email addresses for stats (comma delimited)
JLS_REPORT_OUT_OF_LICENSE : Warn about lack of licenses every hour following the percentage threshold (default 0)
JLS_SMTP_SERVER : SMTP server host to use for sending stats (stats disabled if empty)
JLS_SMTP_PORT : SMTP server port (default 25)
JLS_SMTP_USERNAME : SMTP username (auth disabled if empty)
JLS_SMTP_PASSWORD : SMTP password (auth disabled if empty)
JLS_STATS_FROM : From address for stats emails
JLS_STATS_TOKEN : Enables an auth token for the stats API at /reportApi (HTTP POST)
Volumes:
/data
: Contains registration data and configurationPorts:
`80 : Jetbrains License Server HTTP port
Github
removes repos related to crack
and license, copy or download content from the below link:- https://github.com/crazy-max/docker-jetbrains-license-server
#docker #license_server #jetbrains #crazymax
GitHub
GitHub - crazy-max/docker-jetbrains-license-server: JetBrains License Server Docker image
JetBrains License Server Docker image. Contribute to crazy-max/docker-jetbrains-license-server development by creating an account on GitHub.
If you use
you can connect to snmp on the other side (firewall issues), or to find a specific
For this you can use
#snmp #snmpd #snmpwalk
Icinga2
you are difinitely familiar with snmp
. There are times that you need to debug the system. For exampe to see ifyou can connect to snmp on the other side (firewall issues), or to find a specific
mib
.For this you can use
snmpwalk
as below:snmpwalk -Os -c YOUR_COMMUNITY_STRING -v 1 YOUR_SNMP_IP_ADDRESS
NOTE:
this command is ran from Icinga2
server.NOTE:
snmp should be installed on server you want to monitor: apt-get install snmpd
#snmp #snmpd #snmpwalk
Sharing a piece of code in order to get a solution is a way everone follows, but the difference is about people who shares a piece of code professionally and those who just takes a picture from the screen in front! You should be happy in case the artistic photo is straight otherwise you have to tilt your head :)))
One of the greatest tools to do this job is
Head over to link below to and use websites similar to the below website to share codes, never ever ever share a code with a photo taken from screen. This shows how negligible the time is for you and the person you're asking from, `cause it takes much more time to see what is on the screen:
- https://codeshare.io/
#codeshare #codeshare_io
One of the greatest tools to do this job is
codeshare
. ou paste your code there and other people involve into the code concurrently with you.Head over to link below to and use websites similar to the below website to share codes, never ever ever share a code with a photo taken from screen. This shows how negligible the time is for you and the person you're asking from, `cause it takes much more time to see what is on the screen:
- https://codeshare.io/
#codeshare #codeshare_io
Tech C**P
There are times you run a command in cronjob in a specific interval. Let's say you run that command every hour. If your command copies a huge file, or you are doing a heavy task that may take longer than 1 hour sometimes, then you need run-one command in…
run-one
script for debian:https://github.com/dustinkirkland/run-one/blob/master/run-one
#run_one #debian
GitHub
run-one/run-one at master · dustinkirkland/run-one
git mirror of upstream bzr at http://launchpad.net/run-one - dustinkirkland/run-one
Have you seen some backup disks that has just an ethernet port like WD (western digital) with 8TB of capacity? if you don't know some commands to mount them or access its dashbaord, things could get a little bit harder.
LED color in front of the disk:
- blue LED is blinking: getting ready to serve data (if disk is almost full it may take 2 to 3 hours)
- blue LED is on with no blinking: LAN is connected and device is ready.
- red LED is blinking: there is something wrong with the device, maybe bad cluster or something else!
- red LED is not blinking: Device is ready, but LAN cable is not connected.
This LED color and its behaviour is almost always the same on other devices too. So memorize them :)
To get the IP address of WD (My Cloud) ping the domain as below:
ping wdmycloud.local
To see the GUI dashbaord open a browser and head over to:
- http://wdmycloud.local
To mount the device first check that the blue LED is on without blinking on the disk then create the destination directory if not exist:
mkdir -p /mnt/my_backup_folder
Now mount the disk with the command below (you can see folders like MyFolder from dashboard->Shares menu):
sudo mount -t nfs MyCloudIPAddress:/nfs/MyFolder /mnt/my_backup_folder
#wd #my_cloud #backup_disk #western_digital #wdmycloud
LED color in front of the disk:
- blue LED is blinking: getting ready to serve data (if disk is almost full it may take 2 to 3 hours)
- blue LED is on with no blinking: LAN is connected and device is ready.
- red LED is blinking: there is something wrong with the device, maybe bad cluster or something else!
- red LED is not blinking: Device is ready, but LAN cable is not connected.
This LED color and its behaviour is almost always the same on other devices too. So memorize them :)
To get the IP address of WD (My Cloud) ping the domain as below:
ping wdmycloud.local
To see the GUI dashbaord open a browser and head over to:
- http://wdmycloud.local
To mount the device first check that the blue LED is on without blinking on the disk then create the destination directory if not exist:
mkdir -p /mnt/my_backup_folder
Now mount the disk with the command below (you can see folders like MyFolder from dashboard->Shares menu):
sudo mount -t nfs MyCloudIPAddress:/nfs/MyFolder /mnt/my_backup_folder
NOTE:
dashboard default username is admin
and it has no password by default.NOTE:
if you want to reset the password: https://support.wdc.com/knowledgebase/answer.aspx?ID=13986#wd #my_cloud #backup_disk #western_digital #wdmycloud
Western Digital
Western Digital Support | Western Digital
Find detailed answers to your support questions for your Western Digital, SanDisk, WD_BLACK, or WD storage product.