Skip to content

Instantly share code, notes, and snippets.

View fullkomnun's full-sized avatar

Or Noyman fullkomnun

View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
// Unlike the string type, ShortString is a value type that can be made immutable.
// It supports strings of at most 32 bytes and assumes they don't contain null bytes.
type ShortString is bytes32;
error StringTooLong(string s);
@sm-Fifteen
sm-Fifteen / whats_a_yubikey.md
Last active July 7, 2024 18:10
"What the heck is a Yubikey and why did I buy one?": A user guide

"What the heck is a Yubikey and why did I buy one?": A user guide

(EDIT: Besides Reddit, I've also put this up on Github Gist)

So while looking for information on security keys before getting one myself, I got very confused reading about all the different modes and advertised features of Yubikeys and other similar dongles. The official documentation tends to be surprisingly convoluted at times, weirdly organized and oddly shy about a few of the limitations of these keys (which I'm making a point of putting front and center). Now that I have one, I decided to write down everything I figured out in order to help myself (and hopefully some other people reading this) make sense of all this.

Since I'm partly writing these notes for myself, there might be some back and forth between "exp

@sindresorhus
sindresorhus / esm-package.md
Last active July 8, 2024 16:04
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@MarkusKramer
MarkusKramer / Base64.kt
Last active June 3, 2024 17:25
Kotlin Multiplatform Base64 - no extra dependencies. Based on Java's implementation.
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
@dellisd
dellisd / Resource.kt
Last active December 28, 2023 11:33
Kotlin Multiplatform test resources
// Common
const val RESOURCE_PATH = "./src/commonTest/resources"
expect class Resource(name: String) {
val name: String
fun exists(): Boolean
fun readText(): String
}
@lordcodes
lordcodes / TokenRefreshAuthenticator.kt
Created March 17, 2020 09:31
Code for the article: "Authorization and retrying of web requests for OkHttp and Retrofit"
class TokenRefreshAuthenticator(
private val authorizationRepository: AuthorizationRepository
) : Authenticator {
override fun authenticate(route: Route?, response: Response): Request? = when {
response.retryCount > 2 -> null
else -> response.createSignedRequest()
}
private fun Response.createSignedRequest(): Request? = try {
val accessToken = authenticationRepository.fetchFreshAccessToken()

Windows 10 (20H1 / 2004 / Mai 2020 Update) with WSL2 is out, this guide should be obsolete now.

Upgrading an existing WSL1 setup to WSL2

Docker in WSL1

Note, this is only needed on Windows 10 Home and WSL1. If you have Windows 10 Pro, you can run Docker for Windows (https://docs.docker.com/docker-for-windows).

After completing this guide, you will have a Windows 10 Home running the docker deamon via Docker Toolbox / VirtualBox. The WSL guest OS will connect to this docker deamon, and will have the Windows OS filesystem mapped as C:\ -> /c/ instead of C:\ -> /mnt/c/, which will fix path translation between docker deamon on Windows and docker client in WSL guest OS.

@Justintime50
Justintime50 / standard-user-owned-brew.md
Last active January 12, 2024 16:41
Use the following commands to setup Hombrew as a standard user getting around needing sudo access for most packages.

Standard User Owned Brew

Use the following commands to setup Hombrew as a standard user getting around needing sudo access for most packages.

NOTE: This still requires an admin to install Homebrew initially. After the ownership change, the standard user can use Homebrew moving forward.

Setup Homebrew for a Standard User

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Improving heat management after macbookpro 2011 discrete GPU fix, also a script to automate part of the fix process

Taken from StackExchange

Thanks to LangLangC

NOTE: This is experimental; works for some people, not for others

Improved thermal and power management