Skip to content

Instantly share code, notes, and snippets.

🚀
Liftoff #fpvracing

Craig Derington craigderington

🚀
Liftoff #fpvracing
  • Craig Derington
Block or report user

Report or block craigderington

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@craigderington
craigderington / decoder.py
Created Mar 12, 2019
Python3 Socket Server Data Packet Decoder
View decoder.py
# .env/bin/python
# coding: utf-8
from collections import namedtuple
from datetime import datetime
def pad_reading(_reading):
"""
Return a full binary representation of the individual bytes
@craigderington
craigderington / server.py
Created Mar 12, 2019
Python3 Socket Server - Main App
View server.py
#!.env/bin/python
# -*- coding: utf-8 -*-
import socket
import sys
from db import db_session
from decoder import inspect_header, decode_header, decode_readings
from datetime import datetime
from models import Tx, TxHeader, TxReading
from sqlalchemy import exc
@craigderington
craigderington / db.py
Created Mar 12, 2019
Python3 Socket Server SQLAlchemy
View db.py
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql://user:pass@localhost/RadioData', convert_unicode=True, pool_pre_ping=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base = declarative_base()
session = db_session()
@craigderington
craigderington / models.py
Created Mar 12, 2019
Python3 Socket Server Data Model
View models.py
from db import Base
from datetime import datetime
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, Text, Float
from sqlalchemy.orm import relationship
class RadioType(Base):
__tablename__ = 'radio_types'
id = Column(Integer, primary_key=True)
@craigderington
craigderington / app.py
Created Mar 11, 2019
A small excerpt from MDI Data API
View app.py
@app.route('/api/v1.0/sms/<string:phone_number>', methods=['GET'])
def get_sms_data(phone_number):
"""
Append data to Mobile Number
Return the Person obj by cell phone number
:param: string: phone_number
:return: obj(Person), type(json)
"""
geo, carrier, time_zone, city_geocode = range(4)
@craigderington
craigderington / models.py
Created Mar 11, 2019
MDI - Data Model for Real Time Consumer Data Appending
View models.py
from db import Base
from datetime import datetime
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, Text, Float
from sqlalchemy.orm import relationship
from werkzeug.security import generate_password_hash, check_password_hash
import uuid
# Define application Bases
View app.py
from flask import Flask, Response, abort, request, jsonify, g, url_for, render_template, flash
from flask_mail import Mail, Message
from flask_sslify import SSLify
from flask_sqlalchemy import SQLAlchemy
from flask_httpauth import HTTPTokenAuth
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from sqlalchemy import exc, and_, desc
from celery import Celery
from datetime import datetime
from db import db_session
@craigderington
craigderington / urls.py
Created Mar 8, 2019
DRF by Example Root URLs Module
View urls.py
from django.urls import path
from django.conf.urls import include
from django.conf import settings
from django.contrib import admin
from rest_framework_swagger.views import get_swagger_view
from .views import api_root
schema_view = get_swagger_view(title='DRF by Example')
# url list
@craigderington
craigderington / views.py
Last active Mar 8, 2019
DFR by Example Views Module
View views.py
from .models import Location
from .serializers import LocationSerializer
from rest_framework.response import Response
from rest_framework import generics, permissions
from rest_framework import status
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
import GeoIP
import ipaddress
@craigderington
craigderington / admin.py
Created Mar 8, 2019
DRF by Example Admin module
View admin.py
from django.contrib import admin
from .models import Location
# Register your models here.
class LocationAdmin(admin.ModelAdmin):
list_display = ['ip_addr', 'region_name', 'country_name', 'time_zone', 'latitude', 'longitude']
search_fields = ['ip_addr', 'region_name', 'latitude', 'longitude']
list_filter = ['region_name', 'time_zone']
You can’t perform that action at this time.