我使用了很多scala贴图,偶尔我想将它们作为映射传递给想要java.util.Map的遗留java api(我不在乎它是否抛弃任何更改).
我目前正在进行自动用户语言检测,以用户的语言提供内容.
当然可以手动更改语言,但如果用户第一次访问该页面,我想以他的语言提供内容.
所以我在Google上搜索并找到了$ _SERVER ['HTTP_ACCEPT_LANGUAGE'] - Var来得到这样的结果:
DE-DE,DE; Q = 0.8,EN-US; Q = 0.5,连接; Q = 0.3
什么是过滤此结果以获得"EN"/"DE"/"IT"等清晰结果的最佳方法?
$rL = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; // de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
$langCode = strtoupper($rl[0].$rl[1]);
Run Code Online (Sandbox Code Playgroud)
这个Server-Var的第二个问题是,如果浏览器提供了一些信息,它只会给我一个结果.设置默认页面语言是唯一可以处理的语言吗?
我感兴趣的第二种可能性是通过IP获取语言.所以,如果我得到语言,我可能知道用户的语言.但是在瑞士,比利时这样的多语言国家有什么?什么是.com/.net/.org等等.
那么您将应用哪种方法来检测用户语言?
谢谢你的帮助.
我为Scala列表编写了一个置换生成器,它生成给定列表的所有排列.到目前为止,基于这个Haskell实现,我得到了以下内容(我认为它比我尝试过的其他几个选项更有效).有没有办法让这个更有效率,或者我覆盖了所有的基础?
/** For each element x in List xss, returns (x, xss - x) */
def selections[A](xss:List[A]):List[(A,List[A])] = xss match {
case Nil => Nil
case x :: xs =>
(x, xs) :: (for( (y, ys) <- selections (xs) )
yield (y, x :: ys))
}
/** Returns a list containing all permutations of the input list */
def permute[A](xs:List[A]):List[List[A]] = xs match {
case Nil => List(Nil)
//special case lists of length 1 and 2 for better …Run Code Online (Sandbox Code Playgroud)
这段代码片段让我抓狂,有人可以帮我解释一下吗?
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
Run Code Online (Sandbox Code Playgroud)
谢谢,
Chan Nguyen
现在的问题是相对简单的:我怎样才能建立4.x版系列的GCC(连同的binutils和朋友),关于相同的架构主机编译器的目标2.4 ABI?
主机系统将是x86或x86_64,唯一的要求是只要ABI匹配,构建的ELF文件就在旧内核上运行.(存在内核源/头)
为了将其链接,也需要兼容的libc.但是,我也可以动态链接它,因为我知道(g)libc版本.
任何指针都将非常感激.我对crosstool-ng有点熟悉,但这似乎不再支持2.4内核了(出于显而易见的原因).
我正在编写一个C++ Qt桌面应用程序.
是否有可能在没有创建托盘图标的情况下显示Skype = Qt中的通知?
我发现的所有通知参考都需要一个托盘图标,我不想创建它.
通知应显示应用程序何时打开以及何时最小化.
如何在Clojure中进行相互递归定义?
下面是Scala中的代码,用于查找使用递归定义的素数:
val odds: Stream[Int] = cons(3, odds map { _ + 2 })
val primes: Stream[Int] = cons(2, odds filter isPrime)
def primeDivisors(n: Int) =
primes takeWhile { _ <= Math.ceil(Math.sqrt(n))} filter { n % _ == 0 }
def isPrime(n: Int) = primeDivisors(n) isEmpty
primes take 10
Run Code Online (Sandbox Code Playgroud)
我把它翻译成Clojure:
(def odds (iterate #(+ % 2) 3))
(def primes (cons 2 (filter is-prime odds)))
(defn prime-divisors [n]
(filter #(zero? (mod n %))
(take-while #(<= % (Math/ceil (Math/sqrt n)))
primes)))
(defn …Run Code Online (Sandbox Code Playgroud) 我有一个案例课
case class ~[a,b](_1:a, _2:b)
Run Code Online (Sandbox Code Playgroud)
当我想做pattetn匹配
new ~("a", 25) match{
case "a" ~ 25 =>
}
Run Code Online (Sandbox Code Playgroud)
我可以使用这种方式,因为"a" ~ 25和~("a", 25)是等价的.但如果我想new ~("a", new ~("b", 25))通过{case "a" ~ "b" ~ 25 => }麻烦来匹配开始.我知道这些陈述并不等同.那么,如何 new ~("a", new ~("b", 25))呈现?按什么规则?
我的代码必须解析Vcard 2.1格式.我正在使用vpim(没有其他库)
当我跑步时Vpim::Vcard.decode(data)我得到错误:
undefined method `each' for #<String:0x0000000928e778>
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
NoMethodError (undefined method `each' for #<String:0x0000000928e778>):
vpim (0.695) lib/vpim/rfc2425.rb:82:in `unfold'
vpim (0.695) lib/vpim/rfc2425.rb:308:in `decode'
vpim (0.695) lib/vpim/vcard.rb:692:in `decode'
app/models/event.rb:71:in `block (2 levels) in parse_data'
Run Code Online (Sandbox Code Playgroud)
我gem install vcard尝试在RailsApp初始化之后运行并要求'vcard'directctry(在vpim gem之后config.gem不包括此文件).(config.gem 'vpim'包含在environment.rb中)通过这种方式我得到另一个错误:
;=D0=9D=D0=B0=D0=B4=D1=80=D0=B0=20=D0=B1=D0=B0=D0=BD=D0=BA=20=D0=BE=D0=BB=
(异常类是Vpim::InvalidEncodingError)
Vcard代码我尝试解析:
BEGIN:VCARD
VERSION:2.1
REV:20090710T151929Z
TEL;CELL:80954130722
X-CLASS:private
END:VCARD
Run Code Online (Sandbox Code Playgroud)
有趣的是,第二个错误是我在Rails模型中解码时.当我尝试直接从脚本/控制台解码时(在installinv vcard gem和direct包括'vcard'之后),我成功获得了Vcard对象.
堆栈跟踪:
Vpim::InvalidEncodingError (;=D0=9D=D0=B0=D0=B4=D1=80=D0=B0=20=D0=B1=D0=B0=D0=BD=D0=BA=20=D0=BE=D0=BB=):
vcard (0.1.1) lib/vcard/field.rb:106:in `decode0'
vcard (0.1.1) lib/vcard/field.rb:172:in `initialize'
vcard (0.1.1) lib/vcard/field.rb:183:in `new'
vcard (0.1.1) lib/vcard/field.rb:183:in `decode'
vcard (0.1.1) lib/vcard/rfc2425.rb:308:in …Run Code Online (Sandbox Code Playgroud) 我正在做大学项目。那样,他们想要一个真实的证明。为此,我计划传递TextBox字符串进行报告。
我用谷歌搜索在winform中传递参数。然后我逐步进行了此过程。我实现了。
步:
1:在Visual Studio 2010中,打开.rdlc文件,然后打开“报表数据”窗口(如果看不到此窗口,请转到“视图”菜单将其打开);
2:右键单击“参数”节点,并添加新的参数,即:将其命名为“ content”;
3:在您的.rdlc文件中,添加一个名为tbContent的文本框,并将其字段express设置为:
= Parameters!content.Value
4:转到包含您的reporterview控件的Form文件,然后添加以下代码:
Run Code Online (Sandbox Code Playgroud)this.reportViewer1.LocalReport.ReportEmbeddedResource=“ TestReport.Report1.rdlc”;ReportParameter rp = new ReportParameter(“ content”,this.textBox1.Text); this.reportViewer1.LocalReport.SetParameters(new ReportParameter [] {rp}); this.reportViewer1.RefreshReport();
5:然后可以将参数从表单上的文本框传递到.rdlc文件;
我添加了using Microsoft.Reporting.WinForms;程序集参考。
this.reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";
ReportParameter rp = new ReportParameter("content", this.textBox1.Text);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
this.reportViewer1.RefreshReport();
Run Code Online (Sandbox Code Playgroud)
但这引发了异常:
在
this.reportViewer1.LocalReport.SetParameters(new ReportParameter [] {rp}); 处未处理本地处理异常。线。
这是剪贴板中的完整错误:
Microsoft.Reporting.WinForms.LocalProcessingException was unhandled
Message=An error occurred during local report processing.
Source=Microsoft.ReportViewer.WinForms
StackTrace:
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
at Report.Form1.Form1_Load(Object sender, EventArgs e) in D:\Jagadeeswaran\Project\Report\Report\Form1.cs:line 38 …Run Code Online (Sandbox Code Playgroud) scala ×3
abi ×1
c ×1
c# ×1
c++ ×1
case-class ×1
clojure ×1
definition ×1
gcc ×1
linux ×1
linux-kernel ×1
list ×1
obfuscation ×1
optimization ×1
permutation ×1
php ×1
qt ×1
recursion ×1
ruby ×1
vcf-vcard ×1
windows ×1
winforms ×1