Last active
October 24, 2018 14:57
-
-
Save csyhuang/7af16f98a2bad9ca62d04e66c5913b4f to your computer and use it in GitHub Desktop.
Revisions
-
csyhuang revised this gist
Oct 24, 2018 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,4 +88,8 @@ and then run by ``` $ py.test tests/script.py::particular_module --profile ``` ### Create Symlink in Linux On terminal ``` ln -s /folderorfile/link/will/point/to /name/of/the/link ``` -
csyhuang revised this gist
Oct 2, 2018 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,8 @@ ### Profiling of unittests ``` $ python -m cProfile -o profile $(which py.test) $ python -m cProfile -o profile $(which py.test) tests/script.py::particular_module ``` Afterwards, in python ```python -
csyhuang revised this gist
Oct 2, 2018 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -78,6 +78,11 @@ for i in range(len(chunk_description)): .format(time_array[i+1]-time_array[i])) ``` ### Use `pytest-profile` to profile a single test Install via ``` $ pip install pytest-profiling ``` and then run by ``` $ py.test tests/script.py::particular_module --profile ``` -
csyhuang revised this gist
Oct 2, 2018 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,5 +77,8 @@ for i in range(len(chunk_description)): logging.warning('Time needed: {}' .format(time_array[i+1]-time_array[i])) ``` ### Use `pytest-profile` to profile a single test ``` $ py.test tests/script.py::particular_module --profile ``` -
csyhuang revised this gist
Oct 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,7 +60,7 @@ $ git reset --soft HEAD~1 ``` ### Timing parts of a program ```python import logging import time -
csyhuang revised this gist
Oct 2, 2018 . 1 changed file with 22 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,4 +57,25 @@ Reference from [a post on StackOverflow](https://stackoverflow.com/questions/314 ### Undo the last commit (while keeping the changes with `--soft`) ``` $ git reset --soft HEAD~1 ``` ### Timing parts of a program ```{.python} import logging import time time_array,chunk_description = list(), list() time_array.append(time.time()) ... time_array.append(time.time()) chunk_description.append('DimMpMkUser') ... for i in range(len(chunk_description)): if time_array[i+1]-time_array[i]>1.0: logging.warning(chunk_description[i]) logging.warning('Time needed: {}' .format(time_array[i+1]-time_array[i])) ``` -
csyhuang revised this gist
Oct 2, 2018 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,10 @@ with open('readable_format.txt', 'w') as stream: stats.print_stats() ``` ### Test only a particular module (with printouts) ``` pytest --capture=sys script.py::particular_module ``` Reference from [a post on stackOverflow](https://stackoverflow.com/questions/13532531/python-stats-how-do-i-write-it-to-a-human-readable-file) ### Pull changes from another branch and sync with my own -
csyhuang revised this gist
Oct 1, 2018 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,4 +47,10 @@ Optionally push your rebased branch git push origin v1_adminui ``` Reference from [a post on StackOverflow](https://stackoverflow.com/questions/31471790/bitbucket-syncing-branch-with-another-branch?lq=1) ### Undo the last commit (while keeping the changes with `--soft`) ``` $ git reset --soft HEAD~1 ``` -
csyhuang revised this gist
Oct 1, 2018 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ ### Kill all background jobs `kill $(jobs -p)` ### Run unit-testing and time all procedures `pytest --durations=0` ### Profiling of unittests ``` $ python -m cProfile -o profile $(which py.test) ``` @@ -20,7 +20,7 @@ with open('readable_format.txt', 'w') as stream: Reference from [a post on stackOverflow](https://stackoverflow.com/questions/13532531/python-stats-how-do-i-write-it-to-a-human-readable-file) ### Pull changes from another branch and sync with my own Get the base branch: ``` -
csyhuang revised this gist
Oct 1, 2018 . 1 changed file with 30 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,4 +18,33 @@ with open('readable_format.txt', 'w') as stream: stats.print_stats() ``` Reference from [a post on stackOverflow](https://stackoverflow.com/questions/13532531/python-stats-how-do-i-write-it-to-a-human-readable-file) #### To pull changes from another branch and sync with my own Get the base branch: ``` $ git checkout v1 ``` Pull in any changes to make sure you have the latest version ``` git pull ``` Check out your branch ``` git checkout v1_adminui ``` Rebase your changes on top of the v1 changes ``` git rebase v1 ``` Optionally push your rebased branch ``` git push origin v1_adminui ``` Reference from [a post on StackOverflow](https://stackoverflow.com/questions/31471790/bitbucket-syncing-branch-with-another-branch?lq=1) -
csyhuang revised this gist
Sep 28, 2018 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,6 @@ Afterwards, in python ```python import pstats import sys with open('readable_format.txt', 'w') as stream: stats = pstats.Stats('profile', stream=stream) -
csyhuang revised this gist
Sep 28, 2018 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,14 @@ Afterwards, in python ```python import pstats import sys #p = pstats.Stats('profile') #p.strip_dirs() #p.sort_stats('tottime') #p.print_stats() with open('readable_format.txt', 'w') as stream: stats = pstats.Stats('profile', stream=stream) stats.print_stats() ``` Reference from [a post on stackOverflow](https://stackoverflow.com/questions/13532531/python-stats-how-do-i-write-it-to-a-human-readable-file) -
csyhuang revised this gist
Sep 28, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,9 @@ $ python -m cProfile -o profile $(which py.test) Afterwards, in python ```python import pstats import sys p = pstats.Stats('profile') p.strip_dirs() p.sort_stats('tottime') p.print_stats() ``` -
csyhuang revised this gist
Sep 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ $ python -m cProfile -o profile $(which py.test) ``` Afterwards, in python ```python import pstats p = pstats.Stats('profile') p.strip_dirs() -
csyhuang revised this gist
Sep 28, 2018 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,12 @@ #### Profiling of unittests ``` $ python -m cProfile -o profile $(which py.test) ``` Afterwards, in python ```{python} import pstats p = pstats.Stats('profile') p.strip_dirs() p.sort_stats('tottime') p.print_stats(50) ``` -
csyhuang revised this gist
Sep 28, 2018 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,9 @@ `kill $(jobs -p)` #### Run unit-testing and time all procedures `pytest --durations=0` #### Profiling of unittests ``` $ python -m cProfile -o profile $(which py.test) ``` -
csyhuang revised this gist
Sep 27, 2018 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,5 @@ #### Kill all background jobs `kill $(jobs -p)` #### Run unit-testing and time all procedures `pytest --durations=0` -
csyhuang revised this gist
Sep 25, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ #### Kill all background jobs `kill $(jobs -p)` -
csyhuang created this gist
Sep 25, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ # Kill all background jobs `kill $(jobs -p)`