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
| require(DT) | |
| require(shiny) | |
| custom.CSS <- " | |
| .dataTables_scrollBody thead{ | |
| visibility:hidden; | |
| } | |
| .group{ |
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
| searchCols = vector('list', ncol(mtcars)) | |
| q = list('gear'=3, 'mpg'=10) | |
| colNames = names(mtcars) | |
| for(col_ in names(q)) { | |
| pos = which(colNames == col_) | |
| searchCols[[pos]] <- list(search = q[[col_]]) | |
| } | |
| searchCols |
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
| q)rng: {[w;s;e] s + w*til ceiling(e-s)%w} | |
| q)dt: rng[1;2000.01.01;2001.01.01] / generates list of dates for the year | |
| q)data: {til x}'[(count dt)?1000] / generate some random data, sampling from 1000 - so avg should be about 500 a day. | |
| q)tab: ungroup ([]date:{(count x)#y}'[data;dt];observation:data) / this is shit - but yknow, 6 months since paid for this shit | |
| q)select avg dayCount by date.month from select dayCount: count i by date from tab / Damn son, that daily agg, turned into monthly avg. | |
| month | dayCount | |
| -------| -------- | |
| 2000.01| 472.871 | |
| 2000.02| 507.2759 | |
| 2000.03| 477.6452 |
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 do_math(x): | |
| print(x ** 2) | |
| return | |
| if __name__ == '__main__': | |
| i = input('Please insert an int: ') | |
| assert int(i), 'Not an int. terminating' | |
| i = int(i) | |
| result = do_math(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
| def wat(x): | |
| return x or 'WAT!!' |
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
| import datetime | |
| import logging | |
| import sys | |
| from mongoengine import connect | |
| from mongoengine import DateTimeField, Document, EmbeddedDocument, EmbeddedDocumentField, IntField, ListField, StringField | |
| from pymongo.errors import OperationFailure | |
| # Solution comes from following this: | |
| # https://stackoverflow.com/questions/28982285/mongodb-projection-of-nested-arrays |
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
| torrent: /home/rob/go/src/github.com/anacrolix/go-libutp/utp_internal.cpp:3314: int utp_getpeername(utp_socket*, sockaddr*, socklen_t*): Assertion `conn' failed. | |
| SIGABRT: abort | |
| PC=0x7fe6bcedb428 m=9 | |
| signal arrived during cgo execution | |
| goroutine 9961 [syscall, locked to thread]: | |
| runtime.cgocall(0x81c820, 0xc420519a10, 0x0) | |
| /usr/local/go/src/runtime/cgocall.go:131 +0x110 fp=0xc4205199e0 sp=0xc4205199a0 | |
| github.com/anacrolix/go-libutp._Cfunc_utp_getpeername(0x0, 0xc4222e39d0, 0xc421cbc408, 0x0) | |
| ??:0 +0x4d fp=0xc420519a10 sp=0xc4205199e0 |
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
| # https://stackoverflow.com/questions/11810461/how-to-perform-periodic-task-with-flask-in-python | |
| from apscheduler.schedulers.background import BackgroundScheduler | |
| from flask import Flask | |
| from flask_sqlalchemy import SQLAlchemy | |
| # initialise Flask app | |
| app = Flask(__name__) | |
| app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' | |
| db = SQLAlchemy(app) |