This file contains 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
""" | |
Bitcoin Daemon RPC wrapper for simple calculations, top address list, | |
maybe block explorer verification, etc. | |
""" | |
import time | |
import operator | |
import pickle | |
import json |
This file contains 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
try: | |
range = xrange | |
log.warning("Replacing `range` with `xrange`.") | |
except NameError: | |
pass |
This file contains 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 validate_model(params=None, match=None, headers=lambda r: tuple(), | |
json=json, | |
invalid_params_exc=pyramid.httpexceptions.HTTPBadRequest, | |
invalid_match_exc=pyramid.httpexceptions.HTTPNotFound | |
): | |
"""Basic validation decorator for usage in `view_config`. | |
Takes `params` and `match` as arguments. | |
`params` - Schema to use to and instruct to validate requests.params | |
`match` - Schema to use to and isntruct to validate request.match |
This file contains 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 os | |
import shutil | |
import pickle | |
import cgi | |
import tempfile | |
import formencode | |
import hashlib |
This file contains 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 logging | |
log = logging.getLogger(__name__) | |
from subprocess import Popen, PIPE | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.nonmultipart import MIMENonMultipart | |
from email.mime.text import MIMEText |
This file contains 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 HmacValidator(formencode.validators.FancyValidator): | |
""" | |
""" | |
hashalg = hashlib.sha512 | |
messages = { | |
'malformed': 'Malformed challenge hash.' | |
} |
This file contains 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 math | |
skellie = (438, 26, -410) | |
zombie = (443, 16, -386) | |
c = (440, 21, -398) | |
def dist(x1, y1, z1, x2, y2, z2): | |
return (math.sqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2)) | |
for yn in range(c[1], 0, -1): | |
cn = c[0], yn, c[2] |
This file contains 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
// src: http://stackoverflow.com/a/646643 | |
// Add `startsWith` and `endsWith` to the String prototype. | |
if (typeof String.prototype.startsWith != 'function') { | |
String.prototype.startsWith = function (str){ | |
return this.slice(0, str.length) == str; | |
}; | |
} | |
if (typeof String.prototype.endsWith != 'function') { | |
String.prototype.endsWith = function (str){ |
This file contains 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 pyramid.interfaces import IRoutesMapper | |
from pyramid.request import Request | |
@view_config(route_name='socket_endpoint', renderer='json') | |
def socket_endpoint(request): | |
"""Create a socket endpoint for the client. | |
""" | |
if 'ns' in request.params: |
This file contains 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
/* Mimics a very simple Request/Response dynamic through a | |
socket. | |
see `bicycle_path.views.EnabledNamespace` for an example of | |
the server-side component. | |
*/ | |
function socketRequest(socket, method, data, options) { | |
data || (data = {}); | |
options || (options = {}); | |
options.timeout || (options.timeout = 10000); |