Pythonistas in Portlandia – PyCon US 2017

Apologies for being silent these past few months. I tried to concentrate on launching a product earlier in the year, and I was hopeful that I would get it out soon. Unfortunately it didn’t work out and I will have to shelf development.

That said, I am looking forward to going to Portland and PyCon US 2017 this weekend. I will be also at the sprints next week too. Not presenting a talk this year, but I am looking forward to meeting everyone attending. Message me on twitter @dorianpula and maybe we’ll be able to meet up if you are going.

So much Writing and Coding… so Little Time

I must apologize to regular readers of my blog, that I have been slacking. I plan on writing a blog entry once a week, and even though this one is late, I am trying to keep my promises. At least one should keep promises to one self. And I apologize if this entry is a bit sparse. It is a bit “phoned in”, I guess.

Anyways, I have been keeping busy with my many projects. Because of this I feel like I am pulling myself in a bunch of directions at the same time. This feels counterproductive and progress is slow. But I’m not sure of a better way to progress forward. I fear concentrating on one project, will just make everything else fall behind. Basically what I’m saying is that I’m trying to show some real progress on my open source projects, my not-so-open-source product, my writing, and bunch of other things… but yeah… it may be a while before I have anything substantial to show. Sorry.

Don’t even ask about all my emails… it is all a bit overwhelming. I will try to get back to everyone… but there really is so much to do. And only one of me… sigh…

In the meantime, I will try to keep up with the blogging. Maybe about some tips and tricks, but no real long articles for now. At least until I feel things get more manageable.

Anyways, take care and see you next week!

PyCon CA 2016 – The Art of Writing Wargames in Python with Kivy

Intro

Last year in November, I presented a talk about Kivy at PyCon Canada 2016. I talked about my experiences working with Kivy in the context of writing a strategy game. I discussed the various UI frameworks available to a Python developer, and why Kivy is currently the best choices for UIs in Python. Especially if you are interested in making a cross-platform app or game.

Video

Links

Abstract

Many of us got our start in programming, by building games and simple apps. However creating interesting games and UIs in Python was not a simple task especially for multiple platforms. Kivy, a cross-platform Python UI app framework changes all that. This talk discusses the journey of working with Kivy to develop a moderately complex strategy game. It also contrasts to using other platforms

Reaction

Overall, the talk went better than I expected. The audience was engaged and interested. There was a few technical difficulties, namely I had to resort to using my phone as a wifi hotspot to run my presentation rather than Ryerson University’s wifi. Also there was a noticeable delay between when I changed slides on my presentation notes, and the projected display. This kind of delay is probably the only downside of using slides.com this time around. Having a local copy would of worked better, which I will do so in the future.

Also I wish I had more time to come up with a better demo for the presentation. However even after the sprints, the hex grid layout still plagues my Kivy app. In hindsight, I probably should of worked on a simpler app. Also some folks were turned off by the use of wargames, rather general games. But you know, you learn from your mistakes.

Finally I got quite a few questions, and people are genuinely interested in checking out Kivy. Which ultimately was what I was trying to achieve with this talk.

Encrypt All the Things!

This week has been a rough one for me, so I’ll keep this blog entry short.

However I am pleased to announce that after a bit of struggle, I have setup HTTPS on all my sites, including this one. Thanks to Let’s Encrypt and specifically the acme-nginx project to making that possible. Getting everything setup, and automated using Ansible took a bit of work, but in the end it was worth it.

In the future I am looking forward to using the new more secure TLS 1.3 standard once it is supported more widely by NGINX and various browsers.

Merry Christmas and Happy New Year 2017!

Hey Readers,

Sorry for the delay between posts. I went on an unannounced hiatus, just because of the busyness of last year. However I am back, and I will return to my regular posting schedule of once a week, most likely either Wednesday or Thursday morning.

Also I hope everyone had a Merry Christmas (or has if you’re celebrating the 12 days of Christmas), and I hope your New Year is happy, bright and full of promise!

— Dorian

Avoiding Blank PHP Responses after upgrading to Ubuntu 16.04, and php7.0-fpm

Earlier this week I finally made the plunge to upgrade my VPS to Ubuntu 16.04. With a minor hiccup surrounding supervisord (which I probably can avoid if I go the systemd route) not being enabled at boot, the upgrade was simple for both my WSGI and Node webapps.

I can not say the same thing about my WordPress/PHP installations. (Installations that I hope to transition off to Rookeries once that software becomes more stable.) It took me a few hours to track down and resolve the problems. Hence I am posting this article, to hopefully save someone else’s time when they do the same upgrade.

Upgrading to PHP 7.0

Ubuntu 16.04 makes the switch away from PHP 5 to PHP 7. So I had to switch to php7.0, php7.0-fpm, and php7.0-mysql from their PHP 5 equivalents. The location of the running UNIX socket has changed from /var/run/php5-fpm.sock to /var/run/php/php7.0-fpm.sock, as did the PID files.

Updating the PHP-FPM configuration

Running WordPress using FPM (Fast Process Manager) and NGINX, requires turning off the path translation in php.ini file. This can be done by uncommenting the line cgi.fix_pathinfo=0 found in the configuration file /etc/php/7.0/fpm/php.ini. Again these files have moved from the old location. After you’ve done this remember to restart the FPM service using the new systemd utilities: sudo systemctl restart php7.0-fpm.

Updating the NGINX configuration and Solving the Blank Response

This is the tricky part. After updating my NGINX configurations to the new UNIX socket path, and restarting NGINX, I found that I got blank PHP responses. Everything else worked, expect that any PHP page would not render. And not render by not rendering any content in the body of the responses. That led me down a few rabbit holes, and researching how to re-architecture my setup using Docker. Eventually I stumbled across a blog entry with the solution to the blank PHP response issue.

In a nutshell, with the NGINX upgrade one of the parameters needed for FastCGI went missing namely the fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; bit. Oddly this parameter appears in /etc/nginx/fastcgi.conf and not the /etc/nginx/fastcgi_params file that I normally include in my NGINX configs. Anyways after adding this line and restarting NGINX using sudo systemctl restart nginx everything worked correctly. Below I’ve included a sample NGINX configuration that should work.

Sample NGINX Configuration /etc/nginx/site-enabled/example-site.conf

“`
server {
server_name .example-site.com;
index index.php;
root /srv/www/location_of_wordpress_install;
listen 80;

access_log      /var/logs/nginx/site-access.log;
error_log       /var/logs/nginx/site-error.log info;

location / {
    try_files       $uri $uri/ /index.php$args;
}

location ~ \.php$ {                        
    fastcgi_split_path_info     ^(.+\.php)(/.+)$;
    fastcgi_pass    unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    include         fastcgi_params;
}

location ~* \.(js|css|png|jpg|jpeg|gof|ico)$ {
    expires         max;
    log_not_found   off;
}

}
“`

Selling Off Some Domains

I was going to write about why needing an app isn’t a good way to try get into business. (Hint: It is very expensive, if you can’t code it yourself.) However something else popped up, namely I am trying to sell off two domains: justcheckers.org and justcheckers.net that I own. These were for the justCheckers project, that I’m essentially shutting down. Anyways if you are interested in buying them off me, feel free to contact me.

I will say that the experience so far has been interesting. Thankfully there are some good resources for selling a domain or site. I’ve looked at two companies that handle the auction and transfer of these things Flippa and Sedo. Both are quite legitimate, but there were some bad reviews and some people claiming to have been scammed. I’m trying out Flippa first since it was founded by the fine folks at SitePoint, who I quite like for other reasons. Anyways, I’m hoping that I can find a good home for the domains.

See you at PyCon Canada 2016!

I’m looking forward to PyCon Canada 2016 that will be happening November 12-13 in Toronto. I submitted two talk proposals and I’m hoping that one of them gets accepted. But regardless I am looking forward to the conference. If you are at the conference, and you want to meet up just message me via Twitter @dorianpula. Also I plan coming out to the sprints that I’m hoping will be happening afterwards. See you there!

Rust, a New Toy Opening New Possibilities

I have not had a chance to blog in a while. Aside from the usual busyness of life, and the occasional bouts of illness, I have been distracted by a few new thing I’ve been learning: Rust, Kivy and Electron. I’ll write about Kivy and Electron in a future post. And a lot of that is centred around the upcoming product launches for Amber Penguin Software. But that is again for another post.

Rust

For the longest time, systems level programming (especially operating systems) have fascinated me. As part of that, I tried to learn the languages used to implement systems namely C and C++. While today I feel more comfortable with these languages, these still scare me with either their complexity (C++), their programming tools (gdb, gcc, autoconf, and minions) and their potential to do horrible things to your system if you are not careful. And bugs can be incredibly difficult to trace down and debug. So I while I have tried to code more C and C++, I still avoid them for these reasons.

Recently I started playing around with Rust, the new language developed partially by Mozillians. After trying to write a small Docker utility in Rust, and working through some koans for Rust, I have become smitten with the language. While some of the borrowing, references and types drive me a bit crazy, overall Rust is an amazing language. It brings the best ideas from Haskell, ML, Python and C and makes them very accessible. While the language is new and evolving the community has super active and creating lots of libraries for the language on crate.io.

Also I recommend listening to the New Rustacean podcast to learn Rust as well. It is not only informative, but very well executed by host Chris Krycho. So far I’ve listened to 10 episodes, and between the podcast, the koans and simply playing with Rust, I’ve learned a lot about Rust. In fact I feel more comfortable with Rust now then I have ever felt with C or C++.

Qt Bindings for Rust or Rather the Lack Of

On the topic C++, the one thing that keeps bringing me back to liar of C++ is the amazing platform that is Qt. However one on the most infuriating thing is that (aside from the limited QML), the only effective way to program Qt apps is using C++. Sure there is PySide and PyQt, with promises that PySide will actually support modern Qt5… some day… soon…

One of the things I hoped for Rust bindings for Qt to come quickly. Unfortunately it turns out that binding to Qt and C++ inside of Rust is really, really hard. There is an interesting project to develop some Qt C bindings for Rust, but it is really early in development and I had no luck using it. It probably is easier to bring in Rust to a C++ Qt project than the other way around.

In general UIs in Rust is a weak point for the language. Then again UI libraries are not the simplest thing to get off the ground, and it might be easier to rethink how we build them in general. Again this something I can get to in a future post.