This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>First name: <input data-bind="value: firstName" /></p> | |
<p>Last name: <input data-bind="value: lastName" /></p> | |
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2> | |
// data model | |
var ViewModel = function(first, last) { | |
this.firstName = ko.observable(first); | |
this.lastName = ko.observable(last); | |
this.fullName = ko.pureComputed(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A promise in JavaScript is an object that represents the eventual completion or failure of an asynchronous operation. | |
*/ | |
new Promise((resolveOuter) => { | |
resolveOuter( | |
new Promise((resolveInner) => { | |
setTimeout(resolveInner, 1000); | |
}), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Observables allow you to track changes or data over time, | |
rather than just waiting for a single result like with promises. | |
*/ | |
// Create an Observable that emits a value every second | |
const observable = Rx.Observable.interval(1000); | |
// Subscribe to the Observable and print the emitted values to the console | |
observable.subscribe(value => console.log(value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML file (.html) | |
CSS file (.css) | |
Typescript file (.ts) | |
Test file (.spec.ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var itmes = new int[] { 1, 2, 3 } | |
// Loop from 1 to n (inclusive) | |
for (int i = items; i <= items.Count; ++i) { | |
// Check if i is divisible by both 3 and 5 | |
if (i % 3 == 0 && i % 5 == 0) { | |
// Add "FizzBuzz" to the result vector | |
console.writeline("FizzBuzz"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is an example of a connectionString node. | |
<connectionStrings> | |
<add name="YourConnectionStringKey" | |
providerName="System.Data.SqlClient" | |
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=YourDB;Trusted_Connection=Yes" /> | |
</connectionStrings> | |
*/ | |
// Global Var outside of CRUD methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Global vars | |
private SqlConnection _connection; | |
SqlConnectionStringBuilder conn = new SqlConnectionStringBuilder(); | |
//Azure SQL Server Name | |
conn.DataSource = "mssqltipsserver.database.windows.net"; | |
//User to connect to Azure | |
conn.UserID = "admindaniel"; | |
//Password used in Azure | |
conn.Password = "mypws@#&*234!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resolveAfter2Seconds() { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve('resolved'); | |
}, 2000); | |
}); | |
} | |
async function asyncCall() { | |
console.log('calling'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Connection and transaction passed in from factory | |
IEnumerable object GetData(connection, transaction) { | |
string sql = "SELECT * FROM Person WHERE FirstName = @FirstName And LastName = @LastName | |
And Company = @Company And Title = @Tile And Email = @Email"; | |
var parameter = new DynamicParameters(); | |
parameter.Add("@Id",con.Id,dbType: DbType.Int32,direction:ParameterDirection.InputOutput); | |
parameter.Add("@FirstName", con.FirstName); | |
parameter.Add("@LastName", con.LastName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Abstract class | |
abstract class Animal | |
{ | |
// Abstract method (does not have a body) | |
public abstract void animalSound(); | |
// Regular method | |
public void sleep() | |
{ | |
Console.WriteLine("Zzz"); | |
} |