我是新手,所以很容易.我创建了一个博客,能够通过使用像Facebook的"喜欢"这样的功能在帖子上"投票".我没有使用任何身份验证,但希望通过IP限制对特定帖子的投票.也就是说,一旦有人投票支持一个帖子,他们就不能再投票(除非他们当然重置了他们的路由器).
我觉得这应该是我通过修改投票或帖子模型而影响的东西,但我担心它与Sessions有关,但是......我还没有任何经验.
如果您需要我发布任何代码,请告诉我.这是投票控制者.
class VotesController < ApplicationController
def create
@post = Post.find(params[:post_id])
@vote = @post.votes.create!(params[:vote])
respond_to do |format|
format.html { redirect_to @post}
format.js
end
end
end
Run Code Online (Sandbox Code Playgroud) 为什么我改变一个数组维度的大小我得到一个运行时错误:"分段错误?".例:
#include <stdio.h>
#define DIM 8
int main(int argc, char **argv)
{
int a[3][3][3][3][3][3][3][3][3][3][DIM],
b;
a[1][1][1][1][1][1][1][1][1][1][1] = 2;
b=a[1][1][1][1][1][1][1][1][1][1][1];
printf("%d \n",b);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果DIM为8,则不会产生运行时错误,但只要DIM大于8,就会导致运行时错误"Segmentation Fault".为什么???
我有两个文本框,我想只在两个文本都为空时跳过一段代码:
if (txtBox1.Text.Trim() != string.Empty && txtBox2.Text.Trim() != string.Empty )
{
// Do something
}
Run Code Online (Sandbox Code Playgroud)
如果任何一个文本框都有,我想要//执行某些部分.只有当两者都是空的时候我才想跳过.
但是上面的代码片段不起作用.为什么?
我有一个使用enum类型的表列.我希望更新该enum类型以获得额外的可能值.我不想删除任何现有值,只需添加新值.最简单的方法是什么?
在我的项目的POM父文件中,我有一个这样的配置文件定义了一些对这个项目有用的配置(这样我就无法摆脱这个父POM):
<profile>
<id>wls7</id>
...
<build>
<plugins>
<!-- use java 1.4 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<fork>true</fork>
<source>1.4</source>
<target>1.4</target>
<meminitial>128m</meminitial>
<maxmem>1024m</maxmem>
<executable>%${jdk14.executable}</executable>
</configuration>
</plugin>
</plugins>
</build>
...
</profile>
Run Code Online (Sandbox Code Playgroud)
但在我的项目中,我只想覆盖maven-compiler-plugin的配置,以便使用jdk5而不是jdk4来编译测试类.
这就是我在项目的POM中完成此部分的原因:
<profiles>
<profile>
<id>wls7</id>
<activation>
<property>
<name>jdk</name>
<value>4</value>
</property>
</activation>
<build>
<directory>target-1.4</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>my-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<fork>true</fork>
<executable>${jdk15.executable}</executable>
<compilerVersion>1.5</compilerVersion>
<source>1.5</source>
<target>1.5</target>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
...
</profiles>
Run Code Online (Sandbox Code Playgroud)
它不起作用......
我甚至试图在我的POM的常规插件部分中覆盖配置(我的意思是,不是针对特定的配置文件,而是针对我的整个POM).
可能是什么问题呢 ?
澄清我的一些要求:
它只是一个继承问题(扩展或覆盖一个配置文件,一个来自上层POM的配置)所以我认为应该可以使用Maven 2.
我正在使用IPhone SDK,对于objective-c我是一个新手.现在我正在使用NSUserDefaults来保存和恢复我的iPhone应用程序上的设置.为了保存已创建的类,我将它们编码为字典形式,然后保存NSdictionary.
我的问题是我找不到合理的方法以合理的方式在字典中存储非值(IE是一个nil的类变量).更具体地说,我说我有一个"狗"类,它有NSString*尾色.让我们说我试图保存没有尾巴的狗的类实例,因此该实例的尾部颜色为零.拯救狗作为字典的合理方法是什么?它不会让我将nil保存到NSdictionary中.@""不好,因为如果我这样做(@""),@""是真的.我希望它像假的那样是假的.
我希望我的问题有道理,谢谢你的帮助!
我有一个表单中的textarea,当我在其中输入特殊字符时,我在mysql中出错.(当将表单提交到php文件时,该文件执行插入mysql的工作)
我需要确切地知道哪些字符是不允许的,或者更容易,正是允许的字符是什么,以便我可以在提交之前验证textarea.
有人知道吗?
我试过mysql_real_escape_string()但没有帮助...
注意:在textarea中,用户应该输入一些这样的特殊字符:
+ , . ; : - _ space & % ! ? = # * ½ @ / \ [ ] ' " < > £ $ €
Run Code Online (Sandbox Code Playgroud)
可能得到了所有......
我怎样才能做到这一点?
谢谢
UDPATE
我的mysql_query:
mysql_query("INSERT INTO cars_db (description) VALUES ('$ad_text')");
Run Code Online (Sandbox Code Playgroud)
UPDATE
Mysql错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a"a!a?aa+a-a_a
a/a\a[a]a}a{a&a%a#a@a¨a^a*a*aa,a.a:a;a|a½a
§a' at line 1
Run Code Online (Sandbox Code Playgroud) 是否每个人都迁移到MPI(消息传递接口)或PVM仍然广泛用于超级计算机和HPC?
我正在尝试为我的应用程序的文档类型注册一个图标.在阅读声明新的统一类型标识符并查看后,/Developer/Examples/Sketch我想出了类似这样的内容Info.plist:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.mycompany.myextension</string>
</array>
<key>NSDocumentClass</key>
<string>NSString</string>
</dict>
</array>
...
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>Blah blah blah</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeIconFile</key>
<string>My-file-icon.icns</string>
<key>UTTypeIdentifier</key>
<string>com.mycompany.myextension</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>myextension</string>
</array>
</dict>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
现在,一切都很好,花花公子,即当我点击带有我的扩展名的文件等时我的程序被打开.但是,文档图标没有在操作系统中注册,即我看到一个丑陋的空白图标而不是我的美丽My-file-icon.icns.我怀疑我在上面的plist中遗漏了什么,有什么想法吗?
我正在考虑在其他地方托管的Windows虚拟机上安装subversion,并且不想安装apache.
我是否仅限于使用svn:protocol访问它?它是否适用于异地?
有没有经验呢?
谢谢