Posts

PassGen Pro 1.0 released

Today I publishedd on Google Play my password generator app. Yes, just another one password generator app. But I think, this app has very good interface for touch devices. Also, as I mentioned in this post, it uses a customized spinner in ActionBar.

So, a few words about PassGen Pro. This is an Android app to generate passwords with native, simple, and optimized for mobile touchscreen interface. It supports five modes:
Standard alphanumericExtended with optional special symbolsExtra-customized mode with using of provided symbolsSpecial mode to generate easy to remember, but strong passwordsAnd, generate passwords, based on MD5 hash from provided word All modes are customized, you can set password length, using of uppercase symbols, etc.

Bulk mode to generate up to thousands of passwords into file also supported.

You can download it from Playstore.

GPCL for PHP v. 2.3 commited to GitHub

Today I commit a new version - GPCL for PHP 2.3 - to GitHub.
This is not a release, but master brunch for 2.3 stable.
You can download sources from here.

Install and configure Exim 4 mail server in Debian 8

One of friends ask me to configure mail in VPS to send messages via web form. He using Wordpress, and can't write custom PHP code to send mail directly via SMTP. Only one way is acceptable here: to use PHP mail() function. Okay, in this case we need a mail server on VPS. I like Exim.

To install Exim, run:

apt-get install exim4-base
After this, run configuration tool:

dpkg-reconfigure exim4-config

Make selections with using arrow keys, select “Ok” with tab key (note again, server will setup only for send mail):
Select: ‘internet site; mail is sent and received directly using SMTP’Enter FQDN: yourdomain.tldSMTP Listener: enter 127.0.0.1; ::1Mail destinations - yourdomain.tld, local hostname, localhost.localdomain, localhostRelay Options: Leave blankFollow up Screen to Relay Options: Leave blankDNS Queries: Keep DNS queries to a minimum? select “No”Delivery method: Select “Maildir format in home directory”Choose default unsplit config file by entering “No” Finally (it is very important …

Create custom Spinner on ActionBar

Image
Last days I start working on new Android app, working name is PassGen (Password generator) and plan to place spinner onto the ActionBar. Since API 21 ActionBar replaced to more flexible Toolbar with you can put widgets similar to regular layout.
I plan to use spinner but by default it look not fine for me. Starting from modify colors, my mind moving me to add second line and icon to each item. Finally, it looks like this:
Almost changes are in XML files. In MainActivity:
<android.support.v7.widget.Toolbarandroid:id="@+id/toolbar"android:layout_width="match_parent"android:background="@color/colorPrimaryDark"android:layout_height="?attr/actionBarSize"> <Spinnerandroid:id="@+id/spinner"style="@style/SpinnerTheme"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginEnd="8dp"android:layout_marginStart="8dp"android:layout_marginTop="8dp&q…

One billion records table in Postgresql

I have a simple table in Postgersql database with character key.

CREATE TABLE public.zero_hids ( hexblock character(32) COLLATE pg_catalog."default" NOT NULL, hid bigint, CONSTRAINT zero_hids_pkey PRIMARY KEY (hexblock) USING INDEX TABLESPACE alcal )
It is required to insert into this table 1000000000 unique records by loading from CSV file. We can split this file to 5 parts by 200 millions each and insert it from command line:

!/bin/bash time psql --port=5433 -d db1 -c "COPY zero_hids FROM '/tmp/table0.csv' delimiter AS ',' HEADER CSV" ... time psql --port=5433 -d db1 -c "COPY zero_hids FROM '/tmp/table4.csv' delimiter AS ',' HEADER CSV"
Size of each part is around 9 Gigabytes. Allowed memory limit to Postgresql is 32Gb. Here is results:

COPY 200000000 real 55m16.461s user 0m0.040s sys 0m0.008s COPY 200000000 real 89m48.861s user 0m0.048s sys 0m0.016s COPY 200000000 real 202m21.283s user 0m0.044s sys 0…

Deploy multiple files to multiple servers with Python

In yesterday post I describe how to upload file to multiple servers with scp, sshpass and Python. But sometimes it is required to upload multiple files. For example, I have one hundred files from split one with split command:

split file.txt --additional-suffix=.txt --number=l/100 --numeric-suffixes f

In this case files are named from f00.txt to f99.txt. And, for example, we should put this files for parallel processing on 10 servers. Of course, it is possible to make 10 archives, upload and unpack it, but better way is improve yesterday script to do this by one job, especially if we have more files and/or servers.

Let's do mm-scp.py like this (logindata.py is used some as this):

import sys from subprocess import call from logindata import ip_list user ='root' local_path ='upload/in/' remote_path ='/root/in/' pfx ='f' sfx ='.txt' d =2 fcnt = 100scnt = 10def func(x):for(ip, password)in ip_list:print("--------------\nMoving to %s"% ip)…

Deploy data to multiple servers with Python

One of easiest way to upload files into multiple servers via ssh is using a script that send data uses scp/sshpass and a list of connection data. For this purpose I like to use a Python language.

Firstly, define an array with IP and pasword data in logindata.py file:

ip_list = [('5.1.1.2', 'password1'), ('5.1.1.3', 'password2'),... ('5.1.1.N', 'passwordN')]
Using separate file for logina data is preferred because you can use multiple similar files with different data, and/or multiple scripts with uses that data to connect.

Okay, now we can create upload script (e.g. multi-scp.py) itself:

from subprocess import call from logindata import ip_list user = 'root' local_path = 'uploads/*' remote_path = '/root/'for (ip, password) in ip_list: print("--------------\nMoving to %s" % ip) call(['sshpass -p%s scp -r %s %s@%s:%s' % (password, local_path, user, ip, remote_path)], shell=T…