Skip to content

Instantly share code, notes, and snippets.

@mahfuzsust
mahfuzsust / envrc.plugin.zsh
Created November 22, 2022 09:52
Environment loader plugin for ZSH
if [[ ! $DISABLE_ENVRC -eq 1 ]]; then
_envrc_cwd() {
# if cd in the root dir, there is nothing to do.
if [[ $(pwd) = $ENVRC ]]; then
return 0
fi
# if cwd is not a subdir from root dir, unload env.
if [[ $(pwd) != $ENVRC/* ]]; then
_unload_env
@mahfuzsust
mahfuzsust / AVL.java
Created August 6, 2021 13:24
AVL (Balanced Binary Search Tree)
public class AVL<T extends Comparable<T>> extends BST<T> {
private static final String RIGHT_LEFT = "RL";
private static final String LEFT = "LL";
private static final String LEFT_RIGHT = "LR";
private static final String RIGHT = "RR";
private void rotateLeft(TreeNode<T> node) {
if (node.getParent() != null) {
if (node.getParent().getLeft() == node) {
node.getParent().setLeft(node.getRight());
@mahfuzsust
mahfuzsust / BST.java
Created July 28, 2021 02:56
Binary Search Tree
public class BST {
private Tree root = null;
public BST() {
}
public Tree getRoot() {
return root;
}
@mahfuzsust
mahfuzsust / .vimrc
Last active November 19, 2019 04:14
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'Xuyuanp/nerdtree-git-plugin'
@mahfuzsust
mahfuzsust / ConsumerConfiguration.java
Last active October 10, 2019 17:27
Kafka with Spring boot
package info.mahfuz.kafka.configuration;
import info.mahfuz.kafka.model.User;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
@mahfuzsust
mahfuzsust / kafka_server_start.sh
Last active October 9, 2019 18:06
Kafka server running script
#!/bin/sh
setProperty(){
awk -v pat="^$1=" -v value="$1=$2" '{ if ($0 ~ pat) print value; else print $0; }' $3 > $3.tmp
mv $3.tmp $3
}
downloadAndPrepare() {
DIR="kafka/"
if [[ -d "$DIR" ]]; then
const fs = require('fs');
const readline = require('readline');
const readFile = readline.createInterface({
input: fs.createReadStream('temp.txt'),
output: fs.createWriteStream('temp.out.txt'),
terminal: false
});
readFile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mahfuzsust
mahfuzsust / angularjs_directive_attribute_explanation.md
Created July 12, 2016 16:08 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>