Skip to content

Instantly share code, notes, and snippets.

@maracuja
maracuja / polymorphic.sql
Created July 17, 2020 11:08
Polymorphic Association Example
CREATE TABLE linkable (
id serial PRIMARY KEY
);
CREATE TABLE obja (
id integer not null,
name varchar(50) NOT NULL,
FOREIGN KEY(id) REFERENCES linkable(id)
);

Odds Provider Message Details

For a typical match we will receive messages in the following order; a new_fixture message, then a series of price updates. when the match starts and ends we will receive messages telling us so.

new_fixture
{
    timestamp: 2020-05-01 12:00:00.001,
    game: [lol|csgo],
 match_id: 1,
@maracuja
maracuja / dynamo_db.py
Created September 7, 2018 14:36
Dynamo DB Test
import boto3
db = boto3.resource(
'dynamodb',
region_name='',
)
table = db.Table('table_name')
sample_la = '123123123'
@maracuja
maracuja / doc_upload.py
Last active September 13, 2018 09:51
doc_uploads
from django.db import models
LOAN_PACKAGE_STEPS = [
('la', 'LA',),
('ddq', 'DDQ'),
]
class DocumentCategory(models.Model):
name = models.CharField(max_length=255)
short_name = models.CharField(max_length=255, db_index=True)
@maracuja
maracuja / fame-bits.py
Last active May 17, 2018 13:24
Get financials from FAME
'''
Questions I want answered.
#1 I can get the 80k~ entities out of FAME
- try with one of Marya's searches √
#2 I can ask for the data in the format that I want per company
- try with a complex list format
'''
'''This is #1'''
from suds.client import Client
@maracuja
maracuja / upload_to_s3.py
Created November 9, 2017 10:59
Backup database to S3
import datetime
from fabric.api import *
from fabric.colors import cyan, green
import boto
import boto.s3
from boto.s3.key import Key
@maracuja
maracuja / email.py
Created January 23, 2017 16:48
Emailling attachments in django
from django.core.mail import EmailMessage
email = EmailMessage(
'Hello',
'Body goes here',
'my.name@address.co.uk',
['your.name@address.co.uk'],
)
email.attach_file('/home/ijiro/image.png')
@maracuja
maracuja / cmd.sh
Last active March 22, 2016 16:55 — forked from anonymous/cmd.sh
sample curl request against the vision api
curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=API_KEY_HERE --data-binary @doodle.json
@maracuja
maracuja / remove.py
Created September 9, 2015 08:56
Member Duplicates Removal
def get_membership(code):
memberships = Membership.objects.filter(code=code)
if memberships.count() > 1:
print '-------- code %s has %s memberships' % (code, memberships.count(),)
membership = None
for m in memberships:
if m.customermembership_set.count() > 0:
print '------------ membership %s is linked to customer memberships' % m.id
membership = m
else:
@maracuja
maracuja / 1_signals.py
Last active August 29, 2015 14:26
Device Deletion and Synchronisation Code
'''
Runs when a device is deleted in the Skylark API. delete
'''
def sync_deletion(sender, instance, *args, **kwargs):
try:
if instance.removed:
delete_device(instance)
'''
when synching with ooyala we send a hash of the user id because that's
what we use on the front end.