All Docs

Config-files

AppVeyor Config template

appveyor.yml

### https://github.com/sindresorhus/appveyor-node/blob/master/appveyor.yml
os: unstable

max_jobs: 5
environment:
  matrix:
    - platform: x64

cache:
  - node_modules
  - '%USERPROFILE%\.electron-gyp'
  - '%USERPROFILE%\.node-gyp'

install:
  - ps: Install-Product node 10.15.3 x64
  - set CI=true
  - npm install -g npm@latest
  - npm install

build: off

matrix:
  fast_finish: true

test_script:
  - node --version
  - npm --version
  - npm run build-quick
  - npm run test-build

artifacts:
  - path: ./build/*.exe
    name: executables
  - path: ./test/__testResults__
    name: results

deploy:
  release: myproduct-v$(appveyor_build_version)
  description: 'Release description'
  provider: GitHub
  auth_token:
    secure: w086h7SsN4ZengkZWbBcX3yNc9lM9vS0d7KD7ED0OSblaBlaBla ### your encrypted token from GitHub
  artifact: executables, results
  draft: true
  prerelease: true
  on:
    branch: master
    ### APPVEYOR_REPO_TAG: true 

travis.github.release

.travis-github-release.yaml

sudo: required
dist: trusty

language: node_js
cache: 
  - npm
  - directories:
    - ./build

notifications:
  email:
    on_success: never
    on_failure: change

matrix:
  include:
    - os: linux
      node_js: lts/*

install:
  - npm install

script:
  - npm run download

deploy:
  overwrite: true
  provider: releases
  api_key: $GITHUB_TOKEN
  file_glob: true
  file: out/*
  skip_cleanup: true
  draft: true

.gitignore

logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

### Runtime data
pids
*.pid
*.seed
*.pid.lock

### Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

### Coverage directory used by tools like istanbul
coverage

### nyc test coverage
.nyc_output

### Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)## .grunt

### Bower dependency directory (https://bower.io/)
bower_components

### node-waf configuration
.lock-wscript

### Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

### Dependency directories
node_modules/
jspm_packages/

### TypeScript v1 declaration files
typings/

### Optional npm cache directory
.npm

### Optional eslint cache
.eslintcache

### Optional REPL history
.node_repl_history

### Output of 'npm pack'
*.tgz

### Yarn Integrity file
.yarn-integrity

### dotenv environment variables file
.env
.env.test

### parcel-bundler cache (https://parceljs.org/)
.cache

### next.js build output
.next

### nuxt.js build output
.nuxt

### vuepress build output
.vuepress/dist

### Serverless directories
.serverless/

### FuseBox cache
.fusebox/

### DynamoDB Local files
.dynamodb/

travis-firebase-hosting

.travis-firebase-hosting.yaml

sudo: required
dist: trusty

language: node_js
cache: 
  - npm
  - directories:
    - ./build

notifications:
  email:
    on_success: never
    on_failure: change

matrix:
  include:
    - os: linux
      node_js: lts/*

install:
  - npm install

script:
  - npm run build

deploy:
  provider: firebase
  token:
    secure: "YOUR ENCRYPTED token"
  project: "myapp-staging"
  local_dir: "dist"
  skip_cleanup: true

after_deploy:
  - npm run after-deploy

.travis-github-pages.yaml

sudo: required
dist: trusty

language: node_js
cache: 
  - npm
  - directories:
    - ./build

notifications:
  email:
    on_success: never
    on_failure: change

matrix:
  include:
    - os: linux
      node_js: lts/*

install:
  - npm install

script:
  - npm run build

deploy:
  local_dir: [dist-dir]### e.g. local_dir: ./.vuepress/dist
  provider: pages
  skip_cleanup: true
  github_token: $GITHUB_TOKEN
  fqdn: [subdomain].[domain].[ext] #e.g.## fqdn: notes.nishkal.in
  on:
    branch: master

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "importHelpers": true,
    "outDir": "./dist",
    "inlineSourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "lib": [
      "es2017",
      "dom"
    ],
    "baseUrl": "./",
    "module": "umd",
    "types": [
      "node"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "strict": false,
    "skipLibCheck": true,
    "allowJs": true
  },
    "include": [
    "src/*",
    "worker/*"
  ],
  "exclude": [
    "**/node_modules/*",
  ]
}

cloudbuild.yml

steps:
### Decrypt
- name: gcr.io/cloud-builders/gcloud
  args:
  - kms
  - decrypt
  - --ciphertext-file=.env.enc
  - --plaintext-file=.env
  - --location=global
  - --keyring=cloud-build-keyring
  - --key=cloud-build-key

### install
- name: 'gcr.io/cloud-builders/npm'
  args : ['install']

### build
- name: 'gcr.io/cloud-builders/npm'
  args : ['run','cloud-build']

### deploy
- name: 'gcr.io/cloud-builders/npm'
  args : ['run','deploy-ci']

Snippets

Github encrypt files

Note

View on github: Link

1. Encrypting and decrypting files
  1. Adding files to a tar archive.
### Where foo and bar are the files you want to encrypt.
tar cvf ./path-to-secrets.tar foo bar
  1. Encrypting file
gpg --symmetric --cipher-algo AES256 ./path-to-secrets.tar
  1. Decrypting file
gpg --quiet --batch --yes --decrypt --passphrase="$SECRET_KEY" --output ./path-to-output-file.tar ./path-to-input-gpg-file.gpg
  1. Extracting the tar archive
### -C is for CWD
tar xvf secrets.tar -C ./out-dir

Node on Linux

Install instructions

Instruction manual: Link

For node 12

  1. curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
  2. sudo apt-get install -y nodejs

SSH

Note

Digital ocean tutorial: Link bradtraversy: Link

1. Generate ssh key
ssh-keygen

// variation
ssh-keygen -t ras
2. Copy to server
// login to server

nano ~/.ssh/authorized_keys
3. Change SSH config
// edit config here
sudo nano /etc/shell/sshd_config

// after editing
sudo systemctl reload sshd
4. Create new user with sudo
$ adduser my-user-name

$ id my-user-name

$ usermod -aG sudo my-user-name

$ id my-user-name

Website plan

Markdown v/s Wordpress CMS

What can we do about it?

  • You use wordpress (wont be able to help, scalability issues, maintenance e.t.c)
  • You learn to write markdown
  • OR
    • Use wordpress as CMS
    • Convert wordpress website to markdown

Type of content

  • Exactly as same as fireship.io
    1. Courses - paid as well as free
    2. one-to-one video mapping
    3. quick snippets
    4. tags
    5. NOT categories (see below)

Discuss data structure

  • Get categories list (Do we even need category?)
  • Get tags list

Meta material

  • Comments section (slack v/s disqus)
  • Analytics stuff
  • Image compression (because terrible football analyses was very heavy)

Ask Aayush

  • Adobe premium pro (aayu would see plans /feasibility e.t.c)
  • Elastic search/Algolia
  • Check other blogs for fitness, their layout e.t.c

Building portfolio

1. Install node.js

Install instructions

Download from: Link

2. Install Git SCM

Install instructions

Download from: Link

3. Clone the Git repo
  1. Open a terminal in the folder where you want to clone the repo
  2. Run the following command
git clone https://github.com/Nishkalkashyap/portfolio.git
4. Change the terminal directory

Run the following command

cd portfolio
5. Install project

Run the following command

npm install
6. Start the local server to begin editing the project
  1. Run the following command
npm run start
  1. Open your web-browser and type http://localhost to see the website.
7. Start editing file
  1. Open the file in local directory /.vuepress/components/Resume.vue
  2. Edit the file and save the changes
  3. Observe the changes in the website

Using ffmpeg.

#video## scaling
ffmpeg -i 'input.mp4' -vf "scale=1920:-1" './output.mp4'

#changing## bitrate
ffmpeg -i 'input.mp4' -b:v "1000K"  './output.mp4'

#bitrate## alternative (crf may vary from 18-24 i.e. high quality to low quality);
ffmpeg -i 'input.mp4' -vcodec libx264 -crf 24  './output.mp4'

#video## speed (take note of -an flag. Removed audio)
ffmpeg -i 'input.mp4' -vf "setpts=0.5*PTS" -an './output.mp4'

#framerate## ffmpeg -i 'input.mp4' -r 24 -an './output.mp4'

#screenshot## ffmpeg -i 'input.mp4' -ss 01:23:45 -vframes 1 './output.jpg'

#override:## take note of -y flag
ffmpeg -y -i 'input.mp4' './output.mp4'

#chaining## commands - use ';' in powershell and '&&' in bash
ffmpeg -f concat -i files.txt -an -codec copy output1.mov;ffmpeg -i output1.mov -vf "setpts=0.5*PTS,scale=800:-1" -b:v "1000K" output2.mov

#video## concat
### ref: https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg#11175851## cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

ffmpeg -f concat -i mylist.txt -c copy output.mp4

Quark news mentions

lemondeinformatique.fr

infoworld.com

Javascript weekly

Node weekly

ciokorea.com


Setting up a VPN Server.

  • Follow the guide here
  • Do not waste time setting up open VPN.

Firebase functions:config:set

Note

View on firebase: Link

1. To set environment variables
firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"
2. To get environment variables
firebase functions:config:get someservice
  • which returns
{
  "someservice": {
    "key":"THE API KEY",
    "id":"THE CLIENT ID"
  }
}

OpenSSL encrypt/decrypt files.

Note

View on stackoverflow: Link

1. To encrypt
openssl enc -aes-256-cbc -in un_encrypted.data -out encrypted.data
2. To decrypt
//with password prompt
openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data

//without password prompt
openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data -k [MyPassword]
e.g. openssl enc -d -aes-256-cbc -in encrypted.data -out un_encrypted.data -k 123456789

Travis encrypt files

Note

View on travis: Link

1. Encrypting a single file
### use --add flag to automatically add decrypt script to .travis.yml.
travis encrypt-file inputFilePath outputFilePath --add
2. Encrypting multiple files
  1. Adding files to a tar archive.
### Where foo and bar are the files you want to encrypt.
tar cvf secrets.tar foo bar
travis encrypt-file secrets.tar --add
  1. Extracting the tar archive
//-C is for CWD
- tar xvf secrets.tar -C ./out-dir

Appvoyer encrypt files

Note

View on appvoyer: Link

1. Encrypting file on development machine
  • Download secure-file utility by running the following command on development machine:
### on windows
iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))

### on linux
curl -sflL 'https://raw.githubusercontent.com/appveyor/secure-file/master/install.sh' | bash -e -
  • To encrypt a file:
### on windows
appveyor-tools\secure-file -encrypt C:\path-to\filename-to-encrypt.ext -secret MYSECRET1234

### on linux
./appveyor-tools/secure-file -encrypt /path-to/filename-to-encrypt.ext -secret MYSECRET1234

Encrypted file will be saved in the same directory as the input file, but with the .enc extension added. You can optionally specify output file name with the -out parameter.

2. Decrypting files during an AppVeyor build
  • Put the “secret” value to the project environment variables on the Environment tab of the project settings or in the appveyor.yml as a secure variable:
environment:
  my_secret:
    secure: BSNfEghh/l4KAC3jAcwAjgTibl6UHcZ08ppSFBieQ8E=
  • To decrypt the file, add these lines to the install section of your project config:
install:
  - ps: iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
  - cmd: appveyor-tools\secure-file -decrypt path-to\encrypted-filename.ext.enc -secret %my_secret%
  - sh: ./appveyor-tools/secure-file -decrypt path-to/encrypted-filename.ext.enc -secret $my_secret

The line starting with cmd: will run on Windows-based images only and the line starting with sh: on Linux.

Note

Note that file won’t be decrypted on Pull Request builds as secure variables are not set during PR build.


Setup travis

Note

View travis-ci official deployment guide: Link

1. Generate firebase token.
### This generates a token, e.g. "1/AD7sdasdasdKJA824OvEFc1c89Xz2ilBlaBlaBla"
firebase login:ci
### Encrypt this token
travis encrypt "1/AD7sdasdasdKJA824OvEFc1c89Xz2ilBlaBlaBla" --add
### This command may generate a warning ("If you tried to pass the name of the repository as the first argument, you probably won't get the results you wanted"). You can ignore it.
2. Copy base .travis.yml fron here
3. Push code to github.

Setup travis

Note

View on youtube: Link

View travis-ci official deployment guide: Link

1. Add a personal access token on github.
2. Make sure to have required "homepage" field in package.json.

e.g.

{
    ...
    "homepage": "https://nishkalkashyap.github.io/notes",
}
3. Enable build on travis-ci, and add personal access token in environment variables.
4. Copy base .travis.yml fron here
5. Add A records of custom domain like so.
Type Name Value
A [domain] 185.199.108.153
A [domain] 185.199.109.153
A [domain] 185.199.110.153
A [domain] 185.199.111.153

Warning

If using a subdomain. Instead of adding A records, add a single CNAME record. e.g.

Type Name Value
CNAME [subdomain] [github-user-name].github.io

Setup cloud build

Note

View on fireship: Link

1. Goto Build Page
2. Go to triggers in the sidebar and select trigger.
3. Setup local dev environment.
  1. Add the .env file with all the environment variables.

  2. Get the Keys from google-cloud-iam.

  3. Run the following command.

gcloud kms encrypt   --plaintext-file=.env   --ciphertext-file=.env.enc   --location=global   --keyring=cloud-build-keyring   --key=cloud-build-key
  1. Add the cloudbuild.yaml file at the root of your project. Copy the config file reference fron here.
  2. Push to the repo.

Replies

Email response