Skip to content

Instantly share code, notes, and snippets.

@canimus
canimus / status.py
Last active December 11, 2019 20:52
Ploting FaceGrid
import seaborn as sns
import pandas as pd
from collections import OrderedDict
x = df[df.statusChangeBy>10].groupby([pd.Grouper(freq="W", key="statusChangedDate"), "Name"]).size().compute()
x = x.reset_index()
x.columns = ["Date", "Team", "Total"]
x = x.sort_values(by="Date")
plt.figure(figsize=(30,30))
@canimus
canimus / parquetfier.py
Created December 4, 2019 02:38
Parquet writer from dataframe
import pandas as pd
import numpy as np
import pymssql
conn = pymssql.connect("localhost", "SA", "yourStrong(!)Password", "FORCE_PAPPA")
with open("task.sql") as infile:
doc_query = infile.read().strip()
time_range = list(pd.date_range(start='2019-01-01', periods=12, freq="MS").strftime("%Y-%m-%d").values)
@canimus
canimus / xmlcounter.py
Created October 28, 2019 22:39
XML Tag Counter with Python Multiprocess
# Author: Herminio Vazquez
# Date: 2019-10-28
# Project: DataStore
# @canimus
import os
from multiprocessing import Pool
import multiprocessing
import subprocess
from functional import seq
@canimus
canimus / ssh-keygen.sh
Created September 13, 2019 01:44
Store SSH key with previous version
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
@canimus
canimus / dna_functions.py
Last active September 1, 2019 10:37 — forked from vestalisvirginis/dna_functions.py
dna manipulation functions
from functional import seq # PyFunctional
from itertools import product
def all_kmers(k):
'''return list of all dna carthesien products of length k'''
all = list(product('ACGT', repeat=k))
return seq(all).map(lambda x: ''.join(x)).to_list()
def kmer_per_segment(dna_segment, k):
'''return all the dna substrings of length k of the different dna strings in dna list'''
@canimus
canimus / recursive_tree.py
Created June 25, 2019 07:13
Build NetworkX Graph
# Navigate through xml tree and build a directed graph
def add_tree(G, node):
for n in node.getchildren():
G.add_node(n.tag)
G.add_edge(node.tag, n.tag)
add_tree(G, n)
apk --no-cache add --virtual .builddeps.edge \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \
hdf5-dev
@canimus
canimus / pearson.tick
Created March 16, 2019 21:59
Flux - Pearson of CPUs
// Calculate the correlation between 2 CPU Usage
cpu0 = from(bucket: "telegraf")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "cpu")
|> filter(fn: (r) => r._field == "usage_idle")
|> filter(fn: (r) => r.cpu == "cpu0")
cpu1 = from(bucket: "telegraf")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
@canimus
canimus / expand_xfs.sh
Created March 12, 2019 12:31
Expand volume linux
# Logical volume display
lvdisplay
# Volume maps
vgdisplay
# Extend based on VG Name and lvdisplay path
lvextend -l +5120 /dev/dockerimvg/varlibdocker
# Apply fs grow into volume
# Pull the necessary images:
docker pull nathanleclaire/curl:latest
docker pull openjdk:8u111-jre-alpine

# Start the controller container, note that it has RW access to the Docker API socket:
docker run \
  -ti \
  --rm \