This file contains 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
/* ============= basicServer101.js ============== */ | |
/* shows | |
- handling Body in a POST (or PUT) request; | |
- two http-request handlers can be hooked up to the same event; both get called one after the other... (just experimenting... we could use one handler with if-then inside it) | |
USAGE: | |
at a cmd prompt enter: | |
>node basicServer101 | |
then at a Browser enter: |
This file contains 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
//immutable: | |
const { List } = require('immutable'); | |
const someList = List([1,2,3,4,4,4,4]); | |
const uniqueList = someList.toSet(); | |
//ES6: | |
const someArr = [1,2,3,4,4,4,4]; | |
const uniqueSet = new Set(someArr); //==> {1,2,3,4} uniqueSet.constructor is a Set; typeof uniqueSet = "object" | |
const uniqueArr = [...uniqueSet]; //==> [1,2,3,4] uniqueList.constructor is an Array; typeof uniqueList = "object" | |
const uniqueArr2 = Array.from(uniqueSet); //ALT to above line |
This file contains 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
/* | |
break out of loops | |
--------------------- | |
test in node with: | |
>node loops-breakout | |
*/ | |
//+++++ use for -loop; +++++++++++++++ | |
console.log('starting for -loop...'); | |
let selectedRows = {}; | |
//add props(or keys) to object. |
This file contains 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 System.Collections.Generic; //List<> | |
using System.Data.Entity.Infrastructure; //DbRawSqlQuery | |
using System.Data.SqlClient; //SqlParameter | |
using MyNamespace.EFLayer.MyModel; //EFEntities | |
/* executing SELECT field1,field2 from Tablename WHERE pk IN (1,3,5,69) using EntityFramework; | |
---------- | |
place the WHERE clause set in an array, e.g. wherePkeysArray = [1,3,5,69] | |
create a concrete class DTO.ResultObj such that its prop names match exactly the fields in your sql, i.e. field1, field2 | |
*/ |
This file contains 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
int pkSeqNo = 123; | |
//detached entity | |
MyChildEntity child_entity = new MyChildEntity(); | |
MyParentEntity attachedParentEntity = dbCtx.MyParentEntity | |
.Where( h => h.seqNo == pkSeqNo) | |
.Include( h => h.MyChildEntity) | |
.SingleOrDefault(); |
This file contains 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
-- Find tables without primary keys (PKs) in SQL Server database | |
select schema_name(tab.schema_id) as [schema_name], | |
tab.[name] as table_name | |
from sys.tables tab | |
left outer join sys.indexes pk | |
on tab.object_id = pk.object_id | |
and pk.is_primary_key = 1 | |
where pk.object_id is null | |
order by schema_name(tab.schema_id), | |
tab.[name] |
This file contains 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
//view latest version only | |
>npm view react-scripts version | |
//view all versions | |
>npm view react-scripts versions | |
//#1 view all versions of a lib on the remote npm server. | |
>npm view react-bootstrap versions --json |
This file contains 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 query to retrieve SERVER/DB | |
select ( | |
select | |
@@SERVERNAME as ServerName, | |
db_name() as DatabaseName | |
-- for XML PATH, root --//<== wraps each record with default <row> element, and supply a default root overall. | |
-- for XML PATH('item'), root('treetop') --//<== when you want to rename 'row' to 'item', 'root' to 'treetop' | |
for XML PATH --//<== default <row> element, no root. | |
-- yields a dodgy column name, say, XML_F52E2B61-18A1-11d1-B105-00805F49916B |
This file contains 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 determine logical names / physical names | |
declare @sourceFile varchar(150) = 'D:\Path\To\File\Mybackup.BAK' | |
RESTORE FILELISTONLY | |
FROM DISK = @sourceFile | |
GO -- go clears any variables below here.. need to redefine them again. | |
-- #2 copy logical filenames from step#1, and define target filenames | |
/* |
This file contains 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. The following will search everything from / and children, for the command whoami | |
$ find / -iname "whoami" | |
-- #2. Install chntpw on Kali Linux Light 64 Bit (default pwd for root is toor) | |
$ apt-get install chntpw | |
$ sudo apt-get install chntpw //if you are not already root. | |
-- #3. Mount drive | |
$ sudo mount -t ntfs /dev/blah1/blah2 /mnt/windows |
OlderNewer