Skip to main content

Posts

Showing posts from August, 2019

fork and sync a github project to bitbucket

First create an empty repository on Bitbucket. Then clone it locally git clone git@bitbucket.org:benlongstaff/forked-repo.git cd forked-repo Now add Github repo as a new remote in Bitbucket called “sync” git remote add sync git@github.com:something/original-repo.git Verify the remotes, it should look something like Summer:forked-repo benlongstaff$ git remote -v origin git@bitbucket.org:benlongstaff/forked-repo.git (fetch) origin git@bitbucket.org:benlongstaff/forked-repo.git (push) sync git@github.com:something/original-repo.git (fetch) sync git@github.com:something/original-repo.git (push) Pull from the master branch in the sync remote. git pull sync master Setup a local branch to track the sync remote’s master branch git branch --track github-master sync/master Push the local master branch to the origin remote in Bitbucket. git push -u origin master To merge in changes from the original repo pull them down into the  github-master  branch and then rebase master

running jupyter notebook in a virtual environment

https://stackoverflow.com/questions/33496350/execute-python-script-within-jupyter-notebook-using-a-specific-virtualenv Here's what worked for me (non  conda  python): (MacOS, brew version of python. if you are working with system python, you may (will) need prepend each command with  sudo ) first activate virtualenv if starting afresh then, e.g., you could use virtualenvwrapper $pip install virtualenvwrapper $mkvirtualenv - p python2 py2env $workon py2env # This will activate virtualenv ( py2env ) $ # Then install jupyter within the active virtualenv ( py2env ) $ pip install jupyter # jupyter comes with ipykernel, but somehow you manage to get an error due to ipykernel, then for reference ipykernel package can be installed using: ( py2env ) $ pip install ipykernel Next, set up the kernel ( py2env ) $ python - m ipykernel install -- user -- name py2env -- display - name "Python2 (py2env)" then start jupyter notebook (the venv need not be activated f

decorator in python example

'''                             Online Python Compiler.                 Code, Compile, Run and Debug python program online. Write your code in this editor and press "Run" button to execute it. ''' def anotherFunc():     print("calling another function from decorator")     def deco1(func):     def inner(*args, **kwargs):         print("before1")         # anotherFunc()         func(*args, **kwargs)         # func()         print("after1")     return inner def deco2(func):     def inner(*args, **kwargs):         print("before2")         # anotherFunc()         func(*args, **kwargs)         # func()         print("after2")     return inner @deco1 @deco2 def testfunc(test1, test2, test3):     print("Hello World")     testfunc("hira", "jira", "sira") output: before1