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
DateTimeOffset fails silently with XmlSerializer; instead use DataContractSerializer. | |
Apparently XMLSerializer does not support certain aspects of the DateTimeOffset structure.. WTF?! | |
Generic example below (uses UTF8 encoding here, but you can use whatever you like): | |
public static string SerializeObject<T>(T instance) where T : class | |
{ | |
try | |
{ | |
MemoryStream stream = new MemoryStream(); |
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
function objectHasProperties(obj) { | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
// ALT for more modern JS |
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
Tree accepts only a few command line parameters: | |
c:\>Tree /? | |
Graphically displays the folder structure of a drive or path. | |
TREE [drive:][path] [/F] [/A] | |
/F Display the names of the files in each folder. | |
/A Use ASCII instead of extended characters. | |
None of the indicated parameters are a file mask or filter. |
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
--bit(boolean) flag in SQL COlumn. To check for both false or Null use: isnull(MyTable.isBoolCol, 0) = 0 | |
select * from MyTable | |
where isnull(MyTable.isBoolCol, 0) = 0 | |
-- find all tables that have a DateTime column | |
select * from INFORMATION_SCHEMA.COLUMNS | |
where TABLE_NAME like 'hlc%' -- tables starting with hlc | |
and data_type = 'datetime' |
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
Put in your batch file | |
start cmd.exe /k "net use" | |
From cmd /? | |
Starts a new instance of the Windows XP command interpreter | |
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF] [[/S] [/C | /K] string] | |
/C Carries out the command specified by string and then terminates |
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
const shallowCompareFN = (obj1, obj2) => | |
Object.keys(obj1).length === Object.keys(obj2).length && | |
Object.keys(obj1).every(key => | |
obj2.hasOwnProperty(key) && obj1[key] === obj2[key] | |
); | |
let obj1 = { | |
prop1 : 'abc', | |
prop2 : '123' | |
} |
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
//*** Is STRING a Valid Date? *** | |
approach: check if .getTime is equal to itself; WTF? | |
because if date is invalid, it will return NaN for .getTime(); | |
You can a) check isNaN(.getTime()) or (b) NaN is never equal to itself; | |
; i.e. return .getTime() === .getTime() is true, if valid date; false if not date - haha WTF indeed. | |
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
//Sort Array of Objects by Date Str yyyy-MM-dd; | |
//to run in node, open cmd prompt enter >node sortArrayOfObjectsByDate.js | |
let myArray = [ | |
{trans_date : '2020-01-03', closing_bal: 298700.70}, | |
{trans_date : '2020-01-07', closing_bal: 654321.20}, | |
{trans_date : '2020-01-06', closing_bal: 111700.70}, | |
{trans_date : '2020-01-01', closing_bal: 3000.70} | |
]; |
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', |
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(); |