Skip to content

Instantly share code, notes, and snippets.

View Animeshz's full-sized avatar
👋

Animesh Sahu Animeshz

👋
View GitHub Profile
local M = {}
local uv = vim.loop
local fn = vim.fn
local api = vim.api
function password()
fn.inputsave()
local user = fn.expand("$USER")
local pw = fn.inputsecret(string.format("password for %s: ", user))
@LorbusChris
LorbusChris / MatrixIRC.md
Last active December 30, 2022 19:27
Matrix libera.chat IRC Bridge Setup

Matrix libera.chat IRC Bridge Setup

Change libera.chat IRC Nick

This is optional, in case you prefer your nick to be shown as something other than <matrix_nick>[m] on IRC, e.g. just <matrix_nick> (without the [m] suffix) or <libera_nick>.

Open a private chat with @appservice:libera.chat:

!nick <new_libera_nick>

Note: This does not change your Matrix nick!

@EugeneTheDev
EugeneTheDev / DotsLoaders.kt
Created March 18, 2021 23:15
Dots loading animations with Jetpack Compose
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@Neurognostic
Neurognostic / create-uefi-unified-image.sh
Last active May 31, 2024 11:22
Dracut UEFI Unified Kernel Image with Secure Boot Signing
esp=/efi
distro=archlinux
mkdir -p $esp/EFI/$distro
# Generate UEFI Unified Image
dracut --force --verbose --kver $(uname -r) $esp/EFI/$distro/linux+initramfs.efi.signed
# Create UEFI boot manager entry
efibootmgr --quiet --create --disk /dev/disk/by-label/EFI --label 'Arch Linux' --loader /EFI/$distro/linux+initramfs.efi.signed
@elizarov
elizarov / DeepRecursiveFunction.kt
Last active March 25, 2024 00:40
Defines recursive function that keeps its stack on the heap (productized version)
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
/**
* Defines deep recursive function that keeps its stack on the heap,
* which allows very deep recursive computations that do not use the actual call stack.
* To initiate a call to this deep recursive function use its [invoke] function.
* As a rule of thumb, it should be used if recursion goes deeper than a thousand calls.
*
* The [DeepRecursiveFunction] takes one parameter of type [T] and returns a result of type [R].
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active June 20, 2024 06:15
Conventional Commits Cheatsheet

Conventional Commit Messages

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions and generate verion and changelogs

Commit Message Formats

Default

@lukicdarkoo
lukicdarkoo / configure.sh
Last active June 6, 2024 16:05
Raspberry Pi: AP + client mode
#!/bin/sh
# The script configures simultaneous AP and Managed Mode Wifi on Raspberry Pi Zero W (should also work on Raspberry Pi 3)
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/6b92d182d37d0a10400060d8344f86e4/raw | sh -s WifiSSID WifiPass APSSID APPass
# Licence: GPLv3
# Author: Darko Lukic <lukicdarkoo@gmail.com>
# Special thanks to: https://albeec13.github.io/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/
MAC_ADDRESS="$(cat /sys/class/net/wlan0/address)"
CLIENT_SSID="${1}"
CLIENT_PASSPHRASE="${2}"
@tomaszpolanski
tomaszpolanski / Variance.kt
Created July 3, 2017 16:07
Covariance vs Contravariance
package com.tomek
abstract class Animal(val size: Int)
class Dog(val cuteness: Int): Animal(100)
class Spider(val terrorFactor: Int): Animal(1)
// Covariance
@rongjiecomputer
rongjiecomputer / prime.cpp
Created April 5, 2017 00:00
Sieve of Eratosthenes with C++ constexpr
#include <stdio.h>
template <size_t N>
struct PrimeTable {
constexpr PrimeTable() : sieve() {
sieve[0] = sieve[1] = false;
for (size_t i = 2; i < N; i++) sieve[i] = true;
for (size_t i = 2; i < N; i++) {
if (sieve[i])
for (size_t j = i*i; j < N; j += i) sieve[j] = false;
@wojteklu
wojteklu / clean_code.md
Last active June 20, 2024 21:37
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules