Skip to content

Instantly share code, notes, and snippets.

View craigderington's full-sized avatar
🚀
Automate Everything

Craig Derington craigderington

🚀
Automate Everything
View GitHub Profile
@craigderington
craigderington / de_duplicate.py
Last active June 25, 2018 16:46
De-duplicate two lists. List A contains all records. List B contains a subset of List A. Produce a clean list A NOT IN B.
# *-* coding: utf-8 *-*
lst_a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
lst_b = [1, 4, 5, 7, 9, 11, 14]
def de_duplicate(l1, l2):
"""
Return a de-duplicated list
:param l1: list splash visitor
@craigderington
craigderington / urls.py
Created March 8, 2018 14:26
Django URLs Example
# urls.py
from django.conf.urls import url
from views import CustomerListView
urlpatterns = [
url(r'^customers/$', CustomerListView.as_view()),
]

Keybase proof

I hereby claim:

  • I am craigderington on github.
  • I am craigderington (https://keybase.io/craigderington) on keybase.
  • I have a public key ASCbUM40Q7LxGnKSPW-ar29OyIwHMIHdiFCvctV6uhsAJQo

To claim this, I am signing this object:

@craigderington
craigderington / tmux-cheatsheet.markdown
Created August 11, 2017 17:44 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/bin/bash
# Pretty Welcome Message
echo -e " *************************************************** "
echo -e " *************************************************** "
echo -e " Amazon S3 Restore MySQL Databases "
echo -e " 4-18-2017 - Craig Derington "
echo -e " GitHub @craigderington "
echo -e " "
echo -e " *************************************************** "
from django.contrib import admin
from django.forms.models import BaseInlineFormSet
from .models import Item, ItemLocation
@admin.register(Item)
class ItemAdmin(admin.ModelAdmin):
fieldsets = (
('Item Details', {
'fields': ('sku', 'item_name', 'item_description', 'item_search',
class Location(BaseAddress, TimeStampedModel):
location_name = models.CharField(max_length=50, blank=False, null=False)
default_location = models.BooleanField(default=False)
def __unicode__(self):
if self.location_name and self.city:
return unicode(str(self.location_name + '-' + self.city))
class Meta:
verbose_name = 'Location'
class Item(TimeStampedModel):
LEADTIME_PERIOD = (
('D', 'DAYS'),
('W', 'WEEKS'),
('M', 'MONTHS'),
)
sku = models.CharField(max_length=50, blank=False, null=False)
item_name = models.CharField(max_length=50, blank=False, null=False)
item_description = models.TextField()
#! flask/bin/python
from flask import Flask, request, jsonify, abort, make_response, url_for
from flask_restful import Api, Resource, reqparse, fields, marshal
from flask_httpauth import HTTPBasicAuth
from datetime import datetime
import pyodbc
import json
import config
@craigderington
craigderington / models.py
Last active November 23, 2016 14:15
Solved: Django Tables2 and AJAX
from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Q
class Alert(models.Model):
SYSTEM_ALERT = 'system_alert'