qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Since your asking for a canonical answer, here's an approach that avoids editing the provided object in-place, provides type hints, has a docstring, can be invoked with the `remove` parameter to remove different values, and errors with a `TypeError` as appropriate: ``` from collections import abc from typing import Di...
**Solution:** ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "BBB", }] for element in list(d): for key, value in element.copy().items(): if value == "NULL":...
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
**Solution:** ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "BBB", }] for element in list(d): for key, value in element.copy().items(): if value == "NULL":...
> > I am using Python 3.9, so it is possible to use walrus operator. > > > Well then, let's throw one in there since no one else did: ``` from collections import deque def remove_null(thing): if isinstance(thing, list): deque(map(remove_null, thing), maxlen=0) elif isinstance(thing, dict): ...
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Here is how you can do this with recursion: ``` def remove_null(d): if isinstance(d, list): for i in d: remove_null(i) elif isinstance(d, dict): for k, v in d.copy().items(): if v == 'NULL': d.pop(k) else: remove_null(v) d = [...
Since your asking for a canonical answer, here's an approach that avoids editing the provided object in-place, provides type hints, has a docstring, can be invoked with the `remove` parameter to remove different values, and errors with a `TypeError` as appropriate: ``` from collections import abc from typing import Di...
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Here is how you can do this with recursion: ``` def remove_null(d): if isinstance(d, list): for i in d: remove_null(i) elif isinstance(d, dict): for k, v in d.copy().items(): if v == 'NULL': d.pop(k) else: remove_null(v) d = [...
> > I am using Python 3.9, so it is possible to use walrus operator. > > > Well then, let's throw one in there since no one else did: ``` from collections import deque def remove_null(thing): if isinstance(thing, list): deque(map(remove_null, thing), maxlen=0) elif isinstance(thing, dict): ...
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Here is how you can do this with recursion: ``` def remove_null(d): if isinstance(d, list): for i in d: remove_null(i) elif isinstance(d, dict): for k, v in d.copy().items(): if v == 'NULL': d.pop(k) else: remove_null(v) d = [...
Maybe something like: ``` def remove_nulls(d): res = {} for k, v in d.items(): if v == "NULL": continue if isinstance(v, dict): res[k] = remove_nulls(v) else: res[k] = v return res print([remove_nulls(d) for d in lt]) ```
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Since your asking for a canonical answer, here's an approach that avoids editing the provided object in-place, provides type hints, has a docstring, can be invoked with the `remove` parameter to remove different values, and errors with a `TypeError` as appropriate: ``` from collections import abc from typing import Di...
> > I am using Python 3.9, so it is possible to use walrus operator. > > > Well then, let's throw one in there since no one else did: ``` from collections import deque def remove_null(thing): if isinstance(thing, list): deque(map(remove_null, thing), maxlen=0) elif isinstance(thing, dict): ...
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Since your asking for a canonical answer, here's an approach that avoids editing the provided object in-place, provides type hints, has a docstring, can be invoked with the `remove` parameter to remove different values, and errors with a `TypeError` as appropriate: ``` from collections import abc from typing import Di...
Maybe something like: ``` def remove_nulls(d): res = {} for k, v in d.items(): if v == "NULL": continue if isinstance(v, dict): res[k] = remove_nulls(v) else: res[k] = v return res print([remove_nulls(d) for d in lt]) ```
67,806,380
I have an array of complex *dict* that have some value as a string "NULL" and I want to remove, my dict looks like this: ``` d = [{ "key1": "value1", "key2": { "key3": "value3", "key4": "NULL", "z": { "z1": "NULL", "z2": "zzz", }, }, "key5": "NULL" }, { "KEY": "NULL", "AAA": "...
2021/06/02
[ "https://Stackoverflow.com/questions/67806380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
Maybe something like: ``` def remove_nulls(d): res = {} for k, v in d.items(): if v == "NULL": continue if isinstance(v, dict): res[k] = remove_nulls(v) else: res[k] = v return res print([remove_nulls(d) for d in lt]) ```
> > I am using Python 3.9, so it is possible to use walrus operator. > > > Well then, let's throw one in there since no one else did: ``` from collections import deque def remove_null(thing): if isinstance(thing, list): deque(map(remove_null, thing), maxlen=0) elif isinstance(thing, dict): ...
35,783,817
I am programming an application that is non-modal dialog based. I am using the Visual Studio resource editor to build the dialog and create the application. Everything is going great so far. However, I have reached a brick wall when it comes to handling keyboard input. My research has shown that windows captures keyboa...
2016/03/03
[ "https://Stackoverflow.com/questions/35783817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1813678/" ]
The first place keyboard input appears is your message loop, so just check for the keypress you're looking for before passing it off to `IsDialogMessage()` / `TranslateMessage()` / `DispatchMessage()`. For example: ``` while ((ret = GetMessage(&msg, 0, 0, 0)) != 0) { if (ret == -1) return -1; if (msg....
You could also use **SetWindowsHook** to create low level keyboard proc. **NOTE** this looks a bit complex and advanced but it works great with Dialogs without doing any extra effort to message loop. ``` HHOOK g_hLowLevelKeyHook; //windows Main. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR...
36,278,293
I'm using `templateRest` to post `User` object to `Rest Server` but I encoutered the following error: > > Exception in thread "main" java.lang.NoClassDefFoundError: > com/fasterxml/jackson/core/JsonProcessingException at > edu.java.spring.service.client.RestClientTest.main(RestClientTest.java:33) > Caused by: java...
2016/03/29
[ "https://Stackoverflow.com/questions/36278293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5957380/" ]
Add this : ``` <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </de...
Try add to your pom.xml ``` <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-asl</artifactId> <version>1.9.13</version> </dependency> ```
5,126,633
When I run rspec 2 with rails 3 I use ``` rake rspec ``` sometimes I'd like to use a different formatter, perhaps doc. ``` rake rspec --format doc ``` but unfortunately the option doesn't make it through to the rspec runner. How can I choose a different format when I run the command?
2011/02/26
[ "https://Stackoverflow.com/questions/5126633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/162337/" ]
You can add default options to an .rspec file in the rails root folder. e.g. ``` --colour --format documentation ```
You can also skip rake and use the rspec command directly. In this case the --format option can be used to tell RSpec how to format the output, "documentation" (or "doc") and "progress" are valid options: ``` rspec spec --format doc ``` This is especially useful if you want to run a single test/spec file ``` rspec ...
14,692
I found this sentence on the internet: > > Seems like society **leveled itself out** once again. > > > What does *level out* mean here? I have looked up OALD, and it defines *level out/off* as: > > level off/out > > 1 to stop rising or falling and remain horizontal. > > *The plane levelled off at 1500 f...
2013/12/20
[ "https://ell.stackexchange.com/questions/14692", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/1473/" ]
(To)Level out stands for work on an area to make it even, smooth and free of indents, dents or dings. Figuratively, if some person or group levels out, it comes ahead of its shortcomings, no more ups and downs, and it can have a smooth riding future.
I couldn't find OALD, but I believe that the online [Oxford Dictionary](http://www.oxforddictionaries.com/definition/english/level) should be close enough. A similar definition for ***level out***/***off*** can be found under *verb* sense 2. > > 2 [*no object*] (**level off/out**) begin to fly horizontally after clim...
415,877
I followed some advice I found here for a replacement for Disk Inventory X [OSX disk space shows 200GB as "other"](https://apple.stackexchange.com/questions/388549/osx-disk-space-shows-200gb-as-other#answer-388581) I installed the DaisyDisk app and it worked very well, however now my machine is constantly overheating...
2021/03/16
[ "https://apple.stackexchange.com/questions/415877", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/131099/" ]
You may want to reinstall it and use "[AppCleaner](http://freemacsoft.net/appcleaner/)" to properly remove it and all of its remnants.
If you installed it from the App Store you can delete it from LaunchPad or Finder. Finder moving it to trash works for the direct download version of the app. Spotlight should reveal the location of the app in most cases.
12,421,312
I am getting error when using load data to insert the query . ``` "load data infile '/home/bharathi/out.txt' into table Summary" ``` This file is there in the location . But mysql throws the below error . **ERROR 29 (HY000): File '/home/bharathi/out.txt' not found (Errcode: 13)** ``` show variables like 'data%'; +-...
2012/09/14
[ "https://Stackoverflow.com/questions/12421312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1449101/" ]
As documented under [`LOAD DATA INFILE` Syntax](http://dev.mysql.com/doc/en/load-data.html): > > For security reasons, when reading text files located on the server, the files must either reside in the database directory or be readable by all. Also, to use [`LOAD DATA INFILE`](http://dev.mysql.com/doc/en/load-data.ht...
The solution which really worked for me was to: ``` sudo chown mysql:mysql /path/to/the/file/to/be/read.csv ``` Adding it for future reference.
117,931
I can add custom fields to the user registration form, if I add the fields to the user profile: admin/config/people/accounts/fields There is a checkbox "Show on user registraion" which is inactive: ![enter image description here](https://i.stack.imgur.com/T8azs.png) The checkbox only gets active if I check "Mandatory...
2014/06/11
[ "https://drupal.stackexchange.com/questions/117931", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/17039/" ]
I have never encountered such problem before. But since you have such problem then I think the best way is to write a hook\_form\_alter. And set the required field that you don't want as mandatory to false. ``` function mymodule_form_alter(&$form, $form_state, $form_id){ switch ($form_id) { case 'registration_for...
It sounds like something is missing. Both of those options can be found on the field edit page. Both are usually available for checking. However, when you check the 'Required field' option, the 'Display on user registration form' option gets an automatic check and locked (making it virtually impossible to un-check it.)...
73,248,935
``` public Void traverseQuickestRoute(){ // Void return-type from interface findShortCutThroughWoods() .map(WoodsShortCut::getTerrainDifficulty) .ifPresent(this::walkThroughForestPath) // return in this case if(isBikePresent()){ return cycleQuickestRoute() } .... } ``` Is ther...
2022/08/05
[ "https://Stackoverflow.com/questions/73248935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2321414/" ]
`return` is a control statement. Neither lambdas (arrow notation), nor method refs (`WoodsShortcut::getTerrainDifficulty`) support the idea of control statements that move control to outside of themselves. Thus, the answer is a rather trivial: Nope. You have to think of the stream 'pipeline' as the thing you're worki...
For example: ``` public Void traverseQuickestRoute() { return findShortCutThroughWoods() .map(WoodsShortCut::getTerrainDifficulty) .map(this::walkThroughForestPath) .orElseGet(() -> { if (isBikePresent()) { return cycleQuickestRoute(); } }); } ```
73,248,935
``` public Void traverseQuickestRoute(){ // Void return-type from interface findShortCutThroughWoods() .map(WoodsShortCut::getTerrainDifficulty) .ifPresent(this::walkThroughForestPath) // return in this case if(isBikePresent()){ return cycleQuickestRoute() } .... } ``` Is ther...
2022/08/05
[ "https://Stackoverflow.com/questions/73248935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2321414/" ]
`return` is a control statement. Neither lambdas (arrow notation), nor method refs (`WoodsShortcut::getTerrainDifficulty`) support the idea of control statements that move control to outside of themselves. Thus, the answer is a rather trivial: Nope. You have to think of the stream 'pipeline' as the thing you're worki...
There is `Optional#ifPresentOrElse` with an extra `Runnable` for the *else* case. Since java 9. ``` public Void traverseQuickestRoute() { // Void return-type from interface findShortCutThroughWoods() .map(WoodsShortCut::getTerrainDifficulty) .ifPresentOrElse(this::walkThroughForestPath, ...
17,429,280
I want to detect the edges on the serial data signal (din). I have written the following code in VHDL which is running successfully but the edges are detected with one clock period delay i.e change output is generated with one clk\_50mhz period delay at each edge. Could anyone please help me to detect edges without del...
2013/07/02
[ "https://Stackoverflow.com/questions/17429280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2463272/" ]
Here you go ``` library ieee; use ieee.std_logic_1164.all; entity double_edge_detector is port ( clk_50mhz : in std_logic; rst : in std_logic; din : in std_logic; change : out std_logic ); end double_edge_detector; architecture bhv of double_edge_detect...
You have to use a combinatorial process to detect the difference without incurring extra clock cycle delays. (You will still need one register to delay the input as well.) ``` DELAY: process(clk_50mhz) begin if clk_50mhz'event and clk_50mhz = '1' then din_reg <= din; end if; end process; change <= din...
43,979,701
In preview all good, but when I compiling, there is no image. If problem in source, so why it is showing in preview window? ![preview](https://i.stack.imgur.com/ZY4fQ.png) ![error](https://i.stack.imgur.com/HxRyF.png) ``` <Grid> <!-- Grid 4x3 --> <Grid.RowDefinitions> <RowDefinition Height="1*"></Row...
2017/05/15
[ "https://Stackoverflow.com/questions/43979701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6677766/" ]
Seems that the image you specified is not copied to the output directory. You can resolve the issue in two ways: 1) In the property grid set Build Action to "None" and Copy to Output Directory to "Copy always" (you need to do this because the siteoforigin URI seeks the resource in the binary file location) 2) Set...
Try to set source as this and see if it solve your problem. ``` <Image Source="/MonFitClub;component/Resources/logo.png"/> ``` where if i did see corectly `MonFitClub` is name od your Project.
47,148,128
this problem is driving me nuts. I have a test server and a live server. The test server is showing unicode characters retrieved from an Azure sql database correctly. While the live server running identical code accessing the same data is not showing them correctly. The data in the database is: Hallo ich heiße Pokémon...
2017/11/07
[ "https://Stackoverflow.com/questions/47148128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1556436/" ]
Edit: After searching stackoverflow, here is a solution you maybe looking for: [MySQL - How to search for exact word match using LIKE?](https://stackoverflow.com/questions/5743177/mysql-how-to-search-for-exact-word-match-using-like) What‘s you‘r searchquery exactly? ``` SELECT * FROM songs WHERE singers RLIKE '^Galla...
If you want to display 'Gallagher only then use SUBSTRING\_INDEX ``` SELECT DISTINCT SUBSTRING_INDEX(singers, " ", -1) FROM songs WHERE singers LIKE '%{$search_string}%' ORDER BY title; ```
47,148,128
this problem is driving me nuts. I have a test server and a live server. The test server is showing unicode characters retrieved from an Azure sql database correctly. While the live server running identical code accessing the same data is not showing them correctly. The data in the database is: Hallo ich heiße Pokémon...
2017/11/07
[ "https://Stackoverflow.com/questions/47148128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1556436/" ]
Edit: After searching stackoverflow, here is a solution you maybe looking for: [MySQL - How to search for exact word match using LIKE?](https://stackoverflow.com/questions/5743177/mysql-how-to-search-for-exact-word-match-using-like) What‘s you‘r searchquery exactly? ``` SELECT * FROM songs WHERE singers RLIKE '^Galla...
If you want search single name based on last name (surname) then you need to write below query ``` SELECT * FROM songs WHERE singers LIKE '%Gallagher'; ```
11,650,228
So I have situation when I need skip current test from test method body. Simplest way is to write something like this in test method. ``` if (something) return; ``` But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body. Is it possible?
2012/07/25
[ "https://Stackoverflow.com/questions/11650228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/545920/" ]
You should not skip test this way. Better do one of following things: * mark test as ignored via `[Ignore]` attribute * throw `NotImplementedException` from your test * write `Assert.Fail()` (otherwise you can forget to complete this test) * remove this test Also keep in mind, that your tests should not contain condi...
You can ignore a test and leave it completely untouched in the code. ``` [TestMethod()] [Ignore()] //ignores the test below public void SomeTestCodeTest() { //test code here } ```
11,650,228
So I have situation when I need skip current test from test method body. Simplest way is to write something like this in test method. ``` if (something) return; ``` But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body. Is it possible?
2012/07/25
[ "https://Stackoverflow.com/questions/11650228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/545920/" ]
You should not skip test this way. Better do one of following things: * mark test as ignored via `[Ignore]` attribute * throw `NotImplementedException` from your test * write `Assert.Fail()` (otherwise you can forget to complete this test) * remove this test Also keep in mind, that your tests should not contain condi...
There is an `Assert.Inconclusive()` method which you can use to nicely skip the current test. Check the [docs](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.assert.inconclusive?view=mstest-net-1.2.0). Basically it will throw an exception and will show this method as `Skipped`...
11,650,228
So I have situation when I need skip current test from test method body. Simplest way is to write something like this in test method. ``` if (something) return; ``` But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body. Is it possible?
2012/07/25
[ "https://Stackoverflow.com/questions/11650228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/545920/" ]
Further to other answers (and as suggested): I'd suggest using `Assert.Inconclusive` over `Assert.Fail`, since the original poster's situation is not an explicit failure case. Using `Inconclusive` as a result makes it clear that you don't know whether the test succeeded or failed - which is an important distinction. ...
You can ignore a test and leave it completely untouched in the code. ``` [TestMethod()] [Ignore()] //ignores the test below public void SomeTestCodeTest() { //test code here } ```
11,650,228
So I have situation when I need skip current test from test method body. Simplest way is to write something like this in test method. ``` if (something) return; ``` But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body. Is it possible?
2012/07/25
[ "https://Stackoverflow.com/questions/11650228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/545920/" ]
You can ignore a test and leave it completely untouched in the code. ``` [TestMethod()] [Ignore()] //ignores the test below public void SomeTestCodeTest() { //test code here } ```
There is an `Assert.Inconclusive()` method which you can use to nicely skip the current test. Check the [docs](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.assert.inconclusive?view=mstest-net-1.2.0). Basically it will throw an exception and will show this method as `Skipped`...
11,650,228
So I have situation when I need skip current test from test method body. Simplest way is to write something like this in test method. ``` if (something) return; ``` But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body. Is it possible?
2012/07/25
[ "https://Stackoverflow.com/questions/11650228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/545920/" ]
Further to other answers (and as suggested): I'd suggest using `Assert.Inconclusive` over `Assert.Fail`, since the original poster's situation is not an explicit failure case. Using `Inconclusive` as a result makes it clear that you don't know whether the test succeeded or failed - which is an important distinction. ...
There is an `Assert.Inconclusive()` method which you can use to nicely skip the current test. Check the [docs](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.assert.inconclusive?view=mstest-net-1.2.0). Basically it will throw an exception and will show this method as `Skipped`...
19,273,719
I have a single Crystal Report that I am trying to run via a web site using a Report Viewer and also (using the same .rpt) via a background process that would generate the report straight to a stream or file using the export options. I am not using a database, but have created an xml schema file and am generating an x...
2013/10/09
[ "https://Stackoverflow.com/questions/19273719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2564788/" ]
Have you tried something like this: ``` Report.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("Foldername/Reportname.pdf")); ```
Try this code: ``` report.ExportOptions.DestinationType = CRExportDestinationType.crEDTDiskFile; report.ExportOptions.FormatType = CRExportFormatType.crEFTPortableDocFormat; DiskFileDestinationOptions fileOption = new DiskFileDestinationOptions(); fileOpt...
19,273,719
I have a single Crystal Report that I am trying to run via a web site using a Report Viewer and also (using the same .rpt) via a background process that would generate the report straight to a stream or file using the export options. I am not using a database, but have created an xml schema file and am generating an x...
2013/10/09
[ "https://Stackoverflow.com/questions/19273719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2564788/" ]
Have you tried something like this: ``` Report.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("Foldername/Reportname.pdf")); ```
You could try this: ``` PageMargins margins = new PageMargins { topMargin = 100, leftMargin = 250, bottomMargin = 100, rightMargin = 100 }; report.PrintOptions.ApplyPageMargins(margins ); Stream str = report.ExportToStream(ExportFormatType.PortableDocFormat); int length = Convert.ToInt32(str.Length); byte[] bytes = ne...
28,492,909
I'm putting together a site which has a protected section where users must be logged in to access. I've done this in Laravel 4 without too much incident. However, for the life of me I cannot figure out why I can't get it to work in Laravel 5(L5). In L5 middleware was/were introduced. This changes the route file to: `...
2015/02/13
[ "https://Stackoverflow.com/questions/28492909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3265547/" ]
you forgot the `uses` key : ``` Route::get('foo/bar/{id}', ['middleware'=>'auth', 'uses'=>'FooController@show']); ```
If you add anything more than your controller method into your routes you need to add `uses` as key of the array for your controller, so for example if I don't haw any middleware it's enough to write: ``` Route::get('foo/bar', 'FooController@index'); Route::get('foo/bar/{id}', 'FooController@show'); ``` However if y...
28,492,909
I'm putting together a site which has a protected section where users must be logged in to access. I've done this in Laravel 4 without too much incident. However, for the life of me I cannot figure out why I can't get it to work in Laravel 5(L5). In L5 middleware was/were introduced. This changes the route file to: `...
2015/02/13
[ "https://Stackoverflow.com/questions/28492909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3265547/" ]
you forgot the `uses` key : ``` Route::get('foo/bar/{id}', ['middleware'=>'auth', 'uses'=>'FooController@show']); ```
In case you don't use a controller for your view and you just want to display the view, you should do this: ``` Route::get('foo/bar', ['middleware' => 'auth', function () { return View::make('path.to.your.page'); }]); ```
40,313,389
I am attempting to extract IP Address from a MySQL database using REGEX ina a SELECT statement. When i run the Query in the MySQL console it returns the expected results: ``` SELECT * FROM database.table WHERE field3 REGEXP '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-...
2016/10/28
[ "https://Stackoverflow.com/questions/40313389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6744297/" ]
To answer how to add the `avx` flag into compiler options. In your case the f77 complier is being picked `gfortran:f77: ./distance.f` < That is the key line. You could try specifying `--f77flags=-mavx`
In the comments Warren Weckesser explained that Fortran arrays are stored transposed with regards to the C ones. However, one important implication was not mentioned. To traverse the array in the right order, you have to switch the order of the loops. In C the first index is the outer loop, in Fortran the first index s...
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
You replace the value each time in the loop, so the output is only the result of the last iteration: 4\*4. Not exactly what calculation you want to do that will give you 24, but maybe you want to add the result to the previous value of y, or multiple it?
x = i+i will get executed for each of the values and the print the last one... so will print 8 for the add and 16 for multiplication.
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
You replace the value each time in the loop, so the output is only the result of the last iteration: 4\*4. Not exactly what calculation you want to do that will give you 24, but maybe you want to add the result to the previous value of y, or multiple it?
your code doesn't work correctly because you are only returning the result of the last element in the list simplest implementation without sum(): ``` nums = [1,2,3,4] def add(): x = 0 for i in nums : x += i return x def multiple(): y = 1 for i in nums : y *= i return y print...
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
You only add/multiply the last line So is X=4\*4 = 16 for mulitply and X=4+4 = 8 for add the previous attempts are overwritten in the for-loop
x = i+i will get executed for each of the values and the print the last one... so will print 8 for the add and 16 for multiplication.
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
**Here you go:** ``` nums = [1,2,3,4] def add(): return sum(nums) def multiple(): result = 1 for num in nums: result *= num return result print add() print multiple() ``` **Output:** ``` 10 24 ``` > > If you don't want to use **`sum`** built-in function then you can use this function: ...
x = i+i will get executed for each of the values and the print the last one... so will print 8 for the add and 16 for multiplication.
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
your code doesn't work correctly because you are only returning the result of the last element in the list simplest implementation without sum(): ``` nums = [1,2,3,4] def add(): x = 0 for i in nums : x += i return x def multiple(): y = 1 for i in nums : y *= i return y print...
x = i+i will get executed for each of the values and the print the last one... so will print 8 for the add and 16 for multiplication.
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
You only add/multiply the last line So is X=4\*4 = 16 for mulitply and X=4+4 = 8 for add the previous attempts are overwritten in the for-loop
your code doesn't work correctly because you are only returning the result of the last element in the list simplest implementation without sum(): ``` nums = [1,2,3,4] def add(): x = 0 for i in nums : x += i return x def multiple(): y = 1 for i in nums : y *= i return y print...
33,806,541
I got this homework assignment, cant figure it out. I need to ask the user how many town names he wants to enter. For example 5. Then, he enters the 5 town names. Afterwards, we need to find the average length of the names and show him the names which have less letters than the average length. Thanks for your shared ti...
2015/11/19
[ "https://Stackoverflow.com/questions/33806541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581685/" ]
**Here you go:** ``` nums = [1,2,3,4] def add(): return sum(nums) def multiple(): result = 1 for num in nums: result *= num return result print add() print multiple() ``` **Output:** ``` 10 24 ``` > > If you don't want to use **`sum`** built-in function then you can use this function: ...
your code doesn't work correctly because you are only returning the result of the last element in the list simplest implementation without sum(): ``` nums = [1,2,3,4] def add(): x = 0 for i in nums : x += i return x def multiple(): y = 1 for i in nums : y *= i return y print...
2,029,257
By considering the set $\{1,2,3,4\}$, one can easily come up with an [example](https://en.wikipedia.org/wiki/Pairwise_independence) (attributed to S. Bernstein) of pairwise independent but not independent random variables. Counld anybody give an example with [continuous random variables](https://en.wikipedia.org/wiki...
2016/11/24
[ "https://math.stackexchange.com/questions/2029257", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Let $x,y,z'$ be normally distributed, with $0$ mean. Define $$z=\begin{cases} z' & xyz'\ge 0\\ -z' & xyz'<0\end{cases}$$ The resulting $x,y,z$ will always satisfy $xyz\ge 0$, but be pairwise independent.
An [answer of mine on stats.SE](https://stats.stackexchange.com/a/180727/6633) gives essentially the same answer as the one given by vadim123. Consider three *standard normal random variables* $X,Y,Z$ whose joint probability density function $f\_{X,Y,Z}(x,y,z)$ is **not** $\phi(x)\phi(y)\phi(z)$ where $\phi(\cdot)$ is...
2,029,257
By considering the set $\{1,2,3,4\}$, one can easily come up with an [example](https://en.wikipedia.org/wiki/Pairwise_independence) (attributed to S. Bernstein) of pairwise independent but not independent random variables. Counld anybody give an example with [continuous random variables](https://en.wikipedia.org/wiki...
2016/11/24
[ "https://math.stackexchange.com/questions/2029257", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Let $x,y,z'$ be normally distributed, with $0$ mean. Define $$z=\begin{cases} z' & xyz'\ge 0\\ -z' & xyz'<0\end{cases}$$ The resulting $x,y,z$ will always satisfy $xyz\ge 0$, but be pairwise independent.
The continuous analog of the Bernstein example: Divide up the unit cube into eight congruent subcubes of side length $1/2$. Select four of these cubes: Subcube #1 has one vertex at $(x,y,z)=(1,0,0)$, subcube #2 has one vertex at $(0,1,0)$, subcube #3 has one vertex at $(0,0,1)$, and subcube #4 has one vertex at $(1,1,1...
2,029,257
By considering the set $\{1,2,3,4\}$, one can easily come up with an [example](https://en.wikipedia.org/wiki/Pairwise_independence) (attributed to S. Bernstein) of pairwise independent but not independent random variables. Counld anybody give an example with [continuous random variables](https://en.wikipedia.org/wiki...
2016/11/24
[ "https://math.stackexchange.com/questions/2029257", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Let $x,y,z'$ be normally distributed, with $0$ mean. Define $$z=\begin{cases} z' & xyz'\ge 0\\ -z' & xyz'<0\end{cases}$$ The resulting $x,y,z$ will always satisfy $xyz\ge 0$, but be pairwise independent.
Here's a potentially very simple construction for $k$-wise independent random variables, uniformly distributed on $[0, 1]$ (though admittedly I didn't work it out very carefully so hopefully the condition checks out)? There is a standard way of constructing discrete $k$-wise independent random variables: let $X\_1,\ldo...
2,029,257
By considering the set $\{1,2,3,4\}$, one can easily come up with an [example](https://en.wikipedia.org/wiki/Pairwise_independence) (attributed to S. Bernstein) of pairwise independent but not independent random variables. Counld anybody give an example with [continuous random variables](https://en.wikipedia.org/wiki...
2016/11/24
[ "https://math.stackexchange.com/questions/2029257", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
An [answer of mine on stats.SE](https://stats.stackexchange.com/a/180727/6633) gives essentially the same answer as the one given by vadim123. Consider three *standard normal random variables* $X,Y,Z$ whose joint probability density function $f\_{X,Y,Z}(x,y,z)$ is **not** $\phi(x)\phi(y)\phi(z)$ where $\phi(\cdot)$ is...
Here's a potentially very simple construction for $k$-wise independent random variables, uniformly distributed on $[0, 1]$ (though admittedly I didn't work it out very carefully so hopefully the condition checks out)? There is a standard way of constructing discrete $k$-wise independent random variables: let $X\_1,\ldo...
2,029,257
By considering the set $\{1,2,3,4\}$, one can easily come up with an [example](https://en.wikipedia.org/wiki/Pairwise_independence) (attributed to S. Bernstein) of pairwise independent but not independent random variables. Counld anybody give an example with [continuous random variables](https://en.wikipedia.org/wiki...
2016/11/24
[ "https://math.stackexchange.com/questions/2029257", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
The continuous analog of the Bernstein example: Divide up the unit cube into eight congruent subcubes of side length $1/2$. Select four of these cubes: Subcube #1 has one vertex at $(x,y,z)=(1,0,0)$, subcube #2 has one vertex at $(0,1,0)$, subcube #3 has one vertex at $(0,0,1)$, and subcube #4 has one vertex at $(1,1,1...
Here's a potentially very simple construction for $k$-wise independent random variables, uniformly distributed on $[0, 1]$ (though admittedly I didn't work it out very carefully so hopefully the condition checks out)? There is a standard way of constructing discrete $k$-wise independent random variables: let $X\_1,\ldo...
31,670
I have an 8 year old son who refuses to use the restroom. He does #1 in toilet but not #2. This has been going on for less than a year, I'd say about 8 months now. Before that, his potty routine was normal. Out of nowhere he started refusing to go. I've asked him if there's any reason to why he doesn't use the toilet a...
2017/09/08
[ "https://parenting.stackexchange.com/questions/31670", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/29589/" ]
> > What can I do to make him use the restroom like he used to? > > > My son went through something similar when he was young, and in my case it was just a battle of wills. I said to him you need to **poopy in the potty**. I would repeat this phrase over and over again. I would sit with him in the bathroom until h...
I don't know if this will help you but I must share my experience as what we did HELPED!!! 1. We had NO idea our (completely healthy)teen child was having issues with what I NOW know is called soiling/encopresis. I had no idea it was a thing or that my poor child had been dealing with it for YEARS. THEY didn't even kno...
31,670
I have an 8 year old son who refuses to use the restroom. He does #1 in toilet but not #2. This has been going on for less than a year, I'd say about 8 months now. Before that, his potty routine was normal. Out of nowhere he started refusing to go. I've asked him if there's any reason to why he doesn't use the toilet a...
2017/09/08
[ "https://parenting.stackexchange.com/questions/31670", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/29589/" ]
The first thing which needs to be done is that the child needs to see a pediatrician who specializes in *encopresis*, or a pediatric gastroenterologist. Once a child past the age of 4 starts soiling their pants, it might be a medical problem. (There are medical conditions that start earlier, but they are usually recogn...
I don't know if this will help you but I must share my experience as what we did HELPED!!! 1. We had NO idea our (completely healthy)teen child was having issues with what I NOW know is called soiling/encopresis. I had no idea it was a thing or that my poor child had been dealing with it for YEARS. THEY didn't even kno...
51,415,248
I got two dictionaries and both of them have same keys ,i am trying to access the second dictionary using the key as input of first dictionary like below ``` Players = {0: "Quit", 1: "Player 1", 2: "Player 2", 3: "Player 3", 4: "Player 4", 5: "Player 5"...
2018/07/19
[ "https://Stackoverflow.com/questions/51415248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9775079/" ]
Use `font-size: 0;` to `ul` and `font-size: 15px;` to `li` ```css ul { display: block; columns: 2; font-size: 0; } li { border-top: 1px solid black; list-style: none; font-size: 15px; } ``` ```html <ul> <li>TEST 1</li> <li>TEST 2</li> <li>TEST 3</li> <li>TEST 4</li> <li>TEST 5</li> <li>TES...
Try to use `column-gap: 0;`. If I understood you correctly, this is what you need. ```css ul { display: block; columns: 2; column-gap: 0; } li { border-top: 1px solid #e9e9e9; list-style: none; } ``` ```html <ul> <li>TEST 1</li> <li>TEST 2</li> <li>TEST 3</li> <li>TEST 4</li> <li>TEST 5</li> ...
51,415,248
I got two dictionaries and both of them have same keys ,i am trying to access the second dictionary using the key as input of first dictionary like below ``` Players = {0: "Quit", 1: "Player 1", 2: "Player 2", 3: "Player 3", 4: "Player 4", 5: "Player 5"...
2018/07/19
[ "https://Stackoverflow.com/questions/51415248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9775079/" ]
Use `font-size: 0;` to `ul` and `font-size: 15px;` to `li` ```css ul { display: block; columns: 2; font-size: 0; } li { border-top: 1px solid black; list-style: none; font-size: 15px; } ``` ```html <ul> <li>TEST 1</li> <li>TEST 2</li> <li>TEST 3</li> <li>TEST 4</li> <li>TEST 5</li> <li>TES...
**You Can Try Another Way to use flex box** ```css ul { display:flex; flex-wrap:wrap; box-sizing: border-box; } li { width:50%; padding: 5px 15px 5px 5px; border-top: 1px solid black; list-style: none; font-size: 15px; box-sizing: border-box; } ``` ```html <ul> <li>TEST 1</li> <li>TES...
51,415,248
I got two dictionaries and both of them have same keys ,i am trying to access the second dictionary using the key as input of first dictionary like below ``` Players = {0: "Quit", 1: "Player 1", 2: "Player 2", 3: "Player 3", 4: "Player 4", 5: "Player 5"...
2018/07/19
[ "https://Stackoverflow.com/questions/51415248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9775079/" ]
You can just use `column-gap: 0;` to your `ul` ```css ul { display: block; -webkit-columns: 2; /* Chrome, Safari, Opera */ -moz-columns: 2; /* Firefox */ columns: 2; -webkit-column-gap: 0; /* Chrome, Safari, Opera */ -moz-column-gap: 0; /* Firefox */ column-gap: 0; } li { border-...
Try to use `column-gap: 0;`. If I understood you correctly, this is what you need. ```css ul { display: block; columns: 2; column-gap: 0; } li { border-top: 1px solid #e9e9e9; list-style: none; } ``` ```html <ul> <li>TEST 1</li> <li>TEST 2</li> <li>TEST 3</li> <li>TEST 4</li> <li>TEST 5</li> ...
51,415,248
I got two dictionaries and both of them have same keys ,i am trying to access the second dictionary using the key as input of first dictionary like below ``` Players = {0: "Quit", 1: "Player 1", 2: "Player 2", 3: "Player 3", 4: "Player 4", 5: "Player 5"...
2018/07/19
[ "https://Stackoverflow.com/questions/51415248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9775079/" ]
You can just use `column-gap: 0;` to your `ul` ```css ul { display: block; -webkit-columns: 2; /* Chrome, Safari, Opera */ -moz-columns: 2; /* Firefox */ columns: 2; -webkit-column-gap: 0; /* Chrome, Safari, Opera */ -moz-column-gap: 0; /* Firefox */ column-gap: 0; } li { border-...
**You Can Try Another Way to use flex box** ```css ul { display:flex; flex-wrap:wrap; box-sizing: border-box; } li { width:50%; padding: 5px 15px 5px 5px; border-top: 1px solid black; list-style: none; font-size: 15px; box-sizing: border-box; } ``` ```html <ul> <li>TEST 1</li> <li>TES...
18,331,189
I have form like this: ``` <%= simple_form_for @category do |f| %> <%= f.input :name %> <%= f.input :description %> <%= f.input :parent_id, collection: @board.subtree, include_blank: false %> <%= f.button :submit %> <% end %> ``` `@category` is instance of `Board` so this `:submit` tries to run `create` act...
2013/08/20
[ "https://Stackoverflow.com/questions/18331189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1654940/" ]
Just add the `url` option. ``` <%= simple_form_for @category, url: category_path(@category) do |f| %> ```
This might help: <https://stackoverflow.com/a/7136142/2128691> so yours would look like: ``` <%= simple_form_for @category, :url => category_path, do |f| %> ... <% end ```
34,990,495
Is there a way to use an event to call a function when the JSON.Parse() has parsed all the objects from a file?
2016/01/25
[ "https://Stackoverflow.com/questions/34990495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5685815/" ]
`JSON.parse` is synchronous. it returns the object corresponding to the given JSON text. More about it from [mozilla](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) now a good way of doing JSON.parse is shown below (inside a try-catch) ``` try { var data = JSON.parse(st...
**EDIT: Since question was changed.** JSON.parse() is a synchronous method, meaning that once it's called it will execute fully, before code execution continues. ``` var obj= JSON.parse(jsonString); obj.prop; // obj is already accessible. ``` --- JSON.parse, doesn't actually load any files. It's also synchronous, ...
157,005
I have this tree shape artwork and i want to trim hole (which are spotted with black color). I tried with all the trim options, Did not work. How can i trim. Any other way or option [File](https://drive.google.com/file/d/1qjEp-3dyvqJSyAC8ivlnk8bKEl6zmx6F/view?usp=sharing) [![enter image description here](https://i.st...
2022/05/04
[ "https://graphicdesign.stackexchange.com/questions/157005", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/173783/" ]
Assuming the circles are on top of everything else... * Select all the circles * Choose `Object > Compound Path > Make` from the menu. This forces Illustrator to see the circles as one, singular object, rather than a collection of objects. * Change the **Fill** of the circles to be either 100C100M100Y100K or 0R0G0B, d...
Definitely what Scott said, but depending on your end purpose, it may actually be easier and quicker to just edit the circles from a black fill, to a white fill.
91,269
I want to test a video IP core that reads a block of memory and writes to it again. The IP core is using the VFBC. My idea for testing was to write a core that looks like the VFBC, but just uses a simple 32Meg RAM as back-end. It is allocated like this: ``` memory_size : NATURAL := ((2 * 2048) * 2048) type memory_arr...
2013/11/20
[ "https://electronics.stackexchange.com/questions/91269", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/25263/" ]
If the memory you are simulating can fit into the ram of the workstation then using a fixed-size storage is the easiest to use. But as you have seen, signals are much more expensive compared to variables. This difference is related to the *discrete event simulation* model that VHDL is based on. A signal assignment sche...
Are you needing to use all of that memory? Could you get away with simulating a sparse memory... Using some data structure like a dictionary (I have an [AVL tree](http://en.wikipedia.org/wiki/AVL_tree) - in my 'made-at-work' library, so i can't share it I'm afraid :( ) you can store just the values which have been wr...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
You want to use a refactoring that replaces a conditional using a polymorphic class. For [example](http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html). Or here's another [example](http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism) Essentially the ideal is very simple y...
You don't say what language you're using, but if you are using an OO language such as C++, C# or Java, you can often use **virtual functions** to solve the same problem as you are currently solving with a `switch` statement, and in a more extensible way. In the case of C++, compare: ``` class X { public: int get_t...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
You want to use a refactoring that replaces a conditional using a polymorphic class. For [example](http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html). Or here's another [example](http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism) Essentially the ideal is very simple y...
I actually wrote about how to solve this issues in my blog in April of 2008. Take a look [here](http://adotnetdude.blogspot.com/2008/03/refactoring-code-with-too-many.html) and let me know what you think. I recommend you: 1. Use polymorphism to get the correct run-time behavior you need without conditional statement...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
Were you thinking of Google's "[The Clean Code Talks -- Inheritance, Polymorphism, & Testing](http://www.youtube.com/watch?v=4F72VULWFvc)" video? It discusses approaches to using Object Oriented techniques to remove if/switch conditionals.
How about: ``` /* Code Block 1... */ if(/* result of some condition or function call */) { /* Code Block 2... */ if(/* result of some condition or function call */) { /* Code Block 3... */ if(/* result of some condition or function call */) { /* Code Block 4... */ } } } ...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
Have you read [this](http://www.codinghorror.com/blog/archives/000486.html) on flattening arrow code from Coding Horror? You can replace throw with return or goto if you're using a language without exceptions.
I actually wrote about how to solve this issues in my blog in April of 2008. Take a look [here](http://adotnetdude.blogspot.com/2008/03/refactoring-code-with-too-many.html) and let me know what you think. I recommend you: 1. Use polymorphism to get the correct run-time behavior you need without conditional statement...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
You want to use a refactoring that replaces a conditional using a polymorphic class. For [example](http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html). Or here's another [example](http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism) Essentially the ideal is very simple y...
Have you read [this](http://www.codinghorror.com/blog/archives/000486.html) on flattening arrow code from Coding Horror? You can replace throw with return or goto if you're using a language without exceptions.
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
You don't say what language you're using, but if you are using an OO language such as C++, C# or Java, you can often use **virtual functions** to solve the same problem as you are currently solving with a `switch` statement, and in a more extensible way. In the case of C++, compare: ``` class X { public: int get_t...
How about: ``` /* Code Block 1... */ if(/* result of some condition or function call */) { /* Code Block 2... */ if(/* result of some condition or function call */) { /* Code Block 3... */ if(/* result of some condition or function call */) { /* Code Block 4... */ } } } ...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
I actually wrote about how to solve this issues in my blog in April of 2008. Take a look [here](http://adotnetdude.blogspot.com/2008/03/refactoring-code-with-too-many.html) and let me know what you think. I recommend you: 1. Use polymorphism to get the correct run-time behavior you need without conditional statement...
You don't say what language you're using, but if you are using an OO language such as C++, C# or Java, you can often use **virtual functions** to solve the same problem as you are currently solving with a `switch` statement, and in a more extensible way. In the case of C++, compare: ``` class X { public: int get_t...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
Have you read [this](http://www.codinghorror.com/blog/archives/000486.html) on flattening arrow code from Coding Horror? You can replace throw with return or goto if you're using a language without exceptions.
You might want to look at the [Strategy Pattern](http://en.wikipedia.org/wiki/Strategy_pattern), wherein instead of putting a long chain of ifs with linked conditions, you abstract each condition to a different object, each one defining what its specific behavior. The class that defines those objects will implement a...
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
Have you read [this](http://www.codinghorror.com/blog/archives/000486.html) on flattening arrow code from Coding Horror? You can replace throw with return or goto if you're using a language without exceptions.
Were you thinking of Google's "[The Clean Code Talks -- Inheritance, Polymorphism, & Testing](http://www.youtube.com/watch?v=4F72VULWFvc)" video? It discusses approaches to using Object Oriented techniques to remove if/switch conditionals.
494,506
Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements? I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though
2009/01/30
[ "https://Stackoverflow.com/questions/494506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22039/" ]
You want to use a refactoring that replaces a conditional using a polymorphic class. For [example](http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html). Or here's another [example](http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism) Essentially the ideal is very simple y...
How about: ``` /* Code Block 1... */ if(/* result of some condition or function call */) { /* Code Block 2... */ if(/* result of some condition or function call */) { /* Code Block 3... */ if(/* result of some condition or function call */) { /* Code Block 4... */ } } } ...
38,116,133
I have a nodejs + expressjs app that needs to be converted to an android. A quick solution that we are thinking of is to use phonegap. The issue I am stuck with is all my files under view folder of the web app are ejs files. When I try to upload my app to phonegap it says no index.html found in my .zip folder. My qu...
2016/06/30
[ "https://Stackoverflow.com/questions/38116133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3467302/" ]
As per our discussion discussion , below solution comes:- 1.Need to install `CURL` on your system by the command :- ``` sudo apt-get install php7.0-curl ``` 2.Regarding second error i got this link:- [utf8\_(en|de)code removed from php7?](https://stackoverflow.com/questions/35701730/utf8-endecode-removed-from-php7...
`utf8_encode()` is a function under the `php xml extension`, and `curl` of-course under the `curl extension`. Solved by ``` sudo apt-get install php7.0-curl ``` and ``` sudo apt-get install php7.0-xml ```
59,444,161
I am getting really frustrated already. I have tried so many variations and searched for an answer in all existing stackoverflow questions, but it didn't help. All I need is to get **ALL the text** (**without the @class name 'menu' or without the @id name 'menu'**) I have tried already these commands: ``` //*[not(des...
2019/12/22
[ "https://Stackoverflow.com/questions/59444161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7513730/" ]
This very convoluted xpath 1.0 expression works on your sample html. It would be somewhat simpler in xpath 2.0 and above. But try it on your actual code: ``` //*[not(descendant-or-self::*[contains(@class,'menu')])] [not(descendant-or-self::*[contains(@id,'menu')])] [not(ancestor-or-self::*[contains(@class,'menu')])...
Well, if you consider the element `<li class=""><a href="/Site/DMB/Video.de.html">VideoServices</a> </li>` it's a descendant-or-self of something, and it doesn't have the relevant id or class attribute, so of course it gets selected. Perhaps you want `//*[not(ancestor-or-self::*[@id='menu' or @class='menu']]` You w...
59,444,161
I am getting really frustrated already. I have tried so many variations and searched for an answer in all existing stackoverflow questions, but it didn't help. All I need is to get **ALL the text** (**without the @class name 'menu' or without the @id name 'menu'**) I have tried already these commands: ``` //*[not(des...
2019/12/22
[ "https://Stackoverflow.com/questions/59444161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7513730/" ]
This very convoluted xpath 1.0 expression works on your sample html. It would be somewhat simpler in xpath 2.0 and above. But try it on your actual code: ``` //*[not(descendant-or-self::*[contains(@class,'menu')])] [not(descendant-or-self::*[contains(@id,'menu')])] [not(ancestor-or-self::*[contains(@class,'menu')])...
You can iterate tags through scrapy lxml tree directly as it in this code sample: ``` result = [] for tag in response.css("*"): if 'id' not in tag.attrib and 'class' not in tag.attrib and 'href' not in tag.attrib: text = tag.css("::text").extract_first("").strip("\n ") if text: result.a...
60,140,614
So I have a wordlist containing 3 words: ``` Apple Christmas Tree Shopping Bag ``` And I know only certain characters in the word and the length of the word, for instance: > > *???i???as ?r??* > > > where the **?** means it's an unknown character and I want to type it into the console and get an output of ALL ...
2020/02/09
[ "https://Stackoverflow.com/questions/60140614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10123677/" ]
You can turn your expression into a regex and try matching with that: ``` import re words = [ 'Apple', 'Christmas Tree', 'Shopping Bag' ] match = '???i???as ?r??' regex = '^' + match.replace('?', '.') + '$' # turn your expression into a proper regex for word in words: # go through each word if r...
Try If `str` is in list. ``` IF "str" IN [list] ```
60,140,614
So I have a wordlist containing 3 words: ``` Apple Christmas Tree Shopping Bag ``` And I know only certain characters in the word and the length of the word, for instance: > > *???i???as ?r??* > > > where the **?** means it's an unknown character and I want to type it into the console and get an output of ALL ...
2020/02/09
[ "https://Stackoverflow.com/questions/60140614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10123677/" ]
You can turn your expression into a regex and try matching with that: ``` import re words = [ 'Apple', 'Christmas Tree', 'Shopping Bag' ] match = '???i???as ?r??' regex = '^' + match.replace('?', '.') + '$' # turn your expression into a proper regex for word in words: # go through each word if r...
If you have a *small* word list, then you can run a regex scan on the whole word list. Convert the query string into a regex and you're good to go. Otherwise, you can organize the word list in chunks, e.g. the equivalent of splitting it into several files in different directories: ``` Appl => [ Apple ] Chri => [ Chri...
60,140,614
So I have a wordlist containing 3 words: ``` Apple Christmas Tree Shopping Bag ``` And I know only certain characters in the word and the length of the word, for instance: > > *???i???as ?r??* > > > where the **?** means it's an unknown character and I want to type it into the console and get an output of ALL ...
2020/02/09
[ "https://Stackoverflow.com/questions/60140614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10123677/" ]
If you have a *small* word list, then you can run a regex scan on the whole word list. Convert the query string into a regex and you're good to go. Otherwise, you can organize the word list in chunks, e.g. the equivalent of splitting it into several files in different directories: ``` Appl => [ Apple ] Chri => [ Chri...
Try If `str` is in list. ``` IF "str" IN [list] ```
54,828,044
I'm trying to reference an object that I'm matching for. ``` import re list = ["abc","b","c"] if any(re.search(r"a",i) for i in list): print("yes") print(i) ``` This works, just not the last `print` command. Is there any way to do what I'm trying do to here?
2019/02/22
[ "https://Stackoverflow.com/questions/54828044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9599075/" ]
This solution will scale worse for *large arrays*, for such cases the other proposed answers will perform better. --- Here's one way taking advantage of [`broadcasting`](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html): ``` (coo[:,None] == targets).all(2).any(1) # array([False, True, True, False]) ...
Here is a simple and intuitive solution that actually uses `numpy.isin()`, to **match tuples**, rather than match individual numbers: ``` # View as a 1d array of tuples coo_view = coo.view(dtype='i,i').reshape((-1,)) targets_view = targets.view(dtype='i,i').reshape((-1,)) result = np.isin(coo_view, targets_view) ...
54,828,044
I'm trying to reference an object that I'm matching for. ``` import re list = ["abc","b","c"] if any(re.search(r"a",i) for i in list): print("yes") print(i) ``` This works, just not the last `print` command. Is there any way to do what I'm trying do to here?
2019/02/22
[ "https://Stackoverflow.com/questions/54828044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9599075/" ]
This solution will scale worse for *large arrays*, for such cases the other proposed answers will perform better. --- Here's one way taking advantage of [`broadcasting`](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html): ``` (coo[:,None] == targets).all(2).any(1) # array([False, True, True, False]) ...
The [numpy\_indexed](https://github.com/EelcoHoogendoorn/Numpy_arraysetops_EP/blob/master/numpy_indexed/arraysetops.py#L86) package implements functionality of this type in a vectorized manner (disclaimer: I am its author). Sadly numpy lacks a lot of this functionality out of the box; I started numpy\_indexed with the ...
1,393,216
I have an strange problem. This is Microsoft Office 365 under Windows 10 and I don't remember when, but every time I start the computer, Excel is opened with a blank workbook. I looked at startup tab in task manager and it is not there.. I also saw in Settings -> Applications -> Startup and it is not there two. Do y...
2019/01/11
[ "https://superuser.com/questions/1393216", "https://superuser.com", "https://superuser.com/users/524721/" ]
It turns out that this may be caused by a so-called feature of Microsoft. Short answer: Windows Settings->Accounts->Sign-In Options->Privacy->Off Longer answer: <https://answers.microsoft.com/en-us/msoffice/forum/all/microsoft-word-and-excel-2016-automatically-opens/8d5869df-0212-4f04-9fac-c7e99256a005>
The issue might be from a startup application or service which is opening excel at startup. Run msconfig from the run dialog(Windows Key + R) to open the System Configuration. From the General Tab choose Selective StartUp, uncheck Load startup items(this will disable all startup items seen in the Task Manager). Apply ...
58,140,603
How can i make single select statement that combine both Select statements on the basis of only common 'PO' and 'Style Number' column ![First select statement result](https://i.stack.imgur.com/MGZJ2.png) ![Second select statment result](https://i.stack.imgur.com/1byJI.png)
2019/09/27
[ "https://Stackoverflow.com/questions/58140603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11571211/" ]
[ASP.NET Core 3.0 not currently available for Azure App Service.](https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#aspnet-core-30-not-currently-available-for-azure-app-service) [Microsoft Docs] The [preview versions of .NET Core 3.0](https://learn.microsoft.com/en...
Change this in web.config: ```xml <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> ``` to this: ```xml <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> ``` I ...
58,140,603
How can i make single select statement that combine both Select statements on the basis of only common 'PO' and 'Style Number' column ![First select statement result](https://i.stack.imgur.com/MGZJ2.png) ![Second select statment result](https://i.stack.imgur.com/1byJI.png)
2019/09/27
[ "https://Stackoverflow.com/questions/58140603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11571211/" ]
The current [picture](https://aspnetcoreon.azurewebsites.net/) is that ASP.NET Core 3.0 is available everywhere (but not the SDK). Despite this fact, I (seemingly randomly) got a ``` HTTP Error 500.31 - ANCM Failed to Find Native Dependencies ``` until I realized that activating logging in `web.config` by setting `...
Change this in web.config: ```xml <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> ``` to this: ```xml <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> ``` I ...
22,098,456
I have in my MainPage() the following line of code: ``` string str = tbx1.Text; ``` Then I have a slider that changes this TextBox: ``` private void Slider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e) { Slider slider1 = sender as Slider; tbx1.Text = slider1.Value.T...
2014/02/28
[ "https://Stackoverflow.com/questions/22098456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1189952/" ]
If string is accessable you can do the following ``` private void Slider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e) { Slider slider1 = sender as Slider; tbx1.Text = slider1.Value.ToString(); str = slider1.Value.ToString(); } ```
if you want to change str when `tbx1.Text` you can do that : youcan declare your value in your class ``` private string _str ``` then you have to make your code : (you have to add Leave function to your textbox) ``` private void tbx1_Leave(object sender, EventArgs e) { _str = tbx1.Text; } private void Slider...
22,098,456
I have in my MainPage() the following line of code: ``` string str = tbx1.Text; ``` Then I have a slider that changes this TextBox: ``` private void Slider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e) { Slider slider1 = sender as Slider; tbx1.Text = slider1.Value.T...
2014/02/28
[ "https://Stackoverflow.com/questions/22098456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1189952/" ]
You can wrap the string in a property and access it dynamically: ``` string Str { get { return tbx1.Text; } set { tbx1.Text = value; } } ``` If you only need to read the string then you can drop the setter: ``` string Str { get { return tbx1.Text; } } ``` Use the property `Str` instead of the variable...
if you want to change str when `tbx1.Text` you can do that : youcan declare your value in your class ``` private string _str ``` then you have to make your code : (you have to add Leave function to your textbox) ``` private void tbx1_Leave(object sender, EventArgs e) { _str = tbx1.Text; } private void Slider...
1,921,621
I have this problem for a long time, and can't find a solution. I guess this might be something everybodys faced using Sphinx, but I cnanot get any usefull information. I have one index, and a delta. I queried in a php module both indexes, and then show the results. For each ID in the result, I create an object for th...
2009/12/17
[ "https://Stackoverflow.com/questions/1921621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170915/" ]
Maybe this fits better to my needs, but involves changing the database. <http://sphinxsearch.com/docs/current.html#conf-sql-query-killlist>
I suppose you could ask for maybe 25 results from sphinx and then when you get the full data from your DB just have a `limit 20` on the query.
1,921,621
I have this problem for a long time, and can't find a solution. I guess this might be something everybodys faced using Sphinx, but I cnanot get any usefull information. I have one index, and a delta. I queried in a php module both indexes, and then show the results. For each ID in the result, I create an object for th...
2009/12/17
[ "https://Stackoverflow.com/questions/1921621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170915/" ]
What I've done in my Ruby Sphinx adapter, Thinking Sphinx, is to track when records are deleted, and update a boolean attribute for the records in the main index (I call it `sphinx_deleted`). Then, whenever I search, I filter on values where `sphinx_deleted` is 0. In the sql\_query configuration, I have the explicit at...
I suppose you could ask for maybe 25 results from sphinx and then when you get the full data from your DB just have a `limit 20` on the query.
1,921,621
I have this problem for a long time, and can't find a solution. I guess this might be something everybodys faced using Sphinx, but I cnanot get any usefull information. I have one index, and a delta. I queried in a php module both indexes, and then show the results. For each ID in the result, I create an object for th...
2009/12/17
[ "https://Stackoverflow.com/questions/1921621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170915/" ]
What I've done in my Ruby Sphinx adapter, Thinking Sphinx, is to track when records are deleted, and update a boolean attribute for the records in the main index (I call it `sphinx_deleted`). Then, whenever I search, I filter on values where `sphinx_deleted` is 0. In the sql\_query configuration, I have the explicit at...
Maybe this fits better to my needs, but involves changing the database. <http://sphinxsearch.com/docs/current.html#conf-sql-query-killlist>
54,145,150
I am trying to automate a pretty trivial scenario where I have to get the text inside multiple `li` child elements of a `ul` elements and compare it against a given array. I am using Protractor with Cucumber JS and using `async/await` to manage promises. My scenario HTML looks something like this ``` <div clas...
2019/01/11
[ "https://Stackoverflow.com/questions/54145150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1728790/" ]
```js (function ($) { $.fn.formNavigation = function () { $(this).each(function () { // Events triggered on keydown (repeatable when holding the key) $(this).find('input').on('keydown', function(e) { // Vertical navigation using tab as OP wanted if (e.which === 13 && !e.shiftKey...
Try tabIndex [TabIndex MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) ``` <table> <tr> <td><input tabindex="0" class="vertical_row1" type="text" name="" value="" placeholder=""></td> <td><input tabindex="2" class="vertical_row2" type="text" name="...
19,680
I mean through out the whole show cars are depicted almost exactly the same as cars from our time, except for the lack of wheels. You would think that people 1000 years more advanced than us would be able to come up with a new design.
2012/06/29
[ "https://scifi.stackexchange.com/questions/19680", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/7446/" ]
I say it's nostalgia and marketing...As evidence for this I reference the existence of New New York, Mom's Friendly Robot Company ads and just human nature in general. For every viewpoint, you can use nostalgia to sell it! That, I believe, is the simple, unadorned reason that cars look the same in the year 3000.
The requirements for a car in 3000AD are probably very similar to those of cars today i.e. get people around comfortably, safely and cheaply, so they'll end up with broadly similar designs. Certainly demands of fashion will affect the decorative bits that car designers add to distinguish their models, but until materia...
32,517,452
Can someone help me? I would like to do something like this on a textarea to set the maxlength attribute: ``` <!DOCTYPE html> <html> <head> <style> .democlass { color: red; } </style> </head> <body> <h1>Hello World</h1> <p>Click the button to create a "class" attribute with the value "democlass" and insert it to...
2015/09/11
[ "https://Stackoverflow.com/questions/32517452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324123/" ]
Firstly, you forgot the textarea: ``` <!DOCTYPE html> <html> <head> <style> </style> </head> <body> <h1>Hello World</h1> <button onclick="myFunction()">change max length</button> <textarea></textarea> <script> function myFunction() { var text = document.getElementsByTagName("textarea"); ...
You have two problems: You have to work on an element not a collection =============================================== Compare (specifically the last few characters of each line): ``` var h1 = document.getElementsByTagName("H1")[0]; var text = document.getElementsByTagName("textarea"); ``` In the first case you ar...
32,517,452
Can someone help me? I would like to do something like this on a textarea to set the maxlength attribute: ``` <!DOCTYPE html> <html> <head> <style> .democlass { color: red; } </style> </head> <body> <h1>Hello World</h1> <p>Click the button to create a "class" attribute with the value "democlass" and insert it to...
2015/09/11
[ "https://Stackoverflow.com/questions/32517452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324123/" ]
You have some errors in your code. Check out this simplified one: [jsFiddle](http://jsfiddle.net/kmsdev/cmkhosx6/) ``` <h1>Hello World</h1> <textarea rows="10" cols="40"></textarea><br /> <button onclick="myFunction()">change max length</button> <script> function myFunction() { var text = document.getElemen...
You have two problems: You have to work on an element not a collection =============================================== Compare (specifically the last few characters of each line): ``` var h1 = document.getElementsByTagName("H1")[0]; var text = document.getElementsByTagName("textarea"); ``` In the first case you ar...
32,517,452
Can someone help me? I would like to do something like this on a textarea to set the maxlength attribute: ``` <!DOCTYPE html> <html> <head> <style> .democlass { color: red; } </style> </head> <body> <h1>Hello World</h1> <p>Click the button to create a "class" attribute with the value "democlass" and insert it to...
2015/09/11
[ "https://Stackoverflow.com/questions/32517452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324123/" ]
You have some errors in your code. Check out this simplified one: [jsFiddle](http://jsfiddle.net/kmsdev/cmkhosx6/) ``` <h1>Hello World</h1> <textarea rows="10" cols="40"></textarea><br /> <button onclick="myFunction()">change max length</button> <script> function myFunction() { var text = document.getElemen...
Firstly, you forgot the textarea: ``` <!DOCTYPE html> <html> <head> <style> </style> </head> <body> <h1>Hello World</h1> <button onclick="myFunction()">change max length</button> <textarea></textarea> <script> function myFunction() { var text = document.getElementsByTagName("textarea"); ...
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
> > Is this possible? > > > It definetely is. You could just check which `Activity` is hosting your `Fragment` instance: ``` private void button1OnClick(){ /* could also use instanceof, BUT: if you have something like ActivityC extends ActivityA then instanceof would evaluate to true for both */ if...
Yes you can! ``` if(getActivity() instanceOf ActivityA) { //do stuff related to ActivityA } else if(getActivity() instanceOf ActivityB) { //do stuff related to ActivityB } ```
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
> > Is this possible? > > > It definetely is. You could just check which `Activity` is hosting your `Fragment` instance: ``` private void button1OnClick(){ /* could also use instanceof, BUT: if you have something like ActivityC extends ActivityA then instanceof would evaluate to true for both */ if...
Your activities have different logic, you can define the button logic in each of them and share the views in this way. You can use a fragment to accomplish this however you can be more direct by sharing a partial layout. Create a partial layout called three\_buttons.xml three\_buttons.xml ``` <LinearLayout> <BUtton ...
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
Of course you can. Just create an interface for the Fragment, let's say `FragmentCallback`, with your desired callback method, `onButtonClick()` for instance. In the `onAttached()` of your Fragment, cast the Activity to your new interface and store it in a variable `private FragmentCallback callback;`. Each Activity us...
> > Is this possible? > > > It definetely is. You could just check which `Activity` is hosting your `Fragment` instance: ``` private void button1OnClick(){ /* could also use instanceof, BUT: if you have something like ActivityC extends ActivityA then instanceof would evaluate to true for both */ if...
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
Yes you can, but you have to add more logic to your fragments and add some interfaces for each activity. I don't recommend to do that, maybe you could reuse your layouts.
Yes you can! ``` if(getActivity() instanceOf ActivityA) { //do stuff related to ActivityA } else if(getActivity() instanceOf ActivityB) { //do stuff related to ActivityB } ```
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
Yes you can, but you have to add more logic to your fragments and add some interfaces for each activity. I don't recommend to do that, maybe you could reuse your layouts.
Your activities have different logic, you can define the button logic in each of them and share the views in this way. You can use a fragment to accomplish this however you can be more direct by sharing a partial layout. Create a partial layout called three\_buttons.xml three\_buttons.xml ``` <LinearLayout> <BUtton ...
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
Of course you can. Just create an interface for the Fragment, let's say `FragmentCallback`, with your desired callback method, `onButtonClick()` for instance. In the `onAttached()` of your Fragment, cast the Activity to your new interface and store it in a variable `private FragmentCallback callback;`. Each Activity us...
Yes you can, but you have to add more logic to your fragments and add some interfaces for each activity. I don't recommend to do that, maybe you could reuse your layouts.
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
Of course you can. Just create an interface for the Fragment, let's say `FragmentCallback`, with your desired callback method, `onButtonClick()` for instance. In the `onAttached()` of your Fragment, cast the Activity to your new interface and store it in a variable `private FragmentCallback callback;`. Each Activity us...
Yes you can! ``` if(getActivity() instanceOf ActivityA) { //do stuff related to ActivityA } else if(getActivity() instanceOf ActivityB) { //do stuff related to ActivityB } ```
47,318,912
I am being passed inconsistent data. The problem is the individual rows of `$data_array` are not consistently in the same sequence but each has a reliable "text:" preceding the value. Each row contains about 120 elements of data. I only need 24 of those elements. It's also possible one of the elements I need could b...
2017/11/15
[ "https://Stackoverflow.com/questions/47318912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174910/" ]
Of course you can. Just create an interface for the Fragment, let's say `FragmentCallback`, with your desired callback method, `onButtonClick()` for instance. In the `onAttached()` of your Fragment, cast the Activity to your new interface and store it in a variable `private FragmentCallback callback;`. Each Activity us...
Your activities have different logic, you can define the button logic in each of them and share the views in this way. You can use a fragment to accomplish this however you can be more direct by sharing a partial layout. Create a partial layout called three\_buttons.xml three\_buttons.xml ``` <LinearLayout> <BUtton ...
22,720,603
I'm using `ng-repeat` to create an index of records within a Rails view, on this index I'm trying to implement a button to update a particular record. The problem is I need to pass the correct id through to the Rails controller. I'm getting an error when I attempt to pass the record id through with `'{{swim_record.id}}...
2014/03/28
[ "https://Stackoverflow.com/questions/22720603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3395126/" ]
> > Why is my function returning before the X,Y variables are set? > > > [Because JavaScript I/O is asynchronous](https://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call). If you want to wait for two promises - you need to hook on the promise's completion. Luckily, promises make...
The functions `getX` and `getY` are asynchronous functions. Promise solves the issue of nesting anonymous functions, but it don't make the functions synchronous and blocking. So `x` and `y` are not set at the moment you create the `ref` object and return this object. Try something like this: ``` getX(rows[0].id,con,...
22,720,603
I'm using `ng-repeat` to create an index of records within a Rails view, on this index I'm trying to implement a button to update a particular record. The problem is I need to pass the correct id through to the Rails controller. I'm getting an error when I attempt to pass the record id through with `'{{swim_record.id}}...
2014/03/28
[ "https://Stackoverflow.com/questions/22720603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3395126/" ]
Promises don't change the language, it's just a library. It cannot change how function returning works. However, do you want something like this: ``` return con.getConnectionAsync().then(function(connection) { var x; var y; return connection.queryAsync('SELECT password,id FROM player WHERE name='+mysql.esc...
The functions `getX` and `getY` are asynchronous functions. Promise solves the issue of nesting anonymous functions, but it don't make the functions synchronous and blocking. So `x` and `y` are not set at the moment you create the `ref` object and return this object. Try something like this: ``` getX(rows[0].id,con,...
41,185,122
I am making a complex algorithm in C# in which one step is to compare 2 very large lists of ranges and finding out the overlapping region. I have tried a lot of ways to find them, but m not sure if I am covering all possibilities. Also my algo on this step is taking too long with huge lists. **Example:** **range 1 = ...
2016/12/16
[ "https://Stackoverflow.com/questions/41185122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5305863/" ]
If there is any overlapping range ; it must start from the max lower bound to the min upper bound so just use that "formula" Then just get the number of item in that range by subtracting it's upper bound to it's lower one and add one (to be all inclusive) Finally if that amount is negative it means that the range...
You can try something like this: ``` void Main() { double adStart = 1.501; double adEnd = 21.83; double bdStart = 0.871; double bdEnd = 56.81; int aiStart = 21; int aiEnd = 35; int biStart = 29; int biEnd = 43; // 20.239 double dOverlap = FindOverlapping((int)(adStart*1000), (...
41,185,122
I am making a complex algorithm in C# in which one step is to compare 2 very large lists of ranges and finding out the overlapping region. I have tried a lot of ways to find them, but m not sure if I am covering all possibilities. Also my algo on this step is taking too long with huge lists. **Example:** **range 1 = ...
2016/12/16
[ "https://Stackoverflow.com/questions/41185122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5305863/" ]
If there is any overlapping range ; it must start from the max lower bound to the min upper bound so just use that "formula" Then just get the number of item in that range by subtracting it's upper bound to it's lower one and add one (to be all inclusive) Finally if that amount is negative it means that the range...
A one-liner formula to use would be this one. Let's say you have 2 intervals: (a1, a2) and (b1, b2) Then the overlapping region would be: max{0, min{a2-b1, b2-a1}}
41,185,122
I am making a complex algorithm in C# in which one step is to compare 2 very large lists of ranges and finding out the overlapping region. I have tried a lot of ways to find them, but m not sure if I am covering all possibilities. Also my algo on this step is taking too long with huge lists. **Example:** **range 1 = ...
2016/12/16
[ "https://Stackoverflow.com/questions/41185122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5305863/" ]
You can try something like this: ``` void Main() { double adStart = 1.501; double adEnd = 21.83; double bdStart = 0.871; double bdEnd = 56.81; int aiStart = 21; int aiEnd = 35; int biStart = 29; int biEnd = 43; // 20.239 double dOverlap = FindOverlapping((int)(adStart*1000), (...
A one-liner formula to use would be this one. Let's say you have 2 intervals: (a1, a2) and (b1, b2) Then the overlapping region would be: max{0, min{a2-b1, b2-a1}}
8,725,594
At the moment I have: ``` //replace common characters $search = array('&', '£', '$'); $replace = array('&amp;', '&pound;', '&dollar;'); $html= str_replace($search, $replace, $html); ``` The problem with this code is that if the & has been already converted it will try to convert it again. How would I make sure thi...
2012/01/04
[ "https://Stackoverflow.com/questions/8725594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560287/" ]
I would use the built in functions that PHP has to escape HTML characters: * [`htmlentities()`](http://php.net/manual/en/function.htmlentities.php) * [`htmlspecialchars()`](http://www.php.net/manual/en/function.htmlspecialchars.php) Rather than rolling my own as it is much easier. `htmlentities()` and `htmlspecialcha...
i give an example but it will work if you have the latter like `' & '` then hope this will work for you: ``` $str = 'India & Aust &amp; New '; $regex = '/(\s\&\s)/i'; $replace = ' &amp; '; if(preg_match($regex, $str)){ $new_str = preg_replace($regex, $replace, $str ); echo '<pre>'; echo htmlspecialchars(...
477,504
I got a local repository in `/var/www/html/centos/7` directory. In here, all rpm packages from centos are downloaded. I will create a crontab for updating my local repository every 1 week or sth. I want to learn that does `repocreate --update` do this? Or should I download all the packages from centos repo again? If ...
2018/10/24
[ "https://unix.stackexchange.com/questions/477504", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/317026/" ]
If you have problems with rsync, then you can use [reposync](https://linux.die.net/man/1/reposync). It is able to download all packages (or --newest-only| -n) from repo, configured in the system. So final commands in script looks like: ``` /usr/bin/reposync --repoid=updates --download_path=/var/www/html/centos7/repo/u...
you can try the following mirror which is supporting rsync as well <http://mirror.nl.leaseweb.net/centos/>
477,504
I got a local repository in `/var/www/html/centos/7` directory. In here, all rpm packages from centos are downloaded. I will create a crontab for updating my local repository every 1 week or sth. I want to learn that does `repocreate --update` do this? Or should I download all the packages from centos repo again? If ...
2018/10/24
[ "https://unix.stackexchange.com/questions/477504", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/317026/" ]
repoquery queries every package in repository that you configured for your system and after that give the list to xargs to download all packages (new ones not existing ones)with repotrack to your server. ``` repoquery -a | xargs repotrack -a x86_64 -p . ``` The rsync solution also works if you haven't got any firewa...
you can try the following mirror which is supporting rsync as well <http://mirror.nl.leaseweb.net/centos/>