qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Use list comprehension which is faster and more readable and simpler: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] int_sum = sum([i for i in mylist if isinstance(i, int)]) str_join = ' '.join([i for i in mylist if isinstance(i, str)]) print(str_join) print(int_sum) ``` **Output:** ``` C:\Users\Documen...
You could do: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ints = [str(i).isnumeric() for i in mylist] ix_int = np.flatnonzero(ints) np.array(mylist)[ix_int].astype(int).sum() 68 ``` And for the strings: ``` ix_str = np.setdiff1d(np.arange(len(mylist)), indices) ''.join(np.array(mylist)[ix_str]) 'jacksn...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `sum` function is intended to sum all the elements in an array, which explains the error you're getting. Also, if you keep `output_str` being declared inside your `for` function, everytime if scans a new value from your list, `output_str` would reset. That's why I am now declaring it only once, before the `for` eve...
You can't do sum on single element, sum requires iterable input type. You can do that like this: Code: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] output_str = '' sum_of_int = 0 for x in mylist: if isinstance(x, str): output_str += x elif isinstance(x, int): sum_of_int += x pri...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `sum` function is intended to sum all the elements in an array, which explains the error you're getting. Also, if you keep `output_str` being declared inside your `for` function, everytime if scans a new value from your list, `output_str` would reset. That's why I am now declaring it only once, before the `for` eve...
You can also do it like this: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] output_str = '' sum = 0 for i in mylist: if type(i) == str: output_str += i elif type(i) == int: sum += i ``` Now `sum` will contain the sum of integers in your list, and `output_str` will contain the c...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Use list comprehension which is faster and more readable and simpler: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] int_sum = sum([i for i in mylist if isinstance(i, int)]) str_join = ' '.join([i for i in mylist if isinstance(i, str)]) print(str_join) print(int_sum) ``` **Output:** ``` C:\Users\Documen...
You can't do sum on single element, sum requires iterable input type. You can do that like this: Code: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] output_str = '' sum_of_int = 0 for x in mylist: if isinstance(x, str): output_str += x elif isinstance(x, int): sum_of_int += x pri...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `sum` function is intended to sum all the elements in an array, which explains the error you're getting. Also, if you keep `output_str` being declared inside your `for` function, everytime if scans a new value from your list, `output_str` would reset. That's why I am now declaring it only once, before the `for` eve...
Try this: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] total = 0 output_str = '' for x in mylist: if isinstance(x, str): output_str = output_str + x elif isinstance(x, int): total += x print(output_str) print(total) ```
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `sum` function is intended to sum all the elements in an array, which explains the error you're getting. Also, if you keep `output_str` being declared inside your `for` function, everytime if scans a new value from your list, `output_str` would reset. That's why I am now declaring it only once, before the `for` eve...
You could use [sum](https://docs.python.org/3/library/functions.html#sum) and [join](https://docs.python.org/3/library/stdtypes.html#str.join): ``` my_list = ['jack', 12, 'snake', 17, 'tumbleweed', 39] a, b = sum(e for e in my_list if isinstance(e, int)), ''.join(s for s in my_list if isinstance(s, str)) print(a, b) ...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `sum` function is intended to sum all the elements in an array, which explains the error you're getting. Also, if you keep `output_str` being declared inside your `for` function, everytime if scans a new value from your list, `output_str` would reset. That's why I am now declaring it only once, before the `for` eve...
The [sum()](https://docs.python.org/3/library/functions.html#sum) function expects an iterable. Try this: ``` from functools import reduce mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] n, s = reduce(lambda a, x: (a[0] + x, a[1]) if isinstance(x, int) else (a[0], a[1] + x), mylist, (0, '')) print('n = {}; s = {...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Use list comprehension which is faster and more readable and simpler: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] int_sum = sum([i for i in mylist if isinstance(i, int)]) str_join = ' '.join([i for i in mylist if isinstance(i, str)]) print(str_join) print(int_sum) ``` **Output:** ``` C:\Users\Documen...
You can also do it like this: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] output_str = '' sum = 0 for i in mylist: if type(i) == str: output_str += i elif type(i) == int: sum += i ``` Now `sum` will contain the sum of integers in your list, and `output_str` will contain the c...
5,190,588
What's the good point to use "import static"?
2011/03/04
[ "https://Stackoverflow.com/questions/5190588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/496949/" ]
In general you should use static imports **[very sparingly](http://download.oracle.com/javase/1.5.0/docs/guide/language/static-import.html)**. One of the few places that they make a lot of sense is in your unit tests: ``` import static junit.framework.Assert.*; ``` Static imports were added to Java to stop programm...
It allows you to remove the class name from function calls for static methods, as described with examples in the documentation here: <http://download.oracle.com/javase/1.5.0/docs/guide/language/static-import.html>
20,967,762
**select \* from Teams;** ``` | team_name | team_id | | India | 1 | | England | 2 | | Germany | 3 | | Japan | 4 | ``` **select \* from Matches;** ``` | match_id | match_date | hometeam | awayteam | homescore | awayscore | | 1 | 2014-06-24 | 1 | 2 | ...
2014/01/07
[ "https://Stackoverflow.com/questions/20967762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3168383/" ]
You have to join matches table with teams table like this: ``` SELECT th.team_name as team_home, m.homescore, ta.team_name as team_away, m.awayscore FROM matches m INNER JOIN teams th ON m.hometeam = th.team_id INNER JOIN teams ta ON m.awayteam = ta.team_id ``` Here is [SqlFiddle](http://sqlfiddle.com/#!2/7cb0a/2)
Another one, with entire match data in one select... ``` select m.*, home.team_name as hometeam_name, away.team_name as awayteam_name from matches m, teams home, teams away where home.team_id = m.hometeam and away.team_id = m.awayteam ; ``` see **[SQLFIDDLE](http://sqlfiddle.com/#!2/bf8cd3/1)**
2,606,167
Tehnologies: - CruiseControlNet - Asp.net MVC 2 RTM - enabled view compilation The problem is `UrlParameter.Optional` setting. I can't seem to make it work when I use this setting inside a view. When I compile inside Visual Studio, everything works fine, but when CCNet uses `MSBuild` to compile it it fails with follo...
2010/04/09
[ "https://Stackoverflow.com/questions/2606167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/75642/" ]
Sounds like it could be related to a jQuery repeat ajax call bug listed here: [jQuery Bug #8398](http://bugs.jquery.com/ticket/8398) It turns out that jQuery 1.5 is modifying subsequent ajax calls for json to jsonp which leads to this error. I fixed it by following one of the workarounds suggested in the bug change ...
I got this error when I wasn't specifying the success() function correctly. Try doing the following code where data is whatever information your passing back: ``` success : function(data,status,response){ ``` EDIT: My error was actually there because I was using a plug-in called validate.js. If you're using this pl...
4,158,011
Here's what I am trying to do: `time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync"` When run that on shell the o/p is ``` 125+0 records in 125+0 records out 64000 bytes (62.5KB) copied, 0.028935 seconds, 2.1MB/s real 0m 0.08s user 0m 0.00s sys 0m 0.01s ``` I want to capture the output to a variable or...
2010/11/11
[ "https://Stackoverflow.com/questions/4158011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/494074/" ]
Bash uses `>` for standard output redirection. An example would be: ``` ./test.sh > outfile.txt ``` If you're interested in appending to rather than replacing outfile.txt, use `>>` instead of `>`. Both redirect standard output. However, the output of the `time` command in this case will be to standard error, so yo...
time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync" > ./yourfile > is the redirect command
4,158,011
Here's what I am trying to do: `time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync"` When run that on shell the o/p is ``` 125+0 records in 125+0 records out 64000 bytes (62.5KB) copied, 0.028935 seconds, 2.1MB/s real 0m 0.08s user 0m 0.00s sys 0m 0.01s ``` I want to capture the output to a variable or...
2010/11/11
[ "https://Stackoverflow.com/questions/4158011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/494074/" ]
You can do: ``` (time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync") 2> file ``` Since you need to redirect the output of both `time` and `dd` you need to enclose the entire thing in `(..)`. Both `time` and `dd` send their output to stderr, so using `>` will not work, you need `2>` which redirects stde...
time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync" > ./yourfile > is the redirect command
4,158,011
Here's what I am trying to do: `time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync"` When run that on shell the o/p is ``` 125+0 records in 125+0 records out 64000 bytes (62.5KB) copied, 0.028935 seconds, 2.1MB/s real 0m 0.08s user 0m 0.00s sys 0m 0.01s ``` I want to capture the output to a variable or...
2010/11/11
[ "https://Stackoverflow.com/questions/4158011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/494074/" ]
You can do: ``` (time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync") 2> file ``` Since you need to redirect the output of both `time` and `dd` you need to enclose the entire thing in `(..)`. Both `time` and `dd` send their output to stderr, so using `>` will not work, you need `2>` which redirects stde...
Bash uses `>` for standard output redirection. An example would be: ``` ./test.sh > outfile.txt ``` If you're interested in appending to rather than replacing outfile.txt, use `>>` instead of `>`. Both redirect standard output. However, the output of the `time` command in this case will be to standard error, so yo...
5,921,017
Can I set default file types association for HTML file input? E.g. just .jpg,.bmp/.png with the HTML input control? When browse is clicked the dialog should show just show all those associated filetypes not allfiles that usually occurs.
2011/05/07
[ "https://Stackoverflow.com/questions/5921017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/648372/" ]
I think the [TicketQuery Macro](http://trac.edgewall.org/wiki/TracQuery#UsingtheTicketQueryMacro) does what you want. For example add the following to the wiki page to get all open tickets sorted by ticket#: ``` [[TicketQuery(status=new|assigned|reopened|accepted&order=id)]] ```
I think you'd want to look into writing a [trac plugin](http://trac.edgewall.org/wiki/TracDev/PluginDevelopment). There's an example on [Trac Hacks](http://trac-hacks.org/) that seems like it might be a good starting point for what you're looking to do: [Watchlist Plugin](http://trac-hacks.org/wiki/WatchlistPlugin)
21,841,975
Is there a way to list only those methods of a Reference Class, that were **explicitly** defined in the class definition (as opposed to those methods inherited by "system classes" such as `refObjectGenerator` or `envRefClass`)? ``` Example <- setRefClass( Class="Example", fields=list( ), methods=list( ...
2014/02/18
[ "https://Stackoverflow.com/questions/21841975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/989691/" ]
**1)** Try this: ``` > Dummy <- setRefClass(Class = "dummy") > setdiff(Example$methods(), Dummy$methods()) [1] "testMethodA" "testMethodB" ``` **2)** Here is a second approach which seems to work here but you might want to test it out more: ``` names(Filter(function(x) attr(x, "refClassName") == Example$className, ...
No, because the methods in a reference class "inherited" from the parent are actually copied into the class when it is generated. ``` setRefClass("Example", methods = list( a = function() {}, b = function() {} )) class <- getClass("Example") ls(class@refMethods) #> [1] "a" "b" "callSuper" ...
32,909,125
If I pass function to a function with same function name and handler name, which one will get precedence ? and how to access each of those two inside function in case in need to do recursion as well as refer to the passed function. See below code. ``` var f1,f2; (function f(f){ return typeof f(f2); /*please check...
2015/10/02
[ "https://Stackoverflow.com/questions/32909125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5260883/" ]
The function parameter gets precedence over the function's own name. If you shadow or overwrite a variable, you can't access it (unless it's a shadowed global). Solution is to use different names.
The recursion doesn't happen simply because the argument of the function get precendence than the function itself. here is an example that shows it: ``` (function f (f) { return f.name; }) (function funcName () { }); // this will return funcName ``` if we change the name of the argument to f1, f will become the r...
32,909,125
If I pass function to a function with same function name and handler name, which one will get precedence ? and how to access each of those two inside function in case in need to do recursion as well as refer to the passed function. See below code. ``` var f1,f2; (function f(f){ return typeof f(f2); /*please check...
2015/10/02
[ "https://Stackoverflow.com/questions/32909125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5260883/" ]
The function parameter gets precedence over the function's own name. If you shadow or overwrite a variable, you can't access it (unless it's a shadowed global). Solution is to use different names.
I see that you use jquery. So I want to ask where do you have declared your functions? inside ``` <script type="text/javascript"> $(document).ready(function(){ function f(){ return 'this is local function inside anonymous function, so it's invisible for recursion in aside of current docum...
7,317,205
I'd like to get all groups "Security Groups" available in the Active Diectory. Any idea ? Thanks,
2011/09/06
[ "https://Stackoverflow.com/questions/7317205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
Since you're on .NET 3.5 or higher, you can use a `PrincipalSearcher` and a "query-by-example" principal to do your searching: ``` // create your domain context PrincipalContext ctx = new PrincipalContext(ContextType.Domain); // define a "query-by-example" principal - here, we search for a GroupPrincipal // with the...
Try this way ``` DirectoryEntry ent1 = new DirectoryEntry("LDAP://" + _path, "adminUser", "***********"); DirectorySearcher dSearch = new DirectorySearcher(ent1); dSearch.Filter = "(&(objectClass=group))"; dSearch.SearchScope = SearchScope.Subtree; ...
6,674,311
I caught "Temporary failure in name resolution" while run Hadoop/bin/start-all.sh on my SUSE Linux.I have searched many website to look for the problem,but can not find the effective answer. I look forward your help,thank you!! It is deployed on single same maching,so in both master/slaves files only one line:localhos...
2011/07/13
[ "https://Stackoverflow.com/questions/6674311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502186/" ]
``` $ vi -b conf/slaves ``` Maybe you can know what happened!
I had the same problem and I've resolved it adding to `/etc/hosts` file the next line: `192.168.56.101 localhost hadoop` where you must change the ip and change hadoop and put your own hostname.
57,864,587
I am using Intent flow UPI integration in app, everything works fine for googlepay and paytm, but on using phonepe ,(after successfull payment) when control returns to my app after in onActivityResult method Intent data is null(not in case of googlepay and paytm), and i am not getting response,and all details in it. an...
2019/09/10
[ "https://Stackoverflow.com/questions/57864587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9987728/" ]
Finally, I got the solution for this. Everything is fine in code but for `phonepe .appendQueryParameter("tr", "261433")` this one is mandatory.
Kindly check the URI that you're sending as the intent. Also, it would be nice to see the code snippet in order to understand the problem fully.
11,625
Formally, as head of the [RHSA](https://en.wikipedia.org/wiki/SS-Reichssicherheitshauptamt), [Reinhard Heydrich](https://en.wikipedia.org/wiki/Reinhard_Heydrich) was Himmler's subordinate. But did he actually take orders from [Himmler](http://en.wikipedia.org/wiki/Heinrich_Himmler), or was he effectively independent?
2014/02/10
[ "https://history.stackexchange.com/questions/11625", "https://history.stackexchange.com", "https://history.stackexchange.com/users/1569/" ]
The current Wikipedia entry for the Yue-chi depicts them as being mostly [friendly trading partners](http://en.wikipedia.org/wiki/Yuezhi#Origins) with the Chinese. The (likely Turkish) Xiongnu empire built by the victorious [Modu Chanyu](http://en.wikipedia.org/wiki/Modu_Chanyu) (aka: Mete Khan, or "Brave Khan" in Turk...
Mete Khan (HAN) was the only Turkic ruler of China . He beat China and its colossal army with 300.000 with 40.000 soldiers. What people don't realize is that the Turks history goes back 6 to 7000 years. Turks religion was Tnengrism and shamanism which is oldest religion of the world. The Chinese built the Great China W...
653,122
Does each LAN need to have its own separate DNS server? I am just trying to work this out to answer a practice exam, but I can't find the answer or a solution to it anywhere. Yes I may not have exhausted all my possible avenues, but I can't find the answer I'm looking for.
2013/10/02
[ "https://superuser.com/questions/653122", "https://superuser.com", "https://superuser.com/users/259072/" ]
A DNS server is accessed using IP and so can be placed anywhere in the world, and be accessed from anywhere else in the world (provided such access is permitted). Within a corporate environement, you would traditionally have a number of internal DNS servers to respond to internal queries, but it would be unusual to ha...
Short answer: no, but you need to make sure you don't overwhelm the poor server, and you need to consider and performance issues. --- Long answer: Depends what you mean by LAN. If you mean a network of computers where you might have multiple smaller networks inside (subnets, vlans, etc...) then, no. You would need t...
653,122
Does each LAN need to have its own separate DNS server? I am just trying to work this out to answer a practice exam, but I can't find the answer or a solution to it anywhere. Yes I may not have exhausted all my possible avenues, but I can't find the answer I'm looking for.
2013/10/02
[ "https://superuser.com/questions/653122", "https://superuser.com", "https://superuser.com/users/259072/" ]
A DNS server is accessed using IP and so can be placed anywhere in the world, and be accessed from anywhere else in the world (provided such access is permitted). Within a corporate environement, you would traditionally have a number of internal DNS servers to respond to internal queries, but it would be unusual to ha...
answer is no, if you more than on vlans or subnets and all are LANS then you can place that one DNS some how(like server VLAN) that all subnets or Lans reaches the DNS server (means DNS server IP should be ping from all Lan IP in different Subnets, you can configure reverse Zone for each Lan or subnet and add host ip i...
653,122
Does each LAN need to have its own separate DNS server? I am just trying to work this out to answer a practice exam, but I can't find the answer or a solution to it anywhere. Yes I may not have exhausted all my possible avenues, but I can't find the answer I'm looking for.
2013/10/02
[ "https://superuser.com/questions/653122", "https://superuser.com", "https://superuser.com/users/259072/" ]
Short answer: no, but you need to make sure you don't overwhelm the poor server, and you need to consider and performance issues. --- Long answer: Depends what you mean by LAN. If you mean a network of computers where you might have multiple smaller networks inside (subnets, vlans, etc...) then, no. You would need t...
answer is no, if you more than on vlans or subnets and all are LANS then you can place that one DNS some how(like server VLAN) that all subnets or Lans reaches the DNS server (means DNS server IP should be ping from all Lan IP in different Subnets, you can configure reverse Zone for each Lan or subnet and add host ip i...
5,922,295
Here's my problem: I wrote two base classes: Wire and CircuitComponent. The two were almost similar enough to derive from a common superclass, but not. Wire can only join with CircuitComponent, and CircuitComponent can only join with wire. The implementations were identical aside from type though, so naturally I though...
2011/05/07
[ "https://Stackoverflow.com/questions/5922295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/240655/" ]
The minimally-invasive way to make your code compile is indeed to use a typedef, and either [tag classes](http://www.boost.org/community/generic_programming.html#tag_dispatching), or simply Enumerations: ``` enum MeshType { MeshTypeWire, MeshTypeCircuitComponent }; template <MeshType thisType> class TwoTypeMesh { ...
move the join() outside the class: ``` void join(Wire &w, CircuitComponent &j); void join(CircuitComponent &j, Wire &w); ``` you might need to make the functions friend of the class to access private data members.
5,922,295
Here's my problem: I wrote two base classes: Wire and CircuitComponent. The two were almost similar enough to derive from a common superclass, but not. Wire can only join with CircuitComponent, and CircuitComponent can only join with wire. The implementations were identical aside from type though, so naturally I though...
2011/05/07
[ "https://Stackoverflow.com/questions/5922295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/240655/" ]
move the join() outside the class: ``` void join(Wire &w, CircuitComponent &j); void join(CircuitComponent &j, Wire &w); ``` you might need to make the functions friend of the class to access private data members.
To address your specific compilation error, you should be able to static\_cast `this` to `thisType*` in the call to `n->join`. You appear to have accidentally re-invented [CRTP](http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern): a template base class which takes the derived class as a template paramet...
5,922,295
Here's my problem: I wrote two base classes: Wire and CircuitComponent. The two were almost similar enough to derive from a common superclass, but not. Wire can only join with CircuitComponent, and CircuitComponent can only join with wire. The implementations were identical aside from type though, so naturally I though...
2011/05/07
[ "https://Stackoverflow.com/questions/5922295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/240655/" ]
The minimally-invasive way to make your code compile is indeed to use a typedef, and either [tag classes](http://www.boost.org/community/generic_programming.html#tag_dispatching), or simply Enumerations: ``` enum MeshType { MeshTypeWire, MeshTypeCircuitComponent }; template <MeshType thisType> class TwoTypeMesh { ...
To address your specific compilation error, you should be able to static\_cast `this` to `thisType*` in the call to `n->join`. You appear to have accidentally re-invented [CRTP](http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern): a template base class which takes the derived class as a template paramet...
57,666,707
I'm writing a chrome extension that basically transfer response to my local server. To run this code I just need to turn on the inspect window (so that I can get devtools work). It runs perfectly for several hours but I find eventually it closes the inspect window, without any error or whatever log generated. The mo...
2019/08/27
[ "https://Stackoverflow.com/questions/57666707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1377103/" ]
Look like you have many `div` with the same id `clinic_name`. It's not good because `id` should be unique, you can use `class` instead. If you want to change text of the `h2` inside the div, you can use this selector `div.clinic_name h2:first-child`(here I use `class` instead of `id`). Example: ``` jQuery("div.clini...
You need find child first you can use this ``` jQuery(this).find(':first-child').text(listings[index].name); //this = div.clinic_name ``` First child can be get any element inside or you use these... * `.find(':first-child')` if you need find first of inside * `.find(':last-child')` if you need find last of inside ...
79,459
In John 20:24‭-‬25 one reads > > But Thomas, one of the twelve, called Didymus, was not with them when Jesus came. The other disciples therefore said unto him, We have seen the Lord. But he said unto them, **Except I shall see in his hands the print of the nails, and put my finger into the print of the nails, and thr...
2022/10/23
[ "https://hermeneutics.stackexchange.com/questions/79459", "https://hermeneutics.stackexchange.com", "https://hermeneutics.stackexchange.com/users/23182/" ]
It is not 100% clear the either solution, but, despite the iconography, which shows Thomas touching the wounds, it is more likely, I think, that the seeing and the preliminary testimony of other disciples was enough for him to both believe in the resurrection and the divinity of Christ whom he addresses as “my Lord, my...
Human mind is complicated and quite common we do say something we don't mean it. Sometimes we will exaggerate a situation to emphasis our opinion, for example, if I said "I would rather die if I lost". Did I really kill myself when I'm losing? Surely not! Thomas did not believe the other eleven claimed they saw Jesus,...
574,065
So I have a Dell XS23 Rack with 8 CPUs and 40G Ram with vmware esxi in my production environment. The way I'd partitioned it before was 2 API servers (quad core, 8gig ram) 2 DB servers same specs, etc. The reasoning for this was to have load balancing as well as replication, fail over etc, but all running on one sing...
2014/02/07
[ "https://serverfault.com/questions/574065", "https://serverfault.com", "https://serverfault.com/users/83068/" ]
There's no point in virtualization unless you've a very specific reason to do so. The reason might be like, giving root access to the containers to various people and so on. If everything is under your control, and you don't need to give access to anybody else, I'd discourage any kind of virt since it just adds to mo...
I wouldn't bother virtualizing it, unless you have a good reason. It only adds more complexity to your stack and doesn't give much in the way of actual failover that Docker doesn't already provide.
574,065
So I have a Dell XS23 Rack with 8 CPUs and 40G Ram with vmware esxi in my production environment. The way I'd partitioned it before was 2 API servers (quad core, 8gig ram) 2 DB servers same specs, etc. The reasoning for this was to have load balancing as well as replication, fail over etc, but all running on one sing...
2014/02/07
[ "https://serverfault.com/questions/574065", "https://serverfault.com", "https://serverfault.com/users/83068/" ]
There's no point in virtualization unless you've a very specific reason to do so. The reason might be like, giving root access to the containers to various people and so on. If everything is under your control, and you don't need to give access to anybody else, I'd discourage any kind of virt since it just adds to mo...
From talking to a friend, I came to the conclusion that I do need some sort of redundancy in order to protect myself against OS failure. For example if my esxi box maps the ram/disk for one of the VMs on a bad partition on the host OS. So I'm thinking of setting up 2-n servers all running docker. Each of them would h...
85,485
Many rims seem to have this piece of plastic around one of the spokes. It seems to be a zip tie fastening the rim in place. But what is its exact purpose? If it is required to fasten the rim in place, why don’t all wheels have it? [![Suzuki wheel](https://i.stack.imgur.com/UNaat.jpg)](https://i.stack.imgur.com/UNaat....
2021/09/27
[ "https://mechanics.stackexchange.com/questions/85485", "https://mechanics.stackexchange.com", "https://mechanics.stackexchange.com/users/67826/" ]
The wheel trim that it is holding on is likely damaged, so a previous owner has added the cable/zip tie to stop it falling off. The damage may not be visible from the outside. There are plastic tabs on the inside that are pressed against the rim by a metal ring. One of the plastic tabs may have broken making it a bit l...
These cable ties are usually found on the cheaper plastic wheel trims as they can fly off. Some of the more expensive ones suffer from the springs and tabs getting bent when owners force them. Seen many on the side of the road - often in winter as the snow can help knock them off or build up behind them. The cable ti...
60,056,477
I have a `UICollectionview` that's embedded in a `UIView` (I know it raises questions as per why - long story short, it's the easiest way I can accomplish this UI). The problem is that I can't seem to figure out how to center the 2 columns with right in the middle with a little bit of padding from the left and right ...
2020/02/04
[ "https://Stackoverflow.com/questions/60056477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12478981/" ]
Here is the problem ``` CGSize(width: ((width / 2)), height: 150) ``` You also need to consider section inset's left, right and cell spacing of collection view. for ex: ``` CGSize(width: ((width - 10 - minimumInteritemSpacing) / 2), height: 150) ``` you can get `minimumInteritemSpacing` from `collectionView.coll...
You can use this: Try with `return CGSize(width: ((collectionView.frame.widht / 2)), height: 150)` and change `MinSpacing` to `0` [![enter image description here](https://i.stack.imgur.com/FyeAa.png)](https://i.stack.imgur.com/FyeAa.png) This will remove space between `collectionviewcell`. may be this will help yo...
60,056,477
I have a `UICollectionview` that's embedded in a `UIView` (I know it raises questions as per why - long story short, it's the easiest way I can accomplish this UI). The problem is that I can't seem to figure out how to center the 2 columns with right in the middle with a little bit of padding from the left and right ...
2020/02/04
[ "https://Stackoverflow.com/questions/60056477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12478981/" ]
Here is the problem ``` CGSize(width: ((width / 2)), height: 150) ``` You also need to consider section inset's left, right and cell spacing of collection view. for ex: ``` CGSize(width: ((width - 10 - minimumInteritemSpacing) / 2), height: 150) ``` you can get `minimumInteritemSpacing` from `collectionView.coll...
* Give padding from all sides of collection view as you required for design and then write this code in your view controller : ``` let numberOfCellsPerRow: CGFloat = 2 if let flowLayout = yourCollectionView?.collectionViewLayout as? UICollectionViewFlowLayout { flowLayout.itemSize = CGSize(width: 160, height: 160)...
60,056,477
I have a `UICollectionview` that's embedded in a `UIView` (I know it raises questions as per why - long story short, it's the easiest way I can accomplish this UI). The problem is that I can't seem to figure out how to center the 2 columns with right in the middle with a little bit of padding from the left and right ...
2020/02/04
[ "https://Stackoverflow.com/questions/60056477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12478981/" ]
You can use this: Try with `return CGSize(width: ((collectionView.frame.widht / 2)), height: 150)` and change `MinSpacing` to `0` [![enter image description here](https://i.stack.imgur.com/FyeAa.png)](https://i.stack.imgur.com/FyeAa.png) This will remove space between `collectionviewcell`. may be this will help yo...
* Give padding from all sides of collection view as you required for design and then write this code in your view controller : ``` let numberOfCellsPerRow: CGFloat = 2 if let flowLayout = yourCollectionView?.collectionViewLayout as? UICollectionViewFlowLayout { flowLayout.itemSize = CGSize(width: 160, height: 160)...
30,497,159
An array contains integers that first increase in value and then decrease in value. It is unknown at which point the numbers start to decrease. Write efficient code to copy the numbers in the first array to another array so that the second array is sorted in ascending order. The code is below: ``` int _tmain(int argc...
2015/05/28
[ "https://Stackoverflow.com/questions/30497159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/601200/" ]
A loop invariant is something that holds true before and after each iteration of your loop. This includes after the loop terminates and before it begins. There are quite a few of them, although most of them are not important. You will want to pick one that helps prove the algorithm is correct. A loop invariant for that...
The invariant is the condition in the while loop, so `i <= j`. > > an invariant of a loop is a property that holds before (and after) > each repetition > > > Source: [wiki](http://en.wikipedia.org/wiki/Loop_invariant)
35,045
Erwägen Sie die zwei Sätze: 1. Ich mag Hunde, darum **habe ich** auch einen. 2. Ich mag Hunde, aber **ich habe** keinen. Ich weiß, dass im Satz das Verb an der zweiten Stelle stehen muss. Aber, im zweiten Satz scheint das Verb an der dritten Stelle zu stehen. Darum sagt man, dass *aber* an der »nullten Stelle« des Sa...
2017/02/25
[ "https://german.stackexchange.com/questions/35045", "https://german.stackexchange.com", "https://german.stackexchange.com/users/24842/" ]
»*Darum*« ist ein Adverb, »*aber*« ist aber eine nebenordnende Konjunktion. Nebenordnende Konjunktionen gehören weder zum ersten, noch zum zweiten Satz, sondern stehen als Verbindungselement zwischen zwei gleichwertigen Sätzen. Die Formulierung »*die Konjunktion steht an Stelle 0 des zweiten Satzes*« ist daher eigentli...
Now I got it ;) The word 'darum' can't be in 0th place, because it wouldn't sound like proper German if it was. “darum ich habe auch einen“ would not sound good. Therefore, you could say the word 'darum' requires a verb to be directly following it (not in 0th place). The same applys to 'deshalb' oder auch 'deswegen'. ...
25,505,755
As of now I am passing parameter along with URL in ajax call of data table. But I want to pass it as `POST` method, please anyone one help me regarding parameter passing in post method, here's my trial code: ``` // Sending through GET var $table = $('#example').dataTable( "processing": true, "serverSide": t...
2014/08/26
[ "https://Stackoverflow.com/questions/25505755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3930179/" ]
Just pass it like a normal jQuery ajax in POST fashion. The structure should look like this: ``` ajax: { type: 'POST', url: <path>, data: { your desired data } } ``` Example: ``` var $table = $('#example').dataTable( "processing": true, "serverSide": true, "bDestroy": true, "bJQueryUI": true, ...
``` $("#tbl").dataTable({ oLanguage: { sProcessing: '<div id="loader"></div>' }, bProcessing: true, "bServerSide": true, "iDisplayLength": pageSize, "sAjaxSource": " /PurchaseOrder/AddVendorItems", // url getData.php etc ...
25,505,755
As of now I am passing parameter along with URL in ajax call of data table. But I want to pass it as `POST` method, please anyone one help me regarding parameter passing in post method, here's my trial code: ``` // Sending through GET var $table = $('#example').dataTable( "processing": true, "serverSide": t...
2014/08/26
[ "https://Stackoverflow.com/questions/25505755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3930179/" ]
Just pass it like a normal jQuery ajax in POST fashion. The structure should look like this: ``` ajax: { type: 'POST', url: <path>, data: { your desired data } } ``` Example: ``` var $table = $('#example').dataTable( "processing": true, "serverSide": true, "bDestroy": true, "bJQueryUI": true, ...
You can try this way: ``` $('#example').dataTable( { "ajax": { "url": "data.json", "data": function ( d ) { d.extra_search = $('#extra').val(); } } }); ``` <https://datatables.net/reference/option/ajax.data>
25,505,755
As of now I am passing parameter along with URL in ajax call of data table. But I want to pass it as `POST` method, please anyone one help me regarding parameter passing in post method, here's my trial code: ``` // Sending through GET var $table = $('#example').dataTable( "processing": true, "serverSide": t...
2014/08/26
[ "https://Stackoverflow.com/questions/25505755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3930179/" ]
You can try this way: ``` $('#example').dataTable( { "ajax": { "url": "data.json", "data": function ( d ) { d.extra_search = $('#extra').val(); } } }); ``` <https://datatables.net/reference/option/ajax.data>
``` $("#tbl").dataTable({ oLanguage: { sProcessing: '<div id="loader"></div>' }, bProcessing: true, "bServerSide": true, "iDisplayLength": pageSize, "sAjaxSource": " /PurchaseOrder/AddVendorItems", // url getData.php etc ...
9,174,006
Is it possible to subtract a matched character in a character class? [Java docs](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) are having examples about character classes with subtraction: ``` [a-z&&[^bc]] - a through z, except for b and c: [ad-z] (subtraction) [a-z&&[^m-p]] - a through...
2012/02/07
[ "https://Stackoverflow.com/questions/9174006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/283037/" ]
Use ``` Pattern p = Pattern.compile("((\\w)\\2(?!\\2))((\\w)\\4)"); ``` Your characters will be in groups `1` and `3`. This works by using a negative lookahead, to make sure the character following the second character in the first character group is a different character.
You are using the wrong tool for the job. By all means use a regex to detect pairs of character pairs, but you can just use `!=` to test whether the characters within the pairs are the same. Seriously, there is no reason to do *everything* in a regular expression - it makes for unreadable, non-portable code and brings ...
9,174,006
Is it possible to subtract a matched character in a character class? [Java docs](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) are having examples about character classes with subtraction: ``` [a-z&&[^bc]] - a through z, except for b and c: [ad-z] (subtraction) [a-z&&[^m-p]] - a through...
2012/02/07
[ "https://Stackoverflow.com/questions/9174006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/283037/" ]
Use ``` Pattern p = Pattern.compile("((\\w)\\2(?!\\2))((\\w)\\4)"); ``` Your characters will be in groups `1` and `3`. This works by using a negative lookahead, to make sure the character following the second character in the first character group is a different character.
Try this ``` String regex = "(\\w)\\1(?!\\1)(\\w)\\2"; Pattern pattern = Pattern.compile(regex); ``` `(?!\\1)` is a [negative lookahead](http://www.regular-expressions.info/lookaround.html), it ensures that the content of `\\1` is not following My test code ``` String s1 = "aaaa123"; String s2 = "aabb123"; String ...
60,180,447
For a sample project I am working on (<https://gitlab.com/connorbutch/reading-comprehension-ws>), I am having issues connecting to a google cloud mysql database from google cloud run. However, when I run locally with the same args (in both docker and kubernetes) the application looks to succeed. The steps I followed i...
2020/02/12
[ "https://Stackoverflow.com/questions/60180447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4645723/" ]
Following the documentation steps: 1. [Build and deploy container](https://cloud.google.com/run/docs/quickstarts/build-and-deploy) 2. [Connect from Cloud Run](https://cloud.google.com/sql/docs/mysql/connect-run) On the last step: “[Connecting to CloudSQL](https://cloud.google.com/sql/docs/mysql/connect-run#connecting...
Sadly the <https://cloud.google.com/sql/docs/mysql/connect-run> document is currently not documenting the Knative instructions. Any time you see "Cloud Run (fully managed)" that's not to Kubernetes implementation. If you are using Cloud Run on a Kubernetes/GKE cluster, this is probably more applicable. <https://cloud....
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
This isn't great but it'll work. A simple python script can do the check ``` import sys try: import setuptools except ImportError: sys.exit(1) else: sys.exit(0) ``` OR ``` try: import setuptools except ImportError: print("Not installed.") else: print("Installed.") ``` Then just check it's...
Just run the following code into IDLE: ``` import easy_install ``` If it just goes to the next line, I think it's installed. If it says: ``` Error: invalid syntax ``` Then it probably isn't installed. I know this because I tested pip with it. Also just check `import pip` to see if pip is pre-installed. :)
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
you can check for easy\_install and setuptools by running the following command line commands: ``` which easy_install #finds the path to easy_install if it exists less path/to/easy_install #where path/to/easy_install is the output from the above command #this outputs your easy_install script which will mention the ve...
Depends with the python version installed. you can try `"pip list"` or `"pip3 list"` and check for the setuptools and version installed.
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
This isn't great but it'll work. A simple python script can do the check ``` import sys try: import setuptools except ImportError: sys.exit(1) else: sys.exit(0) ``` OR ``` try: import setuptools except ImportError: print("Not installed.") else: print("Installed.") ``` Then just check it's...
Depends with the python version installed. you can try `"pip list"` or `"pip3 list"` and check for the setuptools and version installed.
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
Try with this command. ``` $ pip list ``` It returns the versions of both `pip` and `setuptools`. Otherwise try with ``` $ pip install pil ``` If this also doesn't work, then try with ``` $ which easy_install ```
This will display the version of your setuptools if it is installed already `$python -c "import sys; import setuptools; print(setuptools.version.__version__)"`
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
Try with this command. ``` $ pip list ``` It returns the versions of both `pip` and `setuptools`. Otherwise try with ``` $ pip install pil ``` If this also doesn't work, then try with ``` $ which easy_install ```
Depends with the python version installed. you can try `"pip list"` or `"pip3 list"` and check for the setuptools and version installed.
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
This isn't great but it'll work. A simple python script can do the check ``` import sys try: import setuptools except ImportError: sys.exit(1) else: sys.exit(0) ``` OR ``` try: import setuptools except ImportError: print("Not installed.") else: print("Installed.") ``` Then just check it's...
you can check for easy\_install and setuptools by running the following command line commands: ``` which easy_install #finds the path to easy_install if it exists less path/to/easy_install #where path/to/easy_install is the output from the above command #this outputs your easy_install script which will mention the ve...
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
Try with this command. ``` $ pip list ``` It returns the versions of both `pip` and `setuptools`. Otherwise try with ``` $ pip install pil ``` If this also doesn't work, then try with ``` $ which easy_install ```
Just run the following code into IDLE: ``` import easy_install ``` If it just goes to the next line, I think it's installed. If it says: ``` Error: invalid syntax ``` Then it probably isn't installed. I know this because I tested pip with it. Also just check `import pip` to see if pip is pre-installed. :)
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
This will display the version of your setuptools if it is installed already `$python -c "import sys; import setuptools; print(setuptools.version.__version__)"`
Depends with the python version installed. you can try `"pip list"` or `"pip3 list"` and check for the setuptools and version installed.
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
This isn't great but it'll work. A simple python script can do the check ``` import sys try: import setuptools except ImportError: sys.exit(1) else: sys.exit(0) ``` OR ``` try: import setuptools except ImportError: print("Not installed.") else: print("Installed.") ``` Then just check it's...
It comes preinstalled with new versions of Python. ``` pip3 list ``` was enough to identify it was installed for me
19,430,353
I'm writing a code that checks if a word has multiple of the same letters in it, so I split each letter into an array and wrote this code. the "correctGuesses" variable is supposed to be the number of duplicate letters. The Array contains the strings ("H, E, L, L ,O"). ``` Dim newCharArray() As Char = wordArray(rndNum...
2013/10/17
[ "https://Stackoverflow.com/questions/19430353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2890001/" ]
It comes preinstalled with new versions of Python. ``` pip3 list ``` was enough to identify it was installed for me
Depends with the python version installed. you can try `"pip list"` or `"pip3 list"` and check for the setuptools and version installed.
43,559,998
From [Array Covariance](https://blogs.msdn.microsoft.com/ericlippert/2007/10/17/covariance-and-contravariance-in-c-part-two-array-covariance/) article: > > Arrays where the element type is a reference type are covariant. [...] It was added to the CLR because Java requires it and the CLR designers wanted to be able to...
2017/04/22
[ "https://Stackoverflow.com/questions/43559998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7821462/" ]
You already do have Polish characters in the list. But when you print the list you only see its representation. ``` >>> print u'zosta\u0142' został ```
Your file is actually not UTF-8 but [UTF-8-BOM](https://en.wikipedia.org/wiki/Byte_order_mark). Use `open(filename, 'r', encoding='utf-8-bom')`
1,390,862
Picture two web pages, both viewed using https. They reside on different domains. How can I (reasonably) ensure that someone arriving at my page came via a hyperlink that resides on another (specific) domain? I only want to allow traffic from that domain. Any ideas on the best way to accomplish this would be appreciat...
2009/09/07
[ "https://Stackoverflow.com/questions/1390862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/142119/" ]
Whether or not the RFCs *allow* the sending of http\_referer or not, you'll find that many web clients and/or the proxies or other privacy-related gateways between it and the server will remove or spoof the http\_referer in the header, rending most http\_referer-based "authentication" scheme partially functional at bes...
If you've got no control over the referring site you are out of luck. Sniff the referrer if you can, and if it's not present throw up a landing page that says "click here go to site A so you can come back here". Additionally, spend some time working on a more robust method of accessing your 'secure' site.
1,390,862
Picture two web pages, both viewed using https. They reside on different domains. How can I (reasonably) ensure that someone arriving at my page came via a hyperlink that resides on another (specific) domain? I only want to allow traffic from that domain. Any ideas on the best way to accomplish this would be appreciat...
2009/09/07
[ "https://Stackoverflow.com/questions/1390862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/142119/" ]
Elaborating on mjv's response: you should put HMAC ([RFC 2104](http://www.faqs.org/rfcs/rfc2104.html)) into the URL. Have a shared secret between the two servers, and have the originating server generate links of the form /timestamp/hmac/path. The hmac should be verified from hmac(key, timestamp+path), so that differen...
If you've got no control over the referring site you are out of luck. Sniff the referrer if you can, and if it's not present throw up a landing page that says "click here go to site A so you can come back here". Additionally, spend some time working on a more robust method of accessing your 'secure' site.
463,530
Do I overlook something? For Live Migration to work in aScenario wher the VM's are stored on a SMB share I have to set up constraint delegation: <http://www.aidanfinn.com/?p=13711> <http://v-enfra.blogspot.com/2012/04/live-migration-with-smb-shared-storage.html> The problem is: I have to set up every target hyper-v ...
2013/01/06
[ "https://serverfault.com/questions/463530", "https://serverfault.com", "https://serverfault.com/users/37059/" ]
You have the option of using SCVMM 2012 SP1. VMM will setup Hyper-V over SMB and there is no requirement to do delegation. You can also use PowerShell and Remoting. If you remote into the boxes, you can set everything up without delegation. Hope this helps, Jose Barreto
The best suggestion I have for you is to use SCVMM, which does this for you.
195,225
I had an interview with a global company yesterday. They had given me a programming assignment. I shared my screen and I must have finished the task in 1.5 hours. Task was programming Reverse Polish Notation calculator in Java. I had developed as I shared my code below. I was rejected by not being stick to KISS and D...
2018/05/26
[ "https://codereview.stackexchange.com/questions/195225", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/98151/" ]
So, I'm late to the party, but I'm going to say I think your approach is a lot more complicated it has to be. Solving RPN is a stack and a loop. Unless I was explicitly being asked to show extensible code, I don't think I'd even use an operation type. It's hard to tell because we weren't there to ask questions - 1.5 ho...
**1. Problem model** In my opinion this problem should rarely use more than three classes. I actually only need two: Operation and value. In each string are only the mathematical operations and the values. This would have cut down your code in half, I assume. **2. Design** I really hope you came prepared and you...
195,225
I had an interview with a global company yesterday. They had given me a programming assignment. I shared my screen and I must have finished the task in 1.5 hours. Task was programming Reverse Polish Notation calculator in Java. I had developed as I shared my code below. I was rejected by not being stick to KISS and D...
2018/05/26
[ "https://codereview.stackexchange.com/questions/195225", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/98151/" ]
Your **naming** is inconsistent and confusing. What is an "Element"? Why does `operationStack` contain `Element`s rather than `Operation`s, as its name would suggest? Why is `elementArray` an array of `String`s rather than of `Element`s, as its name would suggest? Why is `Number` an `Element`, and why does its `.getVal...
**1. Problem model** In my opinion this problem should rarely use more than three classes. I actually only need two: Operation and value. In each string are only the mathematical operations and the values. This would have cut down your code in half, I assume. **2. Design** I really hope you came prepared and you...
195,225
I had an interview with a global company yesterday. They had given me a programming assignment. I shared my screen and I must have finished the task in 1.5 hours. Task was programming Reverse Polish Notation calculator in Java. I had developed as I shared my code below. I was rejected by not being stick to KISS and D...
2018/05/26
[ "https://codereview.stackexchange.com/questions/195225", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/98151/" ]
Your **naming** is inconsistent and confusing. What is an "Element"? Why does `operationStack` contain `Element`s rather than `Operation`s, as its name would suggest? Why is `elementArray` an array of `String`s rather than of `Element`s, as its name would suggest? Why is `Number` an `Element`, and why does its `.getVal...
So, I'm late to the party, but I'm going to say I think your approach is a lot more complicated it has to be. Solving RPN is a stack and a loop. Unless I was explicitly being asked to show extensible code, I don't think I'd even use an operation type. It's hard to tell because we weren't there to ask questions - 1.5 ho...
56,411,290
I want to assign value to datetimepicker, but isn't work anymore. I tried, but the results were not as expected. Jquery to assign value : ``` $('#iTTDateOpen').data('datetimepicker').setLocalDate(new Date(2019, 6, 2, 10, 55)); ``` HTML Code : ``` <div class="form-group"> <label class="col-md-3 control-label">TT ...
2019/06/02
[ "https://Stackoverflow.com/questions/56411290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6459551/" ]
Problem was solved. On your database, convert the value using varchar : `convert(VARCHAR, trx.TroubleTicketDateOpen,20)` On your HTML, add properties like : `<input type="text" id="iTTDateOpen" class="form-control txt filter-time" data-date-format="yyyy-mm-dd hh:ii:ss" placeholder="Trouble Ticket Date Open" onkeyd...
Maybe something like this? ``` $('#iTTDateOpen').html(new Date(2019, 6, 2, 10, 55)); ```
11,279,344
Sounds easy, right? Here's the scenario... ``` Private dbQuery As New ReefEntities Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CurrentCoral = (From c In dbQuery.Corals Where c.CoralID = intCoralID).FirstOrDefault txtCommon...
2012/07/01
[ "https://Stackoverflow.com/questions/11279344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/496189/" ]
HTTP is a stateless protocol and as a result, every request you make to your server needs to rebuild your object graph unless you persist it somewhere. There are many ways to persist data across a web "session". In ASP.NET you can store data in cookies, server side session, viewstate, form variables, and more. First ...
You could put your CurrentCoral object into the ViewState or Session, then retrieve it in the Click event. ``` Dim oCurrentCorral as Object = ViewState("CurrentCoral") dbQuery.ObjectStateManager.ChangeObjectState(oCurrentCoral, System.Data.EntityState.Added) dbQuery.SaveChanges() ```
11,279,344
Sounds easy, right? Here's the scenario... ``` Private dbQuery As New ReefEntities Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CurrentCoral = (From c In dbQuery.Corals Where c.CoralID = intCoralID).FirstOrDefault txtCommon...
2012/07/01
[ "https://Stackoverflow.com/questions/11279344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/496189/" ]
HTTP is a stateless protocol and as a result, every request you make to your server needs to rebuild your object graph unless you persist it somewhere. There are many ways to persist data across a web "session". In ASP.NET you can store data in cookies, server side session, viewstate, form variables, and more. First ...
If the request is a postback, the record isn't loaded in `Page_Load` at all – there's nothing to re-query since you haven't made a query in the request at all. I'd say to just re-query in the postback handler, chances are the overhead of hitting your database once to update is much smaller than the overhead of sending ...
11,279,344
Sounds easy, right? Here's the scenario... ``` Private dbQuery As New ReefEntities Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CurrentCoral = (From c In dbQuery.Corals Where c.CoralID = intCoralID).FirstOrDefault txtCommon...
2012/07/01
[ "https://Stackoverflow.com/questions/11279344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/496189/" ]
You could put your CurrentCoral object into the ViewState or Session, then retrieve it in the Click event. ``` Dim oCurrentCorral as Object = ViewState("CurrentCoral") dbQuery.ObjectStateManager.ChangeObjectState(oCurrentCoral, System.Data.EntityState.Added) dbQuery.SaveChanges() ```
If the request is a postback, the record isn't loaded in `Page_Load` at all – there's nothing to re-query since you haven't made a query in the request at all. I'd say to just re-query in the postback handler, chances are the overhead of hitting your database once to update is much smaller than the overhead of sending ...
6,739,915
I need to pull a section of text from an HTML page that is not on my local site, and then have it parsed as a string. Specifically, the last column from [this](http://www.treasurydirect.gov/NP/BPDLogin?application=np) page. I assume I would have to copy the source of the page to a variable and then setup a regex search...
2011/07/18
[ "https://Stackoverflow.com/questions/6739915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/516833/" ]
* Scrape the page HTML with file\_get\_contents() (needs ini value allow\_url\_fopen to be true) or a system function like curl or wget * Run a Regular Expression to match the desired part. You could just match any `<td>`s in this case, as these values are the first occurrences of table cells, e.g. `preg_match("/<td.*?...
If you can use URL fopen, then a simple file\_get\_contents('http://somesite.com/somepage') would suffice. There are various libraries out there to do web scraping, which is the name for what you're trying to do. They might be more flexible than a bunch of regular expressions (regexes are known for having a tough time ...
16,774,515
I hava a form element with some contents inside as given below. ``` <form action="insertserverdata.php" id="toPopup"> <table> <tr> <td>IP address:</td> <td><input type="text" id="ip" /></td> </tr> <tr> <td></td> <td> <input id="btnLogin" type="submit"/> ...
2013/05/27
[ "https://Stackoverflow.com/questions/16774515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2393591/" ]
Different ways to redirect URL in javascript ``` window.location.href = 'connectServer.php'; ``` OR ``` document.location = 'connectServer.php'; ``` Refer this link <http://ntt.cc/2008/01/21/5-ways-to-redirect-url-with-javascript.html>
``` if($.trim(data)=="1"){ window.location = 'connectServer.php'; } ``` * <https://developer.mozilla.org/en-US/docs/Web/API/window.location>
16,774,515
I hava a form element with some contents inside as given below. ``` <form action="insertserverdata.php" id="toPopup"> <table> <tr> <td>IP address:</td> <td><input type="text" id="ip" /></td> </tr> <tr> <td></td> <td> <input id="btnLogin" type="submit"/> ...
2013/05/27
[ "https://Stackoverflow.com/questions/16774515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2393591/" ]
Different ways to redirect URL in javascript ``` window.location.href = 'connectServer.php'; ``` OR ``` document.location = 'connectServer.php'; ``` Refer this link <http://ntt.cc/2008/01/21/5-ways-to-redirect-url-with-javascript.html>
You can use either window.location or document.location to redirect to a specific page. ``` document.location = "connectServer.php"; ```
59,270,132
I'm trying to use withColumn to null out bad dates in a column in a dataframe, I'm using a when() function to make the update. I have two conditions for "bad" dates. dates before jan 1900 or dates in the future. My current code looks like this: ``` d = datetime.datetime.today() df_out = df.withColumn(my_column, when(c...
2019/12/10
[ "https://Stackoverflow.com/questions/59270132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5195636/" ]
It's just a problem of priority of operators. The error is telling you that `pyspark` cannot apply `OR` to a string. More specifically, it is trying to compute `'1900-01-01' | col(c)` and tells you that it does not know how to do it. You simply need to parenthesize the expression. ```py df_out = df.withColumn(my_colum...
It is a matter of operator precedence. The boolean OR operator `or` has lower precedence than the comparison operators so ``` col(my_column) < 'X' or col(my_column) > 'Y' ``` reads as ``` (col(my_column) < 'X') or (col(my_column) > 'Y') ``` But the bitwise OR operator `|` has higher precedence than the comparison...
23,644,539
I have a rollover image, and the goal is that when the user mouses over the image, it darkens (which I achieved using a rollover image) and two links appear titled "learn more" and "visit site" (they should appear over the image). Before I get to styling I wanted to make sure everything was working properly, and my iss...
2014/05/14
[ "https://Stackoverflow.com/questions/23644539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3474834/" ]
There's a problem with your `css` selector ``` #example1:hover.options { visibility:visible; } ``` Replace the selector to something like this: ``` #example1:hover > .options { visibility:visible; } ``` and that should work. [here's a quick sample](http://jsfiddle.net/Q39w5/)
you have .options {visibility:hidden;} so it is unseen no matter what content in it. you should at least change it to visible when .options:hover.
6,917,638
Hi I am passing an object to procedure in a oracle package using ODP.NET(C#). I am using ODP.NET because of associative arrays. I am unable to find oracledbtype.object in the ODP.NET to make parameter oracledbtype to object. which dbtype I have to use for parameter in .NET side using ODP.NET. ``` public Oracl...
2011/08/02
[ "https://Stackoverflow.com/questions/6917638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/846826/" ]
okay, I'll try to tackle this one without your pl/sql specification but we'll see how this works. I will use the sample provided in the ODP installation @ %ORA\_HOME%\odp.net\samples\2.x\AssocArray\AssocArray.sln as a sample talking point. but this site is also helpful [Using PL/SQL Associative Arrays](http://www.orac...
This should have all the information you need. I've used this article before to perform what you're trying. <http://www.oracle.com/technetwork/issue-archive/2009/09-sep/o59odpnet-085168.html>
57,414,347
I am trying to use the jmap to collect the heapdump. And the application is containerized and lauched on a EC2 Instance. To generate the heapdump the PID got assigned to the java process is "1" and jmap is not able to communicate with the process. If i use the --pid=host in the docker run command, the process inside t...
2019/08/08
[ "https://Stackoverflow.com/questions/57414347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4797832/" ]
These kind of hierarchy definitions are a bit unusual in python projects, which is why you're having a hard time implementing it with the everyday-syntax. You should take a step back and think about how invested into this architecture you really are, and if it isn't too late to rewrite it in a way that adheres more clo...
So, this is probably not the problem Python was designed to solve, but we can make it work. There are two separate parts to this dilemma: first, "how do I import all these packages without knowing them in advance?", and second "how do I bind those packages to a World object in a way that allows me to call method on th...
40,193,172
So I need to read all new messages of one specific channel that I'm in (not as an admin). I searched for different client apis (.NET, PHP, nodejs) but none of them helped. Do you have any idea how I could do this? Thanks!
2016/10/22
[ "https://Stackoverflow.com/questions/40193172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4470461/" ]
Here is how i did it : Install Telegram <https://github.com/vysheng/tg> Install Cli wraper <https://github.com/luckydonald/pytg> ``` from pytg import Telegram from pytg.utils import coroutine tg = Telegram( telegram="./tg/bin/telegram-cli", pubkey_file="./tg/tg-server.pub") receiver = tg.receiver QUIT = Fal...
First step is to add the telegram bot as channel admin if not you can't read channel messages!!!
22,821,390
I want to use Google Feed API from a server (Node.js). I have already installed the googleapis module. My code is: ``` // parts omitted var googleapis = require('googleapis'); // parts omitted googleapis.discover('feeds').execute(function(err, client) { var feed = new google.feeds.Feed('http://rss.lemonde.fr/c/205/f/3...
2014/04/02
[ "https://Stackoverflow.com/questions/22821390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3303704/" ]
to access Google Feed API using Node.js, you should try the google-feed-api module as explained here: <https://www.npmjs.org/package/google-feed-api> Hope it helps! Edit: I tried this with your URL and worked fine: ``` var gfeed = require('google-feed-api'); var feed = new gfeed.Feed('http://rss.lemonde.fr/c/205/f...
It's because `google` is literally not defined. I don't know very much about that module, but I think that instead of using the `google` var you should use `client` , because that's what the `execute` function returns. So the code would be: ``` // parts omitted var googleapis = require('googleapis'); // parts omit...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Haskell](https://www.haskell.org/), 54 bytes ============================================= ```hs import Data.List (.permutations).any.flip elem.mapM id ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRzyezuIQrzVZDryC1KLe0JLEkMz@vWFMvMa9SLy0ns0AhNSc1Vy83scBXITPlf25iZp5tQVFmXolKWnS0kY6hjkGsTrSxjqWOE...
[05AB1E](https://github.com/Adriandmen/05AB1E), 8 bytes ======================================================= ``` .»â€˜JIå ``` [Try it online!](https://tio.run/##yy9OTMpM/f9f79Duw4seNa05PcfL8/DS//@jlSoqlXQUoGRVOZQdy1VRWVUOAA "05AB1E – Try It Online")
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Perl 5](https://www.perl.org/) `-lpa`, ~~86~~ 79 bytes ======================================================= ```perl $"="}{";@a=<>;chomp@a;map{$b=$F[0];$\|=!grep!$_,map$b=~s/$_//,/./g}glob"{@a}"}{ ``` [Try it online!](https://tio.run/##HcyxDsIgFEDR3b8oeSMtOHRCDJObX6CmebQETai8tG6Iny5il7Pc5JJbQl8KMM1yYsqgPhzVeI8zGV...
[Python 3](https://docs.python.org/3/), 86 bytes ================================================ ```python lambda a,b:any(all(map(str.count,b,c))for c in permutations(a)) from itertools import* ``` [Try it online!](https://tio.run/##ddDNasQgEAfw@z7FQA/RIr30ttBrn6C3XQ8To1TwK2ropi@fOjZtdwsb8M8wmZ@Kaa3vMTxv5uW8OfTjhIB...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Python 2](https://docs.python.org/2/), 68 bytes ================================================ One of the few cases where itertools is useful. ```python lambda b,a:s(b)in map(s,product(*a)) s=sorted from itertools import* ``` [Try it online!](https://tio.run/##nY7BDoMgDIbvPgU3cPG04xKfxHkAlc1EhQHL5l7eWURXNV52@Wm@...
[05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes ======================================================= *-1 byte thanks to @KevinCruijssen* ``` œεøε`¢]PZ ``` [Try it online!](https://tio.run/##yy9OTMpM/f//6ORzWw/vOLc14dCi2ICo///T0pK4opUSk5KVdBSUElNSwVRSappSLAA "05AB1E – Try It Online")
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Haskell](https://www.haskell.org/), 54 bytes ============================================= ```hs import Data.List (.permutations).any.flip elem.mapM id ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRzyezuIQrzVZDryC1KLe0JLEkMz@vWFMvMa9SLy0ns0AhNSc1Vy83scBXITPlf25iZp5tQVFmXolKWnS0kY6hjkGsTrSxjqWOE...
[Haskell](https://www.haskell.org/), ~~66~~ 65 bytes ==================================================== Port of my Python answer. -1 byte thanks to @AdHocGarfHunter. ```hs b#(a:s)=or[x!b#s|x<-a,elem x b] b#x=1>0 x!(a:b)|a==x=b|w<-x!b=a:w ``` [Try it online!](https://tio.run/##hczBCsIwDAbg@57it/Wg4ECvYn0R8ZCunYrT...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Python 2](https://docs.python.org/2/), 70 bytes ================================================ ```python f=lambda s,l:l and any(f(s.replace(x,'',1),l[1:])for x in l[0])or''==s ``` [Try it online!](https://tio.run/##bZA9DoMwDIV3TuHNIEVV6YiUk6AMgSQtUhpCEqnQy9P8oNKhg/2e7M8ent3CYza3fVdU8@cgOHiiOw3ciFhbrWp/cdJqPsp6JYi...
[Python 3](https://docs.python.org/3/), 86 bytes ================================================ ```python lambda a,b:any(all(map(str.count,b,c))for c in permutations(a)) from itertools import* ``` [Try it online!](https://tio.run/##ddDNasQgEAfw@z7FQA/RIr30ttBrn6C3XQ8To1TwK2ropi@fOjZtdwsb8M8wmZ@Kaa3vMTxv5uW8OfTjhIB...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Haskell](https://www.haskell.org/), 54 bytes ============================================= ```hs import Data.List (.permutations).any.flip elem.mapM id ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRzyezuIQrzVZDryC1KLe0JLEkMz@vWFMvMa9SLy0ns0AhNSc1Vy83scBXITPlf25iZp5tQVFmXolKWnS0kY6hjkGsTrSxjqWOE...
[Charcoal](https://github.com/somebody1234/Charcoal), 37 bytes ============================================================== ``` Sθ⊞υθFθ«Sι≔υη≔⟦⟧υFηFΦκ№ιλ⊞υΦκ¬⁼λμ»¿υ¹ ``` [Try it online!](https://tio.run/##TU27DsIwDJybr/DoSGFg7oQQSCwIiRExVBVtIkLSPMyC@PbgVELt4LPPd/b1uou972wpJzdRvuZo3IhBtuJCSSMpqPPgI/ASPqJZ2wxLzS4lM7...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Haskell](https://www.haskell.org/), 54 bytes ============================================= ```hs import Data.List (.permutations).any.flip elem.mapM id ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRzyezuIQrzVZDryC1KLe0JLEkMz@vWFMvMa9SLy0ns0AhNSc1Vy83scBXITPlf25iZp5tQVFmXolKWnS0kY6hjkGsTrSxjqWOE...
[05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes ======================================================= *-1 byte thanks to @KevinCruijssen* ``` œεøε`¢]PZ ``` [Try it online!](https://tio.run/##yy9OTMpM/f//6ORzWw/vOLc14dCi2ICo///T0pK4opUSk5KVdBSUElNSwVRSappSLAA "05AB1E – Try It Online")
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Haskell](https://www.haskell.org/), ~~66~~ 65 bytes ==================================================== Port of my Python answer. -1 byte thanks to @AdHocGarfHunter. ```hs b#(a:s)=or[x!b#s|x<-a,elem x b] b#x=1>0 x!(a:b)|a==x=b|w<-x!b=a:w ``` [Try it online!](https://tio.run/##hczBCsIwDAbg@57it/Wg4ECvYn0R8ZCunYrT...
[Python 3](https://docs.python.org/3/), 86 bytes ================================================ ```python lambda a,b:any(all(map(str.count,b,c))for c in permutations(a)) from itertools import* ``` [Try it online!](https://tio.run/##ddDNasQgEAfw@z7FQA/RIr30ttBrn6C3XQ8To1TwK2ropi@fOjZtdwsb8M8wmZ@Kaa3vMTxv5uW8OfTjhIB...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Python 2](https://docs.python.org/2/), 70 bytes ================================================ ```python f=lambda s,l:l and any(f(s.replace(x,'',1),l[1:])for x in l[0])or''==s ``` [Try it online!](https://tio.run/##bZA9DoMwDIV3TuHNIEVV6YiUk6AMgSQtUhpCEqnQy9P8oNKhg/2e7M8ent3CYza3fVdU8@cgOHiiOw3ciFhbrWp/cdJqPsp6JYi...
[Charcoal](https://github.com/somebody1234/Charcoal), 37 bytes ============================================================== ``` Sθ⊞υθFθ«Sι≔υη≔⟦⟧υFηFΦκ№ιλ⊞υΦκ¬⁼λμ»¿υ¹ ``` [Try it online!](https://tio.run/##TU27DsIwDJybr/DoSGFg7oQQSCwIiRExVBVtIkLSPMyC@PbgVELt4LPPd/b1uou972wpJzdRvuZo3IhBtuJCSSMpqPPgI/ASPqJZ2wxLzS4lM7...
203,498
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are `n` badge collectors, each has a known lis...
2020/04/14
[ "https://codegolf.stackexchange.com/questions/203498", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/59642/" ]
[Python 2](https://docs.python.org/2/), 68 bytes ================================================ One of the few cases where itertools is useful. ```python lambda b,a:s(b)in map(s,product(*a)) s=sorted from itertools import* ``` [Try it online!](https://tio.run/##nY7BDoMgDIbvPgU3cPG04xKfxHkAlc1EhQHL5l7eWURXNV52@Wm@...
[C (gcc)](https://gcc.gnu.org/), 170 168 bytes ============================================== *Edited: Switched to returning 1 from inner `main` calls to save a byte not needing to negate the return value when assigning into `u`. Also another byte saved thanks to @ceilingcat for reminding me about `index` instead of `...
2,386,782
Well I found a [nice tutorial](http://developer.apple.com/mac/library/documentation/networking/conceptual/dns_discovery_api/Articles/registering.html) about how to program applications using Bonjour. It's cool. But the only problem, I do not understand which language they teach. I am not even sure that it is a programm...
2010/03/05
[ "https://Stackoverflow.com/questions/2386782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/245549/" ]
Its the C API for apple's Bonjour services; this is hardly a programming tutorial.
That’s not a tutorial about how to program, OS X programs are written in Objective-C (although this is a C API), and that page has a table of contents on the left side. The [`mDNS`](http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/mDNS.1.html) command line tool can be used to test Bo...
2,386,782
Well I found a [nice tutorial](http://developer.apple.com/mac/library/documentation/networking/conceptual/dns_discovery_api/Articles/registering.html) about how to program applications using Bonjour. It's cool. But the only problem, I do not understand which language they teach. I am not even sure that it is a programm...
2010/03/05
[ "https://Stackoverflow.com/questions/2386782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/245549/" ]
Looking at the left, there's a block that says: ``` RELATED REFERENCE PROCEDURAL C DNS Service Discovery C Reference ``` I'm going to go out on a limb and say it's probably C.
That’s not a tutorial about how to program, OS X programs are written in Objective-C (although this is a C API), and that page has a table of contents on the left side. The [`mDNS`](http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/mDNS.1.html) command line tool can be used to test Bo...
2,386,782
Well I found a [nice tutorial](http://developer.apple.com/mac/library/documentation/networking/conceptual/dns_discovery_api/Articles/registering.html) about how to program applications using Bonjour. It's cool. But the only problem, I do not understand which language they teach. I am not even sure that it is a programm...
2010/03/05
[ "https://Stackoverflow.com/questions/2386782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/245549/" ]
Its the C API for apple's Bonjour services; this is hardly a programming tutorial.
From the URL, title, and menu you can tell that it's a article about registering services using their dns\_discovery\_api in C. This is not a programming tutorial.
2,386,782
Well I found a [nice tutorial](http://developer.apple.com/mac/library/documentation/networking/conceptual/dns_discovery_api/Articles/registering.html) about how to program applications using Bonjour. It's cool. But the only problem, I do not understand which language they teach. I am not even sure that it is a programm...
2010/03/05
[ "https://Stackoverflow.com/questions/2386782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/245549/" ]
Looking at the left, there's a block that says: ``` RELATED REFERENCE PROCEDURAL C DNS Service Discovery C Reference ``` I'm going to go out on a limb and say it's probably C.
From the URL, title, and menu you can tell that it's a article about registering services using their dns\_discovery\_api in C. This is not a programming tutorial.
9,343,205
I have an array of char \* initialized like this: ``` char *keys[16]; //16 elements, each of which is a char * ``` Then I am assigning to this array like this: ``` for(i = 0; i < NUM_ROUNDS; i++) { //do some operations that generate a char* holding 48 characters named keyi keys[i] = keyi; } ``` B...
2012/02/18
[ "https://Stackoverflow.com/questions/9343205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702638/" ]
It seems most likely that `keyi` isn't NUL-terminated. Maybe you want this ? ``` keyi[48] = 0; /* Caveat, keyi must be at least 49 chars wide. */ keys[i] = keyi; ``` Or maybe: ``` printf("keys[%d] = %.48s\n", k,keys[k]); ```
`%s` prints the contents untill it encounters a `\0`, Your elements are not `\0` terminated. So it prints out the contents until it randomly encounters a `\0`. You should explicitly `\0` terminate your contents.
9,343,205
I have an array of char \* initialized like this: ``` char *keys[16]; //16 elements, each of which is a char * ``` Then I am assigning to this array like this: ``` for(i = 0; i < NUM_ROUNDS; i++) { //do some operations that generate a char* holding 48 characters named keyi keys[i] = keyi; } ``` B...
2012/02/18
[ "https://Stackoverflow.com/questions/9343205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702638/" ]
It seems most likely that `keyi` isn't NUL-terminated. Maybe you want this ? ``` keyi[48] = 0; /* Caveat, keyi must be at least 49 chars wide. */ keys[i] = keyi; ``` Or maybe: ``` printf("keys[%d] = %.48s\n", k,keys[k]); ```
You should write a `0` byte onto the end of the 48 character string, or it won't know when to stop printing. Just be sure to allocate 49 bytes to allow for this.
9,343,205
I have an array of char \* initialized like this: ``` char *keys[16]; //16 elements, each of which is a char * ``` Then I am assigning to this array like this: ``` for(i = 0; i < NUM_ROUNDS; i++) { //do some operations that generate a char* holding 48 characters named keyi keys[i] = keyi; } ``` B...
2012/02/18
[ "https://Stackoverflow.com/questions/9343205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702638/" ]
It seems most likely that `keyi` isn't NUL-terminated. Maybe you want this ? ``` keyi[48] = 0; /* Caveat, keyi must be at least 49 chars wide. */ keys[i] = keyi; ``` Or maybe: ``` printf("keys[%d] = %.48s\n", k,keys[k]); ```
Your `char*`s do not point to NUL-terminated strings. You need to make `keyi` 49 bytes long, and put a 0 at `keyi[48]`.
9,343,205
I have an array of char \* initialized like this: ``` char *keys[16]; //16 elements, each of which is a char * ``` Then I am assigning to this array like this: ``` for(i = 0; i < NUM_ROUNDS; i++) { //do some operations that generate a char* holding 48 characters named keyi keys[i] = keyi; } ``` B...
2012/02/18
[ "https://Stackoverflow.com/questions/9343205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702638/" ]
`%s` prints the contents untill it encounters a `\0`, Your elements are not `\0` terminated. So it prints out the contents until it randomly encounters a `\0`. You should explicitly `\0` terminate your contents.
You should write a `0` byte onto the end of the 48 character string, or it won't know when to stop printing. Just be sure to allocate 49 bytes to allow for this.
9,343,205
I have an array of char \* initialized like this: ``` char *keys[16]; //16 elements, each of which is a char * ``` Then I am assigning to this array like this: ``` for(i = 0; i < NUM_ROUNDS; i++) { //do some operations that generate a char* holding 48 characters named keyi keys[i] = keyi; } ``` B...
2012/02/18
[ "https://Stackoverflow.com/questions/9343205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702638/" ]
`%s` prints the contents untill it encounters a `\0`, Your elements are not `\0` terminated. So it prints out the contents until it randomly encounters a `\0`. You should explicitly `\0` terminate your contents.
Your `char*`s do not point to NUL-terminated strings. You need to make `keyi` 49 bytes long, and put a 0 at `keyi[48]`.
38,741,681
So I want to center horizontal and vertical a UILabel in my View programmatically. I follow [this topic](https://stackoverflow.com/questions/18496341/how-can-i-center-a-uiview-programmatically-on-top-of-an-existing-uiview-using-au) but it doesn't work. How can I do that? p/s: this is my code: ``` class ViewController...
2016/08/03
[ "https://Stackoverflow.com/questions/38741681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3855875/" ]
Add this to your code: ``` noDataLabel.translatesAutoresizingMaskIntoConstraints = false ``` From apple documentation: > > By default, the autoresizing mask on a view gives rise to > constraints that fully determine > the view's position. This allows the auto layout system to track the frames of views whose ...
You also need create size constraints for `uilabel` like below and add it to your superView ``` NSLayoutConstraint(item: noDataLabel, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100) NSLayoutConstraint(item:...
1,407,263
Suppose, if I have been given this: $\forall x \in A(P(x))$ and $\exists y \in A(Q(y))$. Now from $\forall x \in A(P(x))$ using universal instantiation, I get $P(c)$ where $c$ is an arbitrary element in $A$. Now my doubt is, if using $\exists y \in A(Q(y))$, can I conclude $Q(c)$ ?. My reasoning says yes, because $c$ ...
2015/08/23
[ "https://math.stackexchange.com/questions/1407263", "https://math.stackexchange.com", "https://math.stackexchange.com/users/124772/" ]
No, you have to go the other way around: from $\exists y\in A(Q(y))$ we instantiate to get a $c$ with $Q(c)$; we now conclude that $P(c)$ holds, because $\forall x\in A(P(c))$. --- One way to picture this is as a **game**. You're trying to show that a statement - say, $\exists x\in A(P(x) \wedge Q(x))$ - is true, and...
> > Now from $∀x∈A(P(x))$ using universal instantiation, I get $P(c)$ where $c$ is an arbitrary element in A . Now my doubt is, if using $∃y∈A(Q(y))$ , can I conclude $Q(c)$ ?. > > > No. > > My reasoning says yes, because $c$ is an arbitrary element in $A$ and $y∈A$ . Is this type of instantiation from universal...
444,647
> > А после, со спокойной душой, они плюхнулись на мягкие диваны. > > > Выделяется ли "со спокойной душой"?
2018/10/11
[ "https://rus.stackexchange.com/questions/444647", "https://rus.stackexchange.com", "https://rus.stackexchange.com/users/189463/" ]
**А после, со спокойной душой, они плюхнулись на мягкие диваны.** Оборот обособляется, и это связано со структурой предложения (М.Г. здесь совершенно прав). Только оборот **не имеет значение уточнения, это дополнительное сообщение,** которое автору важно выделить путем обособления. Именно поэтому выбрана **соответс...
Не всегда "со спокойной душой" выделяется, но в данном случае структура и интонационный строй предложения располагают его выделить, только здесь, как заметила Jasmin, не уточнение, а дополнительное сообщение, которое нужно выделить путем обособления. Лучше всего запятыми.
444,647
> > А после, со спокойной душой, они плюхнулись на мягкие диваны. > > > Выделяется ли "со спокойной душой"?
2018/10/11
[ "https://rus.stackexchange.com/questions/444647", "https://rus.stackexchange.com", "https://rus.stackexchange.com/users/189463/" ]
**А после, со спокойной душой, они плюхнулись на мягкие диваны.** Оборот обособляется, и это связано со структурой предложения (М.Г. здесь совершенно прав). Только оборот **не имеет значение уточнения, это дополнительное сообщение,** которое автору важно выделить путем обособления. Именно поэтому выбрана **соответс...
Не выделяется - совершенно нет причин считать его уточнением. А после, а именно со спокойной душой? Так сказать нельзя.
2,208,117
Let ${P\_i}$ be a family of mutually orthogonal projections of a semifinite von Neumann algebra $M$ and $\tau$ be the semifinite faithful normal trace on $M$. If $\tau(\sum P\_i) =\infty$, can we find a sequence of projections $\{Q\_n\}$ from $\{P\_i\}$ such that $\tau(\sum Q\_n) =\infty$? My idea is: Without loss of...
2017/03/29
[ "https://math.stackexchange.com/questions/2208117", "https://math.stackexchange.com", "https://math.stackexchange.com/users/92646/" ]
Since $\tau$ is normal, we have $\tau(\sum P\_i)=\sum \tau(P\_i)$. So this becomes a question about numbers. If $\{\alpha\_j\}\subset[0,\infty)$ satisfies $\sum\_j\alpha\_j=\infty$, this means by definition that $$ \sup\{\sum\_{j\in F}\alpha\_j:\ F \text{ finite}\}=\infty $$ So we can find finite subsets $F\_n$ such...
Assume by contradiction that there is no such a subset $\{P\_n\}\_{n=1}^\infty$ of $\{P\_i\}\_i$ consisting of countably many projections such that $\tau(\sum\_{n=1}^\infty P\_n )=\infty$. Then, there is a finite constant $C>0$ such that, for every subset $\{P\_n\}\_{n=1}^\infty$ of $\{P\_i\}\_i$ consisting of countabl...
71,039,741
I made a custom Checkbox component to handle events differently, code below: ``` const DoubleClickCheckbox = ({ filter, handleDoubleClick, handleSingleClick }: DCCheckboxProps) => { const delay = 400; const timer = useRef(null); const classes = useStyles(); const flags = useFlags(); useEffect(() => { r...
2022/02/08
[ "https://Stackoverflow.com/questions/71039741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5800846/" ]
Seems like you'r ref can be `null` or be a `number` (`ReturnType<typeof setTimeout>` is `number`): ``` const timer = React.useRef<number | null>(null) ```
I think the problem is the `useRef(null)` implicitly sets it's type as `null`. You should define it as `const timer = useRef<null | () => void>(null)`
234,410
In the Netflix subtitles and the fan wikis alike, Martha's son is referred to as Unknown (in the latter, the Unknown). However, one imagines that he has a name. For Martha not to have given him one would have been peculiar, given how much she seemed to care about him initially. Does he have a name? Did Martha decide t...
2020/07/13
[ "https://scifi.stackexchange.com/questions/234410", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/51379/" ]
At the beginning of episode 4 of season 3, Tronte (who turns out to be his son) has an encounter with the middle-aged version of Unknown outside the cave, and they exchange a few words, including these: > > Tronte: Do I know you? > > > Unknown: I knew your mother. But that was long ago. You take after her. Your eye...
The Unknown himself states he has no name as he was never given one. [Scene referenced.](https://www.youtube.com/watch?v=gM4uiY32IvY)