Skip to content

Instantly share code, notes, and snippets.

View pourmand1376's full-sized avatar
😉
Learning

Amir Pourmand pourmand1376

😉
Learning
View GitHub Profile
@pourmand1376
pourmand1376 / main.py
Created August 15, 2023 06:46
Minimal Working Example of FastAPI using LangChain Stream Response
# Answer taken from https://gist.github.com/jvelezmagic/f3653cc2ddab1c91e86751c8b423a1b6
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from langchain.chat_models import ChatOpenAI
from langchain.prompts import PromptTemplate
from pydantic import BaseModel
from typing import AsyncGenerator
@pourmand1376
pourmand1376 / obsidian.sh
Last active August 8, 2023 13:39
Sync Obsidian Android
#!/bin/bash
# Get and validate username
get_name() {
read -p "Enter your name: " name
echo "Username: $name"
if [ -z "$name" ]; then
echo "Name is empty!"
exit 1
@pourmand1376
pourmand1376 / DailyNotesTemplate.md
Last active May 1, 2023 16:44
My Obsidian Templates - تمپلت فارسی من برای ابسیدین
direction date week month quarter year
rtl
<% tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD") %>
<% tp.date.now("YYYY-[W]ww", 0, tp.file.title, "YYYY-MM-DD") %>
<% tp.date.now("YYYY-MM", 0, tp.file.title, "YYYY-MM-DD") %>
<% tp.date.now("YYYY-[Q]Q", 0, tp.file.title, "YYYY-MM-DD") %>
<% tp.date.now("YYYY", 0, tp.file.title, "YYYY-MM-DD") %>

[[ obsidian-notes/Journaling/WeeklyNotes/<% tp.date.now("YYYY-[W]ww", 0, tp.file.title, "YYYY-MM-DD") %> | برنامه این هفته ]] - [[ obsidian-notes/Journaling/MonthlyNotes/<% tp.date.now("YYYY-MM", 0, tp.file.title, "YYYY-MM-DD") %> | برنامه این ماه ]] - [[ obsidian-notes/Journaling/QuarterlyNotes/<% tp.date.now("YYYY-[Q]Q", 0, tp.file.title, "YYYY-MM-DD") %> | برنامه این فصل ]] - [[ obsidian-notes/Journaling/YearlyNotes/<% tp.date.now("YYYY", 0, tp.file.title, "YYYY-MM-DD") %> | برنامه امسال ]]

@pourmand1376
pourmand1376 / git_fix
Created November 28, 2022 08:50
These two lines of code fix whenever there is a mismatch between ubuntu and windows git status
git config core.autocrlf true
git config core.filemode false
@pourmand1376
pourmand1376 / Makefile
Last active November 27, 2022 11:52
My MakeFile Template
.ONESHELL:
SHELL = /bin/bash
CONDA_ACTIVATE = source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate
.PHONY: help
help: update
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'
update: ## pull git updates
@pourmand1376
pourmand1376 / tutorial.md
Created November 9, 2022 15:18 — forked from Makeshift/tutorial.md
Tutorial for automatically syncing an Obsidian vault with Git on an Android device

How to sync Obsidian with Git on Android

Limitations

  • If Termux is closed in the background by Android, the cron service will stop updating your repository and you must open Termux again. Refer to instructions for your device model to disable the killing of certain background applications.
  • This may negatively affect your devices battery life. I'm not entirely sure yet.

Setup

@pourmand1376
pourmand1376 / shecan.sh
Created October 6, 2022 21:47
Add Shecan DNS Server
# https://devilbox.readthedocs.io/en/latest/howto/dns/add-custom-dns-server-on-linux.html
echo "nameserver 178.22.122.100" > /etc/resolv.conf
echo "nameserver 185.51.200.2" > /etc/resolv.conf
@pourmand1376
pourmand1376 / forward.sh
Created September 27, 2022 13:39
Forward Every packet from a server to another!
سلام روز بخیر
روی سرور ایرانتون این کامند رو ران کنید:
sudo apt install iptables-persistent
و بعدش فایل زیر رو باز کنید با nano:
/etc/iptables/rules.v4
این محتویات رو وارد فایل کنید:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
@pourmand1376
pourmand1376 / git-lfs-install.md
Created July 7, 2022 06:53
Single User Installation of Git-LFS without sudo

I wanted to install GIT-Lfs on my user account without access to server root account. I write this to my future self.

  1. Download tar.gz file from git-lfs website.
wget https://github.com/git-lfs/git-lfs/releases/download/v3.2.0/git-lfs-linux-amd64-v3.2.0.tar.gz

2.Untar it

tar xvf git-lfs-linux-amd64-v3.2.0.tar.gz
@pourmand1376
pourmand1376 / sharif_login.sh
Last active February 23, 2024 19:51
Sharif Login
function sharif_login
{
curl -d "username=$1&password=$2" -X POST "https://net2.sharif.edu/login" > /dev/null
curl -s https://net2.sharif.edu/status | grep -o '<td>.*</td>'
sleep 1s # To See login status
}
function sharif_ip
{
# from ping net2.sharif.edu
# this is written since sometimes DNS server doesn't work!