Skip to content

Instantly share code, notes, and snippets.

View hanxiaomax's full-sized avatar
😜
code with love @ shanghai

Lingfeng_Ai hanxiaomax

😜
code with love @ shanghai
View GitHub Profile
@hanxiaomax
hanxiaomax / config.py
Created July 22, 2021 14:50
Create graph from notion with official API
my_token_v2="<token>"
database_id = ""
@hanxiaomax
hanxiaomax / cppp531.cpp
Created October 4, 2015 14:44
派生类调用基类构造函数
#include <iostream>
using namespace std;
class base
{
public:
base(){};
base(int i):base_(i){};
public:
@hanxiaomax
hanxiaomax / pytrans.py
Last active April 2, 2018 03:50
翻译指定的.po文件到目标语言,使用translator模块
#coding:utf-8
#!/usr/bin/env python
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <terry.yinzhe@gmail.com> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return to Terry Yin.
#
# Now google has stop providing free translation API. So I have to switch to
# http://mymemory.translated.net/, which has a limit for 1000 words/day free
@hanxiaomax
hanxiaomax / ajax_way_json.js
Created December 2, 2014 09:00
关于getJSON的一点点小坑
$(function(){
$("input:radio").change(function(){
var selectedvalue = $("input[name='group']:checked").val();
//使用getJSON会导致每次都从浏览器缓存里面加载json,ajax就可以实现动态的修改json并加载了
$.ajax({
type: "get",
url:'/static/select.json',
cache: false,//必须为false,否则同样会从缓存中加载
dataType : "json",
success: function(data){
@hanxiaomax
hanxiaomax / getSON.js
Created November 21, 2014 05:57
根据json创建动态表单
$(function(){
$("input:radio").change(function(){
var selectedvalue = $("input[name='group']:checked").val();
$.getJSON("/static/select.json",function(data){
$("#apply").empty();
$.each(data,function() {
if (this.catagory==selectedvalue)
{
$.each(this.subcatagory, function() {
$("#apply").append("<option>" + this.name + "</option>");
@hanxiaomax
hanxiaomax / Aisfun.py
Last active August 29, 2015 14:08
itertools模块/filter/起名软件/编码
#coding:utf-8
__author__='Lingfeng Ai'
__license__='GPL'
import itertools
class GetName(object):
def __init__(self):
self.num=0
def getResult_ordered(self,filename,list1,list2,list3,list4):
@hanxiaomax
hanxiaomax / match.py
Last active August 29, 2015 14:07
正则表达式基础学习笔记
#coding:utf-8
import re
#---------------------------
pattern=re.compile(r'.ello')#首先编译正则表达式,主要是为了复用
match=pattern.match('hello world!')#使用match来匹配
if match:
print "-------------"
print match.group()
#--------------------------
@hanxiaomax
hanxiaomax / excel2po.py
Last active October 21, 2020 03:41
excel读写/po文件转excel
#coding=utf-8
#从excel中读取中文,然后写入到po文件中,需要手动复制开头的说明文件,否则poedit不能正常读取
import xlrd
workbook = xlrd.open_workbook('Cura_copy.xls')#打开一个excel
sheet = workbook.sheet_by_name(u'sheet1')#获取一个工作表
buf=sheet.col_values(1)
for i in range(0,len(buf)):
buf[i]=unicode(buf[i]).encode('utf-8')
result=open("result.po",'w')
@hanxiaomax
hanxiaomax / GFM2pyg.py
Last active August 29, 2015 14:05
静态方法/装饰器
#coding=utf-8
#使用静态方法,装饰器
from sys import argv
import sys
import glob
import os
script,language=argv#return as strings
#TODO:行号
path=os.path.abspath(sys.argv[0])
print path
@hanxiaomax
hanxiaomax / glob learning-1
Created August 17, 2014 14:38
1.取路径 2.glob取父级目录 3.sys.argv[0]和__file__的区别
from sys import argv
import sys
import glob
import os
script=argv
print os.path.abspath(sys.argv[0])#使用__file__时,命令行和直接运行结果不同,不明白
path=os.path.abspath(sys.argv[0])
#这里sys.argv[0]得到的是相对路径,需要取一下绝对路径
print type(path)
print path+r"../*.md"