Skip to content

Instantly share code, notes, and snippets.

@manugarri
manugarri / pyrasite-stacktrace-how-to.md
Created May 10, 2021 14:49 — forked from soxofaan/pyrasite-stacktrace-how-to.md
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running Python script

Sometimes a Python script will simply hang forever with no indication of what is going wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward.

Here's a way to see where the program is currently stuck, using pyrasite a tool for injecting code into running Python processes.

Install gdb and pyrasite

Install gdb.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@manugarri
manugarri / kafka-cheat-sheet.md
Created October 24, 2018 12:39 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@manugarri
manugarri / Structured_with_text.py
Created October 20, 2018 13:09 — forked from ranihorev/Structured_with_text.py
PyTorch module for classification or regression of categorical+continuous+text inputs. This module is based on fast.ai library
from fastai.text import *
from fastai.structured import proc_df
import pandas as pd
import numpy as np
class MixedInputModelWithText(nn.Module):
def __init__(self, emb_szs, n_cont, emb_drop, out_sz, szs, drops,
y_range=None, use_bn=False, is_reg=True, is_multi=False, n_text=0):
super().__init__()
for i, (c, s) in enumerate(emb_szs): assert c > 1, f"cardinality must be >=2, got emb_szs[{i}]: ({c},{s})"
@manugarri
manugarri / cookie_read_test.go
Created April 19, 2018 12:06 — forked from jonnyreeves/cookie_read_test.go
Testing Cookie Writes in Golang
@manugarri
manugarri / config
Created December 19, 2017 17:11 — forked from gerardorf/config
bastion ssh configuration. Add this config on ~/.ssh/config
Host *.gerardorf.org !bastion.gerardorf.org
User admin
IdentityFile ~/.ssh/gerardorf-private-key
ProxyCommand ssh -W %h:%p [email protected]
Host bastion.gerardorf.org
Hostname XXX.XXX.XXX.XXX
User admin
IdentityFile ~/.ssh/gerardorf-private-key
ForwardAgent yes
{
"IAB1": "Arts & Entertainment",
"IAB1-1": "Books & Literature",
"IAB1-2": "Celebrity Fan/Gossip",
"IAB1-3": "Fine Art",
"IAB1-4": "Humor",
"IAB1-5": "Movies",
"IAB1-6": "Music",
"IAB1-7": "Television",
"IAB2": "Automotive",
@manugarri
manugarri / guess_candidate_model.py
Created November 13, 2016 15:57 — forked from gati/guess_candidate_model.py
Code for training an LSTM model for text classification using the keras library (Theano backend). Was used for guesscandidate.com.
from sklearn.cross_validation import train_test_split
from keras.preprocessing import sequence, text
from keras.models import Sequential
from keras.layers import (Dense, Dropout, Activation, Embedding, LSTM,
Convolution1D, MaxPooling1D)
# Embedding
max_features = 20000
maxlen = 100
embedding_size = 32
@manugarri
manugarri / analytic_wfm.py
Created June 21, 2016 22:19 — forked from sixtenbe/analytic_wfm.py
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@manugarri
manugarri / automation.md
Created June 21, 2016 09:57 — forked from cube-drone/automation.md
Automation For The People

Automation for the People

Long ago, the first time I read "The Pragmatic Programmer", I read some advice that really stuck with me.

"Don't Use Manual Procedures".

This in the chapter on Ubiquitous Automation. To summarize, they want you to automate all the things.

The trouble was that I hadn't much of an idea how to actually go