Skip to content

Instantly share code, notes, and snippets.

@francbartoli
francbartoli / demo.py
Created June 2, 2019 12:48 — forked from wshayes/demo.py
[Websocket demo for fastapi] example of broadcast using websockets for fastapi #fastapi #websockets
# From https://github.com/tiangolo/fastapi/issues/258
from typing import List
from fastapi import FastAPI
from starlette.responses import HTMLResponse
from starlette.websockets import WebSocket, WebSocketDisconnect
app = FastAPI()
@tylerburdsall
tylerburdsall / asynchronous_example.py
Last active December 23, 2022 19:34
Example showing asynchronous HTTP request with Python 3.5.0 + asyncio
import requests
import asyncio
from concurrent.futures import ThreadPoolExecutor
from timeit import default_timer
START_TIME = default_timer()
def fetch(session, csv):
base_url = "https://people.sc.fsu.edu/~jburkardt/data/csv/"
with session.get(base_url + csv) as response:
@gaearon
gaearon / minification.md
Last active March 4, 2024 12:45
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@vividvilla
vividvilla / README.md
Created November 10, 2017 09:31
Kite connect Python ticker save to database example

Instructions

@oprietop
oprietop / chromium_desktop.resource.robot
Last active August 11, 2022 09:01
Robot Framework + Selenium + Browsermob Proxy(via RequestsLibrary)
*** Settings ***
Documentation Selenium Grid + BMP
Library Collections
Library OperatingSystem
Library RequestsLibrary
Library SeleniumLibrary
*** Variables ***
${BMP_HOST} bmp
${BMP_PORT} 9090
@ForgottenUmbrella
ForgottenUmbrella / publish_python.md
Last active December 25, 2023 21:49
How to publish Python apps for human beings

How to publish Python apps for human beings

So, you've created a Python app (be it a graphical user interface with Qt or the like, or a simple command line interface). Great! But how are others going to use it? Python applications often have dependencies (e.g. from third-party modules), and they also need a Python interpreter to run them. For a developer, installing all the necessary bits and bobs to make things work is okay, but that's unacceptable for a normal user - they just want to download the thing and run it.

Below are simple instructions to publish your app on the three main operating systems: Windows, macOS and Linux.

@vividvilla
vividvilla / pykiteconnect_streaming_threaded.py
Last active March 9, 2022 17:54
Test Kite Connect data streaming with threaded Raw
import time
import logging
from kiteconnect import WebSocket
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Initialise.
kws = WebSocket("api_key", "public_token", "zerodha_user_id")
# RELIANCE BSE and RELIANCE NSE
@mgoellnitz
mgoellnitz / snip.sh
Last active January 4, 2024 17:57
GitLab Snippet Command Line Tool
#!/bin/bash
#
# Copyright 2016-2021 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@mgoellnitz
mgoellnitz / gist.sh
Last active December 7, 2022 14:37
Gist Command Line Tool for Single File Gists
#!/bin/bash
#
# Copyright 2016-2021 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@wolever
wolever / watchdog.py
Created December 2, 2016 23:57
A simple watchdog for long-running Python processes
"""
A simple watchdog for long running processes which may stall for some reason or
another.
If the main thread hasn't logged progress (by updating
``self.last_progress_time``) in WATCHDOG_HARD_KILL_TIMEOUT, the watchdog
thread will log an error containing the stack trace of all currently running
threads then use ``kill -9`` to kill the main process.
Assumes that a process monitor like supervisor or systemd will then restart