Thứ Năm, 28 tháng 7, 2016

Git va SVN

Rất nhiều nhà phát triển đã từng nghe về cái gọi là version control, nhưng họ có thể không biết đầy đủ về chúng là cái gì và lợi ích của chúng trong quản lý dự án của họ như nào. Trong bài viết này chúng ta đi tìm hiểu lợi ích công việc với version control và sự khác nhau giữa GIT và SVN, những cái version control được dùng nhiều nhất hiện nay.Phương án đơn giản nhất để giải thích Version control là sử dụng các kho dự án file cùng nhau với lịch sử của các mã nguồn của bạn trong cùng một vị trí. Điều này làm cho những nhà phát triển dự án theo dõi mỗi sự thay đổi tạo ra với mã nguồn, những ai làm thay đổi và lý do thay đổi.
Những file đó bình thường sẽ nằm trên một vài server từ máy tính của những nhà phát triển, sau đó họ đẩy những file của họ lên khi hoàn thành việc gõ xong mã nguồn.
Nó cũng cho phép bạn đánh dấu mã nguồn của bạn vào thời điểm đó, tạo dễ dàng quay trời lại thời điểm đó nếu những tính năng mới đó làm đổ vỡ mã nguồn của bạn. Version control có thể cũng có lợi cho nhà phát triển độc lập(một mình) trên dự án của họ và nó cần thiết cho đội những nhà phát triển làm việc trên cùng một dự án.

 TẠI SAO PHẢI SƯ DỤNG VERSION CONTROL?

Version control là cần thiết khi làm việc cho đội phát triển, nếu bạn đang làm với đội phát triển và không có version control, chắc chắn bất kì một ai đó sẽ dừng công việc bởi không biết ai làm cái gì và đọc điều đó ở đâu.
Nếu bạn không có version control, phương án duy nhất bạn có thể làm việc là chia sẻ mã nguồn của bạn trên các nơi lưu trữ có thể và bạn có thể truy cập tất cả file mã nguồn đó để thấy những thay đổi đó. Nhưng mọi thứ đều làm công việc đi sai hướng, đầu tiên là không có từ hai nhà phát triển làm việc trên cùng một file ở cùng một thời điểm. Nếu hơn hai nhà phát triển làm việc trên nó, người cuối cùng lưu lại sẽ vượt quyền thay đổi những mã nguồn của người khác. Sử dụng version control giúp cho nhiều nhà phát triển làm việc trên một file ở cùng một thời điểm, khi họ đã hoàn thành những thay đổi mã nguồn, họ có thể commit chúng trở lại kho mã nguồn. Khi bạn đã commit file quay trở lại kho, nó sẽ trộn lẫn những thay đổi đó trong version control.
Vấn đề thứ hai đó là không có lịch sử mã nguồn vì vậy nếu bạn tạo ra một tính năng mới và demo nó với khách hàng và họ quyết định họ không muốn nó nữa, bạn sẽ phải đi tới mã nguồn và xóa đi những thứ mà bạn đã làm. Nếu bạn đã sử dụng version control bạn có thể sẽ lấy lại mã nguồn trước khi phát triển những tính năng mới đó.
Vấn đề thứ ba cho việc bạn không thể sử dụng thiếu version control đó là tính năng “trách nhiệm”. Version control sẽ ghi lại ai đã viết ra các phần mã nguồn, điều đó có nghĩa là với nhũng phần mã nguồn mà bạn không biết tại sao nó ở đây, bạn sử dụng version control để kiểm tra mã nguồn để nói với bạn, nhà phát triển nào viết điều đó vì vậy bạn có thể hỏi nhà phát triển đó giải thích lý do tại sao họ làm điều này.
Tagging là một tính năng quan trọng bạn cần có để nâng cao khi làm việc với versioncontrol.Khi bạn hoàn thành với một phần công việc và sẵn cho việc triển khai mã nguồn, bạn sau đó tag phiên bản mã nguồn đó. Điều đó là cần thiết cho việc tạo ra các nhánh mã nguồn khác nhau ở thời điểm tạo đó. Sau đó bạn có thể triển khai mã nguồn với những tag đó, cho phép bạn trích xuất ra mã nguồn đó mà bạn có trên máy chủ. Lợi ích của điều này nếu có vấn đề với phiên bản phát hành hiện tại đó, bạn có thể dễ dàng quay trở lại thời điểm tạo ra tag đó.

LỰA CHỌN VERSION CONTROL

Bây giờ bạn đã hiểu những lợi ích của việc sử dụng version control, nhưng giờ bạn sẽ lựa chọn cái nào để dùng?
Có nhiều kiểu phiên bản version control, ở đây chúng ta sẽ xem xét hai version control hay dùng và phổ biết nhất hiện nay là Git và SVN. Bạn có thể thấy chúng khá giống nhau, nhưng phương án làm việc của hai cái đó là khác nhau hoàn toàn. Không có cái nào là tốt hơn cái nào, nó tùy thuộc vào việc bạn sẽ học nó và phục vụ cho công việc của bạn, cũng như cái gì bạn muốn sử dụng nó.

SVN

SVN or Subversion là một trong những version control được sử dụng phổ biến hiện nay, nó dễ hiểu và rất rõ trong các luồng công việc. Hiện tại kho plugin WordPress sử dụng SVN.
Nó làm việc với một máy chủ trung tâm kho mã nguồn, những kho đó là được chia vào 3 key chính đó là Trunk, Branches(nhánh), tags. Mỗi cái đều có vai trò quan trọng của riêng chúng.
Trunk
Cái này là nơi lưu trữ mã nguồn gốc, nó sẽ không được commit các phần mã nguồn vào trong đó, nó giống như khu vực trung tâm nơi bất cứ ai làm việc trên dự án sẽ lấy các cập nhật tại đây. Khi bạn làm việc với một tính năng mới bạn sẽ branches (nhánh) mã nguồn từ trunk, khi bạn gõ mã hoàn thành tính năng mới đó, sau đó bạn sẽ merge tất cả những thay đổi đó vào trunk.
Branches
Như giải thích ở trên branch(nhánh) là sử dụng khi bạn tạo ra một tính năng mới, vì vậy bạn branch mã nguồn từ trunk. Điều này nghĩa là bạn có thể lấy ra bản sao chép trunk và đặt điều này vào trong một folder mới bện trong khu vực branch. Bây giờ bạn có thể làm việc trong đó với việc tạo ra tính năng mới của bạn, sau khi hoàn thanh bạn sẽ merge những thay đổi đó vào trong trunk.
Lợi ích của điều này giúp cho bạn phát triển tính năng mới mà bạn có thể commits vào trong branche(nhánh) và bạn có thể không làm đổ vỡ trunk cho một ai đó khác làm việc trên cùng dự án., nó giữ cho trunk ổn định nhất có thể.
 Tags
Tag là phương án tạo mã nguồn của bạn vào một thời điểm nào đó, nó giống như branch làm với mã nguồn của bạn. Chúng sẽ làm điều đó với một bản sao chép từ mã nguồn trunk và đặt nó vào bên trong một folder mới với thư mục tag. Sự khác nhau đó là tag sẽ không bao giờ sử dụng cho phát triển mã nguồn, chúng là phưong án dễ dàng cho việc lấy lại mã nguồn của bạn.
 Thời điểm khi sử dụng tag là cho việc triển khai mã nguồn, khi bạn hoàn thành những mã nguồn mới, mereg vào trong trunk, test đầy đủ và sẵn sàng cho việc phát hành, khi đó bạn sử dụng tag. Bạn sẽ tạo tag trên trunk và đánh dấu tính năng mới đó, bạn có thể nắm giữ tag và triển khai nó tới máy chủ của bạn. Lợi ích làm điều này là nếu bản phát hành mới đổ vỡ, bạn có thể lấy lại mã nguồn quay trở lại thời điểm tag trước đó.

GIT 

Thời điểm này GIT là một version control phổ biến và hay dùng nhất, bởi sự phổ biết của website Github. Giống như trước đây đã đề cập GIT và SVN là khá giống nhau nhưng luồng công việc là có chút ít khác nhau. SVN là chỉ có một kho trung tâm, nhưng GIT có đa kho, tức là một kho trung tâm những mỗi nhà phát triển có những kho riêng của họ.
Lợi ích cho việc chia nhỏ đó vào trong nhiều kho mã nguồn đó là sự hỏng hóc ở một chỗ nào đó. Với SVN nếu kho trung tâm là bị hỏng hoặc mã nguồn bị đổ vỡ sau khi phát triển, thì không một nhà phát triển nào khác sử dụng cho việc commit mã nguồn của họ cho đến khi kho được sủa chữa lại. Với GIT thì mỗi nhà phát triển đều có một kho riêng của họ, nó không phải là kho chính nếu kho chính bị đổ vỡ, họ có thể tiếp tục commit mã nguồn trên kho cá nhân , cho đến khi kho chính là được sửa và sau đó họ có thể đẩy mã nguồn của họ vào trong kho chính đó.
 Một lợi ích khác là kho cá nhân đó là commit nhanh, không mất băng thông mạng cần cho việc commit mã nguồn vào trong source control, những nhà phát triển có thể làm việc độc lập cho đến khi sẵn đẩy mã nguồn tới kho chính.
Luồng công việc mà bạn sử dụng khi phát triển với việc dùng GIT như sau:
 Khi làm việc trên dự án bạn sẽ sao chép bản sao mã nguồn từ kho chính, có nghĩa rằng bạn có thể tạo ra một bản sao mã nguồn ở thời điểm đó. Điều này tạo ra một kho GIT cục bộ trên máy tính cá nhân của bạn, nơi bạn có thể tiếp tục công việc cho việc phát triểnt tính năng mới. Bạn có thể sử dụng kho cục bộ đó như sử dụng nó như sử dụng SVN đó là tạo branche mới , tags mới và tiếp tục commit mã nguồn lên kho cục bộ trong khi phát triển.
 Khi tính năng mới của bạn hoàn thành và bạn sẵn merge những thay đổi đó vào trong kho chính bạn cần đẩy những thay đổi đó lên từ kho cục bộ của bạn tới kho chính. Đây chỉ là phần ít sử dụng nhất trong GIT và nó tương tự như commit trong SVN, nhưng bạn sẽ không thường sử dụng commit và sử dụng commit trong GIT nhanh chóng.

Thứ Hai, 30 tháng 11, 2015

Research about amazon server

https://namvuhn.wordpress.com/2015/08/04/aws-tim-hieu-ve-dich-vu-amazon-ec2/
http://codingsoup.com/2014/02/aws-tu-khi-dang-ky-dich-vu-den-hoan-thanh-website-phpapache/
http://quantrimang.com/tim-hieu-ve-dich-vu-amazon-ec2-83626

http://www.ibm.com/developerworks/vn/library/ar-cloudaws1/
http://www.ibm.com/developerworks/vn/library/ar-cloudaws2/



Compute
EC2
Virtual Servers in the Cloud

EC2 Container Service
Run and Manage Docker Containers

Elastic Beanstalk
Run and Manage Web Apps

Lambda
Run Code in Response to Events

Storage & Content Delivery 
S3
Scalable Storage in the Cloud

CloudFront
Global Content Delivery Network

Elastic File System
Fully Managed File System for EC2

Glacier
Archive Storage in the Cloud

Import/Export Snowball
Large Scale Data Transport

Storage Gateway
Integrates On-Premises IT Environments with Cloud Storage

Database
 RDS
Managed Relational Database Service

DynamoDB
Predictable and Scalable NoSQL Data Store

ElastiCache
In-Memory Cache

Redshift
Managed Petabyte-Scale Data Warehouse Service

Networking
 VPC
Isolated Cloud Resources

Direct Connect
Dedicated Network Connection to AWS

Route 53
Scalable DNS and Domain Name Registration

Developer Tools
 CodeCommit
Store Code in Private Git Repositories

CodeDeploy
Automate Code Deployments

CodePipeline
Release Software using Continuous Delivery

Management Tools
 CloudWatch
Monitor Resources and Applications

CloudFormation
Create and Manage Resources with Templates

CloudTrail
Track User Activity and API Usage

Config
Track Resource Inventory and Changes

OpsWorks
Automate Operations with Chef

Service Catalog
Create and Use Standardized Products

Trusted Advisor
Optimize Performance and Security

Security & Identity
 Identity & Access Management
Manage User Access and Encryption Keys

Directory Service
Host and Manage Active Directory

Inspector
Analyze Application Security

WAF
Filter Malicious Web Traffic

Analytics
EMR
Managed Hadoop Framework

Data Pipeline
Orchestration for Data-Driven Workflows

Elasticsearch Service
Run and Scale Elasticsearch Clusters

Kinesis
Work with Real-time Streaming data

Machine Learning
Build Smart Applications Quickly and Easily

Internet of Things
AWS IoT
Connect Devices to the cloud


Mobile Services
Mobile Hub
Build, Test, and Monitor Mobile apps

Cognito
User Identity and App Data Synchronization

Device Farm
Test Android, Fire OS, and iOS apps on real devices in the Cloud

Mobile Analytics
Collect, View and Export App Analytics

SNS
Push Notification Service

Application Services
API Gateway
Build, Deploy and Manage APIs

AppStream
Low Latency Application Streaming

CloudSearch
Managed Search Service

Elastic Transcoder
Easy-to-use Scalable Media Transcoding

SES
Email Sending Service

SQS
Message Queue Service

SWF
Workflow Service for Coordinating Application Components


Enterprise Applications
WorkSpaces
Desktops in the Cloud

WorkDocs
Secure Enterprise Storage and Sharing Service

WorkMail
Secure Email and Calendaring Service

Thứ Tư, 25 tháng 11, 2015

Response a excel file in symfony2

<?php

namespace inSing\AdminBundle\Controller;

use inSing\DataSourceBundle\Utilities\Constant;
use inSing\DataSourceBundle\Repository\TemplateRepository;
use inSing\DataSourceBundle\Repository\TemplateZoneRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

class ExportController extends PageManagerController
{
    /**
     * save page detail
     * @author tri.van
     */
    public function mainAction($page_id = null) {

    $pathFile = dirname(__FILE__).'/../Command/cli/extract_reviews/user_reviews_2015-11-20_15_08_55.xlsx';

        // check if file exists
        $fs = new FileSystem();
        if (!$fs->exists($pathFile)) {
            throw $this->createNotFoundException();
        }

        // prepare BinaryFileResponse
        $response = new \Symfony\Component\HttpFoundation\BinaryFileResponse($pathFile);
        $response->trustXSendfileTypeHeader();
        $response->setContentDisposition(
            ResponseHeaderBag::DISPOSITION_INLINE,
            'user_reviews_2015-11-20_15_08_55sss.xlsx',
            iconv('UTF-8', 'ASCII//TRANSLIT', 'user_reviews_2015-11-20_15_08_55sss.xlsx')
        );

        return $response;
   }
}

Thứ Sáu, 13 tháng 11, 2015

10 Best JavaScript Frameworks and Libraries of 2015

JavaScript is the internet’s most used client-side scripting language. 88.9% of all websites and web apps use JavaScript in one form or the other for animations, user interactions, optimizing page load speeds and even for security purposes. JavaScript is also the most popular language for GitHub repositories
Naturally, with such a large user base Javascript has tons of tools to help improve your code and generally make coding JS faster and easier. In this post we will be discussing the 10 Best JavaScript Frameworks and Libraries for 2015.

The difference between Frameworks and Libraries

Often when discussing any programming related technology, the words Frameworks and Libraries are used interchangeably. However, there is a difference between the two. A library is a collection of functions which your code can call whenever it needs them. Libraries can save lots of time by providing pre-written code for commonly used functions.
A framework is often a collection of software libraries which provide a proper, defined interface to application programming (i.e. creating apps). Frameworks are different from libraries due to some unique features like inversion of control. This basically means that in a framework, unlike in libraries or normal user applications, the overall program’s flow of control is not dictated by the caller, but by the framework.

5 Best JavaScript Frameworks


Best JavaScript Framework of 2015

1. AngularJS


AngularJS is an open-source web app development framework by Google, based on JavaScript. AngularJS aims to be for dynamic web applications what HTML is for static web pages. AngularJS extends HTML, and has extremely powerful features like deep linking, and client side form validation without any extra JavaScript code. AngularJS provides server communication too, so you do not have to worry about using more software and thus more programming languages, for the backend of your app.
Angular even lets you create new HTML elements, using a feature called directives. Components are one of the most useful features of AngularJS. Using Components you can create code that is easily reusable. It also lets you hide complex DOM structures, CSS, and behaviors.
Visit Site

2. Backbone.js


One of 2015’s most popular frameworks, Backbone.js, as the name suggests, gives structure to web applications. Backbone uses data represented in models. Models can be created, validated, destroyed and saved to the server. UI actions cause changes to the models, and when this happens the Views which display the models’ state get re – rendered.
You can read more about how models, key-value bindings, and views (which can perform declarative event handling) come together to form Backbone’s API, in their documentation.

3. Ember.js


Ember.js features Handlebars integrated templates that automatically update as the underlying model data changes. One of Ember’s more powerful features is Components. Using, Components you can create your own app-specific HTML tags, where you can use Handlebars to create the markup and Javascript to implement custom behavior.
Ember uses jQuery to fetch data models from the server, so if you know jQuery, you can easily retrieve JSON stored on the server.
Visit Site

4. Knockout


Knockout is a MV (Model – View) Javascript Framework  which specializes in easy declarative bindings, automatic UI updation (on change in the model state) as well as powerful templating features. Knockout is built on pure Javascript, without any external dependencies. It also happens to work on most browsers, including really out-dated browsers like Internet Explorer (v6).
Visit Site

5. Skel


Skel is an extremely lightweight Javascript framework. Its total size is only  24kb as opposed to 39kb for AngularJS and 54kb for Knockout. Skel is perfectly suitable for developing both web apps as well as responsive websites. It even includes a CSS grid system, which you can read about on their documentation.  Skel also has some great features like normalization of browser styles and API functions.
Visit Site

5 Best Javascript Libraries


Best Javascript Libraries of 2015

1. jQuery


In today’s web, jQuery is to Javascript, what Javascript is to client-side scripting languages. It has an astounding 95% market share when compared against other Javascript libraries. jQuery is used mainly for animations and simple website effects, like transforming elements, changing CSS properties, and utilizing event handlers.
The fact that it is small, packed with features, easy to get started with and still manages to give great performance, makes jQuery a hit with developers everywhere. jQuery even supports user-created plugins. It is undoubtedly the numero uno of Javascript libraries.
Visit Site

2. Modernizr


After jQuery, Modernizr is the most used Javascript library. Modernizr’s job is to detect what HTML and CSS technologies your browser supports. After detecting, Modernizr creates an object with all the properties stored as Boolean values.It then creates classes in the <html> element to explain exactly what is supported and what is not. Modernizr can be used alongside with pretty much anything.
Additionally, Modernizr also supports a script loader, so you can use polyfills to support some never functionalities to an older browser.
Visit Site

3. MooTools


MooTools is a collection of different Javascript libraries that allows you to write flexible code with greater ease, using its APIs. MooTools has extensive documentation and a large number of useful features (Event handlers, creation of new DOM elements,selection of DOM elements, etc) thus making it an excellent tool for web development.
Visit Site

4. YUI


The YUI library is an open source CSS and Javascript library for front-end development. YUI was developed by Yahoo, but as of now the YUI library is no longer being maintained. It can still be downloaded from the YUI website.
Visit Site

5. Dojo


The Dojo Toolkit consists of several Javascript libraries whose main aim is to make it easier to develop websites and web applications. Dojo is small and extremely fast. It also has a widget library ‘dijit’ and a 2D vector graphics API called Dojo GFX, that lets you develop without worrying about your browser’s native graphic technologies.

What database actually FACEBOOK uses?

Hello everyone…..

This is my first blog post and I don’t know how to write it but still I am trying. So fasten your seat belt and get ready for the roller coaster that I will ride with you all with some of the questions which arises sometimes in our mind.  

My today’s question is “What database actually Facebook uses?”
 
A billion of people are using FACEBOOK.Users are expressing themselves and interacting with their peer and friends through wall posts, uploading their photos, passing information’s about events and other meaningful information and for that reason facebook needs a large scalable database.
 
I could imagine that is why it is a very popular Google search keyword. 

I have searched a lot on this topic and come out at a conclusion that Facebook use several database techniques. The challenge for Facebook’s engineers has been to keep the site up and running smoothly in spite of handling close to billion active users.
This article takes a look at some of the software and techniques they use to accomplish their mission.

MYSQL::

Facebook primarily uses MySQL for structured data storage such as wall posts, user information, timeline etc.  This data is replicated between their various data centers.
 

 

MEMCACHED ::

It is also important to note that Facebook makes heavy use of Memcached,a memory caching system that is used to speed up dynamic database driven websites by caching data and objects in RAM to reduce reading time.Memcached is Facebook’s primary form of caching and greatly reduces the database load. Having a
caching system allows Facebook to be as fast as it is at recalling your data.
 
If it doesn’t have to go to the database it will just fetch your data from the cache based on your user ID.

 

 

HAYSTACK :: 

The Photos application is one of Facebook’s most popular features. Up to date, users
have uploaded over 15 billion photos which make Facebook the biggest photo sharing website. For each uploaded photo, Facebook generates and stores four images of different sizes, which translates to a total of 60 billion images and 1.5PB of storage. The current growth rate is 220 million new photos per week, which translates to 25TB of additional storage consumed weekly.
Implements a HTTP based photo server which stores photos in a generic object store called Haystack.
 

 

CASSANDRA ::

 The Apache Cassandra database is the right choice when you need scalability and  high availability without compromising performance. Facebook uses it for its Inbox search.
 

 

SCRIBE ::

 Scribe is a flexible logging system that Facebook uses for a multitude of purposes
internally. It’s been built to be able to handle logging at the scale of Facebook, and automatically handles new logging categories as they show up.
 


 

VARNISH :

:

 Varnish is an HTTP accelerator which can act as a load balancer and also cache content which can then be served lightning-fast. Facebook uses Varnish to serve photos and profile pictures,handling billions of requests every day.

 

HIPHOP FOR PHP ::

 HipHop for PHP is a set of PHP execution engines. HipHop was developed by Facebook and was released as open source in early 2010. To date, Facebook has achieved morethan a 6x reduction in CPU utilization for the site using HipHop as compared with Apache and Zend PHP.Facebook is able to move fast and maintain a high number of engineers who are able to work across the entire codebase.
 
 
So, while “What database does Facebook use?” seems like a simple question, you can see that FACEBOOK developers have added a variety of other systems to make it truly web scalable over their 500million users.

Học lập trình web căn bản với PHP

Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...