Categories
games

Sega Mega Drive and Genesis Classics Hub

Sega Mega Drive and Genesis Classics Hub is official Sega emulator for the Sega Mega Drive available on Steam. It puts the player into a 3D environment of a Sega fan’s bedroom in the early nineties. The player can then boot up the in-game CRT TV, choose the game they want to play off a virtual shelf and load up the Mega Drive to start playing. The Sega Mega Drive Classics Hub features local co-op for supported games, optional graphic enhancement filters, the ability to save at any point during gameplay and full controller and keyboard support.

Categories
interwebs security web server

Let’s Encrypt in manual mode

SSL and TLS are cryptographic protocols designed to provide secure conenction between web client and web server. This security is achieved by installing SSL/TLS certificate on a web server. Certificate contains the public key and additional information such as issuer, what the cert is supposed to be used for, and other types of metadata. Certificate is signed by a certificate authority (CA) using CA’s private key. This verifies the authenticity of the certificate. Secure connection between client and server is established over HTTPS protocol.

Let’s Encrypt is a CA. In order to get a certificate for your website’s domain from Let’s Encrypt, you have to demonstrate control over the domain. If you don’t have shell access (SSH access) to your web host, you can use Certbot software on your own computer in so called manual mode. In manual mode, you upload a specific file to your website to prove your control. Certbot will then retrieve a cert that you can upload to your hosting provider. Example:

certbot certonly --manual --preferred-challenges=http --email admin@domain.com --agree-tos -d domain.com

When you run command above, Certbot will ask you to put specific file on your website to prove ownership. After it is verified you will get your private key (privkey.pem) and chain/bundle (fullchain.pem). Chain files contains your certificate. To decode your cert you can type

openssl x509 -in certificate.crt -text -noout

or use tool such Online Decoder.

Now you need to send those files to your website administrator to make HTTPS work. Downside of this method is that it is time-consuming and you will need to repeat it several times per year as your cert expires every 90 days.

Categories
organization productivity programming

Good programming habits

  • volunteer for things you don’t know so you can constantly learn new things
  • ask to pair up because pairing session is a great way to kick off the work on a task; discuss requirements until you understand what is expected, then discuss the solution
  • talk about what you are doing and what you’re not doing
  • write a blog because writing with the intention to teach others (even if it’s just future you) is a great way of learning and growing
  • have a notebook and a system to convince your mind that whatever you put into the notebook will not be lost; create index, review notes and process them
  • have a time slot for important tasks
  • when stuck, take a break
  • don’t chase “silver bullets”

Source: freeCodeCamp.org

Categories
programming

PHP Exceptions

Example:

  1. exception is thrown
  2. following code is not executed
  3. PHP looks for catch block
  4. if catch block is not found, fatal error is issued with Uncaught Exception message

Solution:

  1. try – a function using an exception should be on a “try” block
  2. catch – a “catch” block retrieves an exception and creates an object containing the exception information
function x(){
  if(true) throw new Exception("error");
  return false;
}

try{
  x();
} catch (Exception $e){
  echo $e->getMessage();
}

You can create custom exception class that inheres properties from PHP’s exception class and add custom functions to it.

try{
  x();
} catch (Exception $e){
  throw new CustomException();
}

Categories
android games linux

Anbox

Anbox is a compatibility layer that allows mobile applications and games developed for Android to run on Linux. To achieve this, it uses standard Linux technologies like containers (LXC) to separate the Android operating system from the Linux host.

While emulators creates an entire emulated system which has its own kernel etc., Anbox runs the Android system under the same kernel as the host operating system does. No emulation layer is necessary, everything runs directly on the hardware. This approach also allows a much better integration with the host operating system. Anbox puts Android apps into a tightly sealed box without direct access to hardware or your data by mounting Android directory structure whilst using the native Linux kernel to execute applications.

Project is open source, current version is having trouble with kernel 5.7.

Commands

systemctl start systemd-networkd
systemctl start systemd-resolved
systemctl start anbox-container-manager.service
anbox session-manager
adb install package.apk
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
Categories
web design wordpress

Elementor

Elementor is a live page builder for WordPress. It means that whole process of writing and designing is done directly on the page with no need to press “Update” or go to preview mode. Free version of this WordPress plugin comes with 30 of the most useful widgets such as button, image carousel, tabs, accordion, alert etc. Pro/paid version comes with even more.

Elementor Page Builder can work with basically any WordPress theme that follows general WordPress guidelines. There are also lot of templates, both free and commercial, that you can customize to match your needs. To start from scratch, use Hello Elementor, a lightweight, plain-vanilla theme for this page builder. Keep in mind that this theme is specifically designed to work with Elementor Pro.

Elementor drag and drop on Twenty Twenty theme

Envato, the company behind the ThemeForest marketplace, is also the author of free WordPress plugin called Envato Elements. This plugin offers hundreds Elementor templates for all website niches. Combination of those two plugins can be used to create awesome websites directly from your WordPress dashboard.

Both plugins are open source.

Categories
games linux

Steam Play

Before we understand what Steam Play is, let’s check some prerequisites…

Wine

Wine, originally an acronym for “Wine Is Not an Emulator”, is a compatibility layer capable of running Windows applications on several POSIX-compliant operating systems such as Linux, macOS and BSD. Instead of simulating internal Windows logic like a virtual machine or emulator, Wine translates Windows API calls into POSIX calls on-the-fly, eliminating the performance and memory penalties of other methods and allowing you to cleanly integrate Windows applications into your desktop.

CrossOver

Wine is an open-source technology and can be downloaded for free. CrossOver is commercialized version of Wine from CodeWeavers.

Proton

Proton, a tool released by Valve Software and CodeWeavers, allows games which are exclusive to Windows to run on the Linux operating system. It uses a custom version of Wine as well as additional libraries developed alongside it to facilitate this. These include Direct3D to Vulkan translation layers, namely DXVK for Direct3D 9, 10 and 11 and VKD3D for Direct3D 12.

Vulkan

Vulkan is 3D rendering API, successor of OpenGL. Vulkan offers lower overhead, more direct control over the GPU, and lower CPU usage. The overall concept and feature set of Vulkan is similar to Mantle later adopted by Microsoft with Direct3D 12 and Apple with Metal.

Steam Play

Steam Play is compatibility layer built into the official Steam client that allows you to play games from your library that were built for other operating systems. For example, Steam Play uses Proton to allow Linux users to play Windows games.

DOSBox

DOSBox emulates an IBM PC compatible computer running a DOS operating system including many IBM PC compatible graphics and sound cards. This means that original DOS programs and games are provided with an environment in which they can run correctly, even though modern computers have dropped support for the old environment.

Boxtron

Boxtron is Steam Play compatibility tool to run DOS games using native Linux DOSBox. It enables you to play games on Linux that don’t have a Linux build setup on Steam only this is for DOSBox games.

Categories
linux programming web server

Simple Laravel Docker setup

composer create-project laravel/laravel laravel-app
cd laravel-app
touch .docker/Dockerfile
touch .docker/vhost.conf

Content of Dockerfile:

FROM php:7.3-apache
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app && a2enmod rewrite

Content of vhost.conf:

<VirtualHost *:80>
    DocumentRoot /srv/app/public
    <Directory "/srv/app/public">
        AllowOverride all
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Building image:

docker build --file .docker/Dockerfile -t laravel-app .

Running container:

docker run --rm -p 8080:80 laravel-app

Source: BitPress

Categories
programming web server

Docker Compose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you can use YAML file to configure your application’s services. Then, with a single command, you can create and start all the services from your configuration.

  • define your app’s environment with Dockerfile
  • define services (containers with additional stuff) that make up your app in docker-compose.yml
  • run docker-compose up so Compose can start and run your entire app

Commands

docker-compose ps
docker-compose up -d
docker-compose stop
docker-compose down
docker-compose rm [name]
docker-compose build [name]
or docker-compose build --no-cache
docker-compose up -d
docker-compose logs --follow [service_name]
docker-compose exec [service_name] [command]

Source: freeCodeCamp

Categories
linux programming web server

Docker

Containerization is the process of encapsulating software code along with all of its dependencies inside a single package so that it can be run consistently anywhere. Docker is an open source containerization platform. It provides the ability to run applications in an isolated environment known as a container.

Containers are lightweight virtual machines that can run multiple containers simultaneously. Containers can be deployed on servers.

Images are multi-layered self-contained files with necessary instructions to create containers. Containers are runnable instances of images. If we compare images with classes from OOP then containers are the objects. Images are stored in registries such Docker Hub, the default public registry for storing images.

Arch install

pacman -Sy docker docker-compose
systemctl start docker.service
gpasswd -a benke docker
docker info
kitematic

Images commands

docker images
docker image ls
docker rmi [image_id]
docker run [image_id]
docker create [image_id]
docker start [container_id]
docker run [image_id] -d
docker pull [image_id]

Containers commands

docker run -it docker/whalesay cowsay Petar
docker run -it -p 80:80 nginx
docker ps
docker ps -a
docker container ls
docker start [container_id]
docker restart [container_id]
docker exec [container_id] [command]
docker logs [container_id]
docker stop [container_id]
docker rm [container_id]
docker container rm --force [container_id]
docker system prune
docker inspect [container_id] (look for RestartPolicy in the output)
docker update --restart=no [container_id]

Dockerfile

  • FROM
  • WORKDIR
  • COPY
  • RUN
  • EXPOSE
  • ENTRYPOINT
  • CMD

Source: freeCodeCamp