syntax

Is there a correct order that attributes should be listed in when linking external files?

霸气de小男生 提交于 2020-01-11 05:39:25
问题 When declaring external files in HTML such as .css or .js, is there a correct order in which to place the link's attributes? For example: <link rel="stylesheet" type="text/css" href="../_css/style.css"> or <link type="text/css" rel="stylesheet" href="../_css/style.css"> or <link href="../_css/style.css" type="text/css" rel="stylesheet"> Does this matter? Same question goes for attributes for linking to external JavaScript files. Thanks for your time. 回答1: No, attribute order is irrelevant.

What does the following colon (:) mean in MATLAB syntax?

本秂侑毒 提交于 2020-01-11 05:19:05
问题 a = imread('autumn.tif'); a = double(a); [row col dim] = size(a); red = a(:, :, 1); green = a(:, :, 2); blue = a(:, :, 3); What does the colon : in the last three lines mean? (The above snippet is from "Image Processing" by Dhananjay Theckedath.) 回答1: : , in this context means 'all'. red = a(:,:,1) is equivalent to red = a(1:end,1:end,1) where end is automatically replaced by the number of elements in the respective dimension by Matlab. So if a is a 23-by-55-by-3 array, a(:,:,1) is a(1:23, 1

Scala dot syntax (or lack thereof)

青春壹個敷衍的年華 提交于 2020-01-11 04:42:11
问题 I was going through the wonderful book Programming in Scala when I came across a piece of code that just doesn't make sense to me: def above(that: Element): Element = { val this1 = this widen that.width val that1 = that widen this.width elem(this1.contents ++ that1.contents) } Note line 2 and 3: val this1 = this widen that.width It seems like I should be able to replace this with: val this1 = this.widen that.width However, when I try to compile this change, it gives the following error: error

Function to return a Haskell record with a modified field

不羁的心 提交于 2020-01-11 04:31:20
问题 Given : data MyRecord a = MyRecord{list :: [a], other_fields :: Char, …} I am trying to write a function which puts a new a on list and returns a new MyRecord : pushOntoList :: a -> MyRecord -> MyRecord Question : Is there a way to write pushOntoList is such a way that it does not depend on what is in the rest of the record, but simply gives it back unmodified? Another way to ask this is can you write pushOntoList without seeing the rest of the MyRecord definition? 回答1: Yes, very easily using

Is it possible to enumerate all methods and properties that are available via Invoke() of an [ADSI] object?

萝らか妹 提交于 2020-01-11 01:41:40
问题 I am curious if someone can describe how to enumerate ADSI methods available via a bound instance as [ADSI]$instance.psbase.Invoke() ? Research has turned up "refer to the docs for the ADSI interface". but I am not particularly happy with that answer. If I instantiate with: [ADSI]$lhost_group="WinNT://./Administrators,group" Then attempt: @($lhost_group.psbase.Invoke("Members")) | foreach-object {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)} Powershell will return the

How to check in Python if string is in a text file and print the line?

折月煮酒 提交于 2020-01-10 19:45:25
问题 What I am trying to do is to check whether this string is found in the text file. If it does, I want it to printout that line, else printout a message. I have implemented this code so far: def check_string(string): w = raw_input("Input the English word: ") if w in open('example.txt').read(): for w.readlines(): print line else: print('The translation cannot be found!') I've tried implementing that but I got a syntax error. It says: invalid syntax at the line -- for w.readlines(): Any idea on

What does the & symbol mean in Objective-C?

醉酒当歌 提交于 2020-01-10 18:44:07
问题 What does the & symbol mean in Objective-C? I am currently looking at data constucts and am getting really confused by it. I have looked around the web for it but have not found an answer at all. I know this is possibly a basic Objective-C concept, but I just can't get my head around it. For example: int *pIntData = (int *)&incomingPacket[0]; What is the code doing with incoming packet here? 回答1: & is the C address-of unary operator. It returns the memory address of its operand. In your

What is the meaning of “??” in swift? [duplicate]

烈酒焚心 提交于 2020-01-10 14:45:19
问题 This question already has answers here : ?? operator in Swift (5 answers) Closed 2 years ago . I came across a syntax in Swift where double question marks are used ("??"). For instance, let val = something["something"] as? String ?? nil What exactly does this mean? What are some use cases for this syntax? 回答1: Nil-Coalescing Operator It's kind of a short form of this. (Means you can assign default value nil or any other value if something["something"] is nil or optional) let val = (something[

Trouble with dependent types in templates

假如想象 提交于 2020-01-10 09:34:30
问题 I'm having trouble with templates and dependent types: namespace Utils { void PrintLine(const string& line, int tabLevel = 0); string getTabs(int tabLevel); template<class result_t, class Predicate> set<result_t> findAll_if(typename set<result_t>::iterator begin, set<result_t>::iterator end, Predicate pred) // warning C4346 { set<result_t> result; return findAll_if_rec(begin, end, pred, result); } } namespace detail { template<class result_t, class Predicate> set<result_t> findAll_if_rec(set

jq special characters in nested keys

随声附和 提交于 2020-01-10 06:07:30
问题 I have a json similar to the following: { "_source" : { "index-pattern" : { "fields" : "" } } } I'm trying to modify fields, but chaining the . identity operator, such as 'jq ._source.["index-pattern"].fields ' produces the following error: '._source.["index-pattern"] ^ 1 compile error' Any ideas? thanks 回答1: You could write: ._source | .["index-pattern"].fields Explanation: if "x" and "y" are alphanumeric strings that begin with an alphabetic character (where "alphabetic" includes "_") then