Playing with Osmosis

Command to filter the file with tag amenity=school and write the filtered data in second file.

$ osmosis –read-xml file=”ludhiana.osm” –nkv keyValueList=”amenity.school” –write-xml file=”school.osm”

Do you want to update your OSM data without deleting existing data?

So here are the steps given below.

Step 1

Derive a change set between two files. The first file is the file after changing, the second planet file is the file before changing. The changeset will be written in the third file.

$ osmosis –read-xml file=”classroom.osm” –read-xml file=”class_lib_tcc.osm” –derive-change –write-xml-change file=”classroom_classlibtcc_diff.osm”

Step 2

Dump the changeset to the database in append mode. It means it will change only affected data. Rest will exist there.

$ osm2pgsql –slim -a -d classroom -C 2500 –hstore -S openstreetmap-carto.style ~/osmosis_files/class_audi_diff.osm

And you are done.:)

Note: Osmosis and osm2pgsql have different schemas. So for using postgis flags of osmosis we have to create schema compatible with osmosis. I followed this link to create ans setup database.

For my satisfaction, I have written that command again.

$ psql -d classroom -f /home/amisha/osm/osmosis/script/pgsnapshot_schema_0.6_action.sql

OUTPUT

CREATE TABLE
ALTER TABLE

 

Advertisements

Variety: Wallpaper Changer

Variety Software

Variety is an open source wallpaper changer for linux.

Features

  1. It allows to set your own wallpapers.
  2. Provide  an option to change wallpaper automatically on hourly, daily basis.

Installation

sudo add-apt-repository ppa:peterlevi/ppa
sudo apt-get update
sudo apt-get install variety

Open it either from dashboard or from terminal by running command “variety”. Set it according to your needs.

Screenlets: Desktop Widgets

The next thing to make your Ubuntu more beautiful is to display desktop widgets like clock, infoPanelDesktop in Ubuntu system with the help of Screenlets software using this link.

Wireshark: Packet Analyzer

Install Wireshark from this link.

Vim Configuration

Are you bored of using standard vim editor?

Do you really want to style and customise your vim editor? Then what you are waiting for.

I have configured vim using this link . The complete source code and documentation of vimrc file is written in my Github repo

Just follow the instruction given in the README.md file and impress your friends with it.;-)

Struggles:

After adding and installing plugin “YouCompleteMe” for auto-complete I was getting message while opening any file with vim.

“The ycmd server SHUT DOWN (restart with :YcmRestartServer)”

Even after running command :YcmRestartServer the problem stucked. After searcing on internet, I ran the python script “install.py” under “$HOME/.vim/bundle/YouCompleteMe”

The following table contains some of vim basic commands and the commands run for my vimrc file.

Command Description
Type v, yank lines then press Ctrl-c It will copy lines in visual mode. It will work if you copy this .vimrc file.
Tap Esc, then Ctrl -p It will paste lines in normal mode. It will work if you copy this .vimrc file.
:Te filename It will open that file within the vim editor. You can also select file instead of typing filename. For that type :Te and then open NerdTree(Ctrl +n) and select the exact file.
gt Switch between the files opened with :Te command.
Ctrl + ww Switch between the files opened with :Te command.
Ctrl-P It enables the search within the vim. It uses plugin ctrlp.vim.
:sp filename Split the layout vertically. It means the vim window is divided in two parts upper and lower.
:vs filename Split the layout horizontally. It means the vim window is divided in two parts left and right.
:b buffer_number Switch to that particular buffer.
:ls List all buffers. Buffers are the files open in that vim session.
0 To reach the beginning of a line.
$ To reach end of a line.
* Move to the next occurrence of the word under cursor.
# Move to the previous occurrence of the word under cursor.
gg To reach beginning of a file.
G To reach end of a file.
o To insert text into a new line.
dw Deletes the first word on the right side of the cursor.
. To repeat the previous command.
x To delete a character.
d$ Delete from cursor to the end of current line.
5yy Copy 5 lines.
line_no>>G To go to particular line number.
Yank lines,then type :e filename. Copy-paste from one file to other. Filename is the destination file where you want to paste the lines.

 

Bitcoins

What is Bitcoin?

Bitcoin is a new currency that was created in 2009 by an unknown person using the alias Satoshi Nakamoto and released as open-source software. It is a cryptocurrency and worldwide payment system. It is the first decentralized digital currency .

Transactions are made with no middle men – meaning, no banks! The price of bitcoin skyrocketed into the thousands in 2017.

Why Bitcoins?

With the help of bitcoins, international payments are easy and cheap because they are not tied to any country or subject to regulation.

Some people just buy bitcoins as an investment, hoping that they’ll go up in value.

Owning Bitcoins

 Bitcoins are stored in a “digital wallet,” which exists either in the cloud or on a user’s computer. Bitcoins are traded from one personal ‘wallet’ to another ( peer to peer communication).

Anonymity

Though each bitcoin transaction is recorded in a public log, names of buyers and sellers are never revealed – only their wallet IDs. That’s why it has become the currency of choice for people online buying drugs or other illicit activities.

Why bitcoins in demand?

1. It does not rely on a central bank.
2. Due to limited supply, people will pay more to get the coins they think have value.
3. It can be used for investment.

Future in question

No one knows what will become of bitcoin. It is mostly unregulated, but some countries like Japan, China and Australia have begun weighing regulations. Governments are concerned about taxation and their lack of control over the currency.

Daily Dose

After so long, I got a time to publish this draft. They are general things a developer should know.

Command to download the debian file of the package.

sudo apt download <package-name>

Command to see the dependencies of the package.

sudo apt-cache depends <package>

I was not able to install any package with apt.

*** Error in `appstreamcli’: double free or corruption (fasttop): 0x0000000001dedf90 **

Solution

$ sudo apt install –reinstall libappstream3

Let’s talk about Git.

What if you want to copy the file from one branch to other in git. Think think…

Congratulations if you know, but still I will explain here in detail.

Let’s say we have two branches A and B. I am currently in branch A and I want to copy one file from branch B to A. Remember, the file you want to copy should be committed. If not, then first go to branch B and commit it using below commands.

git checkout B

git add <filename>

git commit -m “Dear file, you are in demand!”

Now come back to branch A using

git checkout A

Now, using below command copy the file from branch B to A.

git checkout B <filename>

Apart from that,  I updated my Firefox using link

I think you learned some new things. Good bye. Stay tuned!

Title of Lovely Blog hidden under Description

Baar Baar Din Yah Aaye, Baar Baar Dil Yah Gaaye
Tu Jiye Hazaaron Saal, Yah Meri Arazu Hai
Happy Birthday To You…

I am sure you are also rhyming this song with me. Moreover you are thinking why I have written over here. So, it’s time to reveal the surprise.

It’s my Hundredth Happy Blog Day. 😉

All thanks to OpenStreetMap, Linux  and most import Great Developers Team to be a part of this journey.

Coming to non-technical Stuff, today, I heard news

After Train Departs 20 Seconds Early, Japan Railway Issues ‘Deep Apology’

You might be wondering why I have mentioned especially this news over here.

While reading this news many thoughts came to my mind. Previous year while receiving HVPE lecture my Sir said the main reasons how Japanese has a rapid economic growth.

[His Experience- During the departure of bus, In India people catch it by poking others but in Japan they act like civilized person.]

More precisely, they care for people whether it would be their family, employees, or even a person not belong to them in anyway.

They are dedicated to the work assigned to them.

They have spiritual sense of awareness in their social and economic life.

Overall, The Japanese have a practical outlook and believe in showing results in their work, even if this meant trial and error methods.

Now, it’s to time to have a break. Meet you soon with crispy technical stuff. 🙂

Pip freeze outputs a list of python globally installed packages

Few days back, I got to know the actual meaning of virtualenv from my friend Amrit.

Virtualenv

virtualenv <name>

The above command will create a new directory with <name> which create new python executable path, set up tools like pip, wheel etc through which we can install new python packages even without sudo power and independent of global python packages.

source /<name>/bin/activate

It will activate the virtualenv you have created now. Make sure to activate before you install new package under it.

deactivate                                   //deactivate the virtualenv.

pip freeze                                  //list all the packages installed under that environment.

Before the installation of any package under it, it should output none. But in my it was listing global python packages installed.

On browsing the error, I came to know that there was one file existing named “pip.conf”

[global]
target=/usr/local/lib/python3.4/dist-packages

Either you can remove the file or move it at other place. This seems to be a small problem but in actual it was destroying the real power of having virtualenv. So, solve it ASAP otherwise it gonna create chaos.

PDF Editor

Apart from that, I edited pdf with the online tool https://www.sejda.com/

Seriously it’s too flexible and interest seeking tool because of the features like Add your signature, tick the check box and many more.

 

Publish Post on Page through Facebook API

So, here comes very interesting task. As I mentioned in my previous blog about #LuvLdh Event, this blog is related to that only.

Me and my friend Amrit was given a task to make a web app which will allow user to login through facebook, upload images or document and automatically publish it on page.

This blog will cover very small part of the problem i.e. how user can publish post on a page. We used Facebook SDK for Python.

We followed following links to  solve it.

https://facebook-sdk.readthedocs.io/en/latest/api.html

http://nodotcom.org/python-facebook-tutorial.html

https://stackoverflow.com/questions/24052651/python-facebook-sdk-post-to-page

Installation

Install facebook module of Python as given in https://facebook-sdk.readthedocs.io/en/latest/install.html

Generate Access Token

  1. Login to facebook account.
  2. In new tab, browse to https://developers.facebook.com/
  3. Go to “Tools and Support” and then “Graph API Explorer”.
  4. Click “Get Token” and then “Get User Access Token”. It will prompt out permission options.
  5. In order to publish post on your account, Check box “publish actions” permission and then click “Get Access Token”. It will ask for whom should see the post(preferably public). To know more about permissions browse to https://developers.facebook.com/docs/facebook-login/permissions

Congratulations, you have generated your long string of access token.

import facebook

graph = facebook.GraphAPI(access_token="your_generated_token", version=2.10)

 

The above command will create new object “graph” with your own access token.

graph.put_photo(image=open('img.jpg', 'rb'),
                message='Look at this cool photo!')

This will publish photo on your account. Likewise to publish text or anything follow given links.

Publish Post as a Normal User into a Page.

Now recreate Token with more permissions. This time check box

Scopes user_location, user_likes, user_events, user_photos, user_about_me, user_posts, email, publish_actions, manage_pages, pages_show_list, publish_pages, public_profile

 

Here “public_profile” means to view your post to public. This permission is must. This is obtain when we click “get access token” it ask for to show the post to [public, friends,  only me]. Select Public. It took complete one day to debug the problem.:P

Now check the Page_id of the page in which you want to publish. It is displayed in URL or you also see in the “About” Section of the page.

Create the new object just like “graph” object created with new access token.

graph.put_wall_post(message=’Really Worked!!’, profile_id=’your_page_id’)

Likewise, an admin of the page can also publish the post. Rather an admin can select any option among [public, friends,  only me].

Make sure in the General settings of the page there is no bar for a normal user and everything is set to public(if applicable).

Now check post to the page Community section. You will be able to see the post.:)

For any kind of doubt feel free to comment.

Integral

This blog is an integration of small small tasks done few days back.

Steps to install Google chrome in Ubuntu.

sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb

Gh-Pages

Following this link I tried to make Github Pages

https://pages.github.com/

LuvLdh Website

Then TCC Team created website for the event #LuvLdh located at https://amisha2016.github.io/LuvLdh/

Source code

You can clone the source code from https://github.com/amisha2016/LuvLdh

The actual theme was picked from http://markups.io/demo/eventoz/

Common Ubuntu Commands

The purpose of this blog is to inculcate the readers with some of the important network related commands and other command used on daily basis.

Rename multiple files in the same directory with extension phps to php.

$ rename ‘s/.phps$/.php/’ *.phps

History Command in Ubuntu

$history  //This command maintains history of the commands you applied

The output of this command displays serial number and command only. What if you want to know when that command is applied and at what time? What to do so that your history command always display date and time also?

Here is the answer of all questions.

HISTTIMEFORMAT="%d/%m/%y %T "

Or, to make the change permanent for the current user:

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
source ~/.bashrc

Then

history

Command which tells which ports are open by firewall is.

$ nmap  127.0.0.1

Output

Starting Nmap 7.01 ( https://nmap.org ) at 2017-10-13 14:09 IST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000077s latency).
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
110/tcp open pop3
139/tcp open netbios-ssn
143/tcp open imap
445/tcp open microsoft-ds
3306/tcp open mysql
5432/tcp open postgresql

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds

Command to print network connections, routing tables.

$ sudo netstat -nutlap | grep 25

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 14277/master
tcp 0 0 172.20.10.3:47056 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47596 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47424 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47618 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:47576 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:59342 54.251.241.152:443 TIME_WAIT –
tcp 0 0 172.20.10.3:47530 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp 0 0 172.20.10.3:38490 54.251.58.133:443 TIME_WAIT –
tcp 0 0 172.20.10.3:51642 198.252.206.25:443 ESTABLISHED 2956/firefox
tcp6 0 0 :::25 :::* LISTEN 14277/master

SMTP Secure listen to port 465 and TLS listen to port 587

Command to open port

sudo ufw allow <port number>

eg:- sudo ufw allow 8082

To know more about Ubuntu commands read blogs under the same category.

Stay tuned! 🙂