default

Default using directives in new C# files

僤鯓⒐⒋嵵緔 提交于 2019-11-27 05:49:04
问题 Why does Visual Studio 2008 automatically insert the following using directives into each new C# file I create? using System; using System.Collections.Generic; using System.Text; What's so special about these namespaces? Are these the most frequently used ones? 回答1: Yes, they're frequently used, that's all, so MS put them in the Visual Studio templates. Personally I use "sort and remove unused usings" pretty frequently, so they often go away. If you want to remove them, you can amend the "new

Setting default value for Foreign Key attribute

╄→尐↘猪︶ㄣ 提交于 2019-11-27 05:38:34
问题 What is the best way to set a default value for a foreign key field in a model? Suppose I have two models, Student and Exam with student having exam_taken as foreign key. How would I ideally set a default value for it? Here's a log of my effort class Student(models.Model): .... ..... exam_taken = models.ForeignKey("Exam", default=1) Works, but have a hunch there's a better way. def get_exam(): return Exam.objects.get(id=1) class Student(models.Model): .... ..... exam_taken = models.ForeignKey

Linux: command to open URL in default browser

浪尽此生 提交于 2019-11-27 05:12:01
问题 What command we have to execute (from Java, but that should not matter) on Linux (different common distributions) to open a given URL in the default browser? 回答1: The most cross-distribution one is xdg-open http://stackoverflow.com 回答2: I believe the simplest method would be to use Python: python -m webbrowser "http://www.example.com/" 回答3: on ubuntu you can try gnome-open. $ gnome-open http://www.google.com 回答4: In Java (version 6+), you can also do: Desktop d = Desktop.getDesktop(); d

Reset par to the default values at startup

橙三吉。 提交于 2019-11-27 05:05:32
问题 Normally when I make my own plot functions, I make a construct : op <- par("mypar"=myvalue) on.exit(par(op)) which is the standard way of reverting the par to the previous values. Imagine you've been running some functions that did change some of the pars, and you need to reset to the default values at startup in R. What is the convenient way of doing so? Or in other words : how does one reaches the default values for par() ? 回答1: Every time a new device is opened par() will reset, so another

Return a default value if no rows found

↘锁芯ラ 提交于 2019-11-27 05:01:18
I have the following select statement, to grab the next scheduled item for a stream. If there is no matching row, I want it to return a default value. Here's the line I'm using: SELECT `file` FROM `show`, `schedule` WHERE `channel` = 1 AND `start_time` <= UNIX_TIMESTAMP() AND `start_time` > UNIX_TIMESTAMP()-1800 AND `show`.`id` = `schedule`.`file` ORDER BY `start_time` DESC LIMIT 1 That should grab the most recently scheduled item, but not if it's older than 30 minutes before the query. However, if the user doesn't schedule anything, I want a default value, so that something actually plays on

TimeZone.setDefault changes in JDK6

纵饮孤独 提交于 2019-11-27 04:33:21
问题 I just noticed that JDK 6 has a different approach to setting a default TimeZone than JDK5. Previously the new default would be stored in a thread-local variable. With JDK6 (I just reviewed 1.6.0.18) the implementation has changed, so that if the user can write to the "user.timezone" property, or if there is no SecurityManager installed, the timezone changes VM-wide! Otherwise a thread-local change occurs. Am I wrong? This seems to be quite a drastic change, and I couldn't find anything on

Change stringsAsFactors settings for data.frame

僤鯓⒐⒋嵵緔 提交于 2019-11-27 04:24:27
问题 I have a function in which I define a data.frame that I use loops to fill with data. At some point I get the Warning message: Warning messages: 1: In [<-.factor ( *tmp* , iseq, value = "CHANGE") : invalid factor level, NAs generated Therefore, when I define my data.frame, I'd like to set the option stringsAsFactors to FALSE but I don't understand how to do it. I have tried: DataFrame = data.frame(stringsAsFactors=FALSE) and also: options(stringsAsFactors=FALSE) What is the correct way to set

PHP Default Function Parameter values, how to 'pass default value' for 'not last' parameters?

谁说胖子不能爱 提交于 2019-11-27 03:53:22
Most of us know the following syntax: function funcName($param='value'){ echo $param; } funcName(); Result: "value" We were wondering how to pass default values for the 'not last' paramater? I know this terminology is way off, but a simple example would be: function funcName($param1='value1',$param2='value2'){ echo $param1."\n"; echo $param2."\n"; } How do we accomplsh the following: funcName(---default value of param1---,'non default'); Result: value1 not default Hope this makes sense, we want to basically assume default values for the paramaters which are not last. Thanks. PHP doesn't

How can I remove a default gem? ! want to uninstall a gem 1.7.7 version of json

坚强是说给别人听的谎言 提交于 2019-11-27 03:52:01
问题 I have the same rails app in OSX and Ubuntu, I want to use Zeus to speed up my rspec. In Ubuntu, Zeus starts Ok, but in OSX it always be crashed. At last I find the issue, https://github.com/burke/zeus/issues/237#issuecomment-18700462 the difference between OSX and Ubuntu is the version of json gem. I use gem list | grep json Ubuntu shows json (1.8.1, 1.8.0, 1.5.3) json_pure (1.5.3) json_spec (1.1.1) jsonpath (0.5.3) multi_json (1.8.2, 1.7.8, 1.0.3) Mac shows json (1.8.1, 1.7.7) json_spec (1

Why does the Scala compiler disallow overloaded methods with default arguments?

℡╲_俬逩灬. 提交于 2019-11-27 03:04:45
While there might be valid cases where such method overloadings could become ambiguous, why does the compiler disallow code which is neither ambiguous at compile time nor at run time? Example: // This fails: def foo(a: String)(b: Int = 42) = a + b def foo(a: Int) (b: Int = 42) = a + b // This fails, too. Even if there is no position in the argument list, // where the types are the same. def foo(a: Int) (b: Int = 42) = a + b def foo(a: String)(b: String = "Foo") = a + b // This is OK: def foo(a: String)(b: Int) = a + b def foo(a: Int) (b: Int = 42) = a + b // Even this is OK. def foo(a: Int)(b: