Skip to content

Instantly share code, notes, and snippets.

View Alxandr's full-sized avatar
⁉️
⁉️

Aleksander Heintz Alxandr

⁉️
⁉️
View GitHub Profile
public static class FooBar
{
public static string Foo { get; } = "Foo";
public static string Bar { get; } = "Bar";
public static IEnumerable<string> All { get; } = GetAll().ToImmutableList();
static IEnumerable<string> GetAll()
{
foreach (var prop in typeof(FooBar).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly))
k3os-17054 [~]$ k3s check-config
Verifying binaries in /var/lib/rancher/k3s/data/688c8ca42a6cd0c042322efea271d6f3849d3de17c850739b0da2461f6c69ee8/bin:
- sha256sum: good
- links: good
System:
- /usr/sbin iptables v1.8.3 (legacy): ok
- swap: disabled
- routes: ok
@Alxandr
Alxandr / safeish.rs
Last active December 15, 2020 19:02
use crate::tag::TagLookup;
use git2::Repository;
pub struct Context {
// NOTE: This lifetime is fake
tags: TagLookup<'static>,
// IMPORTANT: this has to be last to be dropped last
repo: Box<Repository>,
}
trait ValueCaster {
unsafe fn cast_to_any(&self, b: Box<dyn Value>) -> Box<dyn Any>;
}
struct BoxCaster<V: Value>(PhantomData<V>);
impl<V: Value> BoxCaster<V> {
const INSTANCE: BoxCaster<V> = BoxCaster(PhantomData);
}
public static class Extensions
{
// Temporary workaround until https://github.com/ChilliCream/hotchocolate/issues/2522 is resolved
public static LocaleDirective ToLocaleDirective(this IDirectiveContext context)
{
var node = context.Directive.ToNode(removeNullArguments: false);
CultureInfo culture;
var cultureArgument = node.Arguments.FirstOrDefault(t => t.Name.Value == "culture");
switch (cultureArgument)
[Serializable]
[GraphQLName("locale")]
public sealed class LocaleDirective : ISerializable
{
public LocaleDirective(CultureInfo culture)
{
Culture = culture;
}
LocaleDirective(SerializationInfo info, StreamingContext context)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json;
using StrawberryShake;
using StrawberryShake.Configuration;
using StrawberryShake.Http;
using StrawberryShake.Http.Subscriptions;
using StrawberryShake.Transport;
// This file was initially generated by Windows Terminal (Unpackaged) 0.11.200421001-release0.11
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
macro_rules! define_core_ast_struct {
(@method [$($m:tt)*] $name:ident StringId) => {
$($m)*
pub fn $name<'a, 'ctx: 'a>(&'a self, context: &'ctx Context) -> &'ctx str {
&context.strings.lookup(self.$name)
}
};
(@method [$($m:tt)*] $name:ident SliceId<$ty:ident>) => {
$($m)*
pub(crate) struct Id<T: Sized>(NonZeroU32, PhantomData<*const T>);
impl<T: Sized> Clone for Id<T> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<T: Sized> Copy for Id<T> {}
impl<T: Sized> PartialEq for Id<T> {
#[inline]