Skip to content

Instantly share code, notes, and snippets.

View xiaozhiliaoo's full-sized avatar
🎯
Focusing

小知了 xiaozhiliaoo

🎯
Focusing
View GitHub Profile
@fifar
fifar / node_affinity.yaml
Created April 20, 2020 06:49
node affinity for CPU and GPU pods
singleuser:
profileList:
- display_name: "Default"
description: |
Tubi Data Runtime
default: True
kubespawner_override:
image: <private-docker-registry>/tubi-data-runtime
node_affinity_preferred:
- weight: 1
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-rsocket</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</exclusion>
<exclusion>
import org.openjdk.jmh.annotations.*;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ExecutionException;
/**
* 40 Core Xeon E5-2660 v3 @ 2.60GHz
*
# wget -i this_file
http://www.oreilly.com/programming/free/files/files/microservices-for-java-developers.pdf
http://www.oreilly.com/programming/free/files/modern-java-ee-design-patterns.pdf
http://www.oreilly.com/programming/free/files/object-oriented-vs-functional-programming.pdf
http://www.oreilly.com/programming/free/files/java-the-legend.pdf
http://www.oreilly.com/programming/free/files/functional-programming-python.pdf
http://www.oreilly.com/programming/free/files/reactive-microservices-architecture-orm.pdf
http://www.oreilly.com/programming/free/files/migrating-cloud-native-application-architectures.pdf
http://www.oreilly.com/programming/free/files/software-architecture-patterns.pdf
@WeirdBob
WeirdBob / GatewayApplication.java
Created November 21, 2017 12:55
Spring cloud gateway response body modification
package examples;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAutoConfiguration
public class GatewayApplication {
@nehanarkhede
nehanarkhede / kafka-transactions.java
Last active March 13, 2022 10:06
Exactly-once guarantees and transactions in Apache Kafka
producer.initTransactions();
try {
producer.beginTransaction();
producer.send(record1);
producer.send(record2);
producer.commitTransaction();
} catch(ProducerFencedException e) {
producer.close();
} catch(KafkaException e) {
producer.abortTransaction();
@dankow
dankow / Deploying_MySQL_in_Production_References.md
Last active May 31, 2020 16:30
References for Deploying MySQL in Production

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@il-kyun
il-kyun / ByteBufTest.java
Last active October 6, 2021 19:35
Java ByteBuffer vs Netty ByteBuf
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
public class ByteBufTest {
public static void main(String[] args) {
// 4 types of buffers
@wojteklu
wojteklu / clean_code.md
Last active September 25, 2024 12:06
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules