Skip to content

Instantly share code, notes, and snippets.

@bartosjiri
bartosjiri / react-window-size-hook.md
Last active November 27, 2020 17:46
React window size hook with resize listener

useWindowSize.js:

import {useState, useEffect} from 'react';

const REFRESH_TIMEOUT = 150;

const useWindowSize = () => {
  const getSize = () => ({
    width: window.innerWidth
      || document.documentElement.clientWidth
@bartosjiri
bartosjiri / gatsby-local-plugin.md
Last active September 1, 2020 19:24
Import a local plugin into a Gatsby project

Importing a local plugin into Gatsby

Instructions

  1. Include the plugin in plugins folder by following the official documentation.
  2. Update webpack config in the gatsby-node.js file:
    const path = require('path')
    
@bartosjiri
bartosjiri / raspbian-64bit-headless.md
Created April 9, 2020 20:44
Raspberry Pi Raspbian 64bit headless setup

Raspberry Pi Raspbian 64bit headless setup

A step-by-step guide for running a headless Raspbian 64bit kernel and OS on Raspberry Pi. The provided configuration has been tested on models 3B, 3B+ and 4B.

Instructions

  1. Download the Raspberry Pi Imager application.

  2. Use the application to download Raspbian Lite (under Raspbian (other)) and write the image on your SD card.

  3. Setup wireless connection configuration by creating wpa_supplicant.conf file in the boot folder:

@bartosjiri
bartosjiri / direct-manjaro-cpu-fan-control.md
Last active November 26, 2019 12:51
Direct Manjaro CPU fan control

Direct Manjaro CPU fan control

If your CPU clock is constantly running at high frequency, consuming too much power and keeping the laptop constantly hot, consider using cpupower and mbpfan-git packages:

yaourt -S mbpfan-git cpupower
sudo systemctl enable mbpfan
sudo systemctl enable cpupower

The mbpfan-git controls fan actions while cpupower sets CPU governor to configured performance mode set in /etc/default/cpupower file:

@bartosjiri
bartosjiri / mysecureshell-custom-configuration.md
Last active August 20, 2019 16:32
MySecureShell custom configuration

MySecureShell custom configuration

A simple secure SFTP setup.

New users have disabled bash and similar shells, are allowed to authenticate with password, and are jailed in their home directory.

Configuration

The initial setup to prepare for an easy user management.

SSH

Disable password authentication for all users with an exception for sftp-only group.

@bartosjiri
bartosjiri / secure-nginx-server-guide.md
Last active August 9, 2021 17:52
Secure Nginx server guide

Secure Nginx server guide

This gist will guide you through the setup of a basic Nginx web server using Debian-based Linux distribution.

It is primarily focused on securing the access to the server via various protocols and limiting user permissions.

Launch the server

  1. Launch a server with Ubuntu 19.04 or other Debian-based distribution.
  2. Log in using SSH with the server IP:

ssh root@SERVER-IP

@bartosjiri
bartosjiri / xmodmap-macos.md
Last active September 1, 2023 17:59
Xmodmap macOS configuration

Xmodmap macOS configuration

Xmodmap configuration that swaps ctrl and cmd keys to achieve macOS-like behaviour.

Installation

  1. Open or create .Xmodmap file in your ~/ folder.

  2. Paste the following code into that file:

    ! -*- coding: utf-8 -*-
    
@bartosjiri
bartosjiri / manjaro-disable-bluetooth.md
Last active December 29, 2023 11:10
Manjaro disable bluetooth at login

Manjaro disable bluetooth at login

Problem

Manjaro automatically turns on bluetooth at login.

Solution

  1. Run the following command:
    gsettings set org.blueman.plugins.powermanager auto-power-on false
    
@bartosjiri
bartosjiri / manjaro-broadcom-wlan-fix.md
Last active February 18, 2023 10:33
Manjaro broadcom WLAN fix

Manjaro broadcom WLAN fix

Problem

Manjaro installation doesn't offer any WLAN connections.

Solution

  1. Connect the device to the internet through ethernet, phone-to-USB or other available method.

  2. Uninstall current drivers: