Skip to content

Instantly share code, notes, and snippets.

View skynode's full-sized avatar
💭
I may be slow to respond.

Obi skynode

💭
I may be slow to respond.
  • Amsterdam, The Netherlands
View GitHub Profile
@skynode
skynode / combining-git-repositories.md
Created May 3, 2022 10:19 — forked from msrose/combining-git-repositories.md
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

// This is a port of the amd/win-libm implementation provided in assembly here: https://github.com/amd/win-libm/blob/master/sinf.asm
// The original source is Copyright (c) 2002-2019 Advanced Micro Devices, Inc. and provided under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this Software and associated documentaon files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
@skynode
skynode / .NET6Migration.md
Created October 7, 2021 00:12 — forked from davidfowl/.NET6Migration.md
.NET 6 ASP.NET Core Migration
@skynode
skynode / kubectl.md
Created August 14, 2021 02:07 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@skynode
skynode / AsyncEnumerableExtensions.cs
Created February 25, 2021 16:38 — forked from DCCoder90/AsyncEnumerableExtensions.cs
Convert IEnumerable to IAsyncEnumerable
public static class AsyncEnumerableExtensions
{
public static IAsyncEnumerable<TResult> SelectAsync<T, TResult>(this IEnumerable<T> enumerable,
Func<T, Task<TResult>> selector)
{
return AsyncEnumerable.CreateEnumerable(() =>
{
var enumerator = enumerable.GetEnumerator();
var current = default(TResult);
@skynode
skynode / helm-cheatsheet.md
Created January 17, 2021 07:30 — forked from tuannvm/cka.md
#Helm #Kubernetes #cheatsheet, happy helming!
@skynode
skynode / AsyncLazy.cs
Created June 16, 2020 05:37
AsyncLazy<T> - Stephen Cleary
/// <summary>
/// Provides support for asynchronous lazy initialization. This type is fully threadsafe.
/// </summary>
/// <typeparam name="T">The type of object that is being asynchronously initialized.</typeparam>
public sealed class AsyncLazy<T>
{
/// <summary>
/// The underlying lazy task.
/// </summary>
private readonly Lazy<Task<T>> instance;
@skynode
skynode / JSONInputStream.diff
Created November 8, 2019 04:39 — forked from KengoTODA/JSONInputStream.diff
InputStream from JSONObject. This class will help feeding JSON from the application server.
diff --git a/JSONInputStream.java b/JSONInputStream.java
new file mode 100644
index 0000000..93708ff
--- /dev/null
+++ b/JSONInputStream.java
@@ -0,0 +1,75 @@
+package org.json;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
@skynode
skynode / IndexedPrivilege.md
Created November 7, 2019 10:58 — forked from pthariensflame/IndexedPrivilege.md
An introduction to the indexed privilege monad in Haskell, Scala and C#.

The Indexed Privilege Monad in Haskell, Scala, and C#

We've already looked at two different indexed monads in our tour so far, so let's go for a third whose regular counterpart isn't as well known: the privilege monad.

Motivation

The regular privilege monad allows you to express constraints on which operations a given component is allowed to perform. This lets the developers of seperate interacting components be statically assured that other components can't access their private state, and it gives you a compile-time guarantee that any code that doesn't have appropriate permissions cannot do things that would require those permissions. Unfortunately, you cannot easily, and sometimes cannot at all, build code in the privilege monad that gains or loses permissions as the code runs; in other words, you cannot (in general) raise or lower your own privilege level, not even when it really should be a

@skynode
skynode / IndexedState.md
Created June 7, 2019 00:12 — forked from pthariensflame/IndexedState.md
An introduction to the indexed state monad in Haskell, Scala, and C#.

The Indexed State Monad in Haskell, Scala, and C#

Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)

Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)

If that's the case, the indexed state monad can help!

Motivation