Skip to content

Instantly share code, notes, and snippets.

View ghostcode's full-sized avatar
🎯
Focusing

蝎子 ghostcode

🎯
Focusing
  • SH,China
View GitHub Profile
@ghostcode
ghostcode / gist:7f3c36a370a8e42b9805
Created September 25, 2014 09:47
contentloaded.js
/*!
* contentloaded.js
*
* Author: Diego Perini (diego.perini at gmail.com)
* Summary: cross-browser wrapper for DOMContentLoaded
* Updated: 20101020
* License: MIT
* Version: 1.2
*
* URL:
@ghostcode
ghostcode / 搜索文件.md
Created August 14, 2014 02:20
搜索文件

which (寻找“执行文件”)####

which [-a] commond

参数:

-a :将所有可找到的命令均列出,而不仅仅列出第一个找到的命令名称
@ghostcode
ghostcode / 查看文件内容.md
Last active August 29, 2015 14:05
查看文件内容
cat:由第一行开始显示文件内容

tac:从最后一行开始显示

nl:显示的时候,输出行号

more:一页一页的显示文件内容

less与more类似,可以向前翻页
@ghostcode
ghostcode / readonly和disabled区别.md
Created August 7, 2014 10:37
readonly和disabled区别

不同:

  • readonly可以获得焦点,可以在submit时提交值。
  • disabled不可以获得焦点,不可以提交值。

相同:

  • 都是只读,不可更改。
@ghostcode
ghostcode / localStorage.md
Last active August 29, 2015 14:05
localStorage

Cookie实现localStorage:

###第一种###

if (!window.localStorage) {
  Object.defineProperty(window, "localStorage", new (function () {
    var aKeys = [], oStorage = {};
    Object.defineProperty(oStorage, "getItem", {
      value: function (sKey) { return sKey ? this[sKey] : null; },
@ghostcode
ghostcode / file.md
Last active June 5, 2018 04:28
复制、删除、移动文件和文件夹
cp [-adfilprsu] source(原文件) destination(目标文件)

记录一些常用的:

  -f:强制的意思,若有重复或其他疑问时,不会询问用户,而强制复制。
  -i:若目标文件已经存在,在覆盖时先询问是否真的操作。
 -r:递归持续复制,用于目录的复制操作。
/**
* @ NAME: Cross-browser TextStorage
* @ DESC: text storage solution for your pages
* @ COPY: sofish, http://sofish.de
*/
typeof window.localStorage == 'undefined' && ~function () {
var localStorage = window.localStorage = {},
prefix = 'data-userdata',
doc = document,
@ghostcode
ghostcode / 模拟鼠标点击.md
Created July 28, 2014 02:47
模拟鼠标点击
var target = document.getElementById('demo');
var mEvent = document.createEvent("MouseEvent");
mEvent.initMouseEvent("click", true, true, window, 0,
    0, 0, 0, 0,
    false, false, false, false,
    0, null);

target.dispatchEvent(mEvent);
@ghostcode
ghostcode / 目录相关.md
Last active August 29, 2015 14:04
目录相关

###显示路径###

pwd [-P]

参数:

-P:显示实际路径,而非使用连接(link)路径。

###建立新目录###

@ghostcode
ghostcode / chrome-fixed-disppear.md
Last active August 29, 2015 14:04
position:fixed 元素,鼠标移动时,导致该元素消失

html:

<div class="main"></div>
<div class="sidebar"></div>

css: