(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #!/usr/bin/env python | |
| """ | |
| Interactive execution with automatic history, tries to mimic Mathematica's | |
| prompt system. This environment's main features are: | |
| - Numbered prompts (In/Out) similar to Mathematica. Only actions that produce | |
| output (NOT assingments, for example) affect the counter and cache. | |
| - The following GLOBAL variables always exist (so don't overwrite them!): | |
| _p: stores previous result which generated printable output. |
| # ** ERROR 1 ** | |
| # FATAL: lock file "postmaster.pid" already exists | |
| # HINT: Is another postmaster (PID 4646) running in data directory "/usr/local/var/postgres"? | |
| # | |
| # ** ERROR 2 ** | |
| # Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? | |
| # | |
| # To fix one of this errors: | |
| cat /usr/local/var/postgres/postmaster.pid # pid is the number on first line |
| -- PostgreSQL 9.2 beta (for the new JSON datatype) | |
| -- You can actually use an earlier version and a TEXT type too | |
| -- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
| -- Inspired by | |
| -- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html | |
| -- http://ssql-pgaustin.herokuapp.com/#1 | |
| -- JSON Types need to be mapped into corresponding PG types | |
| -- |
| from gensim import corpora, models, similarities, utils | |
| import logging | |
| import os | |
| import re | |
| logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) | |
| class DirectoryCorpus(corpora.TextCorpus): | |
| def get_texts(self): |
| function grf(){ | |
| # restores file that was deleted. to run | |
| # cd into the directory of the file and type | |
| # grf filename-that-was-deleted | |
| git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1" | |
| } |
| server { | |
| listen 80; | |
| server_name *.foo.example.com; | |
| # We need this to resolve the host, because it's a wildcard. | |
| # This is google's DNS server. | |
| resolver 8.8.8.8; | |
| include /etc/nginx/includes/proxy.conf; |
| import os | |
| import numpy | |
| from pandas import DataFrame | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| from sklearn.naive_bayes import MultinomialNB | |
| from sklearn.pipeline import Pipeline | |
| from sklearn.cross_validation import KFold | |
| from sklearn.metrics import confusion_matrix, f1_score | |
| NEWLINE = '\n' |
| // Just before switching jobs: | |
| // Add one of these. | |
| // Preferably into the same commit where you do a large merge. | |
| // | |
| // This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
| // and then it quickly escalated into more and more evil suggestions. | |
| // I've tried to capture interesting suggestions here. | |
| // | |
| // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
| // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| license: gpl-3.0 |