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 / addEventListener.md
Last active August 29, 2015 14:04
addEventListener你不知道的

addEventListener我们一般会这样用:

element.addEventListener(type,callback,useCapture)

为了兼容__<IE9__:

if (el.addEventListener) {
 el.addEventListener('click', modifyText, false); 
@ghostcode
ghostcode / 切换目录.md
Last active August 29, 2015 14:04
切换目录

一些特殊的目录:

  • . 表示此层目录
  • .. 表示上一层目录
    • 表示前一个目录
  • ~ 表示“当前用户身份”所在的家目录
  • ~account 表示account用户的家目录

注:根目录(/)也有. 和 ..,其实它俩是同一个目录

@ghostcode
ghostcode / 生产ssh keys.md
Last active August 29, 2015 14:04
生产ssh keys

###第一步:查看ssh keys###

首先我们应该查看本机是否已有ssh keys。

ls -al ~/.ssh

查看是否找到__id_rsa.pub__和__id_dsa.pub__,如果有把里面的内容复制、粘贴到你的git里面,若没有请往下看。

@ghostcode
ghostcode / 火狐table-cell 图片垂直居中.md
Last active August 29, 2015 14:04
火狐table-cell 图片垂直居中

图片垂直居中真是伤,又发现一个火狐的问题:

html:

<div class="table-cell"><img src="http://img1.picbed.org/uploads/2014/07/023b5bb5c9ea15ce411a0a58b4003af33b87b2ef.jpg"></div>

css:

@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:

@ghostcode
ghostcode / 目录相关.md
Last active August 29, 2015 14:04
目录相关

###显示路径###

pwd [-P]

参数:

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

###建立新目录###

@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);
/**
* @ 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 / file.md
Last active June 5, 2018 04:28
复制、删除、移动文件和文件夹
cp [-adfilprsu] source(原文件) destination(目标文件)

记录一些常用的:

  -f:强制的意思,若有重复或其他疑问时,不会询问用户,而强制复制。
  -i:若目标文件已经存在,在覆盖时先询问是否真的操作。
 -r:递归持续复制,用于目录的复制操作。
@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; },