我正在尝试编写一个快速插件,将一些AJAX内容加载到jQuery UI对话框中,并相应地调整对话框的大小和居中.以下是它的作用要点:
$(mySelector).html('Loading...').load(options.url, function() {
element = $(mySelector);
element.dialog('option', 'height', element.height() + 50);
element.dialog('option', 'width', element.width());
element.dialog('option', 'position', 'center');
});
Run Code Online (Sandbox Code Playgroud)
高度似乎没问题(添加一些填充对话框添加)但宽度总是274无论如何.我认为对话框本身正在设置它的大小限制.如何将其设置为加载内容的自然宽度?
编辑/添加: 它返回模态的默认大小.因为即使它包含更宽的内容(例如500px图像),父容器(mySelector)也可能不那么宽(至少在FF中),因此它始终是默认值(300 - padding = 274).是否有任何方法可以自动检测返回内容的宽度是否最小而不滚动?)
我在C#WPF应用程序中有两个字符串,并希望生成一个统一的diff文件(格式为GNU diff表示法,就像Subversion和TortoiseSVN中使用的补丁一样).
有没有一个库可以为我做这个而不是重新创建轮子?
我一直在搜索谷歌没有成功.:(
var html = "<div id='blah'>Hello stuff here</div>"
$("#mycontent").append(html).fadeIn(999);
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用.
当内容被追加时,我只想要一个很酷的效果.
注意:我想要新的"blah"div淡入,而不是整个"mycontent".
所以,假设我有一个char,我想在一行代码中将它strcat()转换为char数组.对于[非实际]示例:
strcat("ljsdflusdfg",getchar());
Run Code Online (Sandbox Code Playgroud)
或者我想反过来说,无论数据类型如何,连接或类型转换字符串的适当功能是什么?或者也许有一些我遗漏的语法......
这是一个例子.它编译得很好,但崩溃.
char* input(){
char* inp="";
while(1){
char c=getchar();
if(c){
if(c=='\n'||c==EOF){
break;
}else{
strcat(inp,(char*)c);
}
}
}
return inp;
}
Run Code Online (Sandbox Code Playgroud) 如果#(hash)要转到页面的特定部分,你如何绕过默认行为?我遇到的问题是#字符是SEO友好URL的一部分,它是一个标题而#(hash)是内容的一部分(即与C#一样).我无法检索整个字符串,我只在#之前得到字符.
例:
www.domain.com/C#-programming-book
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我只得到'C'而不是'-programming-book'部分.我目前没有使用任何javascript,并且只想使用PHP解决方案.
在任何人建议我使用url编码之前,seo友好网址的标准是它应该是人类可读的并且容易记住.因此,将哈希值转换为'%23'并未通过标准.
周围没有办法吗?
如果我在GridLayout中有几个JPanels,每个都有一个MouseAdapter,然后创建JLabel(带文本)并添加到每个JPanels.请注意,JLabel没有侦听器.如果我渲染它并尝试单击JPanel,或者,最终尝试单击JLabel,MouseAdapter会将其注册为事件吗?
基本上我希望JPanels注册事件和JPanels只显示JPanels上面的文本.此外,面板具有背景颜色.
如果JLabel确实"隐藏"了注册事件,我该如何解决这个问题呢?
我编写了一个包含用C语言编写的子模块的Python模块:模块本身被调用foo而C部分被调用foo._bar.结构如下:
src/
foo/__init__.py <- contains the public stuff
foo/_bar/bar.c <- the C extension
doc/ <- Sphinx configuration
conf.py
...
Run Code Online (Sandbox Code Playgroud)
foo/__init__.py导入_bar以增加它,并在foo模块中公开有用的东西.它在构建时工作正常,但显然不能以未编译的形式工作,因为_bar在构建之前不存在.
我想使用Sphinx来记录项目,并在模块上使用autodoc扩展foo.这意味着我需要在构建文档之前构建项目.
由于我使用distutils构建,所以构建的模块最终会出现在一些名为dir的变量中build/lib.linux-ARCH-PYVERSION- 这意味着我不能仅仅将目录硬编码为Sphinx conf.py.
那么如何配置我的distutils setup.py脚本以在构建的模块上运行Sphinx构建器?
为了完整性,这里是调用setup('假'的东西是子类的自定义构建器build和build_ext):
setup(cmdclass = {
'fake': fake,
'build_ext_fake' : build_ext_fake
},
package_dir = {'': 'src'},
packages = ['foo'],
name = 'foo',
version = '0.1',
description = desc,
ext_modules = [module_real])
Run Code Online (Sandbox Code Playgroud) 操作系统名称:"linux"版本:"2.6.32-27-generic"arch:"i386"系列:"unix"
Apache Maven 2.2.1(r801777; 2009-08-06 12:16:01-0700)
Java版本:1.6.0_20
我试图在ubuntu中使用maven与maven相关联.如果我移动maven下载到我的$ JAVA_HOME/jre/lib/ext /文件夹中的"mysql-connector-java-5.1.14.jar"文件,那么当我运行jar时一切都很好.
我想我应该只能在pom.xml文件中指定依赖项,maven应该自动设置依赖项jar的类路径.这是不正确的?
我的pom.xml文件如下所示:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ion.common</groupId>
<artifactId>TestPreparation</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestPrep</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.ion.common.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JUnit testing dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
命令"mvn package"构建它没有任何问题,我可以运行它,但是当应用程序尝试访问数据库时,会出现以下错误:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at …Run Code Online (Sandbox Code Playgroud) 我已经实现了简单的TCP服务器和TCP客户端类,可以将消息从客户端发送到服务器,消息将在服务器端转换为大写,但是如何实现从服务器到客户端的传输文件以及从客户端上传文件到服务器.以下代码是我所拥有的.
TCPClient.java
import java.io.*;
import java.net.*;
import java.util.Scanner;
class TCPClient {
public static void main(String args[]) throws Exception {
int filesize=6022386;
int bytesRead;
int current = 0;
String ipAdd="";
int portNum=0;
boolean goes=false;
if(goes==false){
System.out.println("please input the ip address of the file server");
Scanner scan=new Scanner(System.in);
ipAdd=scan.nextLine();
System.out.println("please input the port number of the file server");
Scanner scan1=new Scanner(System.in);
portNum=scan1.nextInt();
goes=true;
}
System.out.println("input done");
int timeCount=1;
while(goes==true){
//System.out.println("connection establishing");
String sentence="";
String modifiedSentence;
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(
System.in)); …Run Code Online (Sandbox Code Playgroud) 我正在寻找最好的解决方案,我可以确保我正确地做到这一点:
我的网站上有一个日历,用户可以在其中使用日历iCal Feed并将其导入到他们偏好的外部日历中(Outlook,iCal,Google Calendar等).
为了阻止坏人抓取/搜索我的网站上的*.ics文件,我设置了Robots.txt来禁止存储订阅源的文件夹.
因此,基本上,iCal Feed可能如下所示:webcal://www.mysite.com/feeds/cal/a9d90309dafda390d09/feed.ics
据我所知,上面仍然是一个公共URL.但是,我有一个功能,用户可以根据需要更改其Feed的地址.
我的问题是:除Google日历外,所有外部日历都无法导入/订阅日历Feed.它会抛出消息:由于robots.txt限制,Google无法抓取该网址. 谷歌对此的回答.
因此,搜索后,我发现以下工作:
1)设置一个PHP文件(我正在使用),它本质上强制下载文件.它基本上看起来像这样:
<?php
$url = "/home/path/to/local/feed/".$_GET['url'];
$file = fopen ($url, "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
print $line;
}
fclose($file);
?>
Run Code Online (Sandbox Code Playgroud)
我尝试使用此脚本,它似乎与Google日历一起使用,没有任何问题.(虽然,我不确定它是否更新/刷新.我还在等着看它是否有效).
我的问题是:有没有更好的方法来解决这个问题?我想保留当前的Robots.txt以禁止抓取我的目录以获取*.ics文件并保持文件隐藏.