This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gm "convert" "-size" "600x900" "xc:green" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words = [] | |
for line in open('usr/share/dict/words'): | |
words.append(line.split()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tag: | |
def __init__(self, tag): | |
self.tag = tag | |
def __enter__(self): | |
print '<%s>' % self.tag | |
def __exit__(self, *_): | |
print '</%s>' % self.tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
NewerOlder