简单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
    

查看Oracle当前用户下的对象(表、视图、同义词)

0表空间

SQL>select username,default_tablespace from user_users;

查看当前用户的角色

SQL>select * from user_role_privs;

查看当前用户的系统权限和表级权限

SQL>select * from user_sys_privs;SQL>select * from user_tab_privs;

查看用户下所有的表

SQL>select * from user_tables;

1、用户查看当前用户的缺省表空间

SQL>select username,default_tablespace from user_users;

查看当前用户的角色

SQL>select * from user_role_privs;

查看当前用户的系统权限和表级权限

SQL>select * from user_sys_privs;
SQL>select * from user_tab_privs;

显示当前会话所具有的权限

SQL>select * from session_privs;

显示指定用户所具有的系统权限

SQL>select * from dba_sys_privs where grantee='GAME';

2、表查看用户下所有的表

SQL>select * from user_tables;

查看名称包含log字符的表

SQL>select object_name,object_id from user_objectswhere instr(object_name,'LOG')>0;

查看某表的创建时间

SQL>select object_name,created from user_objects where object_name=upper('&table_name');

查看某表的大小

SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segmentswhere segment_name=upper('&table_name');

查看放在ORACLE的内存区里的表

SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;

 3、索引查看索引个数和类别

SQL>select index_name,index_type,table_name from user_indexes order by table_name;

查看索引被索引的字段

SQL>select * from user_ind_columns where index_name=upper('&index_name');

查看索引的大小

SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segmentswhere segment_name=upper('&index_name');

4、序列号查看序列号,last_number是当前值

SQL>select * from user_sequences;

5、视图
查看视图的名称

SQL>select view_name from user_views;

查看创建视图的select语句

SQL>set view_name,text_length from user_views;
SQL>set long 2000;

说明:可以根据视图的text_length值设定set long 的大小

SQL>select text from user_views where view_name=upper('&view_name');

6、同义词查看同义词的名称

SQL>select * from user_synonyms;

7、约束条件
查看某表的约束条件

SQL>select constraint_name, constraint_type,search_condition, r_constraint_namefrom user_constraints where table_name = upper('&table_name');
SQL>select c.constraint_name,c.constraint_type,cc.column_name from  user_constraints c,user_cons_columns ccwhere c.owner = upper('&table_owner') and c.table_name = upper('&table_name')and c.owner = cc.owner and c.constraint_name = cc.constraint_nameorder by cc.position;

8、存储函数和过程查看函数和过程的状态

SQL>select object_name,status from user_objects where object_type='FUNCTION';
SQL>select object_name,status from user_objects where object_type='PROCEDURE';

查看函数和过程的源代码

SQL>select text from all_source where owner=user and name=upper('&plsql_name');