Skip to content

Instantly share code, notes, and snippets.

View guillermo-menjivar's full-sized avatar

gmo guillermo-menjivar

View GitHub Profile
cd /opt
wget http://apache-mirror.rbc.ru/pub/apache/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz
tar xvzf kafka_2.11-0.10.1.0.tgz
ln -s kafka_2.11-0.10.1.0/ kafka
vi /etc/systemd/system/kafka-zookeeper.service
[Unit]
Description=Apache Zookeeper server (Kafka)
Documentation=http://zookeeper.apache.org
@guillermo-menjivar
guillermo-menjivar / kafka-cheat-sheet.md
Created January 12, 2018 15:17 — forked from sahilsk/kafka-cheat-sheet.md
Apache Kafka Cheat Sheet

Kafka Cheat Sheet

Display Topic Information

$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic beacon
Topic:beacon	PartitionCount:6	ReplicationFactor:1	Configs:
	Topic: beacon	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
	Topic: beacon	Partition: 1	Leader: 1	Replicas: 1	Isr: 1
dered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.001 0.001 87.313 87.313 analyticsd.py:3(<module>)
1 0.029 0.029 87.149 87.149 analyticsd.py:77(main)
12 87.058 7.255 87.058 7.255 {method 'execute' of 'psycopg2.extensions.cursor' objects}
4 0.000 0.000 81.506 20.377 analyticsd.py:60(update_records)
4 0.000 0.000 2.911 0.728 analyticsd.py:27(get_new_records)
4 0.000 0.000 2.648 0.662 analyticsd.py:45(get_previous_records)
1 0.000 0.000 0.085 0.085 manicthief.py:3(<module>)
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.001 0.001 0.850 0.850 analyticsd.py:3(<module>)
1 0.000 0.000 0.683 0.683 analyticsd.py:90(main)
2 0.682 0.341 0.682 0.341 {method 'execute' of 'psycopg2.extensions.cursor' objects}
1 0.000 0.000 0.639 0.639 analyticsd.py:46(get_previous_records)
1 0.000 0.000 0.085 0.085 manicthief.py:3(<module>)
1 0.000 0.000 0.074 0.074 __init__.py:2(<module>)
1 0.000 0.000 0.068 0.068 _packer.py:1(<module>)
1 0.001 0.001 0.068 0.068 _packer.py:1(__bootstrap__)
@guillermo-menjivar
guillermo-menjivar / .py
Last active January 16, 2018 06:42
take-20123121
def hack_convert(records):
template = "select * from analytics where tag in ({CODE})"
root = "(VALUES "
for rec in records:
root = root + "('"+rec+"'::uuid),"
# this removes the last comma
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.001 0.001 9.264 9.264 analyticsd.py:3(<module>)
1 0.006 0.006 9.099 9.099 analyticsd.py:93(main)
12 8.969 0.747 8.969 0.747 {method 'execute' of 'psycopg2.extensions.cursor' objects}
4 0.059 0.015 3.674 0.919 analyticsd.py:72(update_records)
@guillermo-menjivar
guillermo-menjivar / main.py
Created January 16, 2018 07:11
update commit
125 if len(ips_to_update) > 0:
126
127 while len(uuids_to_update) > 0:
128 print 'updating', len(uuids_to_update[:1000])
129 update_records(analytic['id'], uuids_to_update[:1000])
130 del uuids_to_update[:1000]
#!/usr/bin/env python
from sys import exit
import json
import datetime
import requests
from uuid import uuid4
import psycopg2
import manicthief
@guillermo-menjivar
guillermo-menjivar / something.java
Last active April 9, 2018 05:22
example for ya
import java.util.*;
public class GTac {
public static String PlayerO = " O ";
public static String PlayerX = " X ";
public static String Blank = " ";
public static String Delineator = "-----------"; // 11 ( each entry has 3 spaces and there are 3 entries + 2 deviders = 11
public static String Devider = "|";
public static void main(String[] args){
@guillermo-menjivar
guillermo-menjivar / more.java
Created April 13, 2018 04:26
somejava.java
import java.util.*;
public class TicTacToe {
public static void main(String[] args) {
int[][]board= new int [3][3];
int turn= 1;
while(full(board)== false && winner(board)==0)
{
printBoard(board);