npm install [email protected]
Build Angular Project for Production w/ Relative Path
ng build --prod --base-href ./
Update all npm/Angular packages
// npm packages
npm i -g npm-check-updates
ncu -u
npm install
// angular packages
ng update --all
Register generics for Dependency Injection
services.AddTransient(typeof(IExternalApiResponseReader<>),
typeof(ExternalApiResponseReader<>));
Enable CORS in .NET Core Web API
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options
.AddPolicy("CorsPolicy", builder => builder
.WithOrigins("http://localhost:4200")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
}
}
public void Configure(IApplicationBuilder app, IApiVersionDescriptionProvider provider)
{
app.UseCors("CorsPolicy");
}
Remove from git tracking
git rm --cached <file>
git rm --cached <directory> -r
git rm --cached ./ -r
basic angular requirements
// global req.
npm i -g @angular/cli
edit git commit details
git rebase -i 0abc12def // <- the commit before the one that needs edit
// use vi to change "pick" to "edit" on the commit(s) that need edits, then write/quit
git commit --amend --author="Christopher Snay <[email protected]>"
// write/quit vi
git rebase --continue // <- repeat until all edited commits complete
git push -f
Scaffold a MySql database from .NET Core
PM> Scaffold-DbContext "server=IP.ADD.RE.SS;user=dbuser;password=dbpass;database=dbname" MySql.Data.EntityFrameworkCore -o dbname -f
Requirement:
Microsoft.EntityFrameworkCore.Tools
Different providers:
MySql.Data.EntityFrameworkCore
Microsoft.EntityFrameworkCore.SqlServer
Install Logstash plugins
logstasn\bin\logstash-plugin install json-filter
Start Elasticsearch, Kibana, and Logstash
elasticsearch\version\bin\elasticsearch.exe
kibana\bin\kibana.bat
logstash\bin\logstash -f ..\config\logstashconfig.conf -r
Delete data from Elasticsearch
// deletes all data
curl -XDELETE localhost:9200/*
// deletes index
curl -XDELETE localhost:9200/indexname
Angular setup
// create new app
ng new <PROJECT_NAME>
cd <PROJECT_NAME>
// install angular material
npm i @angular/material @angular/animations @angular/cdk hammerjs
// generate components
ng g c <COMPONENT_NAME>
// generate services
ng g s <SERVICE_NAME>
Undo git changes forcibly
git reset --hard HEAD
compare 2 files with Visual Studio
// open cmd
<<<path to Visual Studio\Common7\IDE>>>devenv /diff file1 file2
Or just create a batch file. Example:
@echo off
echo Drag and drop the first file onto this window. Then press [ENTER]
set /p file1=
echo Drag and drop the second file onto this window. Then press [ENTER]
set /p file2=
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /diff %file1% %file2%
Initial git push via HTTPS
git init
git remote add origin https://<<<repo>>>.git
git add .
git commit -m "some comments"
git push -u origin master
format curl json
curl -X GET "http://api/path" -H "accept: application/json" | python -mjson.tool
Check raspberry pi temp
./opt/vc/bin/vcgencmd measure_temp
install Google USB drivers
// Android Studio
Tools > SDK Manager > Appearance & Behavior > System Settings > Android SDK > SDK Tools (tab) > Google USB Driver (checkbox)
initial git pull via SSH
// after setting up a public ssh key
// cd to new directory
git init
git remote add origin [email protected]:<<<me>>>/<<<project>>>.git
git pull origin master