This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby | |
def compute(current,remain) | |
result = 0 | |
if remain == 0 | |
result = current == 'a' ? 1 : 0 | |
else | |
for n in ['a','b','c','d'] | |
result += compute(n,remain-1) if n != current | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// display the alert view | |
- (void)createProgressionAlertWithTitle:(NSString *)title message:(NSString *)message andIsActivity:(BOOL)isActivity | |
{ | |
UIAlertView *progressAlert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; | |
// Create the progress bar and add it to the alert | |
if (isActivity) | |
{ | |
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; | |
activityView.frame = CGRectMake(139.0f-18.0f, 60.0f, 37.0f, 37.0f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface PageView : UIView { | |
UIImageView *imageView; | |
UITextView *textView; | |
} | |
@property (nonatomic, retain) UIImageView *imageView; | |
@property (nonatomic, retain) UITextView *textView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading development environment (Rails 2.3.8) | |
>> Rails.env | |
=> "development" | |
>> RAILS_ENV | |
=> "development" | |
>> RUBY_VERSION | |
=> "1.8.7" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
require 'hpricot' | |
require 'open-uri' | |
def google_search(service,query,page,options=nil) | |
url = "http://ajax.googleapis.com/ajax/services/search/#{service}?v=1.0&q=#{query}&start=#{page}0" | |
url += options.to_s | |
url += "&key=ABQIAAAAvJK0-O6R9IuRS5y6YePa_BQ7FXN5Ck7MXp2rPPrMwF-0TtPdBhSCDq3eiNkPUQlaeTXgVbm7vRuvyw" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> sudo add-apt-repository ppa:ubuntu-mozilla-security/ppa | |
>> sudo aptitude update | |
>> sudo aptitude install xulrunner-1.9.1-dev | |
http://www.ubuntuupdates.org/packages/show/159108 | |
/etc/apt/sources.list: | |
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid main universe | |
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid main universe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# init.d script with LSB support. | |
# | |
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]> | |
# | |
# This is free software; you may redistribute it and/or modify | |
# it under the terms of the GNU General Public License as | |
# published by the Free Software Foundation; either version 2, | |
# or (at your option) any later version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby developer packages | |
sudo apt-get install ruby1.8 ri1.8 rdoc1.8 irb1.8 | |
sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby | |
# hpricot requirements | |
sudo apt-get install ruby1.8-dev | |
sudo gem install hpricot | |
# nokogiri requirements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MySQL Log 的配置 | |
MySQL内置4种Log: | |
Error Log, General Query Log, Binary Log, Slow Query Log | |
1. Error Log | |
错误日志, 记录MySQL启动、运行、停止过程中出现的错误信息 | |
2. General Query Log | |
记录MySQL客户端连接、查询的细节, 调试的时候很有用, 正式运行的时候最好关闭否则会带来大量磁盘IO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
更换mysql的数据库目录,需要将原来的db数据copy到目标目录,然后做如下更改: | |
/etc/mysql/my.cnf | |
# * Basic Settings | |
# | |
# | |
# * IMPORTANT | |
# If you make changes to these settings and your system uses apparmor, you may |