Skip to content

Instantly share code, notes, and snippets.

View neotheicebird's full-sized avatar

prash neotheicebird

  • Chennai
View GitHub Profile
@neotheicebird
neotheicebird / Flake8.txt
Created November 16, 2018 21:11 — forked from tossmilestone/Flake8.txt
Flake8 integrated with PyCharm
How to manually setup flake8 as PyCharm external tool
File / Settings / Tools / External Tools / Add
Name: Flake8
Program: $PyInterpreterDirectory$/python
Parameters: -m flake8 --max-complexity 10 --ignore E501 $FilePath$
Working directory: $ProjectFileDir$
Output Filters / Add
Name: Filter 1
@neotheicebird
neotheicebird / staircase_lr_decay_tf.py
Created March 5, 2017 20:40
A staircase learning rate decay #tensorflow
# Ref: https://github.com/ericjang/genadv_tutorial/blob/master/genadv1.ipynb
learning_rate = tf.train.exponential_decay(
0.001, # Base learning rate.
batch, # Current index into the dataset.
TRAIN_ITERS // 4, # Decay step - this decays 4 times throughout training process.
0.95, # Decay rate.
staircase=True)
@neotheicebird
neotheicebird / reduce_json_dicts.py
Last active November 20, 2016 18:57
Get an item from a dictionary obtained from a JSON object obtained from a WEB API (not any JSON). Input: List of keys, e.g ["key_1", "key_2", 5, "key_4"]. Output: An item of type <str>, <list>, or<dict>
def get_from_json_dict(json_dict, keys, default_dict=None):
for index, key in enumerate(keys):
if isinstance(json_dict, dict) and isinstance(key, str): # check if you have a `dict` and `str` in hand
# get item of the key from json_dict, if key is Bad, get item from default_dict, or get None
json_dict = json_dict.get(key, default_dict[key] if default_dict else None)
if default_dict:
default_dict = default_dict[key] # reducing default dict
continue
if isinstance(json_dict, list) and isinstance(key, int): # check if you have a `list` and `int` in hand
@neotheicebird
neotheicebird / reduce_nested_dicts.py
Last active November 20, 2016 19:39
Get item contained in depths of nested dicts, using a list of keys. If a valid item cant be found, returns a None
# get only the first element
checkout_curse = reduce(lambda curses_dict, key: dict.get(key), [curses_dict, "curses", "names", 0])
@neotheicebird
neotheicebird / access_webcam_matplotlib_notebook_sigint.ipynb
Last active August 17, 2021 21:03
Acces webcam for image processing. SIGINT signal is captured to exit while loop.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2016-11-01T17:33:15.254949",
"start_time": "2016-11-01T17:33:12.700730"
},
@neotheicebird
neotheicebird / access_webcam_matplotlib_inline.ipynb
Last active October 25, 2020 10:02
Access webcam in iPython notebook (Slower version)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neotheicebird
neotheicebird / access_webcam_matplotlib_notebook.ipynb
Last active April 10, 2019 23:13
Access Webcam in iPython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pickle # pickle is py2 equivalent of cPickle
# if a Py2 cPickle object shows UnicodeError in Py3
with open(picklefile, 'rb') as f
d = pickle.load(f, encoding='latin1')
import requests
url = "http://www.matthewzeiler.com/pubs/arxive2013/eccv2014.pdf"
r = requests.get(url)
pdffile = r.url.split('/')[-1]
with open(pdffile, 'wb') as pdf:
pdf.write(r.content)