- 博客(368)
- 资源 (12)
- 收藏
- 关注
原创 面试题atoi
#include<stdio.h>int myatoi(char * str){ int sign = 0; int result = 0; if (str == NULL) { printf("Invalid input.\n"); return -...
2019-03-02 23:01:28 286
原创 字符串面试题
#include<stdio.h>#include<assert.h>#include<string.h>char * mystrcpy(char * dest, const char * src){ assert((dest!=NULL) && (src!=NULL)); char *addr = de...
2019-03-02 22:24:18 284
原创 sqlalchemy数据库操作增删改查
from sqlalchemy import create_enginefrom sqlalchemy.orm import sessionmaker,relationship, backreffrom sqlalchemy.ext.declarative import declarative_basefrom sqlalchemy import Column, Integer, Strin...
2018-10-02 20:54:25 538 1
原创 python 类之 __call__()函数
class Person(object): def __init__(self, name, age, sex): self.name = name self.age = age self.sex = sex print ('__init__ ({},{},{})'.format(self.name, self.age, se...
2018-09-08 14:42:04 1396
原创 python的类继承&函数重载
class的继承、wait函数重载。调用时 调用实例本身的函数class Launcher(object): def __init__(self, conf, restart_method='reload'): self.conf = conf self.restart_method = restart_method def wait(self...
2018-08-31 12:36:45 1924
原创 标准库-inspect
import inspectimport os#basename求一长串路径中,最后一个路径的名字binary = os.path.basename(inspect.stack()[-1][1])print (binary)binary1 = (inspect.stack())print (binary1)binary2 = (inspect.stack()[-1][1])p...
2018-08-30 22:47:50 810
原创 类方法classmethod
python中 @classmethod classmethod是用来指定一个类的方法为类方法,没有此参数指定的类的方法为实例方法。但第一个参数需要是表示自身类的 cls 参数,可以来调用类的属性,类的方法,实例化对象。#!/usr/bin/python# -*- coding: UTF-8 -*-class Service(object): service_name = "...
2018-08-30 22:26:43 892
原创 2018网络部分总结
目前网络部分学习情况:学习的路还很长,下面的解释来自网络,很形象(分享): 简单的说就是专家级能干所有活, 高级能干大部分活, 中级能干一半的活, 初级能干基础的活。但专家级干初级的活,并不一定比初级的快。打个比喻: 初级知道砖头怎么搬,搬到哪里;(农民工) 中级知道墙怎么砌,下一堵墙怎么砌;(包工头) 高级知道房子怎么盖,在哪里盖房子;(施工项目经理) 专家级知道...
2018-06-03 13:50:38 294
原创 spice日志提取
编写其他工程,可以借鉴。#include <stdarg.h>#include <stdio.h>#include <glib.h>#define spice_info(format, ...) G_STMT_START { \ spice_log(G_LOG_LEVEL_INFO, __FUNCTION__, "" format, #
2017-12-05 18:53:41 1461
原创 flask:使用flask-mail客户端访问触发发送邮件
export MAIL_USERNAME=’[email protected]’ xport MAIL_PASSWORD=’prfrvnqudesgbjxx’启动服务: python mail3.py runserver –host 0.0.0.0 //允许任何主机访问,flask默认端口为5000能ping上面服务器IP的任意主机访问:192.168.0.50:5000 浏览器访问触
2017-12-02 23:32:40 839
原创 spice测试工程
test-stream.c参考: http://blog.csdn.net/sparkliang/article/details/5486069 http://blog.csdn.net/sparkliang/article/details/5490242Linux 下的描述符传递Linux 系统系下,子进程会自动继承父进程已打开的描述符,实际应用中,可能父进程需要向子进程传递“后打开的描述符”
2017-12-01 22:29:57 509
原创 writev与readv系统调用
来自man writev readv, writev, preadv, pwritev - read or write data into multiple buffers 读写数据到多个缓冲去#include <sys/uio.h>ssize_t readv(int fd, const struct iovec *iov, int iovcnt);ssize_t wri
2017-12-01 21:41:40 2162
原创 spice测试程序01-test-loop.c
spice-server测试程序,开个头: /root/spice-0.13.3/server/tests/test-loop.cstatic void ignore_sigpipe(void){ struct sigaction act; /* struct sigaction{ //信号处理函数,或是SIG_IGN,或是SIG_DFL
2017-08-13 21:33:16 701
翻译 glib-The Main Event Loop
参考: https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#GMainContext Description:The main event loop manages all the available sources of events for GLib and GTK+ applications. Thes
2017-08-08 22:28:40 481
翻译 Gobject简介
Introduction Most modern programming languages come with their own native object systems and additional fundamental algorithmic language constructs. Just as GLib serves as an implementation of such fu
2017-07-31 23:15:46 395
原创 linux内核深入学习参考
linux内核学习、参考: http://blog.chinaunix.net/uid-23629988-id-3187266.html http://blog.chinaunix.net/uid-23629988-id-2973560.html
2017-07-12 23:12:54 248
原创 python数据处理(csv->折线图)
highs_lows.py# -*- coding: utf-8 -*-"""Created on Mon May 29 10:00:16 2017@author: Administrator"""import csvfilename = '300001_D.csv'with open(filename) as f: reader = csv.reader(f) heade
2017-05-29 11:48:43 10055 2
原创 pygal-直方图
模拟掷骰子die.py # -*- coding: utf-8 -*-"""Created on Mon May 29 09:11:05 2017@author: Administrator"""from random import randintclass Die(): """表示一个骰子的类""" def __init__(self, num_sides=6):
2017-05-29 09:50:27 2244
原创 matplotlib-随机漫步
random_walk.py# -*- coding: utf-8 -*-"""Created on Mon May 29 07:56:41 2017@author: Administrator"""# -*- coding: utf-8 -*-"""Created on Mon May 29 07:52:39 2017@author: Administrator"""from rand
2017-05-29 08:45:50 788
原创 matplotlib入门-绘制简单折线图
# -*- coding: utf-8 -*-"""Spyder EditorThis is a temporary script file."""import matplotlib.pyplot as pltinput_values = [1, 2, 3, 4, 5]squares = [1, 4, 9, 16, 25]plt.plot(input_values, squares, l
2017-05-28 23:38:23 1036
原创 paramiko之ssh_and_sftp
1.首先安装paramiko以及相应的依赖 2.测试主机 测试项目 192.168.0.50(net01) Ssh登录 192.168.0.102(net02) Sftp(Secure File Transfer Protocol)测试项一:ssh登录,查看远程信息sshclient.py#!/usr/bin/env pyt
2017-05-28 11:18:30 522
原创 pexpect之ssh_scp02
import pexpectimport sysip="192.168.197.128"user="root"passwd="1"target_file="/var/log/mariadb/mariadb.log"child = pexpect.spawn('/usr/bin/ssh', [user+'@'+ip])fout = file('mylog.txt', 'w')child
2017-05-24 00:07:33 424
原创 pexpect02-之ftp
from __future__ import unicode_literalsimport pexpectimport syschild = pexpect.spawn('ftp ftp.sjtu.edu.cn')child.expect('(?i)root')child.sendline('anonymous')child.expect('(?i)password')child.sen
2017-05-23 22:58:15 304
原创 pexpect-scp_and_ssh
import pexpectimport sysimport timechild = pexpect.spawn('scp /root/test.c [email protected]:/home/')#child = pexpect.spawn('ssh [email protected]')fout = file('mylog.txt','w')child.logfile
2017-05-23 00:21:39 390
原创 python之numpy学习02
# -*- coding: utf-8 -*-"""Created on Sun May 14 21:16:22 2017@author: Administrator"""import numpy as np#numpy ndarray 计算全部元素的和、按行求和,按列求和。a = np.arange(20).reshape(4, 5)print ("a:")print (a)prin
2017-05-14 22:31:43 326
原创 python之numpy学习
# -*- coding: utf-8 -*-"""Created on Fri May 12 22:59:30 2017@author: Administrator"""import numpy as npprint (np.version.full_version)#numpy 对象:数组a = np.arange(20)print (a)print (type(a)) # nump
2017-05-14 08:59:07 341
原创 pandas练习
pandas10分钟教程 http://pandas.pydata.org/pandas-docs/stable/10min.html# -*- coding: utf-8 -*-"""Created on Fri May 5 23:23:03 2017@author: Administrator"""import pandas as pdimport numpy as npimpor
2017-05-07 16:11:04 476
原创 pandas之DataFrame创建
# -*- coding: utf-8 -*-"""Created on Mon May 1 21:18:29 2017@author: you"""import pandas as pdimport numpy as npimport matplotlib.pyplot as plt#########################################s = pd.Ser
2017-05-01 23:03:54 722
原创 python游戏练习
来自《python编程:从入门到实践》的一个类似打飞机游戏 python练习 源码: http://download.csdn.net/detail/youhaibo1990/9813291
2017-04-13 19:12:04 1079
原创 《python运维自动化》-备份目录
来自《python运维自动化》#! /usr/bin/env pythonimport os, sysimport filecmpimport reimport shutilholderlist = []def compareme(dir1, dir2): dircomp=filecmp.dircmp(dir1,dir2) only_in_one = dircomp.left
2017-04-13 18:56:56 765
原创 ffmpeg应用测试编译问题
ffmpeg整个工程编译(主要编译使用ffplay): <1>.编译、安装 ./configure –prefix=/opt/test/ make make install<2>.查看最终安装了些什么文件 root@my-pc:/opt/test# tree . ├── bin │ ├── ffmpeg │ ├── ffplay │ ├── ffprobe │
2017-01-19 20:42:11 1536
原创 linux编译安装替换低版本库文件
编译安装学习:<1>../configure –help 可以看到默认的安装路径<2> ./configure –prefix=/opt 指定安装路径,可以看到生成了哪些东西<3> find / -type f | xargs grep “xxxx” 替换指定文件(头文件、库文件、二进制文件,配置文件等)<4>. ldconfig为了让动态链接库为系统所共享,还需运行动态链接库的管理命
2017-01-18 19:49:05 645
原创 linux 孤儿进程
《unix 环境高级编程》练习,附录B常用函数头文件apue.h#ifndef _APUE_H#define _APUE_H#define _XOPEN_SOURCE 600#include <sys/types.h>#include <sys/stat.h>#include <sys/termios.h>#ifndef TIOCGWINSZ#include <sys/ioctl.h>#e
2017-01-16 00:14:04 484
原创 多播测试
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2016-12-12 17:20:33 1703
原创 c中的一些变量大小
[root@localhost smb1]# cat main.c #include <stdio.h>#include <stdlib.h>#include <string.h>void func(char str[100]){ printf("func:%d\n",sizeof(str));}int main(int arc, char ** argv){
2016-09-17 00:29:22 514
原创 面试题001
#include <stdio.h>#include <stdlib.h>int main(int arc, char ** argv){ int arr[]={5,6,7,8}; int i=0; int *ptr = arr; *(ptr++) +=123; printf("%d,%d\n",*ptr,*(++pt
2016-09-17 00:05:46 281
原创 switch():括号中的值
#include <stdio.h>#include <stdlib.h>int main(int arc, char ** argv){ int c = 1;//只能为整数常量,或是常量表达式 switch(c) { case 1:
2016-09-16 23:12:28 4984
原创 网络字节序判断
4字节整数为例:0x01020304 大端:数值的高字节对应地址的低字节; 小端:数值的高字节对应地址的高字节;[root@localhost smb1]# cat main.c #include <stdio.h>#include <stdlib.h>int main(int arc, char ** argv){ char ch = 'a';
2016-09-10 23:12:20 646
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人