A series of quotes from Richard Stallman

Richard (Matthew) Stallman, often known by his initials, RMS, is a software freedom activist and computer programmer. He is a great speaker that makes some strong statements that are definitely worth being aware of, since they also well substantiated by extensive arguments. In this post, we will look at three videos featuring Richard Stallman and list some quotes that may spark your interest in the context in which they were said.

1) Richard Stallman: We’re heading for a total disaster (24:30)

In this interview from 2012, Richard is talking about the dangers of Extreme Capitalism (NB: contains religious and political views).

  1. “..a program is free or proprietary depending on whether the users control the program or the program controls the users..” [2:04-2:12]
  2. “I saw myself facing a life of proprietary software and it was ugly, it was disgusting.” [5:13-5:19]
  3. “Free software combines capitalist ideas, socialist ideas and anarchist ideas, it does not fit in any of those camps.”  [8:18-8:26]
  4. “You father was assuming that when you buy something you control it, and this used to be true, and often it still is true, but not with software.” [10:16-10:26]
  5. “..Microsoft Windows has known malicious features. [It] has features to spy on the user, features to restrict the user, these are called ‘digital handcuffs’, and it has known back-doors..” [10:46-10:56]
  6. “The recent Apple products, the ‘i-things’ have known spy-features, know ‘digital handcuffs’, the nastiest ever, and a known back-door.” [11:05-11:16]

2) Richard Stallman Talks About Ubuntu (6:10)

In this 2013 video, Richard Stallman talks about Ubuntu and its privacy invading features (see related blog).

  1. “Ubuntu has an unusual flaw, which is: it is spyware” [1:38-1:43]

3) Richard Stallman: The Danger of Software Patents (1:57:30)

In 2005, Richard Stallman explains at the University of Calgary (Canada) thoroughly what he thinks about software patents.

  1. “I don’t have an opinion about ‘Intellectual Property’. I have opinions about copyright law. I have a different opinions about patent law. I have an even different opinions about trademark law. I think of these three different subjects separately, and I hope that you will too.” [2:13-2:35]
  2. “You might also think: Let me find out about all the patents that might restrict this program, and then I can try to deal with all of them; that is impossible.” [15:58-16:07]
  3. “They quoted an engineer saying: I can’t recognize my own inventions in patentees [claims].” [24:34-24:38]
Share

EuroPython 2014: full conference on YouTube

europython_2014

EuroPython 2014 was held last week (July 21 – 27) at the Berlin Congress Center (BCC) in Germany.

The EuroPython conference is the second largest global conference for the popular programming language Python, after the PyCon US conference in North America.

For all of you that did not go, the full conference is available on YouTube (120 videos):

  1. Welcome [20:56]
  2. pymove3D Winner Announcement [21:05]
  3. One year of Snowden, what’s next? [58:00]
  4. What can python learn from Haskell? [41:20]
  5. Lightning Talks [40:18]
  6. Amanda: A New Generation of Distributed Services Framework [24:50]
  7. Will I still be able to get a job in 2024 if I don’t do… [46:47]
  8. Cutting-edge APIs using hypermedia at BSkyB [32:30]
  9. Mobile Games to the Cloud With Python [29:45]
  10. Statistics 101 for System Administrators [29:45]
  11. The Magic of Attribute Access [26:47]
  12. Pythonista: A full-featured Python environment for iOS … [40:32]
  13. Brain Waves for Hackers [33:36]
  14. Rethinking packaging, development and deployment [40:21]
  15. The Sorry State of SSL [44:56]
  16. Traversing Mazes the pythonic way and other Algorithmic… [44:50]
  17. The Cython Compiler for Python [48:01]
  18. Message-passing concurrency for Python [42:02]
  19. Extending Python, what is the best option for me? [32:22]
  20. Marconi – OpenStack Queuing and Notification Service [24:37]
  21. Solution oriented error handling [28:19]
  22. Web Scraping in Python 101 [20:18]
  23. Jigna: a seamless Python-JS bridge to create rich HTML … [23:36]
  24. How to make a full fledged REST API with Django OAuth T… [23:59]
  25. Documenting your project with MkDocs. [22:09]
  26. VPython goes to School [25:17]
  27. Full Stack Python [25:47]
  28. Using python, LXC and linux to create a mass VM hosting… [23:09]
  29. log everything with logstash and elasticsearch [18:29]
  30. Gamers do REST [24:20]
  31. Teaching Python [28:09]
  32. PyPy status talk (a.k.a.: no no, PyPy is not dead) [31:38]
  33. pymove3D – Python moves the world – Attractive programm… [23:10]
  34. Designing NRT(NearRealTime) stream processing systems :… [36:35]
  35. GNU/Linux Hardware Emulation with Python [20:34]
  36. Lightning Talks [1:22:47]
  37. Our decentralized future [47:06]
  38. Writing multi-language documentation using Sphinx [24:46]
  39. How we switched our 800+ projects from Apache to uWSGI [28:20]
  40. Introduction to pytest [29:16]
  41. Embedding Python: Charming the Snake with C++ [28:06]
  42. SQLAlchemy Drill [28:37]
  43. Design considerations while Evaluating, Developing, Dep… [40:39]
  44. Using All These Cores: Transactional Memory in PyPy [42:01]
  45. gevent: asynchronous I/O made easy [44:01]
  46. Scaling with Ansible [40:37]
  47. Don’t fear our new robot overlords! [38:43]
  48. Systems Integration: The OpenStack success story [40:00]
  49. Performance Python for Numerical Algorithms [48:28]
  50. DevOps Risk Mitigation: Test Driven Infrastructure [47:25]
  51. Compress Me, Stupid! [35:45]
  52. Stackless: Recent advancements and future goals [44:41]
  53. Design Your Tests [25:32]
  54. Automatic code reviews [20:49]
  55. Supercharge your development environment using Docker [22:36]
  56. An HTTP request’s journey through a platform-as-a-service [24:13]
  57. 3D sensors and Python: A space odyssey [22:40]
  58. How to Setup a new Python Project [24:45]
  59. Graph Databases, a little connected tour [25:33]
  60. Identifying Bugs Before Runtime With Jedi [25:04]
  61. Python refactoring with Rope and Traad [25:02]
  62. I want to help! How to make your first contribution to … [19:14]
  63. Managing the Cloud with a Few Lines of Python [25:37]
  64. How to become an Agile company – case study [22:30]
  65. For lack of a better name(server): DNS Explained [24:54]
  66. Python in system testing [23:10]
  67. Lightning Talks [1:28:23]
  68. Advanced Uses of py.test Fixtures [26:32]
  69. Multiplatform binary packaging and distribution of your… [20:20]
  70. Conversing with people living in poverty [29:12]
  71. Eve – REST APIs for Humans™ [30:44]
  72. The Shogun Machine Learning Toolbox [19:47]
  73. RISCy Business: Development of a RNAi design and off-ta… [25:05]
  74. How Disqus is using Django as the basis of our Service … [30:59]
  75. Metaprogramming, from decorators to macros [39:03]
  76. Support Python 2 and 3 with the same code [39:58]
  77. The Return of “The Return of Peer to Peer Computing”. [39:35]
  78. Python Debugger Uncovered [31:12]
  79. Writing Awesome Command-Line Programs in Python [41:25]
  80. Elasticsearch from the bottom up [36:54]
  81. Scikit-learn to “learn them all” [40:17]
  82. How Pony ORM translates Python generators to SQL queries [44:55]
  83. Probabilistic Programming in Python [45:35]
  84. Morepath: a Python Web Framework with Super Powers [27:46]
  85. Python for Zombies: 15.000 enrolled in the first Brazil… [26:11]
  86. The inner guts of Bitbucket [28:50]
  87. Learning Chess from data [21:58]
  88. Red Hat Loves Python [23:28]
  89. Jython in practice [25:51]
  90. packaging and testing with devpi and tox [26:46]
  91. Non Sequitur: An exploration of Python’s random module [29:13]
  92. Packaging in packaging: dh-virtualenv [31:34]
  93. The Continuum Platform: Advanced Analytics and Web-base… [24:55]
  94. Farewell and Welcome Home: Python in Two Genders [31:42]
  95. Lessons learned from building Elasticsearch client [24:41]
  96. Pioneering the Future of Computing Education [25:55]
  97. Lightning Talks [1:31:25]
  98. How to become a software developer in science? [24:53]
  99. Python’s Role in Big Data Analytics: Past, Present, and… [49:45]
  100. Combining the powerful worlds of Python and R [25:54]
  101. Scientific Visualization with GR [23:19]
  102. Scalable Realtime Architectures in Python [28:31]
  103. Python Driven Company [35:12]
  104. Out-of-Core Columnar Datasets [22:32]
  105. Twisted Names: DNS Building Blocks for Python Programmers [27:51]
  106. Event discrete simulation with SimPy [25:16]
  107. Advanced Database Programming with Python [31:00]
  108. Using asyncio (aka Tulip) for home automation [26:57]
  109. Concurrent programming with Python and my little experiment [21:12]
  110. Big Data Analytics with Python using Stratosphere [20:26]
  111. Practical PyBuilder [23:01]
  112. Building Realtime Web Applications with WebRTC and Python [20:18]
  113. Ganga: an interface to the LHC computing grid [24:28]
  114. Extending Scikit-Learn with your own Regressor [25:54]
  115. Post-Mortem Debugging with Heap-Dumps [26:54]
  116. Fun with cPython memory allocator [28:36]
  117. Everything You Always Wanted to Know About Memory in Python But Were Afraid to Ask [29:04]
  118. Conference Closing [15:52]
  119. Lightning Talks [1:16:09]
  120. Sponsoring von Open Source [28:02]

If you manage to watch all of them… you deserve a medal! 😉

source: http://www.youtube.com/user/europython2014

Share

PSR-0 and PSR-4 autoloading of classes in PHP

The PHP Framework Interop Group is about interoperability standards between frameworks so that code can be reused between projects. To facilitate this way of working there is “Composer” (a package manager) and “Packagist” (a package repository) made available. The SCM system used by the packages is mainly Git and the code repository resides most of the times on Github. Symfony2 is heavily using this system already. For class autoloading (the most important interoperability problem) the following standards apply:

The following PHP file can be put into the vendor directory (and required by your project) to do autoloading of classes:

class Loader
{
    protected static $parentPath = null;
    protected static $paths = null;
    protected static $nsChar = '\\';
    protected static $initialized = false;

    protected static function initialize()
    {
        if (static::$initialized) return;
        static::$initialized = true;
        static::$parentPath = __FILE__;
        for ($i=substr_count(get_class(), static::$nsChar);$i>=0;$i--) {
            static::$parentPath = dirname(static::$parentPath);
        }
        static::$paths = array();
        static::$files = array(__FILE__);
    }

    public static function register($path,$namespace) {
        if (!static::$initialized) static::initialize();
        static::$paths[$namespace] = trim($path,DIRECTORY_SEPARATOR);
    }

    public static function load($class) {
        if (class_exists($class,false)) return;
        if (!static::$initialized) static::initialize();

        foreach (static::$paths as $namespace => $path) {
            if (!$namespace || $namespace.static::$nsChar === substr($class, 0, strlen($namespace.static::$nsChar))) {

                $fileName = substr($class,strlen($namespace.static::$nsChar)-1);
                $fileName = str_replace(static::$nsChar, DIRECTORY_SEPARATOR, ltrim($fileName,static::$nsChar));
                $fileName = static::$parentPath.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$fileName.'.php';

                if (file_exists($fileName)) {
                  include $fileName;
                  return true;
                }
            }
        }
        return false;
    }
}

spl_autoload_register(array('Loader', 'load'));

If you clone the guzzle library into “vendor/guzzle” then you can use the snippet below to load the Loader class and register the library. After that you can just use the Guzzle Client class, because the Loader takes care of the autoloading.

require 'vendor/autoload.php';
Loader::register('guzzle','GuzzleHttp');
use GuzzleHttp\Client;
$client = new Client();
// do something with $client

Alternatively, you can also use the autoloading file generated by Composer. I recommend doing this in a production environment. Using Composer allows you to manage your dependencies and automatically update them when new versions are released. This post should show you how the autoloading mechanism works in PHP. It also shows you how to build your own standards compliant autoloading mechanism, something you probably only need when building your own PHP framework.

Share

WordPress password forgotten? Part 1 (using SSH)

According to Wikipedia, WordPress is the worlds most popular blogging software. Approximately 19% of all websites run WordPress. I cannot count the times I installed and configured WordPress. It is easy to customize using plugins, which make it do almost anything you can dream of. NB: This site runs WordPress as well.

Sometimes you come across a WordPress instance you installed a long time ago and you have forgotten the administrator username and/or password. This has actually happened to me a few times already. In this case, you can run the script below on the web servers SSH shell. It allows you to find the user and reset the password and reset the user to have the ‘Administrator’ role.

In Part 2 of this post we will show you a script that can be run if you have no SSH, but only FTP access to the web server.

Reset WordPress password over SSH

Running the script from the SSH shell gives the following output:

maurits@nuc:~$ php wp-reset-ssh.php
WordPress password reset script
1: /home/maurits/public_html/wp-config.php
Choose config file [1]:
1: Maurits
Choose WP user [1]:
Choose password [NWE0NjE2YW]:
Reset administrator role (y/N)? y
================================================================================
SET @user = 'Maurits';
SET @pass = 'NWE0NjE2YW';
SELECT ID into @user FROM `wp_users` WHERE `user_login`=@user;
UPDATE `wp_users` SET `user_pass`=MD5(@pass) WHERE `ID` = @user;
UPDATE `wp_usermeta` SET `meta_value`='a:1:{s:13:"administrator";s:1:"1";}' WHERE `user_id`=@user AND `meta_key`='wp_capabilities';
UPDATE `wp_usermeta` SET `meta_value`=10 WHERE `user_id`=@user AND `meta_key`='wp_user_level';
================================================================================
Execute this SQL (y/N)? y
Executed SQL successfully
maurits@nuc:~$

wp-reset-ssh.php

This is the source code of the above script:

<?php
echo "WordPress password reset script\n";
$files = array();
exec('locate wp-config.php',$files,$result);
if ($result!=0) {
  echo "Choose search path [.]: ";
  $path = trim(fgets(STDIN));
  if (!$path) $path = '.';
  exec("find '$path' | grep wp-config.php",$files, $result);
}
if ($result!=0 || count($files) == 0) {
  die("ERROR: could not find file 'wp-config.php'");
}
foreach ($files as $i=>$file) echo ($i+1).": $file\n";
echo "Choose config file [1]: ";
$number = trim(fgets(STDIN));
if (!$number) $number = '1';
$lines = file($files[$number-1]);
foreach ($lines as $line) {
  if (preg_match('/^\s*define\(/i',$line)) eval($line);
}
$mysqli = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
$mysqli->set_charset(DB_CHARSET);
if ($mysqli->connect_errno) die($mysqli->connect_error);
$result = $mysqli->query("SELECT `user_login` FROM `wp_users`");
if ($result===false) die($mysqli->error);
$users = array();
while($row=$result->fetch_array()) $users[]=$row[0];
$result->close();
foreach ($users as $i=>$user) echo ($i+1).": $user\n";
echo "Choose WP user [1]: ";
$number = trim(fgets(STDIN));
if (!$number) $number = '1';
$user = $users[$number-1];
$default = substr(rtrim(base64_encode(sha1(microtime())),"="),0,10);
echo "Choose password [$default]: ";
$pass = trim(fgets(STDIN));
if (!$pass) $pass = $default;
$sql = <<<END_OF_SQL
SET @user = '$user';
SET @pass = '$pass';
SELECT ID into @user FROM `wp_users` WHERE `user_login`=@user;
UPDATE `wp_users` SET `user_pass`=MD5(@pass) WHERE `ID` = @user;
END_OF_SQL;
echo "Reset administrator role (y/N)? ";
$yes = trim(fgets(STDIN));
if ($yes=="y") $sql.= <<<END_OF_SQL

UPDATE `wp_usermeta` SET `meta_value`='a:1:{s:13:"administrator";s:1:"1";}' WHERE `user_id`=@user AND `meta_key`='wp_capabilities';
UPDATE `wp_usermeta` SET `meta_value`=10 WHERE `user_id`=@user AND `meta_key`='wp_user_level';
END_OF_SQL;
$bar = str_repeat("=",80);
echo "$bar\n$sql\n$bar\n";
echo "Execute this SQL (y/N)? ";
$yes = trim(fgets(STDIN));
if ($yes!="y") die("Stopped without executing SQL\n");
$mysqli->autocommit(false);
$lines = explode("\n",trim($sql));
foreach ($lines as $query) {
  if ($mysqli->query($query)===false) die($mysqli->error);
}
if ($mysqli->commit()) echo "Executed SQL successfully\n";
else die($mysqli->error);
$mysqli->close();
Share

Using Selenium for automated functional testing

We are now in an age when it is accepted by most IT managers that Software Quality Assurance – and Testing/Validation & Verification in particular – is not only a desirable element in any project, but is actually an essential aspect that cannot be ignored if you want to remain competitive towards more SQA-mature rivals.

The cost of cutting corners usually arrives later, and with heavy interest. In extreme cases, it can make you go bankrupt if the fault has enough impact, but in an age of fast social networking and real-time news – damaging your reputation when your products fail is the most common setback.

Fortunately, it is now possible to rely not only on enterprise-class tools but also on simple, open-source free suites, which help refine the art from management of the initial requirements to test management, automation, defect management, and related practices.


Record and play

Development cycles are getting shorter and the ability to test rapidly in an agile mode going forward is what companies want. At LeaseWeb’s Cloud unit, we have been attempting to find a balance between test costs and coverage, and towards that, there has been an increased effort in areas like unit testing, test automation, and continuous integration.

Shorter periods do not necessarily reduce the risk of new functionality affecting existing functionality; in fact, with frequent releases, there is less time for regression testing. In this post, we will present a small introduction on how an investment on the automation of functional tests, especially regression suites has helped us move faster, without added risk.

Regression cycles can be a drain on productivity and absorb time that would otherwise be spent in other activities, including improving the test management process. Manual regression testing can also be a mundane and boring activity for most test teams, requiring concentration even when following a clear test plan or checklist.

Our team has realized the necessity to automate functional tests and has taken some initial steps:

  • We looked at our test suites and identified core test cases in very high risk/high impact areas.
  • Of the flagged tests, we determined which were more time-consuming on each development cycle, and of those, which would be better performed via automation, and which would benefit the most from experienced-based, human testing, especially when involving exploratory testing techniques. It was determined that the most time-consuming test runs were related to regression on a Bootstrap-frontend-framework based web portal used by our internal teams to manage our Cloud offerings.
  • A subset of the test cases were then selected for automation scripting, allowing us an initial level of coverage of about 43%.
  • With that in mind, we looked at several possible tools for automation, some strongly GUI-dependent, others relying on headless browsers. Both have their strengths and weaknesses, usually trading between ease of first write/maintenance and customization power.

For now, we settled on using Selenium IDE (Se-IDE), a free Firefox extension created by Shinya Kasatani of Japan that can automate the browser usage through a record-and-playback feature. It is both a recording tool and a simple, accessible IDE.

NNE-article1-1The main advantage of Se-IDE is its ease of use when quickly recording test cases by test teams with low-programming skill sets, as well as future easy maintenance. At the same time, it retains the ability to export tests to formats that can be used on Selenium 2 (formerly called WebDriver). In the first case, most interactivity occurs visibly on the browser, while in the latter, extra power is possible via direct control of the browser at OS level.

Even with Se-IDE having limited native functionality, its original commands can be expanded by directly coding JavaScript in the IDE window, should the user need it. In this first article, we will provide an overview of how Se-IDE can be used, with later articles/tutorials focusing on specifics like Element Locators and advanced tests.

Setting up

As a starting point, install the Selenium IDE plugin in Firefox. Selenium IDE has a plugin system that allows for easy extension and customization, with a few additional browser extensions and Se-IDE plugins that can prove useful:

  • Firebug and FirePath: These two extensions provide various useful tools for the Selenium scripter, but object identification will probably be one of the most useful.
  • Highlight Elements: This Selenium plugin allows much easier visual identification of objects being targeted during the execution of a script.

NNE-article1-2

  • Stored Variables: Selenium does not natively provide a way to keep track of stored variables, so this plugin is quite useful.

NNE-article1-3

NNE-article1-4Running the main Selenium IDE plugin

After running Selenium IDE, you can also configure dedicated extensions for the IDE. That can be configured in Options>General>Selenium IDE Extensions. Multiple extensions can be added, comma-separated:

NNE-article1-5

Expanding Selenium IDE further via JavaScript user extensions

The following also prove useful:

  • Sideflow: Selenium does not natively provide a powerful way to control script flow. You can enhance that by adding labels, while cycles, GoTo jumps and so on, via the Sideflow plugin.

NNE-article1-6

Controlling script flow with simple labels, while, and GoToIf usage

  • Random: This library allows the creation of random numbers and strings according to certain parameters. It proves useful to randomize data in relevant test cases.

The usual recipe

After running the IDE window, you will be presented with a blank project. In most cases, the formula to prepare a test case revolves around three basic steps:

  1. Record an execution via manually running a test case.
  2. Fine-tune the recorded script to make it as generic and robust to change as possible, without compromising its ability to validate test conditions. This is the lengthier stage.
  3. Integrate your new test case in the corresponding suite, adding flow-control if necessary. In certain usages, you will want to limit the execution of a test case block depending on previous results and/or required coverage for a release.

Inevitably, you will have to revisit your script as the tested product evolves. Scope changes like new features might require updates. Similarly, the identification of faults in production might bring the need to expand coverage with new tests.

NNE-article1-7

(The Selenium IDE interface, including extra plugins)

Once a stable pool of tests is consolidated, they are executed considerably faster, especially when repeat runs are required. That does not mean, however, that the test cases will not need to be revised often; in our environment, the sprint cycles mean that new functionality is released every two weeks.

In some (most) cases, such new functionality does not affect older regression test cases, but there are occasions when a major interface change might require tweaks to the current scripts, or even a full rewrite. Every time you refactor a script, you might find new ways to make it more adaptable to future changes and updates.

Tracking variables

One way to make the test cases more robust is to use stored variables instead of hardcoded content as much as possible. You can do this with the Store command, later retrieving content with a $ wrapper for full flexibility.

For example, if you store “bar” as the variable my_string_text1, you can later use it in any command, e.g. a Type command with “foo${ my_string_text1}” as value would result in “foobar” being output anywhere during script execution.

If you installed the Stored-Vars plugin mentioned before, a new tab at the bottom of the interface will allow you to keep track of variables, useful during debug/step execution.

Extending the native commands with JavaScript usage

Se-IDE provides a limited number of native functions out-of-the-box. In case you require something that Se-IDE does not originally do, you can add your own JavaScript code. A simple example would be randomizing a username:

NNE-article1-8

Using this in the ‘Target’ field of a Store command, would store “TestUser” plus a random 0-99 number in the variable entered in the value field. While Se-IDE did not natively allow it, a simple code snipped added the feature.

Another simple example would be selecting one of three random locations for a web form, in that case you could do it by using something like this in the target field:

NNE-article1-9

Locating objects

Web test automation predominantly revolves around GUI objects i.e. various UI controls like pull-downs, input boxes, text fields and so on. These objects can be identified via Name, ID, Link, XPath, CSS, etc. and some might have changing properties during runtime.

Once a script is initially recorded, you might find necessary to adjust object identifiers, as they allow Se-IDE to identify targets for actions during runtime, and the accuracy of this process is vital.

Firebug can help identify objects precisely, something you can confirm with the FIND button in the “Target” area of Selenium IDE. You can use Firebug’s “Inspect” tool, select the element and then click FirePath to see its CSS or XPath identifiers.

NNE-article1-10

(Firebug and FirePath showing the XPath locator for an image)

By default, the Se-IDE frequently generates index-based XPath while recording – this is not the right approach and maintainability becomes an issue, as the likelihood of a script breaking simply because an object is later moved is high. For this reason, it might be beneficial to convert those locators to IDs or CSS.

Se-IDE locators’ work on single HTML references at a time, but often you need to work with a nested HTML structure with frames. Firebug can help analyze the HTML DOM to help you derive the best object identification locator.

Wrapping up

In our next posts, we are going to work on a short tutorial and later create advanced automated test cases using only Se-IDE installed as described, as well as delve deeper into locators, recording and editing, and custom JavaScript usage.

Even though the Se-IDE has a decent amount of functionality, it also has a few limitations, for example, it is restricted to only Firefox and it lacks the ability to scale well. To counteract that, we will show you later how to use the IDE to help write cases for the standalone, external Selenium Server.

Share