Category Archives: Tech Fail

ChatGPT and Basic Calculus

Being a Computer Science master’s graduate, I had also being taught courses about Artificial Intelligence. Back then though, those were pretty basic. In ’08, all that was described as AI, was merely some algorithms that were designed to solve or calculate a specific set of problems.

Most common problem I can remember from back then was to write an algorithm that solves Euler’s 8 queens problem, or an algorithm for a permutation of the common puzzle of Hanoi Tower.

The theory behind the AI, was fairly simple. Algorithms and Data Structures, and actually it stopped there! No statistics, nothing fancy from a mathematical point. I can still remember BFS and DFS, but those were thoroughly taught at a separate lesson, called “Algorithms and Data Structures”.

Another aspect that was taught at that lesson, was how to use A* in a graph diagram, or a tree diagram, in order to reduce the possible branches in a potential “Artificial Intelligence” solution employed in an application. But frankly, the use of todays tools needed to create a serious AI application, weren’t the subject of that course.

“Pattern Recognition” was the most similar course that seems to be related to todays AI applications. This course was indeed a more “control theory” oriented course that was the grand-father of todays pattern recognition. Regression and discrete mathematics were the basic subjects of this course. Not probabilistic theory. Not even statistics. Now, after 15 years it has changed radically.

Last night, I decided to ask a very basic calculus question, the kind that 17 year old students are being taught. The subject was limits, and given some mathematical function, to calculate the limit of that function while the values approach the infinite.

A trip to Infinity

To Infinity and beyond!

A small parenthesis here. I have watched the documentary from Netflix, called “A trip to Infinity“, which was amazing! The stories explained in that documentary were very well presented. The “Infinite Hotel”, with infinite many rooms, which always has a room available, and the manager who visits all the rooms just in 1 minute. The Japanese Godzilla story was also very good. Later, physics are also involved and that abstract mathematical concept, called infinity is being applied to our real world universe. Definitely recommended, and I have to say I was very impressed with the work they did!

However, this is something that unfortunately cannot be easily represented in the limited space of a LLM AI application such as ChatGPT. I think in general the Calculus quizzes cannot be answered that well via that model. The reason, is, that it requires a huge amount of data (one would argue infinite?) to actually grasp the concept of something that big as infinity. Even at the very first lessons of my masters, we were taught that a computing machine cannot grasp the concept of infinity.

As simple as doing a division by zero, will raise an exception or make any program crass (I’ll write a blog post sometime why this in PHP created a few hundred thousand dollars losses, once in a blue moon), ChatGPT also crashed when I tried repeatedly to request it to calculate the simple limit:

This is what it replied with:

The calculation of this limit is being done by approximation, a strange technique, but valid from a more practical view, nonetheless.

When I “devised” the above quiz, I had in mind this:

L’Hôpital’s rule

The above rule merely says the following:

If after calculating separately the limits of the numerator and the denominator you reach to a paradox like:

or :

and if we assume the denominator to be a function that is continuous and differentiable, and the same happens to the numerator as well, then the above limit gets transformed to:

Interesting…

Therefore, I saw the response and I quizzically asked:

Completely wrong, but partly also right?

And there you have it. ChatGTP completely flunked the response. The function for the limit calculation changed radically into a sinusoidal function (who knows why? some neuron had different weights and thats the first thing that connected with the question?).

Luckily the response was the same, and correct still, at 0.

I decided to give it another chance:

ChatGPT acknowledges the defect

Again, even though it acknowledged the defect, and it made it even worse! Now it calculated it to 2/3, which is completely wrong.

That’s where I decided to stop playing with ChatGPT and Basic Calculus. I believe it is actually very well written, but, when it involves abstract thinking, we have a long – long way to go…

Conclusion

If you are a calculus student and you want to cheat your homework with ChatGPT, do think it twice. You might get a correct answer result (after all there are a few stuff we can’t calculate with calculatory methods), but the proof of that answer would be mathematically incorrect!

Upgrading to WordPress 3.9 in Heroku

As you may already know, our blog is using the WordPress Heroku PHP Buildpack.

Now, since April of 2014 Heroku has updated it’s buildpack to support officially PHP and their final version here. They have done a really fine job, compared to the old legacy buildpack which involved a custom build batch file, and a plain empty php file to procreate the Heroku Dyno to run the Apache process with php process. More details from this awesome guy, here : https://github.com/mhoofman/wordpress-heroku and the dyno changes here : https://github.com/xyu/wordpress-heroku .

Our current installation though uses also WordPress.

Since then WordPress has released some considerable updates, and we need to update to the newest version. So, doing the necessary process, downloading WP3.9.2 , extracting it to the current setup, committing, pushing to heroku master.

At first heroku fails. Since by default it uses the new buildpack and requires composer.json to exist, so as to run Composer and configure afterwards the PHP-Heroku-Buildpack. Now, that was my point of failure since I did not notice that you can keep the legacy buildpack (but hey, new is always better right?) and I agreed to take on the new one.

After following the guide here Getting Started With PHP ,  created a composer.json (currently empty since we did not require anything new) and modified Procfile since we needed to explicitly tell Heroku that we had a custom Apache configuration.

A custom Apache Configuration?

Aye. While on the old buildpack you could initialize the stack with php, some WordPress plugins (such as Jetpack, or Zip support) did multiple requests on the server (I assume Ajax ?) and Heroku did not support concurrent requests in the old buildpack. Zip required to include mod_deflate.so. So I found out this guy: https://github.com/xyu/ who wrote a custom script doing nothing more complex than including to the Apache conf his configuration which in turn enabled the concurrent requests. This file was being loaded at startup, when heroku dyno was running.

Searching the Heroku documentation

..and I found out that if you want to include a http.conf  file you have to do it somehow like this :
web: vendor/bin/heroku-php-apache2 -C apache_app.conf
by modifying the Procfile and inserting the custom config file.

Obviously that did not work.

There were warnings that stated that we could not declare ServerLimit inside the VirtualHost section. Which later on made more sense when I saw how New Heroku buildpack integrates apache…

Aside from that, in the Heroku Logs :

There were enough warnings (and a fatal) like these :
2014-04-30T17:59:48.184463+00:00 app[web.1]: [30-Apr-2014 17:59:47] WARNING: [pool www] child 48 said into stderr: "NOTICE: PHP message: PHP Warning: pg_query(): Query failed: ERROR: missing FROM-clause entry for table "session""
2014-04-30T17:59:48.184466+00:00 app[web.1]: [30-Apr-2014 17:59:47] WARNING: [pool www] child 48 said into stderr: "LINE 1: SELECT @@SESSION.sql_mode"
2014-04-30T17:59:48.184468+00:00 app[web.1]: [30-Apr-2014 17:59:47] WARNING: [pool www] child 48 said into stderr: " ^ in /app/wp-content/pg4wp/driver_pgsql.php on line 140"

I’m not a Postgres expert, I’m more familiar with MySQL so, I decided that I should install my blog locally.

Downloaded the Postgres dump, restored in local instance, along with the new buildpack, ran an apache instance, and voila another error:
LINE 1: SELECT @@SESSION.sql_mode
^ in /var/sites/example.com/www/wp-content/pg4wp/driver_pgsql.php on line 133
PHP message: PHP Fatal error: Call to undefined function wpsql_errno() in /var/sites/example.com/www/wp-content/pg4wp/core.php(32) : eval()'d code on line 1531"

That one was mitigated from these guys here : https://vitoriodelage.wordpress.com/2014/06/06/add-missing-wpsql_errno-in-pg4wp-plugin/

When I was sure that everything works as intended, I finally pushed again.

Nothing. 0. Actually 500:

500

Checked the logs and I was getting a VERY  descriptive message :
2014-22-11T03:17:49+00:00 heroku[router]: Error H12 (Request timeout) -> GET / dyno=web.1 queue= wait= service=30000ms status=503 bytes=0

This error was not helping at all. No matter what I tried after that, I kept receiving timeout, as if the php apache process was eating up all the resources of the dyno. Clearly something is very wrong…

Finally, I decided to use the standard legacy buildpack

And reverted everything, after upgrading to the new WordPress, migrating the database locally and updating the cloud afterwards.
I used the legacy buildpack by running in my local heroku env:
heroku config:set "BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git#legacy"

 

I have just recently found out that the guy who wrote the plugin connecting to Postgres (this guy: https://wordpress.org/plugins/postgresql-for-wordpress/ ) has recently stoped developing it. And later, (although I still have second thoughts on How hhvm is compatible with php 5.3 and more specifically 5.3 in WordPress) Xiao who migrated his blog to HH-VM/NginX/MySQL heroku build pack : https://github.com/xyu/heroku-wp .

As soon as I have updated I will gather results to see how it went.

EDIT: It looks like there is an update for PG4WP I have been missing. Trying it and letting you know…
EDIT2: Nothing. The process keeps hanging by returning :
←[0m at=error code=H12 desc="Request timeout" method=GET path="/" host=www.must-feed.com request_id=fcaa61c9-1bbf-48d2-9b3c-797ca14ffa58 fwd="192.168.84.223" dyno=web.1 connect=1ms service=30000ms status=503 bytes=1240

5 Unbelievable Security Fixes

While working with security…

…you often find yourself between a rock and a hard place.

Solutions must be provided in with low cost both in time and money !

Since one of my responsibilities during my morning job is security, we had, as a team to outthink all the potential attackers. Now this is a quite hard job to do. While we had a lot of brainstorming going, we decided to take a break. And one of our colleagues came out with the following blog post. Have a look: 

I hope its a demonstration if proper camera usage…

Better than NSA


Looks like I’ll have to think twice before trespassing…

Watch out, it looks very fierce

 

Practical and Efficient

Always lock your mo-pad!

 

Always, always think big!

After some years the chain will actually grow into the tree, rendering it impossible to move

 

But above all, know how to:

Protect and Spell!

 

I personally think that it gives a totally new meaning

to the term “security fixes”. I just hoped I had the opportunity to implement those security fixes during a PCI/DSS audit… By the way, in terms of development and bug-introducing procedure (we all had this, bugs are unfortunately unavoidable), not while ago there was this bug.

The heartbleed bug, has efficiently put all internet to knees…

Heartbleed bug was at the same (ok, a little more) level of stupidity.

<

pre>


/* Enter response type, length and copy payload */
*bp++ = TLS1_HB_RESPONSE;
s2n(payload, bp);
memcpy(bp, pl, payload);

There was absolutely NO static analysis problem. NO compilation error. Nothing at all. Just a stupid thing that two variables where controller by the user. And if you change those two variables you’re gonna get a GOOD dump of the nearby memory….

That was the case…

Source : Diply