Skip to content

Instantly share code, notes, and snippets.

@Allianzcortex
Allianzcortex / export_phont.sql
Last active July 13, 2016 05:30
导出学院电话
# 开始是一段标准的 sql 语句,参见如下
select tt.* from
(
select t.name,t.stu_id,t.realname,t.cur_grade,
case when t.create_time>=c.send_time and t.phone is not null then t.phone else c.recipient_phone end as phone,
case when t.create_time>=c.send_time and t.adds is not null then t.adds else c.recipient_adds end as add from
(
select b.name,b.id as stu_id,b.realname,b.cur_grade,getsecret(a.recipient_phone,'bQQyVGStWD0=','2') as phone,
concat(a.province_name,a.city_name,a.county_name,getsecret(a.recipient_adds,'bQQyVGStWD0=','2'))as adds,a.create_time from
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
// 这种循环方法挺有意思的哈
char[] numbers={'a','b','c'};
for (char x:numbers){
System.out.println(x);
@Allianzcortex
Allianzcortex / logistic regression 逻辑斯蒂回归.md
Created August 21, 2016 14:46
逻辑斯蒂回归+介绍+代码实习,在这周完成

在现实生活中我们往往需要一种算法,能够根据

script_write.py:
import subprocess
def write():
command="ping www.xueersi.com > ping_result.txt"
subprocess.Popen(command,shell=True)
if __name__=='__main__':
write()
Skip to content
Search…
All gists
GitHub
New gist @Allianzcortex
Edit
Delete
Star 0
str2int=lambda s:sum(int(v)*10**i for i,v in enumerate(s[::-1]))
str2int=lambda s:reduce((lambda x,y:x*10+y),map(int,s))

Part I

  1. 实现了 getitem 后就可以用 c[0] 这种 和 c[:2] 切片模式

  2. 在调用 in 这个方法时,如果没有 contains 方法,但它是 iterable 可迭代的,那么这也会起作用

  3. class Vector:

     def __repr__(self):
    

return 'Vector(%r, %r)' % (self.x, self.y)

@Allianzcortex
Allianzcortex / fluent-python.py
Created September 12, 2016 06:32
fluent-python实践代码
# -*- coding:utf-8 -*-
import re
RE_WORD=re.compile(r'\w+')
class Sentence(object):
def __init__(self,text):
self.text=text
self.words=RE_WORD.findall(text)

附录1:

call 的使用:

可以帮忙创建良好的 API,举几个例子:

① Django 实现的 Validators

② june 里实现的 用户验资

如何写出 Pythnnic 的工程代码:

命令行工具和正则是最基本的工具

写出一个只有一个文件的 Pythonic 代码并不难,写出一堆代码只为完成任务也不难,难的就在于 如何非常优雅地实现一个整个 Pythonic 的工程代码。

下面是一个常有的 utils: