Skip to content

Instantly share code, notes, and snippets.

View CapnKernel's full-sized avatar

Mitch Davis CapnKernel

  • Melbourne, Australia
View GitHub Profile
class ItemStatus(models.Model):
name = models.CharField(max_length=96)
class Item(models.Model):
itemStatus_unknown = ItemStatus.objects.get(name="Other")
status = models.ForeignKey(ItemStatus, default=itemStatus_unknown)
def customer_choice_list():
customers = list((c.id, c.name) for c in Customer.objects.order_by('id'))
return customers
class NewOrChangeOrderForm(forms.Form):
customer = forms.ChoiceField(choices=customer_choice_list())
@CapnKernel
CapnKernel / gist:6043692
Created July 20, 2013 03:06
Problem interpreting ambiguous Excellon drill data
=== border.gko === Just shows outline of board so we can get our bearings.
G04 This is an RS-274x file exported by *
G04 gerbv version 2.6.0 *
G04 More information is available about gerbv at *
G04 http://gerbv.gpleda.org/ *
G04 --End of header info--*
%MOIN*%
%FSLAX34Y34*%
%IPPOS*%
M71
M48
T1F00S00C0.500
T2F00S00C0.700
T3F00S00C0.800
T4F00S00C0.900
T5F00S00C1.000
T6F00S00C1.400
T7F00S00C1.700
T8F00S00C2.000
#! /usr/bin/env python
i1 = 1
i2 = 5
r = xrange(i1, i2 + 1)
solutions = ((x, y, z) for x in r for y in r for z in r if x * x + y * y == z * z)
for solution in solutions:
10 REM Length of hypotenuse of triangle
20 A=3
30 B=4
40 GOSUB 100
50 PRINT "A triangle with sides ", A, " and ", B, " has a hypotenuse of length ", C
20 A=5
30 B=12
40 GOSUB 100
50 PRINT "A triangle with sides ", A, " and ", B, " has a hypotenuse of length ", C
60 END
<script id="ois-order-template" type="x-handlebars-template">
{% verbatim %}
{{#each this}}
<li><a href="{% endverbatim %}{% url 'backend.views.order' id="{{ id }}" as my_url %}{{ my_url|safe }}{% verbatim %}">link</a> for {{ id }}/{{ hash }}</li>
{{/each}}
{% endverbatim %}
</script>

=>
@CapnKernel
CapnKernel / output.html
Last active December 30, 2015 21:19
Iterating over nested data structures in Django templates
<pre>
nds={u&#39;outer1&#39;: (&#39;mid1a&#39;, &#39;mid1b&#39;), u&#39;outer2&#39;: &#39;mid2a&#39;}.
outer=outer1
mid=o
mid=u
mid=t
from django.shortcuts import render
from django.template import Template, RequestContext
from django.http import HttpResponse
def view(request):
nds = {
u'outer1': ('mid1a', 'mid1b'),
u'outer2': ('mid2a', ),
}
--- pidgin-lwqq/liblwqq/CMakeLists.txt~ 2014-02-12 10:55:06.000000000 +1100
+++ pidgin-lwqq/liblwqq/CMakeLists.txt 2014-02-12 11:05:24.867410181 +1100
@@ -88,7 +88,7 @@
message( "===============================================")
configure_file(config.h.in ${PROJECT_BINARY_DIR}/lwqq-config.h)
-install(FILES "${PROJECT_BINARY_DIR}/lwqq-config.h" DESTINATION include/lwqq)
+# install(FILES "${PROJECT_BINARY_DIR}/lwqq-config.h" DESTINATION include/lwqq)
add_subdirectory(lib)
add_subdirectory(src)