alexkras.com

  • Home
  • Top Posts
  • Resume
  • Projects
  • YouTube
  • Boots to Bytes
  • About
  • Contact

Group Log Data by Timestamp in Python with Pandas

December 23, 2018 by Alex Kras Leave a Comment

I often find myself with logs in the following format, exported in CSV. timestamp,request_time_in_millis 1545509231863,101 1545509231863,38 1545541592109,202 1545595617945,53 1545595617945,1024 First column is timestamp in milliseconds, second column is timing for some request, also in milliseconds. Often I’d like to see the min, max and average request time, group by day and hour. Here is how […]

Filed Under: data, Python

How to use Virtualenv in Python to Install Packages Locally

August 20, 2018 by Alex Kras 3 Comments

There are two philosophies when it comes to package installation, global first and local first. Global meaning all applications that rely on a certain package have access to the same copy of the library that was installed once. Local means that each project has its own folder of dependencies installed specifically for this project and […]

Filed Under: Python, Tools

Crunching Honeypot IP Data with Pandas and Python

April 7, 2018 by Alex Kras 4 Comments

I am taking a cyber security class. This week’s assignment had us work on Honeypots. Honeypot is a server that pretends to have a vulnerability of sorts (open ports, old software etc.) and instead collects data on people who are trying to hack it. At the end of the experiment I ended up with some […]

Filed Under: data, Python

How to Restart Python Script after Exception and Run it Forever

February 23, 2018 by Alex Kras 16 Comments

Here is a simple trick that I used to restart my python script after unhandled exception. Let’s say I have this simple script called test.py that I want to run forever. It will just wait 2 seconds and throw an error. import time time.sleep(2) raise Exception(“Oh oh, this script just died”) I use the following […]

Filed Under: Python

Transcribing Speech to Text with Python and Google Cloud Speech API

January 4, 2018 by Alex Kras 78 Comments

This tutorial will walk through using Google Cloud Speech API to transcribe a large audio file. All code and sample files can be found in speech-to-text GitHub repo. Transcribe large audio files using Python & our Cloud Speech API. @akras14 shows how https://t.co/dY56lmE0TD — Google Cloud (@googlecloud) January 11, 2018 Sample Results This approach works, […]

Filed Under: Python, Tools

How to read CSV file in Python

December 24, 2017 by Alex Kras 8 Comments

Reading as a List Let’s say we have the following CSV file, named actors.csv. You can download this file here. The first method demonstrated in Python docs would read the file as follows: Open the file Create a CSV reader Skip first line (header) For every line (row) in the file, do something import csv […]

Filed Under: Python, Tools

Convert JSON to dot notation with Python

December 20, 2017 by Alex Kras Leave a Comment

There are many use cases for converting JSON to a dot notation. For example, my current company used Hue to query our log data. Our logs are stored in JSON, and Hue queries expect a dot notation. For example, this JSON file { “vehicle”: { “car”: { “bmw”: true, “audi”: 1, “ford”: “also good” }, […]

Filed Under: Python, Tools

Parsing “Ask HN: Who is hiring?” with Python and Hacker News API

December 2, 2017 by Alex Kras Leave a Comment

Have you heard of Hacker News? It’s a great mini social network dedicated to all things tech. Once a month they post a thread called “Ask HN: Who is hiring?”, where anyone can list their job openings. With hundreds of comments it quickly gets overwhelming. Turns out it’s very easy to get the same data […]

Filed Under: Python

Simple Python Threading Example

August 17, 2017 by Alex Kras 2 Comments

At my work we have a Python library that interfaces to all our API micro services (that are written in Java/Scala). It is a very useful tool for debugging and working with our platform, so I spend a lot of my time in a Python REPL. Often times I find myself needing to hit multiple […]

Filed Under: Python

Fix Issue with Python installed via Brew after OS X El Capitan 10.11.6 Update

August 2, 2017 by Alex Kras 1 Comment

Looks like the recent update to OS X El Capitan version 10.11.6 breaks python installed via homebrew. At least it happened to me both on my work and my home machines. If you are experience the same issue, you may see something that looks as following: $ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) […]

Filed Under: Python

  • 1
  • 2
  • Next Page »

Copyright © 2021 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in