Skip to content

Instantly share code, notes, and snippets.

View nlpjoe's full-sized avatar
🎯
Focusing

Jzzhou nlpjoe

🎯
Focusing
View GitHub Profile
@nlpjoe
nlpjoe / demo.md
Created March 5, 2018 06:07
如何在Python中使用static、class、abstract方法 #python

静态方法,不需要对象初始化

class Pizza(object):
    @staticmethod
    def mix_ingredients(x, y):
        return x + y
 
    def cook(self):
@nlpjoe
nlpjoe / 涂色问题.md
Last active March 16, 2018 05:21
[涂色] #algorithm

一个圆盘,分成N块,有M种涂色方案,要求相邻两块不可同色,有多少种涂色方案。

A(N)可以看成第一块M种和剩下的M-1块又N-1种涂色方案,但是包含了第一块和最后一块同色的情况,即A(N-1) A(N) = M * (M-1)^N-1 - A(N-1)

import math


def vender(N, M): # N块, M种涂色方案
@nlpjoe
nlpjoe / 排序算法.md
Last active March 16, 2018 13:20
排序算法 #algorithm

快排

  • 第3行: 判断列表长度是否小于等于1, 如果小于等于1,直接返回列表
  • 第4行:返回递归函数拼接的列表,[lt for lt in L[1:] if lt <= L[0]] 列表推导表达式,返回一个比 L[0] 小的列表,[ge for ge in L[1:] if ge >= L[0]], 返回一个比L[0] 大的列表, 再加上L[0] 就构成完整的列表
#coding:utf-8
def qsort(L):
    if len(L) <= 1: return L
    return qsort([lt for lt in L[1:] if lt < L[0]]) + L[0:1]+ \
@nlpjoe
nlpjoe / mxboard运行命令.md
Last active September 3, 2018 03:00
[mxboard运行命令] #linux
  1. 准备一个python脚本写入正态分布的数据
import mxnet as mx
from mxboard import SummaryWriter


with SummaryWriter(logdir='./logs') as sw:
    for i in range(10):
 # create a normal distribution with fixed mean and decreasing std
@nlpjoe
nlpjoe / idf.md
Created April 13, 2018 12:53
idf代码
    def _tf(self, word, count):
        return count[word] / sum(count.values())

    def _idf(self, word, count_list):
        if word in self.idf_dict:
            return self.idf_dict[word]
        c_idf = sum(1 for q_id in count_list.keys() if word in count_list[q_id])
        self.idf_dict[word] = math.log(len(count_list)) / (1 + c_idf)
 return self.idf_dict[word]
@nlpjoe
nlpjoe / .gitignore
Last active June 17, 2019 06:53
[python utils] #python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
bin/
build/
@nlpjoe
nlpjoe / virtuoso.md
Last active December 21, 2019 13:04
[virtuoso utils] sql语言 #virtuoso

重要设置

ResultSetMaxRows默认10000,影响返回结果

查看导入状态

select * from DB.DBA.load_list;

导入N3数据

@nlpjoe
nlpjoe / vim.md
Last active June 17, 2019 02:42
[vim utils] #vim

启动及关闭 Vi/Vim

  • 方法一:使用 Ctrl-z 以及 fg 这两个命令组合。
  • 方法二:使用行命令 :sh。

:1,$!sort 将文件内的所有内容排序

q:会显示使用过的行命令历史

@nlpjoe
nlpjoe / linux.md
Last active September 3, 2018 03:00
[linux utils] #linux

linux下通过进程名查看其占用端口:

1、先查看进程pid
ps -ef | grep 进程名

2、通过pid查看占用端口
netstat -nap | grep 进程pid

linux通过端口查看进程: