Skip to content

Instantly share code, notes, and snippets.

View Chiang97912's full-sized avatar
🎯
Focusing

Peter Chiang Chiang97912

🎯
Focusing
View GitHub Profile
import sys
import os
import hashlib
import struct
import subprocess
import collections
dm_single_close_quote = u'\u2019' # unicode
dm_double_close_quote = u'\u201d'
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
@ryanpitts
ryanpitts / gist:1304725
Created October 21, 2011 19:34
GROUP BY and Select MAX from each group in Django, 2 queries
'''
given a Model with:
category = models.CharField(max_length=32, choices=CATEGORY_CHOICES)
pubdate = models.DateTimeField(default=datetime.now)
<other fields>
Fetch the item from each category with the latest pubdate.
'''
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state