This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.concurrent.atomic.AtomicReference; | |
public final class Combiner { | |
public interface Action { | |
public void apply(); | |
} | |
private static final class Node { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
/* | |
* bitAnd - x&y using only ~ and | | |
* Example: bitAnd(6, 5) = 4 | |
* Legal ops: ~ | | |
* Max ops: 8 | |
* Rating: 1 | |
*/ | |
int bitAnd(int x, int y) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::{ensure, Result}; | |
use reqwest::blocking::Client; | |
use reqwest::StatusCode; | |
use serde::Deserialize; | |
use serde_json::Value; | |
use std::collections::HashMap; | |
use std::env; | |
use std::fs; | |
use std::io::BufReader; | |
use std::time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ElementOf<T> = T extends (infer E)[] ? E : never; | |
type TupleHead<Tuple extends readonly unknown[]> = | |
Tuple extends [infer HeadElement, ...readonly unknown[]] ? HeadElement : never; | |
type TupleTail<Tuple extends readonly unknown[]> = | |
Tuple extends [unknown, ...infer TailElements] ? TailElements : never; | |
type Unique<Tuple extends readonly unknown[]> | |
= Tuple extends [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Access<Tuple extends readonly unknown[], I extends string> = | |
I extends keyof Tuple ? Tuple[I] : never | |
type Swap<Tuple extends readonly unknown[], I extends string, J extends string> = { | |
[Index in keyof Tuple]: Index extends I ? Access<Tuple, J> : Index extends J ? Access<Tuple, I> : Tuple[Index] | |
} | |
type Length<Tuple extends readonly unknown[]> = Tuple["length"] extends number ? `${Tuple["length"]}` : never | |
type PushFront<Tuple extends readonly unknown[], E> = [E, ...Tuple] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is an example program to demonstrate false sharing between threads. | |
* | |
* It can be compiled two ways: | |
* gcc -g false_sharing.c -Wall -pthread -lnuma -o false_sharing | |
* gcc -g false_sharing.c -Wall -pthread -lnuma -DNO_FALSE_SHARING -o no_false_sharing | |
* | |
* The -DNO_FALSE_SHARING macro reduces the false sharing. | |
* | |
* The usage is: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function useAnimationDelay( | |
delay: number, | |
shouldShow: boolean, | |
onHide: () => void = () => { | |
return | |
}, | |
): boolean { | |
const [display, setDisplay] = useState(shouldShow) | |
useEffect(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static IProcessorProvider GetProcessorProvider() | |
{ | |
return new ProcessorProviderFor<TheService>() | |
.RemoveDefaultMediaTypeProcessors() | |
.OnAllOperations(_ => _ | |
.Use(typeof(DataValidationProcessor)) | |
.UseForRequests(typeof(RequestLoggingProcessor))) | |
.OnGetOperation(_ => _ | |
.UseForResponses(typeof(ImageFromTextMediaProcessor), | |
typeof(WaveFromTextMediaProcessor))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.UUID; | |
import java.util.concurrent.ConcurrentHashMap; | |
import java.util.concurrent.TimeUnit; | |
import scala.collection.concurrent.TrieMap; | |
import org.openjdk.jmh.annotations.*; | |
@BenchmarkMode(Mode.AverageTime) |
NewerOlder