Generate password using Openssl

Tags

$ openssl rand -base64 32 => 32 characters
$ openssl rand -base64 11 => 11 characters

Advertisements

Postgres Errors

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /home/armano/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pg-0.21.0/ext
/home/armano/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20180619-26423-1scg61l.rb extconf.rb
checking for pg_config… yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
checking for libpq-fe.h… no
Can’t find the ‘libpq-fe.h header
*** extconf.rb failed ***

dropbox

Tags

Run two or more dropbox accounts in your PC
If you have compiled dropbox in your home from tar.gz file -> https://askubuntu.com/a/237655/127327

1. Open a terminal and paste the following commands:
$ mkdir “$HOME”/.dropbox-office
$ ln -s “$HOME/.Xauthority” “$HOME/.dropbox-office/”
$ HOME=”$HOME/.dropbox-office”
$ /home/$USER/.dropbox-dist/dropboxd

2. start Dropbox from terminal
$ /home/$USER/.dropbox-dist/dropboxd

3. start Alternate-Dropbox from terminal
$ HOME=”$HOME/.dropbox-office” && /home/$USER/.dropbox-dist/dropboxd

Reference: https://askubuntu.com/questions/475419/how-to-link-and-use-two-or-more-dropbox-accounts-simultaneously

How to import your GPG keys using GNU Private Assistant

Tags

, ,

Download and install the gpg for windows at https://gpg4win.org/download.html
1. Open the GNU Privacy Assistant
2. Click the Keys menu > click Import Keys
3. Browse your GPG secret keys stored from your USB. Example of filename: secret-key-123456C3.asc
This file contains both the Public & Private key
4. Once it successfully imported then click Windows menu > File Manager
From File Manager, browse your encrypted file e.g. password.zip.gpg then a password dialog box will appear.
You will enter the password of your gpg. That’s it!

More info at https://www.gnupg.org

Named exports/Name imports, export default

Tags

,

// airplane.js
// Export Named Exports

export let availableAirplanes = [
{name: 'AeroJet',
 fuelCapacity: 800,
 availableStaff: ['pilots', 'flightAttendants', 'engineers', 'medicalAssistance', 'sensorOperators'],
 maxSpeed: 1200,
 minSpeed: 300
}, 
{name: 'SkyJet',
 fuelCapacity: 500,
 availableStaff: ['pilots', 'flightAttendants'],
 maxSpeed: 800,
 minSpeed: 200
}
];

export let flightRequirements = {
  requiredStaff: 4,
  requiredSpeedRange: 700
};

export function meetsStaffRequirements(availableStaff, requiredStaff) {
  if (availableStaff.length > requiredStaff) {
    return true;
  } else {
    return false;
  }
};

export function meetsSpeedRangeRequirements(maxSpeed, minSpeed, requiredSpeedRange) {
  let range = maxSpeed - minSpeed;
  if (range > requiredSpeedRange) {
    return true;
    } else {
    return false;
  }
};

export default meetsSpeedRangeRequirements;

// missionControl.js
// Import Named Imports

import { availableAirplanes, flightRequirements, meetsStaffRequirements} from './airplane';

import meetsSpeedRangeRequirements from './airplane';

function displayFuelCapacity() {
  availableAirplanes.forEach(function(element) {
    console.log('Fuel Capacity of ' + element.name + ': ' + element['fuelCapacity']);
  });
}

displayFuelCapacity();

function displayStaffStatus() {
  availableAirplanes.forEach(function(element) {
   console.log(element.name + ' meets staff requirements: ' + meetsStaffRequirements(element.availableStaff, flightRequirements.requiredStaff) );
  });
}

displayStaffStatus();

function displaySpeedRangeStatus() {
  availableAirplanes.forEach(function(element) {
   console.log(element.name + ' meets speed range requirements:' + meetsSpeedRangeRequirements(element.maxSpeed, element.minSpeed, flightRequirements.requiredSpeedRange));
  });
}

displaySpeedRangeStatus();

Modules in JavaScript are reusable pieces of code that can be exported from one program and imported for use in another program.

  • module.exports – exports the module for use in another program.
  • require() – imports the module for use in the current program.

ES6 introduced a more flexible, easier syntax to export modules:

  • default exports use export default to export JavaScript objects, functions, and primitive data types.
  • named exports use the export keyword to export data in variables.
  • named exports can be aliased with the as keyword.
  • import is a keyword that imports any object, function, or data type.

Javascript Inheritance

Tags

class HospitalEmployee {
  constructor(name) {
    this._name = name;
    this._remainingVacationDays = 20;
  }
  
  static generatePassword() {
    return Math.floor(Math.random() * 10000);
  }

  get name() {
    return this._name;
  }
  
  get remainingVacationDays() {
    return this._remainingVacationDays;
  }
  
  takeVacationDays(daysOff) {
    this._remainingVacationDays -= daysOff;
  }
}

class Nurse extends HospitalEmployee {
  constructor(name, certifications) {
    super(name);
    this._certifications = certifications;
  } 
  
  get certifications() {
    return this._certifications;
  }
  
  addCertification(newCertification) {
    this._certifications.push(newCertification);
  }
}

const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
nurseOlynyk.takeVacationDays(5);
console.log(nurseOlynyk.remainingVacationDays);
nurseOlynyk.addCertification('Genetics');
console.log(nurseOlynyk.certifications);
  • Inheritance is when we create a parent class with properties and methods that we can extend to child classes.
  • We use the extends keyword to create a subclass.
  • The super keyword calls the constructor() of a parent class.
  • Static methods are called on the class, but not on instances of the class.

References: https://www.codecademy.com

Javascript classes

Tags

class Surgeon {
  constructor(name, department) {
    this._name = name;
    this._department = department;
    this._remainingVacationDays = 20;
  }
  
  get name() {
    return this._name;
  }
  
  get department() {
    return this._department;
  }
  
  get remainingVacationDays() {
    return this._remainingVacationDays;
  }
  
  takeVacationDays(daysOff) {
    this._remainingVacationDays -= daysOff;
  }
}

const surgeonCurry = new Surgeon('Curry', 'Cardiovascular');
const surgeonDurant = new Surgeon('Durant', 'Orthopedics');

console.log(surgeonCurry.name);
surgeonCurry.takeVacationDays(3);
console.log(surgeonCurry.remainingVacationDays);
  • Classes are templates for objects.
  • Javascript calls a constructor method when we create a new instance of a class.