Nodejs MySQL and Handlebars boilerplate

Node.js boilerplate with express, helmet, cors, xss-protection, mysql, session, cookie and express-handlebars view engine and many more..

Well structured Node.js app. It uses mysql as database and express-handlebars as template and jest test package. It has bootstrap 4 integrated.
Only two urls added for example * / for all users, * /my for all logged in user.

Folder Structure

Download or Clone it from github

Arduino with HC-SR04 Ultra Sonic sensor

Working with Arduino is super fun and it becomes more exciting when you use HC-SR04 Ultra Sonic sensor.

The sensor uses non-contact ultrasound sonar to measure the distance of an object, and consists of two ultrasonic transmitters (speakers), a receiver, and a control circuit. It emits ultrasound at 40k Hz which travels through the air and if there is an object or obstacle on its path it will bounce back to the receiver.


I buy all stuff from this site https://bdspeedytech.com/

My breadboard is super simple. I have a LED that will turn HIGH when anything between 30cm to 60cm in the sensor. You can adjust this value as you need.

Download the sketch file



#define DIG_TRIG_PIN 10
#define DIG_ECHO_PIN 11
#define LED_PIN 13

float duration, distanceInCM;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(DIG_TRIG_PIN, OUTPUT);
  pinMode(DIG_ECHO_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:

  digitalWrite(LED_PIN, LOW);
  digitalWrite(DIG_TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(DIG_TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(DIG_TRIG_PIN, LOW);
  
  duration = pulseIn(DIG_ECHO_PIN, HIGH);

  // Determine distance from duration
  // Use 343 meters per second as speed of sound
  float speedOfSoundInCM = 0.0343;
  int roundTrip = 2;
  distanceInCM = (duration / roundTrip) * speedOfSoundInCM; 

  Serial.print("Distance = ");
  if (distanceInCM >= 400 || distanceInCM <= 2) {
    Serial.print("Out of range");
  } else if (distanceInCM >= 30 && distanceInCM <= 60) {
    digitalWrite(LED_PIN, HIGH);
  } else {
    Serial.print(distanceInCM);
    Serial.println(" cm ");
    delay(500);
  }


  delay(500);

}

Here is a video clip.

For video editing I use DaVinci Resolve 16

Install PHP 5.6 on macOS Catalina

These steps worked on my Mac, Catalina version 10.15.3 (19D76).

Step 1: Tap deprecated brew formula

brew tap exolnet/homebrew-deprecated

Step 2: Install PHP 5.6

brew install [email protected]

You can also have PHP 7.2 just run 

brew install [email protected]

Step 3: Install PHP switcher script to switch between 5.6 and 7.2

$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp 
$ chmod +x /usr/local/bin/sphp

If you run sphp 7.2 it should work but running sphp 5.6 will not work and will show error like this from apache.

Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylibn  Referenced from: /usr/local/opt/[email protected]/lib/httpd/modules/libphp5.son  Reason: image not found

Unless we switch openssl version, it wont work. So we have to install old openssl

Step 4: Install old openssl

brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

Step 5: Switch to openssl 1.0

brew switch openssl 1.0.2t

Now you switch to PHP 5.6 by 

sphp 5.6

Everything works.

You can run these commands to check which version of openssl is being used in your mac.

brew info openssl and brew info openssh