Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 datetime | |
################################################################### | |
# | |
# Showing the way bits, difficulty, target, and hash work together. | |
# | |
################################################################### | |
print "Calculating target from bits, verifying the block's hash is valid, and verify the calculated difficulty." |
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
location / { | |
rewrite ^(.+)/$ $1 permanent; | |
rewrite ^(.+)/index\.html$ $1 permanent; | |
rewrite ^(.+)\.html$ $1 permanent; | |
# Allow CORS for static files | |
add_header Access-Control-Allow-Origin $cors_origin; | |
add_header Access-Control-Allow-Methods "GET, OPTIONS"; | |
location ~* ^/files/.*.(htm|html|svg|xml) { |
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
#!/usr/bin/env python | |
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE | |
# Written by Nathan Hamiel (2010) | |
from http.server import HTTPServer, BaseHTTPRequestHandler | |
from optparse import OptionParser | |
class RequestHandler(BaseHTTPRequestHandler): | |
def do_GET(self): |
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
pip install selenium | |
pip install xvfbwrapper | |
yum install -y firefox | |
# Install the geckodriver | |
cd /tmp | |
curl -SO https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz | tar zxv - -C /usr/sbin | |
yum install -y xorg-x11-server-Xvfb | |
# yum install -y xorg-x11-Xvfb | |
# pip install pyvirtualdisplay |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Sample scraper script | |
See: https://impythonist.wordpress.com/2015/01/06/ultimate-guide-for-scraping-javascript-rendered-web-pages/ | |
""" | |
# standard imports | |
import sys |
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
# You will need to run these with superuser permissions. | |
# Either prefix `sudo` to all commands, or switch user | |
# Be very careful when you switch user | |
sudo su - root | |
# Update all the packages | |
yum update | |
# Install the basics - python27, gcc, svn, git, httpd, make, uuid |
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 nested_from_native(nested_field, data): | |
if isinstance(nested_field, serializers.BaseSerializer): | |
return nested_field.from_native(data, None) | |
return nested_field.from_native(data) | |
class ListField(fields.WritableField): | |
def __init__(self, item_field, *args, **kwargs): | |
super(ListField, self).__init__(*args, **kwargs) |
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 django import forms | |
from django.core import validators | |
from django.core.exceptions import ValidationError | |
class MinLengthValidator(validators.MinLengthValidator): | |
message = 'Ensure this value has at least %(limit_value)d elements (it has %(show_value)d).' | |
class MaxLengthValidator(validators.MaxLengthValidator): | |
message = 'Ensure this value has at most %(limit_value)d elements (it has %(show_value)d).' |
NewerOlder