onchance
Re:Robinhood stock trading app confirms $110M raise at $1.3B valuation
on Saturday April 29, 2017 @04:14PM (#14228500)
But the “fixed” monthly cost varies depending on the size of your credit line, so there is an effective interest rate of 5% or more.
https://d2ue93q3u507c2.cloudfront.net/assets/robinhood/legal...
Re:Paper Centrifuge
on Wednesday January 11, 2017 @07:21PM (#13378786)
The lab behind this invention is led by Manu Prakash, a MacArthur Fellow [1] with a knack for unconventional solutions. He's the same guy who developed Foldscope, an ultra low cost microscope [2][3].
[1]: https://www.macfound.org/fellows/965/
[2]: https://en.wikipedia.org/wiki/Foldscope
[3]: https://www.ted.com/talks/manu_prakash_a_50_cent_microscope_...
Re:Be Careful with Python's New-Style String Format
on Monday January 02, 2017 @07:12PM (#13305589)
Would sanitizing for double underscores be enough to capture the most dangerous cases?
import re
def sanitize(user_input):
"""Sanitize user input for str.format
Usage:
sanitize("{post.title} - {post.blog.title}")
sanitize("{post.title}: Another fine post by "{post.author}")
sanitize("~~~ xXx {post.blog.__init__.dbconnection.__keys__.password} xXx ~~~")
"""
return re.sub(r'{[^}]*__[^}]*}', '', user_input)
Even better, we could specify which variables to allow in user input: import re
def sanitize(user_input, *allowed_variables):
"""Sanitize user input for str.format
Usage:
allowed_variables = ["post.blog.title", "post.title", "post.author"]
sanitize("{post.title} - {post.blog.title}", *allowed_variables)
sanitize("{post.title}: Another fine post by "{post.author}", *allowed_variables)
sanitize("~~~ xXx {post.blog.__init__.dbconnection.__keys__.password} xXx ~~~", *allowed_variables)
"""
for match in re.finditer(r'{([^}]*)}', user_input):
if match[1] not in allowed_variables:
user_input = user_input.replace(match[0], '')
return user_input