Wednesday, November 30, 2016

Newlines got changed when downloading/uploading files using FTP client such as FileZilla

If your source code formatting is destroyed after FTP download or upload, it's probably because your FTP client's transfer mode is currently set to ASCII. Usually, line breaks are removed completely or added excessively to the text (source) files.

Try to switch your transfer mode to Binary. It should fix the problem. In FileZilla, this is located under Transfer->Transfer Type menu. You can choose default transfer type in FileZilla->Edit->Settings...


Thursday, November 24, 2016

10 biggest mistakes when selling something

Here is a short review of an useful article on selling. It lists the 10 following mistakes as the biggest mistakes in selling:


1. Not being prepared when it comes to making a sales presentation, either face to face--as in a retail environment--or over the phone, Skype etc.


2. Not looking the part--where the sales person is dressed inappropriately or the entire sales environment looks unprofessional and unappealing to the customer.


3. Not having enough knowledge about the products or services being sold. 
Customers deserve 1st class information.


4. Not asking the right questions. 
Result -> Not knowing what customer really needs.


5. Not listening to what the customer is saying.
De-motivates and frustrates the buyer.


6. Not getting back to the customer as promised--or in other words, they over promise and under deliver. 

7. Not having clear, specific sales goals. Very few people set goals but those that do tend to achieve them. If you have sales people working for you, you have to set targets. And these need to be talked about, measured and pushed. If you work by yourself, set your own sales goals.

8. Not reading the customer. This means being able to interact with the customer and see that you are connecting with them, that you are helping them and that you are doing your job as a sales professional.

9. Not being compelling. If you don't believe what you are selling, don't sell it. Being compelling generally translates to being believable and sales people already have a stereotype to overcome. If you don't believe what you are saying, your customers won't either.

10. Not caring about the sale. This is the situation where the sales person really doesn't care if the person buys a product or not. They still get paid the same amount so their attitude towards their customers can reflect this.

I find #7, #9 and #1 most interesting. However, probably any one of these can be the weakest link in our sales presentation. What do you think?



View full article here

Tuesday, November 22, 2016

Creating a proper PDF out of HTML

If you have ever wanted to generate a nicely looking, non-rasterized, PDF out of HTML, you probably know that's its hard to find a good library for that. So, I think I have something good for you - PhantomJS!PhantomJS seems to offer a great way to generate PDF documents out of HTML pages:


Here is an example:

https://phantomjscloud.com/api/browser/v2/a-demo-key-with-low-quota-per-ip-address/?request={url:%22http://www.jonathantneal.com/examples/invoice/%22,renderType:%22pdf%22}


That sample, and many others, can be found here:
https://phantomjscloud.com


Original thread discussing phantomjs as a means of generating PDF is here:
http://stackoverflow.com/questions/6896592/is-it-possible-to-save-html-page-as-pdf-using-javascript-or-jquery

Original command:

phantomjs.exe examples/rasterize.js sample.html sample.pdf

Even better option would be Webkit to PDF (the same core is used):

http://wkhtmltopdf.org/

Could not verify Recurly's SSL certificate

Environment:

XAMPP on Windows

Scenario:

You are trying to issue a CURL request to a SSL based endpoint. Your request fails with an error stating that the SSL certificate cannot be verified. In case of Recurly, subscription management system, this error says something like "Could not verify Recurly's SSL certificate".

The actual cause of this is your php's inability to find valid root CAs. One way of fixing this is to manually add a line to your active php.ini:

curl.cainfo=c:\locationA\cacert.pem

where, of course, cacert.pem is the valid CA certificate. After this, restart of Apache / PHP is required.

The original idea for this came from this great blog post:
Stop turning off CURLOPT_SSL_VERIFYPEER and fix your PHP config

Saturday, November 19, 2016

25 Most Productive Ways to Spend Time on the Internet - a list of great web places


1. Duolingo
2. Kahn Academy
3. Justin Guitar
4. Cooking for Engineers
5. The Dating Specialist
6. Nerd Fitness
7. MIT Open Courseware
8. Investopedia
9. Quora
10. Information is beautiful
11. Spreeder
12. Project Gutenberg
13. Codeacademy
14. GeographyIQ
15. Anki
16. Lumosity
17. CliffsNotes
18. TED
19. Pinfruit
20. Mindtools
21. Learn Street
22. HowStuffWorks
23. OneLook
24. The World Factbook
25. Couchsurfing

Original thread on Quora:

https://www.quora.com/Where-can-I-find-the-25-Most-Productive-Ways-to-Spend-Time-on-the-Internet-article-that-was-removed-from-TIME

Wednesday, November 16, 2016

PHPDOMParser library's selectors are very whitespace-sensitive

PHP Simple DOM Parser is a very nice tool for parsing HTML using CSS-like tag selectors.

However, be very careful with whitespaces inside of selector expression,as they might cause silent failure. These are two different expressions:

$elem = $html->find(".container1[container_type=picture]>div", 0);

AND

$elem = $html->find(".container1[container_type=picture] > div", 0);

The second expression has 1 extra whitespace ( > ), and that will cause failure while trying to obtain the first div element inside container.

Saturday, November 12, 2016

Live editing of SVGs using JS - problem analysis

Problem:

How to make dynamic SVGs which can be controlled from JS? For example, we would like to change foreground text, or background image on a SVG. How to do it?

Available tools:
JavaScript (JS), CSS3, PHP and HTML5


Methods used for solving this problem:

*Prerequisite: Inline SVG*


In order for SVGs to become parsable and editable by JS, we need to load it as an inline SVG. A simple src tag to a SVG image will display the image, but it won't allow us to edit it's parts using JS and CSS.


Method #1
Direct access to parsed HTML elements and modification of their properties and content, same as in case of any other HTML document.

Method #2
Using HTML5 Canvas, convert inline svg to a canvas drawing, and further exporting it to a PNG image. Here's an example how to do this:
http://stackoverflow.com/questions/5433806/convert-embedded-svg-to-png-in-place


Android development, adb device status Unknown / Offline

Area: Android app development Problem: When you would like to connect to your mobile device using adb running at your Linux desktop , you receive a device state Unknown / Device Offline error. What you should try: Run this command: sudo adb kill-server After a few seconds, run this one: sudo adb start-server At least in case of Ubuntu Linux distro, it's VERY important to include sudo in these commands. Otherwise, your device remain in state Unknown (Offline).

Tuesday, November 8, 2016

Solved: Angular 1 - Error: [$compile:ctreq] http://errors.angularjs.org/1.5.8/$compile/ctreq?p0=ngModel&p1=ngOptions

If you receive this error message:

 Error: [$compile:ctreq] http://errors.angularjs.org/1.5.8/$compile/ctreq?p0=ngModel&p1=ngOptions


It might be that you haven't added ng-model directive to the select tag you're trying to populate with ng-options.

This code will produce the error above:

<select ng-options="item.id as item.id for item in organizations">
</select>

The solution is simple addition of ng-model directive , like this:


<select ng-model="mychoice"  ng-options="item.id as item.id for item in organizations">
</select>

Sunday, November 6, 2016

WP API with ACF - a crash course / quick tutorial

WP Restful API is frequently implemented with help of the following WP Plugin:

WP-API 

Support for fetching ACF fields tied to the posts is added via this WP Plugin:




Once you have these two plugins activated, you should be able to use these URLs to fetch posts via a RESTful API:

yourdomain.com/wp-json/wp/v2/post?page=1&per_page=10

This will return first 10 posts from your site. The total number of records will be appended to HTTP Response Headers of the REST API call. 

In case you would like to obtain ACF fields tied to a post (i.e. post_id = 892), you can issue a RESTFul GET call like this:

yourdomain.com/wp-json/acf/v2/post/892

It will return full list of ACF fields tied to the post with ID = 892. 



Also , there is an option  to extend the response by adding a custom field like this:








In the example above, we add a new field to JSON output - acf1. The field acf1 will contain everything that can be obtained by get_fields(ID). So, the next time you issue a RESTful call like this:


yourdomain.com/wp-json/wp/v2/market?page=1&per_page=10

your JSON result will contain basic fields of the posts , like id, date ,etc. However, every record will contain the acf1 field , too!

RETURN ALL POSTS FOR A SPECIFIC POST TYPE / CPT

By default, WP-API returns 10 records per page. In caase you would like it to return all records, you should set per_page parameter to -1, like in the following code:


Note that the filter is CPT dependent. This filter will be only executed on market CPT.

Emanuele Feronato - this guy can teach you how to create amazing video games


Today, I would like to introduce you to a very talented game programmer from Italy. His name is Emanuele Feronato. I've first stumbled upon his website a few years ago. Since then, I've been following his updates regularly. Every time I visit his site, I find something really helpful and interesting to read. The site emanueleferonato.com is a blog-based website containing thousands of high quality articles revolving around:


Game design
Mathematical concepts behind every game
New tools and programming languages
Hands on short tutorials covering the game building process from start to the actual delivery
Monetization (making money on the games you have already enjoyed building :) )
All kinds of news and updates from game development world

Personally, what I like the most at the website, is the collection of full tutorials on how to build HTML5 fun and addictive games in matter of hours. It's pure fun to create and to play this type of games. Emanuele's site is located at:




Be sure to visit it. I hope you will find it useful! 

Saturday, November 5, 2016

PHP - require_once inside function requires use of global keyword

In PHP, require_once function locates a file and inserts its content into the the script. Its uses in PHP applications vary from simple loading of configuration files to supporting complex, hierarchical template systems. Typically, require_once is called at the beginning of the script execution. That way, the script is dynamically expanded to include new functionality, originating from the included source file. That scenario is common and straightforward to follow. However, there's a tiny peculiar detail in the behavior of PHP's require_once function:

If you are going to declare a variable V in file1.php and include file1.php into a function func() in file file2.php, you have to use global keyword to reference the V variable in function func() in file2.php.

Here's a simple scenario:

Thursday, November 3, 2016

Solved: CSS width 100% not working.

Problem:

Element A inside another element B, won't take the full width of its parent element (B).

For example, in Bootstrap layout:




If textarea element won't fill the whole parent column, you can simply try to replace CSS's width property with min-width property. Min-width property is likely to extend the textarea to the full width of its parent element. 

So, the new code would look like this:

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...