Look at LSB init scripts for more information.
Copy to /etc/init.d:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)| # | |
| # CONFIGURATION FOR USING SMS KANNEL WITH RAPIDSMS | |
| # | |
| # For any modifications to this file, see Kannel User Guide | |
| # If that does not help, see Kannel web page (http://www.kannel.org) and | |
| # various online help and mailing list archives | |
| # | |
| # Notes on those who base their configuration on this: | |
| # 1) check security issues! (allowed IPs, passwords and ports) | |
| # 2) groups cannot have empty rows inside them! |
| ############# init parent django project settings | |
| from os import path | |
| import sys | |
| sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) | |
| import settings | |
| from django.core.management import setup_environ | |
| setup_environ(settings) | |
| ############### |
| 1. pip install -r reqs.pip | |
| 2. server.py | |
| 3. open client.html in browser | |
| 4. redis-cli publish push '123456' | |
| 5. check browser console |
| """ | |
| Two things are wrong with Django's default `SECRET_KEY` system: | |
| 1. It is not random but pseudo-random | |
| 2. It saves and displays the SECRET_KEY in `settings.py` | |
| This snippet | |
| 1. uses `SystemRandom()` instead to generate a random key | |
| 2. saves a local `secret.txt` |
| """Information Retrieval metrics | |
| Useful Resources: | |
| http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt | |
| http://www.nii.ac.jp/TechReports/05-014E.pdf | |
| http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf | |
| http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf | |
| Learning to Rank for Information Retrieval (Tie-Yan Liu) | |
| """ | |
| import numpy as np |
Look at LSB init scripts for more information.
Copy to /etc/init.d:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)| """making a dataframe""" | |
| df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB')) | |
| """quick way to create an interesting data frame to try things out""" | |
| df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd']) | |
| """convert a dictionary into a DataFrame""" | |
| """make the keys into columns""" | |
| df = pd.DataFrame(dic, index=[0]) |
| class BigForeignKey(models.ForeignKey): | |
| def db_type(self, connection): | |
| """ Adds support for foreign keys to big integers as primary keys. | |
| """ | |
| rel_field = self.rel.get_related_field() | |
| if (isinstance(rel_field, BigAutoField) or | |
| (not connection.features.related_fields_match_type and | |
| isinstance(rel_field, (BigIntegerField, )))): |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| from scipy.spatial.distance import pdist, squareform | |
| import numpy as np | |
| from numbapro import jit, float32 | |
| def distcorr(X, Y): | |
| """ Compute the distance correlation function | |
| >>> a = [1,2,3,4,5] | |
| >>> b = np.array([1,2,9,4,4]) |