I prefer MacOS to develop, because it’s much more stable than Windows 10 – last issues with October update are the best evidence, that something is not ok with this OS development. It’s similar to Linux in many ways, but not exactly Linux like Debian, Ubuntu, RHEL etc. In effect, we can’t just use build-in repositories to install some required software, services and servers. But there is very nice option called Homebrew. Using this, we can make MacOS even closer to Linux system and configuration will be simpler.Continue reading “Create development environment on MacOS using Homebrew”
Last time I must reinstall my MacOS and configure all my development environment again. It wasn’t a big issues except MySQL database and users, becase there are a lot of databases, each with different credentials. I had to move all the data, because test app needs it. The question was: how can I dump not only databases using mysqldump, but also all users and all privileges? Fortunately, solution is very simple and mysqldump allows us to get all in only one command, so there is quick tip to dump all data:
mysqldump -uroot -p --flush-privileges --routines --all-databases > backup.sql
And then we can restore whole data on new server using standard mysql command:
mysql -uroot -p < backup.sql
Very short, but I think, may help a lot of people… Last time I spent a lot of time on the big issue with Phantom.js in Node app. Very common task: application should generate PDF files from input HTML code. Nothing difficult, yes? Yep, and it worked fine on my Node app… But one day, client said, that we should change font in document. Simple, we can just use font-face in input HTML styles, right? In theory, yes. Phantom.js and Node packages to use this library to convert HTML to PDF can use custom fonts and also other external assets like images.
With very popular html-pdf package we can use external, full link to assets, use absolute path to our local directory with files (using file:/// prefix) or specify base path in rendering options, and then use relative (to this base path) paths in our styles. And… it works fine. It also worked fine with custom fonts on my project. But only on local machine where I use MacOS. After deploying app to Debin, Ubuntu Server or CentOS server, PDFs are broken – with no selected text, but all pages are “images”, with many broken characters and very big results file (it isn’t strange if we have images, instead of text in PDF). Custom fonts have been used correctly, but PDF was broken, why?
It’s library and Phantom.js issue, but solution is very, very simple. We must install our custom fonts locally on production machine and do not attach them in CSS – just use as existing font-family! It’s because Phantom is external script and it can use system-wide fonts. Where should we place our files? There are directories. If you have issues with custom fonts and non-selectable text, just copy fonts to:
Yes, I know, this blog post title looks like ad. But it isn’t ad, because I use only Cloudflare free version and don’t have any contact with this company (excluding support for services). I decided to write this post, because I’ve used Cloudflare for many years and I’m very happy – please treat this like small review, and also maybe “tutorial”, how you can make your websites faster, provide better security and remove spam. Installation is very easy and you can also use free SSL – it can be great alternative to Let’s Encrypt. Let’s see, what Cloudflare offers.
When I started work with Node.js and Express, I was looking for something to store my app settings. Something like env files in many PHP frameworks – central place for configuration, not stored in repository, but only for example when we run app in development or production environment. We can write custom code for that, or use some modules from npm, also directly for env files. Nuxt package also has dedicated env file module. These modules are great, but there is something much, much better – nconf.