Skip to content

Instantly share code, notes, and snippets.

View westonplatter's full-sized avatar

westonplatter

View GitHub Profile
@choffstein
choffstein / entropy_pooling.py
Last active February 3, 2024 21:09
Attilio Meucci's Entropy Pooling
import numpy
import scipy.optimize
import pandas
def probability_constraint(x):
j, n = x.shape
Aeq = numpy.ones([1, j])
beq = numpy.array([1.])
@alysivji
alysivji / graph_transitions.py
Created March 30, 2021 06:05
Exporting Mermaid Markdown for django-fsm
# -*- coding: utf-8; mode: django -*-
import graphviz
from optparse import make_option
from django.core.management.base import BaseCommand
from django.utils.encoding import force_text
from django_fsm import FSMFieldMixin, GET_STATE, RETURN_VALUE
try:
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@lauralorenz
lauralorenz / pydata_denver_demo.py
Created April 15, 2020 23:43
Pydata Denver basic ETL flow
import requests
import json
from collections import namedtuple
from contextlib import closing
import sqlite3
from prefect import task, Flow
## extract
@task
# Pandas operations
## getting and setting df rows
credit goes to https://stackoverflow.com/a/29262040/665578
for i, row in df.iterrows():
ifor_val = something
if <condition>:
ifor_val = something_else
@Vigrond
Vigrond / celery_django_redis_ratelimit.py
Last active February 12, 2024 05:42
Celery / Django / Redis Rate Limits done "as expected" - Simple SMTP Example
# Rate limiting with Celery + Django + Redis
# Multiple Fixed Windows Algorithm inspired by Figma https://www.figma.com/blog/an-alternative-approach-to-rate-limiting/
# and Celery's sometimes ambiguous, vague, and one-paragraph documentation
#
# Celery's Task is subclassed and the is_rate_okay function is added
# celery.py or however your App is implemented in Django
import os
import math
@rwev
rwev / econev.py
Created December 16, 2018 04:29
Python web-scraper for economic events on the Bloomberg Econoday calendar.
# -*- coding: utf-8 -*-
"""
ECONEV.PY: Economic Events
Python web-scraper for economic events on the Bloomberg Econoday calendar.
Saves result of scrape to plain text (in Eastern Time) for flexible processing by other applications.
Author: rwev (https://github.com/rwev)
@kgn
kgn / AppReviews
Created June 9, 2015 23:02
App Reviews - Python script to retrieve App Store reviews and save them to a CSV file
#!/usr/bin/env python
try:
# For Python 3.0 and later
from urllib.request import urlopen
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen
import json
@ahawkins
ahawkins / Makefile
Created May 16, 2015 17:20
Example Makefile
RUBY_IMAGE:=$(shell grep FROM Dockerfile | cut -f2 -d' ')
DYNAMODB_IMAGE:=dynamodb:latest # original value ommitted
APP_IMAGE:=inventory_service/app
TAG:=$(shell git rev-parse --short HEAD)
REGISTRY:=example.registry.com # original value omitted
.DEFAULT_GOAL:= build
var Fluxxor = require('fluxxor');
var request = require('superagent');
var AuthStore = Fluxxor.createStore({
actions: {
"LOGIN_AUTH": "onLoginAuth",
},
initialize: function() {
this.currentUser = {};