This gist is inspired on Scott Meyers video about Processor Cache, and why you should care about it.
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.*; | |
class ReversePolishCalculator { | |
interface Operation { | |
int calculate(int a, int b); | |
} | |
enum MathOperation implements Operation { | |
ADD('+') { |
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.Semaphore; | |
public class Resolution { | |
private static final int EAT_TIME = 3 * 1000; | |
private static final int THINK_TIME = 2 * 1000; | |
private static final int WAIT_TIME = 1 * 1000; | |
private static final int ITERATIONS_NUMBER = 1000; |
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 "Semaphore.hpp" | |
#include <chrono> | |
#include <condition_variable> | |
#include <cstdint> | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
using namespace std; |
- Commands to obtain memory usage by certain key prefix:
redis-cli --scan --pattern "KEY_PREFIX*" | awk '{ print $1 }' | xargs --max-args 1 redis-cli MEMORY USAGE | awk '{total=total + $1} END { print "Total of bytes:", total} '
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 <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
/** | |
* Function to serialize a unsigned 64 bit number to a byte array | |
* The serialization uses Little Endian to store the bytes in the byte array | |
* so, the least significant byte(LSB) is the first byte of array, and the | |
* most significant byte(MSB) is the last byte in the array | |
*/ |