Skip to content

Instantly share code, notes, and snippets.

View aliciawyy's full-sized avatar

Alice Wang aliciawyy

  • Paris, France
  • 13:22 (UTC +02:00)
View GitHub Profile
- https://realpython.com/blog/python/python-virtual-environments-a-primer/
```
sudo apt-get install python3-tk
mkvirtualenv -r requirements.txt -p /usr/bin/python3 py35-venv
```
"""
A script to show the mecanism of 'with' in Python
"""
class Indenter(object):
def __init__(self):
self.level = -1
def print_(self, s):
@aliciawyy
aliciawyy / add_new_ssh_key.txt
Created November 30, 2017 15:04 — forked from fcrobot/add_new_ssh_key.txt
Add a new ssh key to git
- Generate a key
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]"
- Add the key to your pc
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
- Copy the SSH key to your clipboard.
xclip -sel clip < ~/.ssh/id_rsa.pub
@aliciawyy
aliciawyy / .bashrc
Last active May 12, 2020 11:41
Useful settings in .bashrc
# To access to the ~/Codes repository directly and previous pw by cd -
export CDPATH=.:~:~/Codes
# hisotory ignore
export HISTIGNORE="cd:ls:ll:"
# To have colorful terminal
PS1='\
\[\033[00m\][\
\[\033[32m\]\u\
@aliciawyy
aliciawyy / patterns.py
Last active July 14, 2017 12:15
Notes on pattern
# inheritance vs delegation
# http://www.jguru.com/faq/view.jsp?EID=27916
@aliciawyy
aliciawyy / count.py
Created January 29, 2017 10:36
Count the most frequent element in list
import collections
lst = [1, 3, 1, 4, 2, 5, 3, 4, 3]
cnt = collections.Counter(lst)
cnt.most_common(1)
@aliciawyy
aliciawyy / Button to hide code in a python notebook
Created September 19, 2016 13:41
Button to hide code in a python notebook
import IPython.core.display as di
# This line will hide code by default when the notebook is exported as HTML
di.display_html('<script>jQuery(function() {if (jQuery("body.notebook_app").length == 0) { jQuery(".input_area").toggle(); jQuery(".prompt").toggle();}});</script>', raw=True)
# This line will add a button to toggle visibility of code blocks, for use with the HTML export version
di.display_html('''<button onclick="jQuery('.input_area').toggle(); jQuery('.prompt').toggle();">Toggle code</button>''', raw=True)
@aliciawyy
aliciawyy / via_server.py
Created July 12, 2016 09:10
to transfer files between server and local machine
"""
To transfer and fetch the data from server
"""
import os
import paramiko
class InternalSSHClient(object):
"""
Examples
@aliciawyy
aliciawyy / stats.py
Created June 22, 2016 12:12
math functions
def autocorr(x):
# auto correlation
# from http://tinyurl.com/afz57c4
result = np.correlate(x, x, mode='full')
result = result / np.max(result)
return result[result.size / 2:]