l1n6yun's Blog

记录学习的技能和遇到的问题

css

1
2
3
4
div.icon{height:20px;width:20px;overflow: hidden;}
.icon .icon{width: 20px;height: 20px;display:block;position: relative;left: -20px;border-right: 20px solid transparent;
background: url(img/icon.png) no-repeat;-webkit-filter: drop-shadow(#000 20px 0);filter: drop-shadow(#000 20px 0);
}

html

1
2
3
4
<div class="icon">
<span class='icon' id='icon'></span>
</div>
<input type="color" id='color' />

JS

1
2
3
4
document.getElementById('color').onchange = function(){
var c = this.value;
document.getElementById('icon').style.webkitFilter = 'drop-shadow('+c+' 20px 0)';
}

在谷歌、火狐手机端、都是可以用的,使用的技术是 css 里滤镜里的投影。

我要睡到下一个世界大战

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<style type="text/css">
*{margin: 0px; padding: 0px;}
html,body{width: 100%; height: 100%;overflow: hidden;}

.section-wrap{width: 100%; height: 100%; overflow: visible;transition:transform 1s cubic-bezier(0.86,0,0.03,1);-webkit-transition:-webkit-transform 1s cubic-bezier(0.86,0,0.03,1);}
.section-wrap .section{width: 100%; height: 100%;}

.section-1{background: #0f0}
.section-2{background: #FF0}

.put-section-1{ transform:translateY(0);-webkit-transform:translateY(0);}
.put-section-2{ transform:translateY(-100%);-webkit-transform:translateY(-100%);}

.section-btn{ width:14px;position:fixed;right:4%;top:50%;}
.section-btn li{ width:14px;height:14px;cursor:pointer;text-indent:-9999px;border-radius:50%;-webkit-border-radius:50%;margin-bottom:12px; background:#BD362F;text-align:center; color:#fff; onsor:pointer;}
.section-btn li.on{ background:#fff}
</style>

<body>
<section class='section-wrap put-section-1'>
<div class="section section-1">
<div class='title'>
<p class="tit">111</p>
</div>
</div>
<div class="section section-2">
<div class='title'>
<p class="tit">222</p>
</div>
</div>
</section>
<ul class="section-btn">
<li class="on"></li>
<li></li>
</ul>

<script type="text/javascript" src='jiaoben3135/js/jquery.min.js'></script>
<script type="text/javascript">

$(function(){
var i=1;
var $btn = $('.section-btn li'),
$wrap = $('.section-wrap'),
$arrow = $('.arrow');

/*当前页面赋值*/
function up(){i++;if(i>$btn.length){i=1};}
function down(){i--;if(i<1){i=$btn.length};}

// /*页面滑动*/
function run(){
$btn.eq(i-1).addClass('on').siblings().removeClass('on');
$wrap.attr("class","section-wrap").addClass(function() { return "put-section-"+i; }).find('.section').eq(i).find('.title').addClass('active');
};

// /*右侧按钮点击*/
$btn.each(function(index) {
$(this).click(function(){
i=index+1;
run();
})
});

// /*翻页按钮点击*/
$arrow.one('click',go);
function go(){
up();run();
setTimeout(function(){$arrow.one('click',go)},1000)
};

// /*响应鼠标*/
$wrap.one('mousewheel',mouse_);
function mouse_(event){
if(event.deltaY<0) {up()}
else{down()}
run();
setTimeout(function(){$wrap.one('mousewheel',mouse_)},1000)
};

// /*响应键盘上下键*/
$(document).one('keydown',k);
function k(event){
var e=event||window.event;
var key=e.keyCode||e.which||e.charCode;
switch(key) {
case 38: down();run();
break;
case 40: up();run();
break;
};
setTimeout(function(){$(document).one('keydown',k)},1000);
}
});
</script>
</body>
</html>

配置:

1
2
'DB_TYPE' => 'sqlite',
'DB_NAME' => DATA_PATH.'/test.db',

文件:\Library\Think\Db\Driver\Sqlite.class.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
namespace Think\Db\Driver;

use Think\Db\Driver;

/**
* Sqlite数据库驱动
*/
class Sqlite extends Driver
{

/**
* 解析pdo连接的dsn信息
* @access public
* @param array $config 连接信息
* @return string
*/
protected function parseDsn($config)
{
$dsn = 'sqlite:' . $config['database'];
return $dsn;
}

/**
* 取得数据表的字段信息
* @access public
* @return array
*/
public function getFields($tableName)
{
list($tableName) = explode(' ', $tableName);
$result = $this->query('PRAGMA table_info( ' . $tableName . ' )');
$info = array();
if ($result) {
foreach ($result as $key => $val) {
$info[$val['name']] = array(
'name' => $val['name'],
'type' => $val['type'],
'notnull' => (bool) (1 === $val['notnull']),
'default' => $val['dflt_value'],
'primary' => '1' == $val['pk'],
'autoinc' => false,
);
}
}
return $info;
}

/**
* 取得数据库的表信息
* @access public
* @return array
*/
public function getTables($dbName = '')
{
$result = $this->query("SELECT name FROM sqlite_master WHERE type='table' "
. "UNION ALL SELECT name FROM sqlite_temp_master "
. "WHERE type='table' ORDER BY name");
$info = array();
foreach ($result as $key => $val) {
$info[$key] = current($val);
}
return $info;
}

/**
* SQL指令安全过滤
* @access public
* @param string $str SQL指令
* @return string
*/
public function escapeString($str)
{
return str_ireplace("'", "''", $str);
}

/**
* limit
* @access public
* @return string
*/
public function parseLimit($limit)
{
$limitStr = '';
if (!empty($limit)) {
$limit = explode(',', $limit);
if (count($limit) > 1) {
$limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' ';
} else {
$limitStr .= ' LIMIT ' . $limit[0] . ' ';
}
}
return $limitStr;
}

/**
* 随机排序
* @access protected
* @return string
*/
protected function parseRand()
{
return 'RANDOM()';
}
}

先来看下面写好的批处理代码,有木有眼花缭乱的感觉,不要害怕哦,其实核心代码只有一行而已!准确的说应该是将一些最基本的DOS命令组合在了一起。

1
2
3
4
5
6
@echo off
color e
title 批处理扫网段主机
echo.
@for /f "tokens=1-4 delims=." %%i in (ip.txt) do (@for /l %%n in (1,1,255) do @ping -w 600 -n 1 -l 1 %%i.%%j.%%k.%%n|find /i "ttl")
echo.&echo 扫描完毕,按任意键退出...&pause>nul

复制以上代码粘贴到记事本文档里,然后另存为 批量ping.bat ,再新建一个空白的文本文档,重命名为 ip.txt 。一切准备完事儿,就可以将你要批量扫描的ip段的地址放入 ip.txt 里(比如要扫自己对应的内网IP段就可以在 ip.txt 里输入 192.168.0.1 后保存),然后双击一键运行 批量ping.bat 批处理脚本就可以看到返回的结果了。格式类似于:

1
2
3
4
5
6
7
来自 192.168.0.1 的回复: 字节=1 时间<1ms TTL=64
来自 192.168.0.101 的回复: 字节=1 时间=31ms TTL=64
来自 192.168.0.103 的回复: 字节=1 时间=326ms TTL=64
来自 192.168.0.104 的回复: 字节=1 时间=26ms TTL=64
来自 192.168.0.108 的回复: 字节=1 时间<1ms TTL=64
来自 192.168.0.162 的回复: 字节=1 时间<1ms TTL=128
……此处省略余下的所有可能的结果……

下面我就来解读一下介个看起来有点儿吃力的批处理命令吧。我们分拆来看一下,ping -w 600 -n 1 -l 1 表示对指定ip地址ping一次,等待超时的时间为600毫秒;|find /i "ttl" 指的是仅显示ping返回结果中带“ttl”字符串的结果,也就是将指定网段内不存活的主机过滤掉了。而前面的 @for /f "tokens=1-4 delims=." %%i in (ip.txt) 意思是将“ip.txt”里的字符串(也就是我们要查找的ip段的地址)以“.”为界分割为四部分,分别赋予后面的变量 %%i、%%j、%%k 。最后剩下的 @for /l %%n in (1,1,255) 则表示从1开始循环+1递增一直到255停止,然后赋予变量 %%n 。不知道这样说同学能否看懂呢?看不懂滴可以在cmd窗口里输入 for /? 查看一下命令详解吧。

  1. 将一下代码保存为浏览器书签
1
javascript:document.cookie=window.prompt("Linx Edit cookie:",document.cookie);void(0);
  1. 打开需要查询或编辑的网站
  2. 点击书签即可对Cookie进行操作

Linx 是作者的名称

基于之前的文章方法,加入批处理命令即可实现自动备份。只是由于批处理命令中对于备份文件的名字按照时间命名比较特别,所以特别整理一文。

复制date文件夹备份

假想环境:
MySQL 安装位置:C:\MySQL
论坛数据库名称为:bbs
数据库备份目的地:C:\db_bak\

新建db_bak.bat,写入以下代码

1
2
3
net stop mysql
xcopy c:\mysql\data\bbs\*.* c:\db_bak\bbs\%date:~0,10%\ /S /I
net start mysql

然后使用Windows的“计划任务”定时执行该批处理脚本即可。(例如:每天凌晨3点执行back_db.bat)

解释:备份和恢复的操作都比较简单,完整性比较高,控制备份周期比较灵活,例如,用%date:0,10%。此方法适合有独立主机但对mysql没有管理经验的用户。缺点是占用空间比较多,备份期间mysql会短时间断开(例如:针对30M左右的数据库耗时5s左右),针对%date:0,10%的用法参考 。

mysqldump备份成sql文件

假想环境:

MySQL 安装位置:C:\MySQL
论坛数据库名称为:bbs
MySQL root 密码:123456
数据库备份目的地:D:\db_backup\

脚本:

1
2
3
4
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
C:\MySQL\bin\mysqldump --opt -u root --password=123456 bbs > D:\db_backup\bbs_%Ymd%.sql
@echo on

将以上代码保存为backup_db.bat

然后使用Windows的“计划任务”定时执行该脚本即可。(例如:每天凌晨5点执行back_db.bat)

说明:此方法可以不用关闭数据库,并且可以按每一天的时间来名称备份文件。

通过%date:5,2%来组合得出当前日期,组合的效果为yyyymmdd,date命令得到的日期格式默认为yyyy-mm-dd(**如果不是此格式可以通过pause命令来暂停命令行窗口看通过%date:,20%得到的当前计算机日期格式**),所以通过%date:5,2%即可得到日期中的第五个字符开始的两个字符,例如今天为2009-02-05,通过%date:5,2%则可以得到02。(日期的字符串的下标是从0开始的)

利用WinRAR对MySQL数据库进行定时备份。

对于MySQL的备份,最好的方法就是直接备份MySQL数据库的Data目录。下面提供了一个利用WinRAR来对Data目录进行定时备份的方法。

首先当然要把WinRAR安装到计算机上。

将下面的命令写入到一个文本文件里

1
2
3
net stop mysql
c:\progra~1\winrar\winrar a -ag -k -r -s d:\mysql.rar d:\mysql\data
net start mysql

保存,然后将文本文件的扩展名修改成CMD。进入控制面版,打开计划任务,双击“添加计划任务”。在计划任务向导中找到刚才的CMD文件,接着为这个任务指定一个运行时间和运行时使用的账号密码就可以了。

这种方法缺点是占用时间比较多,备份期间压缩需要时间,mysql断开比第一种方法更多的时间,但是对于文件命名很好。

一些代码保存为 清除桌面快捷方式小箭头.reg 文件运行后,重启 explorer.exe 进程

1
2
3
4
5
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons]
"29"=""

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*****************************************
Copyright (c) 2004, Laser Lu
http://www.idow.net
*****************************************/
function convertCurrency(currencyDigits) {
// Constants:
var MAXIMUM_NUMBER = 99999999999.99;
// Predefine the radix characters and currency symbols for output:
var CN_ZERO = "零";
var CN_ONE = "壹";
var CN_TWO = "贰";
var CN_THREE = "叁";
var CN_FOUR = "肆";
var CN_FIVE = "伍";
var CN_SIX = "陆";
var CN_SEVEN = "柒";
var CN_EIGHT = "捌";
var CN_NINE = "玖";
var CN_TEN = "拾";
var CN_HUNDRED = "佰";
var CN_THOUSAND = "仟";
var CN_TEN_THOUSAND = "万";
var CN_HUNDRED_MILLION = "亿";
var CN_SYMBOL = "";
var CN_DOLLAR = "元";
var CN_TEN_CENT = "角";
var CN_CENT = "分";
var CN_INTEGER = "整";

// Variables:
var integral; // Represent integral part of digit number.
var decimal; // Represent decimal part of digit number.
var outputCharacters; // The output result.
var parts;
var digits, radices, bigRadices, decimals;
var zeroCount;
var i, p, d;
var quotient, modulus;

// Validate input string:
currencyDigits = currencyDigits.toString();
if (currencyDigits == "") {
PUT.alert("不能为空。");
return false;
}
if (currencyDigits.match(/[^,.\d]/) != null) {
PUT.alert("请输入数字。");
return '';
}
if ((currencyDigits).match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
PUT.alert("请输入正确数字。");
return false;
}

// Normalize the format of input digits:
currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
currencyDigits = currencyDigits.replace(/^0+/, ""); // Trim zeros at the beginning.
// Assert the number is not greater than the maximum number.
if (Number(currencyDigits) > MAXIMUM_NUMBER) {
PUT.alert("超出了最大数字转换。");
return false;
}

// Process the coversion from currency digits to characters:
// Separate integral and decimal parts before processing coversion:
parts = currencyDigits.split(".");
if (parts.length > 1) {
integral = parts[0];
decimal = parts[1];
// Cut down redundant decimal digits that are after the second.
decimal = decimal.substr(0, 2);
}
else {
integral = parts[0];
decimal = "";
}
// Prepare the characters corresponding to the digits:
digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
decimals = new Array(CN_TEN_CENT, CN_CENT);
// Start processing:
outputCharacters = "";
// Process integral part if it is larger than 0:
if (Number(integral) > 0) {
zeroCount = 0;
for (i = 0; i < integral.length; i++) {
p = integral.length - i - 1;
d = integral.substr(i, 1);
quotient = p / 4;
modulus = p % 4;
if (d == "0") {
zeroCount++;
}
else {
if (zeroCount > 0)
{
outputCharacters += digits[0];
}
zeroCount = 0;
outputCharacters += digits[Number(d)] + radices[modulus];
}
if (modulus == 0 && zeroCount < 4) {
outputCharacters += bigRadices[quotient];
zeroCount = 0;
}
}
outputCharacters += CN_DOLLAR;
}
// Process decimal part if there is:
if (decimal != "") {
for (i = 0; i < decimal.length; i++) {
d = decimal.substr(i, 1);
if (d != "0") {
outputCharacters += digits[Number(d)] + decimals[i];
}
}
}
// Confirm and return the final output string:
if (outputCharacters == "") {
outputCharacters = CN_ZERO + CN_DOLLAR;
}
if (decimal == "") {
outputCharacters += CN_INTEGER;
}
outputCharacters = CN_SYMBOL + outputCharacters;
return outputCharacters;
}

使用方法:

1
2
3
4
5
6
convertCurrency(123.45)
"壹佰贰拾叁元肆角伍分"
convertCurrency(123000.45)
"壹拾贰万叁仟元肆角伍分"
convertCurrency(123456.78)
"壹拾贰万叁仟肆佰伍拾陆元柒角捌分"
0%