Skip to content

Instantly share code, notes, and snippets.

View joe-oli's full-sized avatar
💭
what the flock? no status to report, i am not a facebook junkie.

joe-oli

💭
what the flock? no status to report, i am not a facebook junkie.
View GitHub Profile
@joe-oli
joe-oli / UpdateEntityProps.cs
Last active March 8, 2020 15:35
Entity Framework Update Entity Props - not whole Entity, just some props
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();
@joe-oli
joe-oli / Parse-Xml-Date-in-JS.txt
Created October 29, 2019 01:38
parse XML dates in JS
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';
@joe-oli
joe-oli / undefined-js-notes.txt
Created October 29, 2019 23:35
undefined in javascript
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).
@joe-oli
joe-oli / ajax-libs-examples.js
Last active October 30, 2019 23:30
ajax libs
/* 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) {
@joe-oli
joe-oli / Unset-styles.html
Created November 1, 2019 04:59
unset all styles for a container
<!--unset all styles for a container-->
<div id="container">
<!-- stuff in here -->
</div>
<style>
#container {
all: initial;
* {
@joe-oli
joe-oli / 4-export-types.js
Created November 2, 2019 15:02
for module export types
== 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));
}
@joe-oli
joe-oli / Namespacing-approches.txt
Last active November 4, 2019 03:24
namespacing approaches
var MyNamespace = {
foo: function() {
},
bar: function() {
}
};
...
@joe-oli
joe-oli / JS-objects-merge.txt
Last active November 4, 2019 05:21
JS Objects - merging
//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)
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
@joe-oli
joe-oli / Guid-validator-with-Regex.txt
Last active November 4, 2019 09:32
Guid-validator-with-Regex
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
------------