Skip to content

Instantly share code, notes, and snippets.

View uuhnaut69's full-sized avatar
🎯
Focusing

Tuan Nguyen uuhnaut69

🎯
Focusing
View GitHub Profile
@dabit3
dabit3 / marketplace.sol
Last active March 14, 2024 15:55
NFT Marketplace Smart Contract (V2)
// 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 {
#!/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

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. 🔥

Get the tools

@nayato
nayato / Dockerfile
Last active May 8, 2023 13:36
Dockerfile for rust multistage build sample
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
@kikitux
kikitux / Vagrantfile
Last active June 25, 2023 10:23
Vagrantfile, multi machine with ssh password less and hostname over private network.
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 ''
}
@thomasdarimont
thomasdarimont / KeycloakAdminClientExample.java
Last active April 23, 2024 09:02
Using Keycloak Admin Client to create user with roles (Realm and Client level)
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;
@sebastianwebber
sebastianwebber / README.md
Last active February 19, 2024 11:44
Compilation of the Uber Facts on PostgreSQL to MySQL Migration

Uber facts

Original posts/information

Key points

  • ~50GB MySQL Application
  • Main motivation: PostGis
  • Migration made with a custom tool(xml2pgcopy) and mysqldump on 45min
@valyala
valyala / README.md
Last active April 19, 2024 13:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • 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 never DELETE or UPDATE 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 to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@alexdiliberto
alexdiliberto / get_random_bytes.js
Created February 25, 2016 16:57
Get random bytes in Javascript (Browser/Node)
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;