Skip to content

Instantly share code, notes, and snippets.

View laoshuterry's full-sized avatar

A Big Fat Rat laoshuterry

View GitHub Profile
@laoshuterry
laoshuterry / CSV2MySQL
Last active October 25, 2016 13:42
MySQL导入命令实例
--必须使用绝对路径,否则当前路径是数据实例文件路径
load data infile '/mdb/mysql/ExpData.csv'
--必须加上库名
into table OAM.OCS_PROD_CELL_MSISDN
--正常的分隔符
fields terminated by '|'
--Linux环境上不用使用'\n', windows环境上要使用'\r'
lines terminated by '\n'
--以此表字段进行导入
(MSISDN_ID,MSISDN_FIRST,MSISDN_LAST,AREA_CODE,OPERATOR_CODE,EFF_DATE,EXP_DATE,BATCH_NO);
@laoshuterry
laoshuterry / Num_Char_Date_Transfer_SQL
Created October 2, 2016 10:54
工作中4类常用时间转换
NUM2CHAR := SELECT TO_CHAR(TO_DATE('19700101080000','yyyyMMddHH24miss')+((3684394329-2208988800)/86400), 'yyyyMMddHH24miss')FROM DUAL
CHAR2NUM := SELECT (TO_date('20160901000000'char,'yyyyMMddHH24miss') - to_date('19700101080000','yyyymmddhh24miss'))*86400+2208988800 FROM DUAL
DATE2NUM := SELECT (sysdate - to_date('19700101080000','yyyymmddhh24miss'))*86400+2208988800 FROM DUAL;
NUM2DATE := SELECT TO_DATE('19700101080000','yyyyMMddHH24miss')+((3684394329-2208988800)/86400) FROM DUAL
@laoshuterry
laoshuterry / DDOSafeDelete.c
Created July 2, 2016 10:27
以前被用于美国国防部的机密文件销毁算法
/*
* File Destroyer 文件安全销毁
*
* Copyright (C) 2015 Chaobs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@laoshuterry
laoshuterry / effexpdate.sql
Last active December 24, 2015 10:17
利用Oracle中的last_day函数获取本月初的第一天和下月末的最后一天的格式化SQL
SELECT to_char(last_day(add_months(sysdate,-1))+1,'yyyymmdd')||'000000' '生效日期',TO_CHAR(last_day(add_months(sysdate,1)),'yyyymmdd')||235959 '失效日期' FROM DUAL;
#!/bin/bash
. $HOME/.profile
echo "start `basename $0`"
#echo $*
declare -a number=0
declare -i i=0
#read number
cat number.txt |while read num
do
#!/bin/bash
source $HOME/.profile
#declare a number array
declare -a serialNumber=0
declare -i i=0
#Alibase Database Connection String
AltibaseConn='isql -s 10.161.7.56 -u occ_bf -p occ_bf -port 20300 -NLS_USE US7ASCII'
#!/bin/bash
#批量添加用户
read -p "Please input user name: " -t 30 name
read -p "Please input the number of users: " -t 30 num
read -p "Please input the password of users: "-t 30 pass
if [ ! -z "$name" -a ! -z "$num" -a ! -z "$pass" ];then
#将num变量传给sed,sed进行判断是否为数字,如果为数字
#将数字替换成空,如果有一个字符都不为数字,那么整个y就不会为空
y=$(echo $num|sed 's/[0-9]//g')
#如果num全部为数字,那么条件才能为真,其实进行for循环
#!/bin/bash
#备份数据库
datetime=$(date +%y%m%d)
size=$(du -sh /home/fatmouse/sh)
if [ -d /home/fatmouse/backup ];then
echo "Date: $datetime">/home/fatmouse/sh/info.txt
echo "Size: $size" >>/home/fatmouse/sh/info.txt
cd /home/fatmouse/backup
tar -zcf Backup_$datetime.tar.gz /home/fatmouse/sh /home/fatmouse/info.txt &> /dev/null
#!/bin/bash
#硬盘使用率报警
Rate=`df -h|grep /dev/sda5|awk '{print $5}'|cut -f 1 -d "%"`
#变量如果使用整数判断,不需要双引号
if [ $Rate -ge 90 ];then
echo -e "The filesystem is almost full!\n"
else
echo -e "The system is enough!\n"
fi