Wednesday, September 27, 2017

How to Clone an Android Studio Project

1) Find and go to `AndroidStudioProjects` directory
2) Copy-Paste needed project and rename project folder (e.g. rename app to app_new)
3) Android Studio -> Close Project
4) Open an existing Android Studio Project -> choose name of the copied and renamed directory (app_new)
5) app -> src -> main -> AndroidManifest.xml -> change package name (something like package="com.example.android.app" to package="com.example.android.app_new" )
6) select folder (any) under java (app -> src -> main -> java) and right-click -> Refactor -> Rename -> Rename Package -> app_new -> Refactor -> Do Refactor -> Sync Now (Sync Now may not be needed)
7)  app -> src -> main -> AndroidManifest.xml -> change label of an app (something like android:label="App" to android:label="App New" )
8) Run an App 

Wednesday, September 13, 2017

Choosing name for an Android App

1) Avoid using puns
2) Use https://keywordtool.io/ AppStore for free keyword suggestions
3) App description must have most used  search-keywords
4) Try to use no more than 11 characters. If long name is needed - stick to camel-case. If you need even longer name - use tagline (Example - Evernote tagline is "Remember Everything” expanded along with the product to “Your Life’s Work.”)
5) Use name generators: www.nameboy.com / www.dotomator.com to make brainstorms
6) App name must be easy to pronounce
7) The name must be descriptive (Examples: Evernote / Flipboard / Wunderlist / GrubHub / Eventbrite)
8) Include the phrases “free”, “lite” or “cheap” wherever applicable. This will drive additional traffic to your app.
9) Google Play title (name=brandname + very short description) must be not more than 50 characters

Monday, August 14, 2017

Excluding interface form bridge-group on a Cisco Router

When you have several interfaces in one bridge group and want to exclude interface which is used to access the remote device, doing this manually can end with losing the ability to access device and also users of this router will lose the ability to use the network services.
In such a situation Cisco event manager can help. Assume that we have such configuration:
bridge irb
!
bridge 2 protocol ieee
bridge 2 route ip
!
interface GigabitEthernet1
 description ===WAN===
 no ip address
 bridge-group 2
 no shut
!
interface BVI2
 description === WAN ===
 ip address 10.10.10.204 255.255.255.0
our default gateway is 10.10.10.26

We need following:

On Cisco router:

ip sla 1
 icmp-echo 10.10.10.26 source-ip 10.10.10.204
 threshold 1000
 timeout 1500
 frequency 3
ip sla schedule 1 life forever start-time now
track 10 ip sla 1 reachability
 delay down 10 up 60
event manager applet reconfigure_interface
 event track 10 state down
 action 0    cli command "enable"
 action 1    cli command "configure terminal"
 action 2    cli command "no int BVI 2"
 action 3    cli command "interface GigabitEthernet1"
 action 4    cli command "no bridge-group 2"
 action 5    cli command "ip address 10.10.10.204 255.255.255.0"
 action 6    cli command "exit"
 action 7    cli command "no event manager applet reconfigure_interface"
 action 8    cli command "no track 10"
 action 9.1 cli command "no ip sla 1"
 action 9.2 cli command "end"

On default gateway:

we deny icmp from 10.10.10.204

When ping is disabled, track senses this via ip sla and in the end event manager executes commands for us.
That is it ...

PS:
1) if something goes wrong you can re-enable ping and ask somebody on the remote side to restart Cisco. This will load old configuration.
2) after accessing Cisco execute write command to save changes 

Monday, July 3, 2017

git - small tutorial

[admin@localhost ~]$ sudo yum install git -y
[admin@localhost ~]$ git config --global user.name "tarasov.dmitriy"
[admin@localhost ~]$ git config --global user.name "tarasov.dmitriy@gmail.com"

Make git repository in needed directory (I'll use git_test dir):
[admin@localhost ~]$ mkdir git_test
[admin@localhost ~]$ cd git_test
[admin@localhost ~]$ git init
Initialized empty Git repository in /home/admin/git_test/.git/
[admin@localhost git_test]$ cat > git_test.cfg
this is test file used to understand git
[admin@localhost git_test]$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    git_test.cfg
nothing added to commit but untracked files present (use "git add" to track)

If you have many files in directory and want to track only limited number of files, first setup gitignore file as follows (we also can add allfiles in directory via `git add .`):
[admin@localhost git_test]$ echo "*" > .gitignore
[admin@localhost git_test]$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
[admin@localhost git_test]$ ls -1
git_test.cfg

Now we'll add needed files (git_test.cfg in our example):
[admin@localhost git_test]$ git add git_test.cfg
The following paths are ignored by one of your .gitignore files:
git_test.cfg
Use -f if you really want to add them.
fatal: no files added
Aha..
[admin@localhost git_test]$ git add -f git_test.cfg
[admin@localhost git_test]$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#    new file:   git_test.cfg
#

After adding all needed files, we must commit:
[admin@localhost git_test]$ git commit -m "initial configuration commit"
[master (root-commit) 30d2109] initial configuration commit
 Committer: tarasov.dmitriy@gmail.com <admin@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 git_test.cfg

Now we can make symbolic link to that file (git_test.cfg) and place this link to the needed directory so that we can use actual version of this file:
[admin@localhost git_test]$ ln -s ~/git_test/git_test.cfg ~/Desktop/

I prefer to use cp -s because it's more verbose, i.e.:
cp -s git_test.cfg /home/admin/Desktop/
cp: ‘/home/admin/Desktop/git_test.cfg’: can make relative symbolic links only in current directory

Now if we'll check the status of our git repository:
[admin@localhost git_test]$ git status
# On branch master
nothing to commit, working directory clean

To list all files in a repo, use this command:
[admin@localhost git_test]$ git ls-files
git_test.cfg


see:
1) http://www.zyxware.com/articles/2515/track-server-configuration-file-changes-using-git-versioning-system
2) http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/
3) https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/




Friday, June 9, 2017

Azerbaijani letters English transliteration

These letters must be converted as so:

ə - a
ğ - gh
ş - sh
ç - ch
x - kh
ü - u
ö - o
q - g

Friday, April 7, 2017

Ethernet frame and Ethernet Packet

MAC is 6pairs of hex symbols - each hex symbol is 4bits:
4x2:4x2:4x2:4x2:4x2:4x2
8:8:8:8:8:8
8x6=48bits 48bits are 6bytes

Ethernet frame is data-link layer and consists of (sizes are in bytes):
6                   -> destination MAC
6                   -> source MAC
4(Optional)  -> 802.1Q tag
2                   -> type (IPv4 or IPv6)
46-1500        -> data
4                   -> FCS
Ethernet frame overall size:
1) 802.3 frame:
header (6+6+2)+data(46-1500)+trailer(4) -> 64-1518
2) 802.1Q frame:
header (6+6+4+2)+data(46-1500)+trailer(4) -> 68-1522

Ethernet packet is physical layer and consists of (sizes are in bytes ):
7                           -> preamble (7 same bytes each equals 10101010)
1                           -> SFD (Start Frame Delimiter - 10101011)
64|68-1518|1522  -> either 802.3 or 802.1Q Ethernet frame
Ethernet packet overall size:
1) with 802.3 frame:
(7+1)+(64-1518 ) -> 72-1526
2) with 802.1Q frame:
(7+1)+(68-1522)  -> 76-1530

Also 12byte IPG (Inter Packet Gap) is used as minimal pause between Ethernet packets.

So Ethernet payload is 46-1500 bytes and Ethernet overhead is:
1) for Ethernet frame - 6+6+2+4=18 bytes or 22 bytes if 802.1Q is used
2) for Ethernet packet - Ethernet frame overhead (18 or 22) + 8 -> 26 - 30
3) if we'll also take IPG into consideration -> 12 + (26|30) -> 38 - 42


Wednesday, April 5, 2017

Twisted pair cable pinouts (Ethernet)

Cable pairs and RJ-45 pinouts and TIA/EIA colour schemes:

Speaking frankly RJ45 is not the correct name of the connector, correct name of the jack (Ethernet connector) is 8P8C and RJ45 is telephony standard name. 8P8C means 8pins 8connected. In the RJ45 standard central pair was used for for a single telephony pair.

1 - Blue pair - pins 4-5 (middle pins - were used for Voice in RJ45 telephony standard)
2 - Orange pair - pins 1-2 (TIA/EIA 568-B) or pins 3-6 (TIA/EIA 568-A)
3 - Green pair -  pins 3-6 (TIA/EIA 568-B) or pins 1-2 (TIA/EIA 568-A)
4 - Brown pair - pins 7-8

        __3or2__
2or3  |               |
|   |   |    1p     |      4p
|   |   |    |  |   |    |   |
1  2  3  4  5  6  7  8 

Blue pair is the only pair  which pins start with solid colour (blue), all other pairs pinning start with mixed colour (white-mix).
Blue and Brown pairs are always on the same place, so wee need only to remember pins for Orange and Green pair. We can use mnemonic trick - if pins 3 and 6 (close to Blue pair) are Orange (2nd pair) then it's TIA/EIA 568-A, because A is the first letter in the alphabet and pairs go in the proper order - 1st Blue and then 2nd Orange. If pins 3 and 6 (close to Blue pair) are Green (3d pair) then it's TIA/EIA 568-B, because pairs are not in the proper order - 1st Blue and then 3d Green.

DTE / DCE

DTE and DCE are descriptions of the role of an Ethernet interface of the device (so the same device can have both DTE and DCE interfaces):
1- DTE (Data Terminal Equipment) - typically downstream device (user end).
2- DCE (Data Communication Equipment) - typically upstream device (network end).

DTE devices: PC, server, router WAN ports
DCE devices: hub, switch, router LAN ports

DTE devices mostly use pins 1&2 to transmit and 2&3 to receive.
DCE devices mostly use pins 2&3 to transmit and 1&2 to receive.