Skip to content

Instantly share code, notes, and snippets.

function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
const now = new Date();
const key = `/uploads/${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}/${uuidv4()}`
console.log(key);
@doboy
doboy / gist:7a1c72ccb807c0de3917
Created March 18, 2015 21:57
graphics magick
gm "convert" "-size" "600x900" "xc:green"
def number( seq ):
r = 0
for x in seq:
r = r * 10 + x
return r
def fact( n ):
r = 1
for i in xrange( 1, n + 1 ):
r *= i
from random import choice
# index by zero like a real computer scientist
dice = range(6)
def Yahtzee(roll):
for i xrange(len(roll)):
if roll[i] != roll[i-1]:
return False
return True
from flask import Flask, send_from_directory, render_template
app = Flask(__name__)
app.debug = True
@app.route("/")
def hello():
return render_template('index.html')
@app.route("/art/<path:filename>")
def arts(filename):
words = []
for line in open('usr/share/dict/words'):
words.append(line.split())
class Tag:
def __init__(self, tag):
self.tag = tag
def __enter__(self):
print '<%s>' % self.tag
def __exit__(self, *_):
print '</%s>' % self.tag
"apply nansum(axis=1) < paste < window(first, field='minute', increment=15) < units to data in (1335917466213, 1335312666213) streamlimit 1000 where Metadata/Extra/System = 'electric' and ((Properties/UnitofMeasure = 'kW' or Properties/UnitofMeasure = 'Watts') or Properties/UnitofMeasure = 'W') and Metadata/Location/Building like 'Soda Hall%' and not Metadata/Extra/Operator like 'sum%' and not Path like '%demand'"
query = "apply nansum(axis=1) < paste < window(first, field='minute', increment=15) < units to data in (" + starttime + ", " + endtime + ") streamlimit 10000 where Metadata/Extra/System = 'electric' and ((Properties/UnitofMeasure = 'kW' or Properties/UnitofMeasure = 'Watts') or Properties/UnitofMeasure = 'W') and Metadata/Location/Building like 'Etcheverry Hall%' and not Metadata/Extra/Operator like 'sum%' and not Path like '%demand'";
$.ajax({
async: true,
type: 'POST',
url: '/ARDgetData/api/query?',
data: querystring,
success: function(response) {
console.log(response);
starttime = 1335912676604;
endtime = 1335912676604 - 24 * 60 * 60 * 1000;
query = "apply nansum(axis=1) < paste < window(first, field='minute', increment=15) < units to data in (" + starttime + ", " + endtime + ") streamlimit 10000 where Metadata/Extra/System = 'electric' and ((Properties/UnitofMeasure = 'kW' or Properties/UnitofMeasure = 'Watts') or Properties/UnitofMeasure = 'W') and Metadata/Location/Building like 'Etcheverry Hall%' and not Metadata/Extra/Operator like 'sum%' and not Path like '%demand'";
$.ajax({
async: true,
type: 'POST',