我编写了一个powershell脚本,它是一个完整的函数接受参数(例如函数名称(参数){}),下面是一个函数调用,带有参数.
我希望能够在其.ps1文件中调用此函数,并传入参数.如何通过.bat或.cmd文件打包到函数的调用?我正在使用Powershell v2.0.
谢谢
在我的应用程序中,用户写了一个电话号码,我想找到该电话号码的联系人姓名?
我经常搜索这样的联系人:
Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
Run Code Online (Sandbox Code Playgroud)
但我这样做是为了访问所有联系人...在这个应用程序中,我只想获取给定电话号码的联系人姓名...如何限制查询?
或者我是否必须通过所有联系人,看看是否有给定的电话号码?但我相信这可能会很慢......
当解释器是C并且使用C编译器构建时,Python如何能够调用C++对象?
我正在初始化我的NSDateFormatter:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
[dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss z"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
NSDate *date = [NSDate date];
NSString *dateString = [dateFormatter stringFromDate:date];
Run Code Online (Sandbox Code Playgroud)
dateString 就是现在:
Thu, 29 Jul 2010 14:58:42 GMT+00:00
Run Code Online (Sandbox Code Playgroud)
我想摆脱"+00:00"
我猜测来自http://unicode.org/reports/tr35/tr35-6.html#Time_Zone_Fallback我可能有本地化问题.我现在通过手动删除"+00:00"来解决这个问题,但这并不理想.
编辑
我尝试了几种新方法来创建NSTimeZone,但它们都生成相同的dateString:
[NSTimeZone timeZoneWithName:@"GMT"];
[NSTimeZone timeZoneWithName:@"UTC"];
[NSTimeZone timeZoneWithAbbreviation:@"GMT"];
[NSTimeZone timeZoneWithAbbreviation:@"UTC"];
Run Code Online (Sandbox Code Playgroud) 我试图理解我在发送UDP数据包的上下文中看到的一些行为.
我有两个小Java程序:一个传输UDP数据包,另一个接收它们.我在两台通过单个交换机连接的计算机之间的网络上运行它们.
两个网络适配器上的MTU设置(由/ sbin/ifconfig报告)为1500.
我能够看到ping -s的类似行为.
ping -s 24258 hostA 工作,但
ping -s 24259 hostA 失败.
有没有人理解可能发生的事情,或者对我应该寻找什么有所了解?
两台计算机都运行CentOS 5 64位.我使用的是1.6 JDK,但我并不认为这是一个编程问题,它是一个网络或操作系统问题.
什么是SQL子句的linq等价物WHERE UserName LIKE 'fr_d'?
我正在使用内存中的数据集而不是SQL数据库,因此我认为我不能使用类似的东西 where SqlMethods.Like(p.UserName, "Fr_d")
(并不是说我安装的VS2008承认目前存在SqlMethods甚至System.Data.Linq.SqlClient,但那是一个完全不同的问题!)
我有一个iPad应用程序,以下代码绑定到按钮的(bMyDocuments)TouchDown事件处理程序:
UIPopoverController uipoc = new UIPopoverController(new Pop2());
uipoc.PopoverContentSize = new SizeF(200f, 300f);
uipoc.PresentFromRect (bMyDocuments.Frame, v, UIPopoverArrowDirection.Up, true);
Run Code Online (Sandbox Code Playgroud)
Pop2是一个空白的UIViewController,具有默认视图(白色背景,没有ui元素).
此代码从按钮生成弹出窗口,大小正确.然而,应用程序挂起没有任何错误,并且当在其外部单击时,弹出窗口不会消失.
如何正确初始化UIPopoverController?示例代码?
谢谢,
POM
我正在整理一个具有排行榜概念的小应用程序.基本上,模型只是一个player_name和一个current_score.
我想要做的是获得特定玩家的排名,并且考虑到新的分数一直在进行,它需要是动态的.显然,我可以使用order by子句进行正常查找,然后我必须循环遍历每条记录.当我有100,000行时,效率不高.
我应该采取什么方法的任何建议?
以下是表的迁移:
class CreateScores < ActiveRecord::Migration
def self.up
create_table :scores do |t|
t.string :player_name
t.integer :current_score
t.timestamps
end
end
def self.down
drop_table :scores
end
end
Run Code Online (Sandbox Code Playgroud)
编辑作为一个例子,所以我有以下内容:
Score.select('player_name, current_score').limit(20)
=> [#<Score player_name: "Keith Hughes", current_score: 9>, #<Score player_name: "Diane Chapman", current_score: 8>, #<Score player_name: "Helen Dixon", current_score: 4>, #<Score player_name: "Donald Lynch", current_score: 9>, #<Score player_name: "Shawn Snyder", current_score: 2>, #<Score player_name: "Nancy Palmer", current_score: 9>, #<Score player_name: "Janet Arnold", current_score: 1>, #<Score player_name: "Sharon Torres", current_score: 9>, …Run Code Online (Sandbox Code Playgroud) 我正在编写一个查询,我想计算我们的呼叫中心按日期联系的次数.看起来很简单,但由于联系日期字段是日期时间字段,我得到时间,所以当我按联系日期(时间)分组时,每个联系日期实例的计数都为'1'.所以,我想在没有时间的情况下按日期分组.下面是我用来查询数据库的表达式:
MyDataContext db = new MyDataContext();
var items = (from h in db.ContactHistories
group h by h.contact_dt into g
orderby g.Key
select new
{
contact_dt = g.Key,
item_count = g.Count()
}).Take(50);
Run Code Online (Sandbox Code Playgroud)
我试过用
h.contact_dt.ToShortDateString()
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为SQL确实知道ToShortDateString().任何想法都非常感谢.
谢谢!
编辑:
.Take(50)用于限制我获得的记录数量,直到我添加日期选择器和where子句,因此我没有获得所有400K记录.;)
我有代码,当给出一个东西时,它需要理清它是什么特定的东西,然后采取基于此的特殊行动.可能的类别都是desc
public void doSomething(BaseThing genericThing)
{
if (genericThing instanceof SpecificThing)
{
SpecificThingProcessor stp = new SpecificThingProcessor((SpecificThing) genericThing);
}
else if (genericThing instanceof DifferentThing)
{
DifferentThingProcessor dtp = new DifferentThingProcessor((DifferentThing) genericThing);
}
else if (genericThing instanceof AnotherThing){
AnotherThingProcessor atp = new AnotherThingProcessor((AnotherThing) genericThing);
}
else
{
throw new IllegalArgumentException("Can't handle thing!");
}
}
Run Code Online (Sandbox Code Playgroud)
有没有一种模式或更好的方法来处理这个?不幸的是,正在执行的操作不适合围绕BaseThing进行泛化,它们必须针对每个特定类别的事物进行.
c# ×2
activerecord ×1
android ×1
boost-python ×1
c++ ×1
datetime ×1
ipad ×1
java ×1
linq ×1
linq-to-sql ×1
linux ×1
networking ×1
nstimezone ×1
objective-c ×1
powershell ×1
python ×1
timezone ×1
udp ×1
xamarin.ios ×1