Justin's Words


  • Home

  • About

  • Archives
Justin's Words

C++ 头文件

Posted on 2015-02-06 | In C++ |

Refer to: Learn Cpp

直接上代码

三个文件源码如下:

add.h:

1
2
3
4
5
6
#ifndef ADD_H
#define ADD_H

int add(int x, int y);

#endif
Read more »
Justin's Words

从 Typecho 迁移到 Wordpress

Posted on 2015-02-03 | In PHP |

迁移首要原因必然是 Wordpress 的普及性更加广,Typecho 的确是很轻量级,是个不错的博客程序。

迁移其实说白了就是数据库的迁移,再简单点就是文章的迁移,包括文章标题、文章作者、文章内容、文章创建时间、文章修改时间等,差不多这几样是最重要的,标签的话我没有迁移,因为我的标签不算多。

Read more »
Justin's Words

CSS3 Animation

Posted on 2015-01-30 | In Front-End |

CSS 动画指的是 CSS3 的新特性 animation, @keyframes 和 transition。

如果发现动画不起作用注意加上浏览器前缀。

浏览器兼容性

Descktop:

  • Chrome(-webkit)
  • Firfox(-moz)(16.0 以上不需前缀)
  • Internet Explorer(10)
  • Opera(-o)(12.10 以上不需前缀)
  • Safari(-webkit)

Mobile:

  • Android(-webkit)
  • Firfox(-moz)(16.0 以上不需前缀)
Read more »
Justin's Words

SQL JOIN 和 UNION 用法

Posted on 2015-01-28 | In SQL |
1
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons, Orders WHERE Persons.Id_P = Orders.Id_P

等同于

1
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons INNER JOIN Orders ON Persons.Id_P = Orders.Id_P ORDER BY Persons.LastName
Read more »
Justin's Words

阻止搜索引擎对页面进行爬取的方法

Posted on 2015-01-28 | In SEO |

使用元标记

在 <meta> 标签中插入 noindex 元标记可以完全阻止 Google 对该页面的索引,也就是该页面不会出现在 Google 的搜索结果中。

相对大部分搜索引擎的做法:

1
<meta name="robots" content="noindex">

只相对 Google 的做法:

1
<meta name="googlebot" content="noindex">
Read more »
Justin's Words

ImageMagick 备忘录

Posted on 2014-12-19 | In Linux |

转换渐进式图片:

1
convert -interlace Plane -quality 90 source.jpg destination.jpg

画布调整:

1
convert -resize 50%x50% source.jpg destination.jpg

格式转换:

1
convert source.jpg destination.png

背景透明:

1
convert -resize 50% -background transparent source.png destination.png

→更多功能。

Justin's Words

用 rsync 同步本地和服务器的文件

Posted on 2014-12-19 | In Linux |

参考 DigitalOcean

安装

For Debian/Ubuntu:

1
sudo apt-get install rsync

For Redhat/Fedora:

1
sudo yum install rsync
Read more »
Justin's Words

MySQL 数据库迁移

Posted on 2014-12-19 | In SQL |

参考 DigitalOcean

备份数据库:

1
mysqldump -u [username] -p --opt [database name] > [database name].sql

迁移数据库数据到新数据库,你得先创建这个新数据库:

1
mysql -u [username] -p [new database name] < /path/to/[new database name].sql
Justin's Words

JavaScript Carousel

Posted on 2014-12-15 | In Uncategorized |

明天还要上课先睡觉,明天再写过程。



var container = document.getElementsByClassName('container')[0],
carousel = document.getElementsByClassName('carousel')[0],
btns = document.getElementsByClassName('slide');
prev = document.getElementsByClassName('prev')[0],
next = document.getElementsByClassName('next')[0],
index = 1,
animated = false,
interval = 2000;
timer = 0,
itemHeight = 80;

carousel.scrollTop = 0;

window.onload = function () {
carousel.scrollTop += itemHeight;
}

prev.onclick = function () {
if (animated) {
return;
}
index–;
if (index > btns.length) {
index = 1;
} else if (index < 1) {
index = btns.length;
}
animate(-itemHeight);
showBtn();
}

next.onclick = function () {
if (animated) {
return;
}
index++;
if (index > btns.length) {
index = 1;
} else if (index < 1) {
index = btns.length;
}
animate(itemHeight);
showBtn();
}

for (var i = 0; i < btns.length; i++) {
btns[i].onclick = function () {
if (index === (i + 1) || animated) {
return;
}
var myIndex = parseInt(this.getAttribute('index'));
var offset = itemHeight (myIndex - index);

animate(offset);
index = myIndex;
showBtn();
}
}

function animate(offset) {
var time = 300,
interval = 10,
speed = offset/(time/interval),
newTop = carousel.scrollTop + offset;

animated = true;

var go = function() {
if ((speed > 0 && carousel.scrollTop < newTop) || (speed < 0 && carousel.scrollTop > newTop)) {
carousel.scrollTop += speed;
setTimeout(go, interval);
} else {
carousel.scrollTop = newTop;
if (carousel.scrollTop < itemHeight) {
carousel.scrollTop = itemHeight
4;
} else if (carousel.scrollTop > itemHeight * 4) {
carousel.scrollTop = itemHeight;
}
animated = false;
}
}

go();
}

function showBtn() {
for (var i = 0; i < btns.length; i++) {
if (btns[i].className === 'slide on') {
btns[i].className = 'slide';
break;
}
}
btns[index-1].className = 'slide on';
}

function play() {
timer = setTimeout(function () {
next.onclick();
play();
}, interval);
}

function stop() {
clearTimeout(timer);
}

container.onmouseover = stop;
container.onmouseout = play;

play();

See the Pen XJdBbz by Justin Young (@youngdze) on CodePen.

Justin's Words

被放弃的 tag Marquee

Posted on 2014-12-14 | In Front-End |

之所以把这个标签写出来是因为看到学校那些网页还到处都在应用,我只能说,学校那些老顽固真是误人子弟。

MDN 已经不推荐使用

Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Read more »

1…567…11
Justin Young

Justin Young

You Deserve A Better Life

107 posts
15 categories
54 tags
RSS
Github Twitter
© 2014 - 2019 Justin Young
Powered by Hexo
Theme - NexT.Mist