Install Python 3.7 on CentOS 7

Posted on 1 year ago by Ping Cheng

CentOS series natively comes with Python 2 installed, since there are some system level parts are depending on python 2, it is not safe and easily to replace python 2 with python 3.

Therefore, this article would express install python with altinstall.

Step 1 Install dependency

yum install gcc openssl-devel bzip2-devel libffi-devel wget

Step 2 Download Python 3 source code

cd ~
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
tar xzf Python-3.7.2.tgz

Step 3 Install

cd Python-3.7.2.tgz
./configure --enable-optimizations
make altinstall

Note, if you encountered some error message such as no permission, please use sudo.

Verify

python3.7 -V
Python 3.7.2

python -V
Python 2.7.5

Create new swap file on CentOS 7 / RHEL 7

Posted on 1 year ago by Ping Cheng

Shared from https://sharadchhetri.com/2014/12/01/create-new-swap-file-centos-7-rhel-7/

In this tutorial we will learn how to create new swap file on CentOS 7 / RHEL 7. Generally on Cloud Servers ( AWS/ DigitalOcean) or VPS, swap space is not created by default. This requirement we can achieve within a few steps.

Prerequisites

Must have free space on mounted disk. You can check by using df -Th command.

Steps to create / add new swap file on Linux

1. Create swapfile-additional file with dd command in / (root). You can select any other partition but it should be mounted (For eg. /opt, /usr ,/NewMountedPartition)

dd if=/dev/zero of=/swapfile-additional bs=1M count=4048

dd = It is a unix command used for convert and copy a file
if = read from FILE instead of stdin
/dev/zero = /dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it
of = write to FILE instead of

...

[ Read More ]


Validate slack slash commands via signing secret

Posted on 2 years ago by Ping Cheng

Here is a gist for validating the slack slash command via the slack signing secret.

The sample is for Laravel middleware. Since the validation process is written below, you can modify to suit your project.

GitHub gist: https://gist.github.com/pingcheng/f7500adf1b1009df3ed341f511305b0d


<?php

namespace App\Http\Middleware;
use Exception;
use Carbon\Carbon;
use Closure;
use Illuminate\Support\Facades\Log;

class SlackRequest
{
    /**
     * Validate a slack request
     * by the slack signing secret (not the token)
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     *
     * @return mixed
     * @throws Exception
     */
    public function handle($request, Closure $next)
    {
        // define the version number
        $version = 'v0';

        // load the secret, you also can load it from env(YOUR_OWN_SLACK_SECRET)
        $secret = config('services.slack.signing_secret');

        //

...

[ Read More ]

Search
Hand crafted with by Ping Cheng