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 socket, ssl, pprint, threading, time | |
HOST = '127.0.0.1' | |
PORT = 8090 | |
CA = 'server.csr' | |
KEY = 'server.key' | |
CERT = 'server.crt' | |
#openssl genrsa -des3 -out server.key.orig 2048 | |
#openssl rsa -in server.key.orig -out server.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
import os | |
import sys | |
try: | |
import canistreamit | |
print canistreamit | |
except Exception as e: | |
print type(e), e | |
from setuptools.command import easy_install | |
easy_install.main(['-U', 'canistreamit']) |
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
#!/bin/bash | |
FILENAME="$1.p12" | |
echo $FILENAME | |
openssl pkcs12 -in $FILENAME -out $1.cert -clcerts -nokeys -passin pass: | |
openssl pkcs12 -in $FILENAME -out $1.key -nocerts -nodes -passin pass: |
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
{% with messages = get_flashed_messages(category_filter=["error"]) %} | |
{% if messages %} | |
<div class="panel panel-danger"> | |
<div class="panel-heading"> | |
Error | |
</div> | |
<div class="panel-body"> | |
<ul class=flashes> | |
{% for message in messages %} | |
<li>{{ message }}</li> |
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 hashlib | |
from flask import request, make_response, Response | |
import datetime | |
from functools import wraps | |
def just_cache(f): | |
@wraps(f) | |
def _wrap(*args, **kwargs): | |
if 'If-Modified-Since' in request.headers: | |
return Response(status=304) |
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
<!doctype html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
<script src="http://knockoutjs.com/downloads/knockout-2.3.0.js"></script> | |
<script src="http://pagerjs.com/demo/pager.min.js"></script> | |
</head> | |
<body> |
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 AutoSave(object): | |
def __init__(self, d, collection): | |
self.d = d | |
self.collection = collection | |
def __enter__(self): | |
return self.d | |
def __exit__(self, type, value, traceback): |
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
timeit.timeit('x()', setup=''' | |
def create_constant(value): | |
return itertools.repeat(value).next | |
x=create_constant("") | |
''') | |
#0.13626525126508682 | |
timeit.timeit('x()', setup='def x(): ""') | |
#0.17869136946876552 | |
timeit.timeit('x()', setup='x = lambda: ""') | |
#0.18088355837787162 |
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
# self.app can be None | |
# self.app.config.get('DATABASE') can be None | |
try: | |
db = self.app.config['DATABASE'] | |
logger.debug('Using database "{db}"'.format(db=db)) | |
except: | |
db = 'test' | |
logger.warning('DATABASE setting not set, using database "test"') |
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
GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,CREATE TEMPORARY TABLES, DROP, REFERENCES ON database.* TO user@localhost IDENTIFIED BY 'password'; |