Skip to content

Instantly share code, notes, and snippets.

View artschwagerb's full-sized avatar

Brian Artschwager artschwagerb

View GitHub Profile
@artschwagerb
artschwagerb / gist:11123810
Created April 20, 2014 20:03
Django URLs
from django.conf.urls import patterns, include, url
from chordcharts.views import ChordListView #for class based views
from chordcharts import views #for function based views
urlpatterns = patterns('',
url(r'^$', ChordListView.as_view(), name='chord_list'), #for class based views
url(r'^$', 'chordcharts.views.chord_list', name='chord_list'), #for function based views
url(r'^chordcharts/', include('chordcharts.urls')),
)
global
log 127.0.0.1 local0 notice
maxconn 20000
user haproxy
group haproxy
defaults
log global
mode tcp
option dontlognull
@artschwagerb
artschwagerb / gist:a310a23e215a11ce7ad1
Created June 11, 2014 15:06
Django - for loop range
{% for i in '123'|make_list %}
{% if object.property == i|add:"0" %}
<li>(Selected) Property {{ i }}</li>
{% else %}
<li>Property {{ i }}<li>
{% endif %}
{% endfor %}
@artschwagerb
artschwagerb / gist:0aa07f31c44b11ee4eb7
Created December 4, 2014 15:14
Destiny idlink.txt creation script
import os
image_folder = '/Users/brian/Desktop/Student_Images'
image_linkfile = image_folder+'/idlink.txt'
f = open(image_linkfile,'wb')
for filename in os.listdir(image_folder):
filepath = os.path.join(image_folder,filename)
if os.path.isfile(filepath):
@artschwagerb
artschwagerb / barcode.py
Created January 5, 2015 20:14
barcode model property
from base64 import b64encode
from reportlab.lib import units
from reportlab.graphics import renderPM
from reportlab.graphics.barcode import createBarcodeDrawing
from reportlab.graphics.shapes import Drawing
class barcode:
def get_barcode(self, value, width, barWidth = 0.05 * units.inch, fontSize = 30, humanReadable = True):
barcode = createBarcodeDrawing('Code128', value = value, barWidth = barWidth, fontSize = fontSize, humanReadable = humanReadable)
@artschwagerb
artschwagerb / gist:91137af51a421b600773
Last active August 29, 2015 14:14
Raspberry Pi Tornado Temperature Server
#!/usr/bin/python
import tornado.ioloop
import tornado.web
MIN_TEMP = 0
ERROR_TEMP = -999.99
TEMP_SENSORS = {
"28-00043a4518ff" : {"label":"A","location":"Server-1-Front","temperature":None},
"28-00043b61b4ff" : {"label":"B","location":"Server-1-Back","temperature":None},
@artschwagerb
artschwagerb / gist:8efa45d6eefe6697ef07
Last active August 29, 2015 14:14
Django Revision?
#import reversion
from django.db import models
from django.contrib.auth.models import User
class RevisionManager(models.Manager):
def get_queryset(self):
return super(RevisionManager, self).get_queryset().latest()
class Ticket_Status(models.Model):
@artschwagerb
artschwagerb / update_temp.py
Last active August 29, 2015 14:18
Server Room Temperature Probe
#!/usr/bin/python
import sys
import rrdtool
import json
MIN_TEMP = 0
ERROR_TEMP = -999.99
TEMP_SENSORS = {
"E" : {"sensor":"28-00043a4518ff","location":"Server Room Rack B/C (Back)","temperature":{"celsius":None,"fahrenheit":None}},
@artschwagerb
artschwagerb / htps_studentwithdrawn.py
Created May 5, 2015 21:12
Genesis Report CSV to Django
import os
import sys
import datetime
from datetime import datetime
import csv
import traceback
from django.core.management.base import BaseCommand, CommandError
@artschwagerb
artschwagerb / systems_convert.py
Created May 16, 2015 02:09
PIL - Convert to bmp, and resize
import os
from PIL import Image
size = 145, 145
dir_path = '/Users/brian/Desktop/systems_silly'
for filename in os.listdir(dir_path):
if filename.endswith('.bmp'):
# Destroy Previously Converted Bmp
try:
os.remove(os.path.join(dir_path,filename.replace('.jpg','.bmp')))
except: