Skip to content

Instantly share code, notes, and snippets.

View antongorshkov's full-sized avatar

Anton Gorshkov antongorshkov

View GitHub Profile
1. Install ZD(http://docs.zoomdata.com/docker-install)
2. Install MemSQL(http://docs.memsql.com/4.1/setup/docker/)
3. In docker shell:
- docker run -d -p 3306:3306 -p 9000:9000 --name memsql memsql/quickstart
- docker run --rm -it --link=memsql:memsql memsql/quickstart memsql-shell
4. Install DbVisualizer (https://www.dbvis.com/download/)
5. docker stop default
6. open VirtualBox, give at least 8192MB RAM + 4 Cores under processor
7. ZD, login as Supervisor, click advanced, enable MemSQL
8. ZD, connection: jdbc:mysql://192.168.99.100:3306/test
Start here:
http://docs.memsql.com/4.1/setup/docker/
create database test;
use test;
CREATE TABLE test_table (id BIGINT PRIMARY KEY AUTO_INCREMENT, c INT);
INSERT INTO test_table (c) VALUES (1);
bin/kafka-topics.sh --zookeeper $KAFKAZK --describe --topic simple1
bin/kafka-topics.sh --zookeeper $KAFKAZK --alter --topic simple1 --config delete.retention.ms=5000
bin/kafka-topics.sh --zookeeper $KAFKAZK --alter --topic simple1 --config retention.ms=10000
bin/kafka-console-consumer.sh --zookeeper $KAFKAZK --topic simple1 --from-beginning
wget http://www-us.apache.org/dist/kafka/0.8.2.2/kafka_2.9.1-0.8.2.2.tgz
tar -xvf kafka_2.9.1-0.8.2.2.tgz
OR
- xcode-select --install
- /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- export PATH="$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH"
- brew install coreutils
- sort -R

Send a file to Kafka

while true; do bin/kafka-console-producer.sh --broker-list $KAFKA --topic test2 < simple.json > k.out; done

Pick a random file and send to Kafka

while true; do bin/kafka-console-producer.sh --broker-list $KAFKA --topic test2 < "$(ls *100.json | shuf | head -1)" > k.out; done
@antongorshkov
antongorshkov / wikistats_downloader
Created April 10, 2016 03:20
Wikimedia Pagecounts Downloader
#!/bin/bash
i="1"
while [ $i -lt 5 ]
do
url="https://dumps.wikimedia.org/other/pagecounts-raw/2016/2016-0$i/md5sums.txt"
echo $url
wget -q $url
cat md5sums.txt | grep pagecounts | cut -d" " -f3 > md5names.txt
@antongorshkov
antongorshkov / wikistats2json
Created April 10, 2016 03:21
convert pagecount stats to Json messages to be sent to Kafka/MemSQL
#!/bin/bash
for f in *.top; do
f_notop=${f/.top/}
IFS='-' read -r -a array <<< "$f_notop"
date=${array[1]}
hour=${array[2]}
first=0
while read p; do
IFS=' ' read -r -a tokens <<< "$p"
Remove space used:
docker ps -a
docker rm < <IMAGE_NAME>
docker volume ls
docker volume rm <VOLUME_NAME>
sudo service docker stop
sudo rm -rf /var/lib/docker
sudo service docker start
Abiu
Acai
Acerola
Ackee
Agave
Aizen
Alligator
Amazon
Ambarella
Apple
import pprint
with open('fruits') as f:
d = dict([x.rstrip(),1] for x in f)
fruit = raw_input('Enter fruit: ').title()
if fruit in d:
print('Got it!')
else:
print('No luck!')