OData - Querying Data

$filter: The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response.

serviceRoot/People?$filter=FirstName eq 'Scott'

$orderby: The $orderby system query option allows clients to request resources in either ascending order using asc or descending order using desc.

serviceRoot/People('scottketchum')/Trips?$orderby=EndsAt desc

$count: The $count system query option allows clients to request a count of the matching resources included with the resources in the response.

serviceRoot/People/$count

$select: The $select system query option allows the clients to requests a limited set of properties for each entity

serviceRoot/Airports?$select=Name, IcaoCode

$top & $skip: The $top system query option requests the number of items in the queried collection to be included in the result. The $skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.

serviceRoot/People?$top=2

$expand: The $expand system query option specifies the related resources to be included in line with retrieved resources.

serviceRoot/People('keithpinckney')?$expand=Friends

Supporting multiple filters:

Use the and/or operators to apply multiple filters.

References:

http://www.odata.org/getting-started/basic-tutorial

Shared by joubin on Fri Jun 23 2017

Theory attribute, xUnit

Marks a test method as being a data theory.

Data theories are tests which are fed various bits of data from a data source, mapping to parameters on the test method.

If the data source contains multiple rows, then the test method is executed multiple times (once with each data row). Data is provided by attributes which derive from Xunit.Sdk.DataAttribute:

  • Xunit.InlineDataAttribute
  • Xunit.MemberDataAttribute

References:

https://github.com/xunit/xunit

Shared by joubin on Thu May 16 2019

Content-Disposition, Http Header

The Content-Disposition response-header field has been proposed as a means for the origin server to suggest a default filename if the user requests that the content is saved to a file.

Example:

Content-Disposition: attachment; filename="fname.csv"

Note: In the context of a CORS request, use the Access-Control-Expose-Headers Http header to expose Content-Disposition as a header value.

References:

https://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html

Shared by joubin on Thu May 16 2019

CORS related headers

All CORS related headers are prefixed with "Access-Control-".

Access-Control-Allow-Origin
Access-Control-Allow-Credentials
Access-Control-Expose-Headers

References:

https://www.html5rocks.com/en/tutorials/cors/

Shared by joubin on Thu May 16 2019

Azure Security Center

Azure Security Center (ASC) is a monitoring service that provides threat protection across all of your services both in Azure, and on-premises.

ASC is part of the Center for Internet Security (CIS) recommendations.

References:

https://docs.microsoft.com/en-us/learn/modules/top-5-security-items-to-consider/2-azure-security-center

Shared by joubin on Mon May 13 2019

Center for Internet Security

The Center for Internet Security (CIS) is a nonprofit organization, formed in October, 2000.

Its mission is to "identify, develop, validate, promote, and sustain best practice solutions for cyber defense and build and lead communities to enable an environment of trust in cyberspace".

The organization is headquartered in East Greenbush, New York, with members including large corporations, government agencies, and academic institutions.

References:

https://en.wikipedia.org/wiki/Center_for_Internet_Security

Shared by joubin on Mon May 13 2019

SIEM, Security

Security information and event management (SIEM) software products and services combine security information management (SIM) and security event management (SEM). They provide real-time analysis of security alerts generated by applications and network hardware.

Vendors sell SIEM as software, as appliances or as managed services; these products are also used to log security data and generate reports for compliance purposes.

See also:

SIM - Security Information Management

SEM - Security Event Management

References:

https://en.wikipedia.org/wiki/Security_information_and_event_management

Shared by joubin on Mon May 13 2019

Global Error Handling, Angular

Create a class that implements ErrorHandler.

It has one method needs implementing: handleError 

References:

https://angular.io/api/core/ErrorHandler

Shared by joubin on Mon May 13 2019

Http Interception, Angular

You declare a class as an interceptor in Angular by implementing the HttpInterceptor interface.

An interceptor will transform the client requests and responses from the server.

References:

https://angular.io/guide/http#intercepting-requests-and-responses

Shared by joubin on Wed May 08 2019

Anaconda

Anaconda is a Python distribution that comes pre-installed with many data science related libraries.

References:

Shared by joubin on Sat Jun 03 2017

DATEPART, TSql

Returns an integer from a 'date' string based on the argument of datepart abbreviation.

DATEPART ( datepart , date )

References:

Shared by joubin on Mon May 06 2019

DATEFROMPARTS, TSql

Returns a datetime type given integer year/month/day.

DATEFROMPARTS ( year, month, day )

References:

Shared by joubin on Mon May 06 2019

Bottom Sheets, Material design

Bottom sheets are surfaces containing supplementary content that are anchored to the bottom of the screen.

References:

Shared by joubin on Sun Apr 28 2019

New keybinding, Visual Studio Code

All keyboard shortcuts in VS Code can be customized via the keybindings.json file.

To customize Visual Studio Code with a new keyboard short:

  1. File -> Preferences -> Keyboard Shortcuts
  2. On this screen, click on the {} item on the top-right corner. This will open the keybindings.json file.
  3. Enter a custom command such as the following:
    1. { "key": "ctrl+up", "command": "workbench.action.toggleMaximizedPanel" }, // I wanted a command to maximize the terminal window
  4. Save

References:

Shared by joubin on Wed Apr 24 2019

npm commands

Update npm itself

npm install -g npm

Check npm version

npm --version

Install a package

# Local
npm install package-name

# Local + make an entry in package.json as dependency
npm install package-name --save

# Install specific version of a package
npm install package-name@1.2.3

# Global
npm install -g package-name

Un-install a package

# Local
npm uninstall package-name

# Global
npm uninstall package-name -g

Get package info

# Home page
npm home package_name
# Github repo
npm repo package_name

Check for outdated packages in package.json

# Local
npm outdated

# Global
npm outdated -g

# Production only
npm outdated --prod

Remove un-used packages from node_modules folder

npm prune

Update all packages listed in package.json

npm update

npm --depth 9999 update

Remove duplicate packages from node_modules

npm dedupe

References:

Shared by joubin on Fri Apr 12 2019

package-lock.json, NPM

package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json.

It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.

This file is intended to be committed into source repositories, and serves various purposes:

  • Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
  • Provide a facility for users to "time-travel" to previous states of node_modules without having to commit the directory itself.
  • To facilitate greater visibility of tree changes through readable source control diffs.
  • And optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.

References:

Shared by joubin on Wed Dec 19 2018

Editing, Saving and Quitting Vim

Once you're in a Vim editor:

  1. Type 'i' to switch to 'insert' mode. Modify the file now.
  2. Hit 'esc' to return to the 'normal' mode
  3. Type ':wq' - w - 'write' and q - 'quit'

The 'normal' mode of a Vim editor: all key presses are interpretted as a command. To get into an editing (ie insert) mode, press 'i'

References:

Shared by joubin on Wed Apr 10 2019

Access modifier, TypeScript

In TypeScript each member of a class is public by default. You can still explicitly set a member to public.

References:

Shared by joubin on Tue Apr 09 2019

hasOwnProperty, JavaScript

hasOwnProperty returns a boolean value indicating whether the object has a property with the name of the argument.

Example: obj.hasOwnProperty('prop1')

Shared by joubin on Tue Apr 09 2019

Add multiple columns to a table, TSql

ALTER TABLE table_name
ADD {COLUMNNAME} {TYPE} {NULL | NOT NULL},
ADD {COLUMNNAME} {TYPE} {NULL | NOT NULL},
...
ADD {COLUMNNAME} {TYPE} {NULL | NOT NULL};

Shared by joubin on Thu Apr 04 2019