Skip to content

Instantly share code, notes, and snippets.

@zouzias
zouzias / enum.go
Created July 25, 2019 12:26 — forked from lummie/enum.go
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@zouzias
zouzias / alert.sh
Created April 30, 2019 14:09 — forked from cherti/alert.sh
send a dummy alert to prometheus-alertmanager
#!/bin/bash
name=$RANDOM
url='http://localhost:9093/api/v1/alerts'
echo "firing up alert $name"
# change url o
curl -XPOST $url -d "[{
\"status\": \"firing\",
@zouzias
zouzias / clean_code.md
Created September 8, 2018 18:42 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@zouzias
zouzias / load_parquet_s3.py
Created August 10, 2018 20:43 — forked from asmaier/load_parquet_s3.py
Pyspark script for downloading a single parquet file from Amazon S3 via the s3a protocol. It also reads the credentials from the "~/.aws/credentials", so we don't need to hardcode them. See also https://hadoop.apache.org/docs/stable/hadoop-aws/tools/hadoop-aws/index.html .
#
# Some constants
#
aws_profile = "your_profile"
aws_region = "your_region"
s3_bucket = "your_bucket"
#
# Reading environment variables from aws credential file
#
@zouzias
zouzias / sql.py
Created March 18, 2018 08:40 — forked from jorisvandenbossche/sql.py
Patched version of pandas.io.sql to support PostgreSQL
"""
Patched version to support PostgreSQL
(original version: https://github.com/pydata/pandas/blob/v0.13.1/pandas/io/sql.py)
Adapted functions are:
- added _write_postgresql
- updated table_exist
- updated get_sqltype
- updated get_schema
@zouzias
zouzias / README.md
Created February 16, 2018 16:22 — forked from phatak-dev/README.md
Functional Programming in C++

#Compilng You need g++ 4.9 to compile this code. Follow these steps to install g++-4.9

After installing run the following command to compile

/usr/bin/g++-4.9 -std=c++11 lambda.cpp

#Running

./a.out
@zouzias
zouzias / install_python3.6_opensuse42.3.sh
Created January 25, 2018 14:25 — forked from amoilanen/install_python3.6_opensuse42.3.sh
Installing Python 3.6 on OpenSUSE Leap 42.3
# !/bin/bash
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
# Step 2. Install missing headers for all the Python modules to be built
@zouzias
zouzias / lda.py
Created January 10, 2018 10:39 — forked from aronwc/lda.py
Example using GenSim's LDA and sklearn
""" Example using GenSim's LDA and sklearn. """
import numpy as np
from gensim import matutils
from gensim.models.ldamodel import LdaModel
from sklearn import linear_model
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
@zouzias
zouzias / PyUtils.cpp
Created October 6, 2017 14:20 — forked from rjzak/PyUtils.cpp
Convert between Python list/tuples and C++ vectors
#include <Python.h> // Must be first
#include <vector>
#include <stdexcept>
#include "PyUtils.h"
using namespace std;
// =====
// LISTS
// =====
@zouzias
zouzias / setup.py
Created October 4, 2017 19:57 — forked from hryk/setup.py
an example for using boost::unordered_map in Cython.
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
Extension("test_um",
["test_um.pyx"],
include_dirs=["/usr/local/include/boost"],
library_dirs=["/usr/local/lib"],
language="c++")