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:

Connect với firebase

Để chạy được firebase ta cần tạo 1 acc trên firebase website. Sau khi tạo xong, thì My First App là project của chúng ta, ta sẽ test dựa trên project này. Mỗi app có 1 unique host-name riêng, ta chỉ việc dùng nó và gán vào url project chúng ta.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Firebase Chat Application</title>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
	<style>
        .container {
            max-width: 700px;
        }
        #comments-container {
            border: 1px solid #d0d0d0;
            height: 400px;
            overflow-y: scroll;
        }
        .comment-container {
            padding: 10px;
            margin:6px;
            background: #f5f5f5;
            font-size: 13px;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            border-radius: 5px;
        }
        .comment-container .label {
            margin-right: 20px;
        }
        .comment-container:last-of-type {
            border-bottom: none;
        }
    </style>
</head>
<body>
    <div class="container">
		<h1>Firebase Chat Application</h1>
		<div class="panel panel-default">
			<div class="panel-body">
				<div id="comments-container"></div>
			</div>
			<div class="panel-footer">
				<form role="form">
					<div class="form-group">
						<label for="comments">Please enter your comments here</label>
						<input class="form-control" id="comments" name="comments">
					</div>
					<button type="submit" id="submit-btn" name="submit-btn" class="btn btn-primary">Send Comments</button>
					<button type="reset" class="btn btn-default">Clear Comments</button>
				</form>
	 
			</div>
		</div>
	</div>
    <script src="https://cdn.firebase.com/js/client/1.0.6/firebase.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
	<script>
	var fireBaseRef = new Firebase("https://blinding-fire-###.firebaseio.com/"); /* firebase url */
	$("#submit-btn").bind("click", function(event) {
		event.preventDefault();
		event.stopPropagation();
		var comment = $("#comments"),
			commentValue = $.trim(comment.val());
		if (commentValue.length === 0) {
			alert('Comments are required to continue!');
		} else {
			fireBaseRef.push({comment: commentValue}, function(error) {
				if (error !== null) {
					alert('Unable to push comments to Firebase!');
				}
			});
			comment.val("");
		}
	});
	fireBaseRef.on('child_added', function(snapshot) {
		var uniqName = snapshot.name();
		var comment = snapshot.val().comment;
		var commentsContainer = $('#comments-container');
		$('<div/>', {class: 'comment-container'})
			.html('<span class="label label-info">Comment ' + uniqName + '</span>' + comment)
			.appendTo(commentsContainer);
		commentsContainer.scrollTop(commentsContainer.prop('scrollHeight'));
	});
	</script>
</body>
</html>

Từ: code.tutsplus.com

Shepherd: Guide your users through your app

Shepherd is a JavaScript library that guides users through your app, using Tether to position all of its steps. All you have to do to get started is include Shepherd.js and a Shepherd theme file, and then create your steps with straight-forward syntax.

From: github.hubspot.com