Skip to content

Instantly share code, notes, and snippets.

View ramesh960386's full-sized avatar

Ramesh Yele ramesh960386

View GitHub Profile
@ramesh960386
ramesh960386 / s3_to_pandas.py
Created February 14, 2023 11:01 — forked from duncangh/s3_to_pandas.py
Read CSV (or JSON etc) from AWS S3 to a Pandas dataframe
import boto3
import pandas as pd
from io import BytesIO
bucket, filename = "bucket_name", "filename.csv"
s3 = boto3.resource('s3')
obj = s3.Object(bucket, filename)
with BytesIO(obj.get()['Body'].read()) as bio:
df = pd.read_csv(bio)
@ramesh960386
ramesh960386 / middleware.py
Created January 5, 2022 10:27 — forked from jsanchezpando/middleware.py
Simple Django super class to track user and save creator and modifier of a Model.
from myapp.utils import set_current_user
class CurrentUserMiddleware:
def process_request(self, request):
set_current_user(getattr(request, 'user', None))
import requests
headers = {
'Authorization': 'Token c0efa4be06a92f8b60dc4f818b30eb468041fdd7'
}
def getToken(username, password):
url = f"http://127.0.0.1:8000/api-token-auth/ username={username} password={password}"
# settings.py
# Step-1
######################################################################################################################
INSTALLED_APPS = [
'rest_framework',
'rest_framework.authtoken'
]
$RequestHeader = @{};
$RequestHeader.Add("Authorization", "token c0efa4be06a92f8b60dc4f818b30eb468041fdd7");
$api_host = "http://localhost:8000"
#$final_url = "{0}{1}" -f $api_host,'/api/cart-items/'
#Invoke-RestMethod http://localhost:8000/api/cart-items/ -Method GET -Header(@{"Authorization" = "token c0efa4be06a92f8b60dc4f818b30eb468041fdd7"})
#################################################################################################################################
#GET Method for Fetch All objects
$GetAllUrl = "$api_host/api/cart-items/"
#Invoke-RestMethod $GetAllUrl -Method GET -Headers $RequestHeader
import threading
import time
# backup_config = {
# "backup_pc": ["PC-10", "PC-20", "PC-30"],
# "back_up_timer": [2, 4, 3]
# }
# print(backup_config['backup_pc'])
from concurrent.futures import ThreadPoolExecutor
import time
def wait_function(x, y):
print('Task(', x,'multiply', y, ') started')
time.sleep(2)
print('Task(', x,'multiply', y, ') completed')
return x * y
def callback_function(future):
@ramesh960386
ramesh960386 / install virtualenv ubuntu 16.04.md
Created November 27, 2021 08:38 — forked from frfahim/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
@ramesh960386
ramesh960386 / git-ssh-error-fix.sh
Created November 23, 2021 04:56 — forked from Tamal/git-ssh-error-fix.sh
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
$ # This should also timeout
$ ssh -T [email protected]
ssh: connect to host github.com port 22: Connection timed out
$ # but this might work
[settings]
DEBUG=True
SECRET_KEY=y#bz$z0prv)@bie(@3wa@=--ana7%%k!hvo)b-3d4#0mnhh0pi6
AWS_ACCESS_KEY_ID=M5YCPZP3QT36OWMMZS23
AWS_SECRET_ACCESS_KEY=5Npq/S/7tX2IqBl51p3QEAMJuuGvHuFH4680Cl59M3s
AWS_STORAGE_BUCKET_NAME=open-api-space
AWS_S3_ENDPOINT_URL=https://nyc3.digitaloceanspaces.com
AWS_LOCATION=open-api-static