Skip to content

Instantly share code, notes, and snippets.

@yous
yous / server.py
Created December 5, 2016 10:46
Simple multithreaded Flask file server with basic auth
import os.path
from functools import wraps
from flask import Flask, request, Response, redirect
from flask_autoindex import AutoIndex
fileroot = os.path.join(os.path.realpath(os.path.curdir), 'files')
app = Flask(__name__)
idx = AutoIndex(app,
browse_root=fileroot,
add_url_rules=False)
@jsfenfen
jsfenfen / output.png
Created February 17, 2016 07:01 — forked from endolith/output.png
Detecting rotation and line spacing of image of page of text using Radon transform
output.png
@hellpanderrr
hellpanderrr / Python read Excel XML Table.md
Last active March 24, 2021 04:03
Read Excel XML table in a python list
from bs4 import BeautifulSoup
 
def read_excel_xml(path):
    file = open(path).read()
    soup = BeautifulSoup(file,'xml')
    workbook = []
    for sheet in soup.findAll('Worksheet'): 
        sheet_as_list = []
 for row in sheet.findAll('Row'):
@santiagobasulto
santiagobasulto / README.md
Last active May 16, 2021 10:13
Download HumbleBundle books in batch with a simple Python script.

Download HumbleBundle books

This is a quick Python script I wrote to download HumbleBundle books in batch. I bought the amazing Machine Learning by O'Reilly bundle. There were 15 books to download, with 3 different file formats per book. So I scratched a quick script to download all of them in batch.

(Final Result: books downloaded)

@datagrok
datagrok / README.md
Last active June 6, 2021 14:23
Circular imports in Python 2 and Python 3: when are they fatal? When do they work?
@jvanlier
jvanlier / fast.ai-vision-raspberry-pi-4.md
Last active September 8, 2022 04:45
fast.ai for vision on Raspbery pi 4 (Raspbian)

By default, PyTorch team doesn't release packages for ARM architecture. Luckily, someone is supplying unofficial builds (hats off to this person!).

Fast.ai also has a problem: it depends on spaCy, which also doesn't want to build on ARM by default. I'm not going to do NLP, so will install fast.ai without spaCy.

PyTorch

I initially tried using ARM builds from here:

https://github.com/nmilosev/pytorch-arm-builds

@greydanus
greydanus / dynamic_plotting.py
Created October 14, 2016 18:20
Dynamic plotting for matplotlib
"Dynamic plotting in matplotlib. Copy and paste into a Jupyter notebook."
# written October 2016 by Sam Greydanus
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
import time
def plt_dynamic(x, y, ax, colors=['b']):
for color in colors:
ax.plot(x, y, color)
@nrnrnr
nrnrnr / assoc.lua
Created February 18, 2022 21:53
Lua code for association lists on the command line (for use with fish)
#!/usr/bin/env lua5.1
-- assocation list on the command line
--
-- rep is: key1 val1 key2 val2 ...
--
local function succeed(s)
if s ~= true then
io.stdout:write(s, '\n')
@EEVblog
EEVblog / Arduino-IR-TX-NEC
Last active January 25, 2023 20:59
A simple Arduino driver for the NEC (Japanese) Infrared IR protocol. Drive an IR LED direct with your own code. This is a direct pin bit-bang approach, so beware about interrupts and timing difference between hardware. Feel free to use hardware PWM to generate the carrier frequency if you want better accuracy.
//*****************************************
// NEC (Japanese) Infrared code sending library for the Arduino
// Send a standard NEC 4 byte protocol direct to an IR LED on the define pin
// Assumes an IR LED connected on I/O pin to ground, or equivalent driver.
// Tested on a Freetronics Eleven Uno compatible
// Written by David L. Jones www.eevblog.com
// Youtube video explaining this code: http://www.youtube.com/watch?v=BUvFGTxZBG8
// License: Creative Commons CC BY
//*****************************************
@TySkby
TySkby / timeout.py
Last active March 9, 2023 04:24
Timeout decorator/context manager using signals (for Python 3)
#!/usr/bin/env python3
"""Easily put time restrictions on things
Note: Requires Python 3.x
Usage as a context manager:
```
with timeout(10):
something_that_should_not_exceed_ten_seconds()
```