Skip to content

Instantly share code, notes, and snippets.

View pavan538's full-sized avatar

Pavan Kumar pavan538

View GitHub Profile
@pavan538
pavan538 / balanced_partition.py
Created November 9, 2018 03:31
Partitioning problem: Arbitrary list of integers of any length and in any order Determine if the list is partitionable or not. A partitioned list is one where it can be split into 2 lists with equal sum. Enumerate the list of cases to solve to minimize execution time and provide the Order of the algorithm Provide code showing the implementation …
from functools import reduce
def is_balanced_partition(arr):
total = reduce(lambda x, y: x+y , arr)
if total % 2 != 0:
return False
@pavan538
pavan538 / tfpdf.py
Created October 19, 2018 16:21 — forked from bllchmbrs/tfpdf.py
TF IDF Explained in Python Along with Scikit-Learn Implementation
from __future__ import division
import string
import math
tokenize = lambda doc: doc.lower().split(" ")
document_0 = "China has a strong economy that is growing at a rapid pace. However politically it differs greatly from the US Economy."
document_1 = "At last, China seems serious about confronting an endemic problem: domestic violence and corruption."
document_2 = "Japan's prime minister, Shinzo Abe, is working towards healing the economic turmoil in his own country for his view on the future of his people."
document_3 = "Vladimir Putin is working hard to fix the economy in Russia as the Ruble has tumbled."
@pavan538
pavan538 / benchmark-commands.txt
Created September 6, 2018 09:44 — forked from jkreps/benchmark-commands.txt
Kafka Benchmark Commands
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
@pavan538
pavan538 / mysql_python_lib.py
Created September 6, 2018 07:14
MYSQL python utitlity
__author__ = 'pavan.tummalapalli'
import mysql.connector.pooling
import logging
class MySQLPool:
"""
create a pool, when connect to mysql, which will decrease the time spent in
@pavan538
pavan538 / jupyter_nginx_supervisor.md
Created August 7, 2018 10:36
jupyter notebook browser with nginx and supervisor

create a jupyter.conf supervisor setting file

[program:jupyter]
command = /home/ubuntu/virtual_envs/kaggle/bin/jupyter notebook --no-browser --config=/home/ubuntu/.jupyter/jupyter_notebook_config.py
environment=PATH="/home/ubuntu/virtual_envs/kaggle/bin:%(ENV_PATH)s"
directory = /home/ubuntu/ml
user = ubuntu
autostart = true
autorestart = true

Contents

.. toctree::
   :caption: Table of Contents
   :name: mastertoc
   :maxdepth: 2


Components

@pavan538
pavan538 / xpath3.1_examples.md
Created June 13, 2018 08:49
xpath 3.1 examples

xpath 3.1 example

[
        for $result in //supplierAssortment
        return
        map {

           'articleCode': let $article_code := $result//articleCode/string()
                          return xs:integer($article_code),
// imports a couple of java tasks
apply plugin: "java"
// List available tasks in the shell
> gradle tasks
// A Closure that configures the sourceSets Task
// Sets the main folder as Source folder (where the compiler is looking up the .java files)
sourceSets {
main.java.srcDir "src/main"
apply from: 'plugins.gradle'
ext {
dependencies_version = [
dropwizard: [
core: '1.3.1'
]
]
}
class YoutubExtension {
def featureName
}
class YoutubePlugin implements Plugin<Project>{
@Override
void apply(Project target) {