Building a Social Profile Widget: Get Your Follower Count

A feature that’s becoming more common with websites is the social media profile widget. The widget consists of icons and text that link to a number of social network profiles to which the website is associated. Some of these widgets also show the number of followers on each of their respective social network.

There are a lot of free and premium social profile widget plugins available for WordPress that one can use in linking to his/her personal or website social network’s profiles.

In this two-part series, I will show how to get the count of Facebook page Likes, Twitter and Google+ Followers, and how to build a social profile WordPress widget.

We’ll be focusing on Facebook, Twitter, and Google+ because they are three of the biggest social networks.

Read more at: tutplus

select2 3.* insert data without replace content

<li class="list-group-item" data-id-user="3"><span class="badge">+</span>Song Ph'"a'"m</li>
<input type="hidden" name="partners" value="" class="multiselect-partner" style="width:100%"/>
<script type="text/javascript">
window.dataPartners = [
{ id: 4, text: "Xuân Hồng" },
{ id: 5, text: "Văn Luyện" },
{ id: 6, text: "Sau Ngu" },
];
</script>
$(document).ready(function () {
    /**
     * select2 function
     */
    if ($().select2) {
        $(".multiselect-partner").select2({
            multiple: true,
            query: function (query){
                var data = {
                    results: window.dataPartners
                };
                query.callback(data);
            },
            dropdownCssClass: "multiple", // apply css that makes the dropdown taller
            escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
        });
		$newItem = $('.list-group-item');
		$newItem.on('click', function () {
			var isValid = true,
				$me = $(this),
				$fieldMultiselect = $('.multiselect-partner'),
				objectData = {
					id: $me.data('id-user'),
					text: $me.text().substr(1)
				};
			$.each(window.dataPartners, function (index, value) {
				if (value.id == $me.data('id-user')) {
					isValid = false;
					return false;
				}
			});
			if (isValid === true) {
				window.dataPartners.push(objectData); /* update list dataPartners */
				/**
				 * insert this user to group chat
				 */
				var data = $fieldMultiselect.select2('data');
				data.push(objectData);
				$fieldMultiselect.select2("data", data, true);
			}
			$me.remove();
		});
    }
});

Sửa lỗi facebook api: Problem with the SSL CA cert (path? access rights?)

Download file pem
curl.haxx.se/ca/cacert.pem
Và đặt ở đâu đó trên server.
Sửa file php.ini đoạn:
curl.cainfo = PATH_TO_PEM/cacert.pem;
Run:
service httpd restart

Sử dụng custom font trên cross browser

Quy trình bình thường thì đợi font face load xong thì css mới đc load, nhưng với cách này thì chúng ta sẽ load async css, sau khi load css xong thì mới add vào font vào css trên header:
index.html

(function() {
    var headID = document.getElementsByTagName("head")[0],
        fontNode;
    fontNode = document.createElement('link');
    fontNode.type = 'text/css';
    fontNode.rel = 'stylesheet';
    fontNode.href = /css/fonts.css';
    fontNode.media = 'screen';
    headID.appendChild(fontNode);
})();

Continue reading

Protected: SEO Step by Step

This content is password protected. To view it please enter your password below:

Javascript set style element on load

var w = window.innerWidth;
document.getElementById("navbar-collapse-left").setAttribute("style","width: " + ((window.innerWidth / 2) - 96 - 27) + 'px');

THE MORNING ROUTINES OF THE MOST SUCCESSFUL PEOPLE

Core:
At the end of your day, write down the tasks you need to complete tomorrow
Look at the list when you start the next day.
End your day by creating another list for tomorrow.

Continue reading

Tránh filesort khi query mysql

Quy tắc là chỉ nên where 1 field thôi, nếu where 2 field trở lên thì mysql khó work như ý chúng ta:
1

Load combobox cha con

Html:

<tr>
    <td valign="top">
        <label>City</label>
    </td>
    <td valign="top">
        <div class="form-group">
            <select name="city" class="form-control">
                <option value="1" > TP. Hồ Chí Minh</option>
                <option value="2" > Hà Nội</option>
                <option value="3" > Đà Nẵng</option>
            </select>
        </div>
    </td>
</tr>
<tr>
    <td valign="top">
        <label>District</label>
    </td>
    <td valign="top">
        <div class="form-group" id="selectDistrict"></div>
    </td>
</tr>

Continue reading

Protected: Xây dựng chat application với Node Js, Socket.IO và PHP

This content is password protected. To view it please enter your password below: