Skip to content

Instantly share code, notes, and snippets.

impl<V: Value> core::str::FromStr for NonNormalizingDec<V> {
type Err = &'static str;
#[inline(never)]
#[rustfmt::skip]
fn from_str(s: &str) -> Result<Self, Self::Err> {
/// Converts an ASCII decimal digit to an int.
///
/// In release builds, no range checks are performed and passing a
/// non-digit character will result is undefined (yet safe) behavior.
@sts10
sts10 / rust-command-line-utilities.markdown
Last active May 7, 2024 08:15
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
@mattiasghodsian
mattiasghodsian / readme.md
Last active May 7, 2024 08:13
How to create a Windows application Installer with NSIS

Nullsoft Scriptable Install System is also known as NSIS open-source system to create Windows application installers. NSIS is a script-based system allowing you to create the logic behind your installer/setup file in a complex way to install tasks. NSIS offers plug-ins and other scripts, for example, to download/install 3rd-party files or communicate with Windows.

The tutorial application

This tutorial will guide you through installing and creating your first Windows installer with Nullsoft Scriptable Install System and how to compile your project. Captura Portable will be used as "our application" for the sake of this tutorial.

Installation

Head to NSIS official site and download the latest release and install it. Run NSIS and you will be welcomed with a menu like below, It's always a good practice to read the Documentation before jumping in t

@KaneCheshire
KaneCheshire / AnyTask.swift
Last active May 7, 2024 08:13
Type-erased Swift Task that cancels itself on deinit
/// A type-erased task that you can store in a collection
/// to allow you to cancel at a later date.
///
/// Upon deinit of the task, the task will be cancelled
/// automatically. Similar to Combine's AnyCancellable.
final class AnyTask {
/// Call this cancellation block to cancel the task manually.
let cancel: () -> Void
/// Checks whether the task is cancelled.
@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active May 7, 2024 08:11
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.

@borcean
borcean / t480-fedora-fingerprint.md
Last active May 7, 2024 08:11
ThinkPad T480 fingerprint reader on Fedora Linux

ThinkPad T480 fingerprint reader on Fedora Linux

Background

The Synaptics fingerprint sensor (06cb:009a) present on my T480 is not supported by libfprint and fprintd as it requires a non-free binary blob. uunicorn created open-fprintd, a replacement for fprintd, that allows for loading of binary blobs. In conjunction with their python-validity driver we are able to make use of the inbuilt fingerprint reader. The following instructions were tested against Fedora Linux 35.

Installing open-fprintd and python-validity

sudo dnf copr enable tigro/python-validity
sudo dnf install open-fprintd fprintd-clients fprintd-clients-pam python3-validity
@enginefeeder101
enginefeeder101 / auth_provider.py
Last active May 7, 2024 08:10 — forked from sidoh/auth_provider.py
Custom HomeAssistant auth provider
import logging
import jwt
from urllib.parse import urlparse
import urllib.request
from collections import OrderedDict
from typing import Any, Dict, Optional, cast
import voluptuous as vol
@R0GGER
R0GGER / _hsts.conf
Last active May 7, 2024 08:09
Workaround - Security Headers @ NGINX Proxy Manager
{% if certificate and certificate_id > 0 -%}
{% if ssl_forced == 1 or ssl_forced == true %}
{% if hsts_enabled == 1 or hsts_enabled == true %}
# HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
add_header Strict-Transport-Security "max-age=63072000;{% if hsts_subdomains == 1 or hsts_subdomains == true -%} includeSubDomains;{% endif %} preload" always;
add_header Referrer-Policy strict-origin-when-cross-origin;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options SAMEORIGIN;
add_header Content-Security-Policy upgrade-insecure-requests;
@Tapanhaz
Tapanhaz / abcd.py
Last active May 7, 2024 08:08
Custom logging formatter with colored console outputs and logging to file.
import logging
logger = logging.getLogger(__name__)
def func1():
logger.warning("This is a warning message")
logger.info("This is a info message")
@spali
spali / 10-wancarp
Last active May 7, 2024 08:07
Disable WAN Interface on CARP Backup
#!/usr/local/bin/php
<?php
require_once("config.inc");
require_once("interfaces.inc");
require_once("util.inc");
$subsystem = !empty($argv[1]) ? $argv[1] : '';
$type = !empty($argv[2]) ? $argv[2] : '';