Thursday, May 30, 2019

使用簡單的tsc 編譯器來玩typescript

when you would like to learn typescript by self. you could learn it through VS 201x community, then create it with Angular. later, this utility creates several folders and includes multiple typescripts file. it is not a good idea to develop and test.

here, there is a quick guide and just focus on typescript only.
- npm install -g typescript.
check which one version install? and where it is.
command line => where tsc. 
in spite of finding a tsc installed already. but, the version is too old to compiling success.
you might get some fails.

check version & installation folder

D:\test\testTs>where tsc
C:\Users\Terence_Liu\AppData\Roaming\npm\tsc
C:\Users\Terence_Liu\AppData\Roaming\npm\tsc.cmd
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js


D:\test\testTs>tsc -v
Version 3.5.1

if version is 1.x.x of tsc, it means system is using default installation by VS
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js


ES5 and ES6 
When you would like to dedicated format, you can add extra parameter --target with it
under command line
tsc --target es5 prime.ts

let us change it
first:
Second, (below is from "System variables")





Now, let us start working a sample 
use following command to build and try following sample
1. tsc --target es5 prime.ts
2. node prime.js

Note: DO NOT use "es6" to instead of "es5"

in prime.ts
import * as NaW from './modules/NameAndWeather'

import { TempConvert } from './modules/tempConvert';
let myData3 = new NaW.Name("Terence", "Liu");
console.log(myData3.message);

console.log( TempConvert.convertFtoC(38));


in NameAndWeather.ts
export class Name {
constructor( first, second )
{
this.first = first;
this.second = second;
}
get message()
{
return `Hello ${this.first} ${this.second}`
}
first: string;
second:string;
}

export class Weather
{
constructor(weather, city)
{
this.weather = weather;
this.city = city;
}
get weatherMessage()
{
return `It is ${this.weather} in ${this.city}`;
}
city: string;
weather: string;
}


in tempConvert.ts
export class TempConvert
{
constructor()
{

}
static convertFtoC(temp : number)
{
return((parseFloat(temp.toPrecision(2))-32)/1.8).toFixed(1);
}
}

Tuesday, June 12, 2018

JavaScript Object Prototypes

All JavaScript objects inherit properties and methods from a prototype.
in the previous chapter we learned how to use an object constructor.
function Person( first, last, age, eyecolor) {
    this.firstName = first;
    this.lastName = last;
    this.age = age;
    this.eyecolor  = color;
}
var myFather = new Person("John", "Doe", 50, "blue");
var myMother = new Person("Sally", "Rally", 48, "green");

Prototype Inheritance
All JavaScript objects inherit properties and methods from a prototype.
Date objects inherit from Data.prototype. Array objects inherit from Array.prototype. Person objects inherit from Person.prototype. The Object.prototype is on the top of the prototype inheritance chain:
Date objects, Array objects, and Person objects inherit from Object.prototype.

Adding Properties and Methods to Objects
Somtimes you want ot add new proerties (or methods) to all existing objcts of a given type.
sometimes you want to add new properties( or methods) to an object constructor.

Using the Prototype Property
The JavaScript prototype property allows you to add new properties to object constructors:
function Person( first, last, age, eyecolor)
{
    this.firstName = first;
    this.lastName = last;
    this.age = age;
    this.eyecolor = color;
}
Person.prototype.nationality = "English";

Saturday, June 2, 2018

SQL Server 打開SA 帳號,並確保可以正常工作的工具與流程

這邊可以確定是已sa來login了
sql server configuration manager這邊的TCP/IP要確定打開,除此之外
防火牆設定(
https://docs.microsoft.com/zh-tw/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access?view=sql-server-2017
)也必須確認沒有被擋 

上面的檔案預設可以在這個路徑上找得到 C:\Windows\SysWOW64



關於 SQL server connectionstring

1. select "manage user secrets" option from project file.
2.  found such kind of string
{
  "ConnectionStrings:DefaultConnection": "Data Source=TERENCELIU_HP_N;Initial Catalog=RetailStuff;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}



3. in red, you can copy such kind of string from SQL Server Explorer directly,
4. see this picture


you could see a connectionstring field, just copy and paste it.

Friday, June 1, 2018

AngularJS

ng-init --> we are not use this directive often. it is only for

<div ng-app="myApp" ng-controller="myCtrl">
{{firstName+" "+lastName}}
</div>

<script>
var app = angular.module("myApp",[]);
app.controller("myCtrl", function($scope) {
    $scope.firstName = "Terence";
    $scope.lastName = "Liu";
});
</script>

Sunday, May 20, 2018

jQuery Event Methods & What is AJAX?

What are Events?
All  the different visitor's action that a web page can respond to are a called event.

What is AJAX?
AJAX  = Asynchronous JavaScript and XML.
In short; AJAX is about loading data in the background and display it on the webpage, without reloading the whole page.
examples of applications using AJAX: Gmail, Google Maps, Youtube, and Facebook tabs.
you can learn more about AJAX in our AJAX tutorial.


jQuery Chaining

With jQuery, you can chain together actions/methods
Chaining allow us to run multiple jQuery methods (on the same element) within a single statement.

jQuery Method Chaining
Until now we have been writing jQuery statement one at a time( one after the other)
However, there is a technique called chaining, that allows us to run multiple jQuery commands, one after the other, one the same element(s).

jQuery DOM Manipulation
One very import part of jQuery is the possibility to manipulate the DOM.
jQueyr comes with a bunch of DOM related methods that make it easy to access and manipulate elemens and attributes.

jQuery Dimensions

jQuery Dimensions