问题列表 - 第41133页

c#字符串拆分和组合

我有一个符合5个数字的字符串

'1,4,14,32,47'
Run Code Online (Sandbox Code Playgroud)

我想用这个字符串制作5个字符串,每个字符串包含4个数字

喜欢 :

 '1,4,14,32'
 '1,4,14,47'
 '1,4,32,47'
 '1,14,32,47'
 '4,14,32,47'
Run Code Online (Sandbox Code Playgroud)

什么是简单/更快的方式

是什么方法将此转换为数组unset每次不同的entery并将它们组合回字符串?

有一个简单的方法吗?

谢谢

c# arrays string combinations

6
推荐指数
1
解决办法
6163
查看次数

在创建Hibernate SessionFactory时如何设置Datasource?

我正在创建SessionFactory,我将我的数据源作为对象在我正在创建SessionFactory的代码中,但是我无法将数据源设置为Hibernate Configuration对象.那么如何将我的数据源设置为SessionFactory?

Configuration configuration = new Configuration();
Properties properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect");
configuration.setProperties(properties);
configuration.setProperty("packagesToScan", "com.my.app");
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();
Run Code Online (Sandbox Code Playgroud)

java hibernate sessionfactory

19
推荐指数
2
解决办法
5万
查看次数

重启以查看更改?Cherokee + uWSGI + Django/Pinax + Virtualenv

我在切诺基+ uWSGI在我的django应用程序中接受.py文件的代码更改时遇到了一些麻烦.即使使用

find -name "*.pyc" -delete

......似乎没有效果.

在django runserver下运行相同的代码库时,在刷新时会立即注意到更改

如何强制重启并可靠地查看Cherokee + uWSGI + Django下的更改?

django virtualenv cherokee pinax uwsgi

2
推荐指数
1
解决办法
2041
查看次数

使用RApacheOutputErrors控制输出

我在r.conf中激活了ROutputErrors,它可以正常工作.

当我有错误时,我得到了这个:

Oops!!! rApache has something to tell you. View source and read the 
HTML comments at the end. 
Run Code Online (Sandbox Code Playgroud)

在源代码中我得到了错误.

\n<!--\nError in library(micEconAids) : there is no package called 
'micEconAids'\nTraceback:\n5: stop(txt, domain = NA)\n4: 
library(micEconAids)\n3: eval(expr, envir, enclos)\n2: eval(i, envir) 
\n1: sys.source(file = \"\/var\/www\/r\/test\/25.R\", envir = .rAenv) 
\n-->\n 
Run Code Online (Sandbox Code Playgroud)

我正在尝试构建一个Web服务,我想直接得到错误.我想在r.conf中这样做

RApacheOutputErrors(TRUE,"<p>","</p>")
Run Code Online (Sandbox Code Playgroud)

但我在重启时遇到此错误:

"Invalid command 
'RApacheOutputErrors(TRUE,"<p>","</p>")', perhaps misspelled or 
defined by a module not included in the server configuration"; 
Run Code Online (Sandbox Code Playgroud)

我如何以及在何处使用此指令?

谢谢

r rapache

54
推荐指数
1
解决办法
773
查看次数

Code Golf:验证Sudoku Grid

介绍

有效的数独网格填充数字1到9,在9,行或列的每个子块中没有数字出现多次.如果您不熟悉这个流行的谜题,请阅读本文以获取更多详细信息.

挑战

挑战是编写最短的程序来验证可能未满的Sudoku网格.

输入将是一行9行,每行9个字符,代表网格.空单元格将由a表示..您的输出应该是Valid网格有效,否则输出Invalid.

输入

123...789
...456...
456...123
789...456
...123...
564...897
...231...
897...564
...564...
Run Code Online (Sandbox Code Playgroud)

产量

Valid
Run Code Online (Sandbox Code Playgroud)

输入

123456789
987654321
123456789
123456789
987654321
123456789
123456789
987654321
123456789
Run Code Online (Sandbox Code Playgroud)

产量

Invalid
Run Code Online (Sandbox Code Playgroud)

代码高尔夫规则

请以解决此问题的任何语言发布您的最短代码.输入和输出可以通过stdin和stdout或您选择的其他文件来处理.

获胜者将是在发布此问题之前存在实现的语言中最短的解决方案(按字节数).因此,虽然您可以自由地使用您刚刚编写的语言来提交一个0字节的解决方案,但它不会计算,您可能会得到downvotes.

algorithm code-golf sudoku

17
推荐指数
4
解决办法
2673
查看次数

合同需要Session,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它

当我SessionMode = SessionMode.Required在servicecontract中使用时,我得到这个错误

合同需要Session,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它.

有谁告诉我一个解决方案?

wcf

14
推荐指数
2
解决办法
3万
查看次数

AutoMapper的1.1 CreateMap在长时间运行后引发NullReferenceException

我正在托管一个使用AutoMapper将某些类转换为其他类的应用程序.这一直很好,直到今天.该申请已被托管约3个月.在我们之间已经完成了几个部署,其中应用程序已重新启动,但IIS没有.

从不知道应用程序开始失败,回顾我们发现这是原因的日志:

    System.NullReferenceException: Object reference not set to an instance of an object.
   at AutoMapper.Configuration.<>c__DisplayClass13.<FindExplicitlyDefinedTypeMap>b__12(TypeMap x)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at AutoMapper.Configuration.FindExplicitlyDefinedTypeMap(Type sourceType, Type destinationType)
   at AutoMapper.Configuration.CreateTypeMap(Type source, Type destination, String profileName)
   at AutoMapper.Configuration.CreateMap[TSource,TDestination](String profileName)
   at AutoMapper.Configuration.CreateMap[TSource,TDestination]()
   at AutoMapper.Mapper.CreateMap[TSource,TDestination]()
Run Code Online (Sandbox Code Playgroud)

所以我们切换到我们的备份服务器,它根本没有这个问题.我们尝试通过重新启动应用程序来解决问题,但没有帮助.只有重新启动IIS修复了该问题.

我们尝试查看源代码以找出导致此问题的原因,我们在https://github.com/jbogard/AutoMapper/上下载了该问题.异常似乎是在AutoMapper的ConfigurationStore类的此方法中引起的.

    private TypeMap FindExplicitlyDefinedTypeMap(Type sourceType, Type destinationType)
    {
        return _typeMaps.FirstOrDefault(x => x.DestinationType == destinationType && x.SourceType == sourceType);
    }
Run Code Online (Sandbox Code Playgroud)

_typeMaps在类中定义如下.

    private readonly IList<TypeMap> _typeMaps = new List<TypeMap>();
Run Code Online (Sandbox Code Playgroud)

如果我们检查TypeMap,我们会看到x.DestionationType和x.SourceType引用其他属性:

    private readonly TypeInfo _destinationType;
    private readonly TypeInfo _sourceType;

    public …
Run Code Online (Sandbox Code Playgroud)

c# automapper

7
推荐指数
1
解决办法
1497
查看次数

在双向绑定中使用IValueConverter和当前的DataContext

我遇到了转换器的问题,我用它来转换字符串和我们的时间格式.转换器本身工作正常,并实现如下:

    [ValueConversion(typeof(string), typeof(SimpleTime))]
    public class StringToSimpleTimeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // convert from string to SimpleTime and return it
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // convert value from SimpleTime to string and return it
        }
    }
Run Code Online (Sandbox Code Playgroud)

使用转换器的XAML在usercontrol.resources中包含转换器本身,如下所示:

<converter:StringToSimpleTimeConverter x:Key="stringToSimpleTimeConverter"/>
Run Code Online (Sandbox Code Playgroud)

如果遇到属性(我在后台使用wpf工具包中的datagrid),则使用用于编辑simpletime的datatemplate:

<DataTemplate x:Key="SimpleTimeEditingTemplate">
        <TextBox Text="{Binding, Converter={StaticResource stringToSimpleTimeConverter}, Mode=TwoWay}"/>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是转换器需要在绑定中指定路径,如果它是双向转换器(我需要在两个方向),但我想要设置的属性已经是当前的DataContext - 什么路径那我可以指定吗?

我能想到的唯一解决方法是在SimpleTime中引入一个虚拟属性,它只获取当前的SimpleTime或设置它.

public class SimpleTime
{
    ...
    public SimpleTime Clone
    {
        get { …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf datacontext converter ivalueconverter

6
推荐指数
1
解决办法
6851
查看次数

等到文件编辑结束

我有下一个任务.有必要等待结束编辑Microsoft Office文件.我使用下一个传统方法:文件正在编辑文件繁忙时:

function FileIsBusy(AFileName: string): Boolean;
var
  F: Integer;
begin
  F := FileOpen(AFileName, fmShareExclusive);
  Result := F = -1;
  FileClose(F);
end;

function WaitFile(AFileName: string; ASpeepDelay: integer): Boolean;
begin
  while FileIsBusy(AFileName) do
    Sleep(ASpeepDelay);
  Result := True;
end;
Run Code Online (Sandbox Code Playgroud)

这种方法很适合使用Microsoft Word编辑文件,而不是Open Office.OpenOffice像MS Office一样使用一个进程来打开多重文件.但是OpenOffice Writer有一些问题:函数FileIsBusy在OpenOffice Writer 首次保存文件后返回false .有什么建议吗?

============================

我找到下一个解决方案

  repeat
    WaitFile(FFileInfo.lpFile, 333);
    Sleep(1000);
  until not FileIsBusy(FFileInfo.lpFile);
Run Code Online (Sandbox Code Playgroud)

保存后,ОО发布文件一段时间并再次独占分享

delphi openoffice.org shellexecuteex

3
推荐指数
1
解决办法
1370
查看次数

在c中选择调用后是否更改了超时?

在我的socket编程分配中,我做了一个这样的select调用:

select(s+1, &rfds, (fd_set *)0, (fd_set *)0,&tv)
Run Code Online (Sandbox Code Playgroud)

电视的类型 struct timeval

我阅读手册页面选择,它说:

在Linux上,函数select修改超时以反映未睡眠的时间; 大多数其他实现不会这样做.这会导致读取超时的Linux代码移植到其他操作系统,以及将代码移植到Linux时,在循环中重复使用struct timeval进行多次选择而不重新初始化它时会出现问题.在select返回后考虑超时未定义.

这是否意味着我的电视变量将在调用选择后更改?(我正在使用Ubuntu)

c sockets linux select

0
推荐指数
2
解决办法
4602
查看次数