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)
| import pandas as pd | |
| # Read file | |
| results = pd.read_csv("/tmp/data.csv", encoding='utf-8',sep=',', quoting=csv.QUOTE_ALL) | |
| # Print rows | |
| for row in results: | |
| print(row) | |
| # Iterate over rows |
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)
| # Redis Cheatsheet | |
| # All the commands you need to know | |
| redis-server /path/redis.conf # start redis with the related configuration file | |
| redis-cli # opens a redis prompt | |
| # Strings. |
| <?php | |
| function array_keys_multi(array $array) | |
| { | |
| $keys = array(); | |
| foreach ($array as $key => $value) { | |
| $keys[] = $key; | |
| if (is_array($array[$key])) { | |
| $keys = array_merge($keys, array_keys_multi($array[$key])); |
sudo apt-get install python-setuptoolswget http://downloads.sourceforge.net/project/s3tools/s3cmd/1.5.0-alpha1/s3cmd-1.5.0-alpha1.tar.gztar xvfz s3cmd-1.5.0-alpha1.tar.gzcd s3cmd-1.5.0-alpha1python setup.py installs3cmd --configureWhen hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com, example2.com, and example1.com/images on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
| <?php | |
| function get_combinations($arrays) { | |
| $result = array(array()); | |
| foreach ($arrays as $property => $property_values) { | |
| $tmp = array(); | |
| foreach ($result as $result_item) { | |
| foreach ($property_values as $property_value) { | |
| $tmp[] = array_merge($result_item, array($property => $property_value)); | |
| } |
(still a work-in-progress)
#!/bin/sh
# https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88 | grep [email protected] || exit 1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
This is a sample of how to send some information to logstash via the TCP input in nodejs or python. It assumes the logstash host is on 10.10.10.100 and the TCP listening input is 9563.
The logstash.conf should look something like the sample file.
The log message should be a stringified JSON object with the log message in the @message field.
To use, run the node script node sendMessageToLogstash.js, or the python script python sendMessageToLogstash.js