#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
Don't worry about what anybody else is going to do. The best way to | |
predict the future is to invent it. | |
-- Alan Kay | |
Premature optimization is the root of all evil (or at least most of it) | |
in programming. | |
-- Donald Knuth | |
Lisp has jokingly been called "the most intelligent way to misuse a | |
computer". I think that description is a great compliment because it |
#用正则简单过滤html的<>标签 | |
import re | |
str = "<img /><a>srcd</a>hello</br><br/>" | |
str = re.sub(r'</?\w+[^>]*>','',str) | |
print str |
#coding: utf-8 | |
from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template | |
@route('/') | |
@route('/index.html') | |
def index(): | |
return '<a href="/hello">Go to Hello World page</a>' | |
@route('/hello') | |
def hello(): |
#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
# create stub, then run flask app in tornado on port 5000 (perhaps with supervisord config below http://supervisord.org/index.html) | |
#!/usr/bin/env python | |
from tornado.wsgi import WSGIContainer | |
from tornado.httpserver import HTTPServer | |
from tornado.ioloop import IOLoop | |
from myflaskapp import app | |
http_server = HTTPServer(WSGIContainer(app)) |
/** | |
* Expose `Batch`. | |
*/ | |
module.exports = Batch; | |
/** | |
* Create a new Batch. | |
*/ |
# All credit: http://stackoverflow.com/questions/4006324/how-to-atomically-delete-keys-matching-a-pattern-with-redis | |
redis-cli [options] KEYS "prefix:*" | xargs redis-cli [options] DEL |
#!/usr/bin/env python | |
"""Simple HTTP Server With Upload. | |
This module builds on BaseHTTPServer by implementing the standard GET | |
and HEAD requests in a fairly straightforward manner. | |
""" |
package main | |
import ( | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"time" | |
) | |
type Person struct { |
---- starting ---- | |
#!/bin/bash | |
python ./manage.py run_gunicorn -b 0.0.0.0:8001 -p /tmp/gunicorn.pid --daemon --access-logfile /var/log/gunicorn.log | |
echo "Server started, \n using PID /tmp/gunicorn.pid" | |
----- stopping ---- | |
#!/bin/bash | |
kill `cat /tmp/gunicorn.pid` |