Dropbox 做私有 Git 服务器

作者:永远的冰点 发布时间:February 15, 2012 分类:瞎折腾 2 Comments

原理:在dropbox中建立git仓库,然后共享文件夹,从而实现多人协作。例如我们要在Dropbox/project/目录下建立demo.git项目:

一、在Dropbox的文件夹下创建远程repository文件夹(.git后缀),

cd ~/Dropbox/project
mkdir demo.git

二、进入demo.git文件夹并初始化repository

cd demo.git
git init --bare

三、创建完毕,现在创建一份本地clone,如要创建在~/lab/demo/目录下

cd ~/lab/
git clone  ~/Dropbox/project/demo.git demo

四、测试git

cd demo
touch README
git add README
git commit -m "fisrt commit"
git push origin master

五、共享/Dropbox/project/demo.git文件夹,其它指定用户同步后,本地clone git项目。

enJoy it!

CSS3 Media Queries

作者:永远的冰点 发布时间:February 8, 2012 分类:XHTML/CSS No Comments

一、Media Queries 支持的属性

属性                值                 Min/Max     描述
color               integer             yes         每种色彩的字节数
color-index         integer             yes         色彩表中的色彩数
device-aspect-ratio integer/integer     yes         宽高比例
device-height       length              yes         设备屏幕的输出高度
device-width        length              yes         设备屏幕的输出宽度
grid                integer             no          是否是基于格栅的设备
height              length              yes         渲染界面的高度
monochrome          integer             yes         单色帧缓冲器中每像素字节
resolution          resolution          yes         分辨率
scan                                    no          tv媒体类型的扫描方式
width               length              yes         渲染界面的宽度
orientation         Portrait/landscape  no          横屏或竖屏
height              min-height              max-height
device-width        min-device-width        max-device-width
device-height       min-device-height       max-device-height
aspect-ratio        min-aspect-ratio        max-aspect-ratio
device-aspect-ratio min-device-aspect-ratio max-device-aspect-ratio
color               min-color               max-color
color-index         min-color-index         max-color-index
Monochrome          min-monochrome          max-monochrome
Resolution          min-resolution          max-resolution

二、关键字

and - 结合多个媒体查询
not - 排除某种制定的媒体类型
only - 用来定某种特定的媒体类型

三、引用样式示例

<link rel="stylesheet" media="all" href="style.css" />
<link rel="stylesheet" media="screen and (min-width:980px)" href="desktop.css" />
<link rel="stylesheet" media="screen and (min-width:768px) and (max-width:980px)" href="pad.css" />
<link rel="stylesheet" media="screen and (min-width:480) and (max-width: 768px)" href="phone.css" />
<link rel="stylesheet" media="screen and (max-width:320px)" href="small.css" />

四、内联样式示例

@media screen and (min-width: 980px) {
    //css code
}
@screen and (min-width:768px) and (max-width:980px) {
    //css code
}
@screen and (min-width:480) and (max-width: 768px) {
    //css code
}
@screen and (max-width:320px) {
    //css code
}

@media screen and (max-device-width: 480px) {
    //max-device-width等于480px
}
@media screen and (device-aspect-ratio: 16/9), screen and (device-aspect-ratio: 16/10) {
    //设备宽高比
}
@media all and (orientation:portrait) {
    //竖屏
}
@media all and (orientation:landscape) {
    //横屏
}

五、jQuery Media Queries Plugin for ie6/7/8

http://archive.plugins.jquery.com/project/MediaQueries

六、Demo

http://wlog.cn/html5/media_queries/demo.html

扩展阅读:

编程语录

作者:永远的冰点 发布时间:November 30, 2011 分类:我的生活 1 Comment

KISS – Keep It Simple Stupid

DRY – Don’t Repeat Yourself

过早优化是一切罪恶的根源。

不管走了多远,错了就要重新返回。

出了问题最高优先级应该是先解决问题!想想“为了解决这个问题我应该做什么?”

欲速则不达--不要急于修复一段没能真正理解的代码,要真正的解决问题。

一切以用户需求为导向。

Debian vps下 PPTP VPN 安装笔记

作者:永远的冰点 发布时间:November 21, 2011 分类:linux No Comments

一、安装环境检测

下面介绍两种检测方法,只要符合其中的一条就可以安装

zgrep MPPE /proc/config.gz  

返回 CONFIG_PPP_MPPE=y

cat /dev/net/tun

返回 cat: /dev/net/tun: File descriptor in bad state

二、安装pptp

apt-get update
apt-get install pptpd
apt-get install ppp
apt-get install iptables

三、配置PPTP服务器

1)编辑/etc/pptpd.conf

查找:

#remoteip 192.168.0.234-238,192.168.0.245
# or
#localip 192.168.0.234-238,192.168.0.245

后面添加如下内容:

llocalip 192.168.217.1
remoteip 192.168.217.234-238,192.168.217.245

注:此处的remoteip指定的IP范围是用来给远程连接使用的。如果您远程访问VPN,VPN就会在remoteip范围内分配一个ip地址给你。localip的值直接影响到后面要说的iptables转发规则的编写,所以建议不要随意改动

2)添加PPTP VPN用户

编辑/etc/ppp/chap-secrets 添加如下内容:

username pptpd password *

根据您的需要添加账号,每行一个。格式:“用户名 pptp 密码 ip地址”,中间用空格隔开。

3)修改DNS服务器

编辑/etc/ppp/options,添加如下内容:

ms-dns 8.8.8.8
ms-dns 8.8.4.4

4)修改内核设置,使其支持转发。

编辑/etc/sysctl.conf

将:

#net.ipv4.ip_forward=1

改成:

net.ipv4.ip_forward=1

net.ipv4.tcp_syncookies = 1

改成

#net.ipv4.tcp_syncookies = 1

保存关闭后,执行以下命令使修改后的内核生效

sysctl -p

5)添加iptables转发规则

以下两条命令分别对应OpenVZ架构和XEN架构的VPS。

适合于OpenVZ架构的VPS,12.34.56.78为您VPS的公网IP地址

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 12.34.56.78

适合于XEN架构的VPS

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

添加好规则后保存并重启iptables

/etc/init.d/iptables save 
/etc/init.d/iptables restart

在/etc/network/if-up.d/目录下创建iptables文件,内容如下:

#!/bin/sh
iptables-restore < /etc/iptables.pptp

给脚本添加执行权限:

chmod +x /etc/network/if-up.d/iptables

6)重启pptp服务

/etc/init.d/pptpd restart

7)设置pptp和iptables随系统启动

chkconfig pptpd on 
chkconfig iptables on

如果出现错误619则输入命令

mknod /dev/ppp c 108 0

ok,enjoy it!

十一随拍

作者:永远的冰点 发布时间:October 5, 2011 分类:我的生活 2 Comments

紫金山鸟瞰南京
紫金山鸟瞰南京

紫金山鸟瞰南京
紫金山鸟瞰南京

玄武湖
玄武湖

玄武湖
玄武湖

蓝天白云
蓝天白云