I remember the time when I was a part of the team to provide our web-based applications as service (SaaS). We had ideas, of course, based on our previous experience in the web development area. But it was really difficult to start.
This time the situation is changed. Many web apps are SaaS-based now. And you can find not just short posts about SaaS but the articles for long reading. One of these is The SaaS Handbook – How to Build Your First Software-as-a-Service Product Step-By-Step.
The article describes a tech stack (it’s JS – Node.js + Preact – an alternative version of the React), structure, design, integrations with third-party services, and deploy and gives tips and ideas to build your version of the SaaS..
Legacy projects can be a pain – you have to not just support an old code but add new features. And at some point this may become a nightmare. However, there are many ways to upgrade it without full re-development at one time. One possible solution is to move such projects to the modern Laravel ecosystem as it’s described in this article.
The idea behind of it is to wrap the old code to handle it by Laravel. Once it’ll be done, the old functionality will work as expected, while all new features will be added in Laravel. Additionally the old code can be refactored and moved under Laravel without a downtime or an interruption of the project. This solution will give a smooth transition from old system to the new one.
Also do not forget about tests – unit and integration, static analyzers like PHPStand and code style control with PHPCS. This will help you to catch possible bugs even before run your app.
The universal chatbot library based on React allows to create chatbots for Telegram, Slack and Facebook right now. Support of Whatsapp, Viber and VKontakte will be added soon.
By default Subversion shows diff without highlighting which makes a bit difficult review of big changes.
But that situation can be changed extremely simple and fast. I assume you use Fedora 17. For the other distributions you need just use different package manager, choose correct package name and find configs in the proper places.
First of all, install utility colordiff:
sudo yum install colordiff
Now you can get highlighted output of SVN diff:
svn diff foo.php | colordiff
But it isn’t convenient way. Since Subversion allows to use any external program to make a diff we just should just add following in the ~/.subversion/config:
diff-cmd = colordiff
And voilà, we can see colored diff just run ordinary SVN diff command:
svn diff foo.php
To change colors in colordiff just copy its global config to your home directory and edit it:
cp /etc/colordiffrc ~/.colordiffrc
Sure all GUI DB tools can do export of result of query into CSV file. But what if you have to do this from command line? There is a simple way perform that task. Here is an example:
INTO OUTFILE '/tmp/products.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
When you run that query all records from the table products will be dumped into file /tmp/products.csv. All fields of that dump will be delimited by comma, enclosed by double quotes and escaped by two slashes. Each row will be ended by end of the line character.
Sure you can change delimiter, enclose, escape symbols as well as add any others SQL statements such JOIN, WHERE, LIMIT ORDER etc. Enjoy!
UPDATED: Don’t forget to drop the export file before re-export data. Otherwise you’ll get the error:
ERROR 1086 (HY000): File '/tmp/products.csv' already exists
Brian Foy – the author of Mastering Perl and one of the famous perlmonks, wrote an article on the ONLAMP where described five ways to improve Perl programming:
- Cleaning up your code – I also hate to read unformatted code -without tabs, proper style etc.
- Use configuration – sure, my favorite module – Config::General.
- Logging – log4perl should be used in all your applications.
- Persistence – Brian suggested to use Storable or DBM::Deep but I prefer to use Cache::FileCache (it’s used in my module IMDB::Film to cache already retrieved web content).
- Subclasses for applications – it’s good practice to implement a common functionality in the modules instead of keeping it in your script. This approach allows to have more structured application and reuse the same functionality in some other scripts.
So, generally I didn’t find anything new for me in those recommendations. I just confirmed my own point of view 🙂
We use following approach to build print view of documents in our web-based application. At the begging the document template is filled by real data and HTML page is generated. After that this page is sent to HTMLDOC which converts it into PDF. The users open the document via Acrobat plugin installed in the web browser. This approach has worked fine for years.
But recently we decided to send PDF directly to the printer. I’ve added printer to the our server and implemented a simple function (we have a Xerox printer with PostScript support):
lp -d printer_name -o sides=two-sided-long-edge -o media=A4 -o portrait -o page-ranges=1-7 PDF_file
The strange thing appeared right after that. One type of documents couldn’t print anymore. No errors in the CUPS log or on the printer display. The job just disappeared from the queue and was marked as printed. After spending some time I found the way to solve this problem. I use acroread to convert PDF into PostScript and then send it to the printer:
acroread -toPostScript PDF_file
Acroread creates the PostScript file with the same name but with different extension (.ps) and stores it in the current directory. But you can pass desired directory name as second parameter:
acroread -toPostScript PDF_file /store-dir/
I use Acrobat 5 from DAG repository. It works fine even the server doesn’t have installed X. But if you want to use Acrobat 7 you should do additional work. It needs X and if try to run it from command line it give you an error:
(acroread:6488): GTK-WARNING **: cannot open display:
To solve this just install Xvfb – X server that can run on machines with no display hardware and no physical input devices, and run following command:
xinit acroread -toPostScript PDF_file /store-dir/ -- /usr/X11R6/bin/Xvfb :9 -ac
Some of you know about ActiveMQ – an open source (Apache 2.0 licensed) Java Message Service 1.1 (JMS) message broker packed with many enterprise features. One of the way to communicate with it from none-Java programm languages is STOMP (Streaming Text Orientated Messaging Protocol). STOMP is very simple and looks like HTTP-protocol.
Perl has at least two ways to communicate with ActiveMQ over STOMP:
Using ActiveMQ may help you to integrate your applications with others on Enterprise level.