Tuesday, December 8, 2015

More details on Google App Engine os.environ attributes

We can use python
package in Google App Engine to obtain some useful information for the request. As mentioned, we can obtain user geolocation of a user. Actually, there is a lot more we can do with it.

A LIVE DEMO is available. The demo contains a full list of
keys and their corresponding values. Some values are not publicly disclosed, but you can try it in your own application.

The values are accessed with
value available, such as
. However, some of the App Engine-specific keys such as
, only exist in the GAE environment.

The following section comes with the complete source code.

Monday, November 16, 2015

10 Essential Atom Packages for Sublime Text users

Atom is a Text Editor published by GitHub. If you are new to development, or would like to give another editor a try, Atom is a good choice for you.

The benefits of using Atom:
- It is free,
- Atom allows customization by installing packages/ themes,
- Atom is available on Windows, Mac and Linux,

I was used to Sublime Text for my development work. In order to make Atom my favourite one, I conducted a short research about some useful packages in Atom and somehow made it more similar to Sublime Text.

The followings are 10 essential Atom packages available at Atom Package List.
1. pigments Supports color highlighting.

2. color-picker Pick a color in the editor with a right-click.

3. minimap While Sublime Text supports minimap by default, we need to manually install this package in Atom to have minimap.

4. highlight-selected This package helps to highlight repeated words. Use Ctrd+D to select the next occurance of the word.

5. markdown-preview-plus This package provides a real-time preview of markdown documents.

6. autoclose-html This package enables auto-closing html tags in HTML documents.

7. file-icons Adds colourful file specific icons for improved visual grepping in Tree View, Fuzzy Finder and Tabs

8. merge-conflicts Lets you resolve your git merge conflicts in Atom.

9. sublime-style-column-selection This package adds back one of my favourite functions in Sublime Text -- Column select. With this package, we can hold Alt key and mouse select columns of text.

10. slush-poppies This is my favourite theme used in Sublime Text. Together with this theme I also changed my UI Theme settings to "One Light".


What is your favourite Package in Atom? Leave me a comment below!

Wednesday, October 14, 2015

How to center a HTML Popup dialog with CSS

In order to create a CSS-only auto-centered dialog, a few steps have to be done.

The first step is to add CSS
position: fixed;
to the target element with its
attributes both equal to

The target element now appears like this:

There is a problem -- setting left and top to 50% does not make it centered. Instead, the element shifted a bit from the center. To solve this, finish step 2 below.

The next step is to adjust the extra pixels shifted from the center. We can set its
to -1*(its width) and -1*(its height) respectively. For instance, a
with width:400px should set
margin-left: -200px
. With this approach, the element shifts back to center and keeps centered all the time.

Note: The element width and height should be a fixed value.

The following code summarizes the demo:

Here is a Live Demo of this example.

Update 7 Nov 2015: Updated source code section to GitHub version

Wednesday, September 9, 2015

How to obtain user geolocation with Google App Engine

Sometimes it is good to provide a better user experience by obtaining geolocation of a user. In Google App Engine, we can use the information in python
package to achieve this:

Get the current city of a user:

Get the current country of a user (Will return a ISO 3166-1 alpha-2 country code):

Note: If App Engine fails to supply a city name or country code, the output will be the second argument supplied to the
function call.

Update 13 Oct 2015: Added a Demo link

Update 7 Nov 2015: Added complete source code.