Monthly Archiv: April, 2020

Switching phubb’s HTTP client

phubb is a WebSub hub that notifies subscribers in realtime when your website is updated.

Up to this year, phubb sent HTTP requests (GET + POST) with file_get_contents() and a HTTP stream context - see my previous example.

But then I needed a 100% correct way of detecting a page's Hub URL, and copied the code from phinde, my blog search engine. With that I introduced a dependency to PEAR's good old HTTP_Request2 library and I decided to use that library for all requests.

Unfortunately, now the problems began: During development I got an error in about one of 10-20 requests on my machine and could not find the cause:

PHP Fatal error:  Uncaught HTTP_Request2_MessageException: Malformed response:  in HTTP/Request2/Adapter/Socket.php on line 1019

#0 HTTP/Request2/Adapter/Socket.php(1019): HTTP_Request2_Response->__construct('', true, Object(Net_URL2))
#1 HTTP/Request2/Adapter/Socket.php(136): HTTP_Request2_Adapter_Socket->readResponse()
#2 HTTP/Request2.php(946): HTTP_Request2_Adapter_Socket->sendRequest(Object(phubb\HttpRequest))
#3 phubb/src/phubb/HttpRequest.php(22): HTTP_Request2->send()
#4 phubb/src/phubb/Task/Publish.php(283): phubb\HttpRequest->send()
#5 phubb/src/phubb/Task/Publish.php(248): phubb\Task_Publish->fetchTopic(Object(phubb\Model_Topic))
#6 phubb/src/phubb/Task/Publish.php(77): phubb\Task_Publish->checkTopicUpdate('http://push-tes...')
#7  in HTTP/Request2/Response.php on line 215

The socket adapter has this problem, and I did not want to try to debug that strange problem. (No idea if the cURL one has it; I do not want to rely on php-curl). Finding a new HTTP library was the only option.

New HTTP library

The PHP Framework Interop Group has several HTTP-related proposals; one of them PSR-18: HTTP Client. Now that we have a standardized way to send HTTP requests in 2020, I should use a library that implements it.

The psr-18 topic on Github listed some clients:

Symfony's HTTP client was among them, and it provides a mock client for unit tests! Unfortunately, it also introduces a million dependencies.

There were two others that looked ok-ish on first sight (diciotto and http-client-curl) but both of them had no mock client, and the latter was even curl only. Again nothing for me.

Then I found PHP-HTTP that promises a standard interface for HTTP clients in PHP, and it supports PSR-18! It even has a socket client that has nearly no dependencies, and a mock client for unit tests. I'll try that one for now.

Community News: Latest PECL Releases (04.21.2020)

Latest PECL Releases:

  • yaf 3.2.1
    - Fixed Namespace resgister unexpected overridden

    • Fixed yaf_slip_equal fails on 4-bytes string
    • Added Yaf_Dispatcher::getResponse()
  • yaf 3.2.0
    - Refactor core data structs for performance, 20% speed up according to demo created by tool/cg/yaf_cg - Implemented PSR-4 autoloading, user now can specific a path for a namespace by Yaf_Loader::registerNamespace(name, path) - Added Yaf_Loader::registerNamespace(), Yaf_Loader::getNamespaces(), Yaf_Loader::getNamespacePath() - Added Yaf_Request::clearParams() - Added Yaf_Controller::getName(), Yaf_Action::getControllerName() - Added Yaf_Dispatcher::getDefaultModule(), Yaf_Dispatcher::getDefaultController() and Yaf_Dispatcher::getDefaultAction() - Added Yaf_Application::getInstance(), which is alias of Yaf_Application:app() - Added optional $format_name argument to Yaf_Request::setModule/Controller/actionName if it set to false, Yaf will set original input as name, default it true, which means Yaf will format the name(camel/lowercase) before set it to Request - Yaf_Controller::__construct now accpet no parameters, it now requires Yaf_Application is initialized. - Rmoved all lead underline for fake protected property name(examing by var_dump) - Fixed bug that protected method of Bootstrap get executed - Yaf_View_Simple is final class now, custom view engin should implements Yaf_View_Interface - Yaf_Route_* now routes valid Module/Controller/action name directly - Yaf_Controller action's arguments will be set even if there are gaps now (see test/issue420.phpt)
  • handlebars 0.9.1
    - Fixed test failure on PHP 8 (@remicollet) - Fixed test failure on 32bit - The compiled template produced by `HandlebarsVM::compile()` should now be deterministic, if using handlebars.c >= 0.7.1.
  • handlebars 0.9.0
    - Preliminary PHP 8 support - Support for precompiling templates - Mustache-style lambda support - Drop max PHP version constraint - Selective helper options omission - Improved typehints See CHANGELOG.md for full details
  • dio 0.2.0
    - fix stream API for PHP 7.4+
  • lzf 1.6.8
    - fix filter prototype for 7.2+
  • pdo_sqlsrv 5.8.1
    [Fixed] - Pull Request [#1094](https://github.com/microsoft/msphpsql/pull/1094) - Fixed default locale issues in Alpine Linux - Pull Request [#1095](https://github.com/microsoft/msphpsql/pull/1095) - Removed unnecessary data structure to support Client-Side Cursors feature in Alpine Linux - Pull Request [#1095](https://github.com/microsoft/msphpsql/pull/1107) - Fixed logging issues when both drivers are enabled in Alpine Linux [Limitations] - No support for inout / output params when using sql_variant type - No support for inout / output params when formatting decimal values - In Linux and macOS, setlocale() only takes effect if it is invoked before the first connection. Attempting to set the locale after connecting will not work - Always Encrypted requires [MS ODBC Driver 17+](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server) - Only Windows Certificate Store and Azure Key Vault are supported. Custom Keystores are not yet supported - Issue [#716](https://github.com/Microsoft/msphpsql/issues/716) - With Always Encrypted enabled, named parameters in subqueries are not supported - Issue [#1050](https://github.com/microsoft/msphpsql/issues/1050) - With Always Encrypted enabled, insertion requires the column list for any tables with identity columns - [Always Encrypted limitations](https://docs.microsoft.com/sql/connect/php/using-always-encrypted-php-drivers#limitations-of-the-php-drivers-when-using-always-encrypted) [Known Issues] - Connection pooling on Linux or macOS is not recommended with [unixODBC](http://www.unixodbc.org/) < 2.3.7 - When pooling is enabled in Linux or macOS - unixODBC <= 2.3.4 (Linux and macOS) might not return proper diagnostic information, such as error messages, warnings and informative messages - due to this unixODBC bug, fetch large data (such as xml, binary) as streams as a workaround. See the examples [here](https://github.com/Microsoft/msphpsql/wiki/Features#pooling)
  • sqlsrv 5.8.1
    [Fixed] - Pull Request [#1094](https://github.com/microsoft/msphpsql/pull/1094) - Fixed default locale issues in Alpine Linux - Pull Request [#1095](https://github.com/microsoft/msphpsql/pull/1095) - Removed unnecessary data structure to support Client-Side Cursors feature in Alpine Linux - Pull Request [#1095](https://github.com/microsoft/msphpsql/pull/1107) - Fixed logging issues when both drivers are enabled in Alpine Linux [Limitations] - No support for inout / output params when using sql_variant type - No support for inout / output params when formatting decimal values - In Linux and macOS, setlocale() only takes effect if it is invoked before the first connection. Attempting to set the locale after connecting will not work - Always Encrypted requires [MS ODBC Driver 17+](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server) - Only Windows Certificate Store and Azure Key Vault are supported. Custom Keystores are not yet supported - Issue [#716](https://github.com/Microsoft/msphpsql/issues/716) - With Always Encrypted enabled, named parameters in subqueries are not supported - Issue [#1050](https://github.com/microsoft/msphpsql/issues/1050) - With Always Encrypted enabled, insertion requires the column list for any tables with identity columns - [Always Encrypted limitations](https://docs.microsoft.com/sql/connect/php/using-always-encrypted-php-drivers#limitations-of-the-php-drivers-when-using-always-encrypted) [Known Issues] - Connection pooling on Linux or macOS is not recommended with [unixODBC](http://www.unixodbc.org/) < 2.3.7 - When pooling is enabled in Linux or macOS - unixODBC <= 2.3.4 (Linux and macOS) might not return proper diagnostic information, such as error messages, warnings and informative messages - due to this unixODBC bug, fetch large data (such as xml, binary) as streams as a workaround. See the examples [here](https://github.com/Microsoft/msphpsql/wiki/Features#pooling)

Platform.sh + Lando: local dev in perfect sync with the cloud

Platform.sh removes a major pain point for developers: having to invest time in managing servers, virtual machines, or containers. Instead, Platform.sh enables developers to focus 100% of their time on their code. Since the beginning, Platform.sh has provided instant cloning capability, so dev teams can work on perfect copies of their production sites in the cloud for every Git branch. Now, in partnership with Lando, we’re extending that capability to the desktop.

Helping Clients Rapidly Adopt New Business Models

For many website owners, it is anything but business as usual. COVID-19 has forced temporary closures or otherwise limited companies with physical locations. And even online retailers are feeling the pressure of working remotely and the domino effect of impacted vendors.

It’s apparent that a number of businesses are scrambling to survive. This has meant developing new revenue streams on the fly. Brick and mortar stores are throwing together eCommerce sites or expanding existing services. Those who rely on in-person events are now turning to online video.

This is a major challenge for web designers. Clients are expecting to make big changes in a very short amount time. If you’re a freelancer who manages a lot of websites, this may be result in an avalanche of work coming your way.

How can we best deal with these rapid changes? First, take a deep breath. Then, review the following tips for making the process as pain-free as possible.

Advise Clients to Start Small

If a client approaches you with a big idea that will fundamentally change their business, it’s likely to have just as big of an impact on their website. This could mean refactoring a shopping cart or implementing entirely new features.

From the client’s perspective, they are focused on survival in a very uncertain time. Therefore, it’s understandable that they may want to “go big” and will want to do so ASAP.

Designers and developers, however, need a little time to come up with the right solution. In that sense, we need to slow things down a bit.

It’s vital to explain the situation in plain terms. Let your client know the full scope of what’s involved. Fill them in on the process and the potential ramifications of getting this wrong (such as rebuilding the whole thing in six months).

Advise them that, when possible, it’s better to start things off with more incremental changes. For instance, rather than putting all 1,000 or their products into WooCommerce, maybe start with 50 of the top-sellers. This way, they can get their feet wet with selling online. They’ll get a sense of how to best handle shipping and customer service, etc.

Big changes in a short period of time can wreak havoc on a business. Remind clients of the benefits of taking baby steps.

father walking child taking baby steps

Charge Extra for Tight Timelines

For clients who have very accelerated timelines for launching a new feature, designers should charge accordingly. This is not to say that we should ever take advantage of a crisis. However, these types of projects can be incredibly stressful. We should at least be well-paid for it.

While some people may baulk at a higher price, most should understand the reasoning behind it. But if a client is attempting to push you to your limits without properly compensating you, perhaps the job is just not worth the trouble.

In a sense, part of the challenge is to encourage clients to get their priorities in line. One way to accomplish this is to provide multiple pricing options. The shorter the timeframe, the higher the price.

This can force a client to decide whether or not that feature is must-have-now or if taking a little extra time is more prudent.

time clock wall timeframe vintage

Encourage Big-Picture Thinking

For everyone involved, the overall goal should be to get things right the first time. Or, as much as possible given the information we have on hand.

As web designers, we will likely recognize this more quickly than our clients. One reason for this is that we know the technological challenges involved. Our experience with various software packages and types of websites are a great resource for spotting potential roadblocks.

A client focused on making up for lost revenue may not be thinking about the long-term. This is something we’ll need to communicate to them.

Explain that the best option for getting a feature up-and-running quickly isn’t necessarily the same as the best long-term solution. They need to know that, if they choose the short-term option, they’ll likely have to invest in something better down the road.

This is especially the case when dealing with third-party software such as WordPress plugins. There may be ways to implement a feature immediately, but will be a nightmare to maintain if business expands.

In the end, a client may still choose the quicker path. That’s okay, as long as they understand the downsides of doing so.

speed work desk computer

Directing Clients to the Best Solutions

Maybe the best way to both help clients and maintain sanity is to start a dialogue. Clients hire us because of our expertise, after all.

In more normalized times, we would want to take the time to ask the right questions. Find out a client’s pain points and their goals. From there, develop the best solution to make it all work.

But the present time does feel different. Business owners are worried about the future – and rightfully so. Still, that doesn’t mean that we should shrivel under these circumstances.

It’s just as important to have those same conversations. Perhaps even more so, as communication is what will ensure that everyone is on the same page.

So, listen to what your clients have to say. Gain an understanding of their concerns. At the same time, help them to make rational decisions when it comes to their websites. This will save both you and them some major headaches in the long run.

The post Helping Clients Rapidly Adopt New Business Models appeared first on Speckyboy Design Magazine.

Building a PC, Part IX: Downsizing

Hard to believe that I've had the same PC case since 2011, and my last serious upgrade was in 2015. I guess that's yet another sign that the PC is over, because PC upgrades have gotten really boring. It took 5 years for me to muster up the initiative to get my system fully upgraded! 🥱

I've been slogging away at this for quite some time now. My PC build blog entry series spans 13 glorious years:

The future of PCs may not necessarily be more speed (though there is some of that, if you read on), but in smaller builds. For this iteration, my go-to cases are the Dan A4 SFX ...

And the Streacom DA2 ...

The attraction here is maximum power in minimum size. Note that each of these cases are just large enough to fit ...

  • a standard mini-ITX system
  • SFX power supply
  • full sized GPU
  • reasonable CPU cooler

... though the DA2 offers substantially more room for cooling the CPU and adding fans.

http://i.imgur.com/odoYjle.jpg

I'm not sure you can physically build a smaller standard mini-ITX system than the DAN A4 SFX, at least not without custom parts!

DAN A4-SFX
200mm × 115mm × 317mm = 7.3 liters

Silverstone RVZ02 / ML08
380mm × 87mm × 370mm = 12.2 liters

nCase M1
240mm × 160mm × 328 mm = 12.6 liters

Streacom DA2
180mm × 286mm × 340mm = 17.5 liters

(For comparison with The Golden Age of x86 Gaming Consoles, a PS4 Pro occupies 5.3 liters and an Xbox One S 4.3 liters. About 50% more volume for considerably more than 2× the power isn't a bad deal!)

I chose the Streacom DA2 as my personal build, because after experimenting heavily with the DAN A4 SFX, I realized you need more room to deal with extremely powerful CPUs and GPUs in this form factor, and I wanted a truly powerful system:

  • Intel i9-9900KS (8 core, 16 thread, 5.0 GHz) CPU
  • Samsung 970 PRO 1TB / Samsung 970 EVO 2TB / Samsung 860 QVO 4TB SATA
  • 64GB DDR4-3000
  • Cryorig H7 cooler (exact fit)
  • NVIDIA GeForce RTX 2080 Ti GPU

Compared to my old 2015-2017 system, a slightly overclocked i7-7700k, that at least gives me 2× the cores (and faster cores, both in clock rate and IPC), 2× the memory, and 2× the M.2 slots (two versus one).

The DA2 is a clever case though less perfect than the A4-SFX. What's neat about it is the hybrid open-air design (on the top and bottom) plus the versatile horizontal and vertical bracket system interior. Per the manual (pdf):

Check out all the bracket mounting options. Incredibly versatile, and easy to manupulate with the captured nut and bolt design:

Note that you can (and really should) pop out the top and bottom acrylic pieces with the mesh dust net.

I had dramatically better temperatures after I did this, and it also made the build easier since the case can fully "breathe" through the top and bottom. You'll note that the front of the DA2 is totally solid, no air holes, so you do need that extra airflow.

I only have a few criticisms of this Streacom DA2 case:

  • The side panels are tool free, which is excellent, but the pressure fit makes them fairly difficult to remove. Feels like this could be tweaked?
  • (Don't even think about using a full sized ATX power supply. In theory it is supported, but the build becomes so much more difficult. Use a SFX power supply, which you'd expect to do for a mini-ITX build anyway.)
  • My primary complaint is that the power extension cable gets in the way. I had to remove it and re-attach it during my build. They should custom route the power cable upwards so it blocks less stuff.
  • Less of a criticism and more of an observation: if your build uses a powerful GPU and CPU, you'll need two case fans. There's mounting points for a 92mm fan in the rear, and the bracket system makes it easy to mount a 140mm fan blowing inward. You will definitely need both fans!

Here's the configuration I recommend, open on both the top and bottom for maximum airflow, with three fans total:

If you are a water cooling kind of person – I am definitely not, I experienced one too many traumatic cooling fluid leaks in the early 2000s – then you will use that 140mm space for the radiator.

I have definitely burn-in tested this machine, as I do all systems I build, and it passed with flying colors. But to be honest, if you expect to be under full CPU and GPU loads for extended periods of time you might need to switch to water cooling due to the space constraints. (Or pick slightly less powerful components.)

If you haven't built a PC system recently, it's easier than it has ever been. Heck by the time you install the M.2 drives, memory, CPU, and cooler on the motherboard you're almost done, these days!

There are a lot of interesting compact mini-itx builds out there. Perhaps that's the primary innovation in PC building for 2020 and beyond – packing all that power into less than 20 liters of space!

Powered by Gewgley