This file contains hidden or 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
| const http = require("http"); | |
| const https = require("https"); | |
| const AWS = require('aws-sdk'); | |
| const formidable = require("formidable"); | |
| const uuid = require("uuid"); | |
| let server = http.createServer(launch); | |
| let s3 = new AWS.S3({ | |
| // s3 credentials | |
| }); |
This file contains hidden or 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
| // Test this by running the code snippet below and then | |
| // use the "Offline" checkbox in DevTools Network panel | |
| window.addEventListener('online', handleConnection); | |
| window.addEventListener('offline', handleConnection); | |
| function handleConnection() { | |
| if (navigator.onLine) { | |
| isReachable(getServerUrl()).then(function(online) { | |
| if (online) { |
This file contains hidden or 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
| const items = json3.items | |
| const replacer = (key, value) => value === null ? '' : value // specify how you want to handle null values here | |
| const header = Object.keys(items[0]) | |
| let csv = items.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(',')) | |
| csv.unshift(header.join(',')) | |
| csv = csv.join('\r\n') | |
| console.log(csv) |
This file contains hidden or 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
| import { Injectable } from '@angular/core'; | |
| import { HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; | |
| import { Observable } from 'rxjs/Observable'; | |
| import 'rxjs/add/operator/mergeMap'; | |
| import { AuthService } from './auth.service'; | |
| @Injectable() | |
| export class TokenInterceptor implements HttpInterceptor { |
This file contains hidden or 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
| /*This function serves as the core of our DB layer | |
| This will generate a SQL query and execute it whilest returning the response prematurely | |
| @param obj:{Object} this is the options object that contain all of the query options | |
| @return Promise{Object}: returns a promise that will be reject or resolved based on the outcome of the query | |
| The reasoning behind this kind of logic is that we want to abstract our layer as much as possible, if evne the slightest | |
| sytnax change occurs in the near future, we can easily update all our code by updating this one | |
| We are using knex as a query builder and are thus relying on Knex to communicate with our DB*/ | |
| /*Can also be used to build custom query functions from a data.service. This way our database service will remain | |
| unpolluted from many different functions and logic will be contained in a BLL*/ | |
| /* All available options |
This file contains hidden or 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
| # Optimizing postgresql table for more than 100K inserts per second | |
| * Create `UNLOGGED` table. This reduces the amount of data written to persistent storage by up to 2x. | |
| * Set `WITH (autovacuum_enabled=false)` on the table. This saves CPU time and IO bandwidth | |
| on useless vacuuming of the table (since we never `DELETE` or `UPDATE` the table). | |
| * Insert rows with `COPY FROM STDIN`. This is the fastest possible approach to insert rows into table. | |
| * Minimize the number of indexes in the table, since they slow down inserts. Usually an index | |
| on `time timestamp with time zone` is enough. | |
| * Add `synchronous_commit = off` to `postgresql.conf`. | |
| * Use table inheritance for fast removal of old data: |
This file contains hidden or 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
| #Login as root | |
| sudo su | |
| #create jdk directory | |
| mkdir /opt/jdk | |
| #uncompress, change to your file name | |
| tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk | |
| #check if files are there |
This file contains hidden or 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
| version: '2' | |
| services: | |
| myapp: | |
| build: . | |
| container_name: "myapp" | |
| image: debian/latest | |
| environment: | |
| - NODE_ENV=development | |
| - FOO=bar | |
| volumes: |
This file contains hidden or 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
| https://github.com/cloudfoundry/uaa | |
| http://docs.cloudfoundry.org/api/uaa/version/74.4.0/index.html#overview | |
| https://docs.cloudfoundry.org/concepts/architecture/uaa.html | |
| https://www.baeldung.com/cloud-foundry-uaa | |
| React | |
| https://medium.com/@thechrisbull/4-different-kinds-of-components-creating-a-react-ui-component-framework-saga-a-designer-9043c0cc597 |
This file contains hidden or 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
| sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 | |
| ## Ubuntu 18 | |
| echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list | |
| ## Ubuntu 16 | |
| echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list | |
| ## Ubuntu 14 | |
| echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list |
NewerOlder