Skip to content

Instantly share code, notes, and snippets.

@hanreev
hanreev / list-cron-jobs.sh
Created July 12, 2023 16:11
List cron jobs for all users
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
@hanreev
hanreev / Dockerfile
Last active April 8, 2022 04:55
Docker React and Next.js
FROM node:16-buster-slim
WORKDIR /app
EXPOSE 3000
COPY start-container /usr/local/bin
RUN chmod +x /usr/local/bin/start-container
USER node

After some trial and error, I found that the Lenovo IdeaPad Slim 7i Pro had two issues running Ubuntu and its derivatives.

First, the keyboard doesn't work right away at the login screen because the virtual i8042 keyboard controller implemented in the BIOS is not properly delivering interrupts when the keyboard sends three bytes (fa ab 83) in a too quick succession. Adding i8042.dumbkbd kernel parameter fixes the issue.

Second, Panel Self Refresh (PSR), a power saving feature used by Intel iGPUs is known to cause flickering. A temporary solution is to disable this feature using the kernel parameter i915.enable_psr=0.

Third, Some NVMe devices may exhibit issues related to power saving (APST). This happens on ADATA SX6000LNP 1TB. As a workaround, add the kernel parameter nvme_core.default_ps_max_latency_us=0 to completely disable APST.

So, we need to add i8042.dumbkbd, i915.enable_psr=0 and nvme_core.default_ps_max_latency_us=0 kernel boot parameters in order to run Ubuntu properly. Follow

@hanreev
hanreev / compress_image.py
Last active January 10, 2025 07:07
Python Scripts
import argparse
import os
import sys
from concurrent.futures import ThreadPoolExecutor, wait
from glob import glob
from multiprocessing import cpu_count
from PIL import Image
@hanreev
hanreev / BaseEnum.php
Created December 2, 2021 12:23
PHP & Laravel
<?php
namespace App\Enums;
use ReflectionClass;
abstract class BaseEnum
{
/**
* Enumeration constants cache.
@hanreev
hanreev / gdal38-ecw.sh
Last active January 4, 2025 07:24 — forked from 1papaya/gdal_ecw.sh
Install GDAL 3.0 with ECW support on Ubuntu 20.04 (with Java binding for GeoServer)
#!/bin/bash
##
## Tested on: Ubuntu 24.04 & ECW 5.5 & GDAL 3.8.4
## With java binding for GeoServer
##
## Download the ERDAS ECW JP2 SDK v5.5 Update 4 Linux
## Download GDAL Source from apt
@hanreev
hanreev / AdobeAMDFix.md
Created November 18, 2020 11:01 — forked from naveenkrdy/AdobeAMDFix.md
To fix adobe products crashes on AMD hackintosh

Adobe Crash Fix XLNC

Instructions

  1. Install needed adobe apps from adobe creative cloud.

  2. Open Terminal.

  3. Copy-paste the below command to your terminal and run it (enter password if asked).