Install Dingtalk Desktop App on Ubuntu

Dingtalk download: https://www.dingtalk.com/download#/
Choose Linux -> amd64

the downloaded file should be this name: com.alibabainc.dingtalk_7.6.45.5062501_amd64

Install it with this command:
sudo apt install –fix-missing ./com.alibabainc.dingtalk_7.6.45.5062501_amd64.deb -y

To login the desktop app, you have to have the Dingtalk app on your Android/IOS phone. Because you need to scan the QR code from your phone Dingtalk app to login the desktop app.

Dingtalk web: https://oa.dingtalk.com/index.htm#/welcome

Web login: https://login.dingtalk.com/oauth2/challenge.htm?redirect_uri=https%3A%2F%2Foa.dingtalk.com%2Fomp%2Flogin%2Fdingtalk_sso_call_back%3Fcontinue%3Dhttps%253A%252F%252Foa.dingtalk.com%252Findex.htm&response_type=code&client_id=dingoaltcsv4vlgoefhpec&scope=openid+corpid&org_type=management#/login

Install PHP with MacPorts on Mac Big Sur

Install MacPorts based on your mac version.
pls see https://www.macports.org/install.php

if you have already MacPorts, pls update/upgrade it:

Install PHP7.4
read: https://ports.macports.org/port/php74/

run: sudo port install php74
install some php7.4 extension: sudo port install php74-apache2handler php74-cgi php74-gd php74-curl php74-intl php74-iconv php74-gettext php74-mbstring php74-imap php74-mcrypt php74-xmlrpc php74-mysql php74-openssl php74-sockets php74-zip php74-tidy php74-opcache php74-xsl php74-sqlite php74-xdebug

Select php74 as the active PHP version:
sudo port select php php74

check:
php -v
PHP 7.4.33 (cli) (built: Oct 13 2024 09:21:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
with Xdebug v3.1.6, Copyright (c) 2002-2022, by Derick Rethans

Install Apache2
check apache2: (the default apache2 from mac)
[codesyntax lang=”bash”]

[/codesyntax]

read: https://trac.macports.org/wiki/howto/Apache2

verify the config file:
[codesyntax lang=”bash”]

[/codesyntax]

Activate apache2 :
sudo port load apache2

to remove the warning:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using Satrias-MacBook-Pro.local. Set the ‘ServerName’ directive globally to suppress this message
edit /opt/local/etc/apache2/httpd.conf –> should use admin to edit it
Open geany as admin via command line: sudo “/Applications/Geany.app/Contents/MacOS/geany”
then add this line:
ServerName localhost:80
then unload and load again apache2:
sudo port unload apache2
sudo port load apache2
then
[codesyntax lang=”bash”]

[/codesyntax]

Test it on the browser: http://localhost/ –> it should work

Link PHP7.4 with apache2
read: https://trac.macports.org/wiki/howto/MAMP
Go to this dir:
cd /opt/local/lib/apache2/modules
then run:
[codesyntax lang=”bash”]

[/codesyntax]

then modify /opt/local/etc/apache2/httpd.conf, so it’ll be:
DirectoryIndex index.php index.html

 

Install ERPNext/Frappe on Ubuntu 22.04

Read: https://docs.frappe.io/framework/user/en/installation#debian-ubuntu

Update your system’s package index

if not exist, Install/update gitpython, and redis

Check:

Now, edit the MariaDB configuration file (this step is not required for Frappe v15.21.0 or above).

And add this configuration

Now, just restart the MariaDB service and you are good to go.

Check Node or Install Node if not exist

Use node > 18. use the stable version (v20..) instead

Check:

Finally, check/install yarn using npm

Install the libraries for wkhtmltopdf

Download and install wkhtmltopdf package from https://wkhtmltopdf.org/downloads.html, then run this command to install the package. As an example for Ubuntu 22.04 amd64 in Download directory

if you found this error: Package xfonts-75dpi is not installed. then run this to install the dependencies

Install Bench CLI
Install bench via pip (or pip3)
[codesyntax lang=”bash”]

[/codesyntax]

Note: WARNING: The script bench is installed in ‘/home/satria/.local/bin’ which is not on PATH.
So run –> THIS IS NOT SAVED BECAUSE WHEN I TRIED TO LOGIN AGAIN, THE PATH IS MISSING
[codesyntax lang=”bash”]

[/codesyntax]

 

Check ‘Bench’ version
[codesyntax lang=”bash”]

[/codesyntax]

Read: https://docs.frappe.io/framework/user/en/tutorial/install-and-setup-bench
Create frappe-bench directory
Let’s create our project folder which will contain our apps and sites. Run the following command: bench init frappe-bench in my projects directory
[codesyntax lang=”bash”]

[/codesyntax]
Note: make sure to use node > = v18…

Let’s fix the installation problem:
1. [codesyntax lang=”bash”]

[/codesyntax]
pls go to ‘apps/frappe’ directory (here is the complete path: /home/satria/Documents/projects/frappe-bench/apps/frappe) then run ‘npx update-browserslist-db@latest’
[codesyntax lang=”bash”]

[/codesyntax]
2. WARN Cannot connect to redis_cache to update assets_json

the redis service is running:
sudo systemctl status redis
[sudo] password for satria:
● redis-server.service – Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor >
Active: active (running) since Wed 2025-05-14 13:49:23 WIB; 16min ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 1390 (redis-server)
Status: “Ready to accept connections”
Tasks: 5 (limit: 57560)
Memory: 5.2M
CPU: 1.714s
CGroup: /system.slice/redis-server.service
└─1390 “/usr/bin/redis-server 127.0.0.1:6379” “” “” “” “” “” “” “”>

Mei 14 13:49:23 teddy systemd[1]: Starting Advanced key-value store…
Mei 14 13:49:23 teddy systemd[1]: Started Advanced key-value store.

here is the content of sites/common_site_config.json:
{
“background_workers”: 1,
“file_watcher_port”: 6787,
“frappe_user”: “satria”,
“gunicorn_workers”: 17,
“live_reload”: true,
“rebase_on_pull”: false,
“redis_cache”: “redis://127.0.0.1:13000”,
“redis_queue”: “redis://127.0.0.1:11000”,
“redis_socketio”: “redis://127.0.0.1:13000”,
“restart_supervisor_on_update”: false,
“restart_systemd_on_update”: false,
“serve_default_site”: true,
“shallow_clone”: true,
“socketio_port”: 9000,
“use_redis_auth”: false,
“webserver_port”: 8000
}

SO the redis server used PORT 13000 instead of PORT 6379. CHANGED THE PORT FOR redis_cache, redis_queue and redis_socketio to port 6379 in sites/common_site_config.json. So now the content is:
[codesyntax lang=”text”]

[/codesyntax]

Test the redis server for 6379 port
[codesyntax lang=”bash”]

[/codesyntax]

Start the Bench Server
Now that we have created our frappe-bench directory, we can start the Frappe web server by running the following command: bench start

[codesyntax lang=”bash”]

[/codesyntax]

Note: Type CTRL+C to stop the bench engine

It can be opened on http://127.0.0.1:8000/ or http://192.168.1.23:8000
but the app still empty!

So Create an App
Read: https://docs.frappe.io/framework/user/en/tutorial/create-an-app
Case study: Library Management System

To create our Library Management app, run the new-app command:

You should get some prompts, and output like the following. You can enter information manually, or press enter to select the defaults

[codesyntax lang=”bash”]

[/codesyntax]

You will be prompted with details of your app, fill them up and an app named library_management will be created in the apps folder.

Create A Site
Read: https://docs.frappe.io/framework/user/en/tutorial/create-a-site

Run : bench new-site library.localhost
[codesyntax lang=”bash”]

[/codesyntax]
the admin password is Teddy@123

This command will create a new database, so you need to enter your MariaDB root password. It will also ask to set the password for the Administrator user, just set a password that you won’t forget. This will be useful later.

Now, you will have a new folder named library.localhost in the sites directory.

If site creation fails for any reason, you’ll be prompted to roll back the changes. This will delete the library.localhost or equivalent in your sites directory, and delete the database/user that was created. This will allow you to easily retry without having to manually cleanup the unusable site.

the new database (_5b0e23f4238e31a0), user and password can be seen in sites/library.localhost/site_config.json

Now you can open the site http://library.localhost:8000/ on your browser
Note: make sure to run ‘bench start’ first in the frappe-bench directory

The login page will be displayed:
username: Administrator
password: Teddy@123
This user also can be found in the database (tabUser table)

Then install app on site
[codesyntax lang=”bash”]

[/codesyntax]

To confirm if the app was installed, run the following command:
[codesyntax lang=”bash”]

[/codesyntax]

then run ‘bench start’ again!

I found some glitch on the frontend.
for example on http://library.localhost:8000/login, i found these errors related to css on the console:
Failed to load resource: the server responded with a status of 404 (NOT FOUND) -> http://library.localhost:8000/assets/frappe/dist/css/login.bundle.O2AXXQ4F.css
I can’t find the file but I found this file:
sites/assets/frappe/dist/css/login.bundle.M242FIII.css
–> NEED TO RESTART bench server (stop bench then run again bench start). then refresh the browser

but after the login, i found another frontend glitch:
GET http://library.localhost:8000/assets/frappe/dist/css/desk.bundle.5EPJH5Z3.css net::ERR_ABORTED 404 (NOT FOUND) -> http://library.localhost:8000/assets/frappe/dist/css/desk.bundle.5EPJH5Z3.css

GET http://library.localhost:8000/assets/frappe/dist/css/report.bundle.7F2GVCHL.css net::ERR_ABORTED 404 (NOT FOUND) -> http://library.localhost:8000/assets/frappe/dist/css/report.bundle.7F2GVCHL.css

–> READ THE WARNING MESSAGE:
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect. –> So fix it as requested! then restart bench (bench start)
Open http://library.localhost:8000/app/ -> should be working and run the app install wizard
email: advcha@yahoo.com
pass: Teddy@123

Create a DocType
Read: https://docs.frappe.io/framework/user/en/tutorial/create-a-doctype
DocType is analogous to a Model in other frameworks. Apart from defining properties, it also defines the behavior of the Model.

Enable Developer Mode
Before we can create DocTypes, we need to enable developer mode on our bench. This will enable boilerplate creation when we create doctypes and we can track them into version control with our app.

Go to your terminal and quit the bench server if it’s already running then from the frappe-bench directory, run the following command:

Creating a DocType

While in Desk, navigate to the DocType List using the Awesomebar. This list will include DocTypes bundled with the framework, those that are a part of the installed Frappe apps and custom ones, which you can create specific to each site.

The first doctype we will create is Article. To create it, click on New.
-> http://library.localhost:8000/app/doctype/view/list then click ‘+Add DocType’ button on the top right

  1. Enter Name as Article
  2. Select Library Management in Module

Then click ‘Create & Continue’ button
then Go to http://library.localhost:8000/app/doctype
then select ‘Article’

  1. Add the following fields in the Fields table: (Better use ‘Form’ tab)
    1. Article Name (Data, Mandatory)
    2. Image (Attach Image)
    3. Author (Data)
    4. Description (Text Editor)
    5. ISBN (Data)
    6. Status (Select) – Enter two options: Issued and Available (Type Issued, hit enter, then type Available)
    7. Publisher (Data)

Refer the following images to check how it should be done:
Form tab

Naming tab

Setting tab

Field tab (usually populated from the Form tab entries)

After adding the fields, click on Save.

You will see a Go to Article List button at the top right of the form. Click on it to go to the Article List. Here you will see a blank list with no records because the table has no records.

Let’s create some records. But before that, we need to clear the Desk cache. Click on the Settings dropdown on the right side of the navbar and click on Reload.

Click ‘Go to Article List’ button (http://library.localhost:8000/app/article)
then click ‘Add Article’ button

The github gave me much headeache
[codesyntax lang=”bash”]

[/codesyntax]

Local Install Typo3 Version 12

Download the file on https://get.typo3.org/version/12 (Typo3 Version 12.4.28). I downloaded the .tar.gz file
Uncompress the downloaded file then move to the web root and rename to ‘typo3-12.4.28’

CREATE LOCAL SETUP

CREATE A CONF

CONTENT

ENABLE THE VIRTUALHOST

RELOAD APACHE2

CREATE THE HOST

RELOAD APACHE2 AGAIN

SET THE FILE PERMISSION

ALSO MODIFY FILE _.htaccess TO .htaccess

OPEN: http://typo3-12.4.28.test/
INSTALL
FOR THE FIRST INSTALL, CREATE A NEW FILE WITH NAME ‘FIRST_INSTALL’ IN THE TYPO3 ROOT. SO THE FILE PATH WOULD BE LIKE THIS: ~/Documents/projects/typo3-12.4.28/FIRST_INSTALL
CREATE A NEW DATABASE ‘typo3_12_4_28’

http://typo3-12.4.28.test/typo3
ADMIN
user: admin
pass: Teddy@123

FIRST OPEN http://typo3-12.4.28.test/, I GOT THIS ERROR

ALSO ON THE ADMIN PAGE (LOG)
SOLUTION:
THAT’S BECAUSE I HAVEN’T INSTALLED ANY DISTRIBUTION PACKAGES. ON THE INSTALLATION, I CHOOSE EMPTY PACKAGE!
READ: https://hostarmada.com/tutorials/blog-cms/typo3/how-to-troubleshoot-the-no-pages-are-found-on-the-rootlevel-error-after-initial-typo3-installation/
SO I NEED TO INSTALL THE OFFICIAL DISTRIBUTION PACKAGE JUST TO SHOW ANY DATA ON THE WEBSITE
OPEN AGAIN: http://typo3-12.4.28.test/
NOW SHOULD BE NO ERROR

Install Ollama and DeepSeek On Ubuntu 22.04

Ref: https://ollama.com/download

Select the linux then Install on your terminal with this command:
curl -fsSL https://ollama.com/install.sh | sh

[codesyntax lang=”bash”]

[/codesyntax]

on the search model text box, select ‘deepseek-r1’ or go to https://ollama.com/library/deepseek-r1
Okay. I just choose ‘1.5b’ model as a test. then install it on your terminal with this command:
ollama run deepseek-r1:1.5b

[codesyntax lang=”bash”]

[/codesyntax]

Integrate it with VSCode:
Watch : https://www.youtube.com/watch?v=cqFRE9c8048&ab_channel=ChaooCharles

the problem:
1. it’ll take your disk space. For just 1.5b model, it’ll take 1.1 GB disk space
2. If you don’t have GPU, it’ll use your CPU resource and it took 100% CPU resources on my Ubuntu machine
You can stop and disable the ollama services on your machine
[codesyntax lang=”bash”]

[/codesyntax]

Install osTicket

Ref: https://www.rosehosting.com/blog/how-to-install-osticket-on-ubuntu-22-04/

Download

Install osTicket 1.10

LOCAL SETUP (I uses PHP 7.4)

I tried to setup a virtualhost:

sudo gedit /etc/apache2/sites-available/osticket-v1.10.test.conf

Here is the file osticket-v1.10.test.conf:

[codesyntax lang=”text”]

[/codesyntax]

activate it:

sudo a2ensite osticket-v1.10.test

Restart/reload the server:

sudo systemctl reload apache2

Insert osticket-v1.10.test in my local host:

sudo gedit /etc/hosts

Here is the entry that need to be put in:

127.0.0.1 osticket-v1.10.test

Restart/reload the server:

sudo systemctl reload apache2

Change the files & dir permission:
satria@teddy:~/Documents/projects/osticket-v1.10$ sudo chmod -R 777 .

I need to install some php 7.4 extensions missing:
sudo apt install php7.4-imap && sudo apt install php7.4-apcu

Now the site is http://osticket-v1.10.test
SETUP:
rename/copy
from:
/home/satria/Documents/projects/osticket-v1.10/upload/include/ost-sampleconfig.php
to:
/home/satria/Documents/projects/osticket-v1.10/upload/include/ost-config.php

create a new database : osticket_110

set user account
username: adminOT
password: adminOT

after the successful installation:
satria@teddy:~/Documents/projects/osticket-v1.10$ sudo chmod 0644 upload/include/ost-config.php

Your osTicket URL:
http://osticket-v1.10.test/

Your Staff Control Panel or admin:
http://osticket-v1.10.test/scp

after the admin login, I got ‘Valid CSRF Token Required’
SOLUTION:
REF: https://stackoverflow.com/questions/41542268/valid-csrf-token-required-in-osticket-after-login
in include/class.ostsession.php

Just add this line:

$this->data->session_data = “”;
After:

catch (DoesNotExist $e) {
$this->data = new SessionData([‘session_id’ => $id]);
}

So it will be:

catch (DoesNotExist $e) {
$this->data = new SessionData([‘session_id’ => $id]);
$this->data->session_data = “”;
}

Then try to login from scratch, don’t just refresh the submission.

Install osTicket 1.18.1

LOCAL SETUP (I uses PHP 8.2)
[codesyntax lang=”bash”]

[/codesyntax]

I tried to setup a virtualhost:

sudo gedit /etc/apache2/sites-available/osticket-v1.18.1.test.conf

Here is the file osticket-v1.18.1.test.conf:

[codesyntax lang=”text”]

[/codesyntax]

activate it:

sudo a2ensite osticket-v1.18.1.test

Restart/reload the server:

sudo systemctl reload apache2

Insert osticket-v1.18.1.test in my local host:

sudo gedit /etc/hosts

Here is the entry that need to be put in:

127.0.0.1 osticket-v1.18.1.test

Restart/reload the server:

sudo systemctl reload apache2

Change the files & dir permission:
satria@teddy:~/Documents/projects/osticket-v1.18.1$ sudo chmod -R 777 .

I need to install some php 8.2 extensions missing (if not exist):
sudo apt install php8.2-imap && sudo apt install php8.2-apcu

Now the site is http://osticket-v1.18.1.test
SETUP:
rename/copy
from:
/home/satria/Documents/projects/osticket-v1.18.1/osticket-v1.18.1/upload/include/ost-sampleconfig.php
to:
/home/satria/Documents/projects/osticket-v1.18.1/osticket-v1.18.1/upload/include/ost-config.php

create a new database : osticket_1181

set user account
username: adminOT
password: adminOT

after the successful installation:
satria@teddy:~/Documents/projects/osticket-v1.18.1/osticket-v1.18.1/$ sudo chmod 0644 upload/include/ost-config.php

Your osTicket URL:
http://osticket-v1.18.1.test/

Your Staff Control Panel or admin:
http://osticket-v1.18.1.test/scp

THE EMAIL SETTING:

configure emails setting (http://osticket-v1.18.1.test/scp/emails.php)
Note: Create a few emails alias for satria@advchaweb.com on the hostinger like osticket1@advchaweb.com, osticket2@advchaweb.com, osticket3@advchaweb.com

Create a new email ->

Account Tab:
Email Address: osticket1@advchaweb.com
Email Name: osticket1@advchaweb.com
Department:
Priority: Normal
Help Topic:
Auto Response: (unchecked)

Remote Mailbox Tab:
Mailbox Setting:
Hostname: imap.hostinger.com
Port Number: 993
Mail Folder: INBOX
Protocol: IMAP
Authentication: Basic Authentication -> Click ‘Config’ button
–>
Email Address: satria@advchaweb.com
password: +PL5x8mQ

Email Fetching:
Status: Enable  –> to fetch the incoming email
Fetch Frequency: 15 minutes
Emails Per Fetch: 50
Fetched Emails: Archive – move to folder -> 2023OstFetched

Outgoing (SMTP) Tab:
Status: Enable –> MUST BE
Hostname: smtp.hostinger.com –> NO. USE THE smtp-relay.brevo.com SETTING BELOW
Port Number: 465
Authentication: Same as Remote Mailbox
Header Spoofing: (checked) Allow for this email

SORRY, ONLY ADMIN CAN SHOW THIS!

Create a Login App with ASP.NET on Ubuntu 22.04

Here’s a step-by-step guide to create a simple login form using ASP.NET Core (C#) and MS SQL Server with VS Code and Linux:

  1. Install .NET SDK If you haven’t already, install the .NET SDK for your Linux distribution. You can find instructions on the official Microsoft website.check your dotnet version
    [codesyntax lang=”bash”]

    [/codesyntax]
  2. Create a new ASP.NET Core project Open a terminal and run:

    [codesyntax lang=”bash”]

    [/codesyntax]

    Go to the project directory ‘LoginApp’ with ‘cd LoginApp’

  3. Install required NuGet packages Run the following commands:
    [codesyntax lang=”bash”]

    [/codesyntax]

    Make sure the version is match in LoginApp.csproj
    [codesyntax lang=”csharp”]

    [/codesyntax]

  4. Set up the database connection Open appsettings.json and add the connection string:
    [codesyntax lang=”text”]

    [/codesyntax]
    Note: I need to add ‘TrustServerCertificate=True;’

  5. Create ApplicationDbContext Create a new file ApplicationDbContext.cs
    [codesyntax lang=”csharp”]

    [/codesyntax]

  6. Update Program.cs Replace the content of Program.cs:
    [codesyntax lang=”csharp”]

    [/codesyntax]

  7. Create Login Model Create Models/LoginModel.cs:
    [codesyntax lang=”csharp”]

    [/codesyntax]

  8. Create Account Controller Create Controllers/AccountController.cs:
    [codesyntax lang=”csharp”]

    [/codesyntax]

  9. Create Login View Create Views/Account/Login.cshtml:
    [codesyntax lang=”html4strict”]

    [/codesyntax]

  10. Set up the database. Create a new database ‘LoginApp’
  11. Add a test user Create DbInitializer.cs:
    [codesyntax lang=”csharp”]

    [/codesyntax]
    Note: it’ll create a new dummy user with
    email: admin@example.com
    password: Admin123!

  12. Run the application Execute:

  13. Navigate to http://localhost:5000/Account/Login in your browser.
  14. create some navigation menus (login, logout, etc) on the homepage
    Create a new file called _NavBar.cshtml in the Views/Shared folder with the following content:
    [codesyntax lang=”html4strict”]

    [/codesyntax]

    Now, let’s include this partial view in your layout file. Open the Views/Shared/_Layout.cshtml file and add the following line just after the opening <body> tag:
    [codesyntax lang=”html4strict”]

    [/codesyntax]
    Note: I need to remove the default <header> tag to use the new partial navbar

  15. create controller for account logout
    modify Controllers/AccountController.cs
    [codesyntax lang=”csharp”]

    [/codesyntax]

    Now, let’s update the _NavBar.cshtml partial view to use a form for the logout action, as it should be a POST request. Update the logout link in the _NavBar.cshtml file like this:
    [codesyntax lang=”html4strict”]


    [/codesyntax]
    at the end of this file, add this javascript
    [codesyntax lang=”html4strict”]

    [/codesyntax]
  16. Add controller for registration and forgot password?

Install Microsoft SQL Server 2022 On Ubuntu 22.04

Ref: https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver16&tabs=ubuntu2204

1. Update and upgrade the packages on ubuntu 22.04
[codesyntax lang=”bash”]

[/codesyntax]

2. Download the public key, convert from ASCII to GPG format, and write it to the required location:
[codesyntax lang=”bash”]

[/codesyntax]

3. Manually download and register the SQL Server Ubuntu repository:
[codesyntax lang=”bash”]

[/codesyntax]

4. Run the following commands to install SQL Server:
[codesyntax lang=”bash”]

[/codesyntax]

5. After the package installation finishes, run mssql-conf setup and follow the prompts to set the sa password and choose your edition.
Just choose ‘Developer’ version. type 2. My local sa password is {my-nick-name-first-uppercase}@123
[codesyntax lang=”bash”]

[/codesyntax]

6. Once the configuration is done, verify that the service is running:
[codesyntax lang=”bash”]

[/codesyntax]

Install the SQL Server command-line tools (sqlcmd)

1. Import the public repository GPG keys.
[codesyntax lang=”bash”]

[/codesyntax]

2. Register the Microsoft Ubuntu repository. For Ubuntu 22.04, use the following command:
[codesyntax lang=”bash”]

[/codesyntax]

3. Update the sources list and run the installation command with the unixODBC developer package.
[codesyntax lang=”bash”]

[/codesyntax]

To update to the latest version of mssql-tools, run the following commands:
[codesyntax lang=”bash”]

[/codesyntax]

4. Add /opt/mssql-tools18/bin/ to your PATH environment variable in a bash shell.

To make sqlcmd and bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
[codesyntax lang=”bash”]

[/codesyntax]

5. Test sqlcmd with ‘sqlcmd -?’
[codesyntax lang=”bash”]

[/codesyntax]

Connect locally. I tried to use : sqlcmd -S localhost -U sa -P your_password
but it showed up this error
[codesyntax lang=”bash”]

[/codesyntax]

it turned out I need to add -C parameter at the end like this
[codesyntax lang=”bash”]

[/codesyntax]

Create a new database

For example create a new database TestDB from sqlcmd
[codesyntax lang=”bash”]

[/codesyntax]

Create a new table dbo.Inventory and Insert data
[codesyntax lang=”bash”]

[/codesyntax]

Install DBeaver (https://dbeaver.io/)
This is Database GUI for many databases including MS SQL Server

Download it https://dbeaver.io/download/
I used Ubuntu PPA
[codesyntax lang=”bash”]

[/codesyntax]

Open DBeaver CE and select to the MS SQL Server

Connect to the MS SQL Server but it needs to use JDBC driver. Install it directly from the DBeaver

If everything is okay, it’ll look like this

on the DBeaver GUI you can add a new row. for example add a new row
ID: 3
Name: Apple
Quantity: 158
Then save

on the sqlcmd should reflect the changes
[codesyntax lang=”bash”]

[/codesyntax]

Python and Streamlit on Ubuntu 22.04

Check the installed python

satria@teddy:~$ pip -V
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

it seems I already installed python 3. but when I want to find out the location with ‘whereis python’, it showed up nothing

satria@teddy:~$ whereis python
python:

so use ‘whereis python3’ instead

satria@teddy:~$ whereis python3
python3: /usr/bin/python3 /usr/lib/python3 /etc/python3 /usr/share/python3 /usr/share/man/man1/python3.1.gz

I need to symlink python 3 to use just ‘python’ like this
satria@teddy:~$ sudo ln -s /usr/bin/python3 /usr/bin/python

then I can use like this
satria@teddy:~$ whereis python
python: /usr/bin/python

Install streamlit with python3 virtual environment (venv)
ref: https://docs.streamlit.io/get-started/installation/command-line

create a new directory.  for  example ‘streamlit’
satria@teddy:~$ cd Documents/projects/python/streamlit/

then go into the dir. make sure you already have python3-venv package. if not install it
satria@teddy:~/Documents/projects/python/streamlit$ sudo apt install python3.10-venv

then use python3-venv like this:
satria@teddy:~/Documents/projects/python/streamlit$ python -m venv .venv

Activate the virtual environment
satria@teddy:~/Documents/projects/python/streamlit$ source .venv/bin/activate
(.venv) satria@teddy:~/Documents/projects/python/streamlit$

install streamlit with pip in the venv
(.venv) satria@teddy:~/Documents/projects/python/streamlit$ pip install streamlit
Collecting streamlit
Using cached streamlit-1.41.1-py2.py3-none-any.whl (9.1 MB)
Collecting click<9,>=7.0
Downloading click-8.1.8-py3-none-any.whl (98 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.2/98.2 KB 915.4 kB/s eta 0:00:00
Collecting tornado<7,>=6.0.3
Using cached tornado-6.4.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (437 kB)
Collecting packaging<25,>=20
Using cached packaging-24.2-py3-none-any.whl (65 kB)
Collecting requests<3,>=2.27
Using cached requests-2.32.3-py3-none-any.whl (64 kB)
Collecting pydeck<1,>=0.8.0b4
Using cached pydeck-0.9.1-py2.py3-none-any.whl (6.9 MB)
Collecting numpy<3,>=1.23
Using cached numpy-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 MB)
Collecting gitpython!=3.1.19,<4,>=3.0.7
Using cached GitPython-3.1.44-py3-none-any.whl (207 kB)
Collecting toml<2,>=0.10.1
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting cachetools<6,>=4.0
Using cached cachetools-5.5.0-py3-none-any.whl (9.5 kB)
Collecting pandas<3,>=1.4.0
Using cached pandas-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB)
Collecting blinker<2,>=1.0.0
Downloading blinker-1.9.0-py3-none-any.whl (8.5 kB)
Collecting altair<6,>=4.0
Using cached altair-5.5.0-py3-none-any.whl (731 kB)
Collecting watchdog<7,>=2.1.5
Using cached watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl (79 kB)
Collecting pyarrow>=7.0
Using cached pyarrow-19.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (42.1 MB)
Collecting typing-extensions<5,>=4.3.0
Using cached typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting pillow<12,>=7.1.0
Downloading pillow-11.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (4.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.5/4.5 MB 14.1 MB/s eta 0:00:00
Collecting protobuf<6,>=3.20
Using cached protobuf-5.29.3-cp38-abi3-manylinux2014_x86_64.whl (319 kB)
Collecting rich<14,>=10.14.0
Using cached rich-13.9.4-py3-none-any.whl (242 kB)
Collecting tenacity<10,>=8.1.0
Using cached tenacity-9.0.0-py3-none-any.whl (28 kB)
Collecting jsonschema>=3.0
Using cached jsonschema-4.23.0-py3-none-any.whl (88 kB)
Collecting narwhals>=1.14.2
Using cached narwhals-1.22.0-py3-none-any.whl (297 kB)
Collecting jinja2
Using cached jinja2-3.1.5-py3-none-any.whl (134 kB)
Collecting gitdb<5,>=4.0.1
Using cached gitdb-4.0.12-py3-none-any.whl (62 kB)
Collecting pytz>=2020.1
Downloading pytz-2024.2-py2.py3-none-any.whl (508 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.0/508.0 KB 5.5 MB/s eta 0:00:00
Collecting tzdata>=2022.7
Using cached tzdata-2024.2-py2.py3-none-any.whl (346 kB)
Collecting python-dateutil>=2.8.2
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Collecting certifi>=2017.4.17
Downloading certifi-2024.12.14-py3-none-any.whl (164 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 164.9/164.9 KB 12.2 MB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1
Downloading urllib3-2.3.0-py3-none-any.whl (128 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 128.4/128.4 KB 12.5 MB/s eta 0:00:00
Collecting idna<4,>=2.5
Downloading idna-3.10-py3-none-any.whl (70 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.4/70.4 KB 14.6 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
Using cached charset_normalizer-3.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (146 kB)
Collecting pygments<3.0.0,>=2.13.0
Using cached pygments-2.19.1-py3-none-any.whl (1.2 MB)
Collecting markdown-it-py>=2.2.0
Using cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
Collecting smmap<6,>=3.0.1
Using cached smmap-5.0.2-py3-none-any.whl (24 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (20 kB)
Collecting referencing>=0.28.4
Using cached referencing-0.36.1-py3-none-any.whl (26 kB)
Collecting jsonschema-specifications>=2023.03.6
Using cached jsonschema_specifications-2024.10.1-py3-none-any.whl (18 kB)
Collecting rpds-py>=0.7.1
Using cached rpds_py-0.22.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (381 kB)
Collecting attrs>=22.2.0
Using cached attrs-24.3.0-py3-none-any.whl (63 kB)
Collecting mdurl~=0.1
Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Collecting six>=1.5
Downloading six-1.17.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: pytz, watchdog, urllib3, tzdata, typing-extensions, tornado, toml, tenacity, smmap, six, rpds-py, pygments, pyarrow, protobuf, pillow, packaging, numpy, narwhals, mdurl, MarkupSafe, idna, click, charset-normalizer, certifi, cachetools, blinker, attrs, requests, referencing, python-dateutil, markdown-it-py, jinja2, gitdb, rich, pydeck, pandas, jsonschema-specifications, gitpython, jsonschema, altair, streamlit
Successfully installed MarkupSafe-3.0.2 altair-5.5.0 attrs-24.3.0 blinker-1.9.0 cachetools-5.5.0 certifi-2024.12.14 charset-normalizer-3.4.1 click-8.1.8 gitdb-4.0.12 gitpython-3.1.44 idna-3.10 jinja2-3.1.5 jsonschema-4.23.0 jsonschema-specifications-2024.10.1 markdown-it-py-3.0.0 mdurl-0.1.2 narwhals-1.22.0 numpy-2.2.2 packaging-24.2 pandas-2.2.3 pillow-11.1.0 protobuf-5.29.3 pyarrow-19.0.0 pydeck-0.9.1 pygments-2.19.1 python-dateutil-2.9.0.post0 pytz-2024.2 referencing-0.36.1 requests-2.32.3 rich-13.9.4 rpds-py-0.22.3 six-1.17.0 smmap-5.0.2 streamlit-1.41.1 tenacity-9.0.0 toml-0.10.2 tornado-6.4.2 typing-extensions-4.12.2 tzdata-2024.2 urllib3-2.3.0 watchdog-6.0.0

test it by typing ‘streamlit hello’

(.venv) satria@teddy:~/Documents/projects/python/streamlit$ streamlit hello

👋 Welcome to Streamlit!

If you’d like to receive helpful onboarding emails, news, offers, promotions,
and the occasional swag, please enter your email address below. Otherwise,
leave this field blank.

Email: your_email@yahoo.com

You can find our privacy policy at https://streamlit.io/privacy-policy

Summary:
– This open source library collects usage statistics.
– We cannot see and do not store information contained inside Streamlit apps,
such as text, charts, images, etc.
– Telemetry data is stored in servers in the United States.
– If you’d like to opt out, add the following to ~/.streamlit/config.toml,
creating that file if necessary:

[browser]
gatherUsageStats = false

Welcome to Streamlit. Check out our demo in your browser.

Local URL: http://localhost:8501
Network URL: http://192.168.1.23:8501

Ready to create your own Python apps super quickly?
Head over to https://docs.streamlit.io

May you create awesome apps!

it’d open http://localhost:8501 on the browser.

Create new app and run it
In your project directory (/home/satria/Documents/projects/python/streamlit) that exist .venv file, create a new file ‘app.py’

[codesyntax lang=”python”]

[/codesyntax]
then run it.
note: pls make sure you’re already in the virtual environment (venv). if not type ‘source .venv/bin/activate’ to activate it. then run it by typing ‘streamlit run app.py’:
satria@teddy:~/Documents/projects/python/streamlit$ source .venv/bin/activate
(.venv) satria@teddy:~/Documents/projects/python/streamlit$ streamlit run app.py

You can now view your Streamlit app in your browser.

Local URL: http://localhost:8501
Network URL: http://192.168.1.23:8501

it’ll open it on your browser and printed ‘Hello World’

….

if you already finished, you can stop the streamlit app with ctrl+c and deactivated the venv
^C Stopping…
(.venv) satria@teddy:~/Documents/projects/python/streamlit$ deactivate
satria@teddy:~/Documents/projects/python/streamlit$

Golang and Gin Restful API

Ref: https://santrikoding.com/tutorial-restful-api-golang-1-membuat-project-golang

Note: Make sure golang is already installed by checking with ‘go version’ on your linux terminal
[codesyntax lang=”bash”]

[/codesyntax]
Note: it’ll be better to use the newest go version. I already installed go version 1.23.4
[codesyntax lang=”bash”]

[/codesyntax]

Note: don’t forget to run ‘go mod tidy’ on your go project

1. Create a new directory for this project named ‘go-restful-api’ then go into the directory
[codesyntax lang=”bash”]

[/codesyntax]

then type this to create a new module ‘advcha/backend-api’
[codesyntax lang=”bash”]

[/codesyntax]

2. Install ‘Gin’ and the libraries. Gin is a go-based web framework
[codesyntax lang=”bash”]

[/codesyntax]

3. Create a ‘Hello World’ with Gin
create a new file ‘main.go’ then here is the content
[codesyntax lang=”text”]

[/codesyntax]

4. Run it with ‘go run main.go’
[codesyntax lang=”bash”]

[/codesyntax]

5. open it on your browser with http://localhost:3000/
it should print

Install GORM (Go ORM). it’s a Object Relational Mapping (ORM) for Golang
1. Install GORM with MySQL driver
[codesyntax lang=”bash”]

[/codesyntax]

2. Create a new .env file to store the variables like the database name, password, etc.
[codesyntax lang=”text”]

[/codesyntax]
Note: rename ‘your_mysql_username’ and ‘your_mysql_password’ for your mysql account
‘db_go_restful_api’ is the database name we will create later

We need to install a package ‘github.com/joho/godotenv’ on the terminal ‘go get github.com/joho/godotenv’ to read the .env file
Note: run ‘go mod tidy’ to install any missing packages if exist

2. Create a Post model
create a new directory ‘models’ then create a new file ‘post.go’ in it. here is the file content
[codesyntax lang=”text”]

 

[/codesyntax]

3. create a database connection
create a new file ‘setup.go’ in the ‘models’ directory. here is the file content
[codesyntax lang=”text”]

[/codesyntax]

4. create a new mysql database ‘db_go_restful_api’

5. Create a new Post controller ‘postController.go’ in ‘controllers’ directory
[codesyntax lang=”text”]

[/codesyntax]

6. Create a route API Post
edit main.go to import the models and controllers. Also put the route in it. so it’ll be like this
[codesyntax lang=”text”]

[/codesyntax]

 

7. Run it and open it on your browser
If everything okay, the url http://localhost:3000/api/posts will show

Note: Also we can check it via Postman
create a new collection ‘Go Gin Restful API’ then create a new GET request ‘api_posts’ with url http://localhost:3000/api/posts

Insert data into the database
1. Create a new function ‘InsertPost’ in postController.go
note: first, we need to install a package ‘github.com/go-playground/validator/v10′[codesyntax lang=”bash”]

[/codesyntax]

[codesyntax lang=”text”]

[/codesyntax]

2. Then add a route in main.go to insert the post like this
[codesyntax lang=”text”]

[/codesyntax]

3. Run and test with Postman

Note: also need to test the validation with a json for empty title and content to make sure the validation is working.
the above screen showed the json with title and content and the success result
the output on http://localhost:3000/api/posts will be like this: