Giter Site home page Giter Site logo

efficiency's Introduction

efficiency

Pypi Downloads Downloads MIT_License

This is a package of useful one-line logging functions made by Zhijing.

Installation

Requirement: Python 3

pip install --upgrade git+git://github.com/zhijing-jin/efficiency.git
pip install --user -r requirements.txt

Logging Shortcuts

Obtain time:

>>> from efficiency.log import show_time, fwrite
>>> time_stamp = show_time()
	time: 11241933-41
>>> time_stamp
'11241933' # means: Nov 24th, 19:33

Writing out to files by one line:

>>> text = "This is handy!"
>>> fwrite(text, "temp.txt")

Printing out variables (name + value) easily:

>>> num1 = 7
>>> num2 = 2
>>> num3 = 9
>>> show_var(["num1", "num2", "num3"])
num1 : 7
num2 : 2
num3 : 9

ML-Related

>>> from efficiency.log import gpu_mem
>>> gpu_mem(gpu_id=0)
4101 # Currently, GPU Memory of GPU #0 is 4101 MiB
>>> from efficiency.function import set_seed
>>> set_seed(0)
[Info] seed set to: 0 # set the seed for random, numpy and pytorch

Useful Functions

>>> from efficiency.function import shell
>>> stdout, stderr = shell("cat temp.txt")
>>> stdout
b'This is handy!'

Miscellaneous Functions

Formatting README.md Better

This is the way to automatically generate table of contents for an .md file using markdown_toc:

# Step 1. download the file to your local execution path `/usr/local/bin/`
curl \
  https://raw.githubusercontent.com/alexharv074/markdown_toc/master/mdtoc.rb -o \
  /usr/local/bin/mdtoc.rb

# Step 2. generate the ToC in the "copy" mode
mdtoc.rb README.md

# Alternatively, you can automatically add the content to your copyboard and paste it to your .md
mdtoc.rb README.md | pbcopy

efficiency's People

Contributors

zhijing-jin avatar wisartarfun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.