Posts Tagged ‘Global’

How to Avoid the 7 Most Frequent Mistakes in Python Programming

Monday, September 9th, 2019

python-programming-language-logo

Python is very appealing for Rapid Application Development for many reasons, including high-level built in data structures, dynamic typing and binding, or to use as glue to connect different components. It’s simple and easy to learn but new Python developers can fall in the trap of missing certain subtleties.

Here are 7 common mistakes that are harder to catch but that even more experienced Python developers have fallen for.

 

1. The misuse of expressions as function argument defaults

Python allows developers to indicate optional function arguments by giving them default values. In most cases, this is a great feature of Python, but it can create some confusion when the default value is mutable. In fact, the common mistake is thinking that the optional argument is set to whatever default value you’ve set every time the function argument is presented without a value. It can seem a bit complicated, but the answer is that the default value for this function argument is only evaluated at the time you’ve defined the function, one time only.  

how-to-avoid-the-7-most-frequent-mistakes-in-python-programming-3

 

2. Incorrect use of class variables

Python handles class variables internally as dictionaries and they will follow the Method Resolution Order (MRO). If an attribute is not found in one class it will be looked up in base classes so references to one part of the code are actually references to another part, and that can be quite difficult to handle well in Python. For class attributes, I recommend reading up on this aspect of Python independently to be able to handle them.

how-to-avoid-the-7-most-frequent-mistakes-in-python-programming-2

 

3. Incorrect specifications of parameters for exception blocks

There is a common problem in Python when except statements are provided but they don’t take a list of the exceptions specified. The syntax except Exception is used to bind these exception blocks to optional parameters so that there can be further inspections. What happens, however, is that certain exceptions are then not being caught by the except statement, but the exception becomes bound to parameters. The way to get block exceptions in one except statement has to be done by specifying the first parameter as a tuple to contain all the exceptions that you want to catch.

how-to-avoid-the-7-most-frequent-mistakes-in-python-programming-1
 

4. Failure to understand the scope rules

The scope resolution on Python is built on the LEGB rule as it’s commonly known, which means Local, Enclosing, Global, Built-in. Although at first glance this seems simple, there are some subtleties about the way it actually works in Python, which creates a more complex Python problem. If you make an assignment to a variable in a scope, Python will assume that variable is local to the scope and will shadow a variable that’s similarly named in other scopes. This is a particular problem especially when using lists.

 

5. Modifying lists during iterations over it

 

When a developer deletes an item from a list or array while iterating, they stumble upon a well known Python problem that’s easy to fall into. To address this, Python has incorporated many programming paradigms which can really simplify and streamline code when they’re used properly. Simple code is less likely to fall into the trap of deleting a list item while iterating over it. You can also use list comprehensions to avoid this problem.

how-to-avoid-the-7-most-frequent-mistakes-in-python-programming-8

       

6. Name clash with Python standard library

 

Python has so many library modules which is a bonus of the language, but the problem is that you can inadvertently have a name clash between your module and a module in the standard library. The problem here is that you can accidentally import another library which will import the wrong version. To avoid this, it’s important to be aware of the names in the standard library modules and stay away from using them.

how-to-avoid-the-7-most-frequent-mistakes-in-python-programming-5

 

7. Problems with binding variables in closures


Python has a late binding behavior which looks up the values of variables in closure only when the inner function is called. To address this, you may have to take advantage of default arguments to create anonymous functions that will give you the desired behavior – it’s either elegant or a hack depending on how you look at it, but it’s important to know.

 

 

how-to-avoid-the-7-most-frequent-mistakes-in-python-programming-6

Python is very powerful and flexible and it’s a great language for developers, but it’s important to be familiar with the nuances of it to optimize it and avoid these errors.

Ellie Coverdale, a technical writer at Essay roo and UK Writings, is involved in tech research and projects to find new advances and share her insights. She shares what she has learned with her readers on the Boom Essays blog.

How to substitute default TinyMCE Joomla Content editor with JCE Content Editor

Tuesday, May 31st, 2011

This content editor is really awesome compared to the default editor TinyMCE. If you want to have an options rich content editor for Joomla, then this is the one for you 🙂
download JCE Content Editor here

After installing the JCE Joomla content editor in order to enable it as a default editor you need to go to the following location:

Site -> Global Configuration -> Default WYSIWYG Editor

There place on Editor TinyMCE and change it with Editor – JCE

Now go to edit some article, and you will see the difference in the editor 🙂

7. Add gallery Joomla capabilities with sigplus (Image Gallery Plus) and Very Simple Image Gallery

sigplus Image Gallery Plus is a straightforward way to add image or photo galleries to a Joomla article with a simple syntax. It takes a matter of minutes to set up a gallery but those who are looking for a powerful gallery solution will not be disappointed either: sigplus is suitable for both beginner and advanced users.
 

How to set custom page titles in Joomla 1.5 manually for better SEO

Thursday, June 2nd, 2011

he Joomla CMS default behaviour is that Page titles of the Joomla Articles created are always set to the page Title assigned to each of the articles.

This is not very good behaviour in terms of SEO, as the page title of each link on the main page is different and there is no continuous repeating pattern in all of the joomla pages.
Everyone that has even basic idea of SEO knows that page titles are very important weight factor to make indexing inside Search Engines succesful.

There is a well know SEO rule which is the more reoccuring pattern one has in his page titles, more is stressed on the keywords contained in the title.
As I said for some weird reason Joomla has no common page Title for all my the created Article pages linked via the Main Menu*

Thus in order to improve this bad default Joomla SEO behaviour one has to change the default auto assigned titles for created pages, manually.

Two things are necessery to change each of the joomla already existing TITLES.

1. Go to each of the pages (.e.g. Home etc.) and change the Parameters System Page Title settings

After logging in with administrator in Joomla, navigate to Menus -> Main Menu*

Further on choose a menu item from all your existing items, let’s say Home and click on it.

On the left side below the Save, Apply, Close and Help buttons you will notice the menus:

Parameters (Basic), Parameters (Component), Parameters (System)

When clicked on Parameters (System) a submenu will appear:
Joomla Main Menu Parameters System Page Title better SEO

Above is a screenshot of the up-described Parameters (System) [Page Title] location

You need to change where it reads on the screenshot CHANGE THE TITLE HERE !!!!!! 😉

After entering your own desired page title go and save the article via the Apply or Save button (also visible in the screenshot).

Now as the custom Page Title is set, next step is to enable the custom Page Title for the respective Article in Article Manager

2. Enable custom Page Title for created pages in Joomla

Go to the Article Manager by following the menus:

Content -> Article Manager

Select the Article of which you want to change the Page Title to some custom text and click over it.

As the article opens for edit in an html editor, navigate to Parameters (Advanced) tab and therein change the Show Title from default setting value:
Use Global
to
Yes

Once again use the Save or Apply button to confirm the new settings and open your website in a new tab, try to browse and check the title of the articles parameters just edited. It should show up in the Title (page heading) the custom input Title.

Now repeat the same procedure for all pages (Articles), existing in Joomla to attune the Page Titles to some Google friendly strings and enjoy the better Search engine indexing which should likely follow.

How to disable or remove completely Adobe (Macromedia) Flash Cookies on Linux

Monday, April 11th, 2011

As I’ve mentioned in my previous post, one of the greatest “evils” which prevents a good internet anonymization whether you surf online is Adobe Flash Player

There are two approaches you might partake to disable the privacy issues which might be related to Adobe Flash cookies saving data about flash banners or websites which stores their cookies to your computer.

To find out if flash websites has already saved their nasty flash cookies on your Linux, issue the commands:

hipo@debian:~$ cd .macromedia
hipo@debian:/home/hipo/.macromedia$ find -iname '*.sol'
./Flash_Player/macromedia.com/support/flashplayer/sys/#s.ytimg.com/settings.sol
./Flash_Player/macromedia.com/support/flashplayer/sys/settings.sol
./Flash_Player/macromedia.com/support/flashplayer/sys/#ip-check.info/settings.sol

The returned output of the above find command clearly reveals the shitty flash has stored already 3 flash cookies on my Linux, 3 cookies which later can be easily requested by other flash banners.
The 3 flash cookies are:
1. Saved by Adobe’s Flash Configuration Manager
2. Saved by the website ip-check.info
3. Saved by s.ytimg.com’s website

Now to deal with the situation and get rid of flash cookies, there are possibly two ways of approach that one can take:

1. One is to use some kind of script like the one clear_flash_cookies.tsch the other one is to completely disable flash cookies.
Using the clear_flash_cookies.tcsh does get rid of flash cookie problems just temporary as it might be set to be executed either once the browser is starting up, or directly via some kind of cron job entry like:

01 11,19 * * * /home/hipo/scripts/clear_flash_cookies.tcsh

eHowever clearing up (removing) the flash cookies, still doesn’t completely proihibit saving up of flash cookies and in the time intervals between the clear ups of the flash cookies, still some websites might save information related to their use on your Linux host and expose this information for other external flash websites to read and retrieve information about your previous websites visits.

Therefore it might be a better solution in terms of browser security to;

2. completely disable the use of adobe flash cookies on your Linux powered desktop.

Disabling adobe flash cookies is possible by either using the online flash Global Storage Settings (Flash Settings Manager) by navigating to the URL:

http://www.macromedia.com/support/documentation/
en/flashplayer/help/settings_manager03.html

Adobe Flash Player online settings manager unticked option

And by removing the tick which is present to the option:

Allow third party Flash content to store data on your computer

Or by linking the local directory ~/.macromedia -> /dev/null

hipo@debian:~$ mv .macromedia .macromedia-bak
hipo@debian:~$ ln -s /dev/null .macromedia
hipo@debian:~$ ls -ald .macromedia
lrwxrwxrwx 1 hipo hipo 9 2009-03-30 09:56 .macromedia -> /dev/null

That’s all, Farewell nasty Flash cookies!

3 Major incorrect beliefs about Global DNS (root DNS) servers

Tuesday, March 16th, 2010

Until today, since I started getting into the depth of DNS some years from now, I always thought that there are 13 major super-computers used as a Global DNS servers which were responsible for caching in all the domain names on the IPv4 and IPv6 internet and that’s all I knew about this matter.
Today I had to review my knowledge on the subject of DNS protocol, BIND server etc. in order to be able to fix an issue with a newly configured BIND dns server. In relation to that I red a bunch of interesting articles online discussing a matters concerning root DNS servers.
Here are two major articles worthy to read:

1. DNS Root Name Servers Explained for Non-Experts – by Daniel Karrenberg
2. DNS Root servers in the World
This blow off the myth about 13 major super-servers running on top of backbones to serve DNS requests online. By the way it’s interesting fact that I’ve learned that myth from some O’reilly’s books that were explaining the Redhat Linux distrubution long time ago.
It could be that long time ago this was true but not anymore!

As of today’s date: Tue Mar 16 17:19:02 EET 2010, there are 425 DNS root servers which are an Internet’s bone today.

Interestingly enough full list of the root servers is available via isoc.org’s website along with many more information on the subject of how root DNSes works, how the DNS is served on the Internet as well as the RFC which explain the proper way to implement a DNS server.

A copy of the zonefile containing in it all the root DNSes can be obtained via isoc’s website

Another wrong idea about Global DNS servers that I kept with me over the years is that most of the root servers are geographically located in USA.

A good proof to this delusion is root-servers.org website which contains a wonderful Google map with pinpointed geographical locations of all root servers .Along with this there is a plenty of extensive information on root DNS servers.

Another misbelief when talking about DNS servers is that the A-root server is the main DNS server in the Global DNS cluster.

Another good reading location concerning DNS Root servers is The DNS Root Name Server FAQ .