可以选择下面方式登录...

  • LOGIN

OSX中开启和关闭查看隐藏文件

OSX中开启和关闭查看隐藏文件:

chflags nohidden ~/Library
chflags hidden ~/Library

nginx-https服务器 git服务器 archlinux升级问题

修复Archlinux升级出现文件已存在的错误:

pacman -S filesystem --force

创建伪证书使用nginx的https:

$ openssl genrsa -des3 -out server.key 1024
$ openssl req -new -key server.key -out server.csr
$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

修改nginx配置

server {
    server_name localhost;
    listen 443;
    ssl on;
    ssl_certificate server.crt;
    ssl_certificate_key server.key;
}

linux中查找和打包的命令

find / -name your_target_name

tar -cvf your_package_name.tar /your_target_path

使用virtualenv

很多时候需要在同一平台上使用多个不同版本的python包,这种情况可以用到virtualenv。

安装virtualenv:

pip install virtualenv

创建python虚拟环境:

virtualenv --no-site-packages /PROJECT_PATH

激活python虚拟环境:

source /PROJECT_PATH/bin/activate

然后就可以独立使用当前python环境了。

设置UIScrollView的移动速度

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[scrollView scrollRectToVisible:CGRectMake(0, 0, 1024, 768) animated:NO];
[UIView commitAnimations];

或者

[UIView animateWithDuration:3.0 animations:^{
    scrollView.contentOffset = CGPointMake(1024, 0);
}];

在UITableViewController里刷新数据

苹果官方文档里这么写的:

If a nib file containing the table view is loaded, the data source and delegate become those objects defined in the nib file (if any). If no nib file is specified or if the nib file defines no data source or delegate, UITableViewController sets the data source and the delegate of the table view to self.

实际上动态创建的表数据是绑定到了那个NSArray上,在刷新数据以后要把表里的这个NSArray也重载一下,然后:

[self.tableView reloadData]

Xcode4.2里新建空项目的方法

第一种方法:添加空项目以后,添加一个window,然后将window的File's Owner的class选择成UIApplication,然后从组件里拖一个NSObject到Objects里,设置NSObject的的File's Owner的class为项目的Delegate.h,修改Delegate.h文件添加window的输出,并且连接到window。选中window的File's Owner将delegate连接到刚才创建的delegate object。 新建一个带xib的视图控制器,修改Delegate.m:

- (BOOL)application:
(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    FirstViewController *firstViewController = 
                                   [[FirstViewController alloc]
                                   initWithNibName:@"FirstViewController" bundle:nil];
    [self.window addSubview:firstViewController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

还有一种方法就是在新建空项目以后直接新建一个Appication,这样就省去了自己添加window喝Object的步骤。

使用spawn-fcgi和nginx部署php网站

安装spawn-fcgi、nginx、mysql、vsftpd、php、php-cgi。

上传php程序到服务器,最好是找个权限好控制的目录比如/var/www这样。php.ini需要开通一下mysql支持和执行目录限制:

open_basedir=/var/www/

配置nginx

启动spawn-fcgi

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid

非全局VPN

(Mac用户可以忽略)老子的路由器不支持做VPN的客户端,但是老子还是想看youtube的高清视频。建立VPN连接的快捷方式以后,需要在ipv4高级设置里取消选中的*在远程网络上使用默认网关*,这样电脑会还是使用本地的路由器,然后还需要设置一下对需要翻墙的网址使用远程路由器,拿youtube来说(远程网关是192.168.0.1):

route add 203.208.46.29 mask 255.255.255.255 192.168.0.1

操作成功以后可以用route PRINT打印出路由表,可以看到新添加的路由指令,然后用tracert命令测试一下:

tracert 203.208.46.29

tracert www.163.com

对203.208.46.29使用的是远程网关192.168.0.1,对163使用的应该是本地默认的网关192.168.1.1。

不过VPN断开以后路由指令会失效,正在考虑放到网关上共享这个VPN是否可行。

一键拨号并使用局部翻墙:

rasdial VPN_NAME VPN_USERNAME VPN_PASSWORD
@echo off
route add 204.62.114.16 mask 255.255.255.255 192.168.0.1
pause

使用openvpn的可以在配置文件里加入:

route-nopull
route DESTINY_IP 255.255.255.255 vpn_gateway

Advice from a programer

没读过《笨办法学Python》,不过非常喜欢作者最后写的这些话:

Finally, I'll say that learning to create software changes you and makes you different. Not better or worse, just different. You may find that people treat you harshly because you can create software, maybe using words like "nerd". Maybe you'll find that because you can dissect their logic that they hate arguing with you. You may even find that simply knowing how a computer works makes you annoying and weird to them.

To this I have just one piece of advice: they can go to hell. The world needs more weird people who know how things work and who love to figure it all out. When they treat you like this, just remember that this is your journey, not theirs. Being different is not a crime, and people who tell you it is are just jealous that you've picked up a skill they never in their wildest dreams could acquire.

You can code. They cannot. That is pretty damn cool.

1/5 下一页

Copyright © 2009 Castle of Lucid Maded by Zhou Yang