Skip to content

Instantly share code, notes, and snippets.

View sovietspy2's full-sized avatar
💩
will code for food

Barney Dono sovietspy2

💩
will code for food
View GitHub Profile
@sovietspy2
sovietspy2 / venv.sh
Created November 12, 2023 14:34
create venv in current directory or activate venv is present
#!/bin/bash
# Define the name for the virtual environment
venv_name="venv"
# Check if the virtual environment already exists
if [ -d "$venv_name" ]; then
echo "Activating existing virtual environment..."
source "$venv_name/bin/activate"
else
@sovietspy2
sovietspy2 / Main.java
Last active September 28, 2023 14:33
much java so safe
package org.example.inheritance;
import java.lang.reflect.Field;
public class Main2 {
public static void main(String[] args) {
Child child = new Child();
@sovietspy2
sovietspy2 / aws.md
Created December 23, 2022 09:25
how to aws networking

AWS

VPC

define network

Subnet

  • by defautl every subnet is private
  • add NAT to public subnet
  • attach IGW to public subnet
  • enable auto elastic ip assignment for public subnet
@sovietspy2
sovietspy2 / file.java
Created August 18, 2022 14:37
Java stuff
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
for (Integer i : arr) {
// MAP COMPUTE EXAMPLE
map.compute(i, (key,val) -> {
if (val==null) {
return 0;
} else {
return val+1;
}
@sovietspy2
sovietspy2 / docker-compose.yml
Created October 28, 2021 14:33
Kafka+Zookeeper+KafkaDrop
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
@sovietspy2
sovietspy2 / show_nginx_modules.sh
Created August 30, 2021 13:48
This will list all enabled modules of nginx service
nginx -V 2>&1 | tr ' ' '\n'
@sovietspy2
sovietspy2 / log4js2-spring.xml
Created February 26, 2021 14:54
Springboot ELK stack logging config for log4js (logstash)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
</Console>
<RollingFile name="RollingFile"
fileName="./logs/spring-boot-logger-log4j2.log"
@sovietspy2
sovietspy2 / local-mongo-replicaset-with-docker
Created September 29, 2020 15:05 — forked from oleurud/local-mongo-replicaset-with-docker
[Local mongo replicaset with docker] #docker #mongo
# pull the official mongo docker container
docker pull mongo
# create network
docker network create my-mongo-cluster
# create mongos
docker run -d --net my-mongo-cluster -p 27017:27017 --name mongo1 mongo mongod --replSet my-mongo-set --port 27017
docker run -d --net my-mongo-cluster -p 27018:27018 --name mongo2 mongo mongod --replSet my-mongo-set --port 27018
docker run -d --net my-mongo-cluster -p 27019:27019 --name mongo3 mongo mongod --replSet my-mongo-set --port 27019
@sovietspy2
sovietspy2 / nodejsMongodbTransaction.js
Created September 28, 2020 09:22
Nodejs mongodb transaction example
const { MongoClient } = require('mongodb');
// CRUD operations in transactions must be on existing collections, so be sure you have run
// usersCollection.js prior to running this script.
async function main() {
/**
* Connection URI. Update <username>, <password>, and <your-cluster-url> to reflect your cluster.
* See http://bit.ly/NodeDocs_lauren for more details
*/
@sovietspy2
sovietspy2 / createReadStreamExample.js
Created September 10, 2020 10:50
createReadStreamExample.js
const { createReadStream } = require("fs");
async function run() {
const stream = createReadStream("./test.txt",{ highWaterMark: 4 });
console.log("start")
for await (let chunk of stream) {
console.log(chunk.toString('utf-8'));
}
console.log("done")