Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AustinRochford
AustinRochford / pymc3-fosscon2017.ipynb
Last active November 10, 2023 03:18
Open Source Bayesian Inference in Python with PyMC3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@francoismarceau29
francoismarceau29 / aws-lambda-prediction.py
Last active March 31, 2020 08:49
Deployment of SciKit model on AWS Lambda using S3 and Boto3 (WIP)
from sklearn.externals import joblib
from boto.s3.key import Key
from boto.s3.connection import S3Connection
from flask import Flask
from flask import request
from flask import json
BUCKET_NAME = 'your-s3-bucket-name'
MODEL_FILE_NAME = 'your-model-name.pkl'
MODEL_LOCAL_PATH = '/tmp/' + MODEL_FILE_NAME
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 29, 2024 17:57
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@Nikolay-Lysenko
Nikolay-Lysenko / xgb_quantile_loss.py
Last active October 25, 2023 13:26
Customized loss function for quantile regression with XGBoost
import numpy as np
def xgb_quantile_eval(preds, dmatrix, quantile=0.2):
"""
Customized evaluational metric that equals
to quantile regression loss (also known as
pinball loss).
Quantile regression is regression that
@alanwill
alanwill / delete-multiple-rows.py
Created August 21, 2016 08:59
Delete Multiple DynamoDB rows
import boto3
getCleanTable = taskStatus.query(
KeyConditionExpression=Key('requestId').eq('a3248585-8ac0-4889-b1fb-976d9113f7f2') & Key('eventTimestamp').gt('1')
)
for i in getCleanTable['Items']:
cleanupTable = boto3.client('dynamodb').batch_write_item(
RequestItems={
'talr-taskStatus': [
@dwilkie
dwilkie / docker-cheat-sheat.md
Last active January 18, 2024 10:56
Docker Cheat Sheet

Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes