程序设计

专业和发烧友程序员的问答

8
NodeJS需要一个全局模块/包
我试图在全球范围内安装,然后使用forever和forever-monitor这样的: npm install -g forever forever-monitor 我看到了通常的输出以及将文件复制到全局路径的操作,但是如果我尝试require("forever");这样做,则会收到一条错误消息,指出未找到该模块。 我正在使用最新版本的node和npm,并且我已经知道npm在全局安装与本地安装中所做的更改,但是我真的不想在每个项目上都安装localy,并且我正在一个不支持本地安装的平台上工作。不支持,link因此npm link对我而言无法全局安装。 我的问题是:为什么我不需要全局安装的软件包?那是功能还是错误?还是我做错了什么? PS:只是为了让它变得清晰起来:我不想在本地安装。
158 node.js  package  npm 

7
JPA OneToMany不删除子级
我对@OneToMany父实体和子实体之间的简单映射有疑问。一切正常,只有当我从集合中删除子记录时,才会删除它们。 父母: @Entity public class Parent { @Id @Column(name = "ID") private Long id; @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "parent") private Set<Child> childs = new HashSet<Child>(); ... } 孩子: @Entity public class Child { @Id @Column(name = "ID") private Long id; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name="PARENTID", nullable = false) private Parent …
158 java  jpa  jpa-1.0 

8
2列div布局:固定宽度的右列,左侧流体
我的要求很简单:2列,其中正确的列具有固定的大小。不幸的是,无论是在stackoverflow上还是在Google中,我都找不到可行的解决方案。如果我在自己的上下文中实现,那么那里描述的每个解决方案都会失败。当前的解决方案是: div.container { position: fixed; float: left; top: 100px; width: 100%; clear: both; } #content { margin-right: 265px; } #right { float: right; width: 225px; margin-left: -225px; } #right, #content { height: 1%; /* fixed for IE, although doesn't seem to work */ padding: 20px; } <div class="container"> <div id="content"> …
158 css  html 

9
选择SQL Server数据库大小
我如何查询我的sql服务器以仅获取数据库的大小? 我用这个 use "MY_DB" exec sp_spaceused 我懂了 : database_name database_size unallocated space My_DB 17899.13 MB 5309.39 MB 它返回了我不需要的几列,也许有一个技巧可以从此存储过程中选择database_size列? 我也尝试了这段代码: SELECT DB_NAME(database_id) AS DatabaseName, Name AS Logical_Name, Physical_Name, (size * 8) / 1024 SizeMB FROM sys.master_files WHERE DB_NAME(database_id) = 'MY_DB' 它给了我这个结果: DatabaseName Logical_Name Physical_Name SizeMB MY_DB MY_DB D:\MSSQL\Data\MY_DB.mdf 10613 MY_DB MY_DB_log …


14
Android,从字符串获取资源ID?
我需要将资源ID传递给我的一个类中的方法。它既需要使用引用指向的id,也需要使用字符串。我应该如何最好地做到这一点? 例如: R.drawable.icon 我需要获取它的整数ID,但是我还需要访问字符串“ icon”。 如果我只需要传递给该方法的是“ icon”字符串,那将是更好的选择。

8
CSS3自旋动画
我已经回顾了很多演示,并且不知道为什么我无法使CSS3自旋起作用。我正在使用最新的稳定版Chrome。 小提琴:http: //jsfiddle.net/9Ryvs/1/ div { margin: 20px; width: 100px; height: 100px; background: #f00; -webkit-animation-name: spin; -webkit-animation-duration: 40000ms; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-animation-name: spin; -moz-animation-duration: 40000ms; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: linear; -ms-animation-name: spin; -ms-animation-duration: 40000ms; -ms-animation-iteration-count: infinite; -ms-animation-timing-function: linear; -o-transition: rotate(3600deg); } <div></div> 运行代码段隐藏结果展开摘要

1
sed失败,并显示“ s的未知选项”错误
我正在尝试使用 sed -i -e "s/.*seb.*/ \"$ftp_login_template\"/" $ftp_dir 但是我得到这个错误: sed: -e expression #1, char 34: unknown option to `s' 我不明白为什么,因为这很完美: sed -i -e "s/.*wbspassword.*/ \"wbspassword\": \"$password\",/" $user_conf 关于我在做什么错的任何想法吗? 这可能是问题吗? ftp_login_template=\${user}:${password}:24:86::\/var\/lib\/clit.${user}\/downloads:\/bin\/false\"
158 sed 


10
在DST安全的Linux上以bash获取昨天的日期
我有一个运行在Linux上的shell脚本,并使用此调用以以下YYYY-MM-DD格式获取昨天的日期: date -d "1 day ago" '+%Y-%m-%d' 它在大多数情况下都有效,但是当脚本在昨天早晨运行时2013-03-11 0:35 CDT返回"2013-03-09"而不是"2013-03-10"。 大概归咎于夏令时(昨天开始)。我猜想"1 day ago"实现的方式是减去2013-03-11 0:35 CDTwas 之前的24小时和24小时2013-03-09 23:35 CST,这导致的结果"2013-03-09"。 那么,在Linux上bash中获取昨天日期的一种DST安全的好方法是什么?
158 linux  bash 

4
为什么在Visual Studio单元测试中的每个测试都会触发TestInitialize?
我使用Visual Studio 2010 Beta 2中我有一个单一的[TestClass],其中有一个[TestInitialize],[TestCleanup]和几个[TestMethods]。 每次运行测试方法时,初始化和清除方法也都运行! 我的印象是[TestInitialize]&[TestCleanup]每次本地测试只能运行一次。 那是对的吗?如果没有,执行此操作的正确方法是什么?

6
发送字符串到标准输入
有没有一种方法可以有效地在bash中执行此操作: /my/bash/script < echo 'This string will be sent to stdin.' 我知道我可以通过管道传递回声的输出,例如: echo 'This string will be piped to stdin.' | /my/bash/script

7
EOFError:Net :: HTTP文件到达末尾问题
我正在使用ruby-1.8.7-p302 / Rails 2.3.11。我正在尝试使用FQL(Facebook API)来获取链接的统计信息。这是我的代码: def stats(fb_post_url) url = BASE_URI + "?query=#{URI.encode("select like_count from link_stat where url=\"#{fb_post_url}\"")}" parsed_url = URI.parse(url) http = Net::HTTP.new(parsed_url.host, parsed_url.port) request = Net::HTTP::Get.new(parsed_url.request_uri) response = http.request(request) response.inspect end 这是错误: EOFError: end of file reached from /home/rahul/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/net/protocol.rb:135:in `sysread' from /home/rahul/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill' from /home/rahul/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/timeout.rb:67:in `timeout' from /home/rahul/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/timeout.rb:101:in `timeout' …

14
Java中的不可变数组
有没有Java原始数组的不变选择?制作一个原始数组final实际上并不能阻止人们做类似的事情 final int[] array = new int[] {0, 1, 2, 3}; array[0] = 42; 我希望数组的元素不可更改。


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.