inline int saturate_to_255 (int a)
{
int y;
asm ("usat %0, #8, %1\n\t" : "=r"(y) : "r"(a));
return y;
}
should be equivalent to:
inline int saturate_to_255 (int a)
{
if (a < 0) a =0;
if (a > 255) a = 255;
return a;
}
加载中…
加载中…
加载中…
加载中…
inline int saturate_to_255 (int a)
{
int y;
asm ("usat %0, #8, %1\n\t" : "=r"(y) : "r"(a));
return y;
}
should be equivalent to:
inline int saturate_to_255 (int a)
{
if (a < 0) a =0;
if (a > 255) a = 255;
return a;
}
标签:
it |
嗯,另外有个小小的提示,某些VPS提供商的系统真的是非常非常的干净啊~连wget和unzip都没有,所以需要先安装下,
另外,更新下系统也是必要的哦
apt-get -y install wget unzip
apt-get -y update
好吧,Let’s Go~ (我说: mac下用port, sudo port install wget )
Redmine是一个基于RoR的软件~所以安装Redmine之前先要把Ruby同学招来~~
在这里我使用了性能更好的REE(Ruby Enterprise Edition)来代替Ruby原生的解释器
cd /tmp
wget http://rubyforge.org/frs/download.php/71098/ruby-enterprise_1.8.7-2010.02_amd64_ubuntu10.04.deb
deb -i ruby-enterprise_1.8.7-2010.02_amd64_ubuntu10.04.deb
rm -f ruby-enterprise_1.8.7-2010.02_amd64_ubuntu10.04.deb
接着安装Rails和Rack
gem install rails -v=2.3.5
gem install rack -v=1.0.1
gem install mysql
这一步其实不是必要的~因为…因为咱的数据库服务器和Redmine用的不是同一台~
好吧,不废话~
apt-get install mysql-server
安装过程中会要求输入root密码,请记住哦~等下要用到呢;
在这里我将Redmine安装到/var/redmine下,你也可以根据个人喜好修改
wget http://rubyforge.org/frs/download.php/72627/redmine-1.0.2.tar.gz
tar zxvf redmine-1.0.2.tar.gz
mv redmine-1.0.2 /var/redmine
cd /var/redmine
接下来先配置下数据库~
mysql -ppassword
create database redmine character set utf8;
create user ‘redmine’@'localhost’ identified by ‘password‘;
grant all privileges on redmine.* to ‘redmine’@'localhost’;
复制配置文件
cd config
mv database.yml.example database.yml
找个喜欢的编辑器打开database.yml,修改配置
# MySQL (default setup). production: adapter: mysql database: redmine host: localhost username: redmine password: password encoding: utf8 development: adapter: mysql database: redmine host: hocalhost username: redmine password: password encoding: utf8
接下来生成一个Session Store Secret
rake generate_session_store
创建数据库~~然后插入默认设置
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
如果没有啥错误提示的话~~那就是装完了
无敌的apt-get啊。。。果然是超级牛力
apt-get install lighttpd
标签:
it |
标签:
it |
分类: technology |
要使用ant首先要构建一个ant环境,步骤很简单:
1),安装jdk,设置JAVA_HOME ,PATH ,CLASS_PATH(这些应该是看这篇文章的人应该知道的)
2),下载ant 地址www.apache.org找一个你喜欢的版本,或者干脆最新的版本
3),解压ant 你得到的是一个压缩包,解压缩它,并把它放在一个尽量简单的目录,例如D:\ant-1.6虽然你不一
定要这么做,但这么做是有好处的。
4),设置ANT_HOME PATH中添加ANT_HOME目录下的bin目录
5),测试一下你的设置,开始-->运行-->cmd进入命令行-->键入
ant 回车,如果看到
Buildfile: build.xml does not exist!
Build failed
那么恭喜你你已经完成ant的设置
二,体验ant
就像每个语言都有HelloWorld一样,一个最简单的应用能让人感受一下Ant
1,首先你要知道你要干什么,我现在想做的事情是:
编写一些程序
编译它们
把它打包成jar包
把他们放在应该放置的地方
运行它们
这里为了简单起见只写一个程序,就是HelloWorld.java程序代码如下:
package test.ant;
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello world1");
}
};
2,为了达到上边的目的,你可以手动的用javac 、copy 、jar、java来完成,但是考虑一下如果你有成百上千个类,在多次调试,部署的时候,一次次的javac 、copy、jar、java那将是一份辛苦的工作。现在看看ant怎么优雅的完成它们。
要运行ant需要有一个build.xml虽然不一定要叫这个名字,但是建议你这么做
下边就是一个完整的build.xml,然后我们来详细的解释每一句
<?xml version="1.0" encoding="UTF-8"
?>
<project name="HelloWorld" default="run"
basedir=".">
<property name="src"
value="src"/>
<property name="dest"
value="classes"/>
<property name="hello_jar"
value="hello1.jar"/>
<target
name="init">
<mkdir
dir="${dest}"/>
</target>
<target name="compile"
depends="init">
<javac srcdir="${src}"
destdir="${dest}"/>
</target>
<target name="build"
depends="compile">
<jar jarfile="${hello_jar}"
basedir="${dest}"/>
</target>
<target name="run"
depends="build">
<java
classname="test.ant.HelloWorld"
classpath="${hello_jar}"/>
</target>
<target
name="clean">
<delete dir="${dest}"
/>
<delete file="${hello_jar}"
/>
</target>
<target name="rerun"
depends="clean,run">
<ant target="clean"
/>
<ant target="run"
/>
</target>
</project>
解释:
<?xml version="1.0" encoding="UTF-8"
?>
build.xml中的第一句话,没有实际的意义
<project name="HelloWorld" default="run"
basedir=".">
</project>
ant的所有内容必须包含在这个里边,name是你给它取的名字,basedir故名思意就是工作的根目录
.代表当前目录。default代表默认要做的事情。
<property name="src"
value="src"/>
类似程序中的变量,为什么这么做想一下变量的作用
<target name="compile"
depends="init">
<javac srcdir="${src}"
destdir="${dest}"/>
</target>
把你想做的每一件事情写成一个target ,它有一个名字,depends是它所依赖的target,在执行这个target
例如这里的compile之前ant会先检查init是否曾经被执行过,如果执行过则直接直接执行compile,如果没有则会先执行它依赖的
target例如这里的init,然后在执行这个target
如我们的计划
编译:
<target name="compile"
depends="init">
<javac srcdir="${src}"
destdir="${dest}"/>
</target>
做jar包:
<target name="build"
depends="compile">
<jar jarfile="${hello_jar}"
basedir="${dest}"/>
</target>
运行:
<target name="run"
depends="build">
<java
classname="test.ant.HelloWorld"
classpath="${hello_jar}"/>
</target>
为了不用拷贝,我们可以在最开始定义好目标文件夹,这样ant直接把结果就放在目标文件夹中了
新建文件夹:
<target name="init">
<mkdir
dir="${dest}"/>
</target>
为了更多一点的功能体现,又加入了两个target
删除生成的文件
<target name="clean">
<delete dir="${dest}"
/>
<delete file="${hello_jar}"
/>
</target>
再次运行,这里显示了如何在一个target里边调用其他的target
<target name="rerun"
depends="clean,run">
<ant target="clean"
/>
<ant target="run"
/>
</target>
好了,解释完成了,下边检验一下你的ant吧
新建一个src的文件夹,然后把HelloWorld.java按照包目录放进去
做好build.xml文件
在命令行下键入ant ,你会发现一个个任务都完成了。每次更改完代码只需要再次键入ant
有的时候我们可能并不想运行程序,只想执行这些步骤中的某一两个步骤,例如我只想重新部署而不想运行,键入
ant build
标签:
it |
|
Scrum工具大比拼---流行Scrum工具一网打尽
|
|
|
|
|
|
标签:
it |
标签:
vcit |
分类: technology |
Block objects are a C-level syntactic and runtime feature that allow you to compose function expression_rs that can be passed as arguments, optionally stored, and used by multiple threads. The function expression_r can reference and can preserve access to local variables. In other languages and environments, a block object is sometimes also called a closure or a lambda. You use a block when you want to create units of work (that is, code segments) that can be passed around as though they are values. Blocks offer more flexible programming and more power. You might use them, for example, to write callbacks or to perform an operation on all the items in a collection.
In many situations, you use blocks inline so you don’t need to
declare them. The declaration syntax, however, is similar to the
standard syntax for function pointers, except that you use a caret
(^) instead of an asterisk pointer (*). For example, the following
declares a variable aBlock that references a block
that requires three parameters and returns a float
value:
float (^aBlock)(const int*, int, float); |
You use the caret (^) operator to indicate the
beginning, and a semicolon to indicate the end of a block
expression_r. The following example declares a simple block and
assigns it to a previously declared block variable
(oneFrom):
int (^oneFrom)(int); |
|
|
oneFrom = ^(int anInt) {
|
return anInt - 1;
|
}; |
The closing semicolon is required as a standard C end-of-line marker.
If you don’t explicitly declare the return value of a block expression_r, it can be automatically inferred from the contents of the block.
You can use the __block storage modifier with
variables declared locally to the enclosing lexical scope to denote
that such variables should be provided by reference in a block and
so are mutable. Any changes are reflected in the enclosing lexical
scope, including any other blocks defined within the same enclosing
lexical scope.
If you declare a block as a variable, you can use it as you would a function. The following example prints 9 as output.
printf("%d\n", oneFrom(10));
|
Typically, however, you pass a block as the argument to a function or a method. In these cases, you often create a block inline.
The following example determines whether an NSSet
object contains a word specified by a local variable and sets the
value of another local variable (found) to
YES (and stops the search) if it does. In this
example, found is declared as a __block
variable.
__block BOOL found = NO; |
NSSet *aSet = [NSSet setWithObjects: @"Alpha", @"Beta", @"Gamma", @"X", nil]; |
NSString *string = @"gamma"; |
|
|
[aSet enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
|
if ([obj localizedCaseInsensitiveCompare:string] == NSOrderedSame) {
|
*stop = YES;
|
found = YES;
|
}
|
}]; |
|
|
// At this point, found == YES |
In this example, the block is contained within the method’s argument list. The block also makes use of a stack local variable.
标签:
it |
这个主要原因:在svnadmin create时是root身份,所以,mod_dav_svn就没有write权限等。
解决办法:
再试就ok~