Skip to content

Instantly share code, notes, and snippets.

View TheSnowfield's full-sized avatar
🍣
I love sushi and raw salmon. (●ˇ∀ˇ●) yummy~

TheSnowfield TheSnowfield

🍣
I love sushi and raw salmon. (●ˇ∀ˇ●) yummy~
View GitHub Profile
@TheSnowfield
TheSnowfield / README.md
Created November 13, 2024 00:34
Armbian fsck get a newer version of e2fsck

image This problem caused by the host used a newer mke2fs(>=1.47) to created the root filesystem, however Armbian packed the old version e2fsck(<=1.46).

This is a stupid problem, we completely know the root file system is healthy, but we can not skip the check. :(

To deal with this problem, if you're an Armbian maintainer/developer, add the hook script under packages/bsp/common/etc/initramfs-tools/hooks/upgrade-e2fsck.sh, make sure the script file has execture permission: "chmod +x upgrade-e2fsck.sh"

@TheSnowfield
TheSnowfield / Home Assistant: configuring command line sensor using yaml has moved.md
Last active July 20, 2024 13:15
Home Assistant: configuring command line sensor using yaml has moved.

Configuring command line sensor using yaml has moved, after Home Assistant 2023 update.
This gist is guiding you how to perform a quick fix.

The old style

configuration.yml:

binary_sensor: !include sensors.yaml

sensors.yml

@TheSnowfield
TheSnowfield / remove.js
Last active December 1, 2022 10:31
remove grayscale
// ==UserScript==
// @name Fuck Grayscale
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
/*
* Copyright (C) 2016 Icenowy Zheng <[email protected]>
*
* Based on sun8i-h3-orangepi-one.dts, which is:
* Copyright (C) 2016 Hans de Goede <[email protected]>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
@TheSnowfield
TheSnowfield / FuturedSocket.cs
Last active May 20, 2022 09:19
C# async/await Socket
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
internal class FuturedSocket : IDisposable
{
/// <summary>
/// Inner socket
@TheSnowfield
TheSnowfield / rpi-configure-locales.md
Created March 15, 2022 07:26 — forked from tomysmile/rpi-configure-locales.md
Raspberry Pi: Reconfigure Locales

Reconfigure your RPi Locales

First you need to install the locales you want:

sudo dpkg-reconfigure locales

Then refresh your current environment:

@TheSnowfield
TheSnowfield / pocketchip.kmp
Created March 15, 2022 06:41 — forked from thiemok/pocketchip.kmp
Pocketchip keymap for headless boot - fixed for zsh
keymaps 0-2,4-5,8,12
altgr keycode 2 = F1
altgr keycode 3 = F2
altgr keycode 4 = F3
altgr keycode 5 = F4
altgr keycode 6 = F5
altgr keycode 7 = F6
altgr keycode 8 = F7
altgr keycode 9 = F8
altgr keycode 10 = F9
@TheSnowfield
TheSnowfield / SandBox.cs
Last active February 14, 2024 04:56
Dynamically run C# code in the same context
public class SandBox
{
private ScriptState<object> _globalState;
public SandBox()
{
// Create initial script
var script = CSharpScript.Create(string.Empty, ScriptOptions.Default);
{
// Create an empty state
@TheSnowfield
TheSnowfield / compile code.md
Last active February 1, 2022 08:25
compile code in runtime
/// <summary>
/// Run code
/// </summary>
/// <returns></returns>
public static async Task<MessageBuilder> OnRunPlainCode(MessageChain message)
{
    var codeTemplate = @"
namespace DynamicCodeExecution {
    public static class Runnable {
@TheSnowfield
TheSnowfield / braille pattern.md
Last active January 30, 2022 09:25
Braille character in JavaScript

Code snippet

function braille_pattern(blocks)
{
    if(!(blocks instanceof Array) || blocks.length > 8 || blocks.length < 0) 
        throw new TypeError("Only accept an array in max of 8 elements with 0/1 or true/false.");

    // value table
 const table = [1, 2, 4, 64, 8, 16, 32, 128];