Skip to content

Instantly share code, notes, and snippets.

@shcallaway
shcallaway / README.md
Last active April 15, 2024 14:25
Use jq to parse JSON logs into something more readable

Structured logs are way better than normal logs for a whole bunch of reasons, but they can sometimes be a pain to read in the shell. Take this logline for example:

{"erlang_pid":"#PID<0.1584.0>","level":"error","message":"Got error when retry: :econnrefused, will retry after 1535ms. Have retried 2 times, :infinity times left.","module":"","release":"c2ef629cb357c136f529abec997426d6d58de485","timestamp":"2019-12-17T19:22:11.164Z"}

This format is hard for a human to parse. How about this format instead?

error | 2019-12-17T19:21:02.944Z | Got error when retry: :econnrefused, will retry after 1648ms. Have retried 2 times, :infinity times left.
@ines
ines / streamlit_prodigy.py
Created October 3, 2019 20:37
Streamlit + Prodigy
"""
Example of a Streamlit app for an interactive Prodigy dataset viewer that also lets you
run simple training experiments for NER and text classification.
Requires the Prodigy annotation tool to be installed: https://prodi.gy
See here for details on Streamlit: https://streamlit.io.
"""
import streamlit as st
from prodigy.components.db import connect
from prodigy.models.ner import EntityRecognizer, merge_spans, guess_batch_size
@goyalmohit
goyalmohit / post-commit.py
Created April 14, 2019 11:46
Python script for git post-commit hook
#!/usr/bin/env python
import smtplib
from email.mime.text import MIMEText
from subprocess import check_output
# Get the git log --stat entry of the new commit
log = check_output(['git', 'log', '-1', '--stat', 'HEAD'])
# Create a plaintext email message
msg = MIMEText("Look, I'm actually doing some work:\n\n%s" % log)
@hmldd
hmldd / scroll.py
Last active October 6, 2023 14:59
Example of Elasticsearch scrolling using Python client
# coding:utf-8
from elasticsearch import Elasticsearch
import json
# Define config
host = "127.0.0.1"
port = 9200
timeout = 1000
index = "index"
@alChaCC
alChaCC / brew-java-and-jenv.md
Last active July 23, 2020 09:17 — forked from tomysmile/brew-java-and-jenv.md
How To Install Java 8 on Mac

Install HomeBrew first

brew update
brew tap caskroom/cask
brew install brew-cask

If you get the error "already installed", follow the instructions to unlink it, then install again:

@shagunsodhani
shagunsodhani / Teaching Machines to Read and Comprehend.md
Created August 14, 2016 12:48
Notes for Teaching Machines to Read and Comprehend paper

Teaching Machines to Read and Comprehend

Introduction

  • Build a supervised reading comprehension data set using news corpus.
  • Compare the performance of neural models and state-of-the-art natural language processing model on reading comprehension task.
  • Link to the paper

Reading Comprehension

Build tensorflow on OSX with NVIDIA CUDA support (GPU acceleration)

These instructions are based on Mistobaan's gist but expanded and updated to work with the latest tensorflow OSX CUDA PR.

Requirements

OS X 10.10 (Yosemite) or newer

@marcanuy
marcanuy / gunicorn-SITENAME-staging.example.com.service
Created August 7, 2015 22:55
Using Systemd to Make Sure Gunicorn Starts on Boot. As Ubuntu has switched to systemd as its service framework starting in 15.04 for all flavors, this is a migration of the Gunicorn upstart job that appears in "Test Driven Development with Django" (http://chimera.labs.oreilly.com/books/1234000000754/ch08.html#_using_upstart_to_make_sure_gunicorn…
# Gunicorn Site systemd service file
[Unit]
Description=Gunicorn server for SITENAME-staging.example.com
After=network.target
After=syslog.target
Environment=sitedir=/Development/sites/SITENAME-staging.example.com
ExecStart=$(sitedir)/virtualenv/bin/gunicorn --chdir $(sitedir)/source workouts.wsgi:application --bind unix:/tmp/SITENAME-staging.example.com.socket
Restart=on-failure
@derhuerst
derhuerst / intro.md
Last active May 13, 2023 17:56
Installing the Z Shell (zsh) on Linux, Mac OS X and Windows

Installing zsh – the easy way

The Z shell (zsh) is a Unix shell [...]. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh.

Z shell – Wikipedia

Read more about ZSH at An Introduction to the Z Shell.

Choose one of the following options.

@drorata
drorata / gist:146ce50807d16fd4a6aa
Last active February 27, 2024 10:15
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})