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
" vimrc vim iman gowhari | |
set expandtab | |
set tabstop=4 | |
set shiftwidth=4 | |
set autoindent | |
set noswapfile | |
set hlsearch | |
set nowrap | |
set autochdir |
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 quopri | |
print quopri.encodestring('سیب') # '=D8=B3=DB=8C=D8=A8' | |
print quopri.decodestring('=D8=B3=DB=8C=D8=A8') # 'سیب' | |
import HTMLParser | |
unescape = HTMLParser.HTMLParser().unescape | |
print u'سیب'.encode('ascii', 'xmlcharrefreplace') # 'سیب' | |
print unescape('سیب') # 'سیب' |
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
''' | |
This implementaion of BLEU also considers synonyms and tries to give | |
more points to the correct order of words. | |
''' | |
import re | |
import os | |
import sys | |
import shelve | |
import optparse |
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 json | |
import hashlib | |
import database as db | |
from webargs import fields | |
from webargs.flaskparser import use_args | |
from flask import Blueprint, request, session, g | |
from serverbase import return_json, ErrorToClient | |
bp = Blueprint('user', __name__) |
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 config | |
import sqlalchemy as sa | |
import sqlalchemy.orm as saorm | |
import sqlalchemy.ext.declarative | |
Base = sqlalchemy.ext.declarative.declarative_base() | |
db_engine = sa.create_engine(config.db.url, echo=config.db.echo, encoding='utf-8', pool_recycle=3600) | |
Session = saorm.sessionmaker(bind=db_engine) |
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 json | |
import config | |
import logging | |
import database as db | |
from functools import wraps | |
from flask import Flask, request, session, redirect, g | |
app = Flask(__name__, | |
static_url_path=config.flask.static_url_path, |
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 user | |
def register_blueprints(app): | |
app.register_blueprint(user.bp, url_prefix='/user') | |
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
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script><!DOCTYPE html> | |
<style id="jsbin-css"> | |
body { | |
background-color: #a04; | |
} | |
.vol-icon { | |
width: 32px; | |
height: 32px; |
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
# encoding: utf8 | |
# vigenere cipher | |
# https://stackoverflow.com/a/2490718/1675586 | |
def encode(key, string): | |
encoded_chars = [] | |
for i in range(len(string)): | |
key_c = key[i % len(key)] | |
encoded_c = chr(ord(string[i]) + ord(key_c) % 256) | |
encoded_chars.append(encoded_c) |
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 json | |
import time | |
import logging | |
import telepot | |
import telepot.loop | |
thisbot_token = 'YOUR-BOT-TOKEN' | |
OlderNewer