Skip to content

Instantly share code, notes, and snippets.

View souldeux's full-sized avatar

Nic Perry souldeux

View GitHub Profile
{'appData_sales': '35.15', 'appData_vehicles': 0, 'appData_lro': 0, 'rateOverride_10M': 0, 'rateOverride_15M': 0, 'rateOverride_25M': 0, 'rateOverride_LRO': 0, 'rateOverride_vehicleRate_lowBand': 0, 'rateOverride_vehicleRate_highBand': 0, 'rateOverride_50M': 0, 'rateOverride_75M': 0, 'rateOverride_100M': 0, 'salesCategories_0_category': 'Retail Apparel', 'salesCategories_1_category': 0, 'salesCategories_2_category': 0, 'salesCategories_3_category': 0, 'salesCategories_4_category': 0, 'salesCategories_5_category': 0, 'salesCategories_6_category': 0, 'salesCategories_7_category': 0, 'salesCategories_8_category': 0, 'salesCategories_9_category': 0, 'salesCategories_10_category': 0, 'salesCategories_11_category': 0, 'salesCategories_12_category': 0, 'salesCategories_13_category': 0, 'debitCredit_0_category': 'EmptyRow', 'debitCredit_0_inputRate': 0, 'debitCredit_1_category': 'EmptyRow', 'debitCredit_1_inputRate': 0, 'debitCredit_2_category': 'EmptyRow', 'debitCredit_2_inputRate': 0, 'debitCredit_3_category': 'Emp
>>> endpoint = "https://canary.policyfly.com/coverall/api/v1/applications/1296/"
>>> resp1296 = requests.get(endpoint, headers=auth)
>>> next((obj['v'] for obj in resp1296.json()['Application']['derivedData']['decPage']['responses'] if obj['k'] == 'expirationDate'), None)
'2019-12-31'
>>> endpoint = "https://canary.policyfly.com/coverall/api/v1/applications/1295/"
>>> resp1295 = requests.get(endpoint, headers=auth)
>>> next((obj['v'] for obj in resp1295.json()['Application']['derivedData']['decPage']['responses'] if obj['k'] == 'expirationDate'), None)
'2020-01-01'
Internal Server Error: /smartu/api/v1/applications/180/comment/
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 227, in process_exception_by_middleware
response = middleware_method(request, exception)
@souldeux
souldeux / BaseSearchMixin.py
Created October 30, 2017 18:59
Basic Full-Text Postgres Search Mixin for Django Class-Based Views
from django.contrib.postgres.search import SearchVector
class BaseSearchMixin(object):
"""
Implements postgres full-text search engine for programmer-defined fields.
Expects self.search_fields, a tuple containing an arbitraty number of fields
to be used in the search. These should be defined in the view into which
this is mixed, and should correpsond to available text/char fields on the
model on which that view operates.
@souldeux
souldeux / statechoices.py
Created October 11, 2017 15:41
Pastable List of States & Abbreviations for a Django Choice Field
STATE_CHOICES = [
('AL', 'Alabama'),
('AK', 'Alaska'),
('AZ', 'Arizona'),
('AR', 'Arkansas'),
('CA', 'California'),
('CO', 'Colorado'),
('CT', 'Connecticut'),
('DC', 'Washington D.C.'),
('DE', 'Delaware'),
def determine_feature_importance(df):
#Determines the importance of individual features within a dataframe
#Grab header for all feature values excluding score & ids
features_list = df.columns.values[4::]
print "Features List: \n", features_list
#set X equal to all feature values, excluding Score & ID fields
X = df.values[:,4::]
#set y equal to all Score values
def get_queryset(self):
min_amount = self.request.GET.get('min_amount', None)
max_amount = self.request.GET.get('max_amount', None)
dc_contains = self.request.GET.get('dc', None)
min_date = self.request.GET.get('min_date', None)
max_date = self.request.GET.get('max_date', None)
expenses = expense.objects.all()
if min_amount:
@souldeux
souldeux / lolmonitor
Last active August 29, 2015 14:07
League of Legends Server Status Monitor
import requests
import json
from peewee import *
from datetime import datetime
import time
api_key = 'secretkey'
def get_shards():
@souldeux
souldeux / groove_hook
Last active August 29, 2015 14:07
Groove + Django Integration
"""GrooveHQ's Custom Profile app sends a REST-ful request to your server any time you ask it to update info for a user.
If you're a Django user, this means you need to set up a view that returns a JSON object and a urlconf to handle the request."""
"""First set up your URL conf wherever it makes sense in your app. For now, let's assume it's in the root urls.py with your
administrative stuff. Add the following:"""
#root urls.py
#this assumes you've already imported your views with: import views
url(r'groove/$', views.grooveHook, name='groove_hook')