Skip to content

Instantly share code, notes, and snippets.

View AbrarNitk's full-sized avatar
🎯
Focusing

Abrar Khan AbrarNitk

🎯
Focusing
View GitHub Profile
@AbrarNitk
AbrarNitk / Ubuntu-Setup.txt
Last active August 26, 2024 06:22
Install zsh, oh-my-zsh, postgres, java, maven, rust, pyenv, pyenv-virtualenv on Ubuntu-linux
## update machine
sudo apt-get update
## Install essentials and basic utility
sudo apt install -y \
build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
@AbrarNitk
AbrarNitk / emi.py
Created September 14, 2019 16:24
Calculate Emi monthly with reducing price, calculate monthly payable interest and calculate monthly principal amount
"""
L = Loan Amount
I = Interest Rate Per Month
N = Loan Period in Months
EMI = (Loan * I) * ((1 + I)^N) / ((1 + I)^N) - 1))
"""
import math
import csv
print("Enter Amount :: ")
@AbrarNitk
AbrarNitk / lib.rs
Created August 14, 2019 11:07
Proc macro for realm_page
use proc_macro::{TokenStream};
use syn::{ItemFn, ItemStruct, DeriveInput, parse::{Parse, ParseStream, Result}, LitStr, Token};
#[derive(Debug)]
struct PathArgs {
id: String,
}
mod keyword {
@AbrarNitk
AbrarNitk / lib.rs
Created August 14, 2019 11:06
Proc macro for realm_page
use proc_macro::{TokenStream};
use syn::{ItemFn, ItemStruct, DeriveInput, parse::{Parse, ParseStream, Result}, LitStr, Token};
#[derive(Debug)]
struct PathArgs {
id: String,
}
mod keyword {
@AbrarNitk
AbrarNitk / proc_macro_test.rs
Created August 2, 2019 15:46
Proc macro example RUST
// crate name proc_macro_test
//File Cargo.toml
// [package]
// name = "proc_macro_test"
// version = "0.1.0"
// authors = ["AbrarNitk <[email protected]>"]
// edition = "2018"
// [lib]
@AbrarNitk
AbrarNitk / rust_trait_ser_der.rs
Created June 26, 2019 13:51
Rust Trait Object Serialize/Deserialize
use crate::frame::Frame;
use chrono::prelude::*;
use std::fmt::Debug;
use typetag;
#[typetag::serde(tag = "type", content = "value")]
pub trait Queue: Debug {
fn print_me(&self);
}
@AbrarNitk
AbrarNitk / .vimrc
Created April 19, 2019 04:46 — forked from JeffreyWay/.vimrc
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
# Friendly Color Names
Black="\[\033[0;30m\]"
Dark_Gray="\[\033[1;30m\]"
Blue="\[\033[0;34m\]"
Light_Blue="\[\033[1;34m\]"
Green="\[\033[0;32m\]"
Light_Green="\[\033[1;32m\]"
Cyan="\[\033[0;36m\]"
Light_Cyan="\[\033[1;36m\]"
pub fn subset(arr: &Vec<String>, st: usize, end: usize, reserve: &mut Vec<String>, subsets: &mut Vec<Vec<String>>) {
for index in st..end {
reserve.push(arr[index].clone());
subsets.push(reserve.clone());
subset(&arr, index + 1, end, reserve, subsets);
reserve.pop();
}
}
fn main() {
@AbrarNitk
AbrarNitk / subset.rs
Created March 7, 2019 06:33
Find subset of a vector
pub fn find_subset(arr: &Vec<i32>, st: i32, end: i32, init: &mut Vec<i32>, new_index: i32, count: &mut usize, v: &mut Vec<Vec<i32>>) {
for index in st..end {
*count += 1;
init[new_index as usize] = arr[index as usize];
v.push((&init[0..(*count) as usize]).to_vec());
find_subset(arr, index + 1, end, init, new_index + 1, count, v);
*count -= 1;
}
}