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
2,263,313
Why doesn't this [`eval`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/eval) call [`alert("Summer")`](https://developer.mozilla.org/en/window.alert)? ``` eval('(caption="Summer";alert(caption))'); ``` Does it have something to do with the quotes in "Summer"?
2010/02/14
[ "https://Stackoverflow.com/questions/2263313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/272697/" ]
Chrome console: ``` eval('(caption="Summer";alert(caption))') SyntaxError: Unexpected token ; ``` This works: ``` eval('caption="Summer"; alert(caption)') ```
A more better way to do this and avoid syntax problem is to do following, `eval(function(){var x="test"; alert(x)}());`
62,290,526
I got very confused with `Except`, specially since there is no good tutorial around the web. I don't know how can I convert this function from `ExceptT` to `Except`: ```hs data Error = Empty deriving (Show) badFunction :: ExceptT Error IO () badFunction = throwError Empty main :: IO () main = do caught_result <-...
2020/06/09
[ "https://Stackoverflow.com/questions/62290526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11584231/" ]
You write ``` badFunction :: ExceptT Error IO () badFunction = throwError Empty ``` which suggests that it does `IO`. But it doesn't do any `IO`. As Willem Van Onsem points out, one option is to indicate that by using `Except` instead: ``` badFunction :: Except Error () ``` By the definition of `Except`, this is ...
The reason `badFunction` should be an `ExceptT Error IO ()` is because `runExceptT` has type [**`runExceptT :: ExceptT e m a -> m (Either e a)`**](https://hackage.haskell.org/package/transformers-0.5.6.2/docs/Control-Monad-Trans-Except.html#v:runExceptT). Since your main has type `main :: IO ()`, this means that `runEx...
212,641
This is how my render preview looks in eevee: ![eevee](https://i.imgur.com/dKI0GO8.png) However, if I switch to cycles, this happens: ![cycles](https://i.imgur.com/SAsDG2E.png) I've been following a tutorial to get to this point, and I'm really a beginner, any of you have an idea of why this is happening? Am I forced...
2021/02/22
[ "https://blender.stackexchange.com/questions/212641", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/117457/" ]
I just need to uncheck "ambient occlusion". It was making everything way too bright, even with low values.
If you started to make a scene, and always used eevee to do your renders, it will probably look like that. There are meny differences with Eevee and Cycles. I think making the background a little darker might work, and you might have to tweak some settings to make it look right. Eevee isn't bad, I think your render lo...
6,192,699
I'm creating a simple checkout for a client where the visitor can check out via *PayPal*. Currently, my HTML form looks like this: ``` <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <fieldset> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="busine...
2011/05/31
[ "https://Stackoverflow.com/questions/6192699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/102205/" ]
option\_selectX is the name of the parameter in the IPN message. What you'll want to add to the button is this: ``` <input type="hidden" name="on0" value="Size">Size <select name="os0"> <option value="Option 1">Option 1 $10.00</option> <option value="Option 2">Option 2 $12.00</option> <option value="Option 3">Option 3...
If I recall correctly, the custom options you're referring to are simply passed back by PayPal to the callback. The premise being you then tie that particular payment to a particular order which would then have all the options you require specified. I'm not sure if you can get PayPal to do anything with them their end...
6,192,699
I'm creating a simple checkout for a client where the visitor can check out via *PayPal*. Currently, my HTML form looks like this: ``` <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <fieldset> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="busine...
2011/05/31
[ "https://Stackoverflow.com/questions/6192699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/102205/" ]
I had trouble passing custom variables as well, and found out that it was the naming convention that I was getting wrong (probably due to outdated docs). I had been trying to use `option_name1` and `option_selection`, and that wasn't working. After I was this post, I tried `option_select0` and `option_amount0`. But i...
If I recall correctly, the custom options you're referring to are simply passed back by PayPal to the callback. The premise being you then tie that particular payment to a particular order which would then have all the options you require specified. I'm not sure if you can get PayPal to do anything with them their end...
26,236,594
I'm completely new to this, so forgive me if I seem a lot less informed than others. I'm attempting to create a program that will allow me to figure out x using the quadratic equation in combination with the math module. I'm taking Computing so I'd thought I'd try this for a challenge. Me and my teacher looked at it, ...
2014/10/07
[ "https://Stackoverflow.com/questions/26236594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4117199/" ]
Before addressing the actual problem, a few things: * There should be a negative sign in front of the first B. * `b^2` is not equivalent to "b squared"; you want `b**2`. * The equation inside the sqrt should be "B squared minus 4AC"; you wrote "B minus 4AC". Similarly, the B outside the sqrt should not be squared. * ...
you need to use [`cmath`](https://docs.python.org/2/library/cmath.html) module for calculate the negatives sqrt also you cant use `^` for power ! you could use [`math.pow(x, y)`](https://docs.python.org/2/library/math.html#math.pow) function or use `b*b` : ``` import cmath a=int(input("a = ")) b=int(input("b = ")) c=...
26,236,594
I'm completely new to this, so forgive me if I seem a lot less informed than others. I'm attempting to create a program that will allow me to figure out x using the quadratic equation in combination with the math module. I'm taking Computing so I'd thought I'd try this for a challenge. Me and my teacher looked at it, ...
2014/10/07
[ "https://Stackoverflow.com/questions/26236594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4117199/" ]
Before addressing the actual problem, a few things: * There should be a negative sign in front of the first B. * `b^2` is not equivalent to "b squared"; you want `b**2`. * The equation inside the sqrt should be "B squared minus 4AC"; you wrote "B minus 4AC". Similarly, the B outside the sqrt should not be squared. * ...
You could make sure the value is positive by wrapping it in `abs()` to get the absolute value. However, as others have commented that would give a mathematically incorrect result. You can either report "no real roots" or deal with complex numbers (look at the `cmath` module for that). Also, there are mistakes in your ...
92,463
I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in code review for the below code? This is my code for Kth Largest element in an Array. The logic is to create a K size m...
2015/06/02
[ "https://codereview.stackexchange.com/questions/92463", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/74909/" ]
> > Total array size can be equal to INT\_MAX and k can be as small as 2 > > > Why not 1? --- ``` @Override public int compare(Long firstNumber , Long secondNumber) { return (int) (secondNumber - firstNumber); } ``` I found myself several time staring at such a line and being sure, there ca...
In Java 8, you can use [`Comparator.reverseOrder()`](https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#reverseOrder--) instead of writing a custom comparator to do reverse sorting. You would then also avoid the potential overflow from subtracting and casting. ``` PriorityQueue<Long> heap = new Priori...
92,463
I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in code review for the below code? This is my code for Kth Largest element in an Array. The logic is to create a K size m...
2015/06/02
[ "https://codereview.stackexchange.com/questions/92463", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/74909/" ]
> > Total array size can be equal to INT\_MAX and k can be as small as 2 > > > Why not 1? --- ``` @Override public int compare(Long firstNumber , Long secondNumber) { return (int) (secondNumber - firstNumber); } ``` I found myself several time staring at such a line and being sure, there ca...
The class is named `CustomArray` but there is no visible reason why. Even `Solver` would be a better name, because this class certainly *is not* a custom array. The class `DecreasingComparator` should be static, as it makes no reference to members of the enclosing class. And you don't need to create a new instance of ...
92,463
I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in code review for the below code? This is my code for Kth Largest element in an Array. The logic is to create a K size m...
2015/06/02
[ "https://codereview.stackexchange.com/questions/92463", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/74909/" ]
> > Total array size can be equal to INT\_MAX and k can be as small as 2 > > > Why not 1? --- ``` @Override public int compare(Long firstNumber , Long secondNumber) { return (int) (secondNumber - firstNumber); } ``` I found myself several time staring at such a line and being sure, there ca...
This version uses Java 8's streams. I think it is relatively easy to understand, and I think that accounts for a lot in an interview. Sort array and take kth element (skip input.length - k to account for reverse order). ``` public long findKthLargestElement(long[] input, int k) { if(k < 1 || k > input.length) { ...
92,463
I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in code review for the below code? This is my code for Kth Largest element in an Array. The logic is to create a K size m...
2015/06/02
[ "https://codereview.stackexchange.com/questions/92463", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/74909/" ]
In Java 8, you can use [`Comparator.reverseOrder()`](https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#reverseOrder--) instead of writing a custom comparator to do reverse sorting. You would then also avoid the potential overflow from subtracting and casting. ``` PriorityQueue<Long> heap = new Priori...
This version uses Java 8's streams. I think it is relatively easy to understand, and I think that accounts for a lot in an interview. Sort array and take kth element (skip input.length - k to account for reverse order). ``` public long findKthLargestElement(long[] input, int k) { if(k < 1 || k > input.length) { ...
92,463
I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in code review for the below code? This is my code for Kth Largest element in an Array. The logic is to create a K size m...
2015/06/02
[ "https://codereview.stackexchange.com/questions/92463", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/74909/" ]
The class is named `CustomArray` but there is no visible reason why. Even `Solver` would be a better name, because this class certainly *is not* a custom array. The class `DecreasingComparator` should be static, as it makes no reference to members of the enclosing class. And you don't need to create a new instance of ...
This version uses Java 8's streams. I think it is relatively easy to understand, and I think that accounts for a lot in an interview. Sort array and take kth element (skip input.length - k to account for reverse order). ``` public long findKthLargestElement(long[] input, int k) { if(k < 1 || k > input.length) { ...
1,063,086
I made an Access Database that includes dates. I have a Report connected to a query that, when opened, prompts the user for a month in numbers (1-12) in order to produce the report for that months. For example, if I type 4, I get the report for April. The problem is that sometimes I want a full report for all months an...
2016/04/08
[ "https://superuser.com/questions/1063086", "https://superuser.com", "https://superuser.com/users/548741/" ]
fairly simply - add it as a startup script - last line of script after checking all ok etc: rm $0
I've written the 'firstboot' script for multiple physical and virtual storage appliances over the past fifteen years, and always used the 'rm' of the symlink upon successful completion of the first boot to make sure it doesn't run on future boots. The other possibility is setting a sentinel file like '/FIRSTBOOT' upo...
807,156
Let $\rho\in H^{1}(0,\pi)$ be a function, and consider the functional $$ I(\rho)=\bigg(\int\_{0}^{\pi}{\sqrt{\rho^2(t)+\dot\rho^2(t)}\,dt}\bigg)^2. $$ I'm asking if it is equivalent to the norm $$ \lVert \rho \rVert\_{H^1}=\lVert \rho \rVert\_{L^2}+\lVert \dot\rho \rVert\_{L^2} $$ on $H^{1}(0,\pi)$. Obviously $I(\rh...
2014/05/23
[ "https://math.stackexchange.com/questions/807156", "https://math.stackexchange.com", "https://math.stackexchange.com/users/152111/" ]
To be precise, you are asking if $\sqrt{I(\rho)}$ is equivalent to $\|\rho\|\_{H^1}$. As you noted, $\sqrt{I(\rho)}$ is dominated by $\|\rho\|\_{H^1}$. However, the converse fails. Consider $\rho(x)=\sqrt{x+\epsilon}$. Since $\rho'(x) = \dfrac{1}{2\sqrt{x+\epsilon}}$, we have $\|\rho\|\_{H^1}\to\infty$ as $\epsilon \...
The functional $\sqrt{I(\rho)}$ cannot be equivalent to the norm $\|\rho\|\_{H^1}$ becuase the latter cannot be equivalent to the norm $$ \|\rho\|\_{W^{1,1}}=\|\rho\|\_{L^1}+\|\dot{\rho}\|\_{L^1}\,. $$ More precisely, due to an obvious fact $$ \frac{1}{\sqrt{2}}(|\rho|+|\dot{\rho}|)\leqslant\sqrt{|\rho|^2+|\dot{\rho}|...
68,919,409
I have a bash script where I want that script to replace the "IP addresses" in the hosts file by deleting the existing IP addresses. My hosts file contains the below entry.. ``` [buildservers] 10.10.10.01 10.10.10.02 10.10.10.03 [buildservers:vars] ansible_connection=ssh ansible_user=root ``` My expected result aft...
2021/08/25
[ "https://Stackoverflow.com/questions/68919409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16748441/" ]
With Bluetooth it is normal to pass information as a list of bytes(Uint8List). The solution for `float` value is to have an expected exponent. There is more detail in the [GATT Specification Supplement 4](https://www.bluetooth.com/specifications/specs/) especially in section 2 "Values and represented values" If the nu...
The dart:typed\_data library has some useful methods to convert data to bytes. This method worked for me. ``` import 'dart:typed_data'; List<int> doubleToListInt(double value) { ByteData bytes = ByteData(8); bytes.setFloat64(0, value); List<int> response = bytes.buffer.asInt8List().toList(); return respon...
69,001,151
So I have a list of variables (all being integers). I would want to randomly choose one of these variables, but make it so that it returns the actual variable, not the value. for example: ``` list = [a, b, c, d] ``` (with all of them equal to 0) ``` print(random.choice(list)) ``` would return 0, while I want it...
2021/08/31
[ "https://Stackoverflow.com/questions/69001151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16797374/" ]
This may be related to this long open conda issue: <https://github.com/conda/conda/issues/7980> Basically, you can't run conda from within scripts by default. To address this, previously, people had been putting something like the following in their ~/.bashrc or ~/.bash\_profile after the conda stanzas (i.e., after ...
It looks like your conda environment is broken, or you're running snakemake in an environment that doesn't have conda installed. Look at the last line of the error message: ``` subprocess.CalledProcessError: Command 'conda info --json' returned non-zero exit status 127. ``` This is saying that snakemake ran the com...
1,093,516
I have a router I'm playing with and I am curious if it is possible for me to give a custom URL name to the IP of the router, so that people in my house can type `http://www.my-fancy-url.com` rather than `http://aaa.bbb.ccc.ddd`—not only on PCs but also on mobile devices. I heard that I could do this if I make my own ...
2016/06/25
[ "https://superuser.com/questions/1093516", "https://superuser.com", "https://superuser.com/users/610037/" ]
(from: <https://www.pckr.co.uk/arch-grub-mkconfig-lvmetad-failures-inside-chroot-install/> ) try first to disable lvmetad from `/etc/lvm/lvm.conf` and set `use_lvmetad = 0` I had a similar problem on my Arch Linux VM, and following the commands in that blogpost I linked above helped me to get rid of that error. I ho...
the lvmetad thing (while annoying) isn't the problem. The main issue there is Kali is hanging w/ a black screen. You see in the final message that sda5 is clean. So, booting was proceeding. PROBABLY (this is what happened to me, anyway) systemd tried to start X but nothing happened. When this happened to me it was b...
64,451
I'd like to use alternatives to System Center Virtual Machine Manager 2008 is possible, in other words, any FREE tools?
2008/09/15
[ "https://Stackoverflow.com/questions/64451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
Before SCVMM, Microsoft's solution was the [Virtual Server Migration Toolkit](http://technet.microsoft.com/en-us/virtualserver/bb676674.aspx). This requires Windows Server 2003 Automated Deployment Services, which in turn can only be installed on Windows Server 2003 Enterprise Edition. It's about as far from a free too...
Google "Pysical to virtual conversion" or P2V. There are several solutions available. Unfortunately it sounds as though not many have had success with Microsoft's solution. Try the following: 1. Download and install the VMWare Converter and follow the instructions to convert the physical machine. 2. Download the VMWa...
64,451
I'd like to use alternatives to System Center Virtual Machine Manager 2008 is possible, in other words, any FREE tools?
2008/09/15
[ "https://Stackoverflow.com/questions/64451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
Google "Pysical to virtual conversion" or P2V. There are several solutions available. Unfortunately it sounds as though not many have had success with Microsoft's solution. Try the following: 1. Download and install the VMWare Converter and follow the instructions to convert the physical machine. 2. Download the VMWa...
Use VMWare its not free, but you can get a decent 30 day trial, which should be enough to do your conversions. VMWare also has other great advantages if you're willing to pay for the product.
64,451
I'd like to use alternatives to System Center Virtual Machine Manager 2008 is possible, in other words, any FREE tools?
2008/09/15
[ "https://Stackoverflow.com/questions/64451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
Google "Pysical to virtual conversion" or P2V. There are several solutions available. Unfortunately it sounds as though not many have had success with Microsoft's solution. Try the following: 1. Download and install the VMWare Converter and follow the instructions to convert the physical machine. 2. Download the VMWa...
First, backup the physical system to an image, and convert it to a virtual disk which can be directly used in a virtual machine. [See this article](http://www.todo-backup.com/products/features/convert-physical-to-virtual.htm).
64,451
I'd like to use alternatives to System Center Virtual Machine Manager 2008 is possible, in other words, any FREE tools?
2008/09/15
[ "https://Stackoverflow.com/questions/64451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
Before SCVMM, Microsoft's solution was the [Virtual Server Migration Toolkit](http://technet.microsoft.com/en-us/virtualserver/bb676674.aspx). This requires Windows Server 2003 Automated Deployment Services, which in turn can only be installed on Windows Server 2003 Enterprise Edition. It's about as far from a free too...
Use VMWare its not free, but you can get a decent 30 day trial, which should be enough to do your conversions. VMWare also has other great advantages if you're willing to pay for the product.
64,451
I'd like to use alternatives to System Center Virtual Machine Manager 2008 is possible, in other words, any FREE tools?
2008/09/15
[ "https://Stackoverflow.com/questions/64451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
Before SCVMM, Microsoft's solution was the [Virtual Server Migration Toolkit](http://technet.microsoft.com/en-us/virtualserver/bb676674.aspx). This requires Windows Server 2003 Automated Deployment Services, which in turn can only be installed on Windows Server 2003 Enterprise Edition. It's about as far from a free too...
First, backup the physical system to an image, and convert it to a virtual disk which can be directly used in a virtual machine. [See this article](http://www.todo-backup.com/products/features/convert-physical-to-virtual.htm).
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
You can do that with a single statement and a subquery in nearly all relational databases. ``` INSERT INTO targetTable(field1) SELECT field1 FROM myTable WHERE NOT(field1 IN (SELECT field1 FROM targetTable)) ``` Certain relational databases have improved syntax for the above, since what you describe is a fairly com...
It is possible with **`EXISTS`** condition. `WHERE EXISTS` tests for the existence of any records in a subquery. `EXISTS` returns true if the subquery returns one or more records. Here is an example ``` UPDATE TABLE_NAME SET val1=arg1 , val2=arg2 WHERE NOT EXISTS (SELECT FROM TABLE_NAME WHERE val1=arg1 AND val2=...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
It is possible with **`EXISTS`** condition. `WHERE EXISTS` tests for the existence of any records in a subquery. `EXISTS` returns true if the subquery returns one or more records. Here is an example ``` UPDATE TABLE_NAME SET val1=arg1 , val2=arg2 WHERE NOT EXISTS (SELECT FROM TABLE_NAME WHERE val1=arg1 AND val2=...
If you're looking to do an "upsert" one of the most efficient ways currently in SQL Server for single rows is this: ``` UPDATE myTable ... IF @@ROWCOUNT=0 INSERT INTO myTable .... ``` You can also use the `MERGE` syntax if you're doing this with sets of data rather than single rows. If you want to `INSERT` and...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
I dont know about SmallSQL, but this works for MSSQL: ``` IF EXISTS (SELECT * FROM Table1 WHERE Column1='SomeValue') UPDATE Table1 SET (...) WHERE Column1='SomeValue' ELSE INSERT INTO Table1 VALUES (...) ``` Based on the where-condition, this updates the row if it exists, else it will insert a new one. I ho...
If you're looking to do an "upsert" one of the most efficient ways currently in SQL Server for single rows is this: ``` UPDATE myTable ... IF @@ROWCOUNT=0 INSERT INTO myTable .... ``` You can also use the `MERGE` syntax if you're doing this with sets of data rather than single rows. If you want to `INSERT` and...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
You can do that with a single statement and a subquery in nearly all relational databases. ``` INSERT INTO targetTable(field1) SELECT field1 FROM myTable WHERE NOT(field1 IN (SELECT field1 FROM targetTable)) ``` Certain relational databases have improved syntax for the above, since what you describe is a fairly com...
Usually you make the thing you don't want duplicates of unique, and allow the database itself to refuse the insert. Otherwise, you can use INSERT INTO, see [How to avoid duplicates in INSERT INTO SELECT query in SQL Server?](https://stackoverflow.com/questions/2513174/sql-server-insert-into-select-to-avoid-duplicates)
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
You can do that with a single statement and a subquery in nearly all relational databases. ``` INSERT INTO targetTable(field1) SELECT field1 FROM myTable WHERE NOT(field1 IN (SELECT field1 FROM targetTable)) ``` Certain relational databases have improved syntax for the above, since what you describe is a fairly com...
I write this solution based on MERGE statement in SQL Server. Please note that the "source" in MERGE mustn't always be a table. ``` MERGE [my_target_table] t USING (SELECT [val1]=... , [val2]=...) s ON t.[val1]=s.[val1] AND t.[val2]=s.[val2] WHEN MATCHED THEN UPDATE set t.[val1]=s.[val1] , t.[...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
It is possible with **`EXISTS`** condition. `WHERE EXISTS` tests for the existence of any records in a subquery. `EXISTS` returns true if the subquery returns one or more records. Here is an example ``` UPDATE TABLE_NAME SET val1=arg1 , val2=arg2 WHERE NOT EXISTS (SELECT FROM TABLE_NAME WHERE val1=arg1 AND val2=...
I write this solution based on MERGE statement in SQL Server. Please note that the "source" in MERGE mustn't always be a table. ``` MERGE [my_target_table] t USING (SELECT [val1]=... , [val2]=...) s ON t.[val1]=s.[val1] AND t.[val2]=s.[val2] WHEN MATCHED THEN UPDATE set t.[val1]=s.[val1] , t.[...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
I dont know about SmallSQL, but this works for MSSQL: ``` IF EXISTS (SELECT * FROM Table1 WHERE Column1='SomeValue') UPDATE Table1 SET (...) WHERE Column1='SomeValue' ELSE INSERT INTO Table1 VALUES (...) ``` Based on the where-condition, this updates the row if it exists, else it will insert a new one. I ho...
It is possible with **`EXISTS`** condition. `WHERE EXISTS` tests for the existence of any records in a subquery. `EXISTS` returns true if the subquery returns one or more records. Here is an example ``` UPDATE TABLE_NAME SET val1=arg1 , val2=arg2 WHERE NOT EXISTS (SELECT FROM TABLE_NAME WHERE val1=arg1 AND val2=...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
I dont know about SmallSQL, but this works for MSSQL: ``` IF EXISTS (SELECT * FROM Table1 WHERE Column1='SomeValue') UPDATE Table1 SET (...) WHERE Column1='SomeValue' ELSE INSERT INTO Table1 VALUES (...) ``` Based on the where-condition, this updates the row if it exists, else it will insert a new one. I ho...
I write this solution based on MERGE statement in SQL Server. Please note that the "source" in MERGE mustn't always be a table. ``` MERGE [my_target_table] t USING (SELECT [val1]=... , [val2]=...) s ON t.[val1]=s.[val1] AND t.[val2]=s.[val2] WHEN MATCHED THEN UPDATE set t.[val1]=s.[val1] , t.[...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
You can do that with a single statement and a subquery in nearly all relational databases. ``` INSERT INTO targetTable(field1) SELECT field1 FROM myTable WHERE NOT(field1 IN (SELECT field1 FROM targetTable)) ``` Certain relational databases have improved syntax for the above, since what you describe is a fairly com...
If you're looking to do an "upsert" one of the most efficient ways currently in SQL Server for single rows is this: ``` UPDATE myTable ... IF @@ROWCOUNT=0 INSERT INTO myTable .... ``` You can also use the `MERGE` syntax if you're doing this with sets of data rather than single rows. If you want to `INSERT` and...
16,636,723
I have a frame that I want to parse. It is a String, and the fields have no delimiters, and have different lengths. How can I get those fields (using Java)? For example the frame: $XXYYYU# How can I get the content of the fields 'XX', 'YYY' and 'U' ? Thanks!
2013/05/19
[ "https://Stackoverflow.com/questions/16636723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2144555/" ]
I dont know about SmallSQL, but this works for MSSQL: ``` IF EXISTS (SELECT * FROM Table1 WHERE Column1='SomeValue') UPDATE Table1 SET (...) WHERE Column1='SomeValue' ELSE INSERT INTO Table1 VALUES (...) ``` Based on the where-condition, this updates the row if it exists, else it will insert a new one. I ho...
Usually you make the thing you don't want duplicates of unique, and allow the database itself to refuse the insert. Otherwise, you can use INSERT INTO, see [How to avoid duplicates in INSERT INTO SELECT query in SQL Server?](https://stackoverflow.com/questions/2513174/sql-server-insert-into-select-to-avoid-duplicates)
566,935
I've got a simular problem as described in [How can I repair the Windows 8 EFI Bootloader?](https://superuser.com/questions/460762/how-can-i-repair-the-windows-8-efi-bootloader), but with some different details. When I tried to change the bootsequence of my harddisks (of which 1 SSD) in the BIOS (system=Medion Akoya P...
2013/03/16
[ "https://superuser.com/questions/566935", "https://superuser.com", "https://superuser.com/users/207615/" ]
Try not using the "All" part of selecting the firmware in BCDBoot. Had the same problem, but selected just UEFI (my machine has it) and it worked! If you have BIOS just use ``` bcdboot c:\Windows /l nl-NL /s b: /f BIOS ``` Or for UEFI use ``` bcdboot c:\Windows /l nl-NL /s b: /f UEFI ``` Tell me how that goes.
I boot Win8 from USBflash trying repair with most other answers with no result. What helped for me was: `bcdboot d:\Windows /l ru-ru /s c: /f UEFI` I'll mention this happened on ASUS n76vj on 256Gb SSD factory split on 5 partitions
28,852,366
I am trying to create a view similar to the attached image below. there is a variable sized width. I have marked text as black as there is a copyright issue. Can anyone please look into the same and put some code so that it can help me somewhere. Do I need to implement Custom Collection View Layout? Please help me....
2015/03/04
[ "https://Stackoverflow.com/questions/28852366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2193918/" ]
You can set size for every item by impelmenting UICollectionViewDelegateFlowLayout protocol, and calculate item width using even/odd formula. ``` -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)index...
if you are trying to do this without any framework, you need to develop your own algroithm to calculate the width of each cell. first, you need to calculate the width of text plus margin maybe border as well. Second, calculate how many items are gonna be placed in given row. try to add 3 togther , if the total width...
28,852,366
I am trying to create a view similar to the attached image below. there is a variable sized width. I have marked text as black as there is a copyright issue. Can anyone please look into the same and put some code so that it can help me somewhere. Do I need to implement Custom Collection View Layout? Please help me....
2015/03/04
[ "https://Stackoverflow.com/questions/28852366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2193918/" ]
This is response to your comment you need to add 3 extra lines of code in SGSStaggeredFlowLayout ``` NSArray* arr = [super layoutAttributesForElementsInRect:rect]; // THIS CODE SEPARATES INTO ROWS NSMutableArray* rows = [NSMutableArray array]; NSMutableArray* currentRow = nil; NSInteger currentIndex = 0; BOOL nextIsN...
You can set size for every item by impelmenting UICollectionViewDelegateFlowLayout protocol, and calculate item width using even/odd formula. ``` -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)index...
28,852,366
I am trying to create a view similar to the attached image below. there is a variable sized width. I have marked text as black as there is a copyright issue. Can anyone please look into the same and put some code so that it can help me somewhere. Do I need to implement Custom Collection View Layout? Please help me....
2015/03/04
[ "https://Stackoverflow.com/questions/28852366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2193918/" ]
This is response to your comment you need to add 3 extra lines of code in SGSStaggeredFlowLayout ``` NSArray* arr = [super layoutAttributesForElementsInRect:rect]; // THIS CODE SEPARATES INTO ROWS NSMutableArray* rows = [NSMutableArray array]; NSMutableArray* currentRow = nil; NSInteger currentIndex = 0; BOOL nextIsN...
if you are trying to do this without any framework, you need to develop your own algroithm to calculate the width of each cell. first, you need to calculate the width of text plus margin maybe border as well. Second, calculate how many items are gonna be placed in given row. try to add 3 togther , if the total width...
430,432
Parallels Desktop had a great feature "[Coherence mode](https://www.howtogeek.com/307655/HOW-TO-USE-PARALLELS-COHERENCE-MODE-TO-RUN-WINDOWS-AND-MAC-APPS-SIDE-BY-SIDE/)" that displays windows, of the VM, in the macOS UI as if they're part of macOS making the experience much better. I have a powerful Windows (Pro, non-s...
2021/11/08
[ "https://apple.stackexchange.com/questions/430432", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/143745/" ]
When using "plain RDP" it is not possible to achieve something similar to Coherence mode. The reason for that is that the Windows host sends a whole desktop to the remote client without any kind of specification as to where one application or window starts and another ends. I.e. it is desktop centric, and not window or...
This is possible using standard RDP. There are many tutorials on how to set this up on a Windows Server, but it is actually possible to do it on Windows 10 Professional, Education and Enterprise versions as well. All you have to do is open up `regedit` on the Windows machine, then navigate to: ``` HKEY_LOCAL_MACHINE\...
27,514,762
I am trying to put 6 buttons in the middle of the screen and it worked until I added text to one of them, as you can see in the picture below : <https://imgur.com/IxIVgHj> This is the code for the 2 buttons that causes problems : ``` <LinearLayout android:id="@+id/tableRow3" android:padding="5dp" andro...
2014/12/16
[ "https://Stackoverflow.com/questions/27514762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2564360/" ]
If you set `android:baselineAligned="false"` on the `LinearLayout`, then the buttons inside the `LinearLayout` would align properly. Reference: <https://possiblemobile.com/2013/10/shifty-baseline-alignment/>
``` Comment ``` Instead of using a LinearLayout try and use relative layout instead, with an android:gavity of fill\_horizontal, and add a bit of space between your textviews, also try and decrease the padding on the first button.
73,544,842
I have the following vector: ``` v<-c(1,2,3,4,1,2,3,4,2) ``` which I want to "transform" into a 3x3 matrix: ``` matrix <- matrix(data=v,ncol=3) ``` which I then want to "flip" over (not transpose) ``` flip_matrix<-matrix[,3:1,drop=FALSE] ``` It's very easy to use the tidyverse pipe to chain all this but to cu...
2022/08/30
[ "https://Stackoverflow.com/questions/73544842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10743337/" ]
Another way calling the function `[`. ``` v <- c(1,2,3,4,1,2,3,4,2) matrix(data=v,ncol=3) |> `[`(x=_,,3:1, drop = FALSE) # [,1] [,2] [,3] #[1,] 3 4 1 #[2,] 4 1 2 #[3,] 2 2 3 ``` or without placeholder: ``` #Does not work as '[' is currently not supported in RHS call of a pipe #matrix...
We could use a lambda function ``` matrix(data=v,ncol=3) |> {\(x) x[, 3:1, drop = FALSE]}() ``` -output ``` [,1] [,2] [,3] [1,] 3 4 1 [2,] 4 1 2 [3,] 2 2 3 ``` --- Or use `Alias` from `magrittr` ``` library(magrittr) v |> matrix(ncol = 3) |> extract(, 3:1) [,1] [,...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
If I understand your question correctly, you're trying to build a lazy implementation of an enumerator that splits a larger collection of items into smaller enumerable collections of items. For instance, a sequence of a million numbers could be split up into "sections", each producing only 100 of them, and you want it...
Here's another approach not using linq which was much faster then your second method: ``` public static IEnumerable<IEnumerable<a>> Section<a>(this IEnumerable<a> source, int length) { var enumerator = source.GetEnumerator(); var continueLoop = true; do { ...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
Wherever possible, I try to only iterate through a source once within an operator. If the source is something like the result of a `Reverse()` operator, calling `Any`, `Take` and `Skip` could cause a lot of nasty performance. It's not entirely clear what your operator is trying to do, but if you can do it without read...
Do you need to keep your original source around for some reason as you progress? If not, why don't you use recursion and use hd :: tl style to pull the head, pass the tl into the recursive call, and on any even number recursion merge the two you have sitting around into a section? With the updated release of the exper...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
Is this any faster? It should be, because it only needs a single iteration through the source sequence. ``` public static IEnumerable<IEnumerable<T>> Section<T>( this IEnumerable<T> source, int length) { return source .Select((x, i) => new { Value = x, Group = i / length }) .GroupBy(x => x.Grou...
How about an extension method ``` public static class IEnumerableExtensions { public static IEnumerable<List<T>> InSetsOf<T>(this IEnumerable<T> source, int max) { List<T> toReturn = new List<T>(); foreach(var item in source) { toReturn.Add(item); if (toR...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
I suspect that the problem you're having is related to the fact that enumerating the final result is at least an O(n^2) operation, possibly worse; I haven't worked it all out in my head yet. Why is that? Well, suppose you have [1, 2, 3, 4, 5, 6] and you split that up into what you think is { { 1, 2 }, {3, 4}, {5, 6} ...
How about an extension method ``` public static class IEnumerableExtensions { public static IEnumerable<List<T>> InSetsOf<T>(this IEnumerable<T> source, int max) { List<T> toReturn = new List<T>(); foreach(var item in source) { toReturn.Add(item); if (toR...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
Is this any faster? It should be, because it only needs a single iteration through the source sequence. ``` public static IEnumerable<IEnumerable<T>> Section<T>( this IEnumerable<T> source, int length) { return source .Select((x, i) => new { Value = x, Group = i / length }) .GroupBy(x => x.Grou...
I had an idea today; check this out ``` public static IEnumerable<α> Take<α>(this IEnumerator<α> iterator, int count) { for (var i = 0; i < count && iterator.MoveNext(); i++) yield return iterator.Current; } public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerator<α> iterator, int length) { ...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
If I understand your question correctly, you're trying to build a lazy implementation of an enumerator that splits a larger collection of items into smaller enumerable collections of items. For instance, a sequence of a million numbers could be split up into "sections", each producing only 100 of them, and you want it...
Wherever possible, I try to only iterate through a source once within an operator. If the source is something like the result of a `Reverse()` operator, calling `Any`, `Take` and `Skip` could cause a lot of nasty performance. It's not entirely clear what your operator is trying to do, but if you can do it without read...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
I suspect that the problem you're having is related to the fact that enumerating the final result is at least an O(n^2) operation, possibly worse; I haven't worked it all out in my head yet. Why is that? Well, suppose you have [1, 2, 3, 4, 5, 6] and you split that up into what you think is { { 1, 2 }, {3, 4}, {5, 6} ...
Here's another approach not using linq which was much faster then your second method: ``` public static IEnumerable<IEnumerable<a>> Section<a>(this IEnumerable<a> source, int length) { var enumerator = source.GetEnumerator(); var continueLoop = true; do { ...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
Wherever possible, I try to only iterate through a source once within an operator. If the source is something like the result of a `Reverse()` operator, calling `Any`, `Take` and `Skip` could cause a lot of nasty performance. It's not entirely clear what your operator is trying to do, but if you can do it without read...
I had an idea today; check this out ``` public static IEnumerable<α> Take<α>(this IEnumerator<α> iterator, int count) { for (var i = 0; i < count && iterator.MoveNext(); i++) yield return iterator.Current; } public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerator<α> iterator, int length) { ...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
I suspect that the problem you're having is related to the fact that enumerating the final result is at least an O(n^2) operation, possibly worse; I haven't worked it all out in my head yet. Why is that? Well, suppose you have [1, 2, 3, 4, 5, 6] and you split that up into what you think is { { 1, 2 }, {3, 4}, {5, 6} ...
Wherever possible, I try to only iterate through a source once within an operator. If the source is something like the result of a `Reverse()` operator, calling `Any`, `Take` and `Skip` could cause a lot of nasty performance. It's not entirely clear what your operator is trying to do, but if you can do it without read...
2,222,292
I have this query that is bothering me; it is encapsulated as a new query operator, I made two versions of it, trying to see which one performs better. Both perform horribly. First attempt; declarative style ``` public static IEnumerable<IEnumerable<α>> Section<α>(this IEnumerable<α> source, int length) { return ...
2010/02/08
[ "https://Stackoverflow.com/questions/2222292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444976/" ]
I suspect that the problem you're having is related to the fact that enumerating the final result is at least an O(n^2) operation, possibly worse; I haven't worked it all out in my head yet. Why is that? Well, suppose you have [1, 2, 3, 4, 5, 6] and you split that up into what you think is { { 1, 2 }, {3, 4}, {5, 6} ...
Do you need to keep your original source around for some reason as you progress? If not, why don't you use recursion and use hd :: tl style to pull the head, pass the tl into the recursive call, and on any even number recursion merge the two you have sitting around into a section? With the updated release of the exper...
16,555,751
I currently have a Hadoop cluster where I store tons of logs over which I run pig scripts for calculating aggregated analytics. I also have a Mongo cluster where I store production data. I've recently been put in a position where I need to do a lot of one-off analytics queries, or enable others to do them. These quer...
2013/05/15
[ "https://Stackoverflow.com/questions/16555751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392975/" ]
First of all, you should use something which you already can handle. Therefore, Mongo DB seems a good choice, especially when the data is already in the json format. On the other hand, I used HBase quite a while and the read performance is amazing although having a lot of rows and I really don't know if there is any ...
From what you're saying it seems a mongoDB based solution would work best for you. HBase is extremely versatile and you can get it to serve both your prod needs as well as your analytics needs however the general purpose SQL capabilities (in Phoenix, Cloudera's Impala and others) are in their infancy and the standard ...
54,461,709
I am trying to make a hover effect which will spin the three different cog svg icon to its respected centre origin. I tried using `transform-origin` as centre but no luck. Any help would be appreciated. Here is my code below. ```css .cog--middle { transform: rotate(0deg); transition: 0.3s; transform-origin: ...
2019/01/31
[ "https://Stackoverflow.com/questions/54461709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3877150/" ]
Gears can be drawn in a vector editor. But while it is difficult to find the exact center of rotation of the gear. In case of inaccurate indication of the center of rotation, the gear will rotate with a bean, I decided to first select the center of rotation - `100,100px` and create a gear around it. * Draw the o...
Considering that you are trying to avoid using `transform-box`, one way to achieve the desired result is playing around with the `transform-origin` property using `percentage` values ```css .cog--middle { transform: rotate(0deg); transition: 0.3s; transform-origin: 47% 34%; } svg:hover .cog--middle { tr...
54,461,709
I am trying to make a hover effect which will spin the three different cog svg icon to its respected centre origin. I tried using `transform-origin` as centre but no luck. Any help would be appreciated. Here is my code below. ```css .cog--middle { transform: rotate(0deg); transition: 0.3s; transform-origin: ...
2019/01/31
[ "https://Stackoverflow.com/questions/54461709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3877150/" ]
Gears can be drawn in a vector editor. But while it is difficult to find the exact center of rotation of the gear. In case of inaccurate indication of the center of rotation, the gear will rotate with a bean, I decided to first select the center of rotation - `100,100px` and create a gear around it. * Draw the o...
Basically, there are many ways you can solve this problem. I won't cover all of them, but here are some in order of effectiveness: **1) Just use separate SVG objects** If you going to animate different parts of pure SVG (no libraries like Snap.svg) with pure CSS - don't mix everything in one single SVG object. Instea...
1,265,020
I have recently installed KDE Plasma 5.18 in my desktop PC running Ubuntu 20.04. I didn't like the large size fonts that came pre-configured with Plasma, so I have changed the font settings as follows: [![enter image description here](https://i.stack.imgur.com/2grVM.png)](https://i.stack.imgur.com/2grVM.png) The pr...
2020/08/06
[ "https://askubuntu.com/questions/1265020", "https://askubuntu.com", "https://askubuntu.com/users/1035349/" ]
I have fixed this issue. There was a `.gtkrc-2.0` file in my home folder. On viewing the contents I have found that the font size was set to 11. I had to delete that file. After re-login font size is working perfectly.
I found that the 'Force Font DPI' option under System Settings, Fonts has solved a problem with GTK and KDE apps having different font sizes. I have two screens with different DPI and have set it to the DPI of my primary display.
1,265,020
I have recently installed KDE Plasma 5.18 in my desktop PC running Ubuntu 20.04. I didn't like the large size fonts that came pre-configured with Plasma, so I have changed the font settings as follows: [![enter image description here](https://i.stack.imgur.com/2grVM.png)](https://i.stack.imgur.com/2grVM.png) The pr...
2020/08/06
[ "https://askubuntu.com/questions/1265020", "https://askubuntu.com", "https://askubuntu.com/users/1035349/" ]
I found a fairly comprehensive guide to changing font settings [with this answer](https://unix.stackexchange.com/a/279833/293199). I'm regularly using KDE and Gnome apps, some apps not even in the Ubuntu 20.04 repo. I found the `qt5ct` and `gnome-tweaks` tools complement each other well for maintaining control over fon...
I found that the 'Force Font DPI' option under System Settings, Fonts has solved a problem with GTK and KDE apps having different font sizes. I have two screens with different DPI and have set it to the DPI of my primary display.
18,654
I've read numerous posts and articles on dry hopping in primary, secondary, and kegs. My current brew calls (AIPA) calls for dry hopping. I've think, after reading these articles, that I'd like to dry hop in my secondary which is a glass carboy. I've also think that I'm just going to pour the pellets in without any typ...
2016/11/29
[ "https://homebrew.stackexchange.com/questions/18654", "https://homebrew.stackexchange.com", "https://homebrew.stackexchange.com/users/12982/" ]
The generally approved advice is don't dilute beer post fermentation - and that advice is "not wrong". However it depends on the type and gravity of the beer. I have regularly dissolved the priming sugar in (say) 1 Litre of water and added it to the brew before bottling. I totally recommend dissolving the priming sugar...
You can. Don't do it. Transfer beer to bottling bucket just before bottling. Add priming sugar, let it dissolve. Bottle. Bucket will be partially empty most of the time anyway, because you are bottling. If you want to rack to secondary, just do it, but don't use bottling bucket, use regular one, and don't worry too mu...
3,875,475
hi i have a string like this ``` track._Event('product', 'test');Product.lisen(1234, 21, 4343); return false; ``` i want to use some regular expression so i would end up with groups ``` pid = 1234 p1 = 21 p2 = 4343 ```
2010/10/06
[ "https://Stackoverflow.com/questions/3875475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/313093/" ]
``` import re s = "track._Event('product', 'test');Product.lisen(1234, 21, 4343); return false;" pattern = re.compile(r'.*lisen\((?P<pid>\d+),\s*(?P<p1>\d+),\s*(?P<p2>\d+)\).*') pid, p1, p2 = map(int, pattern.match(s).groups()) ``` Note: I used named capturing groups, but that is not necessary in this case.
Why regular expression? you can do it will simple string manipulations ``` >>> s="track._Event('product', 'test');Product.lisen(1234, 21, 4343); return false;" >>> s.split("lisen(")[-1].split(")")[0].split(",") ['1234', ' 21', ' 4343'] ```
35,648,577
I am trying to install Node Js and npm on my new Amazon EC2 instance but I can't succeed in doing so. I am referring to the official doc : <https://nodejs.org/en/download/package-manager/> I run ``` sudo curl --silent --location https://rpm.nodesource.com/setup_5.x | bash - ``` But I am getting an error : ``` er...
2016/02/26
[ "https://Stackoverflow.com/questions/35648577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5524750/" ]
Adding a **sudo** right before **bash** did it for me ``` curl --silent --location https://rpm.nodesource.com/setup_5.x |sudo bash - ``` Then ``` sudo yum install -y nodejs ```
Use this command and you'll be good to go: ``` curl -sL https://rpm.nodesource.com/setup_17.x | bash - ```
44,970,437
I have a ReactJS project where i get JSON from REST Django host and creating a table with filters for it. I have a Table class : ``` class MainTable extends React.Component { constructor(props) { super(props); this.state = { results: [] }; } componentDidMount(){ axios.get(this.props.link)...
2017/07/07
[ "https://Stackoverflow.com/questions/44970437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8120580/" ]
As pointed out you can implement shouldComponentUpdate. Alternatively if you dont need a deep comparison, ie on any collections or objects, just use PureComponent instead of Component: <https://github.com/facebook/react/blob/master/docs/docs/reference-react.md> React.PureComponent# React.PureComponent is exactly like...
You should take a look at the [`shouldComponentUpdate()`](https://facebook.github.io/react/docs/react-component.html#shouldcomponentupdate) life-cycle method, [**here**](https://facebook.github.io/react/docs/react-component.html#shouldcomponentupdate). > > **shouldComponentUpdate()** > > > > ``` > shouldComponentU...
44,970,437
I have a ReactJS project where i get JSON from REST Django host and creating a table with filters for it. I have a Table class : ``` class MainTable extends React.Component { constructor(props) { super(props); this.state = { results: [] }; } componentDidMount(){ axios.get(this.props.link)...
2017/07/07
[ "https://Stackoverflow.com/questions/44970437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8120580/" ]
As pointed out you can implement shouldComponentUpdate. Alternatively if you dont need a deep comparison, ie on any collections or objects, just use PureComponent instead of Component: <https://github.com/facebook/react/blob/master/docs/docs/reference-react.md> React.PureComponent# React.PureComponent is exactly like...
Thanks for help, the best solution I found and choose is : ``` componentDidMount() { axios.get(this.props.link) .then(res => { this.setState({results: res.data.results, count: res.data.count}); }); } componentWillReceiveProps(nextProps) { axios.get(nextProps.link) .then(res => { ...
13,042,117
I have an Android activity utilizing a JNI library that uses netlink commands to configure a network interface (in this case a socketcan interface). If I run the activity, the network interface configuration fails with an **EPERM** error from RTNETLINK. The commands that are failing require the **CAP\_NET\_ADMIN** capa...
2012/10/24
[ "https://Stackoverflow.com/questions/13042117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235684/" ]
It turns out that Android modifies the kernel capability system to allow verification of specific capabilities based on group-id. Unfortunately the modifications made don't seem to cover all cases. To resolve the problem I was having, I modified the **cap\_netlink\_recv** check to use the Android modified **cap\_capabi...
Indeed, in the netlink path, there is no check for additional permissions *for kernel versions before [v3.1-18-gfd77846](https://git.kernel.org/linus/fd778461524849afd035679030ae8e8873c72b81)*. Originally it did not seem to be a good idea to replace `cap_raised` completely, so here I chose to prepend a similar check a...
884,883
``` Status: Resolving address of ftp.bdtourbazar.com Status: Connecting to 173.254.62.212:21... Status: Connection established, waiting for welcome message... Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- Response: 220-You are user number 11 of 1000 allowed. Response: 220-Local time is n...
2015/03/03
[ "https://superuser.com/questions/884883", "https://superuser.com", "https://superuser.com/users/424384/" ]
honestly, a software solution for such things is just never going to be something I think anyone should trust. Get a post-it note and stick it over your camera. I've got had the trimmed corner of one there permanently. It's reversible, but the level of difficulty for an attacker to defeat it means it can't be-beat for...
As @schroeder said, pretty much any program on your computer has access to all your hardware. You *could* theoretically sandbox Firefox to prevent access to your camera hardware, but it doesn't really make sense to do so. Why do you not trust Firefox with camera access and yet you trust other programs? Is Firefox someh...
884,883
``` Status: Resolving address of ftp.bdtourbazar.com Status: Connecting to 173.254.62.212:21... Status: Connection established, waiting for welcome message... Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- Response: 220-You are user number 11 of 1000 allowed. Response: 220-Local time is n...
2015/03/03
[ "https://superuser.com/questions/884883", "https://superuser.com", "https://superuser.com/users/424384/" ]
If you don't mind installing additional security software on your computer, then there are some products that will prevent processes on your computer from accessing the webcam and microphone. I know of two of them - [SpyShelter](https://www.spyshelter.com/spyshelter-premium/) and [Zemana AntiLogger](http://www.zemana.u...
As @schroeder said, pretty much any program on your computer has access to all your hardware. You *could* theoretically sandbox Firefox to prevent access to your camera hardware, but it doesn't really make sense to do so. Why do you not trust Firefox with camera access and yet you trust other programs? Is Firefox someh...
1,250,282
Hi I configured the following [persistent routes](https://www.howtogeek.com/howto/windows/adding-a-tcpip-route-to-the-windows-routing-table/) on my Windows Server. ``` route -p ADD 10.32.1.40 MASK 255.255.255.255 172.16.8.254 route -p ADD 10.192.1.40 MASK 255.255.255.255 172.16.8.254 ``` They work fine initially, bu...
2017/09/14
[ "https://superuser.com/questions/1250282", "https://superuser.com", "https://superuser.com/users/675151/" ]
It might sound silly, but to fix this issue, assign a sufficiently wide border (bold or wider, depending on scale) on the left edge of the table. This will apparently cover the white margin :) (tested both with Adobe PDF Printer and Save as PDF native feature) (it works well enough with right edge too, but you still...
See the screenshot here: ![See the screenshot here](https://i.stack.imgur.com/nERdL.png) After editing the document in MS Excel. save the document and **mark it final** to make it read-only. Then open and print the document in LibreOffice. LibreOffice will print with 0 margins. You may download a [portable version...
1,248,750
I was trying to install CentOS 6.9 [downloaded from official website (LiveDVD)] in a new assembled PC. The PC came with Windows 10 Pro preinstalled. The specifications of the PC are as follows: * Inter i5 7th Gen Processor * 4 GB RAM * Asus H110M-CS Motherboard * 2 TB HDD There was no DVD drive, so first I used a por...
2017/09/09
[ "https://superuser.com/questions/1248750", "https://superuser.com", "https://superuser.com/users/294338/" ]
I solved the issue myself, but still I don't know what was wrong with the installation. So here is what I did. After trying a lot I decided to delete all the partitions in the hard disk. So I deleted all the partitions and created 2 new ext4 partitions with Ubuntu 14.04 LTS live disk. After it I tried to boot from the...
It’s not clear what’s causing the kernel panic. Could be any number of things. Can you see any errors before that? If it’s in a GUI loader (not sure if CentOS uses Plymouth), you can hit `ESC` and see some more detail. I did find [this](https://darktraining.com/2012/01/23/kernel-panic-not-syncing-attempted-to-kill-in...
1,248,750
I was trying to install CentOS 6.9 [downloaded from official website (LiveDVD)] in a new assembled PC. The PC came with Windows 10 Pro preinstalled. The specifications of the PC are as follows: * Inter i5 7th Gen Processor * 4 GB RAM * Asus H110M-CS Motherboard * 2 TB HDD There was no DVD drive, so first I used a por...
2017/09/09
[ "https://superuser.com/questions/1248750", "https://superuser.com", "https://superuser.com/users/294338/" ]
I solved the issue myself, but still I don't know what was wrong with the installation. So here is what I did. After trying a lot I decided to delete all the partitions in the hard disk. So I deleted all the partitions and created 2 new ext4 partitions with Ubuntu 14.04 LTS live disk. After it I tried to boot from the...
This can be caused by numerous things. I had this problem when trying to boot a live USB image of PerfSonar "pS-Performance\_Toolkit-3.3-LiveUSB-x86\_64.iso" I learned: 1. This version of CentOS cannot boot from a USB3 device. Ensure you have the USB stick plugged in to a USB2 port, even if it is a 3+ device. 2. The ...
48,789,872
I have a port 'Number\_1' in expression transformation in Informatica. I connected the Number\_1 port to a target sql table. I need to generate number for this port 'Number\_1' every time i run the mapping starting from 1 till 999. once it reaches 999 then again the value of the Number\_1 should reset to 1. I'm awar...
2018/02/14
[ "https://Stackoverflow.com/questions/48789872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8307444/" ]
There is an easier way to do this, you just need to do `df.plot` with the option `subplots=True` and then change there the outlier, vertical (`layout=(4,1)`): ``` df2.plot(kind='box',subplots=True, layout=(4,1), figsize=(8,8)) plt.show() ``` [![enter image description here](https://i.stack.imgur.com/Bdnng.png)](http...
You need to pass the axis as argument to the plot function. Something along these lines: ``` df2 = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD')) fig, axes = plt.subplots(nrows=4, ncols=1, sharex=True) for i, col in enumerate(df2.columns): print(col) df2[col].plot(kind="box", ax=axe...
59,385,599
I am writing the unit test cases for the Angular 8 app. This is the hybrid application with AngularJs + Angular 8. I'm getting following error: ``` NullInjectorError: StaticInjectorError(DynamicTestModule)[TestService -> $injector]: StaticInjectorError(Platform: core)[TestService -> $injector]: NullInjectorE...
2019/12/18
[ "https://Stackoverflow.com/questions/59385599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7792527/" ]
You can create a mock object for $injector . I had faced a similar issue for $rootscope in my project where I provided an empty object for $rootscope using Angular provider : ``` {provide: '$rootScope',useValue : {}} This provider will be part of TestBed configuration like this : beforeEach(async(() => { ...
Its a syntax error, TestService import right component/module. for more information "<https://angular.io/start>"
274,310
Whenever I work on some fairly significant piece of code, often I find that the I go through a phase of high level designing (aside: I like to use pencil and paper for this), followed by mental walkthroughs to highlight flaws and make refinements. I see coding as another level (and finest grained) of mental walkthrou...
2015/02/24
[ "https://softwareengineering.stackexchange.com/questions/274310", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/32728/" ]
Everything you say in your question is absolutely true, though I have a feeling that many companies don't actually go through quite the same thought process as you. Your thought process is (more or less, for any significant piece of code) "I need a day to write it, a day to debug it, and a day to refactor it." Your co...
You are describing a core component of [clean coding](http://rads.stackoverflow.com/amzn/click/0132350882). No matter how well you *think* you design something up front, development is an iterative process that demands change. You start with the high level overview of a system and design accordingly. Maybe you go thro...
63,096,571
In `WordPress`, I want to display a different menu on the front page than on all other pages (without plugin). I'm using a theme I created myself. This is the code: **`functions.php`** ``` register_nav_menus( array( 'menu-1' => esc_html__( 'Main navigation', 'theme' ), 'menu-2' => esc_html__( 'Su...
2020/07/26
[ "https://Stackoverflow.com/questions/63096571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11152605/" ]
See this DartPad for running ex. [PinnedAppBar\_SliverAppBar\_NestedScrollView](https://dartpad.dev/5b5ba2a1323dac6fc78faf94436addd9) ``` NestedScrollView( controller: ScrollController(), physics: ClampingScrollPhysics(), headerSliverBuilder: (context, value) { return [ ...
I tried below code hope it solves your problem.... You can also play with this code at DartPad [NestedScrollView](https://dartpad.dev/f60b95ad004de6c3131b12d92669fefd) ``` NestedScrollView( physics: ClampingScrollPhysics(), headerSliverBuilder: (context, value) { return [ SliverToBoxAdap...
19,341,801
I have a spinner that when selected should add a new spinner to the view. But when I try an inflate it I am getting an error on this line: ``` LinearLayout addSpinner =(LinearLayout)selectedItemView.getContext().findViewById(R.id.addSpinnerLayout); ``` findViewByID is red and shows this error on mouse hover: ``` Ca...
2013/10/13
[ "https://Stackoverflow.com/questions/19341801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1637374/" ]
Python's distutils has `strtobool` which might work for you. [Documentation Link](http://docs.python.org/3/distutils/apiref.html?highlight=distutils.util#distutils.util.strtobool). > > **distutils.util.strtobool(val)** > > > Convert a string representation of truth to true (1) or false (0). > > > * True values ar...
Considering any answers (which also could be multiple) affirmative or negative is all up to you. You can either create an array of potential user answers (as you've already shown) or you can simply tell the user the input was wrong and alert with a message like "please answer yes or no". Also mostly used affirmative m...
19,341,801
I have a spinner that when selected should add a new spinner to the view. But when I try an inflate it I am getting an error on this line: ``` LinearLayout addSpinner =(LinearLayout)selectedItemView.getContext().findViewById(R.id.addSpinnerLayout); ``` findViewByID is red and shows this error on mouse hover: ``` Ca...
2013/10/13
[ "https://Stackoverflow.com/questions/19341801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1637374/" ]
Python's distutils has `strtobool` which might work for you. [Documentation Link](http://docs.python.org/3/distutils/apiref.html?highlight=distutils.util#distutils.util.strtobool). > > **distutils.util.strtobool(val)** > > > Convert a string representation of truth to true (1) or false (0). > > > * True values ar...
I have a better idea: accept anything starting with "yYnN", and an empty string if you must. Complain about anything else and ask again. Users will get used to that very quickly. "There should be one- and preferably only one -obvious way to do it" :-)
19,341,801
I have a spinner that when selected should add a new spinner to the view. But when I try an inflate it I am getting an error on this line: ``` LinearLayout addSpinner =(LinearLayout)selectedItemView.getContext().findViewById(R.id.addSpinnerLayout); ``` findViewByID is red and shows this error on mouse hover: ``` Ca...
2013/10/13
[ "https://Stackoverflow.com/questions/19341801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1637374/" ]
I have a better idea: accept anything starting with "yYnN", and an empty string if you must. Complain about anything else and ask again. Users will get used to that very quickly. "There should be one- and preferably only one -obvious way to do it" :-)
Considering any answers (which also could be multiple) affirmative or negative is all up to you. You can either create an array of potential user answers (as you've already shown) or you can simply tell the user the input was wrong and alert with a message like "please answer yes or no". Also mostly used affirmative m...
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
I think you're after the [singleton](http://en.wikipedia.org/wiki/Singleton_pattern) pattern.
There isn't a reasonable way to find out whether or not an instance of a particular class already exists. If you need to know this information, create a static boolean field and set it from the constructor: ``` class MyClass { private static bool instanceExists = false; public MyClass() { MyClass.inst...
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
Several factors would contribute to obtaining a reliable solution in Java, as opposed to C++. The following example is unreliable, although it could provide you with a *correct enough* answer if you use the hasAtleastOne() method. ``` class Example { private static int noOfInstances = 0; public Example() { ...
There isn't a reasonable way to find out whether or not an instance of a particular class already exists. If you need to know this information, create a static boolean field and set it from the constructor: ``` class MyClass { private static bool instanceExists = false; public MyClass() { MyClass.inst...
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
If you want to have only one instance of "PNLSpcMaster" then you [do need a singleton](https://stackoverflow.com/questions/1441984/how-can-i-know-whether-an-instance-of-a-class-already-exists-in-memory/1442004#1442004): This is the common singleton idiom: ``` public class PNLSpcMaster { /** * This class attri...
There isn't a reasonable way to find out whether or not an instance of a particular class already exists. If you need to know this information, create a static boolean field and set it from the constructor: ``` class MyClass { private static bool instanceExists = false; public MyClass() { MyClass.inst...
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
I think you're after the [singleton](http://en.wikipedia.org/wiki/Singleton_pattern) pattern.
For classes that have a notion of identity, the [Identity Map pattern](http://martinfowler.com/eaaCatalog/identityMap.html) applies.
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
If you want to have only one instance of "PNLSpcMaster" then you [do need a singleton](https://stackoverflow.com/questions/1441984/how-can-i-know-whether-an-instance-of-a-class-already-exists-in-memory/1442004#1442004): This is the common singleton idiom: ``` public class PNLSpcMaster { /** * This class attri...
I think you're after the [singleton](http://en.wikipedia.org/wiki/Singleton_pattern) pattern.
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
Several factors would contribute to obtaining a reliable solution in Java, as opposed to C++. The following example is unreliable, although it could provide you with a *correct enough* answer if you use the hasAtleastOne() method. ``` class Example { private static int noOfInstances = 0; public Example() { ...
For classes that have a notion of identity, the [Identity Map pattern](http://martinfowler.com/eaaCatalog/identityMap.html) applies.
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
If you want to have only one instance of "PNLSpcMaster" then you [do need a singleton](https://stackoverflow.com/questions/1441984/how-can-i-know-whether-an-instance-of-a-class-already-exists-in-memory/1442004#1442004): This is the common singleton idiom: ``` public class PNLSpcMaster { /** * This class attri...
Several factors would contribute to obtaining a reliable solution in Java, as opposed to C++. The following example is unreliable, although it could provide you with a *correct enough* answer if you use the hasAtleastOne() method. ``` class Example { private static int noOfInstances = 0; public Example() { ...
1,441,984
How can I know whether an instance of a class already exists in memory? --- My problem is that don't want read method if exist instance of Class this is my code ``` private void jButton (java.awt.event.ActionEvent evt) { PNLSpcMaster pnlSpc = new PNLSpcMaster(); jtabbedPanel.addTab("reg",pnlSpc); } ``` I ...
2009/09/18
[ "https://Stackoverflow.com/questions/1441984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175266/" ]
If you want to have only one instance of "PNLSpcMaster" then you [do need a singleton](https://stackoverflow.com/questions/1441984/how-can-i-know-whether-an-instance-of-a-class-already-exists-in-memory/1442004#1442004): This is the common singleton idiom: ``` public class PNLSpcMaster { /** * This class attri...
For classes that have a notion of identity, the [Identity Map pattern](http://martinfowler.com/eaaCatalog/identityMap.html) applies.
129,143
I found the `.bashrc` file and I want to know the purpose/function of it. Also how and when is it used?
2014/05/13
[ "https://unix.stackexchange.com/questions/129143", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/66803/" ]
`.bashrc` is a Bash [shell script](http://en.wikipedia.org/wiki/Shell_script) that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt. You put commands here to set up the shell for use in your parti...
The purpose of a `.bashrc` file is to provide a place where you can set up variables, functions and aliases, define your (PS1) prompt and define other settings that you want to use every time you open a new terminal window. It works by being run each time you open up a new terminal, window or pane. A super minimal on...
129,143
I found the `.bashrc` file and I want to know the purpose/function of it. Also how and when is it used?
2014/05/13
[ "https://unix.stackexchange.com/questions/129143", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/66803/" ]
`.bashrc` is a Bash [shell script](http://en.wikipedia.org/wiki/Shell_script) that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt. You put commands here to set up the shell for use in your parti...
It is a `bash` config file. Interactive (non-login) shells, then the config is read from these files: * `$HOME/.bashrc` For Login shells, the config is read from these files: * `/etc/profile` (Always sourced) * `$HOME/.bash_profile` (the rest of these files are checked in order until one is found, then no others ar...
129,143
I found the `.bashrc` file and I want to know the purpose/function of it. Also how and when is it used?
2014/05/13
[ "https://unix.stackexchange.com/questions/129143", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/66803/" ]
The purpose of a `.bashrc` file is to provide a place where you can set up variables, functions and aliases, define your (PS1) prompt and define other settings that you want to use every time you open a new terminal window. It works by being run each time you open up a new terminal, window or pane. A super minimal on...
It is a `bash` config file. Interactive (non-login) shells, then the config is read from these files: * `$HOME/.bashrc` For Login shells, the config is read from these files: * `/etc/profile` (Always sourced) * `$HOME/.bash_profile` (the rest of these files are checked in order until one is found, then no others ar...
49,058,006
I am using Angular 5 in a project and i get a typescript error: ``` ERROR TypeError: Cannot read property 'indexOf' of undefined ``` What my code is supposed to do is to update the template on input change like this: The template: ``` <input #f (input)="filterResults(f.value)"/> <div *ngIf="filteredCandidates.len...
2018/03/01
[ "https://Stackoverflow.com/questions/49058006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6814832/" ]
If c.name is not defined in some cases, you could do the check like this: ``` this.candidates.filter(c => { return c.name !== null && c.name.indexOf(queryString) >= 0 }); ``` Here, !== null will check for both null and undefined values.
It seems like you're trying to perform filter operation on collection `candidates` even though it haven't been retrieved from the API server yet. By looking at your UI, it doesn't look like you are peforming any remote filtering based on query string. In this case I'd recommend to retrieve the `candidates` collection a...
49,058,006
I am using Angular 5 in a project and i get a typescript error: ``` ERROR TypeError: Cannot read property 'indexOf' of undefined ``` What my code is supposed to do is to update the template on input change like this: The template: ``` <input #f (input)="filterResults(f.value)"/> <div *ngIf="filteredCandidates.len...
2018/03/01
[ "https://Stackoverflow.com/questions/49058006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6814832/" ]
It seems like you're trying to perform filter operation on collection `candidates` even though it haven't been retrieved from the API server yet. By looking at your UI, it doesn't look like you are peforming any remote filtering based on query string. In this case I'd recommend to retrieve the `candidates` collection a...
What a foolish mistake. I had to do some error handling. In the database, one of the objects had no property name (undefined). So when the loop got there, the code broke. I have to handle errors better. Thank you all for suggestions though.
49,058,006
I am using Angular 5 in a project and i get a typescript error: ``` ERROR TypeError: Cannot read property 'indexOf' of undefined ``` What my code is supposed to do is to update the template on input change like this: The template: ``` <input #f (input)="filterResults(f.value)"/> <div *ngIf="filteredCandidates.len...
2018/03/01
[ "https://Stackoverflow.com/questions/49058006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6814832/" ]
If c.name is not defined in some cases, you could do the check like this: ``` this.candidates.filter(c => { return c.name !== null && c.name.indexOf(queryString) >= 0 }); ``` Here, !== null will check for both null and undefined values.
What a foolish mistake. I had to do some error handling. In the database, one of the objects had no property name (undefined). So when the loop got there, the code broke. I have to handle errors better. Thank you all for suggestions though.
42,773,089
I'm looking to have PowerShell check if the file exists in two locations - the source folder and destination folder. If it does exist in both, I'd like it to append `"voided"` to the destination file then move the source file to destination location. I found the below script which works, but it renames the source file...
2017/03/13
[ "https://Stackoverflow.com/questions/42773089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6099594/" ]
Don't modify `$nextName`. Rename the destination file before moving the source file. ``` if (Test-Path -LiteralPath $nextName) { Rename-Item -LiteralPath $nextName -NewName ($_.BaseName + "_$v" + $_.Extension) } $_ | Move-Item -Destination $nextName ```
I'm fairly new to all this myself, but please try the below and let me know if you have any issues? ``` $sourceFolder = "\\root\source\folder" $destinationFolder = "\\root\destination\folder" $v = "voided" #Get just the file names for the items in your source folder $filesInSource = Get-ChildItem -Path $sourc...
46,854,977
It works for the most part until the end of the for loop but I get an error not sure how to fix or if its all just wrong. Problem: The USF math department has forgotten the value of pi and they want you to calculate it for them. Assume you have a quarter circle inside a square with sides of 1x1 unit. Then the radius...
2017/10/20
[ "https://Stackoverflow.com/questions/46854977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5566131/" ]
You probably need the core dependency as well: ``` <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>5.6.3</version> </dependency> ``` A `NoClassDefFoundError` is generally a configuration error - it means that the code you use references a certain class, ...
I had the same problem. ElasticSearch pointed to old version: ``` org.elasticsearch:elasticsearch:6.2.3 -> 1.5.2 ``` I used dependencyManagement gradle plugin to force use the version I mention: ``` dependencyManagement { dependencies { dependency 'org.elasticsearch:elasticsearch:6.2.3' }} ``` For more info:...
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
Destroy previous Swiper and reinitialize Swiper giving the direction value. Here is [doc](http://idangero.us/swiper/api/) ***DEMO*** ```js let isVertical = true, direction = 'vertical'; let swiper = initSwiper(direction); function initSwiper(direction) { return new Swiper('.swiper-container', { spaceBet...
Try my solution. ```js //Tested in Swiper 7.2.0 /** * Insert to your page */ var rotate90Swiper = (function (swiper, optIsRotate90) { var isRoate90 = !!optIsRotate90 swiper.___touches = {} swiper.___touches.currentX = swiper.touches.currentX Object.defineProperty(swiper.touches, 'currentX', { ...
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
Destroy previous Swiper and reinitialize Swiper giving the direction value. Here is [doc](http://idangero.us/swiper/api/) ***DEMO*** ```js let isVertical = true, direction = 'vertical'; let swiper = initSwiper(direction); function initSwiper(direction) { return new Swiper('.swiper-container', { spaceBet...
For who's searching this in 2022, now is possible to update direction using `swiper.changeDirection('vertical'); // or horizontal` complete example here: <https://stackblitz.com/edit/swiper-demo-43-change-direction>
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
Destroy previous Swiper and reinitialize Swiper giving the direction value. Here is [doc](http://idangero.us/swiper/api/) ***DEMO*** ```js let isVertical = true, direction = 'vertical'; let swiper = initSwiper(direction); function initSwiper(direction) { return new Swiper('.swiper-container', { spaceBet...
Quick edit if you need to rotate at 180 your swiperjs ``` var rotate180Swiper = (function (swiper, optIsRotate180) { var isRoate180 = !!optIsRotate180 swiper.___touches = {} swiper.___touches.currentX = swiper.touches.currentX Object.defineProperty(swiper.touches, 'currentX', { ...
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
Destroy previous Swiper and reinitialize Swiper giving the direction value. Here is [doc](http://idangero.us/swiper/api/) ***DEMO*** ```js let isVertical = true, direction = 'vertical'; let swiper = initSwiper(direction); function initSwiper(direction) { return new Swiper('.swiper-container', { spaceBet...
Just simply add reverseDirection: true, in the autoplay ``` autoplay: { delay: 0, disableOnInteraction: true, reverseDirection: true, }, ```
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
For who's searching this in 2022, now is possible to update direction using `swiper.changeDirection('vertical'); // or horizontal` complete example here: <https://stackblitz.com/edit/swiper-demo-43-change-direction>
Try my solution. ```js //Tested in Swiper 7.2.0 /** * Insert to your page */ var rotate90Swiper = (function (swiper, optIsRotate90) { var isRoate90 = !!optIsRotate90 swiper.___touches = {} swiper.___touches.currentX = swiper.touches.currentX Object.defineProperty(swiper.touches, 'currentX', { ...
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
For who's searching this in 2022, now is possible to update direction using `swiper.changeDirection('vertical'); // or horizontal` complete example here: <https://stackblitz.com/edit/swiper-demo-43-change-direction>
Quick edit if you need to rotate at 180 your swiperjs ``` var rotate180Swiper = (function (swiper, optIsRotate180) { var isRoate180 = !!optIsRotate180 swiper.___touches = {} swiper.___touches.currentX = swiper.touches.currentX Object.defineProperty(swiper.touches, 'currentX', { ...
54,594,033
I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on slide I'm rotating "swiper-container" making it full screen . So it still has swiping direction from left to right , but I need to change from top to bottom without...
2019/02/08
[ "https://Stackoverflow.com/questions/54594033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7234678/" ]
For who's searching this in 2022, now is possible to update direction using `swiper.changeDirection('vertical'); // or horizontal` complete example here: <https://stackblitz.com/edit/swiper-demo-43-change-direction>
Just simply add reverseDirection: true, in the autoplay ``` autoplay: { delay: 0, disableOnInteraction: true, reverseDirection: true, }, ```
25,996,317
I'd like to be able to list all of an objects classes instance methods without getters and setters from `attr_accessor`. I've written this as an example and it behaves the way I need it to. I find it hard to believe that there isn't an easier way to do this. ``` class Object def instance_methods_without_variables ...
2014/09/23
[ "https://Stackoverflow.com/questions/25996317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1510063/" ]
The Ruby language has no notion of getters and setters for properties. `attr_accessor :a_var` is merely a convenient shorthand for creating the methods `:a_var` that returns the value, and `:a_var=` that set the value of the instance variable `@a_var`. The methods `:a_var`, and `:a_var=` are no different than any other...
If you're going to do this lots, probably better that you overwrite `attr_accessor` write your own `custom_attr_accessor` ``` class AuditedClass def indexed_attr_accessor(*args) self.class_eval %Q{ unless instance_variable_get(:@attr_accessor_index).is_a?(Array) instance_variable_set...
25,996,317
I'd like to be able to list all of an objects classes instance methods without getters and setters from `attr_accessor`. I've written this as an example and it behaves the way I need it to. I find it hard to believe that there isn't an easier way to do this. ``` class Object def instance_methods_without_variables ...
2014/09/23
[ "https://Stackoverflow.com/questions/25996317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1510063/" ]
The Ruby language has no notion of getters and setters for properties. `attr_accessor :a_var` is merely a convenient shorthand for creating the methods `:a_var` that returns the value, and `:a_var=` that set the value of the instance variable `@a_var`. The methods `:a_var`, and `:a_var=` are no different than any other...
Well, this is a quick hack that relies on the fact that when you do Class.instance\_variables(false), Ruby first displays the accessors/mutators methods in pairs of 2, and then the regular methods show up (this will work only if you don't put any methods above attr\_accessor in your class definition). It's not perfect,...
64,423,529
Google Recently Deleted my app because of new rules for location privacy. I am using Mapbox library for maps and I have `ACCESS_FINE_LOCATION` permission, When I Upload new generated app to google play it says my app use background location and force me to the privacy tab for more information, i dont have any `BACKGROU...
2020/10/19
[ "https://Stackoverflow.com/questions/64423529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4266649/" ]
Instead of iterating over rows you can precompute indexes of rows and iterate over columns: ``` nbcols = size(A, 2); [r, c] = find(tril(true(nbrows))); rc = [r c]; for i = 1:nbcols B(:, i) = sum(reshape(A(rc, i), [], 2), 2); end ``` Equivalent possibly less efficient solution: ``` for i = 1:nbcols B(:, i...
Based on the suggestion of @rahnema1 here is a test result about three possible ways. Let us generate matrix `A` as `A=rand(1e4,20);` Method 1: using indexes and vectorization ``` tic nbrows = size(A,1); [r, c] = find(tril(true(nbrows))); B = A(r,:) + A(c,:); toc ``` Terminate in 12.8 seconds. Method 2: using inde...
62,644,694
I was wondering say if I have this snippet where the row is a string value is there a way to make the code look better with list comprehension? ``` row_output = list(row) for i in range(len(row_output)) if i % 2 == 0: row_output[i] = '*' row_output = ''.join(row_output) ```
2020/06/29
[ "https://Stackoverflow.com/questions/62644694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13726957/" ]
You can definitely use a list comprehension to abbreviate the task. IIUC, what you want to do is replace the values that are in odd-numbered positions with '\*', else retain the value. I'm stating this to make sure it is what you intend. My suggestion would be: ``` ''.join(['*' if x % 2 == 0 else row_output[x] for x i...
using `enumerate` to get the job done. ``` row = "This Question was asked on StackOverflow" row_output = list(row) row_output = "".join( ["*" if index % 2 == 0 else item for index, item in enumerate(row_output)] ) print(row_output) ``` Output: ------- ``` *h*s*Q*e*t*o* *a* *s*e* *n*S*a*k*v*r*l*w ```
14,166,763
I'm using the answer provided here: [Query rows for which meta data key does not exist](https://stackoverflow.com/questions/6483228/query-rows-for-which-meta-data-key-does-not-exist) ``` UPDATE table1 SET table1.id = table2.id FROM table1 LEFT JOIN table2 ON table1.id=table2.id WHERE table.id IS NULL `...
2013/01/04
[ "https://Stackoverflow.com/questions/14166763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1950072/" ]
Like most databases, MySQL has a [unique syntax](http://dev.mysql.com/doc/refman/5.0/en/update.html) for a join in combination with an update: ``` UPDATE table1 LEFT JOIN table2 ON table1.id=table2.id SET table1.id = table2.id WHERE table1.id IS NULL ```
You can't join in an UPDATE statement (edit - maybe you can). You need a subselect that returns exactly one row. Also your query makes no sense if id is the join column - I'll assume you're joining on something else. I think something like this is correct (haven't tested it). ``` UPDATE table1 outer SET id = ( SE...