This file contains hidden or 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
//--before | |
class Brief extend React.Component { | |
render() { | |
let {post} = this.props | |
return ( | |
<div className="brief"> | |
<Link to={`/apps/blog/posts/${post._id}`} className="title"> | |
<strong>{post.title}</strong> | |
</Link> |
This file contains hidden or 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
From http://www.sitepoint.com/javascript-truthy-falsy/ | |
The following values are always falsy: | |
* false | |
* 0 (zero) | |
* "" (empty string) | |
* null | |
* undefined | |
* NaN (a special Number value meaning Not-a-Number!) |
This file contains hidden or 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
/* Usage: | |
node LookupDescByCode | |
You can ommit '.js' | |
Using a constant lookup Structure (either Array or Obj), fetch the Code+Desc, given the Code. | |
*/ | |
const CodeDescArrMap = [ | |
{Code: 'Z101', Desc: "Apples"}, | |
{Code: 'Z201', Desc: "Bananas"}, | |
{Code: 'Z301', Desc: "Oranges"} |
This file contains hidden or 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
<script> | |
$(function(){ | |
$.ajax( | |
{ | |
type: "POST", | |
url: "https://testapi.XXXXXXXX.com/auth", | |
data: { | |
username:'TestUser', | |
password: 'TestPwd' | |
}, |
This file contains hidden or 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
/* | |
* Download from http://www.javazoom.net/javalayer/sources.html | |
* Unarchive JLayer into source directory | |
* | |
* Build with something like: | |
* javac -classpath JLayer1.0.1/classes/ RandomMP3Player.java | |
* Run with something like: | |
* java -classpath .:jl1.0.1.jar RandomMP3Player 10 z.mp3 1.mp3 | |
* | |
*/ |
This file contains hidden or 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
/* in both cases, wire the `handleSubmit` FN in the html.form onSubmit event | |
<form onSubmit={this.handleSubmit}> | |
<input old pwd | |
<input new pwd | |
<input confirm pwd | |
<button etc | |
</form> | |
*/ | |
//ALT #1: use Promise.then().catch() syntax |
This file contains hidden or 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
Just for reference, here is a table of some old .NET 2 style List<> instance methods, and their equivalent extension methods in Linq: | |
METHOD IN List<> METHOD IN Linq | |
------------------------------------------------------------------------------------------ | |
list.Contains(item) query.Contains(item) | |
list.Exists(x => x.IsInteresting()) query.Any(x => x.IsInteresting()) | |
list.TrueForAll(x => x.IsInteresting()) query.All(x => x.IsInteresting()) |
This file contains hidden or 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
dynamic x = new ExpandoObject(); | |
x.NewProp = string.Empty; | |
Alternatively: | |
var x = new ExpandoObject() as IDictionary<string, Object>; | |
x.Add("NewProp", string.Empty); | |
//============= | |
IDictionary<string, object> expando = new ExpandoObject(); | |
expando["foo"] = "bar"; |
This file contains hidden or 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
IDictionary<string, object> expando = new ExpandoObject(); | |
expando["foo"] = "bar"; | |
dynamic d = expando; | |
Console.WriteLine(d.foo); // bar | |
//Example use case, convert XML payload. loop over the elements, e.g. | |
var doc = XDocument.Load(file); | |
IDictionary<string, object> expando = new ExpandoObject(); |
This file contains hidden or 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
//test #1: exactly the same. | |
let myArrayA = [ | |
{periodSeqNo: 30010, period_month :'jan 2020', start_date: '2020-01-01', end_date: '2020-01-31', opening_bal: 350000.11, opening_rate: 3.100, int_amount_charged: 255.10}, | |
{periodSeqNo: 30020, period_month :'feb 2020', start_date: '2020-02-01', end_date: '2020-02-29', opening_bal: 360000.12, opening_rate: 3.200, int_amount_charged: 255.20}, | |
{periodSeqNo: 30030, period_month :'mar 2020', start_date: '2020-03-01', end_date: '2020-03-31', opening_bal: 370000.13, opening_rate: 3.300, int_amount_charged: 255.30}, | |
]; | |
let myArrayB = [ | |
{periodSeqNo: 30010, period_month :'jan 2020', start_date: '2020-01-01', end_date: '2020-01-31', opening_bal: 350000.11, opening_rate: 3.100, int_amount_charged: 255.10}, | |
{periodSeqNo: 30020, period_month :'feb 2020', start_date: '2020-02-01', end_date: '2020-02-29', opening_bal: 360000.12, opening_rate: 3.200, int_amount_charged: 255.20}, | |
{periodSeqNo: 30030, period_month :'mar 2020', start_date: '2020-03-01', end_date: '2020-03-31', |