SSL in DigitalOcean

Goto your server and

openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr



  1.  Generate Key and CSR file for request certificate in hosting by using command
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/ -out /etc/ssl/certs/
  2. Go to control panel which hosting provide SSL and download
  3. Now you will get 2 files are *.key and *.crt
  4. copy file domainName.key to /etc/ssl/private/
  5. copy file domainName.crt to /etc/ssl/certs/ 
  6. modify file default in sudo nano /etc/nginx/sites-available/default as bellow

server {

        listen 80 default_server;

        listen [::]:80 default_server;

        # SSL configuration


        listen 443 ssl http2 default_server;

        listen [::]:443 ssl http2 default_server;


        # Note: You should disable gzip for SSL traffic.

        # See:


        # Read up on ssl_ciphers to ensure a secure configuration.

        # See:


        # Self signed certs generated by the ssl-cert package

        # Don’t use them in a production server!


        # include snippets/snakeoil.conf;

        root /var/www/landing-page;

        # Add index.php to the list if you are using PHP

        index index.html index.htm index.nginx-debian.html;


        #ssl on;

        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers         “HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES”;

        ssl_certificate     /etc/ssl/certs/;

        ssl_certificate_key /etc/ssl/private/;

        location / {

                # First attempt to serve request as file, then

                # as directory, then fall back to displaying a 404.

                try_files $uri $uri/ =404;




server {

       listen         80;


       return         301 https://$server_name$request_uri;




Install Parse Server


  1. Mongodb
  2. Nodejs

    $ curl -sL | sudo -E bash -
    $ sudo apt-get install -y nodejs
  3. Settup Parse Server
  4. Setup Parse Dashboard


var dashboard = new ParseDashboard({

  “apps”: [


      “serverURL”: “”,

      “appId”: “ChindaKey”,

      “masterKey”: “MchindaKey”,

      “appName”: “MyApp”



  users: [{

    user: “admin”,

    pass: “admin”


}, {

  allowInsecureHTTP: true


How To Install Parse Server on Ubuntu 16.04 & 14.04


Auto start pm2 when reboot Windows

install pm2:

$ npm install pm2 -g

install mp2 start for windows

$ npm install pm2-windows-startup -g


install pm2 window service

$ npm i pm2-windows-service -g

$ pm2-service-install [-n <service name>]

and go to this install path: C:\Users\Administrator\AppData\Roaming\npm\node_modules\pm2-windows-service\src\daemon\ and find file

is called “mp2node” and edit at <argument>[js file].js</argument> to path of your javascript file and save and reboot service in “Service.msc”





Install RabbitMQ on Windows


  1. Download rabbitmq at:
  2. Install
  3. Config Manangement
    • Open cmd
    • go to this path: C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.4\sbin
    • input rabbitmq-plugins.bat enable rabbitmq_management and press enter key
    • rabbitmq-service.bat stop
    • rabbitmq-service.bat install
    • rabbitmq-service.bat start
  4. Start use: http://localhost:15672
    • User: guest
    • Password: guest
  5. Crate User:
    • Add a new/fresh user, say user ‘test’ and password ‘test’
      rabbitmqctl add_user test test
    • Give administrative access to the new access
      rabbitmqctl set_user_tags test administrator
    • Set permission to newly created user
      rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
  6. How to allow Guest login via IP
    • C:\Users\[User Name]\AppData\Roaming\RabbitMQ\rabbitmq.config
    • And add: [{rabbit, [{loopback_users, []}]}]. 

Get started with RabbitMQ on Android (Android Studio)

By: LOVISA JOHANSSON (cloudamqp)

This guide explains how to create a simple chat application in Android using Android Studio and RabbitMQ. Everyone that has the application will be able to send and receive messages from all other users that are using the same application.

If you are using Eclipse, check out this blog post instead.

In the code given, messages will first be added to an internal queue and the publisher will send messages from the internal queue to RabbitMQ when there is a connection established. The message will be added back to the queue if the connection is broken.

RabbitMQ Android

This guide assumes that you have downloaded, installed and set up everything correct for Android Studio.

Start by creating a new Android project, open Android Studio and go to File -> New -> New Project..

1. Configure your new project

  1. Enter project information as specified below.create new android project
  2. Select the form factor your app will run onandroid studio
  3. Select if you like to add an activity to your app or not. In this example we choose Blank Activity to get autogenerated files for the project.add android activity
  4. Customize the Activitycustomize android activity

2. Add Java AMQP library to project

RabbitMQ has developed an excellent Java AMQP library. The full API documentation for the library can be found here.

We need to include the RabbitMQ Java Client Library and reference the jar files into the project. In Android Studio you can create a libs folder in the same level as the app. Copy and past the jars in to this libs folder. Mark all the jar files and press “Add As Library…” as seen in the image below.

add rabbitmq library

You can confirm that the libs has been added as library by opening build.gradle and check under dependencies, all files should seen be there.

dependencies {
  compile files('libs/rabbitmq-client.jar')

NOTE: Only if you are using Android Gradle plugin 0.7.0 and do get the error “Duplicate files copied in APK” when you later run your application, you need to add packagingOptions to your build.gradle file as specified in here.

android {
  packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'

3. Android Manifest, internet permission

We need to tell the Android system that this app is allowed to access internet. Open the AndroidManifest.xml file, located in the root of the project. Add the user permission android.permission.INTERNET just before the closing /manifest tag.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
     <uses-permission android:name="android.permission.INTERNET"></uses-permission>

4. Start coding


Create the view for the application. The .xml layout file can be found under res->layout. What we have here is a root ScrollView containing a

EditText a Button and a TextView The EditText will be used as an input field for the text that will be sent. The text will be published when the button is pressed and all messages received by the subscriber will be printed to the TextView.

<ScrollView xmlns:android=""
  android:hint="Enter a message" />

  android:text="Publish message" />

  android:textColor="#000000" />


Create an internal message queue. In this case is a BlockingDeque used. Blockingqueues implementations are designed to be used primarily for producer-consumer queues.

private BlockingDeque<String> queue = new LinkedBlockingDeque>String>();
void publishMessage(String message) {
  try {
    Log.d("","[q] " + message);
  } catch (InterruptedException e) {

Create a setup function for the ConnectionFactory The connection factory encapsulates a set of connection configuration parameters, in this case the CLOUDAMQP_URL. The URL can be found in the control panel for your instance.

ConnectionFactory factory = new ConnectionFactory();
private void setupConnectionFactory() {
  String uri = "IP";
  try {

  } catch (KeyManagementException | NoSuchAlgorithmException | URISyntaxException e1) {

Create a publisher that publish messages from the internal queue. Messages are added back to the queue if an exception is catched. The publisher will try to reconnect every 5 seconds if the connection is broken.

A thread (“background” or “worker” threads or use of the AsyncTask class) is needed when we have operations to perform that are not instantaneous, such as network access when connecting to rabbitMQ.

We will use a fanout exchange. A fanout exchange routes messages to all of the queues that are bound to it and the routing key is ignored. If N queues are bound to a fanout exchange, will a new message that is published to that exchange, be copied and delivered to all N queues. Fanout exchanges are ideal for the broadcast routing of messages.

public void publishToAMQP()
  publishThread = new Thread(new Runnable() {
    public void run() {
      while(true) {
        try {
          Connection connection = factory.newConnection();
          Channel ch = connection.createChannel();

          while (true) {
            String message = queue.takeFirst();
              ch.basicPublish("amq.fanout", "chat", null, message.getBytes());
              Log.d("", "[s] " + message);
            } catch (Exception e){
              Log.d("","[f] " + message);
              throw e;
       } catch (InterruptedException e) {
       } catch (Exception e) {
         Log.d("", "Connection broken: " + e.getClass().getName());
         try {
           Thread.sleep(5000); //sleep and then try again
         } catch (InterruptedException e1) {


We have now created the publisher, and it is time to create the subscriber. The subscriber will take a handler as parameter. The handler will print the messages to the screen when the messages arrives. The subscribe thread will try to reconnect every 5 seconds when the connection gets broken.

void subscribe(final Handler handler)
  subscribeThread = new Thread(new Runnable() {
    public void run() {
      while(true) {
        try {
          Connection connection = factory.newConnection();
          Channel channel = connection.createChannel();
          DeclareOk q = channel.queueDeclare();
          channel.queueBind(q.getQueue(), "amq.fanout", "chat");
          QueueingConsumer consumer = new QueueingConsumer(channel);
          channel.basicConsume(q.getQueue(), true, consumer);

          while (true) {
            QueueingConsumer.Delivery delivery = consumer.nextDelivery();
            String message = new String(delivery.getBody());
            Log.d("","[r] " + message);
            Message msg = handler.obtainMessage();
            Bundle bundle = new Bundle();
            bundle.putString("msg", message);
        } catch (InterruptedException e) {
        } catch (Exception e1) {
          Log.d("", "Connection broken: " + e1.getClass().getName());
          try {
            Thread.sleep(5000); //sleep and then try again
          } catch (InterruptedException e) {

Call all functions listed above from function onCreate The handler used by the subscribe functions is also created in onCreate. A handler has to be used because it is only possible to write to the GUI from the main tread.

public void onCreate(Bundle savedInstanceState) {


  final Handler incomingMessageHandler = new Handler() {
    public void handleMessage(Message msg) {
      String message = msg.getData().getString("msg");
      TextView tv = (TextView) findViewById(;
      Date now = new Date();
      SimpleDateFormat ft = new SimpleDateFormat ("hh:mm:ss");
      tv.append(ft.format(now) + ' ' + message + '\n');

void setupPubButton() {
  Button button = (Button) findViewById(;
  button.setOnClickListener(new OnClickListener() {
    public void onClick(View arg0) {
      EditText et = (EditText) findViewById(;

The subscribe and the publish tread can both be interrupted when the application is destroyed by adding following code in onDestroy

Thread subscribeThread;
Thread publishThread;
protected void onDestroy() {


Copy from:

How to enable GZip compression in XAMPP server

By: TarranJones

When we test our webiste by and we get error:

The following publicly cacheable, compressible resources should have a “Vary: Accept-Encoding” header


Find apache\conf\httpd.conf

uncomment the following line(remove #)

LoadModule headers_module modules/

some versions may require you to comment out the following lines instead.

LoadModule headers_module modules/
LoadModule deflate_module modules/

finally add this line to your .htaccess file.

SetOutputFilter DEFLATE

Copy from: