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
class Button extends React.Component { | |
handleClick = () => { | |
this.props.onClickFn(this.props.incrementValue); | |
}; | |
render () { | |
return( | |
<button onClick={this.handleClick}> | |
+{this.props.incrementValue}</button> |
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
const Card = (props) => { | |
return ( | |
<div style={{margin:'1em'}}> | |
<img width="175" src={props.avatar_url} /> | |
<div style={{display:"inline-block", marginLeft:"10px"}}> | |
{props.name} | |
<div>{props.company}</div> | |
</div> | |
</div> |
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
const Card = (props) => { | |
return ( | |
<div style={{margin:'1em'}}> | |
<img width="175" src={props.avatar_url} /> | |
<div style={{display:"inline-block", marginLeft:"10px"}}> | |
{props.name} | |
<div>{props.company}</div> | |
</div> | |
</div> |
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 delegate is a function pointer | |
when we work with events we use a delegate which inherie from multicast deletegate | |
a delegate is the pipeline between the event and the event handler | |
button.Click += EventHandler(btnHit_Click) // here when the click event is raised the eventhandler delegate will call the btnHit_CLick method | |
public delegate void WorkHandler(string job, int time) // this delegate can be used as the pipeline for methods that take these two args | |
public void work(string job, int time) |
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
// Student collection | |
IList<Student> studentList = new List<Student>>() { | |
new Student() { StudentID = 1, StudentName = "John", Age = 13} , | |
new Student() { StudentID = 2, StudentName = "Moin", Age = 21 } , | |
new Student() { StudentID = 3, StudentName = "Bill", Age = 18 } , | |
new Student() { StudentID = 4, StudentName = "Ram" , Age = 20} , | |
new Student() { StudentID = 5, StudentName = "Ron" , Age = 15 } | |
}; | |
// LINQ Query Syntax to find out teenager students |
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
avoid .Result Or Wait on task as it will block threads and can lead to deadlocks | |
always wrap your calls in try catch as the async errors are generally swallowed by the framework | |
public async Task<Customer> Get(int id) | |
{ | |
// you are on a particular thread here | |
var customer = await SomeAsyncFunctionThatGetsCustomer(id).ConfigureAwait(false); // doesn't have find the orginal thread it used so is much faster | |
// now you are on a different thread! will that cause problems? | |
return customer; | |
} |
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
Change the hover over object value in the debug window https://msdn.microsoft.com/en-us/library/x810d419.aspx | |
null coelescing opertor | |
string i = name ?? "no name"; these is a shorted version of the ternary ? name : "no name" | |
//deep checks and = | |
string i = name ?? lname ?? fname ?? "no name"; these is a shorted version of the ternary ? name : "no name" | |
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
C++ templates are set at compile time not runtime like C#, java | |
//returns max of two values | |
template <class T> | |
T max(T& t1, T& t2){ | |
return t1 < t2 ? t2 : t1; | |
} | |
overload operators in c++ often | |
instead creating a Add() overload + and or += |
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
smart pointers | |
shared pointer - bumps ref | |
weak pointer - doesn't bump ref | |
uniqiue pointer - can't be copied | |
auto pointer - this is a weak attempt at smart pointers - don't use this it has many problems in containers | |
pResource=std::make_shared<Resource>("Resource for " + GetName()); // init a shard ptr |
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 config = { | |
apiKey: "***", | |
authDomain: "***", | |
databaseURL: "***", | |
projectId: "***", | |
storageBucket: "***", | |
messagingSenderId: "***" | |
}; | |
firebase.initializeApp(config); |