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 ***




Run two or more dropbox accounts in your PC
If you have compiled dropbox in your home from tar.gz file ->

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


How to import your GPG keys using GNU Private Assistant


, ,

Download and install the gpg for windows at
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. then a password dialog box will appear.
You will enter the password of your gpg. That’s it!

More info at

Named exports/Name imports, export default



// 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['fuelCapacity']);


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


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


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


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) {
    this._certifications = certifications;
  get certifications() {
    return this._certifications;
  addCertification(newCertification) {

const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
  • 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.


Javascript classes


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');

  • Classes are templates for objects.
  • Javascript calls a constructor method when we create a new instance of a class.

PostgreSQL: How to create user in PostgreSQL


root@27a0239d18d7:/# psql -U postgres
postgres=# CREATE USER johndoe WITH PASSWORD ‘123456’;
postgres=# ALTER USER johndoe WITH SUPERUSER;
postgres=# GRANT ALL PRIVILEGES ON DATABASE “yourDatabaseName” to johndoe;
Make sure that you assign the user to SUPERUSER else you will encounter an error that says PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations…

To test it out do this..
root@27a0239d18d7:/# psql -h localhost -d “yourDatabaseName” -U johndoe -W

Linux/Ubuntu: How to use grep and find command


, , ,

How to use grep to find text including sub directories:
grep -rl {yoursearchstring} {pathtosearch} e.g.,

$ grep -rl "hello" /var/
/var/log/test.log:1:hello world

-r or –recursive – is used to traverse also all sub-directories of /path
l or –files-with-matches – used to only print filenames of matching files, and not the matching lines (this could also improve the speed, given that grep stop reading a file at first match with this option).

Another way to search that will return the line matching files.

$ grep -Hrn "hello" /var/
/var/lib/dpkg/status-old:10:hello world
/var/lib/dpkg/status:13:hello world
/var/log/test.log:1:hello world

How to find/search a specific file from a directory:
find {directory} -iname {searchstring}
iname – search by search string (case insensitive )

$ find rails-blog-heroku/ -iname *.bak

How to delete a files from find search results:
Search all the bak files and delete it.
$ find rails-blog-heroku/ -iname *.bak | xargs rm

OpenShift v3 tips


Tips on how to deploy your web app in Openshift v3
If you have a code changes then we need to build it again.
Click Builds menu => click {projectname} => click Start build button

If you got an error that says “quota limited”.
To fix that we need to stop all pods.

How to access your mysql in Openshift v3
$ oc login {endpoint} e.g. oc login
$ oc project {projectname}
$ oc status -v — get the status of the project
$ oc get pods — get all the running pods
$ oc rsh {podname} e.g. oc rsh mysql-a24de
$ mysql -h -u $MYSQL_USER -D $MYSQL_DATABASE -p

How to import mysql database(schema.sql) in Openshift v3 with running MySQL datastore ?
$ oc login {endpoint} e.g. oc login
$ oc project {projectname}
$ oc get pods

php-17-build 1/1 Running 0 16h
mysql-1-f4g6p 1/1 Running 0 16h

$ oc rsh {podname}
$ oc rsh mysql-1-f4g6p

So we are now inside the mysql pod…
The current directory / and /home don’t have a write permission. Luckily, the /var/tmp has a write permission.
sh-4.2 $ cd /var/tmp
sh-4.2 $ curl -k -o downloaded.sql
sh-4.2 $ mysql -h -u $MYSQL_USER -D $MYSQL_DATABASE -p < downloaded.sql


Reactjs: Unexpected token <



If you’ve encounter an error that says Unexpected token and it points to < character E.g:

ERROR in ./src/index.js
Module build failed: SyntaxError: C:/_react/react-post/src/index.js: 
Unexpected token (11:17)
> 11 |  ReactDOM.render(<div>Hello world</div>, document.getElementById('root'))

Check your package.json if you have babel-preset-react. If none then we need to install it.
npm install –save-dev babel-preset-react
Next in your .babelrc, we need to add the “react” preset. E.g.

  "presets":[ "es2015", "react" ]