中文乱码的根源在于 windows 基于一些历史原因无法全面支持 utf-8 编码格式,并且也无法通过有效手段令其全面支持。
- 安装
| """ | |
| Install : pip install pymongo flask | |
| Minimalistic url shortener : use with curl -sd "url=http://example.com/" http://this-app.com/shorten | |
| """ | |
| from flask import Flask, request, redirect, abort | |
| from pymongo import MongoClient | |
| import base64, md5, re | |
| con = MongoClient() | |
| col = con.shortener.entries |
| # encoding: utf-8 | |
| """ | |
| @author: BrikerMan | |
| @contact: eliyar917@gmail.com | |
| @blog: https://eliyar.biz | |
| @version: 1.0 | |
| @license: Apache Licence | |
| @file: w2v_visualizer.py | |
| @time: 2017/7/30 上午9:37 | |
| """ |
| logconfig = { | |
| "version": 1, | |
| "disable_existing_loggers": 0, | |
| "root": { | |
| "level": "DEBUG", | |
| "handlers": [ | |
| "console", | |
| "file", | |
| "debugfile" | |
| ] |
| library(data.table) | |
| library(dplyr) | |
| library(dtplyr) | |
| library(abroadplayr) | |
| library(GGally) | |
| library(stringr) | |
| library(ggplot2) | |
| library(wordcloud2) | |
| reports <- as.data.table(reports) |
| #!/bin/bash | |
| if [ $# -lt 1 ] | |
| then | |
| echo "Usage: "$0" <file_name>" | |
| echo "Convert files to utf-8" | |
| exit | |
| fi | |
| for i in $* | |
| do |
| @echo off | |
| SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe | |
| rem add it for all file types | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f | |
| rem add it for folders | |
| @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f |
| from __future__ import division | |
| from numpy import * | |
| class AdaBoost: | |
| def __init__(self, training_set): | |
| self.training_set = training_set | |
| self.N = len(self.training_set) | |
| self.weights = ones(self.N)/self.N | |
| self.RULES = [] |
| library(caret) | |
| library(xgboost) | |
| #------------------------------------------------------- | |
| # (1) caret + xgboost: xgbTree, auto-tuning | |
| #------------------------------------------------------- | |
| # create training sample and test sample | |
| index = createDataPartition(iris$Species, p = 0.9, list = FALSE) | |
| iris.Train = iris[index, ] | |
| iris.Test = iris[-index, ] |
| import re | |
| url = '快來好康大放送http://www.test.com/dir/zxczxc/filename.jpg?zxc=zxxc&var1=foo#bar刷台新卡' | |
| url_regex1 = 'http[s]?:\/\/(?:[a-zA-Z0-9$-_@.&+!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+(?:#[-A-z0-9]+)?' | |
| # url_regex2 = '(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?' | |
| urls = re.findall(url_regex1, url) | |
| print(urls) |