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
using (SECEntities dbCtx = new SECEntities()) | |
{ | |
dbCtx.Configuration.LazyLoadingEnabled = false; | |
dbCtx.Configuration.ProxyCreationEnabled = false; //NO dynamic PROXY, want strongly typed entities ! | |
//select * from TB_ADMIN_UserSession where accessToken = '12345678-...' and getDate() <= expireAt | |
var qry = dbCtx.TB_ADMIN_UserSession.Where(x => x.accessToken == token && DateTime.Now <= x.expireAt); | |
var TB_SessionFound = qry | |
.AsNoTracking() //readonly ! (faster) | |
.SingleOrDefault(); |
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
let myXmlDate = "2019-12-31T14:30:50"; | |
let myJsDate = new Date(myXmlDate); //THIS WILL WORK IN MODERN BROWSERS. | |
For other such as ancient IE7,8 (but i dont give a flock for those anymore), you can manually parse the string and | |
manually create a date object. It's not hard: | |
( Answer from here: https://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object ) | |
var dateString = '2011-11-12T13:00:00-07:00'; |
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
The definition of undefined in ECMAScript 1st edition is | |
Undefined is a primitive value used when a variable has not been assigned a value. | |
It is also used: | |
as the returned value when trying to retrieve an object property that does not exist (after looking for it over the prototype chain). | |
1. If O doesn’t have a property with name P, go to step 4. | |
2. Get the value of the property. | |
3. Return Result(2). |
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
/* axios -------------------------------------------------- | |
Axios is a promise based HTTP client for the browser and Node.js. | |
>npm install axios | |
*/ | |
var request = require('axios'); | |
axios.get('https://localhost:3000/data.json') | |
.then(function (response) { |
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
<!--unset all styles for a container--> | |
<div id="container"> | |
<!-- stuff in here --> | |
</div> | |
<style> | |
#container { | |
all: initial; | |
* { |
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
== 1. Name exports == | |
//------ lib.js ------ | |
export const sqrt = Math.sqrt; | |
export function square(x) { | |
return x * x; | |
} | |
export function diag(x, y) { | |
return sqrt(square(x) + square(y)); | |
} |
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
var MyNamespace = { | |
foo: function() { | |
}, | |
bar: function() { | |
} | |
}; | |
... |
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
//c. 2011 | |
Javascript's Object doesn't have any native merge operation. If you have two objects, say | |
{a:1, b:2} | |
{c:3, d:4} | |
And want to get | |
{a:1, b:2, c:3, d:4} | |
As far as I know, you have to iterate through the objects. That is to say that you decide on either a merge left or merge right strategy and then you do something like (simplified) |
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
Applicable for EF 6.0 and above: | |
Any command sent from the EF to the database can now be logged. To view the generated queries from EF 6.x, use the DBContext.Database.Log property | |
What Gets Logged | |
- SQL for all different kinds of commands. For example: | |
- Queries, including normal LINQ queries, eSQL queries, and raw queries from methods such as SqlQuery. | |
- Inserts, updates, and deletes generated as part of SaveChanges | |
- Relationship loading queries such as those generated by lazy loading |
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
Example #1 | |
------------ | |
Use | in a regular expression to match either what comes before or what comes after: | |
const re = /^([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})|[0-9]+$/i; | |
console.log('11111111-1111-1111-8111-111111111111'.match(re)[0]); | |
console.log('5555'.match(re)[0]); | |
Example #2 | |
------------ |