I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "hardhat/console.sol"; | |
contract NFTMarketplace is ERC721URIStorage { |
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
#!/bin/bash | |
# Script to enable oplog tailing in a production meteor deployment using mongodb 4.0 or later | |
echo "# Enabling replication, required for oplog tailing" >> /etc/mongod.conf | |
echo "replication:" >> /etc/mongod.conf | |
echo " oplogSizeMB: 100" >> /etc/mongod.conf | |
echo " replSetName: rs0" >> /etc/mongod.conf | |
systemctl restart mongod |
Install logical decoding plugin
- decoderbufs plugin
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
FROM rustlang/rust:nightly as builder | |
WORKDIR /app/src | |
RUN USER=root cargo new --bin ht | |
COPY Cargo.toml Cargo.lock ./ht/ | |
WORKDIR /app/src/ht | |
RUN cargo build --release | |
COPY ./ ./ | |
RUN cargo build --release |
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
numnodes=2 | |
baseip="192.168.10" | |
#global script | |
$global = <<SCRIPT | |
#check for private key for vm-vm comm | |
[ -f /vagrant/id_rsa ] || { | |
ssh-keygen -t rsa -f /vagrant/id_rsa -q -N '' | |
} |
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
package demo.plain; | |
import org.keycloak.OAuth2Constants; | |
import org.keycloak.admin.client.CreatedResponseUtil; | |
import org.keycloak.admin.client.Keycloak; | |
import org.keycloak.admin.client.KeycloakBuilder; | |
import org.keycloak.admin.client.resource.RealmResource; | |
import org.keycloak.admin.client.resource.UserResource; | |
import org.keycloak.admin.client.resource.UsersResource; | |
import org.keycloak.representations.idm.ClientRepresentation; |
- ~50GB MySQL Application
- Main motivation: PostGis
- Migration made with a custom tool(xml2pgcopy) and mysqldump on 45min
- Create
UNLOGGED
table. This reduces the amount of data written to persistent storage by up to 2x. - Set
WITH (autovacuum_enabled=false)
on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we neverDELETE
orUPDATE
the table). - Insert rows with
COPY FROM STDIN
. This is the fastest possible approach to insert rows into table. - Minimize the number of indexes in the table, since they slow down inserts. Usually an index
on
time timestamp with time zone
is enough. - Add
synchronous_commit = off
topostgresql.conf
. - Use table inheritance for fast removal of old data:
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
let getRandomBytes = ( | |
(typeof self !== 'undefined' && (self.crypto || self.msCrypto)) | |
? function() { // Browsers | |
var crypto = (self.crypto || self.msCrypto), QUOTA = 65536; | |
return function(n) { | |
var a = new Uint8Array(n); | |
for (var i = 0; i < n; i += QUOTA) { | |
crypto.getRandomValues(a.subarray(i, i + Math.min(n - i, QUOTA))); | |
} | |
return a; |
NewerOlder