Skip to content

Instantly share code, notes, and snippets.

View sonha's full-sized avatar

Simon sonha

  • Ha Noi
View GitHub Profile
@sonha
sonha / mvc_demo_controller_action.php
Created August 9, 2016 07:15
mvc_demo_controller_action
<?php
require_once('connection.php');
if (isset($_GET['controller']) && isset($_GET['action'])) {
$controller = $_GET['controller'];
$action = $_GET['action'];
} else {
$controller = 'pages';
$action = 'home';
}
@sonha
sonha / include.php
Created August 9, 2016 07:12
include
<?php
require_once('connection.php');
?>
@sonha
sonha / mvc_connection.php
Created August 9, 2016 07:12
mvc_connection
<?php
class Db {
private static $instance = NULL;
private function __construct() {}
private function __clone() {}
public static function getInstance() {
if (!isset(self::$instance)) {
@sonha
sonha / Nested_Foreach_loop.php
Last active June 4, 2019 13:41
Nested Foreach loop Php
<?php
/** Cấu trúc
foreach(array as value){
foreach(array as value){
Statement;
}
Statement;
}
**/
$color= array( "M", "XL", "XXL");
@sonha
sonha / nested_loop_while.php
Last active August 9, 2016 06:45
[Blog] - Nested while loop trong php
<?php
/**Cấu trúc
while(condition){
while(condition) {
statement(s);
increment/decrements;
}
statement(s);
increment/decrements;
}
@sonha
sonha / facebook_share_type_2
Created August 8, 2016 08:01
Ví dụ share facebook tại Codeto - kiểu 2
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta property="og:title" content="Codeto Viet nam">
<meta property="og:description" content="Hoc lap trinh tot nhat Viet Nam">
<meta property="og:type" content="website">
<meta property="og:url" content="http://codeto.vn/product/khoa-dao-tao-lap-trinh-nodejs-can-ban/"/>
<meta property="og:image" content="http://s3.amazonaws.com/heykorean.image.public/common/SNS/2016/02/20/2OvOvtYwEK0.png">
<meta property="og:site_name" content="HeyKorean.com">
@sonha
sonha / facebook_share_type_1
Created August 8, 2016 07:58
Ví dụ về share facebook tại Trung tâm lập trình Codeto
<html>
<head>
<title>Your Website Title</title>
<!-- You can use Open Graph tags to customize link previews.
Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
<meta property="og:url" content="http://codeto.vn/product/khoa-dao-tao-lap-trinh-nodejs-can-ban/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Your Website Title" />
<meta property="og:description" content="Your description" />
<meta property="og:image" content="http://www.your-domain.com/path/image.jpg" />
var express = require("express");
var router = express.Router();
//localhost:3000/admin/
router.use("/", function(req, res) {
console.log(req.url);
res.json({"message" : "This is Admin Default Page"});
});
//localhost:3000/admin/
var express = require("express");
var app = express();
app.get('/', function(req, res){
res.send("This is first application");
});
app.listen(3000);
var http = require("http");
var fs = require("fs");
var path = require("path");
var model = require("./model");
//request
//response : tra ve ket qua cho nguoi dung, dinh nghia kieu du lieu se tra ve
var server = http.createServer(function(req, res) {
console.log("Incoming Request" , req.method, '- ', req.url);