Skip to content

Instantly share code, notes, and snippets.

View raaghulr's full-sized avatar

Raaghul R raaghulr

View GitHub Profile
@raaghulr
raaghulr / noip-dyndns-update.py
Created September 6, 2023 11:37 — forked from imvaskii/noip-dyndns-update.py
A python (python3) script to update no-ip (https://www.noip.com) dynamic dns ip.
#!/usr/bin/env python
import requests, socket
username = ""
password = ""
hostname = "" # your domain name hosted in no-ip.com
# Gets the current public IP of the host machine.
myip = requests.get('http://api.ipify.org').text
@raaghulr
raaghulr / async_download_files.py
Created November 12, 2022 06:04 — forked from darwing1210/async_download_files.py
Script to download files in a async way, using Python asyncio
import os
import asyncio
import aiohttp # pip install aiohttp
import aiofiles # pip install aiofiles
REPORTS_FOLDER = "reports"
FILES_PATH = os.path.join(REPORTS_FOLDER, "files")
def download_files_from_report(urls):
@raaghulr
raaghulr / oracle-cloud-free-tier-guide.md
Created September 24, 2022 13:49 — forked from rssnyder/oracle-cloud-free-tier-guide.md
oracle-cloud-free-tier-guide

how to leverage oracle's temping offers

free tier limits

The limits of the free tier say that you can create up to 4 instances.

  • x2 x86 instances (2core/1g)
  • x2 ampere instances (with 4core/24g spread between them)
  • 200GB total boot volume space across all intances (minimum of 50G per instance)

create your account

@raaghulr
raaghulr / curl-websocket.sh
Created July 13, 2022 04:25 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@raaghulr
raaghulr / create-kiteconnect-candlestick-q.py
Created June 26, 2022 17:21 — forked from oldmonkABA/create-kiteconnect-candlestick-q.py
Implementation of ticks to 1min and 15 mins candles in zerodha kiteconnect using python queues. This code is modified version of the code given in http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html. The difference is that in on_ticks functions the only action performed is that the ticks are place in a event queue. This …
################## Ticks to candles in kiteconnect python ####################
# Author : Arun B
# Reference : http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html
# Purpose : Convert ticks to candles by putting ticks in a queue. This redues time wasted in on_ticks function
################################################################################
from kiteconnect import KiteTicker
import datetime
from copy import copy
import queue
@raaghulr
raaghulr / nas_client.py
Created May 19, 2022 04:28 — forked from fkromer/nas_client.py
Super simple client to get files from/write files to a NAS.
# License: Apache-2.0
# Copyright: Florian Kromer 2020
from smb.SMBConnection import SMBConnection
from typing import List, Union
from smb.base import SharedDevice, SharedFile
from tempfile import NamedTemporaryFile
class NasServerClient:
@raaghulr
raaghulr / connect_psycopg2_to_pandas.py
Created May 10, 2022 03:47 — forked from jakebrinkmann/connect_psycopg2_to_pandas.py
Read SQL query from psycopg2 into pandas dataframe
import pandas as pd
import pandas.io.sql as sqlio
import psycopg2
conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
sql = "select count(*) from table;"
dat = sqlio.read_sql_query(sql, conn)
conn = None
@raaghulr
raaghulr / wsl2-memory-cap-docker-settings
Created March 8, 2022 14:53
WSL Memory Cap - Limit CPU/Memory When using Docker
# turn off all wsl instances such as docker-desktop
wsl --shutdownnotepad "$env:USERPROFILE/.wslconfig"
[wsl2]
memory=3GB # Limits VM memory in WSL 2 up to 3GB
processors=4 # Makes the WSL 2 VM use two virtual processors
#credits: https://itnext.io/wsl2-tips-limit-cpu-memory-when-using-docker-c022535faf6f
@raaghulr
raaghulr / README.md
Created March 6, 2022 05:13 — forked from quiver/README.md
Who says PostgreSQL can't Pub/Sub like Redis?

Pub/Sub pattern with PostgreSQL's LISTEN/NOTIFY command

This is a simple chat-like program using pub-sub pattern, backed by PostgreSQL's LISTEN/NOTIFY command.

Publish

publish message to foo channel from user nickname.

$ python pub.py foo nickname
PUBLISH to channel #foo
@raaghulr
raaghulr / upsert_df.py
Created February 17, 2022 04:35 — forked from pedrovgp/upsert_df.py
Allow upserting a pandas dataframe to a postgres table (equivalent to df.to_sql(..., if_exists='update')
# Upsert function for pandas to_sql with postgres
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT
import pandas as pd
import sqlalchemy
import uuid
import os
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine):