Vincent He's waking life

在发现我没有道德后
对方放弃了道德绑架


  • Home

  • Footprint

  • Cheat sheet

OS X 不能使用 127.0.0.2 的解决方法

Posted on 2014-09-17 | In power user of everything

原因

FreeBSD (also OS X, and I believe NetBSD & OpenBSD) will respond to requests sent to configuredaddresses on the loopback interface, just as they would for addresses on any other interface – If you want an answer you need to assign the address first:

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
mgraziano@monitor ~]$ ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>

[mgraziano@monitor ~]$ ping 127.1.1.1
PING 127.1.1.1 (127.1.1.1): 56 data bytes
ping: sendto: Can't assign requested address
^C

[mgraziano@monitor ~]$ sudo ifconfig lo0 alias 127.1.1.1 netmask 0xFFFFFFFF

[mgraziano@monitor ~]$ ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet 127.1.1.1 netmask 0xffffffff
nd6 options=3<PERFORMNUD,ACCEPT_RTADV>

[mgraziano@monitor ~]$ ping 127.1.1.1
PING 127.1.1.1 (127.1.1.1): 56 data bytes
64 bytes from 127.1.1.1: icmp_seq=0 ttl=64 time=0.020 ms
^C

解决

1
$ sudo ifconfig lo0 alias 127.0.0.2 netmask 0xFFFFFFFF

via serverfault.com

关于 css position:fixed 和 transform 的一点研究

Posted on 2014-09-02 | In 前端 , css

先摘抄 w3school 对position:fixed和transform:translate()的定义:

position:fixed
生成绝对定位的元素,相对于浏览器窗口进行定位。
元素的位置通过 “left”, “top”, “right” 以及 “bottom” 属性进行规定。

transform
transform 属性向元素应用 2D 或 3D 转换。该属性允许我们对元素进行旋转、缩放、移动或倾斜。

理论上来说 style 为position:fixed的元素,不管他的父、子、兄弟元素如何变化,他的位置相对于屏幕可视区域的位置都是不会变化的.但是在实际操作中却发现并非如此,如下是一个简单的 demo:

DEMO:

查看源码 on [runjs.cn](http://runjs.cn/code/acnggx22)

Dom 结构如下:

1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<body>
<div id="wrap">
<div id="fixed">
</div>
</div>
</body>
</html>

样式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#wrap {
width: 300px;
height: 300px;
}
#wrap.transformed {
transform: rotate(15deg) translate(12px, 20px);
}
#fixed {
position: fixed;
width: 100px;
height: 100px;
bottom: 0;
right: 0;
}

两个按钮:

作用分别是给#wrap添加和去除transform属性.

1
2
3
4
5
6
7
$('#addtBtn').on('click', function() {
$('#wrap').addClass('transformed')
})

$('#removeBtn').on('click', function() {
$('#wrap').removeClass('transformed')
})

很容易发现,当设置为position: fixed的元素的父元素有transform属性时,子元素不再**”相对于浏览器窗口进行定位”**,而是变为相对于有transform属性的父元素定位,以 w3c 给出的定义来看,这应该是一个 bug.


小结:

transform作为 css3 的主要属性,他的值其实更像是一个个方法.打个比方来说,如果说 css2 的属性都是”静态”的属性,浏览器在渲染页面的时候,css 渲染引擎是先将这些静态的样式渲染出来,再来计算 css3 的那些”方法”.也就是说,transform属性是后产生作用.反映出的现象就是transform优先更高,甚至高于position: fixed.

以上是我的一点粗陋的推想,请斧正,谢谢.

coding.net 是个好东东

Posted on 2014-08-30 | In power user of everything

前几天发现有个垃圾站的域名是 xxx.coding.net,当时还闪了一下怎么垃圾站的域名都这么高大上了.也没多长个心眼去看看顶级域名是什么情况.

直到昨天上班遇到一个需求,把一个 php 做的 demo 放到外网,我去找免费 php 空间的时候又一次搜到了这个神奇的网站.

经过我近一天的使用,感觉coding.net是想做成中国的 github,同样可以建立远程 git 库,可以 clone 别人的 git 库,可以 fork…等等等等.但是这货比 github 强在它的演示空间居然提供 php 环境(github.io 只提供静态空间)!只需要简单的把本地的工程 push 到云端,配置好数据库,再切换到演示面板,点击部署就不用管了..实测访问速度超过某些号称高速的 vps(服务器在国内就是好).

coding.net演示界面截图

coding.net不支持 github.io 的自动部署,每次 push 代码之后需要手动点一下一键部署.

目前coding.net还不支持绑定域名,只能用它提供的二级域名.估计以后也不会提供绑定域名吧,那样的话建站蝗虫大军就该找它了.


顺便放上最近做的一个项目的前端 demo

fork me on [coding.net](https://coding.net/stariveer/O2O_demo.git).

Over

给新博客弄了个 404 页面

Posted on 2014-08-26 | In power user of everything

很简单,在/source/下新建 404.html,里面内容自由发挥.
如果不想让 hexo 自作主张的渲染,可以在文件开始处加上

1
## layout: false

Over.
可以在这里看到效果哦

发几张夏天拍的照片

Posted on 2014-08-26 | In photograph

试一下七牛云的效果

1…45

45 posts
10 categories
46 tags
GitHub E-Mail Twitter Douban Zhihu
© 2014 — 2025 Vincent He