- 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} '| #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 | |
| */ |
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} '| #include "Semaphore.hpp" | |
| #include <chrono> | |
| #include <condition_variable> | |
| #include <cstdint> | |
| #include <iostream> | |
| #include <string> | |
| #include <thread> | |
| using namespace std; |
| 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 gist is inspired on Scott Meyers video about Processor Cache, and why you should care about it.
| import java.util.*; | |
| class ReversePolishCalculator { | |
| interface Operation { | |
| int calculate(int a, int b); | |
| } | |
| enum MathOperation implements Operation { | |
| ADD('+') { |