Skip to content

Instantly share code, notes, and snippets.

@jmasonherr
jmasonherr / Collect Parler Metadata.ipynb
Created January 12, 2021 17:53 — forked from kylemcdonald/Collect Parler Metadata.ipynb
Collect video URLs and GPS data for Parler videos.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jmasonherr
jmasonherr / recursive_sql_example.sql
Created February 4, 2019 15:53
Bottom up recursive SQL example
-- A bottom-up recursive Postgres query on a table named 'family'
-- with three columns: id, parent_id, child_id
WITH RECURSIVE bottom_up_family (
parent_id, child_id, depth, path
) AS (
SELECT
fam_initial.parent_id,
fam_initial.child_id,
1,
@jmasonherr
jmasonherr / middleware.py
Created June 28, 2018 14:43
Get current user from anywhere in Django 2.x with middleware
from __future__ import absolute_import, division, print_function
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
_thread_locals = local()
"""
No dependency Python script for converting uBiome's raw data .zip
into a single FASTQ file. Based on
https://gist.github.com/boydgreenfield/805ac27e0a6b9a5adea7
Usage:
>>>python ubiome2fastq.py ubiomedatafile.zip
"""
@jmasonherr
jmasonherr / statclassify.py
Created May 23, 2014 16:03
Naive Bayes and Fisher Classifier based on PCI book
# -*- coding: utf-8 -*-
import math
"""
Statistical classification classes based on Toby Segarin's Programming Collective Intelligence. I wanted a version that was a little easier to read and didn't talk to SQLite. Its meant to be trained and tested on blocks of text.
This is good for separating things of discrete classes. Spam detection is used as the example in the book
@jmasonherr
jmasonherr / connect_tutorial_python.py
Created May 12, 2014 18:28
Stripe connect tutorial for python
# coding: utf-8
import json
import stripe
import datetime
# Required for OAuth flow
from rauth import OAuth2Service
# Our secret key from stripe
STRIPE_SECRET_KEY = 'sk_test_xxxxxxxxxxxxx'
@jmasonherr
jmasonherr / url_to_image_service.py
Last active April 21, 2020 12:55
Upload a photo to App Engine's Image service from a URL of an image elsewhere on the internet. Integrates App Engine's images service with InkPicker, so we can use their upload and store the actual image in our server
# Requires poster https://pypi.python.org/pypi/poster/
# Requires webapp2 on App Engine for demo
# Example usage:
# import requests
# 'http://upload.wikimedia.org/math/4/7/9/479d9d21b183eb546b771447fcf69ddf.png'
# response = requests.post('http://myapp.appspot.com/i/post_from_url', {'url': wikipediaimg})
import json