Skip to content

Instantly share code, notes, and snippets.

@oldmonkABA
oldmonkABA / automatic-login-kiteconnect-selenium.py
Last active March 3, 2022 16:52
This code demonstrates the automatic process of generating access token for kiteconnect using headless firefox browser
#######################################################################
# Author : Arun B
#
# Purpose : Automate the process of generating access token for kiteconnect in python
############################################################################
# For this code to run you have to download geckodriver and put it in /usr/local/bin
from kiteconnect import KiteConnect,KiteTicker
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
@AlokGaira
AlokGaira / API-MasterList.txt
Last active June 1, 2025 16:15
Sample strateries in Python using UpstoxAPI
class Session:
__init__(api_key)
set_api_secret(api_secret)
set_redirect_uri(redirect_uri)
set_code(code)
get_login_url(self)
retrieve_access_token(self)
class Upstox:
@rochacbruno
rochacbruno / markdocs_idea.md
Last active February 2, 2021 18:22
Using markdocs to Python documentation (markdown) - Idea - WIP

UNDER DEVELOPMENT HERE: https://github.com/rochacbruno/markdocs


Python documentation

I still think that the problem of lack of good documentation in the Python ecosystem is also related to .rst format and the use of complicated tools like Sphinx.

I'm enjoying writing functional documentation using Markdown in Rustlang, so I'll do experiments to have the same functionality in Python. Take a look at rustdoc and here an example of documentation site generated for a Rust crate using markdown comments.

@adippel
adippel / ws4pyReconnectClient.py
Created March 24, 2017 08:15
ws4py Client implementing reconnection logic
import time
import socket
import threading
import logging
from ws4py.client import WebSocketBaseClient
from ws4py.streaming import Stream
logger = logging.getLogger(__name__)
@bdarnell
bdarnell / streaming.py
Created January 11, 2015 21:23
Demo of streaming requests with Tornado
"""Demo of streaming requests with Tornado.
This script features a client using AsyncHTTPClient's body_producer
feature to slowly produce a large request body, and two server
handlers to receive this body (one is a proxy that forwards to the
other, also using body_producer).
It also demonstrates flow control: if --client_delay is smaller than
--server_delay, the client will eventually be suspended to allow the
server to catch up. You can see this in the logs, as the "client
@dedunumax
dedunumax / .gitignore Java
Last active October 19, 2025 04:39
A complete .gitignore file for Java.
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
@terrywang
terrywang / nginx.conf
Last active July 28, 2022 23:29
Nginx config file template for self-hosted personal site on Fedora, Ubuntu, Debian and Arch Linux
# User and group used by worker processes
# ubuntu
# user www-data;
# fedora
user nginx;
# Ideally # of worker processes = # of CPUs or cores
# Set to auto to autodetect
# max_clients = worker_processes * worker_connections
worker_processes auto;
@igniteflow
igniteflow / env-context.py
Last active December 12, 2023 16:43
A Python context manager for setting/unsetting environment variables
from contextlib import contextmanager
"""
Usage:
with env_var('MY_VAR', 'foo'):
# is set here
# does not exist here
"""
@sebclaeys
sebclaeys / autodict.py
Created September 19, 2011 20:49
Python autodict: implicitly create a dictionary instead of raising KeyError + support for object-like dot access + dictionary visitor
# Autodict class
# Create new autodict if accessing undefined key
# support dot access syntax (mydict.test == mydict['test'])
class autodict(dict):
def __getitem__(self, name):
if not name in self:
dict.__setitem__(self, name, autodict())
return dict.__getitem__(self, name)
def __getattr__(self, name):
@joninvski
joninvski / bellman.py
Created November 16, 2010 11:31
Bellman ford python implementation
import pdb
"""
The Bellman-Ford algorithm
Graph API:
iter(graph) gives all nodes
iter(graph[u]) gives neighbours of u
graph[u][v] gives weight of edge (u, v)
"""