How to Write a C Module and Build it with Meson
In this post I put my latest C project skeleton, you can find a github repo for the this tiny project here: https://github.com/rayed/c_module_meson
Fast Way to Edit SSH known_hosts
Few days ago I migrated my website to a new server, and whenever you try to connect
to a server using ssh
it must know it first, if not it will complain, and ask you
verfiy the server key signature:
$ ssh rayed.com
The authenticity of host 'rayed.com (x.x.x.x)' can't be established.
:
Are you sure you want to continue connecting (yes/no/[fingerprint])?
If you say yes, it will add the server signature to your system as known host, in
the file ~/.ssh/known_hosts
Migrating From Centos to Debian
Finally I managed to migrate from Centos 7 to Debian.
The migration was motivated by two updates:
- Debian has improved a lot, specially in the field of ease of use, I can now recommend it without hesitation.
- Redhat decided to stop supporting Centos as a downstream version from its own OS, it is now continuous update OS similar to Fedora but for the server version. Thank you Redhat but I don’t think I can rely on it any more.
I also updated my Hugo website setup.
Debian New System Useful Commands
Update System
# switch to user root
su -
apt update && apt upgrade
apt install sudo
usermod -aG sudo rayed
# logout from root & user
Network
Enable New Interface
Ref: https://wiki.debian.org/NetworkConfiguration
sudo vi /etc/network/interfaces
:
auto enp0s8
iface enp0s8 inet dhcp
:
sudo ifup enp0s8
NTP
sudo vi /etc/systemd/timesyncd.conf
:
NTP=sa.pool.ntp.org
:
sudo systemctl restart systemd-timesyncd
timedatectl timesync-status
Security
Secure SSH
sudo vi /etc/ssh/sshd_config
:
PasswordAuthentication no
:
sudo systemctl restart ssh
Firewall
Ref: https://wiki.debian.org/Uncomplicated%20Firewall%20%28ufw%29
Django and NGINX in Docker
In this post we will run Django application behind a NGINX webserver, which is a very common practice in production.
Build small Go Program Docker Image
Let’s start with this small Go program:
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
We will use go modules to manage dependencies:
go mod init rayed.com/server
go mod tidy
You can run it without installing Go on your machine using Docker:
docker run --rm -it -v `pwd`:/app -w /app golang:1.16 go run server.go
Building a Docker Image
Next step we will make a custom Docker image from our application, we would need a Dockerfile
like this:
SELinux Tip: Web Contents in User Home
I moved my website to new a server, since I moved my blog to Hugo I only needed small machine with minimal spec, so I downgraded my server to one costing $5 per month instead of $10.
I usually put all my personal projects including the blog under my home directory /home/rayed
, and point the Apache web server to serve content from inside it.
So I configured Apache web server as follow:
My "Introduction to Cryptography & PGP" Talk
I had the pleasure to give a talk at The Saudi Federation for Cyber Security and Programming titled “Introduction to Cryptography & PGP”
You can watch Video of the talk, and for the slides:
Art Installation Technology
Have you ever wondered about …
- how a ride in a theme park works
- how the lights in a music show move and synchronize with the music
- how a dancing fountain … dance
- how the interactive art installation move based on your movement?
- how a skyscraper change color during special occasions
If you haven’t I have! and here I am trying to find the technology behind all of these projects.
In this post I’ll keep links and videos related to this subject, I’ll try to keep adding to it as I learn more about the subject, and please share with me any links about resources that could be relevant.
Parsing In Shell Script
Here a small snippet to parse name:value pairs is shell script: