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 | |
NAME="myproject" | |
VIRTURLROOT=/home/ubuntu/.virtualenvs/hezhi | |
DJANGODIR=/var/www/hezhi | |
SOCKFILE=/var/www/hezhi/run/gunicorn.sock | |
USER=ubuntu | |
GROUP=ubuntu | |
NUM_WORKERS=3 | |
DJANGO_SETTINGS_MODULE=hezhi.settings.dev |
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 | |
NAME="hezhi" # Name of the application | |
PYTHONPATH=/home/ubuntu/.virtualenvs/hezhi/bin/python3 # Python path | |
DJANGODIR=/var/www/hezhi # Django project directory | |
SOCKFILE=/var/www/hezhi/run/gunicorn.sock # we will communicte using this unix socket | |
USER=ubuntu # the user to run as | |
GROUP=ubuntu # the group to run as | |
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
DJANGO_SETTINGS_MODULE=hezhi.settings # which settings file should Django use, change to |
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
#include <stdio.h> | |
#define IN 1 | |
#define OUT 0 | |
#define MAXWORDLEN 10 | |
void drawChart(int maxValue, int *wordsLengthNum) | |
{ | |
int i, j; |
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
// | |
// main.c | |
// PointerPlayer | |
// | |
// Created by Vicent Tsai on 16/3/1. | |
// Copyright © 2016年 HeZhi Corp. All rights reserved. | |
// | |
#include <stdio.h> | |
#include <string.h> |
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
# https://community.topcoder.com/stat?c=problem_statement&pm=2402&rd=5009 | |
# | |
# 状态转移方程: | |
# | |
# max{ | |
# max{m[i-1][0], m[i-2][0] + A[i-1]}, | |
# max{m[i-1][1], m[i-2][1] + A[i]} | |
# } | |
# |
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
# https://community.topcoder.com/stat?c=problem_statement&pm=1259&rd=4493 | |
def longest_zigzag(A): | |
n = len(A) | |
d = [0] * n | |
s = [0] * n | |
last_indices = [0] * n | |
longest_len = 1 | |
for i in range(0, n): |
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
# http://www.hawstein.com/posts/dp-novice-to-advanced.html | |
# d(i) = max{1, d(j)+1}, 其中j<i, A[j]<=A[i] | |
def longest_increasing_sequence(A): | |
n = len(A) | |
d = [0] * n | |
last_idx_to_this_one = [0] * n | |
length = 1 | |
for i in range(0, n): |
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
@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { | |
UIImageOrientation scrollOrientation; | |
CGPoint lastPos; | |
} | |
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { | |
if (tableView.isDragging) { | |
UIView *myView = cell.contentView; | |
CALayer *layer = myView.layer; | |
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; |
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
from flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.wtf import Form | |
from flask.ext.babel import gettext | |
from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField | |
from wtforms.validators import Optional, Required | |
app = Flask(__name__) | |
db = SQLAlchemy(app) |
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
""" Inspired by http://flask.pocoo.org/snippets/40/ """ | |
app = Flask(__name__) | |
@app.url_defaults | |
def hashed_url_for_static_file(endpoint, values): | |
if 'static' == endpoint or endpoint.endswith('.static'): | |
filename = values.get('filename') | |
if filename: | |
if '.' in endpoint: # has higher priority |