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
49,611,336
I used same setting for enabling arbitrary load but now i faced some issues.I used alamofire for json parsing. [![enter image description here](https://i.stack.imgur.com/rxA08.png)](https://i.stack.imgur.com/rxA08.png) info.plist settings: [![enter image description here](https://i.stack.imgur.com/7d6ea.png)](https:...
2018/04/02
[ "https://Stackoverflow.com/questions/49611336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9045825/" ]
your info plist hierarchy for transport should be like this [![enter image description here](https://i.stack.imgur.com/5yFbN.png)](https://i.stack.imgur.com/5yFbN.png)
> > `NSAppTransportSecurity` provides the network layer security and only allow http secured urls. > > > There are 2 ways to solve this: **Case 1:** In your code you are using an unsecure url with `http://` replace it with `https://`, then it will work. **Case 2:** If you don't have ssl enabled url then, allow...
96,598
I would like to say, "I have played piano for 23 years" -- but this document will have to be changed every year so I remember to make it 23, then 24, then 25. Is there a way to do something like: ``` I have played piano for \calculate{\year - 1986} years. ``` Perhaps using the `calc` package and the `\year` command...
2013/02/03
[ "https://tex.stackexchange.com/questions/96598", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/10376/" ]
You can use the integer arithmetic of TeX too. ``` \documentclass{article} \begin{document} I've played the piano for \number\numexpr\year-1986\relax~years. \end{document} ```
Just in case you are going to use `tikz` in your document, here is an overkill solution with this package. ``` \documentclass{article} \usepackage{tikz} \begin{document} I have played piano for \pgfmathparse{int(\year-1986)}\pgfmathresult~years. \end{document} ```
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You want to make a new thread; depending on how long the method needs to be, you can make it inline: ``` // some code new Thread(new Runnable() { @Override public void run() { // do stuff in this thread } }).start(); ``` Or just make a new class: ``` public class MyWorker extends Thread { public...
Naïve idea : you might be able to create Thread, give it a low priority, and do a loop of : * doing a little bit of work * using yield or sleep to let other threads work in parrallel That would depend on what you actually want to do in your thread
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You should use Thread Pools, <http://java.sun.com/docs/books/tutorial/essential/concurrency/pools.html>
Naïve idea : you might be able to create Thread, give it a low priority, and do a loop of : * doing a little bit of work * using yield or sleep to let other threads work in parrallel That would depend on what you actually want to do in your thread
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You want to make a new thread; depending on how long the method needs to be, you can make it inline: ``` // some code new Thread(new Runnable() { @Override public void run() { // do stuff in this thread } }).start(); ``` Or just make a new class: ``` public class MyWorker extends Thread { public...
Yes, you're going to want to spin the operation off on to it's own thread. Adding new threads can be a little dangerous if you aren't careful and aware of what that means and how resources will interact. Here is a good [introduction to threads](http://www.javabeginner.com/learn-java/java-threads-tutorial) to help you g...
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You want to make a new thread; depending on how long the method needs to be, you can make it inline: ``` // some code new Thread(new Runnable() { @Override public void run() { // do stuff in this thread } }).start(); ``` Or just make a new class: ``` public class MyWorker extends Thread { public...
You should use Thread Pools, <http://java.sun.com/docs/books/tutorial/essential/concurrency/pools.html>
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You want to make a new thread; depending on how long the method needs to be, you can make it inline: ``` // some code new Thread(new Runnable() { @Override public void run() { // do stuff in this thread } }).start(); ``` Or just make a new class: ``` public class MyWorker extends Thread { public...
Make a thread. Mark this thread as Daemon. The JVM exits when the only thread running are all daemon threads.
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You should use Thread Pools, <http://java.sun.com/docs/books/tutorial/essential/concurrency/pools.html>
Yes, you're going to want to spin the operation off on to it's own thread. Adding new threads can be a little dangerous if you aren't careful and aware of what that means and how resources will interact. Here is a good [introduction to threads](http://www.javabeginner.com/learn-java/java-threads-tutorial) to help you g...
2,804,376
I was wondering which would be the most efficient approach to implement some kind of background task in java (I guess that would be some kind of nonblocking Threads). To be more precise - I have some java code and then at some point I need to execute a long running operation. What I would like to do is to execute that ...
2010/05/10
[ "https://Stackoverflow.com/questions/2804376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181150/" ]
You should use Thread Pools, <http://java.sun.com/docs/books/tutorial/essential/concurrency/pools.html>
Make a thread. Mark this thread as Daemon. The JVM exits when the only thread running are all daemon threads.
35,138
I have just installed ubuntu (11.04). I have installed apache/mysql/php etc. I have a few sites sitting in ``` /var/www/site1 /var/www/site2 /var/www/site3 ``` I want to be able to access these at ``` http://site1.local http://site2.local http://site3.local ``` So in my hosts file I have ``` 127.0....
2011/04/14
[ "https://askubuntu.com/questions/35138", "https://askubuntu.com", "https://askubuntu.com/users/14127/" ]
File: **/etc/hosts** ``` 127.0.0.1 site1.local 127.0.0.1 site2.local 127.0.0.1 site3.local ``` File: **/etc/apache2/apache2.conf** ``` [...] NameVirtualHost *:80 [...] ``` Files: **/etc/apache2/sites-available/site{i}.local.conf** (instead of {i} insert number: 1 or 2 or 3) ``` <VirtualHost *:80> ServerName ...
There is a script that makes this simple for you - <https://github.com/RoverWire/virtualhost> This eventually does the same thins as explained by the answers given but does it in just one command eg. - ``` sudo virtualhost create mysite.local my_site ``` It also allows you to delete a host you created ``` sudo vi...
251,223
My goal is to obtain the function $s$ defined in the code below as a function of $\chi\_1$, $\chi\_2$, $\chi\_3$. The code runs but never ends, although the problem does not seem too hard to solve for a computer. Any idea what the problem could be? I believe it should be solvable, unless the $\chi$'s are not all indepe...
2021/07/19
[ "https://mathematica.stackexchange.com/questions/251223", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/68480/" ]
`Hue` uses the HSB color space which is a cylindrical transformation of the RGB color space. Like you say, this means that `Hue[0]` and `Hue[1]` are both red, which is why you get the same colors in the center and outer ring. You'll want to change your `ColorFunction` to go from about `Hue[0.7]` for blue in the outer r...
There are many pre-defined color gradients ``` ColorData["Gradients"] (* {"AlpineColors", "Aquamarine", "ArmyColors", "AtlanticColors", \ "AuroraColors", "AvocadoColors", "BeachColors", "BlueGreenYellow", \ "BrassTones", "BrightBands", "BrownCyanTones", "CandyColors", "CherryTones", \ "CMYKColors", "CoffeeTones", "Da...
64,916
> > 1) ごはんを食べて、ねました。 > > 2) あさおきて、新聞を読みました。 > > > I was wondering, if the part [食べて] and [おきて] are also past tense, because of [~ました]. So the correct translation would be [I went to bed, after I ate.] or is it [I went to bed, after eating.]? Somehow I can't find similar question to this. Anyway, thank you ver...
2019/01/15
[ "https://japanese.stackexchange.com/questions/64916", "https://japanese.stackexchange.com", "https://japanese.stackexchange.com/users/32440/" ]
The -te construction is used here to describe one event happening after another. More exact translations might be "I ate dinner, then went to bed" or "I woke up, then read the paper." If you wanted to write "I went to bed after I ate", you might use "食べた後で寝ました" or similar.
Technically speaking, the ~て verbs are not in a "tense": the て ending is a conjunctive or connective form, basically meaning that the action of the verb happens, and then the next thing happens. The て ending itself suggests that the action of the verb **completes** (technically a kind of [grammatical aspect](https://en...
47,462
In a study, [linked here](https://www.preprints.org/manuscript/202004.0381/v1/download), a Brazilian institute says that hydroxychloroquine associated with azithromycin is associated with reduced hospitalization rate when given quickly to people showing symptoms of Covid-19. How serious and trustworthy is that study?
2020/04/25
[ "https://skeptics.stackexchange.com/questions/47462", "https://skeptics.stackexchange.com", "https://skeptics.stackexchange.com/users/55460/" ]
[USA Today: "COVID-19 treatment: FDA says hydroxychloroquine touted by Trump is not safe or effective", 19 May 2020](https://www.usatoday.com/story/news/2020/04/24/covid-19-treatment-fda-says-hydroxychloroquine-not-safe-effective/3020046001/): > > The Food and Drug Administration is warning against the use of two > d...
The peer-reviewed version of the Pagliaro et al. preprint mentioned by the OP is [here](http://www.medicineresearch.org/EN/10.21127/yaoyimr20200014) and appears to have been published in September 2020. [This meta-analysis](https://www.cochranelibrary.com/cdsr/doi/10.1002/14651858.CD013587.pub2/full) (Cochrane review,...
140,360
I was told that saying ***Like I said*** isn't grammatically correct although it is used a lot. That we should use ***As I said*** instead. Is it true?
2013/12/04
[ "https://english.stackexchange.com/questions/140360", "https://english.stackexchange.com", "https://english.stackexchange.com/users/58879/" ]
*Like I said* is much more informal than *As I said*, but the former isn't ungrammatical. In formal writing you may prefer to use *as*, but in speech or less formal writing *like* is fine.
The increasing use of "like" pushing away "as" (expressing comparison) - especially in colloqial language - may be explained with the fact that the function word "as" has too many meanings.
58,291,915
``` function test(n) { let y = 0 let x = y / 2 while (y < n) { console.log('add'); y++; } console.log(y); console.log(x); } test(6); //x prints out 0 instead of 3 ``` `x` is supposed to change as `y` changes. How do I keep these variables synchronized?
2019/10/08
[ "https://Stackoverflow.com/questions/58291915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12183923/" ]
If you want to keep the variables in sync all the time, you can create an object having `y` and a `getter` method for `x` which returns the value dependent on current value of `y` ```js let obj = { y: 0, get x() { return this.y / 2; } }; function test(n) { while (obj.y < n) { console.log("add"...
There's nothing that does that automatically, you need to do it yourself. ``` while (y < n) { console.log('add'); y++; } x = y/2; ``` If the second variable is always the same function of the first variable, are you sure you need two variables?
58,291,915
``` function test(n) { let y = 0 let x = y / 2 while (y < n) { console.log('add'); y++; } console.log(y); console.log(x); } test(6); //x prints out 0 instead of 3 ``` `x` is supposed to change as `y` changes. How do I keep these variables synchronized?
2019/10/08
[ "https://Stackoverflow.com/questions/58291915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12183923/" ]
If you want to keep the variables in sync all the time, you can create an object having `y` and a `getter` method for `x` which returns the value dependent on current value of `y` ```js let obj = { y: 0, get x() { return this.y / 2; } }; function test(n) { while (obj.y < n) { console.log("add"...
In general, your best option will likely be to use a function to calculate the value when it's called, particularly if you're doing inexpensive calculations. Think of it as an algebraic expression. Consider the following: ```js function x(y) { return y / 2 } function test(n) { let y = 0 while (y < n) { ...
58,291,915
``` function test(n) { let y = 0 let x = y / 2 while (y < n) { console.log('add'); y++; } console.log(y); console.log(x); } test(6); //x prints out 0 instead of 3 ``` `x` is supposed to change as `y` changes. How do I keep these variables synchronized?
2019/10/08
[ "https://Stackoverflow.com/questions/58291915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12183923/" ]
If you want to keep the variables in sync all the time, you can create an object having `y` and a `getter` method for `x` which returns the value dependent on current value of `y` ```js let obj = { y: 0, get x() { return this.y / 2; } }; function test(n) { while (obj.y < n) { console.log("add"...
If x is always half of y, then why do you need X?
41,522,900
I'm trying to build an application on Laravel 5.3 where my models, database and controllers are in separate folders. I have the following folder structure: ``` Nitseditor System Controllers Database 2016_12_28_130149_create_domains_table.php 2017_01_06_193355_create_themes_t...
2017/01/07
[ "https://Stackoverflow.com/questions/41522900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6085328/" ]
sorry for my short comment as answer... I have not enough reputation for comment, change your `themes()` method to : ``` public function themes() { return $this->belongsToMany('Nitseditor\System\Models\Theme'); } ``` see [Here](https://laravel.com/docs/4.2/eloquent#many-to-many) for more info
Table name should be called `domain_theme`. If you've used corrent names for foreign keys and have built correct relationships, [`whereHas()`](https://laravel.com/docs/5.3/eloquent-relationships#querying-relationship-existence) will work for you: ``` $domainName = 'example.com'; $themes = Theme::whereHas('domains', f...
18,907,004
Here is the HTML version form I need to create using jquery... ``` <form id="loginForm" class="loginLabel" action="login/login.php" method="post"> Username : <input type="text" name="Username" ><br> Password : <input type="password" name="Password" ><br> <input type="Submit" name="login_Submit" value="Logi...
2013/09/20
[ "https://Stackoverflow.com/questions/18907004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2041707/" ]
[`.text()`](http://api.jquery.com/text/) overwrites the entire content of the element, use `.append()` instead of `.text()` ``` $(loginForm).attr("id","loginForm" ) .attr("class", "loginLabel") .append("Username : ") .append(userInput) .append(br) .append("Password : ") ...
Because text function will replace all the things in the DOM Node with new value. Why not just use string concatenation: ``` <div id="loginWrapper"></div> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> <script> var html = '<form id="loginForm" class="loginLabel" actio...
18,907,004
Here is the HTML version form I need to create using jquery... ``` <form id="loginForm" class="loginLabel" action="login/login.php" method="post"> Username : <input type="text" name="Username" ><br> Password : <input type="password" name="Password" ><br> <input type="Submit" name="login_Submit" value="Logi...
2013/09/20
[ "https://Stackoverflow.com/questions/18907004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2041707/" ]
[`.text()`](http://api.jquery.com/text/) overwrites the entire content of the element, use `.append()` instead of `.text()` ``` $(loginForm).attr("id","loginForm" ) .attr("class", "loginLabel") .append("Username : ") .append(userInput) .append(br) .append("Password : ") ...
Musa is correct `.text()` will overwrite, to get around this you can use `document.createTextNode(data);` to create a textNode to append these to your form. working fiddle: <http://jsfiddle.net/QDpsP/9/> <https://developer.mozilla.org/en-US/docs/Web/API/document.createTextNode>
36,489,284
[GAE page](http://i.stack.imgur.com/vsIdV.png) As suggested by GAE, I have added the retry parameter as(copied from the GAE website): ``` - retry_parameters min_backoff_seconds: 2.5 max_doublings: 5 ``` But when I'm trying to deploy my project, it gives the following error: "Error parsing yaml f...
2016/04/08
[ "https://Stackoverflow.com/questions/36489284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5560740/" ]
Remove the hyphen from `retry_parameters`. Also, the parameters to `retry_parameters` should be indented by one more level. ``` cron: - description: daily reports and exports url: /admin/reports/reportsdaily schedule: every 10 mins retry_parameters: min_backoff_seconds: 2.5 max_doublings: 5 ```
That's not valid yaml, from what I can tell. Assuming it's the example on <https://cloud.google.com/appengine/docs/python/config/cron>. Try adding a colon after `retry_parameters`. The parameters to retry\_parameters should be indented by one more level. ``` cron: - description: retry demo url: /retry schedule: ev...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
In n-bit two's complement, bits have value: > > bit 0 = 20 > > bit 1 = 21 > > bit n-2 = 2n-2 > > bit n-1 = -2n-1 > > > But bit n-1 has value 2n-1 when unsigned, so the number is 2n too high. Subtract 2n if bit n-1 is set: ``` >>> def twos_complement(hexstr,bits): ... value = int(hexstr,16) ... ...
``` import struct ``` For Python 3 (with comments' help): ``` h = '9DA92DAB' struct.unpack('>i', bytes.fromhex(h)) ``` For Python 2: ``` h = '9DA92DAB' struct.unpack('>i', h.decode('hex')) ``` or if it is little endian: ``` h = '9DA92DAB' struct.unpack('<i', h.decode('hex')) ```
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
In n-bit two's complement, bits have value: > > bit 0 = 20 > > bit 1 = 21 > > bit n-2 = 2n-2 > > bit n-1 = -2n-1 > > > But bit n-1 has value 2n-1 when unsigned, so the number is 2n too high. Subtract 2n if bit n-1 is set: ``` >>> def twos_complement(hexstr,bits): ... value = int(hexstr,16) ... ...
Here's a general function you can use for hex of any size: ``` import math # hex string to signed integer def htosi(val): uintval = int(val,16) bits = 4 * (len(val) - 2) if uintval >= math.pow(2,bits-1): uintval = int(0 - (math.pow(2,bits) - uintval)) return uintval ``` And to use it: ``` h...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
In n-bit two's complement, bits have value: > > bit 0 = 20 > > bit 1 = 21 > > bit n-2 = 2n-2 > > bit n-1 = -2n-1 > > > But bit n-1 has value 2n-1 when unsigned, so the number is 2n too high. Subtract 2n if bit n-1 is set: ``` >>> def twos_complement(hexstr,bits): ... value = int(hexstr,16) ... ...
This works for 16 bit signed ints, you can extend for 32 bit ints. It uses the basic definition of [2's complement signed numbers.](https://en.wikipedia.org/wiki/Two%27s_complement#Why_it_works) Also note xor with 1 is the same as a binary negate. ``` # convert to unsigned x = int('ffbf', 16) # example (-65) # check s...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
In n-bit two's complement, bits have value: > > bit 0 = 20 > > bit 1 = 21 > > bit n-2 = 2n-2 > > bit n-1 = -2n-1 > > > But bit n-1 has value 2n-1 when unsigned, so the number is 2n too high. Subtract 2n if bit n-1 is set: ``` >>> def twos_complement(hexstr,bits): ... value = int(hexstr,16) ... ...
It's a very late answer, but here's a function to do the above. This will extend for whatever length you provide. Credit for portions of this to another SO answer (I lost the link, so please provide it if you find it). ``` def hex_to_signed(source): """Convert a string hex value to a signed hexidecimal value. ...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
``` import struct ``` For Python 3 (with comments' help): ``` h = '9DA92DAB' struct.unpack('>i', bytes.fromhex(h)) ``` For Python 2: ``` h = '9DA92DAB' struct.unpack('>i', h.decode('hex')) ``` or if it is little endian: ``` h = '9DA92DAB' struct.unpack('<i', h.decode('hex')) ```
Here's a general function you can use for hex of any size: ``` import math # hex string to signed integer def htosi(val): uintval = int(val,16) bits = 4 * (len(val) - 2) if uintval >= math.pow(2,bits-1): uintval = int(0 - (math.pow(2,bits) - uintval)) return uintval ``` And to use it: ``` h...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
``` import struct ``` For Python 3 (with comments' help): ``` h = '9DA92DAB' struct.unpack('>i', bytes.fromhex(h)) ``` For Python 2: ``` h = '9DA92DAB' struct.unpack('>i', h.decode('hex')) ``` or if it is little endian: ``` h = '9DA92DAB' struct.unpack('<i', h.decode('hex')) ```
This works for 16 bit signed ints, you can extend for 32 bit ints. It uses the basic definition of [2's complement signed numbers.](https://en.wikipedia.org/wiki/Two%27s_complement#Why_it_works) Also note xor with 1 is the same as a binary negate. ``` # convert to unsigned x = int('ffbf', 16) # example (-65) # check s...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
``` import struct ``` For Python 3 (with comments' help): ``` h = '9DA92DAB' struct.unpack('>i', bytes.fromhex(h)) ``` For Python 2: ``` h = '9DA92DAB' struct.unpack('>i', h.decode('hex')) ``` or if it is little endian: ``` h = '9DA92DAB' struct.unpack('<i', h.decode('hex')) ```
It's a very late answer, but here's a function to do the above. This will extend for whatever length you provide. Credit for portions of this to another SO answer (I lost the link, so please provide it if you find it). ``` def hex_to_signed(source): """Convert a string hex value to a signed hexidecimal value. ...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
Here's a general function you can use for hex of any size: ``` import math # hex string to signed integer def htosi(val): uintval = int(val,16) bits = 4 * (len(val) - 2) if uintval >= math.pow(2,bits-1): uintval = int(0 - (math.pow(2,bits) - uintval)) return uintval ``` And to use it: ``` h...
It's a very late answer, but here's a function to do the above. This will extend for whatever length you provide. Credit for portions of this to another SO answer (I lost the link, so please provide it if you find it). ``` def hex_to_signed(source): """Convert a string hex value to a signed hexidecimal value. ...
6,727,875
How do I convert a hex string to a signed int in Python 3.2? The best I can come up with is ``` h = '9DA92DAB' b = bytes(h, 'utf-8') ba = binascii.a2b_hex(b) print(int.from_bytes(ba, byteorder='big', signed=True)) ``` Is there a simpler way? Unsigned is so much easier: int(h, 16) BTW, the origin of the question is...
2011/07/18
[ "https://Stackoverflow.com/questions/6727875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173922/" ]
This works for 16 bit signed ints, you can extend for 32 bit ints. It uses the basic definition of [2's complement signed numbers.](https://en.wikipedia.org/wiki/Two%27s_complement#Why_it_works) Also note xor with 1 is the same as a binary negate. ``` # convert to unsigned x = int('ffbf', 16) # example (-65) # check s...
It's a very late answer, but here's a function to do the above. This will extend for whatever length you provide. Credit for portions of this to another SO answer (I lost the link, so please provide it if you find it). ``` def hex_to_signed(source): """Convert a string hex value to a signed hexidecimal value. ...
38,421,186
I have two string ``` private StringProperties firstName; private StringProperties lastName; private StringProperties nickName; ``` the first and last name are picked by user, the nickName is a concatenation of first 3 character of first and lastname How i can do that? Actually i initialize it like that (this is t...
2016/07/17
[ "https://Stackoverflow.com/questions/38421186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6088149/" ]
You should use `ReadOnlyStringProperty` for the nickname: ``` private ReadOnlyStringWrapper nickName= new ReadOnlyStringWrapper(); ... public final String getNickName() { return nickName.get(); } public final ReadOnlyStringProperty nickNameProperty() { return nickName.getReadOnlyProperty(); } ``` As for bin...
You can use `Bindings.format`: ``` nickName.bind(Bindings.format("%.3s%.3s", firstName, lastName)); ``` The `3` in `%.3s` is the maximum length of the string. --- This won't do any trimming of the strings though, (you could do that before passing the strings to `firstName` and `lastName`). It will also work on s...
61,492,353
I'm learning OpenGL, and I've been experimenting with creating widgets for a GUI. Rendering a monochrome box as `(pos, color)[4]` seems a little wasteful to me. Is there a way to pack this down to `(x, y, w, h, color)`? I'm not going to be drawing enough rects that it's going to matter much, but I'm curious. Note: I'...
2020/04/29
[ "https://Stackoverflow.com/questions/61492353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4591180/" ]
Alright, so after some experimenting with the hint given by Spektre, I think I have a solution. I've taken to representing a shape as: ``` struct Shape { enum Kind : byte { LineRect, FillRect, ... } float2 position, extent; uint color; Kind kind; } ``` The vertex shader takes that struct, a...
Well, you can somehow abstract the code to some class that uses these parameters, something like SDL2 has done. There is no OpenGL Class that can help you with these questions. Something Like: ``` struct Vertex { glm::vec3 position; glm::vec3 color; }; class Model { private: std::vector<Vertex> mVertices; ...
46,084,421
Suppose `S` is the SHA of a git commit. How can we express the range `S^..S` without the annoyance of repeating S? In other words, "give me the one-commit range ending in commit S". (And is there way which generalizes to N commits ending in S?) I read `man gitrevisions` backwards and forwards; didn't find anything.
2017/09/06
[ "https://Stackoverflow.com/questions/46084421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1250772/" ]
I think you are searching for `<tree-ish>^!` See [gitrevisions](https://git-scm.com/docs/gitrevisions#gitrevisions-emltrevgtemegemHEADem) documentation for details: Repeated for convenience: > > `<rev>^!, e.g. HEAD^!` > > > A suffix `^` followed by an exclamation mark is the same as giving commit `<rev>` and then...
You could wrap this up into a tidy little git alias: ``` git config --global alias.range '!bash -c "git $1 ${2-HEAD}~$3..${2-HEAD}" -' ``` Breaking down: 1. Create the global alias range ``` git config --global alias.range ``` 2. Call an external bash command ``` '!bash -c "<command>" -' ``` 3. Call git with th...
34,317,753
I have a python 3 script that using libraries urllib.request and BeautifulSoup load content of an website, and export informations from it to csv file or MySQL database. Here are main lines of code from script: ``` # ... url = urllib.request.urlopen("<urls here>") html = url.read() url.close() soup = BeautifulSoup(h...
2015/12/16
[ "https://Stackoverflow.com/questions/34317753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5687084/" ]
If you are running into performance issues, I would recommend you start [profiling](https://docs.python.org/2/library/profile.html) your code. This will give you a pretty detailed idea about where your code spends most of its time running. You could also measure the time it takes for the script to scrap each web page, ...
I would recommend [`simple-requests`](http://pythonhosted.org/simple-requests/), something like: ``` from simple_requests import Requests # Creates a session and thread pool requests = Requests(concurrent=2, minSecondsBetweenRequests=0.15) # Cookies are maintained in this instance of Requests, so subsequent requests...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
For people who encounter this question in the future, adding `adapter: nil` to the `render: json...` will work (instead of `serializer: nil`)
Just a heads up that @dbj's answer, while correct, won't work in Rails4 due to the fact that respond\_with was moved. > > NoMethodError: The `respond_with` feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: > gem 'responders', '~> 2.0' > Consult the Rails upgr...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
I know the question is kind of old and the solutions offered here are outdated just wanted to share my solution to have [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers) and [FastJsonApi](https://github.com/Netflix/fast_jsonapi) by Netflix The solution I made works for `ActiveModel::Ser...
I don't know if there's an elegant solution. It looks like you'd have to monkeypatch ActionController::Serialization - <https://github.com/rails-api/active_model_serializers/blob/5a92e00b51927c9c0e7c90f92c825aff09314bfd/lib/action_controller/serialization.rb>. The minimal change would probably by overriding the `build...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
You can also do: ``` respond_with @your_object, serializer: nil ```
Just a heads up that @dbj's answer, while correct, won't work in Rails4 due to the fact that respond\_with was moved. > > NoMethodError: The `respond_with` feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: > gem 'responders', '~> 2.0' > Consult the Rails upgr...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
You can override the `default_serializer_options` method on a controller to disable serializers for all actions in that controller. ``` def default_serializer_options { serializer: nil } end ``` We're currently generating our JSON in other ways, but I wanted to investigate `ActiveModel::Serializers` for a pa...
Just a heads up that @dbj's answer, while correct, won't work in Rails4 due to the fact that respond\_with was moved. > > NoMethodError: The `respond_with` feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: > gem 'responders', '~> 2.0' > Consult the Rails upgr...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
I was having an issue that also required disabling serialization, so I created [this pull request](https://github.com/rails-api/active_model_serializers/pull/458) that adds the ability to disable serialization in a specific controller by calling `disable_serialization` in a controller.
Just a heads up that @dbj's answer, while correct, won't work in Rails4 due to the fact that respond\_with was moved. > > NoMethodError: The `respond_with` feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: > gem 'responders', '~> 2.0' > Consult the Rails upgr...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
For people who encounter this question in the future, adding `adapter: nil` to the `render: json...` will work (instead of `serializer: nil`)
I know the question is kind of old and the solutions offered here are outdated just wanted to share my solution to have [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers) and [FastJsonApi](https://github.com/Netflix/fast_jsonapi) by Netflix The solution I made works for `ActiveModel::Ser...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
For people who encounter this question in the future, adding `adapter: nil` to the `render: json...` will work (instead of `serializer: nil`)
You can override the `default_serializer_options` method on a controller to disable serializers for all actions in that controller. ``` def default_serializer_options { serializer: nil } end ``` We're currently generating our JSON in other ways, but I wanted to investigate `ActiveModel::Serializers` for a pa...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
For people who encounter this question in the future, adding `adapter: nil` to the `render: json...` will work (instead of `serializer: nil`)
I was having an issue that also required disabling serialization, so I created [this pull request](https://github.com/rails-api/active_model_serializers/pull/458) that adds the ability to disable serialization in a specific controller by calling `disable_serialization` in a controller.
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
For people who encounter this question in the future, adding `adapter: nil` to the `render: json...` will work (instead of `serializer: nil`)
I don't know if there's an elegant solution. It looks like you'd have to monkeypatch ActionController::Serialization - <https://github.com/rails-api/active_model_serializers/blob/5a92e00b51927c9c0e7c90f92c825aff09314bfd/lib/action_controller/serialization.rb>. The minimal change would probably by overriding the `build...
20,101,179
We're using [active\_model\_serializers - 0.8.1](https://github.com/rails-api/active_model_serializers/tree/v0.8.1) in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to [rails-api](https://github.com/rails-api/rails-api)'s [ActionController::API]...
2013/11/20
[ "https://Stackoverflow.com/questions/20101179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071550/" ]
I know the question is kind of old and the solutions offered here are outdated just wanted to share my solution to have [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers) and [FastJsonApi](https://github.com/Netflix/fast_jsonapi) by Netflix The solution I made works for `ActiveModel::Ser...
Just a heads up that @dbj's answer, while correct, won't work in Rails4 due to the fact that respond\_with was moved. > > NoMethodError: The `respond_with` feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: > gem 'responders', '~> 2.0' > Consult the Rails upgr...
72,990,836
I'm new to Pyspark. **I would like to find the products not seen after 10 days from the first day they entered the store. And create a column in dataframe and set it to 1 for these products and 0 for the rest.** First I need to group the data based on product\_id, then find the maximum of the seen\_date. And finally c...
2022/07/15
[ "https://Stackoverflow.com/questions/72990836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5711976/" ]
You can use REGEX to search for non-alphabetic or space characters in the string: ``` userName.search(/^[a-zA-Z\s]+$/) ``` The response will be `0` or `-1`. `0` means that no characters except `A-Z`, `a-z` and `space` were found, `-1` means the contrary. Edit: I found similar question with more detailed answers [he...
``` let chars = /[$&+,:;=?@#|'<>.^*()%!-]/g; chars.test(UserName) ``` Use Regular expressions ( Regex ) <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions>
121,804
I hag a previous JSON-LD tag on my products page, which worked well (no errors, and 3 warnings in [Google's Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool?hl=en)). ```html <script type="application/ld+json"> { "@context": "https://schema.org/", "@ty...
2019/03/25
[ "https://webmasters.stackexchange.com/questions/121804", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/74270/" ]
Your markup is valid. But if you move `Product` from the top level to bottom the testing tool suppresses warnings. Look into page with <http://linter.structured-data.org/> - everything is on the place. If you really-really want to see warnings by testing tool, so use an opposite type to `mainEntity` → `mainEntityOfPa...
Thanks to [this answer on stackOverflow](https://stackoverflow.com/a/30506476/4834168), I was able to create a code which worked for both a product and a breadcrumb, using a [named graph](https://www.w3.org/TR/2014/REC-json-ld-20140116/#named-graphs) array : ```js <script type="application/ld+json"> { ...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
Something to think about: Since the coin flips are independent, and assuming the coin is fair, the probability that ten coin flips land heads is: $$P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H) \cdot P(H)\cdot P(H)=(0.5)^{10}$$ The probability that nine coin flips land heads and the tent...
The probability of getting $10$ heads in a row is exactly the same (given a fair coin) as the chance of getting $9$ heads, then a tail. Using your logic, the probability of getting $9$ heads and one tail (in that order) is $\frac{1}{1024}$, so you have only a $\frac{1}{1024}$ chance of surviving. The probability of an...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
If the man had announced at the trial that he was confident in an 0.1% chance of death because he would flip 9 consecutive heads that night, then he would be correct: there is an 0.2% chance of that string of heads occurring. However, he cheated and waited until this monstrously unlikely event happened by exhaustion. N...
The probability of getting $10$ heads in a row is exactly the same (given a fair coin) as the chance of getting $9$ heads, then a tail. Using your logic, the probability of getting $9$ heads and one tail (in that order) is $\frac{1}{1024}$, so you have only a $\frac{1}{1024}$ chance of surviving. The probability of an...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
The probability that a fair coin will come up heads, given that it already has come up heads nine times consecutively, is one half. It would still be one half whatever the history of the way it came up before. This fact is completely consistent with the probability that it will come up heads on the next ten tosses bein...
The probability of getting $10$ heads in a row is exactly the same (given a fair coin) as the chance of getting $9$ heads, then a tail. Using your logic, the probability of getting $9$ heads and one tail (in that order) is $\frac{1}{1024}$, so you have only a $\frac{1}{1024}$ chance of surviving. The probability of an...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
Something to think about: Since the coin flips are independent, and assuming the coin is fair, the probability that ten coin flips land heads is: $$P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H)\cdot P(H) \cdot P(H)\cdot P(H)=(0.5)^{10}$$ The probability that nine coin flips land heads and the tent...
The probability that a fair coin will come up heads, given that it already has come up heads nine times consecutively, is one half. It would still be one half whatever the history of the way it came up before. This fact is completely consistent with the probability that it will come up heads on the next ten tosses bein...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
All the answers provided explain why there is no "paradox." I would like to provide you an answer that is rather intuitive (hopefully) than formal. Your question is a good example of what is known as "gamblers' fallacy" (see, Croson and Sundali (2005)). The fallacy occurs when one wrongly assumes that a bin from which...
If the man had announced at the trial that he was confident in an 0.1% chance of death because he would flip 9 consecutive heads that night, then he would be correct: there is an 0.2% chance of that string of heads occurring. However, he cheated and waited until this monstrously unlikely event happened by exhaustion. N...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
Let $E$ be the event that the first nine flips are all heads and $F$ be the event that the first ten flips are all heads. The probability of getting ten conservative heads in ten flips is small. $P(F) =(0.5)^{10}$. But now it is given that the first nine flips are all heads. So the probability that the tenth flip is al...
The probability of getting $10$ heads in a row is exactly the same (given a fair coin) as the chance of getting $9$ heads, then a tail. Using your logic, the probability of getting $9$ heads and one tail (in that order) is $\frac{1}{1024}$, so you have only a $\frac{1}{1024}$ chance of surviving. The probability of an...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
All the answers provided explain why there is no "paradox." I would like to provide you an answer that is rather intuitive (hopefully) than formal. Your question is a good example of what is known as "gamblers' fallacy" (see, Croson and Sundali (2005)). The fallacy occurs when one wrongly assumes that a bin from which...
The probability that a fair coin will come up heads, given that it already has come up heads nine times consecutively, is one half. It would still be one half whatever the history of the way it came up before. This fact is completely consistent with the probability that it will come up heads on the next ten tosses bein...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
The probability that a fair coin will come up heads, given that it already has come up heads nine times consecutively, is one half. It would still be one half whatever the history of the way it came up before. This fact is completely consistent with the probability that it will come up heads on the next ten tosses bein...
If the man had announced at the trial that he was confident in an 0.1% chance of death because he would flip 9 consecutive heads that night, then he would be correct: there is an 0.2% chance of that string of heads occurring. However, he cheated and waited until this monstrously unlikely event happened by exhaustion. N...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
All the answers provided explain why there is no "paradox." I would like to provide you an answer that is rather intuitive (hopefully) than formal. Your question is a good example of what is known as "gamblers' fallacy" (see, Croson and Sundali (2005)). The fallacy occurs when one wrongly assumes that a bin from which...
Let $E$ be the event that the first nine flips are all heads and $F$ be the event that the first ten flips are all heads. The probability of getting ten conservative heads in ten flips is small. $P(F) =(0.5)^{10}$. But now it is given that the first nine flips are all heads. So the probability that the tenth flip is al...
2,730,687
So - I am no math genius but I do have shower thoughts. And there is one thought about normal distribution that I just couldn't let go. I converted it into a little story to visualize it a little better. Let's see if it makes sense and if it really is a paradox I came up with. Here is the story: A man is in court. He ...
2018/04/10
[ "https://math.stackexchange.com/questions/2730687", "https://math.stackexchange.com", "https://math.stackexchange.com/users/550901/" ]
The answers given so far are all theoretical. Let's be practical. Exercise #1: Go get a coin right now, and a piece of paper. Flip the coin until it comes up heads three times in a row. Now, if the man's theory is correct, it should be more likely that the next toss is tails. Toss the coin one more time and record ...
The probability of getting $10$ heads in a row is exactly the same (given a fair coin) as the chance of getting $9$ heads, then a tail. Using your logic, the probability of getting $9$ heads and one tail (in that order) is $\frac{1}{1024}$, so you have only a $\frac{1}{1024}$ chance of surviving. The probability of an...
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
In some cases, `LIKE` can be faster than an equivalent function like `SUBSTRING` when an index can be utilized. Can you give the exact `SQL`? Sometimes functions can stop the optimizer from being able to use an index. Compare the execution plans.
Have you tried updating the statistics on this table/database? Might be worth a try.
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
It may have just been a poor execution plan that had been cached; Changing to the LIKE statement then just caused a new execution plan to be generated. The same speedup may have been noticed if the person had run sp\_recompile on the table in question and then re-run the = query.
Have you tried updating the statistics on this table/database? Might be worth a try.
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
The other possibility is that this is a complex query and a type conversion is taking place across the = operator for every row. LIKE changes the semantics somewhat so that the type conversion does not have to weigh as heavily in execution planning. I would suggest that your coworker take a look at the execution plan w...
Have you tried updating the statistics on this table/database? Might be worth a try.
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
Well, if he ran the two queries one after the other, then it is quite likely that the data had to read from the disk for the first query, but was still in the RDBMS data cache for the second one... If this is what happened, then if he ran them in the opposite order he would have seen the opposite results... If he use...
Have you tried updating the statistics on this table/database? Might be worth a try.
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
It may have just been a poor execution plan that had been cached; Changing to the LIKE statement then just caused a new execution plan to be generated. The same speedup may have been noticed if the person had run sp\_recompile on the table in question and then re-run the = query.
In some cases, `LIKE` can be faster than an equivalent function like `SUBSTRING` when an index can be utilized. Can you give the exact `SQL`? Sometimes functions can stop the optimizer from being able to use an index. Compare the execution plans.
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
The other possibility is that this is a complex query and a type conversion is taking place across the = operator for every row. LIKE changes the semantics somewhat so that the type conversion does not have to weigh as heavily in execution planning. I would suggest that your coworker take a look at the execution plan w...
In some cases, `LIKE` can be faster than an equivalent function like `SUBSTRING` when an index can be utilized. Can you give the exact `SQL`? Sometimes functions can stop the optimizer from being able to use an index. Compare the execution plans.
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
It may have just been a poor execution plan that had been cached; Changing to the LIKE statement then just caused a new execution plan to be generated. The same speedup may have been noticed if the person had run sp\_recompile on the table in question and then re-run the = query.
The other possibility is that this is a complex query and a type conversion is taking place across the = operator for every row. LIKE changes the semantics somewhat so that the type conversion does not have to weigh as heavily in execution planning. I would suggest that your coworker take a look at the execution plan w...
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
It may have just been a poor execution plan that had been cached; Changing to the LIKE statement then just caused a new execution plan to be generated. The same speedup may have been noticed if the person had run sp\_recompile on the table in question and then re-run the = query.
Well, if he ran the two queries one after the other, then it is quite likely that the data had to read from the disk for the first query, but was still in the RDBMS data cache for the second one... If this is what happened, then if he ran them in the opposite order he would have seen the opposite results... If he use...
265,051
A co-worker recently ran into a situation where a query to look up security permissions was taking ~15 seconds to run using an = comparison on UserID (which is a UNIQUEIDENTIFIER). Needless to say, the users were less than impressed. Out of frustration, my co-worker changed the = comparison to use a LIKE and the query...
2008/11/05
[ "https://Stackoverflow.com/questions/265051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
The other possibility is that this is a complex query and a type conversion is taking place across the = operator for every row. LIKE changes the semantics somewhat so that the type conversion does not have to weigh as heavily in execution planning. I would suggest that your coworker take a look at the execution plan w...
Well, if he ran the two queries one after the other, then it is quite likely that the data had to read from the disk for the first query, but was still in the RDBMS data cache for the second one... If this is what happened, then if he ran them in the opposite order he would have seen the opposite results... If he use...
40,098
I'm an absolute beginner and I'm planning to buy a [Yamaha Pacifica 611HFM](http://www.bax-shop.nl/elektrische-gitaren/yamaha-pacifica-611hfm-elektrische-gitaar-zwart). At the moment I have no idea what else I need in order to start playing the guitar. Could anyone give some suggestions on gear I would need?
2015/12/08
[ "https://music.stackexchange.com/questions/40098", "https://music.stackexchange.com", "https://music.stackexchange.com/users/15581/" ]
Here are a few things you might want to get for an **electric guitar** in addition to what Jamie Brace listed. * **A basic string winder** (around $2.00 US) to make it easier to change your strings when needed. * **A guitar strap**. I recommend a good one. To learn more about why this is important read this - **[Playi...
I'll list some basics for you, but your best bet would be to find a guitar teacher who can explain everything in detail for you. * a guitar * an amplifier * tuner (whether it's a pedal or a clip on, it's essential) * picks (more than just 1, as many as possible of a size and thickness you prefer) * 1/4" jack cable/s *...
70,132
I began my role just few months ago. My responsibilities consist mostly of analyzing data and presenting them internally. During these presentations, my manager is present as I am still at my early days. I have noticed that some of the colleagues to whom I deliver the presentations do not address me. Instead, they add...
2016/06/20
[ "https://workplace.stackexchange.com/questions/70132", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/52990/" ]
If it is bothering you, talk to your boss. If your boss is on board that these questions should come to you instead then they can redirect them in a way that makes it obvious that these questions should go to you instead. It's possible your boss wants those questions to come to them for any number of reasons. Don't be ...
Have better more prepared presentation with an agenda or outline. Have sharp handouts with more detail than the presentation. They may not ask if they see it is something you are planning to cover. If not a lot of pages include the actual analysis as an attachment. Anticipate questions and have good answers. Don't in...
70,132
I began my role just few months ago. My responsibilities consist mostly of analyzing data and presenting them internally. During these presentations, my manager is present as I am still at my early days. I have noticed that some of the colleagues to whom I deliver the presentations do not address me. Instead, they add...
2016/06/20
[ "https://workplace.stackexchange.com/questions/70132", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/52990/" ]
Some of this may be cultural (both cultural to the country you are in or to the organization) and some may be that you are new and have not yet developed a reputation as someone who can provide answers. The first step is to talk to your manager about the workplace culture and determine if the reason why they are goin...
If it is bothering you, talk to your boss. If your boss is on board that these questions should come to you instead then they can redirect them in a way that makes it obvious that these questions should go to you instead. It's possible your boss wants those questions to come to them for any number of reasons. Don't be ...
70,132
I began my role just few months ago. My responsibilities consist mostly of analyzing data and presenting them internally. During these presentations, my manager is present as I am still at my early days. I have noticed that some of the colleagues to whom I deliver the presentations do not address me. Instead, they add...
2016/06/20
[ "https://workplace.stackexchange.com/questions/70132", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/52990/" ]
Some of this may be cultural (both cultural to the country you are in or to the organization) and some may be that you are new and have not yet developed a reputation as someone who can provide answers. The first step is to talk to your manager about the workplace culture and determine if the reason why they are goin...
Have better more prepared presentation with an agenda or outline. Have sharp handouts with more detail than the presentation. They may not ask if they see it is something you are planning to cover. If not a lot of pages include the actual analysis as an attachment. Anticipate questions and have good answers. Don't in...
65,709
Ever since I was a kid, we have routinely brought our own pre-packaged snacks into movies in order to avoid the exorbitant prices of those sold in the theaters. Is it permitted to bring such snacks into a theater according to *halakhah* or is one obligated to buy snacks and drinks there?
2015/11/26
[ "https://judaism.stackexchange.com/questions/65709", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/-1/" ]
There is a simple and easy alternative by which to avoid any questionable behavior. Namely, don't eat snacks during the movie, and enjoy them before or afterward. It's certainly better under halacha to avoid potential violations when possible. When you enter the theater you are agreeing to abide by their rules as thei...
Here are some elements of reasoning about your question: It would seem strange that I can force you to remain hungry and thereby coerce you into buying from me (but you are not forced to put in the theater). If the theater was an individual's house we would say this is preposterous (condition for entry). The right ...
65,709
Ever since I was a kid, we have routinely brought our own pre-packaged snacks into movies in order to avoid the exorbitant prices of those sold in the theaters. Is it permitted to bring such snacks into a theater according to *halakhah* or is one obligated to buy snacks and drinks there?
2015/11/26
[ "https://judaism.stackexchange.com/questions/65709", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/-1/" ]
It may be a chilul Hashem if someone who works there sees you trying to save money at their loss, especially if there is a no food from outside policy. He may think, “I knew it! Jews are cheap” even though we are not. But with all due respect going to the theater itself may be the greater chilul Hashem, as the Gemara i...
Here are some elements of reasoning about your question: It would seem strange that I can force you to remain hungry and thereby coerce you into buying from me (but you are not forced to put in the theater). If the theater was an individual's house we would say this is preposterous (condition for entry). The right ...
11,875,464
I would like to be able to change certain elements on the landing page based on a)whether it was accessed through a search engine or not b)what search keywords were used Is there a way I can change either specific elements on the landing page or the landing page itself based on these criteria? How? Thanks so m...
2012/08/09
[ "https://Stackoverflow.com/questions/11875464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572755/" ]
Maybe these code can help you <http://jsfiddle.net/sechou/UmRph/7/> ``` $("li").hide(); // hide every element first $("li:first").show(); // only display the first one var idx = 0; $("nextbtn").click(function(){ if(idx == $("li").size() -1) idx =0; else idx++; $("li").hide(); ...
Please, If you're going to upload something, make sure it's correct. Your syntax and spelling wasn't correct, for someone of my experience, It's very hard to nut out problems when things are wrong, thankyou for helping all the same, i still managed to get your code working after about 2 hours of fiddling... ``` var...
42,843,891
I am refactoring a stateless functional component to use `branch` and `renderComponent` from `recompose`. The original component looks like this: ``` const Icon = props => { const { type, name } = props let res if (type === 'font') { return (<FontIcon name={name} />) } else if (type === 'svg') { res =...
2017/03/16
[ "https://Stackoverflow.com/questions/42843891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2309862/" ]
`branch` returns a HOC, which accepts a component and return a component, so `branch(...)` is a HOC and `branch(...)(...)` is a component. In your case, because `Icon` is not a component but a HOC, so React can't render it. To fix it, you can move `SvgIcon` out from `branch`'s arguments and apply it to the HOC returne...
You can also just use an if statement instead of branch. Consider that you just had some difficulties doing what an if statement does. Maybe time to reconsider that library ?
1,047,933
If $X$, $Y$ are two independent and identically distributed random variables of mean $0$, it is true that $\mathbb{E}(X - Y)^3 = 0$?
2014/12/02
[ "https://math.stackexchange.com/questions/1047933", "https://math.stackexchange.com", "https://math.stackexchange.com/users/186983/" ]
Let me get you started: if $(X,Y)$ is i.i.d., $(Y,X)$ is distributed like $(X,Y)$ hence $Y-X$ is distributed like $X-Y$ hence $E(u(Y-X))=E(u(X-Y))$ for every $u$ such that the expectations exist. For $u(t)=t^3$ (or any odd function), this yields $E((X-Y)^3)=E((Y-X)^3)=-E((X-Y)^3)$ hence... Thus, the answer is "Yes, pr...
I'll get you started: $$ E(X-Y)^3 = E(X^3)-E(3X^2Y)+E(3XY^2)-E(Y^3) = E(X^3)-3E(X^2)E(Y)+3E(X)E(Y^2)-E(Y^3) $$ The last step followed since $X^2$ is independent of $Y$, and the same for $X$ and $Y^2$. Now, how can you simplify this further?
264,440
I've just started to learn C++. I have this class and I don't know where to put the following two lines because of the catch: ``` delete[] chost; delete[] cport; ``` I think they are in the right place, but I have doubts because in C++ doesn't exist `finally`. Header: ``` #pragma once #include <string> #include "...
2021/07/27
[ "https://codereview.stackexchange.com/questions/264440", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/44890/" ]
> > > ``` > Ephemeris::Ephemeris() > { > } > > ``` > > No need for a constructor if it does nothing. > > > ``` > Ephemeris::~Ephemeris() > { > if (telnet != nullptr) > delete telnet; > } > > ``` > > The test here is pointless, since `delete` works fine with a null argument. We can improve on th...
I agree with everything Toby Speight wrote. I'd like to add: Name things according to what they represent ============================================ You have this line of code: ``` tcp::resolver::iterator iterator = resolver.resolve(query); ``` But while `iterator` is indeed an iterator, that's not what is impor...
264,440
I've just started to learn C++. I have this class and I don't know where to put the following two lines because of the catch: ``` delete[] chost; delete[] cport; ``` I think they are in the right place, but I have doubts because in C++ doesn't exist `finally`. Header: ``` #pragma once #include <string> #include "...
2021/07/27
[ "https://codereview.stackexchange.com/questions/264440", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/44890/" ]
> > > ``` > Ephemeris::Ephemeris() > { > } > > ``` > > No need for a constructor if it does nothing. > > > ``` > Ephemeris::~Ephemeris() > { > if (telnet != nullptr) > delete telnet; > } > > ``` > > The test here is pointless, since `delete` works fine with a null argument. We can improve on th...
If you just started learning C++, I suggest reading through (and bookmarking) the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md). One example that pops out, from your opening remarks, is C.149, R.11, and P.9. That is, rather than being puzzled as to where to put the...
9,599,196
How do I change the font style in a TextView in a Home screen widget?
2012/03/07
[ "https://Stackoverflow.com/questions/9599196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/517561/" ]
If you mean in runtime, a simple way is: Text Size ``` yourRemoteView.setFloat(R.id.textview, "setTextSize", 30); ``` Text Color ``` yourRemoteView.setInt(R.id.textview, "setTextColor", Color.RED); ```
Like this: First, define text styles in `values/styles.xml`: ``` <resources> <style name="AppTheme" parent="android:style/Theme.Light"> .... </style> <style name="WidgetEntryTitle" parent="style/AppTheme"> <item name="android:textSize">24sp</item> <item name="android:textStyle">bol...
250,621
I have bought 4 MvM tour tickets. Enough to get a botkillers, or I have been told at least. Anyway, so I have a few questions. I plan on playing one of 3 classes: * Engie * Pyro * Soldier Now, do I have to play as one class throughout all four tickets? Further to this, if we fail a mission, do we get to start over? ...
2016/01/05
[ "https://gaming.stackexchange.com/questions/250621", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/107125/" ]
You can play as whatever class you want and switch at will between waves. After switching class you can refund the money spend on other classes to spend it on your new class. At the end of a level you will go back to the menu and chooses another map to play on meaning character wise you will start a fresh selecting a ...
You can always switch classes between waves. You should however think about picking the class you think will have the most effect.
31,602,885
``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Team A" an...
2015/07/24
[ "https://Stackoverflow.com/questions/31602885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150844/" ]
Add `android:gravity=""` attribute to the parent `LinearLayout` of those 3 `TextViews` with value of `center_horizontal`. Those `TextViews` will be centered. ``` <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="cent...
**Use** ``` android:layout_gravity="center_horizontal" in textViews ```
31,602,885
``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Team A" an...
2015/07/24
[ "https://Stackoverflow.com/questions/31602885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150844/" ]
Add `android:gravity=""` attribute to the parent `LinearLayout` of those 3 `TextViews` with value of `center_horizontal`. Those `TextViews` will be centered. ``` <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="cent...
you should set linearLayout fill parent and set Gravity for linearLayout. try this: ``` android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizo...
31,602,885
``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Team A" an...
2015/07/24
[ "https://Stackoverflow.com/questions/31602885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150844/" ]
Add `android:gravity=""` attribute to the parent `LinearLayout` of those 3 `TextViews` with value of `center_horizontal`. Those `TextViews` will be centered. ``` <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="cent...
Make parent layout a `RelativeLayout` instead of `LinearLayout`, and then in you child `LinearLayout` which has the `TextViews` you want in center add these properties ``` android:layout_gravity="center" android:gravity="center_horizontal|center_vertical" ``` or ``` android:layout_centerVertical="true" android:lay...
31,602,885
``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Team A" an...
2015/07/24
[ "https://Stackoverflow.com/questions/31602885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150844/" ]
Add `android:gravity=""` attribute to the parent `LinearLayout` of those 3 `TextViews` with value of `center_horizontal`. Those `TextViews` will be centered. ``` <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="cent...
Try This, ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" and...
31,602,885
``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Team A" an...
2015/07/24
[ "https://Stackoverflow.com/questions/31602885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150844/" ]
Add `android:gravity=""` attribute to the parent `LinearLayout` of those 3 `TextViews` with value of `center_horizontal`. Those `TextViews` will be centered. ``` <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="cent...
you can use the following xml. in this xml using the advantages of the `android:weightSum` property ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical...
31,602,885
``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Team A" an...
2015/07/24
[ "https://Stackoverflow.com/questions/31602885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150844/" ]
Add `android:gravity=""` attribute to the parent `LinearLayout` of those 3 `TextViews` with value of `center_horizontal`. Those `TextViews` will be centered. ``` <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="cent...
If you would like specific control of location of xml widgets within your layout then I recommend using a RelativeLayout. Then you can use: android:layout\_below="@+id/yourTextviewId" etc. to place widgets with respect to each other and you can use: android:layout\_alignParentBottom="true" etc. to align them with r...
157,817
I'm creating the theme with two styles, dark and light. User can choose which style he wants in theme settings. My default theme logo is in the root of the theme. Now I want to change default logo according to choosen style, so if the user choose dark style and doesn't set logo image, default logo is `logo.png` form t...
2015/05/09
[ "https://drupal.stackexchange.com/questions/157817", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/14487/" ]
If I understand the question correctly, this can easily be done using Views alone with a nice tabbed menu: * Create your view page as normal, with the default information provided, except for the url - set that to whatever you want, in my example /tabs * change the Display name under Page details to: Base (just to mak...
You can remove title by setting it to `<none>` or leaving it empty. Then other block can be used to look like title with links on it.
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
Adding logins means adding *alternative* methods to access your account; see [this page](https://stackoverflow.com/help/edit-credentials) for details. Thus, additional logins cannot reduce the risk of hostile hijack; in fact, they can only *increase* the risk since they provide additional entry routes for the attacker...
Simply put, additional logins would have 2 effects: * **It increases the risk** of attacks and account compromission but on the other hand, * **It lowers the impact** of a successful attack by limiting the perimeter of data accessed. Then it's up to you to decide based on the risk you accept, and the balance you wa...
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
Adding logins means adding *alternative* methods to access your account; see [this page](https://stackoverflow.com/help/edit-credentials) for details. Thus, additional logins cannot reduce the risk of hostile hijack; in fact, they can only *increase* the risk since they provide additional entry routes for the attacker...
Before addressing the "hacker gaining access to my Stack Exchange account" using 3rd party authentication, shouldn't you be addressing the security of your 3rd party OpenID/OAuth provider? Sign up for two-factor authentication.
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
Adding logins means adding *alternative* methods to access your account; see [this page](https://stackoverflow.com/help/edit-credentials) for details. Thus, additional logins cannot reduce the risk of hostile hijack; in fact, they can only *increase* the risk since they provide additional entry routes for the attacker...
My recommendation is either: 1, based on Stack Exchange's own login system. There's absolutely no good reason to crosslink systems. or 1, based on some trusted shared identity hub, if you're already using such a hub other than Stack Exchange's own system. Assuming you have found a single-sign-on system that you do ...
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
If someone compromises your StackExchange account can't they just unlink all your recovery options? Assuming they can't, the model is that: * Losing any of the accounts linked to SE is a "compromise". * If any of the *other* accounts linked to SE is not lost then you can "recover". On this model, 2 seems reasonable b...
Simply put, additional logins would have 2 effects: * **It increases the risk** of attacks and account compromission but on the other hand, * **It lowers the impact** of a successful attack by limiting the perimeter of data accessed. Then it's up to you to decide based on the risk you accept, and the balance you wa...
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
Simply put, additional logins would have 2 effects: * **It increases the risk** of attacks and account compromission but on the other hand, * **It lowers the impact** of a successful attack by limiting the perimeter of data accessed. Then it's up to you to decide based on the risk you accept, and the balance you wa...
Before addressing the "hacker gaining access to my Stack Exchange account" using 3rd party authentication, shouldn't you be addressing the security of your 3rd party OpenID/OAuth provider? Sign up for two-factor authentication.
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
Simply put, additional logins would have 2 effects: * **It increases the risk** of attacks and account compromission but on the other hand, * **It lowers the impact** of a successful attack by limiting the perimeter of data accessed. Then it's up to you to decide based on the risk you accept, and the balance you wa...
My recommendation is either: 1, based on Stack Exchange's own login system. There's absolutely no good reason to crosslink systems. or 1, based on some trusted shared identity hub, if you're already using such a hub other than Stack Exchange's own system. Assuming you have found a single-sign-on system that you do ...
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
If someone compromises your StackExchange account can't they just unlink all your recovery options? Assuming they can't, the model is that: * Losing any of the accounts linked to SE is a "compromise". * If any of the *other* accounts linked to SE is not lost then you can "recover". On this model, 2 seems reasonable b...
Before addressing the "hacker gaining access to my Stack Exchange account" using 3rd party authentication, shouldn't you be addressing the security of your 3rd party OpenID/OAuth provider? Sign up for two-factor authentication.
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
If someone compromises your StackExchange account can't they just unlink all your recovery options? Assuming they can't, the model is that: * Losing any of the accounts linked to SE is a "compromise". * If any of the *other* accounts linked to SE is not lost then you can "recover". On this model, 2 seems reasonable b...
My recommendation is either: 1, based on Stack Exchange's own login system. There's absolutely no good reason to crosslink systems. or 1, based on some trusted shared identity hub, if you're already using such a hub other than Stack Exchange's own system. Assuming you have found a single-sign-on system that you do ...
56,037
On Stack Exchange's [Add Login Credential page](https://security.stackexchange.com/users/login-add), one can add logins with Google, Facebook, Yahoo, etc. How many logins should I have to provide best combination of: * The least chance of a hacker gaining access to my Stack Exchange account. * The best recovery in cas...
2014/04/17
[ "https://security.stackexchange.com/questions/56037", "https://security.stackexchange.com", "https://security.stackexchange.com/users/44839/" ]
Before addressing the "hacker gaining access to my Stack Exchange account" using 3rd party authentication, shouldn't you be addressing the security of your 3rd party OpenID/OAuth provider? Sign up for two-factor authentication.
My recommendation is either: 1, based on Stack Exchange's own login system. There's absolutely no good reason to crosslink systems. or 1, based on some trusted shared identity hub, if you're already using such a hub other than Stack Exchange's own system. Assuming you have found a single-sign-on system that you do ...
56,681,816
I am trying to show `Instructor Profile` component after user clicked `login` button in `Instructor Login Form` **It works fine until I refresh the page, that `User Profile` component disappears after the refresh** Here is the screenshot of the page once a user clicked `login` [![](https://i.stack.imgur.com/YJT4M.pn...
2019/06/20
[ "https://Stackoverflow.com/questions/56681816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7084115/" ]
It's because the ModelBinder is expecting a property in the JSON named `data`, yet you're not sending that; all the properties are in the root object. That would work fine if you were binding to a model, but as you're not you need to amend the data structure in your JS slightly, to this: ``` var data = { data: { ...
```js $(document).ready(function() { $("#btnSaveCustomer").click(function() { debugger; var data = { _DcLink: "1", _Account: "Test", _Name: "TestName", _Title: "Mr", _Init: "T" } $.ajax({ method: "POST", url: '/Customer/SaveCustomer', data: JSON.stringi...
56,681,816
I am trying to show `Instructor Profile` component after user clicked `login` button in `Instructor Login Form` **It works fine until I refresh the page, that `User Profile` component disappears after the refresh** Here is the screenshot of the page once a user clicked `login` [![](https://i.stack.imgur.com/YJT4M.pn...
2019/06/20
[ "https://Stackoverflow.com/questions/56681816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7084115/" ]
It's because the ModelBinder is expecting a property in the JSON named `data`, yet you're not sending that; all the properties are in the root object. That would work fine if you were binding to a model, but as you're not you need to amend the data structure in your JS slightly, to this: ``` var data = { data: { ...
Having same issues. AJAX call fails. If I remove [FromBody] from controller then the ajax call is successful however, the data is null. I am using .NET Core 3.1 and razor pages ``` <script> $(document).ready(function () { var data = { "name": "John Doe" } $.ajax({ url: "/membership/t...
56,681,816
I am trying to show `Instructor Profile` component after user clicked `login` button in `Instructor Login Form` **It works fine until I refresh the page, that `User Profile` component disappears after the refresh** Here is the screenshot of the page once a user clicked `login` [![](https://i.stack.imgur.com/YJT4M.pn...
2019/06/20
[ "https://Stackoverflow.com/questions/56681816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7084115/" ]
change like this; ``` data: {data : JSON.stringify(data)}, ```
```js $(document).ready(function() { $("#btnSaveCustomer").click(function() { debugger; var data = { _DcLink: "1", _Account: "Test", _Name: "TestName", _Title: "Mr", _Init: "T" } $.ajax({ method: "POST", url: '/Customer/SaveCustomer', data: JSON.stringi...
56,681,816
I am trying to show `Instructor Profile` component after user clicked `login` button in `Instructor Login Form` **It works fine until I refresh the page, that `User Profile` component disappears after the refresh** Here is the screenshot of the page once a user clicked `login` [![](https://i.stack.imgur.com/YJT4M.pn...
2019/06/20
[ "https://Stackoverflow.com/questions/56681816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7084115/" ]
Having same issues. AJAX call fails. If I remove [FromBody] from controller then the ajax call is successful however, the data is null. I am using .NET Core 3.1 and razor pages ``` <script> $(document).ready(function () { var data = { "name": "John Doe" } $.ajax({ url: "/membership/t...
```js $(document).ready(function() { $("#btnSaveCustomer").click(function() { debugger; var data = { _DcLink: "1", _Account: "Test", _Name: "TestName", _Title: "Mr", _Init: "T" } $.ajax({ method: "POST", url: '/Customer/SaveCustomer', data: JSON.stringi...
56,681,816
I am trying to show `Instructor Profile` component after user clicked `login` button in `Instructor Login Form` **It works fine until I refresh the page, that `User Profile` component disappears after the refresh** Here is the screenshot of the page once a user clicked `login` [![](https://i.stack.imgur.com/YJT4M.pn...
2019/06/20
[ "https://Stackoverflow.com/questions/56681816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7084115/" ]
change like this; ``` data: {data : JSON.stringify(data)}, ```
Having same issues. AJAX call fails. If I remove [FromBody] from controller then the ajax call is successful however, the data is null. I am using .NET Core 3.1 and razor pages ``` <script> $(document).ready(function () { var data = { "name": "John Doe" } $.ajax({ url: "/membership/t...
633,372
I have two wired connections of which the first has internet via static IPv4 and gateway and the second connects to another network. I want to share internet from first connection over second connection with a different IP-address.
2015/06/07
[ "https://askubuntu.com/questions/633372", "https://askubuntu.com", "https://askubuntu.com/users/417490/" ]
I managed to solve this myself. Here are the steps: 1. `eth0` configured like this ``` ipv4=85.185.254.69,255.255.255.0,85.185.254.66,dns=4.2.2.4. ``` 2. `eth1` configured like this: ``` ipv4=185.185.185.1,255.255.255.0,85.185.254.69. ``` 3. Restart ubuntu. 4. Open terminal and run: ``` sudo bash -c 'echo 1 > /p...
You could've done it easier than this. If your internet connection is established via some sort of routing device you can just make a VLAN for the connection you want to share internet with to make it to have access to the router subnet. <https://wiki.ubuntu.com/vlan> You can do this in Network Manager GUI easily. Af...