Skip to content

Instantly share code, notes, and snippets.

@jmasonherr
jmasonherr / Collect Parler Metadata.ipynb
Created Jan 12, 2021 — forked from kylemcdonald/Collect Parler Metadata.ipynb
Collect video URLs and GPS data for Parler videos.
View Collect Parler Metadata.ipynb
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 Feb 4, 2019
Bottom up recursive SQL example
View recursive_sql_example.sql
-- 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 Jun 28, 2018
Get current user from anywhere in Django 2.x with middleware
View middleware.py
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()
View ubiome2fastq.py
"""
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
Naive Bayes and Fisher Classifier based on PCI book
View statclassify.py
# -*- 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
Stripe connect tutorial for python
View connect_tutorial_python.py
# 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 Apr 21, 2020
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
View url_to_image_service.py
# 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