书签脚本 - 简单编辑Cookie
- 将一下代码保存为浏览器书签
1 | javascript:document.cookie=window.prompt("Linx Edit cookie:",document.cookie);void(0); |
- 打开需要查询或编辑的网站
- 点击书签即可对Cookie进行操作
Linx 是作者的名称
1 | javascript:document.cookie=window.prompt("Linx Edit cookie:",document.cookie);void(0); |
Linx 是作者的名称
基于之前的文章方法,加入批处理命令即可实现自动备份。只是由于批处理命令中对于备份文件的名字按照时间命名比较特别,所以特别整理一文。
假想环境:
MySQL 安装位置:C:\MySQL
论坛数据库名称为:bbs
数据库备份目的地:C:\db_bak\
新建db_bak.bat,写入以下代码
1 | net stop mysql |
然后使用Windows的“计划任务”定时执行该批处理脚本即可。(例如:每天凌晨3点执行back_db.bat)
解释:备份和恢复的操作都比较简单,完整性比较高,控制备份周期比较灵活,例如,用%date:0,10%。此方法适合有独立主机但对mysql没有管理经验的用户。缺点是占用空间比较多,备份期间mysql会短时间断开(例如:针对30M左右的数据库耗时5s左右),针对%date:0,10%的用法参考 。
假想环境:
MySQL 安装位置:C:\MySQL
论坛数据库名称为:bbs
MySQL root 密码:123456
数据库备份目的地:D:\db_backup\
脚本:
1 | @echo off |
将以上代码保存为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开始的)
对于MySQL的备份,最好的方法就是直接备份MySQL数据库的Data目录。下面提供了一个利用WinRAR来对Data目录进行定时备份的方法。
首先当然要把WinRAR安装到计算机上。
将下面的命令写入到一个文本文件里
1 | net stop mysql |
保存,然后将文本文件的扩展名修改成CMD。进入控制面版,打开计划任务,双击“添加计划任务”。在计划任务向导中找到刚才的CMD文件,接着为这个任务指定一个运行时间和运行时使用的账号密码就可以了。
这种方法缺点是占用时间比较多,备份期间压缩需要时间,mysql断开比第一种方法更多的时间,但是对于文件命名很好。
一些代码保存为 清除桌面快捷方式小箭头.reg 文件运行后,重启 explorer.exe 进程
1 | Windows Registry Editor Version 5.00 |
1 | /***************************************** |
使用方法:
1 | convertCurrency(123.45) |
create_code.php
1 | <?php |
引用
demo.html
1 |
|
//处理,判断是否输入正确
act.php
1 | <?php |
有没有觉得浏览器自带的原始滚动条很不美观,同时也有看到很多网站的自定义滚动条显得高端,就连
chrome32.0开发板都抛弃了原始的滚动条,美观多了。那 ** webkit浏览器 ** 是如何自定义滚动条的呢?
webkit 支持拥有 overflow 属性的区域,列表框,下拉菜单,textarea 的滚动条自定义样式,所以用处还是挺大的。当然,兼容所有浏览器的滚动条样式目前是不存在的。
来看看这2个滚动条demo: demo1(图片版)、demo2(纯CSS3版)
| 样式名 | 介绍 |
|---|---|
::-webkit-scrollbar |
滚动条整体部分 |
::-webkit-scrollbar-thumb |
滚动条里面的小方块,能向上向下移动(或往左往右移动,取决于是垂直滚动条还是水平滚动条) |
::-webkit-scrollbar-track |
滚动条的轨道(里面装有Thumb) |
::-webkit-scrollbar-button |
滚动条的轨道的两端按钮,允许通过点击微调小方块的位置。 |
::-webkit-scrollbar-track-piece |
内层轨道,滚动条中间部分(除去) |
::-webkit-scrollbar-corner |
边角,即两个滚动条的交汇处 |
::-webkit-resizer |
两个滚动条的交汇处上用于通过拖动调整元素大小的小控件 |
这里就不贴出详细代码了, demo 里面可以通过查看源码寻找具体样式的设置。来看看 demo2 中第二个滚动条的样式
1 | /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ |
定义滚动条就是利用伪元素与伪类,那什么是伪元素和伪类呢?
伪类大家应该很熟悉 :link , :focus , :hover ,此外 CSS3 中又增加了许多伪类选择器,如 :nth-child , :last-child , :nth-last-of-type() 等。
CSS 中的伪元素大家以前看过: :first-line , :first-letter , :before , :after 。那么在 CSS3 中,伪元素进行了调整,在以前的基础上增加了一个 : 也就是现在变成了” ::first-letter , ::first-line , ::before , ::after “,另外 CSS3 还增加了一个 ::selection 。两个 :: 和一个 : 在 CSS3 中主要用来区分伪类和伪元素。
webkit的伪类和伪元素的实现很强,可以把滚动条当成一个页面元素来定义,再结合一些高级的 CSS3 属性,比如渐变、圆角、RGBa等等。然后如果有些地方要用图片,可以把图片也可以转换成 Base64 ,不然每次都得加载那个多个图片,增加请求数。
任何对象都可以设置:边框、阴影、背景图片等等,创建的滚动条任然会按照操作系统本身的设置来完成其交互的行为。下面的伪类可以应用到上面的伪元素中。有点小复杂,具体怎么写可以看第一个 demo ,那里也有注释。
| 样式名 | 介绍 |
|---|---|
:horizontal |
horizontal 伪类适用于任何水平方向上的滚动条 |
:vertical |
vertical 伪类适用于任何垂直方向的滚动条 |
:decrement |
decrement 伪类适用于按钮和轨道碎片。表示递减的按钮或轨道碎片,例如可以使区域向上或者向右移动的区域和按钮 |
:increment |
increment 伪类适用于按钮和轨道碎片。表示递增的按钮或轨道碎片,例如可以使区域向下或者向左移动的区域和按钮 |
:start |
start 伪类适用于按钮和轨道碎片。表示对象(按钮 轨道碎片)是否放在滑块的前面 |
:end |
end 伪类适用于按钮和轨道碎片。表示对象(按钮 轨道碎片)是否放在滑块的后面 |
:double-button |
double-button 伪类适用于按钮和轨道碎片。判断轨道结束的位置是否是一对按钮。也就是轨道碎片紧挨着一对在一起的按钮。 |
:single-button |
single-button 伪类适用于按钮和轨道碎片。判断轨道结束的位置是否是一个按钮。也就是轨道碎片紧挨着一个单独的按钮。 |
:no-button |
no-button 伪类表示轨道结束的位置没有按钮。 |
:corner-present |
corner-present 伪类表示滚动条的角落是否存在。 |
:window-inactive |
适用于所有滚动条,表示包含滚动条的区域,焦点不在该窗口的时候。 |
::-webkit-scrollbar-track-piece:start |
滚动条上半边或左半边 |
::-webkit-scrollbar-thumb:window-inactive |
当焦点不在当前区域滑块的状态 |
::-webkit-scrollbar-button:horizontal:decrement:hover |
当鼠标在水平滚动条下面的按钮上的状态 |
导语:
Markdown 是一种轻量级的「标记语言」,它的优点很多,目前也被越来越多的写作爱好者,撰稿者广泛使用。看到这里请不要被「标记」、「语言」所迷惑,Markdown 的语法十分简单。常用的标记符号也不超过十个,这种相对于更为复杂的 HTML 标记语言来说,Markdown 可谓是十分轻量的,学习成本也不需要太多,且一旦熟悉这种语法规则,会有一劳永逸的效果。

Ulysses for Mac
在刚才的导语里提到,Markdown 是一种用来写作的轻量级「标记语言」,它用简洁的语法代替排版,而不像一般我们用的字处理软件 Word 或 Pages 有大量的排版、字体设置。它使我们专心于码字,用「标记」语法,来代替常见的排版格式。例如此文从内容到格式,甚至插图,键盘就可以通通搞定了。目前来看,支持 Markdown 语法的编辑器有很多,包括很多网站(例如简书)也支持了 Markdown 的文字录入。Markdown 从写作到完成,导出格式随心所欲,你可以导出 HTML 格式的文件用来网站发布,也可以十分方便的导出 PDF 格式,这种格式写出的简历更能得到 HR 的好感。甚至可以利用 CloudApp 这种云服务工具直接上传至网页用来分享你的文章,全球最大的轻博客平台 Tumblr,也支持 Mou 这类 Markdown 工具的直接上传。
这里可以看到官方的 Markdown 语法规则文档,当然,** 后文我也会用自己的方式阐述这些语法的具体用法 **。
*We believe that writing is about content, about what you want to say – not about fancy formatting. *
我们坚信写作写的是内容,所思所想,而不是花样格式。
— Ulysses for Mac

flowchart.js on Github(使用 Markdown 绘制流程图)

Mou for Mac

Mou 的编写与预览窗口
如果你从事文字工作,我强烈建议你购买 Ulysses for Mac,这款软件入围了苹果 Mac App Store 的 The Best of 2013。它支持更多的写作格式、多文档的支持。Mou,iA writer 这些软件都是基于单文档的管理方式,而 Ulysses 支持 Folder、Filter 的管理,一个 Folder 里面可以创建多个 Sheet,Sheet 之间也可以进行 Combine 处理。

Mac 上一些 Markdown 编辑器

简书的编辑预览模式

标题
标题是每篇文章都需要也是最常用的格式,在 Markdown 中,如果一段文字被定义为标题,只要在这段文字前加 # 号即可。
# 一级标题
## 二级标题
### 三级标题
以此类推,总共六级标题,建议在井号后加一个空格,这是最标准的 Markdown 语法。
熟悉 HTML 的同学肯定知道有序列表与无序列表的区别,在 Markdown 下,列表的显示只需要在文字前加上 - 或 * 即可变为无序列表,有序列表则直接在文字前加1. 2. 3. 符号要和文字之间加上一个字符的空格。

无序列表与有序列表
如果你需要引用一小段别处的句子,那么就要用引用的格式。
例如这样
只需要在文本前加入
>这种尖括号(大于号)即可

引用
插入链接与插入图片的语法很像,区别在一个 ! 号
图片为:![](){ImgCap}{/ImgCap}
链接为:[]()
插入图片的地址需要图床,这里推荐围脖图床修复计划 与 CloudApp 的服务,生成URL地址即可。

URL 与图片
Markdown 的粗体和斜体也非常简单,用两个 * 包含一段文本就是粗体的语法,用一个 * 包含一段文本就是斜体的语法。
例如:** 这里是粗体 ** * 这里是斜体 *
表格是我觉得 Markdown 比较累人的地方,例子如下:
1 | | Tables | Are | Cool | |
这种语法生成的表格如下:
| Tables | Are | Cool |
|---|---|---|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
如果你是个程序猿,需要在文章里优雅的引用代码框,在 Markdown下实现也非常简单,只需要用两个 ` 把中间的代码包裹起来。图例:

使用 tab 键即可缩进。
分割线的语法只需要三个 * 号,例如:
[ 到这里,Markdown 的基本语法在日常的使用中基本就没什么大问题了,只要多加练习,配合好用的工具,写起东西来肯定会行云流水。更多的语法规则,其实 Mou 的 Help 文档栗子很好,当你第一次使用 Mou 时,就会显示该文档。可以用来对用的查找和学习。

图床工具用来上传图片获取 URL 地址
在线好用的Markdown工具,为印象笔记而生
对于文件夹:
1、解除对某磁盘某个文件夹的强行隐藏(示例):
1 | attrib d:\"Program Files" -s -h /s /d |
2、解除对某磁盘全部文件夹的强行隐藏(示例):
1 | attrib d:\"*" -s -h /s /d |
——友情提示:以上示例中,d:为磁盘盘符;引号内为文件夹名称;相关命令参数:
| 参数 | 注释 |
|---|---|
| +r | 设置只读文件属性。 |
| -r | 清除只读文件属性。 |
| +a | 设置存档属性。 |
| -a | 清除存档属性。 |
| +s | 设置系统文件属性。 |
| -s | 清除系统文件属性。 |
| +h | 设置隐藏文件属性。 |
| -h | 清除隐藏文件属性。 |
| /s | 将attrib和任意命令行选项应用到当前目录及其所有子目录中的匹配文件。 |
| /d | 将attrib和任意命令行选项应用到目录。 |
| /? | 在命令提示符下显示帮助。 |
对于文件:
1 | ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path] filename] [/S [ /D]] |
| 参数 | 注释 |
|---|---|
| + | 设置属性。 |
| - | 清除属性。 |
| R | 只读文件属性。 |
| A | 存档文件属性。 |
| S | 系统文件属性。 |
| H | 隐藏文件属性。 |
| [drive:][path][filename] | 指定要处理的文件属性。 |
| /S | 处理当前文件夹及其子文件夹中的匹配文件。 |
| /D | 也处理文件夹。 |
例如:
1 | attrib -s -h -r c:\*.* |
1 | Windows Registry Editor Version 5.00 |
打开文件夹C:\Windows\System32\oobe\info\backgrounds(如果没有这个文件夹的请自行创建)。
添加自己选择好的图片,文件名修改成backgroundDefault.jpg.
注:我们编辑好的登录界面的背景图片backgroundDefault.jpg,其体积一定控制在250KB以内;否则,我们修改后的登录界面的背景图片就无法了.
首先我们需要在页面中引入Chart.js文件。此工具库在全局命名空间中定义了Chart变量。
1 | <script src="Chart.js"></script> |
为了创建图表,我们要实例化一个Chart对象。为了完成前面的步骤,首先需要需要传入一个绘制图表的2d context。以下是案例。
1 | <canvas id="myChart" width="400" height="400"></canvas> |
1 | //Get the context of the canvas element we want to select |
我们还可以用jQuery获取canvas的context。首先从jQuery集合中获取我们需要的DOM节点,然后在这个DOM节点上调用 getContext(“2d”) 方法。
1 | //Get context with jQuery - using jQuery's .get() method. |
当我们完成了在指定的canvas上实例化Chart对象之后,Chart.js会自动针对retina屏幕做缩放。
Chart对象设置完成后,我们就可以继续创建Chart.js中提供的具体类型的图表了。下面这个案例中,我们将展示如何绘制一幅极地区域图(Polar area chart)。
1 | new Chart(ctx).PolarArea(data,options); |
We call a method of the name of the chart we want to create. We pass in the data for that chart type, and the options for that chart as parameters. Chart.js will merge the options you pass in with the default options for that chart type.
曲线图就是将数据标于曲线上的一种图表。
一般用于展示趋势数据,和比较两组数据集。
1 | new Chart(ctx).Line(data,options); |
1 | var data = { |
The line chart requires an array of labels for each of the data points. This is show on the X axis.
The data for line charts is broken up into an array of datasets. Each dataset has a colour for the fill, a colour for the line and colours for the points and strokes of the points. These colours are strings just like CSS. You can use RGBA, RGB, HEX or HSL notation.
1 | Line.defaults = { |
A bar chart is a way of showing data as bars.
It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
1 | new Chart(ctx).Bar(data,options); |
1 | var data = { |
The bar chart has the a very similar data structure to the line chart, and has an array of datasets, each with colours and an array of data. Again, colours are in CSS format.
We have an array of labels too for display. In the example, we are showing the same data as the previous line chart example.
1 | Bar.defaults = { |
A radar chart is a way of showing multiple data points and the variation between them.
They are often useful for comparing the points of two or more different data sets
1 | new Chart(ctx).Radar(data,options); |
1 | var data = { |
For a radar chart, usually you will want to show a label on each point of the chart, so we include an array of strings that we show around each point in the chart. If you do not want this, you can either not include the array of labels, or choose to hide them in the chart options.
For the radar chart data, we have an array of datasets. Each of these is an object, with a fill colour, a stroke colour, a colour for the fill of each point, and a colour for the stroke of each point. We also have an array of data values.
1 | Radar.defaults = { |
Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.
This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.
1 | new Chart(ctx).PolarArea(data,options); |
1 | var data = [ |
As you can see, for the chart data you pass in an array of objects, with a value and a colour. The value attribute should be a number, while the color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.
These are the default chart options. By passing in an object with any of these attributes, Chart.js will merge these objects and the graph accordingly. Explanations of each option are commented in the code below.
1 | PolarArea.defaults = { |
Pie charts are probably the most commonly used chart there are. They are divided into segments, the arc of each segment shows a the proportional value of each piece of data.
They are excellent at showing the relational proportions between data.
1 | new Chart(ctx).Pie(data,options); |
1 | var data = [ |
For a pie chart, you must pass in an array of objects with a value and a color property. The value attribute should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each. The color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.
These are the default options for the Pie chart. Pass in an object with any of these attributes to override them.
1 | Pie.defaults = { |
Doughnut charts are similar to pie charts, however they have the centre cut out, and are therefore shaped more like a doughnut than a pie!
They are aso excellent at showing the relational proportions between data.
1 | new Chart(ctx).Doughnut(data,options); |
1 | var data = [ |
For a doughnut chart, you must pass in an array of objects with a value and a color property. The value attribute should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each. The color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.
These are the default options for the doughnut chart. Pass in an object with any of these attributes to override them.
1 | Doughnut.defaults = { |
If you are looking to add interaction as a layer to charts, Chart.js is not the library for you. A better option would be using SVG, as this will let you attach event listeners to any of the elements in the chart, as these are all DOM nodes.
Chart.js uses the canvas element, which is a single DOM node, similar in characteristics to a static image. This does mean that it has a wider scope for compatibility, and less memory implications than SVG based charting solutions. The canvas element also allows for saving the contents as a base 64 string, allowing saving the chart as an image.
In SVG, all of the lines, data points and everything you see is a DOM node. As a result of this, complex charts with a lot of intricacies, or many charts on the page will often see dips in performance when scrolling or generating the chart, especially when there are multiple on the page. SVG also has relatively poor mobile support, with Android not supporting SVG at all before version 3.0, and iOS before 5.0. (caniuse.com/svg-html5).
所有现代浏览器和大部分手机浏览器都支持canvas(caniuse.com/canvas)。
对于IE8及以下版本的浏览器,建议使用ExplorerCanvas - 见 https://code.google.com/p/explorercanvas/。对于不支持canvas的IE会自动降级为VML格式。使用方法:
1 | <head> |
Usually I would recommend feature detection to choose whether or not to load a polyfill, rather than IE conditional comments, however in this case, VML is a Microsoft proprietary format, so it will only work in IE.
Some important points to note in my experience using ExplorerCanvas as a fallback.
Initialise charts on load rather than DOMContentReady when using the library, as sometimes a race condition will occur, and it will result in an error when trying to get the 2d context of a canvas.
New VML DOM elements are being created for each animation frame and there is no hardware acceleration. As a result animation is usually slow and jerky, with flashing text. It is a good idea to dynamically turn off animation based on canvas support. I recommend using the excellent Modernizr to do this.
When declaring fonts, the library explorercanvas requires the font name to be in single quotes inside the string. For example, instead of your scaleFontFamily property being simply “Arial”, explorercanvas support, use “‘Arial’” instead. Chart.js does this for default values.
Please report these on the Github page - at github.com/nnnick/Chart.js.
New contributions to the library are welcome.
Chart.js is open source and available under the MIT license.