作者归档:Rick

Python中的继承

class Person(object):
    def __init__(self,name):
        self.__name = name
        print('Person: Constructor called')

    def getName(self):
        return self.__name

class Nation(object):
            """docstring for Chinese"""
            def __init__(self, nation):
                self.__nation = nation
                print('Nation: Constructor called')

            def getNation(self):
                return self.__nation



class Student(Person, Nation):
    def __init__(self, nation, name, score):
        print('Student: Constructor called')
        #super(Student, self).__init__(name) #super() only support single extend
        #super().__init__(name)

        Person.__init__(self,name) # 'ClassName.__init__(self)' support multiple extend
        Nation.__init__(self,nation)

        self.__score = score

    def getScore(self):
        return self.__score

person = Student('China','Rick',100)

print(person.getNation())
print(person.getName())                
print(person.getScore())

简单shell字符菜单模拟

  • menu.sh
#!/bin/bash
#menu.sh


function menu() {
    title="My Menu"
    url="www.xhope.top"
    time=`date +%Y-%m-%d`
    cat << eof
#############################################
                 `echo -e "\033[32;40m$title\033[0m"`
#############################################
*   1) Add a user
*   2) Set password for user
*   3) Delete a user
*   4) Print disk space
*   5) Print men space
*   6) Quit
*   7) Return main menu
#############################################
$url                   $time
#############################################
eof
}
  • index.sh
#!/bin/bash
#index.sh

. menu.sh  #include menu.sh
clear

menu #call menu function

while [[ true ]]; do

    read -p "Please type a  option:" option
    #echo $option

    case $option in
        1 )
            read -p "Please type username:" username
            useradd $username &>/dev/null
            if [[ $? -eq 0 ]]; then
                echo "user $username is created successfully"
            else
                echo "user $username is created failed"
            fi
        ;;
        2 )
            read -p "Please type pass username:" name
            read -p "Please type password:" pass

            echo $pass | passwd --stdin $name &>/dev/null

            if [[ $? -eq 0 ]]; then
                echo "user $username password set successfully"
            else
                echo "user $username password set failed failed"
            fi
        ;;
        3 )
            read -p "Please type username:" username
            userdel -r $username &>/dev/null
            if [[ $? -eq 0 ]]; then
                echo "user $username is deleted successfully"
            else
                echo "user $username is deleted failed"
            fi
        ;;
        4 )
            str=`df -Th`
            echo -e "\033[30;47m$str\033[0m"
        ;;
        5 )
            str=`free`
            echo -e "\033[30;47m$str\033[0m" 
        ;;
        6 )
        echo -e "\033[30;47mQuit successfully!!\033[0m"
        break
        ;;
        7 )
            clear
            menu
        ;;
    esac
done

  • Shell界面
    http://xhope.top/wp-content/uploads/2015/12/1.png

Javascript面向对象编程

对象的封装、继承、模块开发示例

//extends
var module = (function(window) {
'use strict';
    var Person = function(name, age) {
        this._name = name;
        this._age = age;
        console.log('Person is constructor executed...');
    };

    Person.prototype.getName = function() {
        return this._name;
    };

    Person.prototype.getAge = function() {
        return this._age;
    };

    // console.log(Person.prototype.constructor === Person); //true
    // console.log(Person.prototype.constructor.prototype === Person.prototype); //true
    // console.log(Person.prototype.constructor.prototype.constructor.prototype === Person.prototype); //true
    /********************Student extends Person*****************/

    var Student = function(name, age, score) {
        Person.call(this, name, age);  // 调用父类构造函数
        this._score = score;
        console.log('Student is constructor executed...');

    };


    Student.prototype = Object.create(Person.prototype); //new Person();
    Student.prototype.constructor = Student;    //其实并没有什么用处,历史遗留的产物,默认指向自己

    Student.prototype.getScore = function() {
        return this._score;
    }

    var stu = new Student('Rick', 23, 98);
/*
    console.log(stu.getName());
    console.log(stu.getAge());
    console.log(stu.getScore());*/

    return stu;

})(window);

console.log(module.getName());

JQuery插件模板
http://xhope.top/?p=499

参考网站:JavaScript 六种继承方式

Linux权限管理

  • linux权限

    1. r 读
    2. w 写
    3. x 执行
  • linu用户

    1. 所有者(u)
    2. 所属组(g)
    3. 其他用户(o)
-rw-r--r--. 1 root root  215 Dec  2 20:16 abc.txt

用户、组、权限分配

  1. 用户管理
    useradd rick
    userdel rick
    passwd rick

  2. 用户组
    groupadd xhope
    groupdel xhope
    gpasswd -a rick xhope

  3. 权限分配
    chmod 755 test.java
    chmod g+w test.java
    chmod o-w test.java
    chmod a+w test.java

    acl权限分配

    [root@localhost common]# setfacl -m u:tmpuser:rw test.py
    [tmpuser@localhost common]$ getfacl test.py
    # file: test.py
    # owner: rick
    # group: xhope
    user::r-x
    user:tmpuser:rw-
    group::--x
    mask::rwx
    other::--x
    [root@localhost common]# setfacl -m g:xhope:rw test.py
    [root@localhost common]# setfacl -x u:tmpuser test.py
    [root@localhost common]# setfacl -b test.py
    [root@localhost common]# getfacl test.py
    # file: test.py
    # owner: rick
    # group: xhope
    user::r-x
    group::--x
    other::--x
    

PL/SQL Developer客户端连接Oracle服务器

PL/SQL Developer客户端连接Oracle服务器

  1. 下载PL/SQL Developer 最新版本Version 11.0.2.1766
  2. 下载instantclient注意Oracle是32位或者64位
    a. instantclient-basic-win32-11.2.0.1.0.zip
    b. instantclient-basic-win-x86-64-11.2.0.1.0.zip
  3. 配置:
    a. 解压对应的版本到D:\develop\instantclient_11_2
    b. 双击plsqldev.exe,开始设置Oracle Home & OCI library

        Oracle Home:D:\develop\instantclient_11_2
        OCI library:D:\develop\instantclient_11_2\oci.dll
    
  4. 登录对话框
    e.g.

        Username:aswdspc_my
        Password:aswdspc_my
        Database:10.32.186.133:1503/aswdspc