Home
About
Search
🌐
English Română
  • How to make use of the Xiaomi Air Conditioning Companion in Home Assistant in only 20 easy steps!

    Citește postarea în română

    Oct 13, 2019 homeassistant
    Share on:

    Xiaomi Air Conditioning Companion si Home assistant

    Step 1:

    Buy a Xiaomi Air Conditioning Companion without first researching how well it is supported by Home Assistant.

    Step 2:

    Realize that the Chinese power socket for 16A is different from the 10A one.

    Step 3:

    Realize that nobody is selling a 16A socket adapter for a 10A China power outlet in Romania.

    Step 4:

    Order a 16A power socket from China.

    Step 5:

    Wait 2 months for both the socket and the device to arrive from China.

    Step 6:

    Realize that there is no adapter for the wall outlet from China also.

    Step 7:

    Find the only seller that will sell a modular outlet that matches outlet box, probably by mistake

    Step 8:

    Wait for them to tell you that it will be delivered in a month

    Step 9:

    If it did not arrive yet, wait for a socket module to be delivered

    Step 10:

    Install the wall module and power socket

    Step 11:

    Connect the Xiaomi Air Conditioning Companion and AC for the first time

    Step 12:

    Realize that the Xiaomi Mi Home App has been updated in the meantime and there is no working tutorial on how to get the password for Home Assistant.

    Step 13:

    Figure out (after many tries) how to get the gateway password.

    Step 14:

    Add it to Home Assistant and realize that the gateway is not well supported and that the only things you can do from Home Assistant are sound the alarm and change its volume.

    Step 15:

    Find the xiaomi_airconditioningcompanion module and realize that you didn’t need the gateway password in the first place.

    Step 16:

    Downgrade the Xiaomi Mi Home App to get the token as specified in the instructions: https://www.home-assistant.io/integrations/vacuum.xiaomi_miio#retrieving-the-access-token

    Step 17:

    Realize that you don’t have the right version of Hass.io to use the module.

    Step 18:

    Move to Hassbian from Hass.io

    Step 19:

    Finally, install the extension and setup the module.

    Step 20:

    Now the only thing that remains is to enjoy the comfort of controlling your air conditioning from a few feet away, without ever using the remote!

  • How I use Magento2 on my local with Docker and Docker Compose

    Citește postarea în română

    Nov 29, 2018 docker docker-compose magento2 nginx PHP
    Share on:

    Disclaimer

    Please note that this solution is tailored specifically for my needs and, while your needs may vary, don’t worry, everything is on GitHub, so feel free to take what you need.

    I would like to add that this is not a “you’ve been using Docker with Magento2 wrong, this is how it’s done” kind of blog, I just want to share what I’m using and how. It may not be the best fit for you, but maybe you will find something useful.

    Intro

    For almost 2 years I’ve been using Magento2 in Docker containers. I’ve been doing that before, but I must admit that it was because I had to, not because I’ve seen the light, I mean advantages.

    As you may know Magento2 is not exactly a small and light app, it’s quite heavy on the resources, especially during development.

    Compared to a VM, with Docker you get:

    • Speed: I think the speed is one of the biggest advantages, you can stop and start containers very fast, only the first build will take time, after that it will be very fast;
    • Light on resources: Compared to a VM, the container does not need to include the entire operating system, so it will not take a lot of space on disk and will not use a lot of processing power, because it’s not an entire OS doing… well… OS stuff, it’s just a server most of the time.

    What you don’t get:

    • Learning curve: if you don’t know Docker and Docker Compose, it will be less intuitive at first;
    • First setup: harder to setup at first, if you have been using a VM for a long time, you will feel that you are going against the tide, but I assure you, in the long term it will be a lot simpler this way.

    Taking the above into consideration, I would like to say that when I’ve started with this setup I was using Linux with 8G of RAM. One of my colleagues even wished me good luck on installing Magento2 on a ultraportable 8Gb RAM system. He wasn’t even sarcastic, more like pitying me for my bad workstation selection.

    One of the requirements was that I needed some isolation and configuration between projects, I couldn’t just install a server and be done with it.

    Previously I’ve been using Vagrant and VirtualBox, a great fit, very easy to use (most of the time). However, for Magento2 I’ve realised that it was heavy enough on its own, it was making me run out of resources fast.

    Also, I wanted it to be easy to use, I don’t like to have to remember and type out a 3 word command, I just want to press some tabs and get it over with.

    The requirements

    There were some specific requirements:

    • nginx config – should work out of the box, Magento configuration isn’t very small, I wanted to make use of it with ease;
    • SSL – the domain has to also work with HTTPS, mostly because some APIs require it, the certificates don’t need to be valid;
    • bash – the Magento command should work as the system user, not as root (as containers usually do). This is required, because I don’t want the files generated by Magento to be generated as root (and therefore only removable with root rights);
    • xdebug – must work out of the box and be easily integrated with an IDE.

    The implementation and usage

    Magento2 offered a Docker container to work with. I will not say anything about it, since it wasn’t at all something I needed.

    My main source of inspiration was: https://github.com/markoshust/docker-magento. The project changed a lot since I’ve started, so I definitely think you should check it out.

    The starter point is: https://github.com/claudiu-persoiu/magento2-docker-compose

    The relevant files are:

    • magento2 – it should contain a folder html with the project
    • dkc_short – it can reside anywhere, but it should be added to the files ~/.bash_profile or ~/.bashrc, this file contains shortcuts, it’s not necessary, but I like it because it make my life easier;
    • docker-compose.yml – it contains all the mappings and relevant containers.

    NOTE: I think I should point out that the commands on the PHP container run in two ways, as the system user or as root. This is a limitation of the Linux implementation, please make a note of it, as I will refer to it later.

    Step 1:

    What you should do when starting a new project with an existing Magento2 repository:

    1$ git clone https://github.com/claudiu-persoiu/magento2-docker-compose.git project_name
    2$ cd project_name
    3$ git clone your_own_magento2_repository magento2/html
    

    Step 2 (optional):

    Copy the shortcuts to your bash console:

    1$ cp dkc_short ~/
    2$ echo ~/dkc_short >> ~/.bash_profile
    3$ source ~/.bash_profile
    

    NOTE: If you don’t have the file ~/.bash_profile on your computer, just use ~/.bashrc

    Step 3:

    Start the setup:

    1$ dkc-up -d
    

    It will take a bit of time the first time, but it will be a lot faster next time you run it.

    Step 4:

    Run composer install:

    1$ dkc-php-run composer install
    

    That’s about it.

    What is this dkc stuff?

    Well, I like to use tabs when running a command, so I added some aliases that allow me to run a Magento command without typing everything, I just type dkc[tab]p[tab]-[tab] and the command. I just love bash autocomplete.

    The command list is very simple:

    • dkc-up -d – start the containers in the background
    • dkc-down – stop all containers
    • dkc-mag [command] – run a Magento2 command
    • dkc-clean – clear the cache
    • dkc-php-run – run a bash command inside the php container, like composer in the previous example. NOTE: This command is running as the system user, not as root.
    • dkc-exec phpfpm [command] – this is same as above, but running as root. You should almost always use the command above.
    • dkc-exec [container] [command] – this command needs a bit more explanation:
      • container can be:
        • app – for Nginx server,
        • phpfrm – for php container,
        • db – for database,
        • cache or fpc – for cache containers;
    • the command can be anything that applies to that container, like “bash” or “bash composer”, etc.

    I know the commands seem like “one more thing to learn”, but most of the time you will only use the first 4 commands.

    How does the magic work?

    Well, to see what the above commands translate to, just check the “dkc_short” file.

    There are only 2 other interesting repositories:

    • https://github.com/claudiu-persoiu/magento2-docker-php – that contains phpfpm,
    • https://github.com/claudiu-persoiu/magento2-docker-nginx – that contain the nginx server.

    The repositories are pretty small and not very hard to understand.

    If you need to modify anything, just feel free to fork the repositories.

    The conclusion

    That’s about all you need to know about it, I’ve been using this setup for almost 2 years.

    For me, it’s working as a charm and I was able to use Magento2 on ultraportable laptop with 8Gb RAM without any issues.

    The (happy) end!

  • About passion, programming and heating systems

    Citește postarea în română

    Aug 8, 2018 programming
    Share on:

    Don’t be fooled, this post is about programming, system architecture but mostly about using a heating system.

    If you don’t know how can you talk about programming without programming you should check out the “The Passionate Programmer” book by Chad Fowler, a great read. The Jazz stories from this book inspired me to write this blog.

    The story begins with a new apartment in an old building. Or at least it’s new to me.

    The building has its own heating system, very old and extremely inefficient. After a long consideration I’ve decided that it was time to install my own heating system and disconnect from the main building one.

    So far, nothing interesting, there are many people that do this, partly because of the added comfort and partly to optimize expenses.

    With this being said, I had a project and needed a developer. Or in other words, I had a heating system to build and I was in need of somebody to do it.

    I’ve asked around for that “good” developer.

    Like in anything else, there are a lot of people that come up with bad solutions. There are devs that make great offers but are unable to finish the project, or they write very bad code that is not scalable and even worst, unmaintainable.

    Since what I know about heating systems can be covered by anyone with the patience to google the subject for a couple of hours or so, I wanted somebody I could trust, so I was looking for the passionate kind of developer!

    I had a couple of recommendations. The first one told me that he had to put all the pipes close to the ceiling. After convincing him that I don’t want my house to look like a factory full of pipes he said that he will definitely need to replace one of the radiators (at least) because he could not fit a pipe behind it. I could fit my palm behind that radiator, with this in mind I knew I wanted somebody that could fit a pipe behind my radiator.

    It was clear that he wasn’t a good developer. A good developer must work with the requirements, the very least a project should be able to respect most of the client requirements, if it doesn’t, there can be several explanations: he can’t because he doesn’t know how or he doesn’t want because he knows it’s hard and doesn’t want to go that extra mile. In some cases that’s not a tragedy, maybe it will be cheaper and faster, and in his case it was. Unfortunately for him, I aimed for quality.

    Then there was the passionate developer. He never mentioned anything about not being able to do something, it was always a cost and maybe a consequence. The deal with better developers is that they are more expensive and everything about them is expensive, they will want better servers for hosting, better tools and sometimes more time for things like testing and maintenance. In other words, sometimes the cost is bigger not just then, but also in the log run. A quality project takes time and money.

    This is my resulting project:

    If you never seen an apartment heating system before you should know that except for the pipes, nothing else is actually required.

    It’s all just passion!

    For instance: the pump on the lower right, it’s there just to force the water to move faster in the system. Think of it as Redis, it will have a good effect on your system but most systems will happily work without it. Of course, at some point there may be maintenance for that pump and can even result in issues, like this Magento 2 issue: https://github.com/magento/magento2/issues/10002. Every system has its own cost.

    The expansion tank in the lower left was unnecessary (in the sense that the system already has one built-in), but it’s not a bad idea to have an extra. Think of it as that extra storage space, ram or CPU that you don’t actually use. Your server should never go above certain server loads, that’s the expansion tank you should take into consideration.

    The water intake filter is like your firewall, you need it, it’s your protection, maybe most of the time will be useless but when there will be issues, then you will be glad you have it, because he will have filtered them out.

    The good thing with passionate developers is that other developers understand and appreciate their work. That is very important, no matter the industry of the “developer”.

    The only one that had anything to comment on the system was the ISCIR certified technician that initialized the heating system (ISCIR in Romania is a special authorization needed for this exact thing). You can tell that he wasn’t passionate, he just wanted to say something bad about it because he wanted to make a good impression on me.

    Unfortunately for him, he made some very stupid comments and then he made me a maintenance offer. This guy was the consultant, he didn’t do the project and he doesn’t want to work on it but he definitely wants to make some money on it without actually doing anything.

    I guess the conclusion is that no matter the developer, the quality and passion transcends the industry.

  • The Books for Zend Certified Engineer 2017

    Citește postarea în română

    Jun 12, 2018 book PHP review zce zend
    Share on:

    I have recently passed the Zend Certified Engineer 2017, certification offered by Rogue Wave.

    While experience is the most important thing for a certification, books are the best way to expand your knowledge, in my opinion.

    Since a certification is something very specific, there aren’t a lot of books.

    Before we begin, keep in mind that the most exhaustive resource for learning PHP is the manual, always take a look on all the classes and functions available.

    Zend Certified Engineer Exam Study Guide $20

    I’ve bought this book just so I can review it and earn my right to have an opinion about it.

    The study guide was introduced with the certification for PHP 5.3 and it was a free resource. The quality of the book has updated continually, but never by a lot and at some point it was no longer a free resource.

    Over time I kept hoping that it will become better and better, but it didn’t. It’s a short book with a big font and lots and lots of misspellings and errors.

    The only good part about it is that it has several questions for each chapter, other then that it’s not a very good resources and it’s not worth the $20, probably about $5 would be closer to a fair price since with every version they just update it a bit and adding the new features of the language. The questions don’t even seem to change a lot over time.

    So if it’s the only book you are going to buy, go for the next one.

    PHP 7 Zend Certification Study Guide – Andrew Beak – Apress 2017 – $19.99

    The book is exploring all the sections for the certification in more depth, it has over 300 pages.

    It feels more like a programming book and less like a guilde. The quality of the book is way better than the official guide, but that’s not hard at all considering that the guide set such a low bar.

    There are also questions on all the chapters which is a good way to practice your knowledge in an exam format. The questions just feel a bit more soft than the guide, the exam itself has a lot of very tricky questions.

    Of course this book is not exhaustive, you can’t really cover all the subjects in depth in a single book, and even if it did, then you would probably not have time to read it anyway.

    If you are going to buy a single book, I would recommend this one, since it’s an actual book, not a very high level (and low quality) guide.

    Zend PHP 5 Certification Study Guide, Third Edition – php[architect] – $22

    If you think that I’ve got the version wrong, well, what can I say? you are right!

    I wanted to add this book here because for me it was the best Study Guide. Over the years there were various study guides but this one I liked the most.

    For the PHP 5 certification there wasn’t an official certification from Zend, only the first edition of this book. It was just a nice programming book to read. Sometimes, when I want to remember something that I haven’t used a lot, or at all, I will read the chapter in this book.

    When I took the PHP 5.5 certification, (because I just had to collect them all) I was happy to find out that there is a new version of the book.

    It’s basically the same book but updated to cover the new certification. It may be that I like Davey Shafik’s style of writing.

    The book feels a bit more dense in terms of information, for me it just feels more like a study guide then the previous book.

    However this book does not have questions and is no longer up to date.

    If you have the time you can give it a read anyway, I think it is a good general PHP book.

    Conclusion

    Not a lot of books for this certification, but if I had to pick only one, it would be the “PHP 7 Zend Certification Study Guide” from Apress.

    Unfortunately there isn’t a lot of competition, because the “Zend PHP 5 Certification Study Guide, Third Edition” from PHP Arch is no longer up to date and the official guide just isn’t worth the $20 price tag.

    If your boss will buy the books, I say go all in! After all, the cost is: $20 + $19.99 + $22 = $61.99! Not bad for three programming books!

  • Why is a language like PHP so popular?

    Citește postarea în română

    Oct 19, 2017 PHP
    Share on:

    Yes, PHP is probably the most popular programming language on the server side for the web at the moment. And it’s probably going to be for a long while…

    It’s probably the best!

    That’s not really it, just read on…

    Why is it so easy to learn?

    First of all, it’s the syntax. It’s not the best syntax out there, the reason is actually that it’s the most popular! I knew most of the syntax before I even looked at a “hello world” example, why? I’ve studied C in school, and people coming from Java had the same feeling.

    Let’s see a few programming languages that are using this syntax: Java, C#, JavaScript, Perl, Go, PHP and, of course, C and C++, and between them you have most of the market and platforms.

    Unlike (most) other languages listed above, it’s a lot easier to get started! You don’t have to create a main function, a class or anything else to get started, you just get down to it!

    The good part is that you can make it as complex as you want (or need) to, these days there are Java-like classes and interfaces, horizontal inheritance with traits, functional programming with closures and anonymous functions, generators and, if you really are a hipster, even goto.

    But PHP doesn’t sound so bad…

    Now, there is an important detail that must be mentioned, PHP didn’t become popular because of the features mentioned above, but the features came to it because of its popularity, even “goto”. I don’t know why somebody would add goto to a language more than 10 years after its creation but that’s none of my business, nor is it important for the subject at hand.

    The language became really popular with versions 3 and 4. By the time a decent OOP model is introduced, it had already gained a lot of popularity! Now, especially more so since PHP 7 is looking a whole lot more like a decent programming language, but 10 years ago it wasn’t the same story.

    But node.js will probably surpass it!

    Right… remember Ruby? Python? And others…

    If you think about PHP, it has a major advantage and disadvantage, is very much as stateless as it can be.

    With PHP you feel like it doesn’t know anything about the world, you have to bootstrap everything all the time. The advantage is that if you have a memory leak, most of the time, it’s ok. The current user will finish and everything will get cleared and nobody will have to care. And PHP had a lot of memory leaks when it started to became very popular and nobody seemed to mind.

    When people started making cron jobs and other long running processes, this becomes a big issue and the need for features like explicit garbage collection became a must. That was added with version 5.3, which was released in 2009.

    Normally, continuous running should not be a disadvantage, so the moral of this story is that it’s not necessarily an advantage either.

    Nobody is going to build the next Google on it, but how about some blogs? Or even better, some shopping carts?

    It just doesn’t have what it takes for something like the Google search engine and that’s ok because it was just not designed for that.

    Another example for “not necessarily the best will win” is that WordPress is the most popular blogging platform.

    Even more, people are using WordPress for all kind of weird things, basically you can do anything with it! And you should not blame the people using it, it’s not like you look what’s in your microwave when you buy it, you just want to have a warm meal. People forcing the limit of WordPress are doing the same, they can do what they need, so there is no good reason not to.

    Should I ever use it?

    Let’s take a couple of positive examples: Yahoo! and Facebook.
    Yahoo! has been using it for a very long time on some of their products and in combination with other programming languages.

    Facebook has been using it since the beginning because it is so easy to learn. They have been pushing the limit of the language in several occasions with: HipHop for PHP and more recently Hack, which was a very important motivational drive and a big influence for PHP 7.

    Why all that trouble for a language? Because it’s just so easy to learn and use!

    Usually, it’s a lot more important to release “now” then to have something “perfect” later, especially on the world wide web.

    There is a very good reason why a language that is definitely not “the best”, but it is easy to learn is so popular online, while a programming language like C, which is way harder to learn, is more popular offline than online.

    In other words, while definitely not being the best, PHP is most of the time just good enough.

    • ««
    • «
    • 1
    • 2
    • 3
    • 4
    • 5
    • »
    • »»

Claudiu Perșoiu

Programming, technology and more
Read More

Recent Posts

  • Is PHP dead in 2026?
  • 30 years of PHP
  • HTTPS certificate monitoring in Home Assistant
  • Adding a slider to Tasmota using BerryScript
  • The future proof project
  • Docker inside wsl2
  • Moving away from Wordpress
  • Custom path for Composer cache

PHP 51 MISCELLANEOUS 47 JAVASCRIPT 14 MAGENTO 7 MYSQL 7 BROWSERS 6 DESIGN PATTERNS 5 HOME AUTOMATION 3 LINUX-UNIX 2 WEB STUFF 2 GO 1

PHP 37 JAVASCRIPT 15 PHP5.3 11 MAGENTO 7 PHP6 7 MYSQL 6 PHP5.4 6 ZCE 6 CERTIFICARE 5 CERTIFICATION 5 CLOSURES 4 DESIGN PATTERNS 4 HACK 4 ANDROID 3
All tags
3D1 ADOBE AIR2 ANDROID3 ANGULAR1 ANONYMOUS FUNCTIONS3 BERRYSCRIPT1 BOOK1 BROWSER2 CARTE1 CERTIFICARE5 CERTIFICATION5 CERTIFIED1 CERTIFIED DEVELOPER1 CHALLENGE1 CHM1 CLASS1 CLI2 CLOSURES4 CODE QUALITY1 CODEIGNITER3 COFFEESCRIPT1 COLLECTIONS1 COMPOSER1 CSS1 DEBUG1 DESIGN PATTERNS4 DEVELOPER1 DEVELOPMENT TIME1 DOCKER2 DOCKER-COMPOSE1 DOUGLAS CROCKFORD2 ELEPHPANT2 FACEBOOK2 FFI1 FINALLY1 FIREFOX3 GAMES1 GENERATOR1 GO1 GOOGLE1 GOOGLE CHROME1 GOOGLE MAPS1 HACK4 HOMEASSISTANT3 HTML2 HTML HELP WORKSHOP1 HTML51 HUG1 HUGO1 INFORMATION_SCHEMA1 INI1 INTERNET EXPLORER3 IPV41 IPV61 ITERATOR2 JAVASCRIPT15 JQUERY1 LAMBDA1 LINUX1 MAGENTO7 MAGENTO22 MAP1 MINESWEEPER1 MOTIVATION1 MYSQL6 NGINX1 NODE.JS2 NOSQL1 OBSERVER3 OBSERVER PATTERN1 OOP1 OPERA1 OPTIMIZATION1 ORACLE1 PAGESPEED1 PAIR1 PARSE_INI_FILE1 PHONEGAP2 PHP37 PHP ELEPHANT2 PHP FOR ANDROID1 PHP-GTK1 PHP42 PHP53 PHP5.311 PHP5.46 PHP5.53 PHP5.61 PHP67 PHP7.41 PROGRAMMING1 REVIEW1 ROMANIAN STEMMER2 SAFARY1 SCALAR TYPE HINTING1 SCHEME1 SET1 SHOPPING CART PRICE RULE1 SINGLETON1 SOAP1 SPL2 SQLITE1 SSH1 STACK TRACE1 STDERR1 STDIN1 STDOUT1 SUN1 SYMFONY2 TASMOTA1 TEST TO SPEECH1 TITANIUM2 TRAITS1 TTS1 UBUNTU1 UNICODE2 UTF-82 VECTOR1 WEBKIT1 WINBINDER1 WINDOWS2 WORDPRESS1 WSL21 YAHOO3 YAHOO MAPS1 YAHOO OPEN HACK1 YSLOW1 YUI1 ZCE6 ZCE5.31 ZEND3 ZEND FRAMEWORK3
[A~Z][0~9]

Copyright © 2008 - 2026 CLAUDIU PERȘOIU'S BLOG. All Rights Reserved