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
6,266,652
I have a drop down list on my page & want the list items to be folders from a local directory on the web server... ie.... T:\Forms T:\Manuals T:\Software Here is my code so far... ``` protected void Page_Load(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo("C:/"); DirectoryInfo[] dirArray = di.GetDirectories(); DropDownList1.DataSource = dirArray; foreach (DirectoryInfo i in dirArray) { DropDownList1.DataTextField = i.FullName; DropDownList1.DataValueField = i.FullName; } } ``` **SOLVED** ``` protected void Page_Load(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo("C:/"); DropDownList1.DataSource = di.GetDirectories(); DropDownList1.DataBind(); foreach (DirectoryInfo i in di.GetDirectories()) { DropDownList1.DataTextField = i.FullName; } } ```
2011/06/07
[ "https://Stackoverflow.com/questions/6266652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636824/" ]
Check out the System.IO.DirectoryInfo and System.IO.FileInfo classes. Obviously you will only be able to read the filesystem of the web server
You can use ``` List<string> dirList=new List<string>(); DirectoryInfo[] DI = new DirectoryInfo(@"T:\Forms\").GetDirectories("*.*",SearchOption.AllDirectories ) ; foreach (DirectoryInfo D1 in DI) { dirList.Add(D1.FullName); } ``` Do that for all three directories and then databind to the list
6,266,652
I have a drop down list on my page & want the list items to be folders from a local directory on the web server... ie.... T:\Forms T:\Manuals T:\Software Here is my code so far... ``` protected void Page_Load(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo("C:/"); DirectoryInfo[] dirArray = di.GetDirectories(); DropDownList1.DataSource = dirArray; foreach (DirectoryInfo i in dirArray) { DropDownList1.DataTextField = i.FullName; DropDownList1.DataValueField = i.FullName; } } ``` **SOLVED** ``` protected void Page_Load(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo("C:/"); DropDownList1.DataSource = di.GetDirectories(); DropDownList1.DataBind(); foreach (DirectoryInfo i in di.GetDirectories()) { DropDownList1.DataTextField = i.FullName; } } ```
2011/06/07
[ "https://Stackoverflow.com/questions/6266652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636824/" ]
I would suggest using such a piece of code ``` DirectoryInfo di = new DirectoryInfo(@"e:\"); ddlFolders.DataSource = di.GetDirectories(); ddlFolders.DataTextField = "Name"; ddlFolders.DataValueField = "FullName"; ddlFolders.DataBind(); ``` hth
You can use ``` List<string> dirList=new List<string>(); DirectoryInfo[] DI = new DirectoryInfo(@"T:\Forms\").GetDirectories("*.*",SearchOption.AllDirectories ) ; foreach (DirectoryInfo D1 in DI) { dirList.Add(D1.FullName); } ``` Do that for all three directories and then databind to the list
7,244,338
I'm trying to use the same media player but change the data source. Here is what I'm trying to do:  ``` private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source etc. } mMediaPlayer.setOnErrorListener(this); AssetFileDescriptor afd = getAssets().openFd(mediafile); mMediaPlayer.setDataSource(afd.getFileDescriptor()); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepareAsync(); // prepare async to not block main thread mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // Keep playing when screen goes off! } ``` I just call this when I want to change to a new mediafile. It doesn't appear to be changing the data source successfully though. First question: is it possible to do it this way, or do I have to release the media player and create a new one for each new file? If it is possible, then why isn't my code working right? Edit: well, releasing and recreating the media player isn't doing it either! It just keeps playing the same song!?!? How is that even possible? New idea -- create a different media player for each track, is that really what I have to do here? Is this a bug in Android perhaps?
2011/08/30
[ "https://Stackoverflow.com/questions/7244338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754559/" ]
Well, I never did get a really good answer for this. I think it might be something funny that happens in the emulator. What I have done that is working great for me, is to download the files to the external SD card and play them from there. That changes the code slightly to this: ``` String path = getExternalFilesDir(null).toString() + "/"; mMediaPlayer.setDataSource(path + mediafile); ``` the rest remains the same.
You declare `private String mediafile="my.mp3";` then you use `AssetFileDescriptor afd = getAssets().openFd(mediafile);` but at no point (from the code you posted) do you change the value of `mediafile`. I would recommend putting `mediafile = theNextFile;` onthe line before `afd = getAssets().openFd(mediafile);` where `theNextFile` would likely refer to a file on the sd card that the user chose before clicking said button. I'm not sure how to manage getting the file names from sd card, but I'd think using a `startActivityForResult` would be one way to do it.
7,244,338
I'm trying to use the same media player but change the data source. Here is what I'm trying to do:  ``` private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source etc. } mMediaPlayer.setOnErrorListener(this); AssetFileDescriptor afd = getAssets().openFd(mediafile); mMediaPlayer.setDataSource(afd.getFileDescriptor()); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepareAsync(); // prepare async to not block main thread mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // Keep playing when screen goes off! } ``` I just call this when I want to change to a new mediafile. It doesn't appear to be changing the data source successfully though. First question: is it possible to do it this way, or do I have to release the media player and create a new one for each new file? If it is possible, then why isn't my code working right? Edit: well, releasing and recreating the media player isn't doing it either! It just keeps playing the same song!?!? How is that even possible? New idea -- create a different media player for each track, is that really what I have to do here? Is this a bug in Android perhaps?
2011/08/30
[ "https://Stackoverflow.com/questions/7244338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754559/" ]
I've actually had this same problem with assets today, and I know the fix. The problem is that the assets are stored as one big chunk of data rather than actually as a bunch of individual files on a real file system somewhere. So, when you get an `assetfiledescriptor`, it points both to a file, but also has an offset and a length. If you just point `mediaplayer` at the `assetfiledescriptor` itself, it always plays the first media file in your assets folder (or something). If you do this: `mMediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());` then it plays the right file.
You declare `private String mediafile="my.mp3";` then you use `AssetFileDescriptor afd = getAssets().openFd(mediafile);` but at no point (from the code you posted) do you change the value of `mediafile`. I would recommend putting `mediafile = theNextFile;` onthe line before `afd = getAssets().openFd(mediafile);` where `theNextFile` would likely refer to a file on the sd card that the user chose before clicking said button. I'm not sure how to manage getting the file names from sd card, but I'd think using a `startActivityForResult` would be one way to do it.
7,244,338
I'm trying to use the same media player but change the data source. Here is what I'm trying to do:  ``` private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source etc. } mMediaPlayer.setOnErrorListener(this); AssetFileDescriptor afd = getAssets().openFd(mediafile); mMediaPlayer.setDataSource(afd.getFileDescriptor()); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepareAsync(); // prepare async to not block main thread mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // Keep playing when screen goes off! } ``` I just call this when I want to change to a new mediafile. It doesn't appear to be changing the data source successfully though. First question: is it possible to do it this way, or do I have to release the media player and create a new one for each new file? If it is possible, then why isn't my code working right? Edit: well, releasing and recreating the media player isn't doing it either! It just keeps playing the same song!?!? How is that even possible? New idea -- create a different media player for each track, is that really what I have to do here? Is this a bug in Android perhaps?
2011/08/30
[ "https://Stackoverflow.com/questions/7244338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754559/" ]
Make sure to stop and reset mediaplayer before changing datasource. On more important thing when you stop it calls > > onCompletion > > > .. So do check what you are doing in this method. Then call ``` mplayer.setDataSource(audioPath); mplayer.setOnPreparedListener(this); mplayer.prepareAsync(); ```
You declare `private String mediafile="my.mp3";` then you use `AssetFileDescriptor afd = getAssets().openFd(mediafile);` but at no point (from the code you posted) do you change the value of `mediafile`. I would recommend putting `mediafile = theNextFile;` onthe line before `afd = getAssets().openFd(mediafile);` where `theNextFile` would likely refer to a file on the sd card that the user chose before clicking said button. I'm not sure how to manage getting the file names from sd card, but I'd think using a `startActivityForResult` would be one way to do it.
7,244,338
I'm trying to use the same media player but change the data source. Here is what I'm trying to do:  ``` private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source etc. } mMediaPlayer.setOnErrorListener(this); AssetFileDescriptor afd = getAssets().openFd(mediafile); mMediaPlayer.setDataSource(afd.getFileDescriptor()); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepareAsync(); // prepare async to not block main thread mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // Keep playing when screen goes off! } ``` I just call this when I want to change to a new mediafile. It doesn't appear to be changing the data source successfully though. First question: is it possible to do it this way, or do I have to release the media player and create a new one for each new file? If it is possible, then why isn't my code working right? Edit: well, releasing and recreating the media player isn't doing it either! It just keeps playing the same song!?!? How is that even possible? New idea -- create a different media player for each track, is that really what I have to do here? Is this a bug in Android perhaps?
2011/08/30
[ "https://Stackoverflow.com/questions/7244338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754559/" ]
I've actually had this same problem with assets today, and I know the fix. The problem is that the assets are stored as one big chunk of data rather than actually as a bunch of individual files on a real file system somewhere. So, when you get an `assetfiledescriptor`, it points both to a file, but also has an offset and a length. If you just point `mediaplayer` at the `assetfiledescriptor` itself, it always plays the first media file in your assets folder (or something). If you do this: `mMediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());` then it plays the right file.
Well, I never did get a really good answer for this. I think it might be something funny that happens in the emulator. What I have done that is working great for me, is to download the files to the external SD card and play them from there. That changes the code slightly to this: ``` String path = getExternalFilesDir(null).toString() + "/"; mMediaPlayer.setDataSource(path + mediafile); ``` the rest remains the same.
7,244,338
I'm trying to use the same media player but change the data source. Here is what I'm trying to do:  ``` private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source etc. } mMediaPlayer.setOnErrorListener(this); AssetFileDescriptor afd = getAssets().openFd(mediafile); mMediaPlayer.setDataSource(afd.getFileDescriptor()); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepareAsync(); // prepare async to not block main thread mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // Keep playing when screen goes off! } ``` I just call this when I want to change to a new mediafile. It doesn't appear to be changing the data source successfully though. First question: is it possible to do it this way, or do I have to release the media player and create a new one for each new file? If it is possible, then why isn't my code working right? Edit: well, releasing and recreating the media player isn't doing it either! It just keeps playing the same song!?!? How is that even possible? New idea -- create a different media player for each track, is that really what I have to do here? Is this a bug in Android perhaps?
2011/08/30
[ "https://Stackoverflow.com/questions/7244338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754559/" ]
Make sure to stop and reset mediaplayer before changing datasource. On more important thing when you stop it calls > > onCompletion > > > .. So do check what you are doing in this method. Then call ``` mplayer.setDataSource(audioPath); mplayer.setOnPreparedListener(this); mplayer.prepareAsync(); ```
Well, I never did get a really good answer for this. I think it might be something funny that happens in the emulator. What I have done that is working great for me, is to download the files to the external SD card and play them from there. That changes the code slightly to this: ``` String path = getExternalFilesDir(null).toString() + "/"; mMediaPlayer.setDataSource(path + mediafile); ``` the rest remains the same.
7,244,338
I'm trying to use the same media player but change the data source. Here is what I'm trying to do:  ``` private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source etc. } mMediaPlayer.setOnErrorListener(this); AssetFileDescriptor afd = getAssets().openFd(mediafile); mMediaPlayer.setDataSource(afd.getFileDescriptor()); } catch (IllegalStateException e) { Log.d(TAG, "IllegalStateException: " + e.getMessage()); } catch (IOException e) { Log.d(TAG, "IOException: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.d(TAG, "IllegalArgumentException: " + e.getMessage()); } catch (SecurityException e) { Log.d(TAG, "SecurityException: " + e.getMessage()); } mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.prepareAsync(); // prepare async to not block main thread mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // Keep playing when screen goes off! } ``` I just call this when I want to change to a new mediafile. It doesn't appear to be changing the data source successfully though. First question: is it possible to do it this way, or do I have to release the media player and create a new one for each new file? If it is possible, then why isn't my code working right? Edit: well, releasing and recreating the media player isn't doing it either! It just keeps playing the same song!?!? How is that even possible? New idea -- create a different media player for each track, is that really what I have to do here? Is this a bug in Android perhaps?
2011/08/30
[ "https://Stackoverflow.com/questions/7244338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754559/" ]
Make sure to stop and reset mediaplayer before changing datasource. On more important thing when you stop it calls > > onCompletion > > > .. So do check what you are doing in this method. Then call ``` mplayer.setDataSource(audioPath); mplayer.setOnPreparedListener(this); mplayer.prepareAsync(); ```
I've actually had this same problem with assets today, and I know the fix. The problem is that the assets are stored as one big chunk of data rather than actually as a bunch of individual files on a real file system somewhere. So, when you get an `assetfiledescriptor`, it points both to a file, but also has an offset and a length. If you just point `mediaplayer` at the `assetfiledescriptor` itself, it always plays the first media file in your assets folder (or something). If you do this: `mMediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());` then it plays the right file.
40,153,230
how can i replace value inside ng-repeat. ``` <div ng-repeat="item in test"> <input type="text" data-ng-model="item.qty"> </div> $scope.test = [ {"InventoryItemID":78689,"Location":"My Location",qty:"2"}, {"InventoryItemID":78689,"Location":"My Location",qty:"1"} ] ``` now i have to replace the test qty with test1 qty . how can i do that. ``` $scope.test1 = [ {qty:"6"}, {qty:"6"} ] ```
2016/10/20
[ "https://Stackoverflow.com/questions/40153230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3482007/" ]
Try this.this is solve your problem <http://javapapers.com/android/android-searchview-action-bar-tutorial/>
``` <RelativeLayout> <SearchView> <RecyclerView> </RelativeLayout> ```
63,894,578
I have list of Objects ``` class Product{ String productName; int mfgYear; int expYear; } int testYear = 2019; List<Product> productList = getProductList(); ``` I have list of products here. Have to iterate each one of the Product from the list and get the `List<String> productName` that lies in the range between mfgYear & expYear for a given 2019(testYear). ``` For example, mfgYear <= 2019 <= expYear ``` How can I write this in java 8 streams.
2020/09/15
[ "https://Stackoverflow.com/questions/63894578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1712810/" ]
You can write as following: ``` int givenYear = 2019; List<String> productNames = products.stream() .filter(p -> p.mfgYear <= givenYear && givenYear <= p.expYear) .map(Product::name) .collect(Collectors.toList()); // It would be more clean if you can define a boolean function inside your product class class Product { // your code as it is boolean hasValidRangeGiven(int testYear) { return mfgDate <= testYear && testYear <= expYear: } List<String> productNames = products.stream() .filter(p -> p.hasValidRange(givenYear)) .map(Product::name) .collect(Collectors.toList()); ```
``` List<String> process(List<Product> productList) { return productList.stream() .filter(this::isWithinRange) .map(Product::getProductName) .collect(Collectors.toList()); } boolean isWithinRange(Product product) { return product.mfgYear <= 2019 && product.expYear <= 2019; } static class Product { String productName; int mfgYear; int expYear; public String getProductName() { return productName; } } ``` **filter()** will pass any item for which the lambda expression (or method reference in this case) return true. **map()** will convert the value passing the item to the method reference and create a stream of whatever type it returns. We pass the name getter in that case.
19,846,406
I am making a pentaho transformation and using a table input. The condition is that the name of the table will be passed dynamically as an argument. So the table input has the sql: ``` select * from ? ``` And this table input takes the input from a `Get Variables` step where i have defined a varibale called `'table_name'`. When i run the transformation i pass in the tablename. I need to do it this way because the table name is of the form abc\_ddmmyyyy and ddmmyyyy can vary.
2013/11/07
[ "https://Stackoverflow.com/questions/19846406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454671/" ]
To set that address, use a cast like ``` const long* address = (const long*) 0x0000002; // C style ``` or ``` const long* address = reinterpret_cast<const long*>(0x000002); // C++ style ``` BTW, on most systems 0x0000002 is not a valid address (in the usual virtual address space of applications). See wikipage on [virtual memory](http://en.wikipedia.org/wiki/Virtual_memory) & [virtual address space](http://en.wikipedia.org/wiki/Virtual_address_space).
You have the address expressed as an integer. You need to cast it to a pointer of the appropriate type: ``` const long *address = reinterpret_cast<const long *>(0x00000002); ``` And you need to perform that cast in standard C++. I'm not sure why you think that the cast can be omitted in standard C++. Of course, when you run your code, you will encounter a segmentation fault.
9,268,815
I'm trying to use Scheme in a distributed system. The idea is that one process would evaluate some expressions and pass it on to another process to finish. Example: ``` (do-stuff (f1 x) (f2 x)) ``` would evaluate to ``` (do-stuff res1 (f2 x)) ``` in the first process. This process passes the expression as a string to another process (on another node), which would evaluate it to ``` (do-stuff res1 res2) ``` The ideas is to do a map reduce style work distribution, but by passing scheme expressions around. Is this possible? Any pointers would be helpful. (I'm using IronScheme btw).
2012/02/13
[ "https://Stackoverflow.com/questions/9268815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30698/" ]
As [Aslan986](https://stackoverflow.com/users/724395/aslan986) suggested you need support for full continuations. Unfortunately Ironscheme does not support full continuations but only escape continuations, which go the call stack up. See the [known limitations](http://ironscheme.codeplex.com/documentation) of Ironscheme. Furthermore you need to serialize the continuations, to be able to pass them from one process to another. In general this is not always possible and only few Scheme systems have support for that. One example is [Gambit-C](http://www.iro.umontreal.ca/~gambit/). There exists a presentation which shows how to implement a [distributed computing](http://www.iro.umontreal.ca/~gambit/Distributed-computing-with-Gambit.pdf) system.
it's not a real answer, but just an hint. Have you tried with continuations? [Here](http://en.wikipedia.org/wiki/Call-with-current-continuation) I think the can do what you need.
263,092
I'm trying to build a simple low-power water level alarm such that it could run continuously for at least 4 months on just 3x AA batteries. I've found this schematic which uses the 555 timer: [![enter image description here](https://i.stack.imgur.com/hmYaY.jpg)](https://i.stack.imgur.com/hmYaY.jpg) However, the 555 timer has a minimum power consumption of around 30mW, which would be too much. Would it be a good idea to modify the circuit such that the water's conduction supplies power to the 555 like so: [![enter image description here](https://i.stack.imgur.com/LzVSy.jpg)](https://i.stack.imgur.com/LzVSy.jpg) Is water conductive enough for this to operate? Would it be a better idea to just use a low-power MCU like MSP430 and raise an interrupt when the probes short by water's conduction? Any thought appreciated.
2016/10/12
[ "https://electronics.stackexchange.com/questions/263092", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/80217/" ]
I assume that you are using BLE or similar. Be aware that RSSI is a very blunt instrument indeed and needs both understanding and a degree of magic to work well. There is only so much magic available in an office building and if you expect consistent fine precision you will be disappointed. If working in air (eg assuming that your office is not underwater or filled with solid rock or polystyrene beads or other dielectric) then n should be constant and determinate. The fact that they have given a typical range is a clue that things are less exact in practice than in theory. If you are doing this only theoretically and not with practical experiment as well then then the value of n used is not too important as it is almost certain to be wrong. RSSI (signal strength) readings can be affected by reflections, position of objects in the target space, object motion, line of site or not between nodes, number of nodes, presence of other unrelated signals on the allocated frequency band (or stronger ones out of band), directionality (or not) of antennas, front end overload and intermodulation performance, system signal to noise ratio, ... to give a far from complete list. RSSI distance measurements almost certainly need to be based on multiple signal attempts processed in some way. Having reference nodes of known distance can help. You can have fixed "beacons" with moving targets, or moving beacons with fixed targets, or some mix. There is a VERY large amount of information online on indoor distance determination using RSSI and some fairly basic searching will turn up more than you are liable to be able to assimilate in a sensible timespan. **\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_** **CLOSELY RELATED:** Here is an edited subset of some notes I wrote for somebody else a few months ago. Estimote are very active in this area and looking at what they are doing should be informative: **ESTIMOTE LOCATION development kit (!)** A must read. But, it starts like this: * Estimote Indoor Location SDK is a set of tools for building precise, blue-dot location services indoors. Just configure Estimote Beacons (no sweat, it’s fully automated), attach them to walls and you’re ready to set up your first location. From there, the location’s map is automatically uploaded to Estimote Cloud, and voila! You can now embed it in your own app. Location accuracy varies depending on location size, shape, and crowd density. In small rooms, it’s as good as 1 meter, in larger spaces it can be around 4 meters on average. Keep in mind that Indoor Location SDK is still work in progress: we’re constantly improving accuracy, adding new features, and optimizing for bigger venues. --- Estimote indoor location video 2m-12 <https://www.youtube.com/watch?v=wtBERi7Lf3c> Nearables video 2m (smaller, lower range, lower capability, lower cost.) <https://www.youtube.com/watch?v=JrRS8qRYXCQ> Estimote location (scroll down) Existing working install beacons, setup and go system Estimote You tube videos many many many <https://www.youtube.com/results?search_query=estimote> eg Estimote Beacons factory - posted December 2013 56s <http://estimote.com/indoor/> --- Building the next generation of context-aware mobile apps requires more than just iBeacon™ hardware. Developers need smarter software: tools that give them control over proximity and position within a given space, without unnecessary hassle. Estimote Indoor Location does just that. It makes it incredibly easy and quick to map any location. Once done, you can use our SDK to visualize your approximate position within that space in real-time, in your own app. Indoor Location creates a rich canvas upon which to build powerful new mobile experiences, from in-venue analytics and proximity marketing to frictionless payments and personalized shopping. What is Estimote Indoor Location SDK? Download software free. ``` http://developer.estimote.com/indoor/ ``` **\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_** **iBeacon and other RSSI position location:** While iBeacon is principally intended as an information promulgation system, a number of people have used the BLE transmitters as position/ triangulation based on RSSI and other methods. The Wikipedia page provides a good general overview. ``` https://en.wikipedia.org/wiki/IBeacon ``` BLE mesh networking ``` https://en.wikipedia.org/wiki/Scatternet ``` An experienced BLE position location developer and vendor. ``` https://locatify.com/blog/indoor-positioning-systems-ble-beacons/ ``` BLE - more re beacon based ``` http://estimote.com/ ``` Another <http://kontakt.io/> BLE in GEC lighting fixtures ``` http://9to5mac.com/2014/05/29/ge-integrates-ibeacons-in-new-led-lighting-fixtures-rolling-out-in-walmart-other-retailers/ ``` ' Google Scholar on ble position detection. ``` https://scholar.google.co.nz/scholar?q=ble+position+detection&hl=en&as_sdt=0&as_vis=1&oi=scholart&sa=X&ved=0ahUKEwiinMfLzqLNAhXkdqYKHWe4AOkQgQMIGjAA ``` 9783319226880-c2.pdf <- URL needed. ``` Indoor Position Detection Using BLE Signals Based on Voronoi Diagram ``` An Analysis of the Accuracy of Bluetooth Low Energy for Indoor Positioning Applications ``` http://www.cl.cam.ac.uk/~rmf25/papers/BLE.pdf ``` Indoor positioning with beacons and mobile devices ``` http://bits.citrusbyte.com/indoor-positioning-with-beacons/ ``` **OPEN BEACON PROJECT** ``` http://get.openbeacon.org/about.html ``` Development <http://get.openbeacon.org/source/#github> <http://www.openbeacon.org/> Bluetooth Proximity Tag Nordic BLS IC / modules <https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy2/nRF51822> <http://get.openbeacon.org/source/#github> --- I have many many many variably related references if of interest - but, so does Mr Gargoyle. eg [Every picture tells a story](https://www.google.co.nz/search?q=ble+rssi+distance+position&num=100&espv=2&source=lnms&tbm=isch&sa=X&ved=0ahUKEwitnuz6ldXPAhVEilQKHQGnCQ8Q_AUICCgB&biw=1527&bih=836) and Most of these [many many many stories](https://www.google.co.nz/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=ble%20rssi%20distance%20position&oq=ble%20rssi%20distance%20position&aqs=chrome..69i57.11311j0j8) will be of high relevance.
If using a well designed WiFi receiver such as in Laptops, there is a Windows App ( get WiFiInspector-Setup-1.2.1.4.exe ) that will display WiFi signal in 1dB resolution with stripchart or numeric display. Then using **Friis Loss** to define inverse squared Distance losses in RF, one can make a reasonable conversion from RSSI to dB to distance for line of site with care to avoid wall reflections. from -80 dBm to say -30dBm [![enter image description here](https://i.stack.imgur.com/6V2jM.png)](https://i.stack.imgur.com/6V2jM.png) Body proximity will also affect near field reflections at low levels. Put router high on plastic chair or table and expect all metal structures and some other materials to reflect signals and cause Ricean Fading nulls. To expect decent coverage, you will need a high quality router such as DIR-880L Warning: Slightest orientation of a few mm of Laptop can cause peaks and nulls in low level areas due to Ricean fading. You can then chart range of signals in each room and plot Min/max mean vs distance. using strip chart and walking around zone to be measured. Typically if RSSI > > * -60 dBm excellent > * -70 dBm good > * < -70 dBm marginal and baud rates will be affected from interference > * <-80 dBm poor and barely enough to communicate > * WiFi speed and SNR threshold or RSSI level are inversely related so "b" speed 11Mbps needs less signal and "n" speed needs more. > > >
263,092
I'm trying to build a simple low-power water level alarm such that it could run continuously for at least 4 months on just 3x AA batteries. I've found this schematic which uses the 555 timer: [![enter image description here](https://i.stack.imgur.com/hmYaY.jpg)](https://i.stack.imgur.com/hmYaY.jpg) However, the 555 timer has a minimum power consumption of around 30mW, which would be too much. Would it be a good idea to modify the circuit such that the water's conduction supplies power to the 555 like so: [![enter image description here](https://i.stack.imgur.com/LzVSy.jpg)](https://i.stack.imgur.com/LzVSy.jpg) Is water conductive enough for this to operate? Would it be a better idea to just use a low-power MCU like MSP430 and raise an interrupt when the probes short by water's conduction? Any thought appreciated.
2016/10/12
[ "https://electronics.stackexchange.com/questions/263092", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/80217/" ]
I assume that you are using BLE or similar. Be aware that RSSI is a very blunt instrument indeed and needs both understanding and a degree of magic to work well. There is only so much magic available in an office building and if you expect consistent fine precision you will be disappointed. If working in air (eg assuming that your office is not underwater or filled with solid rock or polystyrene beads or other dielectric) then n should be constant and determinate. The fact that they have given a typical range is a clue that things are less exact in practice than in theory. If you are doing this only theoretically and not with practical experiment as well then then the value of n used is not too important as it is almost certain to be wrong. RSSI (signal strength) readings can be affected by reflections, position of objects in the target space, object motion, line of site or not between nodes, number of nodes, presence of other unrelated signals on the allocated frequency band (or stronger ones out of band), directionality (or not) of antennas, front end overload and intermodulation performance, system signal to noise ratio, ... to give a far from complete list. RSSI distance measurements almost certainly need to be based on multiple signal attempts processed in some way. Having reference nodes of known distance can help. You can have fixed "beacons" with moving targets, or moving beacons with fixed targets, or some mix. There is a VERY large amount of information online on indoor distance determination using RSSI and some fairly basic searching will turn up more than you are liable to be able to assimilate in a sensible timespan. **\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_** **CLOSELY RELATED:** Here is an edited subset of some notes I wrote for somebody else a few months ago. Estimote are very active in this area and looking at what they are doing should be informative: **ESTIMOTE LOCATION development kit (!)** A must read. But, it starts like this: * Estimote Indoor Location SDK is a set of tools for building precise, blue-dot location services indoors. Just configure Estimote Beacons (no sweat, it’s fully automated), attach them to walls and you’re ready to set up your first location. From there, the location’s map is automatically uploaded to Estimote Cloud, and voila! You can now embed it in your own app. Location accuracy varies depending on location size, shape, and crowd density. In small rooms, it’s as good as 1 meter, in larger spaces it can be around 4 meters on average. Keep in mind that Indoor Location SDK is still work in progress: we’re constantly improving accuracy, adding new features, and optimizing for bigger venues. --- Estimote indoor location video 2m-12 <https://www.youtube.com/watch?v=wtBERi7Lf3c> Nearables video 2m (smaller, lower range, lower capability, lower cost.) <https://www.youtube.com/watch?v=JrRS8qRYXCQ> Estimote location (scroll down) Existing working install beacons, setup and go system Estimote You tube videos many many many <https://www.youtube.com/results?search_query=estimote> eg Estimote Beacons factory - posted December 2013 56s <http://estimote.com/indoor/> --- Building the next generation of context-aware mobile apps requires more than just iBeacon™ hardware. Developers need smarter software: tools that give them control over proximity and position within a given space, without unnecessary hassle. Estimote Indoor Location does just that. It makes it incredibly easy and quick to map any location. Once done, you can use our SDK to visualize your approximate position within that space in real-time, in your own app. Indoor Location creates a rich canvas upon which to build powerful new mobile experiences, from in-venue analytics and proximity marketing to frictionless payments and personalized shopping. What is Estimote Indoor Location SDK? Download software free. ``` http://developer.estimote.com/indoor/ ``` **\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_** **iBeacon and other RSSI position location:** While iBeacon is principally intended as an information promulgation system, a number of people have used the BLE transmitters as position/ triangulation based on RSSI and other methods. The Wikipedia page provides a good general overview. ``` https://en.wikipedia.org/wiki/IBeacon ``` BLE mesh networking ``` https://en.wikipedia.org/wiki/Scatternet ``` An experienced BLE position location developer and vendor. ``` https://locatify.com/blog/indoor-positioning-systems-ble-beacons/ ``` BLE - more re beacon based ``` http://estimote.com/ ``` Another <http://kontakt.io/> BLE in GEC lighting fixtures ``` http://9to5mac.com/2014/05/29/ge-integrates-ibeacons-in-new-led-lighting-fixtures-rolling-out-in-walmart-other-retailers/ ``` ' Google Scholar on ble position detection. ``` https://scholar.google.co.nz/scholar?q=ble+position+detection&hl=en&as_sdt=0&as_vis=1&oi=scholart&sa=X&ved=0ahUKEwiinMfLzqLNAhXkdqYKHWe4AOkQgQMIGjAA ``` 9783319226880-c2.pdf <- URL needed. ``` Indoor Position Detection Using BLE Signals Based on Voronoi Diagram ``` An Analysis of the Accuracy of Bluetooth Low Energy for Indoor Positioning Applications ``` http://www.cl.cam.ac.uk/~rmf25/papers/BLE.pdf ``` Indoor positioning with beacons and mobile devices ``` http://bits.citrusbyte.com/indoor-positioning-with-beacons/ ``` **OPEN BEACON PROJECT** ``` http://get.openbeacon.org/about.html ``` Development <http://get.openbeacon.org/source/#github> <http://www.openbeacon.org/> Bluetooth Proximity Tag Nordic BLS IC / modules <https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy2/nRF51822> <http://get.openbeacon.org/source/#github> --- I have many many many variably related references if of interest - but, so does Mr Gargoyle. eg [Every picture tells a story](https://www.google.co.nz/search?q=ble+rssi+distance+position&num=100&espv=2&source=lnms&tbm=isch&sa=X&ved=0ahUKEwitnuz6ldXPAhVEilQKHQGnCQ8Q_AUICCgB&biw=1527&bih=836) and Most of these [many many many stories](https://www.google.co.nz/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=ble%20rssi%20distance%20position&oq=ble%20rssi%20distance%20position&aqs=chrome..69i57.11311j0j8) will be of high relevance.
If you want to calculate the path loss exponent 'n' you would first need to train the linear or straight line model. You can do this by determining the path loss for a range of distances within the region of interest. The path loss exponent can then be determined by fitting a straight line to the distance vs path loss data. This can either be done in MATLAB or if you are not good with coding using the linear regression model within excel. More the data used to find 'n' better it is. But remember that the linear model just gives you averaged out results. The results obtained by this approach may vary from reality quite appreciably.
263,092
I'm trying to build a simple low-power water level alarm such that it could run continuously for at least 4 months on just 3x AA batteries. I've found this schematic which uses the 555 timer: [![enter image description here](https://i.stack.imgur.com/hmYaY.jpg)](https://i.stack.imgur.com/hmYaY.jpg) However, the 555 timer has a minimum power consumption of around 30mW, which would be too much. Would it be a good idea to modify the circuit such that the water's conduction supplies power to the 555 like so: [![enter image description here](https://i.stack.imgur.com/LzVSy.jpg)](https://i.stack.imgur.com/LzVSy.jpg) Is water conductive enough for this to operate? Would it be a better idea to just use a low-power MCU like MSP430 and raise an interrupt when the probes short by water's conduction? Any thought appreciated.
2016/10/12
[ "https://electronics.stackexchange.com/questions/263092", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/80217/" ]
If using a well designed WiFi receiver such as in Laptops, there is a Windows App ( get WiFiInspector-Setup-1.2.1.4.exe ) that will display WiFi signal in 1dB resolution with stripchart or numeric display. Then using **Friis Loss** to define inverse squared Distance losses in RF, one can make a reasonable conversion from RSSI to dB to distance for line of site with care to avoid wall reflections. from -80 dBm to say -30dBm [![enter image description here](https://i.stack.imgur.com/6V2jM.png)](https://i.stack.imgur.com/6V2jM.png) Body proximity will also affect near field reflections at low levels. Put router high on plastic chair or table and expect all metal structures and some other materials to reflect signals and cause Ricean Fading nulls. To expect decent coverage, you will need a high quality router such as DIR-880L Warning: Slightest orientation of a few mm of Laptop can cause peaks and nulls in low level areas due to Ricean fading. You can then chart range of signals in each room and plot Min/max mean vs distance. using strip chart and walking around zone to be measured. Typically if RSSI > > * -60 dBm excellent > * -70 dBm good > * < -70 dBm marginal and baud rates will be affected from interference > * <-80 dBm poor and barely enough to communicate > * WiFi speed and SNR threshold or RSSI level are inversely related so "b" speed 11Mbps needs less signal and "n" speed needs more. > > >
If you want to calculate the path loss exponent 'n' you would first need to train the linear or straight line model. You can do this by determining the path loss for a range of distances within the region of interest. The path loss exponent can then be determined by fitting a straight line to the distance vs path loss data. This can either be done in MATLAB or if you are not good with coding using the linear regression model within excel. More the data used to find 'n' better it is. But remember that the linear model just gives you averaged out results. The results obtained by this approach may vary from reality quite appreciably.
11,229,778
Problem: When I run my tests, I get the following message in the command prompt ``` Started ChromeDriver port=9515 version=21.0.1180.4 log=C:\Users\jhomer\Desktop\Workspace\WebAutomationTesting\Tests\chromedriver.log ``` Chrome then starts, after which I get a windows error message stating the chromedriver has stopped working. Additional Information: I just recently switched from a mac (osx) to windows 7. I'm using the same IDE (Aptana 3) and I have installed the same gems: ``` addressable (2.2.8) bigdecimal (1.1.0) builder (3.0.0) childprocess (0.3.2) commonwatir (3.0.0) ffi (1.0.11) hoe (3.0.6) io-console (0.3) json (1.7.3, 1.5.4) json_pure (1.7.3) libwebsocket (0.1.3) minitest (3.2.0, 3.1.0, 2.5.1 multi_json (1.3.6) nokogiri (1.5.5 x86-mingw32) rake (0.9.2.2) rautomation (0.7.2) rdoc (3.12, 3.9.4) rubygems-update (1.8.24) rubyzip (0.9.9) s4t-utils (1.0.4) selenium-webdriver (2.24.0) user-choices (1.1.6.1) watir (3.0.0) watir-classic (3.0.0) watir-webdriver (0.6.1) win32-api (1.4.8 x86-mingw32) win32-process (0.6.5) windows-api (0.4.1) windows-pr (1.2.1) xml-simple (1.1.1) ``` I have run gem update, gem pristine --all, none of which have helped. \*\* update \*\* The error I was getting on the prompt after the tests "completed" is as follows: So before I used the version you suggested I was getting this error: ``` Error: test_UserRoles(UserRolesTest): Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2) C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/default.rb:76:in `response_for' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/default.rb:38:in 'request' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/common.rb:40:in `call' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:598:in 'raw_execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:576:in `execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:189:in 'quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/chrome/bridge.rb:48:in 'quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/common/driver.rb:166:in `quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdrive r/browser.rb:87:in 'close' UserRolesTest.rb:48:in 'teardown' ``` Let me know if there is any additional information you may require. Thanks.
2012/06/27
[ "https://Stackoverflow.com/questions/11229778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486119/" ]
Const-conversion is covered by section 6.5.16.1 (1) of the standard: > > * both operands are pointers to qualified or unqualified versions of compatible types, > and the type pointed to by the left has all the qualifiers of the type pointed to by the > right; > > > In this case it looks like `T` is `char [6]` and the rest of the requirement clearly holds, as can be seen by modifying your example: ``` int main(int argc, char *argv[]) { typedef char c6[6]; c6 a = "hello"; const c6 *p = &a; } ``` However this is actually not the case! This intersects with 6.7.3 (8): > > If the specification of an array type includes any type qualifiers, the element type is so qualified, not the array type. > > > So `const c6 *` actually names the type `const char (*)[6]`; that is, *pointer to array[6] of const char*, not *pointer to const array[6] of char*. Then the LHS points to the type `const char[6]`, the RHS points to the type `char[6]`, which are not compatible types, and the requirements for simple assignment do not hold.
Actually the reasons are quite similar (char \*\* vs. pointer of arrays). For what you are trying to do, the following would suffice (and it works): ``` void fun(const char *p) { printf("%s", p); } int main(int argc, char *argv[]) { char a[6] = "hello"; char *c; c = a; fun(c); } ``` With what you are trying to do, it would be possible to modify the values as follows that defeats the purpose (just an example): ``` void morefun(const char *p[6]) { char d; char *p1 = &d; p[1] = p1; *p1 = 'X'; printf("\nThe char is %c\n", *p[1]); } int main(int argc, char *argv[]) { const char *d[6]; morefun(d); } ```
11,229,778
Problem: When I run my tests, I get the following message in the command prompt ``` Started ChromeDriver port=9515 version=21.0.1180.4 log=C:\Users\jhomer\Desktop\Workspace\WebAutomationTesting\Tests\chromedriver.log ``` Chrome then starts, after which I get a windows error message stating the chromedriver has stopped working. Additional Information: I just recently switched from a mac (osx) to windows 7. I'm using the same IDE (Aptana 3) and I have installed the same gems: ``` addressable (2.2.8) bigdecimal (1.1.0) builder (3.0.0) childprocess (0.3.2) commonwatir (3.0.0) ffi (1.0.11) hoe (3.0.6) io-console (0.3) json (1.7.3, 1.5.4) json_pure (1.7.3) libwebsocket (0.1.3) minitest (3.2.0, 3.1.0, 2.5.1 multi_json (1.3.6) nokogiri (1.5.5 x86-mingw32) rake (0.9.2.2) rautomation (0.7.2) rdoc (3.12, 3.9.4) rubygems-update (1.8.24) rubyzip (0.9.9) s4t-utils (1.0.4) selenium-webdriver (2.24.0) user-choices (1.1.6.1) watir (3.0.0) watir-classic (3.0.0) watir-webdriver (0.6.1) win32-api (1.4.8 x86-mingw32) win32-process (0.6.5) windows-api (0.4.1) windows-pr (1.2.1) xml-simple (1.1.1) ``` I have run gem update, gem pristine --all, none of which have helped. \*\* update \*\* The error I was getting on the prompt after the tests "completed" is as follows: So before I used the version you suggested I was getting this error: ``` Error: test_UserRoles(UserRolesTest): Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2) C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/default.rb:76:in `response_for' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/default.rb:38:in 'request' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/common.rb:40:in `call' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:598:in 'raw_execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:576:in `execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:189:in 'quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/chrome/bridge.rb:48:in 'quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/common/driver.rb:166:in `quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdrive r/browser.rb:87:in 'close' UserRolesTest.rb:48:in 'teardown' ``` Let me know if there is any additional information you may require. Thanks.
2012/06/27
[ "https://Stackoverflow.com/questions/11229778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486119/" ]
It is just a quirk of C language specification. For another example, the `char **` to `const char *const *` conversion is also safe from the const-correctness point of view, yet it is prohibited in C. This quirk of const-correctness rules was "fixed" in C++ language, but C continues to stick to its original specification in this regard.
Const-conversion is covered by section 6.5.16.1 (1) of the standard: > > * both operands are pointers to qualified or unqualified versions of compatible types, > and the type pointed to by the left has all the qualifiers of the type pointed to by the > right; > > > In this case it looks like `T` is `char [6]` and the rest of the requirement clearly holds, as can be seen by modifying your example: ``` int main(int argc, char *argv[]) { typedef char c6[6]; c6 a = "hello"; const c6 *p = &a; } ``` However this is actually not the case! This intersects with 6.7.3 (8): > > If the specification of an array type includes any type qualifiers, the element type is so qualified, not the array type. > > > So `const c6 *` actually names the type `const char (*)[6]`; that is, *pointer to array[6] of const char*, not *pointer to const array[6] of char*. Then the LHS points to the type `const char[6]`, the RHS points to the type `char[6]`, which are not compatible types, and the requirements for simple assignment do not hold.
11,229,778
Problem: When I run my tests, I get the following message in the command prompt ``` Started ChromeDriver port=9515 version=21.0.1180.4 log=C:\Users\jhomer\Desktop\Workspace\WebAutomationTesting\Tests\chromedriver.log ``` Chrome then starts, after which I get a windows error message stating the chromedriver has stopped working. Additional Information: I just recently switched from a mac (osx) to windows 7. I'm using the same IDE (Aptana 3) and I have installed the same gems: ``` addressable (2.2.8) bigdecimal (1.1.0) builder (3.0.0) childprocess (0.3.2) commonwatir (3.0.0) ffi (1.0.11) hoe (3.0.6) io-console (0.3) json (1.7.3, 1.5.4) json_pure (1.7.3) libwebsocket (0.1.3) minitest (3.2.0, 3.1.0, 2.5.1 multi_json (1.3.6) nokogiri (1.5.5 x86-mingw32) rake (0.9.2.2) rautomation (0.7.2) rdoc (3.12, 3.9.4) rubygems-update (1.8.24) rubyzip (0.9.9) s4t-utils (1.0.4) selenium-webdriver (2.24.0) user-choices (1.1.6.1) watir (3.0.0) watir-classic (3.0.0) watir-webdriver (0.6.1) win32-api (1.4.8 x86-mingw32) win32-process (0.6.5) windows-api (0.4.1) windows-pr (1.2.1) xml-simple (1.1.1) ``` I have run gem update, gem pristine --all, none of which have helped. \*\* update \*\* The error I was getting on the prompt after the tests "completed" is as follows: So before I used the version you suggested I was getting this error: ``` Error: test_UserRoles(UserRolesTest): Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2) C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/default.rb:76:in `response_for' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/default.rb:38:in 'request' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/http/common.rb:40:in `call' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:598:in 'raw_execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:576:in `execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/remote/bridge.rb:189:in 'quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/chrome/bridge.rb:48:in 'quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/w ebdriver/common/driver.rb:166:in `quit' C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdrive r/browser.rb:87:in 'close' UserRolesTest.rb:48:in 'teardown' ``` Let me know if there is any additional information you may require. Thanks.
2012/06/27
[ "https://Stackoverflow.com/questions/11229778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486119/" ]
It is just a quirk of C language specification. For another example, the `char **` to `const char *const *` conversion is also safe from the const-correctness point of view, yet it is prohibited in C. This quirk of const-correctness rules was "fixed" in C++ language, but C continues to stick to its original specification in this regard.
Actually the reasons are quite similar (char \*\* vs. pointer of arrays). For what you are trying to do, the following would suffice (and it works): ``` void fun(const char *p) { printf("%s", p); } int main(int argc, char *argv[]) { char a[6] = "hello"; char *c; c = a; fun(c); } ``` With what you are trying to do, it would be possible to modify the values as follows that defeats the purpose (just an example): ``` void morefun(const char *p[6]) { char d; char *p1 = &d; p[1] = p1; *p1 = 'X'; printf("\nThe char is %c\n", *p[1]); } int main(int argc, char *argv[]) { const char *d[6]; morefun(d); } ```
9,717,159
Could an iOS app get the iTunes link of itself? Is there an API for this?
2012/03/15
[ "https://Stackoverflow.com/questions/9717159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41948/" ]
You way use iTunes Search API to look up your and other apps on the App Store. Docs: <http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html> Example: <http://itunes.apple.com/search?media=software&country=us&term=raining%20weather> iTunes may return more then one result, but you can filter results by `bundleId`. `trackViewUrl` will contain iTunes URL to your app. `trackId` will contain app's ID.
Until your app is approved and published for the first time you cannot get the app store link. I would recommend using bit.ly shorturl with a random link in your app. Once the app is approved you can change the bit.ly destination to the app store link.
9,717,159
Could an iOS app get the iTunes link of itself? Is there an API for this?
2012/03/15
[ "https://Stackoverflow.com/questions/9717159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41948/" ]
Here is the answer. 1. The app requests <http://itunes.apple.com/lookup?bundleId=com.clickgamer.AngryBirds> 2. Find the `"version": "2.1.0"` and `"trackId": 343200656` in the JSON response. Warning: This API is undocumented, Apple could change it without notice. References: [1] <https://github.com/nicklockwood/iVersion/blob/master/iVersion/iVersion.m#L705> [2] <https://stackoverflow.com/a/8841636/41948> [3] <http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsLookup?id=343200656&mt=8> [4] <http://itunes.apple.com/WebObjects/MZStoreServices.woa/ws/wsSearch?term=+Angry+Birds&country=US&media=software&entity=softwareDeveloper&limit=6&genreId=&version=2&output=json&callback=jsonp1343116626493>
You way use iTunes Search API to look up your and other apps on the App Store. Docs: <http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html> Example: <http://itunes.apple.com/search?media=software&country=us&term=raining%20weather> iTunes may return more then one result, but you can filter results by `bundleId`. `trackViewUrl` will contain iTunes URL to your app. `trackId` will contain app's ID.
9,717,159
Could an iOS app get the iTunes link of itself? Is there an API for this?
2012/03/15
[ "https://Stackoverflow.com/questions/9717159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41948/" ]
Here is the answer. 1. The app requests <http://itunes.apple.com/lookup?bundleId=com.clickgamer.AngryBirds> 2. Find the `"version": "2.1.0"` and `"trackId": 343200656` in the JSON response. Warning: This API is undocumented, Apple could change it without notice. References: [1] <https://github.com/nicklockwood/iVersion/blob/master/iVersion/iVersion.m#L705> [2] <https://stackoverflow.com/a/8841636/41948> [3] <http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsLookup?id=343200656&mt=8> [4] <http://itunes.apple.com/WebObjects/MZStoreServices.woa/ws/wsSearch?term=+Angry+Birds&country=US&media=software&entity=softwareDeveloper&limit=6&genreId=&version=2&output=json&callback=jsonp1343116626493>
Until your app is approved and published for the first time you cannot get the app store link. I would recommend using bit.ly shorturl with a random link in your app. Once the app is approved you can change the bit.ly destination to the app store link.
29,748
Recently saw a video by a nurse swinging a baby probably under 1 year holding baby's legs. Is it safe to lift 7-month-old girl baby using the legs if the baby enjoys?
2017/04/14
[ "https://parenting.stackexchange.com/questions/29748", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/27334/" ]
This depends somewhat on the baby's age and whether the baby has any problems with his hips. If a baby is cruising (standing holding on to furniture and taking steps this way), I don't think short periods of gentle upside down swinging is harmful; obviously, don't repeat if the baby isn't enjoying it. I would also add that it shouldn't be done if a baby has recently eaten.\* The hips are comparatively very stable joints; it's rare to dislocate a normal hip, whereas dislocated shoulders are common, and dislocated elbows are very, very common. That's because one of the pair of bones in the forearm, the radius, is incompletely formed still, and the ligaments still relatively weak, and do not protect from being pulled out of joint with force. > > Nursemaid's elbow often occurs when a caregiver holds a child's hand or wrist and pulls suddenly on the arm to avoid a dangerous situation or to help the child onto a step or curb. The injury may also occur during play when an older friend or family member swings a child around holding just the arms or hands. > > > Nursemaid's elbow occurs when there is a partial separation of the radiocapitellar joint. Because a young child's ligaments - the strong tissues that attach bones to each other-are not fully formed, even a mild force on the joint may cause it to shift, or partially dislocate. > > > The annular ligament surrounds the radius and may be particularly loose in some young children, which may lead to nursemaid's elbow recurring over and over again. > > > Although the source mentions swinging a child by the arms, I have never seen a dislocation of this kind occur if this is done gently and properly (both hands - or wrists - at the same time.) Otherwise, with the popular "swing me" game (where the child is walking between the parents and asks to be swung) would result in many injuries. Of course, this should be avoided in children who have already experiences a dislocated elbow (or more properly called a radial head subluxation, which is a partial dislocation) because the first **recurrence rate** is about 22%. \*My husband was doing this to our (maybe 6 month old) baby, who was loving it. I asked him to stop, I encouraged him to stop, I warned him to stop, but he didn't, until the child vomited in a large arc everywhere. He should have thought about it more. Common sense. But the baby was fine, if perhaps a little dizzy on returning to the proper upright position. The hips are so stable normally that on delivery of sheep and goats, if the newborn animal is not breathing, one of the first things the 'midwife' (me, in my case) can do is to grab the newborn by the hind legs and forcefully swing in a full circle. This helps to clear liquid from the respiratory tract. NB: sheep and goat infants's hips are strong enough to withstand walking/weightbearing a very short time after birth. [Nursemaid's Elbow](http://orthoinfo.aaos.org/topic.cfm?topic=a00717) [Developmental Dislocation (Dysplasia) of the Hip (DDH)](http://orthoinfo.aaos.org/topic.cfm?topic=a00347)
The biggest risk I see is hitting the head on something (if swinging) or dropping the baby (head/neck injury). You might think you would never do that... but accidents do happen. Imagine you're holding her close to your face and you suddenly get a stream of vomit coming your way. It could be reflex to put her down a bit more quickly than you should. So at that age I would only be comfortable doing it a very short distance above a soft surface, with slow movements and no hard objects nearby.
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
Probably `str` doesn't represent an `int`. See the [docs](http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt%28java.lang.String%29) - ... `NumberFormatException` - **if the string does not contain a parsable integer**. To know your problem, you can do the following: ``` int[] intarray=new int[token.length]; int i=0; for(String str : token){ try { intarray[i++] = Integer.parseInt(str); } catch(NumberFormatException e) { System.out.println(str + " is not a parsable int"); } } ```
Hi i am fully agreed with @maroun but if you say you are passing only numeric value in token array then use the trim because sometime we do not take care of space before and after.. like if you try to convert `" 123 " to int it will throw error because of extra space` so i will suggest you to also use the **trim()** when u are parsing the string to int ``` intarray[i++] = Integer.parseInt(str.trim()); ```
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
Probably `str` doesn't represent an `int`. See the [docs](http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt%28java.lang.String%29) - ... `NumberFormatException` - **if the string does not contain a parsable integer**. To know your problem, you can do the following: ``` int[] intarray=new int[token.length]; int i=0; for(String str : token){ try { intarray[i++] = Integer.parseInt(str); } catch(NumberFormatException e) { System.out.println(str + " is not a parsable int"); } } ```
You can get a NumberFormatException if you are reading even the spaces from your input. Please make sure that you trim your string before Integer.parseInt also check whether the string represents an integer
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
Probably `str` doesn't represent an `int`. See the [docs](http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt%28java.lang.String%29) - ... `NumberFormatException` - **if the string does not contain a parsable integer**. To know your problem, you can do the following: ``` int[] intarray=new int[token.length]; int i=0; for(String str : token){ try { intarray[i++] = Integer.parseInt(str); } catch(NumberFormatException e) { System.out.println(str + " is not a parsable int"); } } ```
I face the same problem but in my case string contains only number.and if your token contains only number value then you can try with int[] intarray=new int[token.length]; int i=0; for (String str : token) { intarray[i++] = Integer.valueOf(str); }
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
Probably `str` doesn't represent an `int`. See the [docs](http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt%28java.lang.String%29) - ... `NumberFormatException` - **if the string does not contain a parsable integer**. To know your problem, you can do the following: ``` int[] intarray=new int[token.length]; int i=0; for(String str : token){ try { intarray[i++] = Integer.parseInt(str); } catch(NumberFormatException e) { System.out.println(str + " is not a parsable int"); } } ```
The problem is in the way you're getting the strings from your file. Try this function to get your array of strings: ``` String[] getTokens(String filename) { try { String line; StringBuilder fileInAStringBuilder = new StringBuilder(); BufferedReader fileReader = new BufferedReader(new FileReader(filename)); while((line = fileReader.readLine()) != null) { fileInAStringBuilder.append(line).append(' '); } String fileInAString = fileInAStringBuilder.toString(); fileInAString = fileInAString.replaceAll("\\D", " "); fileReader.close(); return fileInAString.split(" +"); } catch (IOException e) { throw new RuntimeException(e); } } ``` Your code would be something like this: ``` String[] token = getTokens("myFileName.txt"); int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Be also aware that this could fail if any of numbers is too big to "fit" in an int.
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
The best way is to make sure your `str` represent `ints` only, by removing all non-digit character: ``` for (String str : token){ if(str.replaceAll("\\D","").length()>0) intarray[i++] = Integer.parseInt(str.replaceAll("\\D","")); } ``` By the way, if `white-spaces` is the only possible non-digit characters to exist in your array, you can simply use `str.trim()`
Hi i am fully agreed with @maroun but if you say you are passing only numeric value in token array then use the trim because sometime we do not take care of space before and after.. like if you try to convert `" 123 " to int it will throw error because of extra space` so i will suggest you to also use the **trim()** when u are parsing the string to int ``` intarray[i++] = Integer.parseInt(str.trim()); ```
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
The best way is to make sure your `str` represent `ints` only, by removing all non-digit character: ``` for (String str : token){ if(str.replaceAll("\\D","").length()>0) intarray[i++] = Integer.parseInt(str.replaceAll("\\D","")); } ``` By the way, if `white-spaces` is the only possible non-digit characters to exist in your array, you can simply use `str.trim()`
You can get a NumberFormatException if you are reading even the spaces from your input. Please make sure that you trim your string before Integer.parseInt also check whether the string represents an integer
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
The best way is to make sure your `str` represent `ints` only, by removing all non-digit character: ``` for (String str : token){ if(str.replaceAll("\\D","").length()>0) intarray[i++] = Integer.parseInt(str.replaceAll("\\D","")); } ``` By the way, if `white-spaces` is the only possible non-digit characters to exist in your array, you can simply use `str.trim()`
I face the same problem but in my case string contains only number.and if your token contains only number value then you can try with int[] intarray=new int[token.length]; int i=0; for (String str : token) { intarray[i++] = Integer.valueOf(str); }
21,423,965
a little help here. I'm so confused and have done so many variations of converting String array into int array. I get numbers from a file then tokenize it. However, I get a NumberFormatException and a lot of errors when trying to convert the array. Any idea? Here's my code below: ``` int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Any help would be much appreciated. [EDIT] When I do this code below. No errors but it only prints some integers in the token. ``` int[] ints = new int[arrays.length]; for(int i=0; i<array.length; i++){ try{ ints[i] = Integer.parseInt(array[i]); } catch(NumberFormatException nfe){ //Not an integer, do some } } ``` Here's the txt file where I get the numbers: ``` 3 5 1 2 1 2 4 2 3 1 2 6 2 3 4 9 1 ``` [SOLVED] I got it. Simply split("\W+"). I thought splitting " " is enough to also split newline. Thanks guys.
2014/01/29
[ "https://Stackoverflow.com/questions/21423965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2165940/" ]
The best way is to make sure your `str` represent `ints` only, by removing all non-digit character: ``` for (String str : token){ if(str.replaceAll("\\D","").length()>0) intarray[i++] = Integer.parseInt(str.replaceAll("\\D","")); } ``` By the way, if `white-spaces` is the only possible non-digit characters to exist in your array, you can simply use `str.trim()`
The problem is in the way you're getting the strings from your file. Try this function to get your array of strings: ``` String[] getTokens(String filename) { try { String line; StringBuilder fileInAStringBuilder = new StringBuilder(); BufferedReader fileReader = new BufferedReader(new FileReader(filename)); while((line = fileReader.readLine()) != null) { fileInAStringBuilder.append(line).append(' '); } String fileInAString = fileInAStringBuilder.toString(); fileInAString = fileInAString.replaceAll("\\D", " "); fileReader.close(); return fileInAString.split(" +"); } catch (IOException e) { throw new RuntimeException(e); } } ``` Your code would be something like this: ``` String[] token = getTokens("myFileName.txt"); int[] intarray=new int[token.length]; int i=0; for (String str : token){ intarray[i++] = Integer.parseInt(str); } ``` Be also aware that this could fail if any of numbers is too big to "fit" in an int.
7,577,473
I am pretty new to .Net. In classes I have seen objects as IComparer, IEnumerable etc. Could some one explain what does these stand for? Thanks for your help.
2011/09/28
[ "https://Stackoverflow.com/questions/7577473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968179/" ]
They are interfaces. An interface ensures that an object has certain methods, regardless of it's class. They are useful when you have code that requires a few common methods, but doesn't need to know all of the details of the class. `Object()`, `System.Collections.ArrayList` and `System.Collections.Queue` all implement `IEnumerable`. If you have a function that asks for an `IEnumerable`, you can pass an object of any of these classes to the function, and the function is confident that the object implements all of the IEnumerable members. Try the following code in a console application. These three different classes are all acceptable to pass to `PrintAll(items)`. ``` Public Sub PrintAll(items As IEnumerable) For Each item In items Console.WriteLine(item) Next End Sub Public Sub Main() Dim objects As Object() = {1, 2, 3} Dim list As New ArrayList({4, 5, 6}) Dim queue As New Queue({7, 8, 9}) PrintAll(objects) PrintAll(list) PrintAll(queue) Console.ReadLine() End Sub ```
These are interfaces. The "I" usually denotes this. These contain method contracts that any class implementing the specific interface must implement. In other words, if you have a class that implements IEnumerable then you need to have the methods in your class that are contained in the interface. Interfaces (and object oriented programming) can get very deep, but that's a broad explanation hopefully simple enough to understand. Please let me know if I can clarify.
7,577,473
I am pretty new to .Net. In classes I have seen objects as IComparer, IEnumerable etc. Could some one explain what does these stand for? Thanks for your help.
2011/09/28
[ "https://Stackoverflow.com/questions/7577473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968179/" ]
They are interfaces. An interface ensures that an object has certain methods, regardless of it's class. They are useful when you have code that requires a few common methods, but doesn't need to know all of the details of the class. `Object()`, `System.Collections.ArrayList` and `System.Collections.Queue` all implement `IEnumerable`. If you have a function that asks for an `IEnumerable`, you can pass an object of any of these classes to the function, and the function is confident that the object implements all of the IEnumerable members. Try the following code in a console application. These three different classes are all acceptable to pass to `PrintAll(items)`. ``` Public Sub PrintAll(items As IEnumerable) For Each item In items Console.WriteLine(item) Next End Sub Public Sub Main() Dim objects As Object() = {1, 2, 3} Dim list As New ArrayList({4, 5, 6}) Dim queue As New Queue({7, 8, 9}) PrintAll(objects) PrintAll(list) PrintAll(queue) Console.ReadLine() End Sub ```
I would start by looking into the idea of an [interface](http://msdn.microsoft.com/en-us/library/87d83y5b%28v=vs.80%29.aspx) since these are both interfaces as is evidenced by their [naming conventions](http://msdn.microsoft.com/en-us/library/8bc1fexb%28v=vs.71%29.aspx). It would require a potentially long-winded answer to impart complete understanding but the idea is that the interface provides the signatures of methods so that the inheriting class knows which methods to implement. I realize that was a lot of potentially unfamiliar concepts but think of the interface as a recipe. You are given the guidelines to create something. 1 C of flour, 1 T of sugar, etc. When you want to make the item you make sure you can meet the requirements, throw it all together and you have a finished product. Sorry if this is a terrible analogy, but hope it helps. In your case, the names of the interfaces provided by Microsoft give a small idea of what they're intended to represent. If you inherit [IComparer](http://msdn.microsoft.com/en-us/library/system.collections.icomparer.aspx), for instance, you end up with a class that can compare two objects. It's important to note that the type of objects are not necessarily defined by the interface. It is up to the implementation to dictate the types. Only the "framework" is provided by the interface. Good luck!
7,577,473
I am pretty new to .Net. In classes I have seen objects as IComparer, IEnumerable etc. Could some one explain what does these stand for? Thanks for your help.
2011/09/28
[ "https://Stackoverflow.com/questions/7577473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968179/" ]
They are interfaces. An interface ensures that an object has certain methods, regardless of it's class. They are useful when you have code that requires a few common methods, but doesn't need to know all of the details of the class. `Object()`, `System.Collections.ArrayList` and `System.Collections.Queue` all implement `IEnumerable`. If you have a function that asks for an `IEnumerable`, you can pass an object of any of these classes to the function, and the function is confident that the object implements all of the IEnumerable members. Try the following code in a console application. These three different classes are all acceptable to pass to `PrintAll(items)`. ``` Public Sub PrintAll(items As IEnumerable) For Each item In items Console.WriteLine(item) Next End Sub Public Sub Main() Dim objects As Object() = {1, 2, 3} Dim list As New ArrayList({4, 5, 6}) Dim queue As New Queue({7, 8, 9}) PrintAll(objects) PrintAll(list) PrintAll(queue) Console.ReadLine() End Sub ```
ICompare is for comparing stuffs. classes that related to sorting/comparing(obviously) may implement this. IEnumerable is for collection, listing, linq stuffs.
1,907,504
I've run into reoccuring problem for which I haven't found any good examples or patterns. I have one core service that performs all heavy datasbase operations and that sends results to different front ends (html, silverlight/flash, web services etc). One of the service operation is "GetDocuments", which provides a list of documents based on different filter criterias. If I only had one front-end, I would like to package the result in a list of Document DTOs (Data transfer objects) that just contains the data. However, different front-ends needs different amounts of "metadata". The simples client just needs the document headline and a link reference. Other clients wants a short text snippet of the document, another one also wants a thumbnail and a third wants the name of the author. Its basically all up to the implementation of the GUI what needs to be displayed. Whats the best way to model this: 1. As a lot of different DTOs (Document, DocumentWithThumbnail, DocumentWithTextSnippet) * tends to become a lot of classes 2. As one DTO containing all the data, where the client choose what to display * Lots of unnecessary data sent 3. As one DTO where certain fields are populated based on what the client requested * Tends to become a very large class that needs to be extended over time 4. One DTO but with some kind of generic "Metadata" field containing requested metadata. Or are there other options? Since I want a high performance service, I need to think about both network load and caching strategies. Does anyone have any good patterns or practices that might help me?
2009/12/15
[ "https://Stackoverflow.com/questions/1907504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/112966/" ]
In case anybody gets here looking for an answer to this question, you can follow it here: [Groups not updated on Roster from Database using custom DB](http://www.igniterealtime.org/community/thread/40616?tstart=0) There's a partial solution over there at the Ignite Realtime forums.
A better approach would be to use roster protocol (see [RFC 3921, section 7](http://xmpp.org/rfcs/rfc3921.html#roster)) to modify the roster, perhaps by writing a component for OpenFire. This will modify the caches in transit, as well as sending notifications to clients that are currently logged in for the user. As well, you won't have issues with your changes getting overwritten.
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
In below piece of code, after deleting, your temp is not pointing to next node. So, once you delete first entry of "2" your loop stops. ``` if(temp->data == key) { prev->next = temp->next; temp = 0; delete temp; } ``` Try doing below in IF block. ``` itemToDelete = temp; temp = temp->next; delete itemToDelete; ```
You have a few problems in your code. If first node equal '2' - you delete only first node. And why do you allocate memory for `Node *prev`? And you have memory leak (see comments). You can try this code: ``` void LinkedList::Delete(int key) { if (head == 0) return; Node* prev = 0; Node* cur = head; while (cur != 0) { if (cur->data == key) { Node* temp = cur; if (prev == 0) head = cur->next; else prev->next = cur->next; cur = cur->next; delete temp; } else { prev = cur; cur = cur->next; } } } ```
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
In below piece of code, after deleting, your temp is not pointing to next node. So, once you delete first entry of "2" your loop stops. ``` if(temp->data == key) { prev->next = temp->next; temp = 0; delete temp; } ``` Try doing below in IF block. ``` itemToDelete = temp; temp = temp->next; delete itemToDelete; ```
I have written in Turbo C++ Compiler. It is working very correctly. ``` //start deleteEnd code void deleteEnd() { if (first == NULL) { cout<<"No list Available"; return; } next = first; while (next->add != NULL) { cur = next; next = next->add; } cur->add=NULL; } //deleteEnd ```
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
This is pretty typical C++ beginner's mistake, I bet by the time I'm done typing this answer there will be tones of answers showing you how to delete a pointer (tip: first delete, then nullify -- if you need to). For the sake of completeness, you can avoid having to check `prev` pointer and simplify the code by using pointer to pointer. [See here for details](https://stackoverflow.com/questions/12914917/using-pointers-to-remove-item-from-singly-linked-list). ``` void LinkedList::Delete(int key) { for (Node** pp = &head; *pp; pp = &(*pp)->next) { Node* p = *pp; if (p->data == key) { *pp = p->next; delete p; } } } ```
You have a few problems in your code. If first node equal '2' - you delete only first node. And why do you allocate memory for `Node *prev`? And you have memory leak (see comments). You can try this code: ``` void LinkedList::Delete(int key) { if (head == 0) return; Node* prev = 0; Node* cur = head; while (cur != 0) { if (cur->data == key) { Node* temp = cur; if (prev == 0) head = cur->next; else prev->next = cur->next; cur = cur->next; delete temp; } else { prev = cur; cur = cur->next; } } } ```
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
Your code is not deleting anything because you are not going through the list. You are simply checking that the first element is equal to the key (2), but the list's first element is 1. You need to loop through the whole list if you wish to delete every node whose key == the function argument key. ``` node* current_node{ head }; while (current_node) { node* next{ current_node->next }; if (current_node->key == key) { // This operation should take care of properly managing pointers // in the linked list when a node is erased. erase(current_node); } current_node = next; } ```
You have a few problems in your code. If first node equal '2' - you delete only first node. And why do you allocate memory for `Node *prev`? And you have memory leak (see comments). You can try this code: ``` void LinkedList::Delete(int key) { if (head == 0) return; Node* prev = 0; Node* cur = head; while (cur != 0) { if (cur->data == key) { Node* temp = cur; if (prev == 0) head = cur->next; else prev->next = cur->next; cur = cur->next; delete temp; } else { prev = cur; cur = cur->next; } } } ```
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
You have a few problems in your code. If first node equal '2' - you delete only first node. And why do you allocate memory for `Node *prev`? And you have memory leak (see comments). You can try this code: ``` void LinkedList::Delete(int key) { if (head == 0) return; Node* prev = 0; Node* cur = head; while (cur != 0) { if (cur->data == key) { Node* temp = cur; if (prev == 0) head = cur->next; else prev->next = cur->next; cur = cur->next; delete temp; } else { prev = cur; cur = cur->next; } } } ```
I have written in Turbo C++ Compiler. It is working very correctly. ``` //start deleteEnd code void deleteEnd() { if (first == NULL) { cout<<"No list Available"; return; } next = first; while (next->add != NULL) { cur = next; next = next->add; } cur->add=NULL; } //deleteEnd ```
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
This is pretty typical C++ beginner's mistake, I bet by the time I'm done typing this answer there will be tones of answers showing you how to delete a pointer (tip: first delete, then nullify -- if you need to). For the sake of completeness, you can avoid having to check `prev` pointer and simplify the code by using pointer to pointer. [See here for details](https://stackoverflow.com/questions/12914917/using-pointers-to-remove-item-from-singly-linked-list). ``` void LinkedList::Delete(int key) { for (Node** pp = &head; *pp; pp = &(*pp)->next) { Node* p = *pp; if (p->data == key) { *pp = p->next; delete p; } } } ```
I have written in Turbo C++ Compiler. It is working very correctly. ``` //start deleteEnd code void deleteEnd() { if (first == NULL) { cout<<"No list Available"; return; } next = first; while (next->add != NULL) { cur = next; next = next->add; } cur->add=NULL; } //deleteEnd ```
32,510,948
I know that plenty of questions have been asked regarding deleting a node from linked list. But my mind got stuck at a point and I am unable to clear my confusion. I have a linked list with nodes 1,2,2 in it. And I want to delete nodes of 2 from it. My code is deleting only first node of 2 not the second one. In short I want to delete all the nodes that match to the key give by the user. Here is my code: ``` void LinkedList::Delete(int key) { if(head == 0) return; if(head->data == key) { Node *p = head; head = head->next; delete p; } else { Node *prev = 0; Node *temp = head; while(temp!=0) { if(temp->data == key) { Node *q = temp; temp = temp->next; prev = temp; delete q; } else { prev = temp; temp = temp->next; } } } } ``` If I comment out the `else` portion then it gives me the access violation error at the last line i.e `temp=temp->next` and I know the issue is that to which node it should point if it is at the last node!
2015/09/10
[ "https://Stackoverflow.com/questions/32510948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5280547/" ]
Your code is not deleting anything because you are not going through the list. You are simply checking that the first element is equal to the key (2), but the list's first element is 1. You need to loop through the whole list if you wish to delete every node whose key == the function argument key. ``` node* current_node{ head }; while (current_node) { node* next{ current_node->next }; if (current_node->key == key) { // This operation should take care of properly managing pointers // in the linked list when a node is erased. erase(current_node); } current_node = next; } ```
I have written in Turbo C++ Compiler. It is working very correctly. ``` //start deleteEnd code void deleteEnd() { if (first == NULL) { cout<<"No list Available"; return; } next = first; while (next->add != NULL) { cur = next; next = next->add; } cur->add=NULL; } //deleteEnd ```
50,342,278
I'm still a learner on PHP. I have a button, and it shall run a JavaScript after clicking it, but I want it to show an alert / pop up for users to confirm whether to continue or to abort. Can I do the function in my PHP file in the button code? ``` <TD style='text-align:left;padding:0;margin:0;'> <INPUT type='button' onmouseup="javascript:JS1();" value='JS1'></INPUT> </TD> ```
2018/05/15
[ "https://Stackoverflow.com/questions/50342278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6766972/" ]
you need to make function and use `confirm();` ``` <TD style='text-align:left;padding:0;margin:0;'> <INPUT type='button' onmouseup="myFunction();" value='JS1'></INPUT> </TD> ``` And ``` <script> function myFunction() { confirm("Please confrim"); } </script> ```
Have you tried bootstrap modal? <https://www.w3schools.com/bootstrap/bootstrap_modal.asp> <https://getbootstrap.com/docs/4.0/components/modal/> <https://getbootstrap.com/docs/3.3/javascript/> I have provided 3 links. I think these might help you a little. Do a research and it won't be very hard. Good luck.
50,342,278
I'm still a learner on PHP. I have a button, and it shall run a JavaScript after clicking it, but I want it to show an alert / pop up for users to confirm whether to continue or to abort. Can I do the function in my PHP file in the button code? ``` <TD style='text-align:left;padding:0;margin:0;'> <INPUT type='button' onmouseup="javascript:JS1();" value='JS1'></INPUT> </TD> ```
2018/05/15
[ "https://Stackoverflow.com/questions/50342278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6766972/" ]
you need to make function and use `confirm();` ``` <TD style='text-align:left;padding:0;margin:0;'> <INPUT type='button' onmouseup="myFunction();" value='JS1'></INPUT> </TD> ``` And ``` <script> function myFunction() { confirm("Please confrim"); } </script> ```
Writing code is not what is supposed here. But, still following pseudo code and concepts should work. Steps: 1. If you are using jQuery, bind the event of click. If you are using core Javscript, use `onclick` attribute. 2. In the `onclick` function, add a `confirmation` popup. 3. `confirm()` returns `true` if user selects `yes`, or else it will return `false`. 4. Now, you have to proceed only if `true` is returned by `confirm()`. And javascript code: ``` <script> function JS1() { if (confirm('Your confirmation message')) { // Write your code of form submit/button click handler. } else { return false; } } </script> ```
50,342,278
I'm still a learner on PHP. I have a button, and it shall run a JavaScript after clicking it, but I want it to show an alert / pop up for users to confirm whether to continue or to abort. Can I do the function in my PHP file in the button code? ``` <TD style='text-align:left;padding:0;margin:0;'> <INPUT type='button' onmouseup="javascript:JS1();" value='JS1'></INPUT> </TD> ```
2018/05/15
[ "https://Stackoverflow.com/questions/50342278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6766972/" ]
Writing code is not what is supposed here. But, still following pseudo code and concepts should work. Steps: 1. If you are using jQuery, bind the event of click. If you are using core Javscript, use `onclick` attribute. 2. In the `onclick` function, add a `confirmation` popup. 3. `confirm()` returns `true` if user selects `yes`, or else it will return `false`. 4. Now, you have to proceed only if `true` is returned by `confirm()`. And javascript code: ``` <script> function JS1() { if (confirm('Your confirmation message')) { // Write your code of form submit/button click handler. } else { return false; } } </script> ```
Have you tried bootstrap modal? <https://www.w3schools.com/bootstrap/bootstrap_modal.asp> <https://getbootstrap.com/docs/4.0/components/modal/> <https://getbootstrap.com/docs/3.3/javascript/> I have provided 3 links. I think these might help you a little. Do a research and it won't be very hard. Good luck.
5,632
Until now, I thought 新 meant 'new' in all contexts. In class recently, our tutor showed a slide in which he used 生词 for 'new words'. My dictionary gives the meaning of 生 when used as an adjective as 'raw, uncooked, unripe'. Is there some other subtle meaning of 生 when used in this context to distinguish it from 新 - when would I choose one over the over?
2014/01/22
[ "https://chinese.stackexchange.com/questions/5632", "https://chinese.stackexchange.com", "https://chinese.stackexchange.com/users/3844/" ]
Try a dictionary such as the excellent [汉典](http://www.zdic.net/). [生](http://www.zdic.net/z/1e/js/751F.htm) is both a common and ancient character, so it has many meanings (汉典 lists 20), although a lot of them are related. The definition you are after is this one, which means "unfamiliar": > >  11. 不熟悉的,不常见的:~疏。~客。~字。陌~。 > > > This is subtly different from 新 which means "new".
新词 = new words that did not exist 生词 = words new to me (literally raw/uncooked words) They are as such because the opposition of 新(new) is 老(old)/旧(used), while for 生(raw/living), it is 熟(fully cooked). In French, also, they distinguish 'neuf' and 'nouvel' just so. Generally we make metaphor of the process of learning things as raffinated cooking. For example, a stranger is 生人, however, a familiar person is 熟人 (literally cooked people, here should be taken as 'a learned people'). Although sometimes we regard this 熟 as abbr of 熟悉 (literally all-cooked-ly known), it cannot really jump out of this opposition. By the way, 新人 means a nova/noob(=新手), its opposition is 老人/熟手 rather than 旧人. And, 炒冷饭 means to learn something you have known well over and over.
5,632
Until now, I thought 新 meant 'new' in all contexts. In class recently, our tutor showed a slide in which he used 生词 for 'new words'. My dictionary gives the meaning of 生 when used as an adjective as 'raw, uncooked, unripe'. Is there some other subtle meaning of 生 when used in this context to distinguish it from 新 - when would I choose one over the over?
2014/01/22
[ "https://chinese.stackexchange.com/questions/5632", "https://chinese.stackexchange.com", "https://chinese.stackexchange.com/users/3844/" ]
Try a dictionary such as the excellent [汉典](http://www.zdic.net/). [生](http://www.zdic.net/z/1e/js/751F.htm) is both a common and ancient character, so it has many meanings (汉典 lists 20), although a lot of them are related. The definition you are after is this one, which means "unfamiliar": > >  11. 不熟悉的,不常见的:~疏。~客。~字。陌~。 > > > This is subtly different from 新 which means "new".
新: new 生: fresh. There are many meanings of this character also. Fresh is only one of them.
5,632
Until now, I thought 新 meant 'new' in all contexts. In class recently, our tutor showed a slide in which he used 生词 for 'new words'. My dictionary gives the meaning of 生 when used as an adjective as 'raw, uncooked, unripe'. Is there some other subtle meaning of 生 when used in this context to distinguish it from 新 - when would I choose one over the over?
2014/01/22
[ "https://chinese.stackexchange.com/questions/5632", "https://chinese.stackexchange.com", "https://chinese.stackexchange.com/users/3844/" ]
I am a Chinese. 新 means new and 生 means unfamiliar. In your daily study, a word you first see could be either 新词 (new word) or 生词 (unfamiliar word) to you. However, in public articles, 新词 usually stand for newly made word (ABSOLUTELY NEW TO EVERYONE), and 生词 stand for unfamiliar word (RELATIVELY NEW TO SOMEONE). Hope this helps.
Try a dictionary such as the excellent [汉典](http://www.zdic.net/). [生](http://www.zdic.net/z/1e/js/751F.htm) is both a common and ancient character, so it has many meanings (汉典 lists 20), although a lot of them are related. The definition you are after is this one, which means "unfamiliar": > >  11. 不熟悉的,不常见的:~疏。~客。~字。陌~。 > > > This is subtly different from 新 which means "new".
5,632
Until now, I thought 新 meant 'new' in all contexts. In class recently, our tutor showed a slide in which he used 生词 for 'new words'. My dictionary gives the meaning of 生 when used as an adjective as 'raw, uncooked, unripe'. Is there some other subtle meaning of 生 when used in this context to distinguish it from 新 - when would I choose one over the over?
2014/01/22
[ "https://chinese.stackexchange.com/questions/5632", "https://chinese.stackexchange.com", "https://chinese.stackexchange.com/users/3844/" ]
新词 = new words that did not exist 生词 = words new to me (literally raw/uncooked words) They are as such because the opposition of 新(new) is 老(old)/旧(used), while for 生(raw/living), it is 熟(fully cooked). In French, also, they distinguish 'neuf' and 'nouvel' just so. Generally we make metaphor of the process of learning things as raffinated cooking. For example, a stranger is 生人, however, a familiar person is 熟人 (literally cooked people, here should be taken as 'a learned people'). Although sometimes we regard this 熟 as abbr of 熟悉 (literally all-cooked-ly known), it cannot really jump out of this opposition. By the way, 新人 means a nova/noob(=新手), its opposition is 老人/熟手 rather than 旧人. And, 炒冷饭 means to learn something you have known well over and over.
新: new 生: fresh. There are many meanings of this character also. Fresh is only one of them.
5,632
Until now, I thought 新 meant 'new' in all contexts. In class recently, our tutor showed a slide in which he used 生词 for 'new words'. My dictionary gives the meaning of 生 when used as an adjective as 'raw, uncooked, unripe'. Is there some other subtle meaning of 生 when used in this context to distinguish it from 新 - when would I choose one over the over?
2014/01/22
[ "https://chinese.stackexchange.com/questions/5632", "https://chinese.stackexchange.com", "https://chinese.stackexchange.com/users/3844/" ]
I am a Chinese. 新 means new and 生 means unfamiliar. In your daily study, a word you first see could be either 新词 (new word) or 生词 (unfamiliar word) to you. However, in public articles, 新词 usually stand for newly made word (ABSOLUTELY NEW TO EVERYONE), and 生词 stand for unfamiliar word (RELATIVELY NEW TO SOMEONE). Hope this helps.
新词 = new words that did not exist 生词 = words new to me (literally raw/uncooked words) They are as such because the opposition of 新(new) is 老(old)/旧(used), while for 生(raw/living), it is 熟(fully cooked). In French, also, they distinguish 'neuf' and 'nouvel' just so. Generally we make metaphor of the process of learning things as raffinated cooking. For example, a stranger is 生人, however, a familiar person is 熟人 (literally cooked people, here should be taken as 'a learned people'). Although sometimes we regard this 熟 as abbr of 熟悉 (literally all-cooked-ly known), it cannot really jump out of this opposition. By the way, 新人 means a nova/noob(=新手), its opposition is 老人/熟手 rather than 旧人. And, 炒冷饭 means to learn something you have known well over and over.
5,632
Until now, I thought 新 meant 'new' in all contexts. In class recently, our tutor showed a slide in which he used 生词 for 'new words'. My dictionary gives the meaning of 生 when used as an adjective as 'raw, uncooked, unripe'. Is there some other subtle meaning of 生 when used in this context to distinguish it from 新 - when would I choose one over the over?
2014/01/22
[ "https://chinese.stackexchange.com/questions/5632", "https://chinese.stackexchange.com", "https://chinese.stackexchange.com/users/3844/" ]
I am a Chinese. 新 means new and 生 means unfamiliar. In your daily study, a word you first see could be either 新词 (new word) or 生词 (unfamiliar word) to you. However, in public articles, 新词 usually stand for newly made word (ABSOLUTELY NEW TO EVERYONE), and 生词 stand for unfamiliar word (RELATIVELY NEW TO SOMEONE). Hope this helps.
新: new 生: fresh. There are many meanings of this character also. Fresh is only one of them.
14,591,486
I have a story board set up like this: 1. Navigation Controller --- connected to ---> View A ---> table cell segue ---> View B 2. Standalone View C, that is, there is no segue connected to it from any other view in the storyboard. I tap on a cell in View A, that automatically performs segue to View B. In View B, after the view is shown and an application event is triggered, it automatically dismisses itself and pushes an instance of View C, doing something like this: View B: ``` - (void)someEvent { ViewCController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewC"]; [self.navigationController pushViewController:controller animated:YES]; } ``` That works all great, View C pops into view. However, when I tap the "back" button on the navigation bar of View C, I want it to pop all the way back to View A, not View B. I tried this: View C: ``` - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController popToRootViewControllerAnimated:animated]; } ``` That works almost as expected in that View C is dismissed and View A comes back up bypassing View B. Problem is, the navigation bar in View A still thinks it's one level deeper because it still shows the "Back" button and not the ones in View A. I have to tap the "Back" button again for it to show the correct buttons. What am I missing?
2013/01/29
[ "https://Stackoverflow.com/questions/14591486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1971981/" ]
Safari 6's webkit has an older version of web audio. Try it on a nightly build, and it might be better - but yes, these are transient issues.
This is an older question but I'll answer since I've come across this before. It seems that in older Safari versions, the GainNode value was limited to 0..1. In Chrome and newer Safari versions you can assign any value (I've run FM/xmod with gain nodes at 30000, for example). I haven't found a solution to this, other than to advise users to use a current browser. The good news is that as of 2016 / Safari 9, the issue has been fixed.
23,830,544
I have a Wordpress set up which requires redirection when the user enters the root of the site to a static HTML file start.html ``` http://www.myhomepage.com/ ``` Redirect to ``` http://www.myhomepage.com/start.html ``` Wordpress adds url rewrites for calls to index.php ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> ``` I only want to redirect ``` http://www.myhomepage.com/ ``` and not ``` http://www.myhomepage.com/buy/ ``` This will not work as all requests to Wordpress goes through index.php. ``` redirect /index.php /start.html ``` I guess I need a redirect for all pure requests to index.php and not those with query strings. Though I can not figure out how to rewrite it. The reason is that I want all users that enters the site to get a static html of the wordpress site. Only when the user starts to navigate the site should request be made against wordpress. EDIT: I required the rule to apply only on GET requests
2014/05/23
[ "https://Stackoverflow.com/questions/23830544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2591411/" ]
It can be done without mod\_rewrite, with [mod\_dir](http://httpd.apache.org/docs/2.2/mod/mod_dir.html) and the [DirectoryIndex](http://httpd.apache.org/docs/2.2/mod/mod_dir.html#DirectoryIndex) Directive. ``` DirectoryIndex start.html ```
Add this line: ``` RewriteRule ^/?$ /start.html [L] ``` just after this line: ``` RewriteBase / ```
23,830,544
I have a Wordpress set up which requires redirection when the user enters the root of the site to a static HTML file start.html ``` http://www.myhomepage.com/ ``` Redirect to ``` http://www.myhomepage.com/start.html ``` Wordpress adds url rewrites for calls to index.php ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> ``` I only want to redirect ``` http://www.myhomepage.com/ ``` and not ``` http://www.myhomepage.com/buy/ ``` This will not work as all requests to Wordpress goes through index.php. ``` redirect /index.php /start.html ``` I guess I need a redirect for all pure requests to index.php and not those with query strings. Though I can not figure out how to rewrite it. The reason is that I want all users that enters the site to get a static html of the wordpress site. Only when the user starts to navigate the site should request be made against wordpress. EDIT: I required the rule to apply only on GET requests
2014/05/23
[ "https://Stackoverflow.com/questions/23830544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2591411/" ]
Add this line: ``` RewriteRule ^/?$ /start.html [L] ``` just after this line: ``` RewriteBase / ```
In addition to @Oussama solution, as I have a form which posts to itself on the first page. Posting to start.html would not work. I added a condition so that rule only applies to GET requests. That way form post would be sent to index.php as usual. ``` RewriteCond %{REQUEST_METHOD} GET RewriteRule ^/?$ /start.html [L] ``` Final file ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_METHOD} GET RewriteRule ^/?$ /start.html [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> ```
23,830,544
I have a Wordpress set up which requires redirection when the user enters the root of the site to a static HTML file start.html ``` http://www.myhomepage.com/ ``` Redirect to ``` http://www.myhomepage.com/start.html ``` Wordpress adds url rewrites for calls to index.php ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> ``` I only want to redirect ``` http://www.myhomepage.com/ ``` and not ``` http://www.myhomepage.com/buy/ ``` This will not work as all requests to Wordpress goes through index.php. ``` redirect /index.php /start.html ``` I guess I need a redirect for all pure requests to index.php and not those with query strings. Though I can not figure out how to rewrite it. The reason is that I want all users that enters the site to get a static html of the wordpress site. Only when the user starts to navigate the site should request be made against wordpress. EDIT: I required the rule to apply only on GET requests
2014/05/23
[ "https://Stackoverflow.com/questions/23830544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2591411/" ]
It can be done without mod\_rewrite, with [mod\_dir](http://httpd.apache.org/docs/2.2/mod/mod_dir.html) and the [DirectoryIndex](http://httpd.apache.org/docs/2.2/mod/mod_dir.html#DirectoryIndex) Directive. ``` DirectoryIndex start.html ```
In addition to @Oussama solution, as I have a form which posts to itself on the first page. Posting to start.html would not work. I added a condition so that rule only applies to GET requests. That way form post would be sent to index.php as usual. ``` RewriteCond %{REQUEST_METHOD} GET RewriteRule ^/?$ /start.html [L] ``` Final file ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_METHOD} GET RewriteRule ^/?$ /start.html [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> ```
4,559,747
Prove that $f$ differentiable at $p$ is continuous at $p$. *Note that proofs of this are readily available on the internet. My goal here is help with* my *proof.* **Proof:** Since $f$ is differentiable, there exists a function $\delta\_d: (0, \infty) \to (0, \infty)$ such that for all $\epsilon\_d > 0$, $$|h| < \delta\_d(\epsilon\_d) \implies |f(p+h) - f(p)| < |hf'(p)| + \epsilon\_d$$ If $f'(p) = 0$, we are done. Otherwise, define $\delta\_c: (0, \infty) \to (0, \infty)$ as $$\epsilon\_c \mapsto \min(\frac{\epsilon\_c}{2|f'(p)|}, \delta\_d(\frac{\epsilon\_c}{2}))$$ Then, for any $\epsilon\_c > 0$, $$|h| < \delta\_c(\epsilon\_c) \implies |f(p+h) - f(p)| < |hf'(p)| + \epsilon\_c/2 \leq \epsilon\_c$$ **Discussion:** I believe my proof is correct, but excessively complicated for what seems like a simple conclusion. Is my proof needlessly complicated? If so, what is the cause - what step could I do differently to keep it simpler (either in my work leading to a proof, or my exposition of the proof). My intuition is that the complication comes from my usage of $\epsilon, \delta$ definitions. [Here](https://math.jhu.edu/%7Ebrown/courses/f17/Documents/DiffImpliesCont.pdf) is a proof which is much simpler, but I can't reverse engineer the proof to figure out how it was inspired. [Here](https://proofwiki.org/wiki/Differentiable_Function_is_Continuous) is an even simpler one. How would you reach the key ideas needed to form a simpler proof, such as the ones cited? What "crux move" would lead me to realize a [simple proof](https://proofwiki.org/wiki/Differentiable_Function_is_Continuous)?
2022/10/23
[ "https://math.stackexchange.com/questions/4559747", "https://math.stackexchange.com", "https://math.stackexchange.com/users/414550/" ]
Proofs of this tend to be reflections of the fact that, in order for: $$\lim\_{h\to0}\frac{f(x+h)-f(x)}{h}$$To even exist, the numerator must also tend to zero. Else you’d observe $\cdot/0$ blowup along some subsequence. Your proof can accordingly be simplified. Note that you can actually have: $$0\le|f(p+h)-f(p)|<|h|\cdot(|f’(p)|+\epsilon\_d)$$So you don’t need to mess with these $\delta\_\bullet$ functions. *Differentiable functions are locally Lipschitz.* Just specify $\varepsilon\_d=1$. I know there is a $\delta>0$ such that $|h|<\delta$ implies: $$0\le|f(p+h)-f(p)|<h(|f’(p)|+1)$$But you can just take $h\to0$ on this inequality, from within $(-\delta,\delta)$, to conclude $|f(p+h)-f(p)|\to0$. If you like, $\forall\epsilon>0$ there is $0<\delta’<\delta$, $\delta’:=\frac{1}{1+|f’(p)|}\epsilon$, such that $|h|<\delta’$ implies: $$0\le|f(x+h)-f(x)|<\epsilon$$
The definition of the differentiability at $p$ says that $$f(p + h) = f(p) + f'(p)h + o(h).$$ In comparison, the definition of continuity at $p$ says that $$f(p + h) = f(p) + o(1).$$ It is clear that $f'(p)h + o(h) = o(1)$, so differentiability implies continuity. The "it is clear" relies on the facts that $f'(p)h = o(1)$ and $o(h) = o(1)$. Both of these are very trivial to prove using $\varepsilon$-$\delta$.
4,559,747
Prove that $f$ differentiable at $p$ is continuous at $p$. *Note that proofs of this are readily available on the internet. My goal here is help with* my *proof.* **Proof:** Since $f$ is differentiable, there exists a function $\delta\_d: (0, \infty) \to (0, \infty)$ such that for all $\epsilon\_d > 0$, $$|h| < \delta\_d(\epsilon\_d) \implies |f(p+h) - f(p)| < |hf'(p)| + \epsilon\_d$$ If $f'(p) = 0$, we are done. Otherwise, define $\delta\_c: (0, \infty) \to (0, \infty)$ as $$\epsilon\_c \mapsto \min(\frac{\epsilon\_c}{2|f'(p)|}, \delta\_d(\frac{\epsilon\_c}{2}))$$ Then, for any $\epsilon\_c > 0$, $$|h| < \delta\_c(\epsilon\_c) \implies |f(p+h) - f(p)| < |hf'(p)| + \epsilon\_c/2 \leq \epsilon\_c$$ **Discussion:** I believe my proof is correct, but excessively complicated for what seems like a simple conclusion. Is my proof needlessly complicated? If so, what is the cause - what step could I do differently to keep it simpler (either in my work leading to a proof, or my exposition of the proof). My intuition is that the complication comes from my usage of $\epsilon, \delta$ definitions. [Here](https://math.jhu.edu/%7Ebrown/courses/f17/Documents/DiffImpliesCont.pdf) is a proof which is much simpler, but I can't reverse engineer the proof to figure out how it was inspired. [Here](https://proofwiki.org/wiki/Differentiable_Function_is_Continuous) is an even simpler one. How would you reach the key ideas needed to form a simpler proof, such as the ones cited? What "crux move" would lead me to realize a [simple proof](https://proofwiki.org/wiki/Differentiable_Function_is_Continuous)?
2022/10/23
[ "https://math.stackexchange.com/questions/4559747", "https://math.stackexchange.com", "https://math.stackexchange.com/users/414550/" ]
Proofs of this tend to be reflections of the fact that, in order for: $$\lim\_{h\to0}\frac{f(x+h)-f(x)}{h}$$To even exist, the numerator must also tend to zero. Else you’d observe $\cdot/0$ blowup along some subsequence. Your proof can accordingly be simplified. Note that you can actually have: $$0\le|f(p+h)-f(p)|<|h|\cdot(|f’(p)|+\epsilon\_d)$$So you don’t need to mess with these $\delta\_\bullet$ functions. *Differentiable functions are locally Lipschitz.* Just specify $\varepsilon\_d=1$. I know there is a $\delta>0$ such that $|h|<\delta$ implies: $$0\le|f(p+h)-f(p)|<h(|f’(p)|+1)$$But you can just take $h\to0$ on this inequality, from within $(-\delta,\delta)$, to conclude $|f(p+h)-f(p)|\to0$. If you like, $\forall\epsilon>0$ there is $0<\delta’<\delta$, $\delta’:=\frac{1}{1+|f’(p)|}\epsilon$, such that $|h|<\delta’$ implies: $$0\le|f(x+h)-f(x)|<\epsilon$$
Here's how I found a simpler proof. *Please comment not only on the correctness, but on the **"how to solve it"** of finding a simpler solution.* The first step is to notice that the OP approach is more complicated than expected, and look for alternate approaches, such as moving from *definitions* (as in the OP) to *computation*. This means asking: 1. What do I want to compute? 2. Are there any known quantities that might be useful in computing it? #1 is clear: $\lim\_{x \to p} f(x)$. We wish to show it equals $f(p)$. #2 is likewise clear: We're given only $\lim\_{h \to 0} \frac{f(p+h) - f(p)}{h} = f'(p)$. We can't immediately use #2 to compute #1, because they are in different "coordinates". Can we rewrite these quantities so that they use more similar "coordinates"? We can! We rewrite #1 as $\lim\_{h \to 0} f(p+h)$ , putting it in the same "coordinates" as #2. This then suggests we use #2 to show $\lim\_{h \to 0} f(p+h) - f(p) = 0$. Multiplying both sides of #2 by $h$, we get $lim\_{h \to 0}f(p+h)-f(p) = hf'(p) = 0$, QED.
41,195,196
I've been looking and looking everywhere for an example of how to get this to work appropriately. I've tried using $q.all() and it doesn't work. I can't seem to get promises to work appropriately or I'm not accessing them correctly. I'm making an API call to retrieve information about movies and I want to keep them ordered by release date. The easiest way would be to keep the call in the order I make them. I order the movie ids by release date and call them in that array order. Then I want to push the data from the call to a new array. But it's instead not always doing it in the correct order. Could someone possibly tell me what I may be doing wrong? ``` $scope.movies = [ {url:"tt3470600", group:"m",youtube:"Vso5o11LuGU", showtimes: "times1"}, {url:"tt3521164", group:"m",youtube:"iAmI1ExVqt4", showtimes: "times2"} ]; $scope.imdb = function () { var promises = []; for(var i = 0; i < $scope.movies.length; i++) { var movie = $scope.movies[i]; var options = {trailer: movie.youtube, times: $scope.times[movie.showtimes]}; var promise = $http.get('http://www.omdbapi.com/?i=' + movie.url); promise.times = options; promises.push(promise); }; return $q.all(promises); }; var x = $scope.imdb(); console.log(x); ``` What's returned is an object `d` with a key of `$$state`. I would love to keep the order desperately because the times I return have a date selection that I would like to keep ordered.
2016/12/17
[ "https://Stackoverflow.com/questions/41195196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2839879/" ]
Even though this topic already has it's accepted answer, this one is not true in any case. There can be situations, in which your app has all the known architectures as valid architectures, has Build Active Architecture Only to NO for Release and still getting this issue. The reason is: If your deployment target is iOS >= 11, then this will run on devices starting with iPhone 5s only. iPhone 5s is the first arm64 device. Hence XCode (at least in version 10) does NOT include anything else than arm64, even though you have all the settings made as suggested. Usually this is not a problem, but it can lead to the "Too many symbols" issue, if you are using Pods, which come with binaries for architectures < arm64. Those will have symbols for armv7, even though your upload does not have a binary for armv7. So it is suggested to fight this by altering the PodFile and include only symbols for arm64.
I suspect you are building the active architecture only. To fix this set `Build Active Architecture Only` to `NO` for `Release` configuration.
135,406
We tried to set the Global Search Center URL in Cental Admin -> Search Servcie Application but it seems not working. We tried to set it by PowerShell script and do an IISREST but when do a search within a site, it is still goes to \_layouts/15/osssearchresults.aspx
2015/03/17
[ "https://sharepoint.stackexchange.com/questions/135406", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/40563/" ]
This does it: ``` $ssa = Get-SPEnterpriseSearchServiceApplication $ssa.SearchCenterUrl = "$SearchSiteURL" #which ends /pages $ssa.Update() ``` No Site Collection settings need to be updated - only if it should display on a different search center.
How does the URL you tried to set in Central administration look like? Did you add the mandatory `"/Pages/"` to your preferred search center URL? This is the most common miss. Don't forget to update the User Profiles / Mysites search center URL after. Oh, and after this is done, you have to specify in every site collection that the query should be redirected to the global search center. Log into the site collection as a site collection administrator and follow this steps: > > Specify search settings for a site collection > > > In your site collection, go to Settings, click Site settings and then > under Site Collection Administration, click Search Settings. > > > To specify a Search Center, in the Search Center URL box, type the URL > of the Search Center site. > > > To change which search result page queries are sent to, in the section > Which search results page should queries be sent to?, clear Use the > same results page settings as my parent, and then select one of the > following: > > > Send queries to a custom results page URL. Enter the URL. Custom URLs > can be relative or absolute, and can also include special tokens, such > as {SearchCenterURL}. Example: `/SearchCenter/Pages/results.aspx` or > `http://server/sites/SearchCenter/Pages/results.aspx`. > > > Turn on the drop-down menu inside the search box, and use the first > Search Navigation node as the destination results page. If you choose > this option, users can choose search vertical in the search box when > they enter a query. > > > Click OK. > > > I've answered this question before, take a look at this two threads to get some more information. [Modify Global Search Center URL](https://sharepoint.stackexchange.com/questions/105282/modify-global-search-center-url/105284#105284) [How to use associate Search Center with Search Box?](https://sharepoint.stackexchange.com/questions/98906/how-to-use-associate-search-center-with-search-box/98935#98935) [Specify search settings for a site collection or a site](https://support.office.com/en-sg/article/Specify-search-settings-for-a-site-collection-or-a-site-99da1d77-f42b-4f56-b48a-24e87f336e91)
135,406
We tried to set the Global Search Center URL in Cental Admin -> Search Servcie Application but it seems not working. We tried to set it by PowerShell script and do an IISREST but when do a search within a site, it is still goes to \_layouts/15/osssearchresults.aspx
2015/03/17
[ "https://sharepoint.stackexchange.com/questions/135406", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/40563/" ]
How does the URL you tried to set in Central administration look like? Did you add the mandatory `"/Pages/"` to your preferred search center URL? This is the most common miss. Don't forget to update the User Profiles / Mysites search center URL after. Oh, and after this is done, you have to specify in every site collection that the query should be redirected to the global search center. Log into the site collection as a site collection administrator and follow this steps: > > Specify search settings for a site collection > > > In your site collection, go to Settings, click Site settings and then > under Site Collection Administration, click Search Settings. > > > To specify a Search Center, in the Search Center URL box, type the URL > of the Search Center site. > > > To change which search result page queries are sent to, in the section > Which search results page should queries be sent to?, clear Use the > same results page settings as my parent, and then select one of the > following: > > > Send queries to a custom results page URL. Enter the URL. Custom URLs > can be relative or absolute, and can also include special tokens, such > as {SearchCenterURL}. Example: `/SearchCenter/Pages/results.aspx` or > `http://server/sites/SearchCenter/Pages/results.aspx`. > > > Turn on the drop-down menu inside the search box, and use the first > Search Navigation node as the destination results page. If you choose > this option, users can choose search vertical in the search box when > they enter a query. > > > Click OK. > > > I've answered this question before, take a look at this two threads to get some more information. [Modify Global Search Center URL](https://sharepoint.stackexchange.com/questions/105282/modify-global-search-center-url/105284#105284) [How to use associate Search Center with Search Box?](https://sharepoint.stackexchange.com/questions/98906/how-to-use-associate-search-center-with-search-box/98935#98935) [Specify search settings for a site collection or a site](https://support.office.com/en-sg/article/Specify-search-settings-for-a-site-collection-or-a-site-99da1d77-f42b-4f56-b48a-24e87f336e91)
I had the same issue, that the global search center wasn't being picked up by the site collections when you specified a blank search center url in the site collection settings and had the "use the same results page settings as my parent" checked off. The way I've gotten this to work is by going to the pages library of the search center and setting the results.aspx page as the home page of the site.
135,406
We tried to set the Global Search Center URL in Cental Admin -> Search Servcie Application but it seems not working. We tried to set it by PowerShell script and do an IISREST but when do a search within a site, it is still goes to \_layouts/15/osssearchresults.aspx
2015/03/17
[ "https://sharepoint.stackexchange.com/questions/135406", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/40563/" ]
This does it: ``` $ssa = Get-SPEnterpriseSearchServiceApplication $ssa.SearchCenterUrl = "$SearchSiteURL" #which ends /pages $ssa.Update() ``` No Site Collection settings need to be updated - only if it should display on a different search center.
I had the same issue, that the global search center wasn't being picked up by the site collections when you specified a blank search center url in the site collection settings and had the "use the same results page settings as my parent" checked off. The way I've gotten this to work is by going to the pages library of the search center and setting the results.aspx page as the home page of the site.
18,079,421
I have a question about scope or lifetime of variables, let me explain my question with an example.The code below, I've created a local variable c and returned it. In main() function the line `a=foo()`, I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed and the variable a should have been kept garbage value.However it keeps 1. Where am I wrong is there anyone to help me ? Thanks in advance. ``` #include <stdio.h> int foo() { int c=1; return c; } int main() { int a; a=foo(); printf("%d",a); return 0; } ```
2013/08/06
[ "https://Stackoverflow.com/questions/18079421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653020/" ]
its basically a function activation record,which will be pushed on the system stack and when your function is returning it will first copy all values to the return result area,that is nothing but a=foo(); and then it will destroy that function activation record from the system stack,I hope it would help
It is not necessary to make its value garbage. after function collapse allocated memory is getting freed but its value remain same,it does not overwrite value with another garbage value.
18,079,421
I have a question about scope or lifetime of variables, let me explain my question with an example.The code below, I've created a local variable c and returned it. In main() function the line `a=foo()`, I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed and the variable a should have been kept garbage value.However it keeps 1. Where am I wrong is there anyone to help me ? Thanks in advance. ``` #include <stdio.h> int foo() { int c=1; return c; } int main() { int a; a=foo(); printf("%d",a); return 0; } ```
2013/08/06
[ "https://Stackoverflow.com/questions/18079421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653020/" ]
its basically a function activation record,which will be pushed on the system stack and when your function is returning it will first copy all values to the return result area,that is nothing but a=foo(); and then it will destroy that function activation record from the system stack,I hope it would help
After `foo` function returns, object `c` is destroyed. In the return statement, `c` object is evaluated and its value is returned. What you are returning is not `c` object but the value of `c`.
18,079,421
I have a question about scope or lifetime of variables, let me explain my question with an example.The code below, I've created a local variable c and returned it. In main() function the line `a=foo()`, I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed and the variable a should have been kept garbage value.However it keeps 1. Where am I wrong is there anyone to help me ? Thanks in advance. ``` #include <stdio.h> int foo() { int c=1; return c; } int main() { int a; a=foo(); printf("%d",a); return 0; } ```
2013/08/06
[ "https://Stackoverflow.com/questions/18079421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653020/" ]
its basically a function activation record,which will be pushed on the system stack and when your function is returning it will first copy all values to the return result area,that is nothing but a=foo(); and then it will destroy that function activation record from the system stack,I hope it would help
When `return c;` it copy c to a tmporary value .And the then copy the tmporary value to a
18,079,421
I have a question about scope or lifetime of variables, let me explain my question with an example.The code below, I've created a local variable c and returned it. In main() function the line `a=foo()`, I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed and the variable a should have been kept garbage value.However it keeps 1. Where am I wrong is there anyone to help me ? Thanks in advance. ``` #include <stdio.h> int foo() { int c=1; return c; } int main() { int a; a=foo(); printf("%d",a); return 0; } ```
2013/08/06
[ "https://Stackoverflow.com/questions/18079421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653020/" ]
its basically a function activation record,which will be pushed on the system stack and when your function is returning it will first copy all values to the return result area,that is nothing but a=foo(); and then it will destroy that function activation record from the system stack,I hope it would help
the memory of c was indeed destroyed when the function was done, but the function returned 1 and that 1 was put in `a`. the value was copied to the memory of `a`! but, for example, this next example will not save the value: ``` #include <stdio.h> int foo(int a) { int c=1; a = c; } int main() { int a = 0; a=foo(); printf("%d",a); return 0; } ``` will print "0"
18,079,421
I have a question about scope or lifetime of variables, let me explain my question with an example.The code below, I've created a local variable c and returned it. In main() function the line `a=foo()`, I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed and the variable a should have been kept garbage value.However it keeps 1. Where am I wrong is there anyone to help me ? Thanks in advance. ``` #include <stdio.h> int foo() { int c=1; return c; } int main() { int a; a=foo(); printf("%d",a); return 0; } ```
2013/08/06
[ "https://Stackoverflow.com/questions/18079421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653020/" ]
its basically a function activation record,which will be pushed on the system stack and when your function is returning it will first copy all values to the return result area,that is nothing but a=foo(); and then it will destroy that function activation record from the system stack,I hope it would help
> > I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed > > > Yes, this is likely what happens. But, your function returns a *value*, and in this case 1, the value of `c`. So however the variable `c` is freed, that value is returned, it is not lost or freed. Then you store that value in `a` and that is why `a` = 1.
18,079,421
I have a question about scope or lifetime of variables, let me explain my question with an example.The code below, I've created a local variable c and returned it. In main() function the line `a=foo()`, I think since c is a local variable and the function foo() was done, the memory cell for variable c should have been destroyed and the variable a should have been kept garbage value.However it keeps 1. Where am I wrong is there anyone to help me ? Thanks in advance. ``` #include <stdio.h> int foo() { int c=1; return c; } int main() { int a; a=foo(); printf("%d",a); return 0; } ```
2013/08/06
[ "https://Stackoverflow.com/questions/18079421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653020/" ]
its basically a function activation record,which will be pushed on the system stack and when your function is returning it will first copy all values to the return result area,that is nothing but a=foo(); and then it will destroy that function activation record from the system stack,I hope it would help
opps i misunderstood your question in my first reply. actually when you return from any function there are some rules in assembly code. so it copy value in internal register and then value of this register is copied into a.
77,848
I am trying to build a plugin to load a print composer from file, generate an atlas and export to image. So far I have been successful in loading the template and exporting it to image. I have been unable to add any of the layers in the legend (which are also in the toc) to the exported map, which results in a blank map and none of the field expressions working. ``` # Get layers in the legend and append, suspect there must be a cleaner way to do this layers = self.iface.legendInterface().layers() layerStringList = [] for layer in layers: layerID = layer.id() layerStringList.append(layerID) # Add layer to map render myMapRenderer = QgsMapRenderer() myMapRenderer.setLayerSet(layerStringList) myMapRenderer.setProjectionsEnabled(False) # Load template myComposition = QgsComposition(myMapRenderer) myFile = os.path.join(os.path.dirname(__file__), 'MMR_Template.qpt') myTemplateFile = file(myFile, 'rt') myTemplateContent = myTemplateFile.read() myTemplateFile.close() myDocument = QDomDocument() myDocument.setContent(myTemplateContent) myComposition.loadFromTemplate(myDocument) # Save image myImagePath = os.path.join(os.path.dirname(__file__), 'come_on.png') myImage = myComposition.printPageAsRaster(0) myImage.save(myImagePath) ``` Here is a snippet from the loaded template which should setup the atlas: ``` <Atlas hideCoverage="false" featureFilter="reference = '61922'" coverageLayer="desktop_search20130615160118593" fixedScale="true" composerMap="0" singleFile="false" filenamePattern="&quot;reference&quot;" enabled="true" filterFeatures="true" sortFeatures="true" sortKey="0" sortAscending="true" margin="1"/> ``` I am also unsure of the best way to add all the layer in the toc to the instance of QgsMapRenderer().
2013/11/18
[ "https://gis.stackexchange.com/questions/77848", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/10415/" ]
If anyone is interested here is the code I ended up with. This will turn on/off specific layers in the table of contents (from a list of layers), load a selected composer template from file, generate an atlas and export the map. Finally, returning the table of contents to its original state. ``` def sort_toc(self): # Turn on/off layers as required by search type legend = self.iface.legendInterface() layers = legend.layers() wanted_layers = metal_wanted global turn_on, turn_off, atlas_desktop turn_off = [] turn_on = [] all_layers = [] for layer in layers: layername = layer.name() all_layers.append(layername) layerid = layer.id() if layername == "desktop_search": atlas_desktop = layer if layername in wanted_layers and legend.isLayerVisible(layer) is False: turn_off.append(layer) legend.setLayerVisible(layer, True) if layername not in wanted_layers and legend.isLayerVisible(layer) is True: turn_on.append(layer) legend.setLayerVisible(layer, False) else: pass # Checks for required layers missing from map file for layer in wanted_layers: missing = [] if layer not in all_layers: missing.append(layer) else: pass if not missing: pass else: QMessageBox.warning(self.iface.mainWindow(), "Missing layers", "Required layers are missing from your map file. Details: %s" % (str(missing))) return atlas_desktop def quick_export(self, ref, stype, scale): # Add all layers in map canvas to render myMapRenderer = self.iface.mapCanvas().mapRenderer() # Load template from file myComposition = QgsComposition(myMapRenderer) myFile = os.path.join(os.path.dirname(__file__), 'MMR_Template.qpt') myTemplateFile = file(myFile, 'rt') myTemplateContent = myTemplateFile.read() myTemplateFile.close() myDocument = QDomDocument() myDocument.setContent(myTemplateContent) myComposition.loadFromTemplate(myDocument) # Get map composition and define scale myAtlasMap = myComposition.getComposerMapById(0) myAtlasMap.setNewScale(int(scale)) # Setup Atlas myAtlas = QgsAtlasComposition(myComposition) myAtlas.setCoverageLayer(atlas_desktop) # Atlas run from desktop_search myAtlas.setComposerMap(myAtlasMap) myAtlas.setFixedScale(True) myAtlas.fixedScale() myAtlas.setHideCoverage(False) myAtlas.setFilterFeatures(True) myAtlas.setFeatureFilter("reference = '%s'" % (str(ref))) myAtlas.setFilterFeatures(True) # Generate atlas myAtlas.beginRender() for i in range(0, myAtlas.numFeatures()): myAtlas.prepareForFeature( i ) jobs = r"\\MSUKSERVER\BusinessMan Docs\Jobs" job_fol = os.path.join(jobs, str(ref)) output_jpeg = os.path.join(job_fol, ref + "_BMS_plan.jpg") myImage = myComposition.printPageAsRaster(0) myImage.save(output_jpeg) myAtlas.endRender() def return_toc(self): # Revert layers back to pre-script state (on/off) legend = self.iface.legendInterface() for wanted in turn_on: legend.setLayerVisible(wanted, True) for unwanted in turn_off: legend.setLayerVisible(unwanted, False) ```
Perhaps this can work on you for getting all current layers: ``` registry = QgsMapLayerRegistry.instance() layers = registry.mapLayers().values() ```
226,838
I want to deploy a "Did you know..." or "Tip of the day" application at the office. It should: * Show a dialog at login time with a random tip. * Obviously, provide some way to store my own tips. * Be easy to disable and reenable by the user itself. I'm using puppet, so I'm covered with the deployment. The tips don't even need to be gathered from a server, since I can deploy the newest tips file/database with no costs. Sure, I could hack a quick solution by using zenity and bash, but I'd like to know if there's any application out there specifically targeted at this. I don't like the zenity approach very much because it's very limited on the contents that can be displayed. No text alongside screenshots, for example. Zenity is aimed towards displaying simple dialogs.
2012/12/08
[ "https://askubuntu.com/questions/226838", "https://askubuntu.com", "https://askubuntu.com/users/83068/" ]
This sounds a lot like a graphical interface to `fortune` with a custom fortunes database. Creating the Custom Fortunes Database ===================================== 1. Create a text file containing all of the tips you want to display. Each tip should be on its own line, and there should be line containing only the `%` character after every tip. 2. Run `strfile -c % tips tips.dat` to produce a file suitable for use with `fortune` Installing `fortune` and the Tips ================================= 1. Run `sudo apt-get install fortune-mod` to get the `fortune` program. 2. Now place `tips` and `tips.dat` in /usr/share/games/fortunes. If there are other files already there, those fortunes will display intermixed with your tips; you may wish to remove them. Graphical Interface =================== There are unfortunately not many options for graphically displaying fortunes. You can either install `xcowsay`, which is in the normal repositories, or install the Wanda the Fish indicator applet from its PPA: <https://launchpad.net/~dylanmccall/+archive/indicator-fish>. Both of these can be configured to start when a user logs in. I believe only `xcowsay` can display images, however. Neither of these programs are particularly professional looking, as `xcowsay` has a talking cow and indicator-fish a cartoon fish accompanying each fortune. If that is a concern for you, you'll likely be better off writing your own graphical wrapper for `fortune`.
I ended up hacking a quick solution with Python using Python-webkit. This solution displays HTML files ``` #!/usr/bin/env python import gtk,webkit,os from random import choice win = gtk.Window() win.connect("destroy", lambda w: gtk.main_quit()) scroller = gtk.ScrolledWindow() win.add(scroller) web = webkit.WebView() scroller.add(web) banners = ["banner1","banner2","banner3"] banner = choice(banners) web.load_uri("file:///usr/local/lib/tips/"+banner+".html") win.resize(640,400) win.show_all() gtk.main() ``` Place the corresponding banners on `/usr/local/lib/tips/`, for example, the `banner1.html` is a simple image: ``` <html><head><style>*,html,body{margin:0;padding:0;}</style></head><body></body><img src='banner1.png' /></html> ``` If you reference resources (images, css, js...), place them also in `/usr/local/lib/tips/`. Then, run this python script at session start, by creating a desktop file on `/etc/xdg/autostart`.
23,397,771
I'm not so great with VHDL and I can't really see why my code won't work. I needed an NCO, found a working program and re-worked it to fit my needs, but just noticed a bug: every full cycle there is one blank cycle. ![](https://i.imgur.com/gmYXHig.jpg) The program takes step for argument (jump between next samples) and clock as trigger. ``` library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.ALL; --try to use this library as much as possible. entity sinwave_new_01 is port (clk :in std_logic; step :in integer range 0 to 1000; dataout : out integer range 0 to 1024 ); end sinwave_new_01; architecture Behavioral of sinwave_new_01 is signal i : integer range 0 to 1999:=0; type memory_type is array (0 to 999) of integer range 0 to 1024; --ROM for storing the sine values generated by MATLAB. signal sine : memory_type :=(long and boring array of 1000 samples here); begin process(clk) begin --to check the rising edge of the clock signal if(rising_edge(clk)) then dataout <= sine(i); i <= i+ step; if(i > 999) then i <= i-1000; end if; end if; end process; end Behavioral; ``` What do I do to get rid of that zero? It appears every full cycle - every (1000/step) pulses. It's not supposed to be there and it messes up my PWM... From what I understand the whole block (`dataout` changes, it is increased, and `if i>999 then i<=i-1000`) executes when there is a positive edge of clock applied on the entrance... BUT it looks like it requires one additional edge to, I don't know, reload it? Does the code execute sequentially, or are all conditions tested when the clock arrives? Am I reaching outside the table, and that's why I'm getting zeroes in that particular pulse? Program /shouldn't/ do that, as far as I understand if statement, or is it VHDL being VHDL and doing its weird stuff again. How do I fix this bug? Guess I could add one extra clock tick every 1k/step pulses, but that's a work around and not a real solution. Thanks in advance for help.
2014/04/30
[ "https://Stackoverflow.com/questions/23397771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2561009/" ]
I had the exact same situation a while back while switching to YARN. Basically there was the concept of `task slots` in MRv1 and `containers` in MRv2. Both of these differ very much in how the tasks are scheduled and run on the nodes. The reason that your job is stuck is that it is unable to find/start a `container`. If you go into the full logs of `Resource Manager/Application Master` etc daemons, you may find that it is doing nothing after it starts to allocate a new container. To solve the problem, you have to tweak your memory settings in `yarn-site.xml` and `mapred-site.xml`. While doing the same myself, I found [this](http://www.alexjf.net/blog/distributed-systems/hadoop-yarn-installation-definitive-guide) and [this](http://hortonworks.com/blog/how-to-plan-and-configure-yarn-in-hdp-2-0/) tutorials especially helpful. I would suggest you to try with the very basic memory settings and optimize them later on. First check with a word count example then go on to other complex ones.
I was facing the same issue.I added the following property to my yarn-site.xml and it solved the issue. ``` <property> <name>yarn.resourcemanager.hostname</name> <value>Hostname-of-your-RM</value> <description>The hostname of the RM.</description> </property> ``` Without the resource manager host name things go awry in the multi-node set up as each node would then default to trying to find a local resource manager and would never announce its resources to the master node. So your Map Reduce execution request probably didn't find any mappers in which to run because the request was being sent to the master and the master didn't know about the slave slots. Reference : <http://www.alexjf.net/blog/distributed-systems/hadoop-yarn-installation-definitive-guide/>
10,116,456
I have been trying to implement a solution for cross browser rounded corners and even though the demo works in all browsers, when I try to implement it in my own code, it works in all browsers *except* IE8. Here is my CSS: ``` body { background:#ffffff url("images/bg.gif") repeat-x ; font-family:verdana,helvetica,sans-serif ; font-size:12px ; color:#000000 ; margin:0 auto ; padding:0 ; } .clear { clear:both } /* clears floats */ /* #container defines layout width and positioning */ #container { width:1000px ; margin:auto ; position:relative ; z-index:inherit ; zoom:1 ; /* enables rounded corners in IE6 */ } #header { width:1000px ; height:75px ; padding:10px 0px 10px 0px ; } #header-logo { float:left ; width:255px ; height:55px ; background:url("http://template.sophio.com/images/logo.png") no-repeat ; } #header-phone { float:left ; display:block ; line-height:55px ; background:url("images/header-phone-bg.png") no-repeat ; background-position:0px 0px ; font-size:28px ; color:#900 ; font-weight:bold ; padding-left:50px ; margin:0px 0px 0px 120px ; } #header-right { float:right ; width:225px ; } #header-right-translate { display:block ; text-align:right ; background:#ffffff ; line-height:26px ; } #header-right-social { display:block ; text-align:right ; background:#FF9 ; line-height:24px ; margin-top:5px ; } #navbar { width:1000px ; height:32px ; background:#9d9687 url("images/header-bg.gif") repeat-x ; border:1px solid #494437 ; -moz-border-radius: 11px 11px 0px 0px ; -webkit-border-radius: 11px 11px 0px 0px ; border-radius: 11px 11px 0px 0px ; behavior: url("border-radius.htc"); } ``` and here is my HTML: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Two Column Right</title> <link rel="stylesheet" href="../style.css" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <div id="header-logo"></div> <div id="header-phone">888-563-2591</div> <div id="header-right"> <div id="header-right-translate"> [Google Translate Widget Here] </div> <div id="header-right-social"> [Social Icons Widget Here] </div> </div> </div> <div id="navbar">text</div> </div> </body> </html> ``` The navbar is what I am applying rounded corners to. In IE8, ALL of my corners are rounded, whereas I only want the top left and right corners to be rounded (they display right in all but IE8).
2012/04/12
[ "https://Stackoverflow.com/questions/10116456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1255168/" ]
This problem has been solved by others on stackoverflow by using CSSPIE: <http://css3pie.com/> In order for rounded-corners to display properly in IE 8, the element with the rounded-corners must have: ``` position: relative; ``` set in the css. see: [CSS rounded corners in IE8](https://stackoverflow.com/questions/7077331/help-with-rounded-corners-css-webkit-ie8) [Border Radius for IE8](https://stackoverflow.com/questions/9426979/border-radius-for-ie8) [Border-radius for IE7 & IE8](https://stackoverflow.com/questions/8308584/border-radius-for-ie7-ie8) also: <http://jc-designs.net/blog/2010/07/getting-border-radius-to-work-in-ie/> (for more info on the position:relative hack) The sass library Compass also offers cross-browser border-radius, but I have no experience using it with ie8
See fiddle for demo: <http://jsfiddle.net/esjzX/1/> , <http://jsfiddle.net/esjzX/1/embedded/result/> ``` Css: b.rtop, b.rbottom{display:block;background: #FFF} b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA} b.r1{margin: 0 5px} b.r2{margin: 0 3px} b.r3{margin: 0 2px} b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px} .rs1{margin: 0 2px} .rs2{margin: 0 1px} div.container{ margin: 0 10%;background: #9BD1FA} HTML: <div class="container"> <b class="rtop"> <b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b> </b> <h1 align="center">Hi!</h1> <p>Rounded corners for cross browsers</p> <b class="rbottom"> <b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b> </b> </div> <br /><br /> <div class="container"> <b class="rtop"> <b class="rs1"></b> <b class="rs2"></b> </b> <h1 align="center">Hi!</h1> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> <b class="rbottom"> <b class="rs2"></b> <b class="rs1"></b> </b> </div> ``` Screen Shot: Pure css bases rounded corners for cross browser compatibility ![enter image description here](https://i.stack.imgur.com/V1oxD.jpg)
3,848,960
i'm ASP.NET programmer and have no experience in creating windows services. Service i need to create should send emails to our customers each specified period of time. This service should solve issue when hundreds of emails are sent at the same time and block SMTP service on the server while there are many periods of time when SMTP is on idle without sending anything. Idea is to create a service that i will send whole email and address to, inside of the service i will have some type of dataset ( i don't know which one should i use in winforms/winservices) and some basic timer functionality (ie. each 3 seconds get first mail and send it)... Thing is that there are two main types of mails, registration mails which should be main priority and reminder mails (ie. you haven't entered a site for month ) which have low priority. I prefer to create this priority issue with two data sets, when main one is empty less important one sends. Another issue is how do i access this service from asp.net application on the same server? How would you write that in code or at least point me how to, i know there are many explanations on MS website on basic services but as i don't know much about issue i prefer having it explained in here. Thanks for your time.
2010/10/03
[ "https://Stackoverflow.com/questions/3848960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/185824/" ]
I don't know why or maybe is buried in some PEP somewhere, but i do know 2 very basic "find" method for lists, and they are `array.index()` and the `in` operator. You can always make use of these 2 to find your items. (Also, re module, etc)
The "find" method for lists is `index`. I do consider the inconsistency between `string.find` and `list.index` to be unfortunate, both in name and behavior: `string.find` returns -1 when no match is found, where `list.index` raises ValueError. This could have been designed more consistently. The only irreconcilable difference between these operations is that `string.find` searches for a string of items, where `list.index` searches for exactly one item (which, alone, doesn't justify using different names).
3,848,960
i'm ASP.NET programmer and have no experience in creating windows services. Service i need to create should send emails to our customers each specified period of time. This service should solve issue when hundreds of emails are sent at the same time and block SMTP service on the server while there are many periods of time when SMTP is on idle without sending anything. Idea is to create a service that i will send whole email and address to, inside of the service i will have some type of dataset ( i don't know which one should i use in winforms/winservices) and some basic timer functionality (ie. each 3 seconds get first mail and send it)... Thing is that there are two main types of mails, registration mails which should be main priority and reminder mails (ie. you haven't entered a site for month ) which have low priority. I prefer to create this priority issue with two data sets, when main one is empty less important one sends. Another issue is how do i access this service from asp.net application on the same server? How would you write that in code or at least point me how to, i know there are many explanations on MS website on basic services but as i don't know much about issue i prefer having it explained in here. Thanks for your time.
2010/10/03
[ "https://Stackoverflow.com/questions/3848960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/185824/" ]
I don't know why or maybe is buried in some PEP somewhere, but i do know 2 very basic "find" method for lists, and they are `array.index()` and the `in` operator. You can always make use of these 2 to find your items. (Also, re module, etc)
I think the rationale for not having separate 'find' and 'index' methods is they're not different enough. Both would return the same thing in the case the sought item exists in the list (this is true of the two string methods); they differ in case the sought item is not in the list/string; however you can trivially build either one of find/index from the other. If you're coming from other languages, it may seem bad manners to raise and catch exceptions for a non-error condition that you could easily test for, but in Python, it's often considered more pythonic to shoot first and ask questions later, er, to use exception handling instead of tests like this (example: [Better to 'try' something and catch the exception or test if its possible first to avoid an exception?](https://stackoverflow.com/questions/7604636/better-to-try-something-and-catch-the-exception-or-test-if-its-possible-first)). I don't think it's a good idea to build 'find' out of 'index' and 'in', like ``` if foo in my_list: foo_index = my_list.index(foo) else: foo_index = -1 # or do whatever else you want ``` because both in and index will require an O(n) pass over the list. Better to build 'find' out of 'index' and try/catch, like: ``` try: foo_index = my_list.index(foo) catch ValueError: foo_index = -1 # or do whatever else you want ``` Now, as to why list was built this way (with only index), and string was built the other way (with separate index and find)... I can't say.
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
Hey I had this same problem recently, I tried re-starting adb server but no luck, however when I uninstalled the APK present on my device. Then everything was back to normal. When I tried to run it on a emulator which didn't have application already, it worked perfectly fine. Hope this helps :) Thank You.
When these errors occur: * Message in Run * No communication with Run (stacktraces, System.out ...) * No restart button 1. Install the newest Android Studio version 2. Try on different virtual devices, some of them are glitched
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
For me, it took marking the build as "debuggable" in the application `build.gradle` file. For example: ``` android { //... buildTypes { // ... releaseStaging { debuggable true // <- add this line signingConfig signingConfigs.release applicationIdSuffix ".releaseStaging" versionNameSuffix "-STAGING" matchingFallbacks = ['release'] } } } ``` Remember to remove this before building release APKs though!!!
Hey I had this same problem recently, I tried re-starting adb server but no luck, however when I uninstalled the APK present on my device. Then everything was back to normal. When I tried to run it on a emulator which didn't have application already, it worked perfectly fine. Hope this helps :) Thank You.
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
For me the problem was that I accidentally removed the Launch of the Default Activity in the "Run > Edit Configurations..." option. Just insert the "Default Activity" under "Launch Options" and your application will run again on your device.
I was using debugging over Bluetooth. Giving Location permission to the WearOS app on my phone solved the problem for me. (Bluetooth scan access is restricted in the modern android versions unless fine Location permission is granted)
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
I managed to fix the problem by uninstalling Android studio, deleting all relevant files in the user folder (including gradle cached files) and installing the latest version of Android studio. The problem seems to have been fixed after several months. Note that I am now using Android Studio 4.1.
I tried most of the answers from here and on YouTube. What worked for me is updating my Android studio to the latest version; 4.0.
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
For me the problem was that I accidentally removed the Launch of the Default Activity in the "Run > Edit Configurations..." option. Just insert the "Default Activity" under "Launch Options" and your application will run again on your device.
Hey I had this same problem recently, I tried re-starting adb server but no luck, however when I uninstalled the APK present on my device. Then everything was back to normal. When I tried to run it on a emulator which didn't have application already, it worked perfectly fine. Hope this helps :) Thank You.
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
For me the problem was that I accidentally removed the Launch of the Default Activity in the "Run > Edit Configurations..." option. Just insert the "Default Activity" under "Launch Options" and your application will run again on your device.
When these errors occur: * Message in Run * No communication with Run (stacktraces, System.out ...) * No restart button 1. Install the newest Android Studio version 2. Try on different virtual devices, some of them are glitched
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
Even if I faced the timed out issue in one plus and followed steps that fixed for me. 1. Go to the respective app 2. Hold for 3 sec > App info> permissions> allow for storage>. 3. Next, go to adv settings> battery opt > check "Don't optimize."> 4. Come back and scroll down > display over other apps> enable.... Hope this helps.
In case it can help someone... try one of the following: 1. Make sure device is not connected the same time via data cable and wifi 2.If you are connecting through wifi, try to connect via data cable. 3.Check maybe your device has some component or anything maybe like fingerprint interfering with the connection.
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
There is a bug in the recent Android Studio release. You can revert to previous version or test it from command line.
Everything was working fine for me, when I started getting the error described in this question. So I created and started using a different virtual device for the emulator, and it didn't have the problem.
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
For me, it took marking the build as "debuggable" in the application `build.gradle` file. For example: ``` android { //... buildTypes { // ... releaseStaging { debuggable true // <- add this line signingConfig signingConfigs.release applicationIdSuffix ".releaseStaging" versionNameSuffix "-STAGING" matchingFallbacks = ['release'] } } } ``` Remember to remove this before building release APKs though!!!
When these errors occur: * Message in Run * No communication with Run (stacktraces, System.out ...) * No restart button 1. Install the newest Android Studio version 2. Try on different virtual devices, some of them are glitched
58,245,771
I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following: Launching app on device. Waiting for process to come online... and after some time I see the following: Timed out waiting for process to appear on 'device'... I have attached a screenshot that shows the problem. [![enter image description here](https://i.stack.imgur.com/dXzhJ.jpg)](https://i.stack.imgur.com/dXzhJ.jpg) The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success. Any ideas?
2019/10/05
[ "https://Stackoverflow.com/questions/58245771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501223/" ]
Even if I faced the timed out issue in one plus and followed steps that fixed for me. 1. Go to the respective app 2. Hold for 3 sec > App info> permissions> allow for storage>. 3. Next, go to adv settings> battery opt > check "Don't optimize."> 4. Come back and scroll down > display over other apps> enable.... Hope this helps.
Everything was working fine for me, when I started getting the error described in this question. So I created and started using a different virtual device for the emulator, and it didn't have the problem.
8,234,708
I have a multi-module maven project made up of three sub-modules: **web**, **service** and **domain**. I use m2e and have managed to import the maven projects into Eclipse. What's more, the **service** and **domain** projects are in the **web**'s java build path and the **domain** project is in the **service**'s java build path. It is very strange because compilation errors are displayed which seem to indicate that for instance **service** does not see **domain**. However when I click on a class in error in eclipse, I can navigate to the **domain** class. Furthermore, I can add the **web** project to the Tomcat server instance but the **web** project does not contain the other two projects. Can anyone please help? web pom.xml: ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.bignibou</groupId> <artifactId>bignibou</artifactId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.bignibou</groupId> <artifactId>bignibou-web</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>bignibou-web</name> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.tml</include> <include>**/*.properties</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <!-- <version>2.0.2</version> <configuration> <webResources> <resource> <directory>${basedir}/WebContent</directory> </resource> </webResources> <warSourceDirectory>WebContent</warSourceDirectory> <warSourceExcludes>WebContent/WEB-INF/lib/*.jar</warSourceExcludes> <archiveClasses>false</archiveClasses> </configuration> --> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.bignibou</groupId> <artifactId>bignibou-domain</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.bignibou</groupId> <artifactId>bignibou-service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-core</artifactId> <version>5.2.6</version> </dependency> <dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-beanvalidator</artifactId> <version>5.2.6</version> </dependency> <dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-spring</artifactId> <version>5.2.6</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-test</artifactId> <version>5.2.6</version> <scope>test</scope> <exclusions> <exclusion> <artifactId>testng</artifactId> <groupId>org.testng</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>3.0.5.RELEASE</version> <scope>test</scope> </dependency> <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <version>2.5.2</version> <scope>test</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> <!-- <dependency> <groupId>com.formos.tapestry</groupId> <artifactId>tapestry-testify</artifactId> <version>1.0.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.formos.tapestry</groupId> <artifactId>tapestry-xpath</artifactId> <version>1.0.1</version> <scope>test</scope> </dependency> --> </dependencies> </project> ``` service pom.xml ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.bignibou</groupId> <artifactId>bignibou</artifactId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.bignibou</groupId> <artifactId>bignibou-service</artifactId> <version>1.0-SNAPSHOT</version> <name>bignibou-service</name> <!-- Shared version number properties --> <properties> <org.springframework.version>3.0.5.RELEASE</org.springframework.version> </properties> <dependencies> <!-- Core utilities used by other modules. Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Expression Language (depends on spring-core) Define this if you use Spring Expression APIs (org.springframework.expression.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Bean Factory and JavaBeans utilities (depends on spring-core) Define this if you use Spring Bean APIs (org.springframework.beans.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans) This is the central artifact for Spring's Dependency Injection Container and is generally always defined --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration Define this if you need any of these integrations --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context) Define this if you use Spring Transactions or DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis. (depends on spring-core, spring-beans, spring-context, spring-tx) Define this if you need ORM (org.springframework.orm.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans. (depends on spring-core, spring-beans, spring-context) Define this if you need OXM (org.springframework.oxm.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Web application development utilities applicable to both Servlet and Portlet Environments (depends on spring-core, spring-beans, spring-context) Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Support for testing Spring applications with tools such as JUnit and TestNG This artifact is generally always defined with a 'test' scope for the integration testing framework and unit testing stubs --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${org.springframework.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.3</version> </dependency> <dependency> <groupId>com.bignibou</groupId> <artifactId>bignibou-domain</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.6</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.1</version> </dependency> </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> </resources> </build> </project> ``` domain pom.xlm ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.bignibou</groupId> <artifactId>bignibou</artifactId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.bignibou</groupId> <artifactId>bignibou-domain</artifactId> <version>1.0-SNAPSHOT</version> <name>bignibou-domain</name> <dependencies> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> </dependency> <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> <version>1</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.2.0.Final</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>1.7.1</version> </dependency> <!-- <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.5.3-Final</version> </dependency> --> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>javax.persistence</artifactId> <version>2.0.0</version> </dependency> </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> </resources> </build> <repositories> <repository> <id>eclipselink</id> <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo/</url> </repository> </repositories> </project> ``` super pom.xlm: ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.bignibou</groupId> <artifactId>bignibou</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <name>bignibou super pom</name> <modules> <module>domain</module> <module>service</module> <module>web</module> </modules> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.8</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.5.8</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.3</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> </project> ```
2011/11/22
[ "https://Stackoverflow.com/questions/8234708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536299/" ]
Define domain and service modules inside the dependency management tag in super pom. So basically add following definition inside super pom: ``` <dependencyManagement> <dependencies> <dependency> <groupId>com.bignibou</groupId> <artifactId>bignibou-domain</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.bignibou</groupId> <artifactId>bignibou-service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependencies> </dependencyManagement> ``` After adding these definitions to the super pom, you will also have the chance to remove version numbers for these dependencies from module pom's.
You shouldn't work with eclipses build paths. Add the service and domain to the web pom.xml dependencies. Add the domain to the pom.xml from your service. After you set up the dependencies correctly m2e will configure the build paths correctly for you.
44,205,464
I could not assign `TokenLifetimePolicy` Azure AD application policy from PowerShell. I had an error `BadRequest` : `Message: Open navigation properties are not supported on OpenTypes.Property name: 'policies` I am trying to implement token expiry time from [Configurable token lifetimes in Azure Active Directory](https://learn.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties) See screenshot below, any useful links and solutions on the AzureAD cmdlet `Add-AzureADApplicationPolicy` are welcome [![enter image description here](https://i.stack.imgur.com/DeRNy.png)](https://i.stack.imgur.com/DeRNy.png)
2017/05/26
[ "https://Stackoverflow.com/questions/44205464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1080738/" ]
I made it work by only using `New-AzureADPolicy` cmdlet and setting `-IsOrganizationDefault $true` not `$false`. The effect takes a while for you to see it. So wait for about 30 minutes to an hour (I don't know how long exactly). After that your new policy will be created and applied. Also remember that this is PowerShell, so no whitespaces in the cmdlet. Example: ``` New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"02:00:00","MaxInactiveTime":"02:00:00","MaxAgeSessionSingleFactor":"02:00:00"}}') -DisplayName "PolicyScenario" -IsOrganizationDefault $true -Type "TokenLifetimePolicy" ``` Multi-Line version: ``` New-AzureADPolicy -Definition @( ' { "TokenLifetimePolicy": { "Version": 1, "AccessTokenLifetime": "02:00:00", "MaxInactiveTime": "02:00:00", "MaxAgeSessionSingleFactor": "02:00:00" } } ' ) -DisplayName "PolicyScenario" -IsOrganizationDefault $true -Type "TokenLifetimePolicy" ``` Microsoft may fix the issue with `IsOrganizationDefault $true`. Read more on this in the question: [Azure AD Configurable Token Lifetimes not being Applied](https://stackoverflow.com/questions/41799280/azure-ad-configurable-token-lifetimes-not-being-applied/44231959#44231959).
Was the application created in B2C portal? Assuming the answer is yes, this behavior is expected: Microsoft has 2 authorization end points, V1 and V2. B2C portal creates V2 apps. The token lifetime setting from powershell probably only works against the V1 apps. There are settings on the b2c blade to change this. The other option is to create an app from the azure active directory blade(as opposed to the b2c blade). Then you can set the token life time using powershell.
44,205,464
I could not assign `TokenLifetimePolicy` Azure AD application policy from PowerShell. I had an error `BadRequest` : `Message: Open navigation properties are not supported on OpenTypes.Property name: 'policies` I am trying to implement token expiry time from [Configurable token lifetimes in Azure Active Directory](https://learn.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties) See screenshot below, any useful links and solutions on the AzureAD cmdlet `Add-AzureADApplicationPolicy` are welcome [![enter image description here](https://i.stack.imgur.com/DeRNy.png)](https://i.stack.imgur.com/DeRNy.png)
2017/05/26
[ "https://Stackoverflow.com/questions/44205464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1080738/" ]
I test this quite a bit for my customers. I run into issues like this every now and then due to not on the latest version of PowerShell. ``` get-module ``` Latest Version 2.0.0.114 at the moment for AzureADPreview (V2) [Instructions to download here](https://learn.microsoft.com/en-us/powershell/azure/install-adv2?view=azureadps-2.0) There was an issue with -IsOrganizationDefault $true as Seth has pointed out. Another issue I've found is having multiple versions of PowerShell on your system and it's loading the wrong one that doesn't have the updated bits. I hit this last Friday - I had to wipe everything and reinstall - then it fixed it. Also - There is a difference between: ``` Add-AzureADApplicationPolicy ``` and ``` Add-AzureADServicePrincipalPolicy ``` One is for an application object and the other is for a ServicePrincipal. If you are applying it to say, a SAML-Based application, then you should apply it to the ServicePrincpal. **Note:** There is a different ObjectID for the application object and the servicePrincipal object. Don't get these confused. For an experiment, run the two cmds against your application: ``` Get-AzureADServicePrincipal -SearchString <name of app> Get-AzureADApplication -SearchString <name of app> ``` If you grab the wrong ObjectID - no go when you go to apply the policy The sequence for these Policies are: ServicePrincipal -> Application -> Tenant (organization)
Was the application created in B2C portal? Assuming the answer is yes, this behavior is expected: Microsoft has 2 authorization end points, V1 and V2. B2C portal creates V2 apps. The token lifetime setting from powershell probably only works against the V1 apps. There are settings on the b2c blade to change this. The other option is to create an app from the azure active directory blade(as opposed to the b2c blade). Then you can set the token life time using powershell.
44,205,464
I could not assign `TokenLifetimePolicy` Azure AD application policy from PowerShell. I had an error `BadRequest` : `Message: Open navigation properties are not supported on OpenTypes.Property name: 'policies` I am trying to implement token expiry time from [Configurable token lifetimes in Azure Active Directory](https://learn.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties) See screenshot below, any useful links and solutions on the AzureAD cmdlet `Add-AzureADApplicationPolicy` are welcome [![enter image description here](https://i.stack.imgur.com/DeRNy.png)](https://i.stack.imgur.com/DeRNy.png)
2017/05/26
[ "https://Stackoverflow.com/questions/44205464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1080738/" ]
I made it work by only using `New-AzureADPolicy` cmdlet and setting `-IsOrganizationDefault $true` not `$false`. The effect takes a while for you to see it. So wait for about 30 minutes to an hour (I don't know how long exactly). After that your new policy will be created and applied. Also remember that this is PowerShell, so no whitespaces in the cmdlet. Example: ``` New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"02:00:00","MaxInactiveTime":"02:00:00","MaxAgeSessionSingleFactor":"02:00:00"}}') -DisplayName "PolicyScenario" -IsOrganizationDefault $true -Type "TokenLifetimePolicy" ``` Multi-Line version: ``` New-AzureADPolicy -Definition @( ' { "TokenLifetimePolicy": { "Version": 1, "AccessTokenLifetime": "02:00:00", "MaxInactiveTime": "02:00:00", "MaxAgeSessionSingleFactor": "02:00:00" } } ' ) -DisplayName "PolicyScenario" -IsOrganizationDefault $true -Type "TokenLifetimePolicy" ``` Microsoft may fix the issue with `IsOrganizationDefault $true`. Read more on this in the question: [Azure AD Configurable Token Lifetimes not being Applied](https://stackoverflow.com/questions/41799280/azure-ad-configurable-token-lifetimes-not-being-applied/44231959#44231959).
I test this quite a bit for my customers. I run into issues like this every now and then due to not on the latest version of PowerShell. ``` get-module ``` Latest Version 2.0.0.114 at the moment for AzureADPreview (V2) [Instructions to download here](https://learn.microsoft.com/en-us/powershell/azure/install-adv2?view=azureadps-2.0) There was an issue with -IsOrganizationDefault $true as Seth has pointed out. Another issue I've found is having multiple versions of PowerShell on your system and it's loading the wrong one that doesn't have the updated bits. I hit this last Friday - I had to wipe everything and reinstall - then it fixed it. Also - There is a difference between: ``` Add-AzureADApplicationPolicy ``` and ``` Add-AzureADServicePrincipalPolicy ``` One is for an application object and the other is for a ServicePrincipal. If you are applying it to say, a SAML-Based application, then you should apply it to the ServicePrincpal. **Note:** There is a different ObjectID for the application object and the servicePrincipal object. Don't get these confused. For an experiment, run the two cmds against your application: ``` Get-AzureADServicePrincipal -SearchString <name of app> Get-AzureADApplication -SearchString <name of app> ``` If you grab the wrong ObjectID - no go when you go to apply the policy The sequence for these Policies are: ServicePrincipal -> Application -> Tenant (organization)
291,057
How to install the varnish cache in magento2. I need setup the varnish cache in my system localhost. can anyone please guide me.
2019/09/27
[ "https://magento.stackexchange.com/questions/291057", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/55236/" ]
try this: in vendor/magento/module-customer/view/frontend/web/js/customer-data.js (about line 163) this code was added: ``` if (typeof sectionDataIds == 'string') sectionDataIds = JSON.parse(sectionDataIds); ``` the section looks like this now: ``` /** * @param {Object} sections */ update: function (sections) { var sectionId = 0, sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; // THIS LINE WAS ADDED <------><------>if (typeof sectionDataIds == 'string') sectionDataIds = JSON.parse(sectionDataIds);<-- _.each(sections, function (sectionData, sectionName) { sectionId = sectionData['data_id']; sectionDataIds[sectionName] = sectionId; storage.set(sectionName, sectionData); storageInvalidation.remove(sectionName); buffer.notify(sectionName, sectionData); }); $.cookieStorage.set('section_data_ids', sectionDataIds); }, ```
Did you find a solution for this problem? i'm facing the same problem with magento 2.2.8 Thank you,
291,057
How to install the varnish cache in magento2. I need setup the varnish cache in my system localhost. can anyone please guide me.
2019/09/27
[ "https://magento.stackexchange.com/questions/291057", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/55236/" ]
I had similar problems with Magento 2.4. So I applied quality patch. More about here: [magento quality patches](https://devdocs.magento.com/guides/v2.4/comp-mgr/patching/mqp.html) In my case I applied MC-41359. Open terminal (root folder) and type: $ ./vendor/bin/magento-patches apply MC-41359, then run rm -rf var/di/\* generated/\* var/cache/\* var/page\_cache/\* var/view\_preprocessed/\* pub/static/\* php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento c:f php bin/magento c:c You can also check status of patches by typing: $./vendor/bin/magento-patches status
Did you find a solution for this problem? i'm facing the same problem with magento 2.2.8 Thank you,
291,057
How to install the varnish cache in magento2. I need setup the varnish cache in my system localhost. can anyone please guide me.
2019/09/27
[ "https://magento.stackexchange.com/questions/291057", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/55236/" ]
try this: in vendor/magento/module-customer/view/frontend/web/js/customer-data.js (about line 163) this code was added: ``` if (typeof sectionDataIds == 'string') sectionDataIds = JSON.parse(sectionDataIds); ``` the section looks like this now: ``` /** * @param {Object} sections */ update: function (sections) { var sectionId = 0, sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; // THIS LINE WAS ADDED <------><------>if (typeof sectionDataIds == 'string') sectionDataIds = JSON.parse(sectionDataIds);<-- _.each(sections, function (sectionData, sectionName) { sectionId = sectionData['data_id']; sectionDataIds[sectionName] = sectionId; storage.set(sectionName, sectionData); storageInvalidation.remove(sectionName); buffer.notify(sectionName, sectionData); }); $.cookieStorage.set('section_data_ids', sectionDataIds); }, ```
I had similar problems with Magento 2.4. So I applied quality patch. More about here: [magento quality patches](https://devdocs.magento.com/guides/v2.4/comp-mgr/patching/mqp.html) In my case I applied MC-41359. Open terminal (root folder) and type: $ ./vendor/bin/magento-patches apply MC-41359, then run rm -rf var/di/\* generated/\* var/cache/\* var/page\_cache/\* var/view\_preprocessed/\* pub/static/\* php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento c:f php bin/magento c:c You can also check status of patches by typing: $./vendor/bin/magento-patches status
33,678,543
I have two numpy arrays, A and B. A conatains unique values and B is a sub-array of A. Now I am looking for a way to get the index of B's values within A. For example: ``` A = np.array([1,2,3,4,5,6,7,8,9,10]) B = np.array([1,7,10]) # I need a function fun() that: fun(A,B) >> 0,6,9 ```
2015/11/12
[ "https://Stackoverflow.com/questions/33678543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4759209/" ]
You can use [`np.in1d`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.in1d.html) with [`np.nonzero`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html) - ``` np.nonzero(np.in1d(A,B))[0] ``` You can also use [`np.searchsorted`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.searchsorted.html), if you care about maintaining the order - ``` np.searchsorted(A,B) ``` For a generic case, when `A` & `B` are unsorted arrays, you can bring in the `sorter` option in `np.searchsorted`, like so - ``` sort_idx = A.argsort() out = sort_idx[np.searchsorted(A,B,sorter = sort_idx)] ``` I would add in my favorite [`broadcasting`](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) too in the mix to solve a generic case - ``` np.nonzero(B[:,None] == A)[1] ``` Sample run - ``` In [125]: A Out[125]: array([ 7, 5, 1, 6, 10, 9, 8]) In [126]: B Out[126]: array([ 1, 10, 7]) In [127]: sort_idx = A.argsort() In [128]: sort_idx[np.searchsorted(A,B,sorter = sort_idx)] Out[128]: array([2, 4, 0]) In [129]: np.nonzero(B[:,None] == A)[1] Out[129]: array([2, 4, 0]) ```
Have you tried `searchsorted`? ``` A = np.array([1,2,3,4,5,6,7,8,9,10]) B = np.array([1,7,10]) A.searchsorted(B) # array([0, 6, 9]) ```
33,678,543
I have two numpy arrays, A and B. A conatains unique values and B is a sub-array of A. Now I am looking for a way to get the index of B's values within A. For example: ``` A = np.array([1,2,3,4,5,6,7,8,9,10]) B = np.array([1,7,10]) # I need a function fun() that: fun(A,B) >> 0,6,9 ```
2015/11/12
[ "https://Stackoverflow.com/questions/33678543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4759209/" ]
You can use [`np.in1d`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.in1d.html) with [`np.nonzero`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html) - ``` np.nonzero(np.in1d(A,B))[0] ``` You can also use [`np.searchsorted`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.searchsorted.html), if you care about maintaining the order - ``` np.searchsorted(A,B) ``` For a generic case, when `A` & `B` are unsorted arrays, you can bring in the `sorter` option in `np.searchsorted`, like so - ``` sort_idx = A.argsort() out = sort_idx[np.searchsorted(A,B,sorter = sort_idx)] ``` I would add in my favorite [`broadcasting`](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) too in the mix to solve a generic case - ``` np.nonzero(B[:,None] == A)[1] ``` Sample run - ``` In [125]: A Out[125]: array([ 7, 5, 1, 6, 10, 9, 8]) In [126]: B Out[126]: array([ 1, 10, 7]) In [127]: sort_idx = A.argsort() In [128]: sort_idx[np.searchsorted(A,B,sorter = sort_idx)] Out[128]: array([2, 4, 0]) In [129]: np.nonzero(B[:,None] == A)[1] Out[129]: array([2, 4, 0]) ```
Just for completeness: If the values in `A` are non negative and reasonably small: ``` lookup = np.empty((np.max(A) + 1), dtype=int) lookup[A] = np.arange(len(A)) indices = lookup[B] ```
33,678,543
I have two numpy arrays, A and B. A conatains unique values and B is a sub-array of A. Now I am looking for a way to get the index of B's values within A. For example: ``` A = np.array([1,2,3,4,5,6,7,8,9,10]) B = np.array([1,7,10]) # I need a function fun() that: fun(A,B) >> 0,6,9 ```
2015/11/12
[ "https://Stackoverflow.com/questions/33678543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4759209/" ]
Have you tried `searchsorted`? ``` A = np.array([1,2,3,4,5,6,7,8,9,10]) B = np.array([1,7,10]) A.searchsorted(B) # array([0, 6, 9]) ```
Just for completeness: If the values in `A` are non negative and reasonably small: ``` lookup = np.empty((np.max(A) + 1), dtype=int) lookup[A] = np.arange(len(A)) indices = lookup[B] ```
20,070,186
I'm using this code to check if a user is granted in my Symfony application : ``` $securityContext = $this->container->get('security.context'); if($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') ){ $user = $this->get('security.context')->getToken()->getUser()->getId(); } else { return $this->render('IelCategoryBundle:Category:home.html.twig'); } ``` I have to ckeck this in almost every CRUD action that I'm writing (edit, delete, ...). I feel not DRY at all (no play on words ;-)). Is there a better way to check this in many actions ?
2013/11/19
[ "https://Stackoverflow.com/questions/20070186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
[JMSSecurityExtraBundle](https://packagist.org/packages/jms/security-extra-bundle) provides the [@Secure](http://jmsyst.com/bundles/JMSSecurityExtraBundle/1.2/annotations#secure) annotation which eases checking for a certain user-role before invoking a controller/service method. ``` use JMS\SecurityExtraBundle\Annotation as SecurityExtra; /** @SecurityExtra\Secure(roles="IS_AUTHENTICATED_REMEMBERED") */ public function yourAction() { // ... } ```
Your best bet would be to rely on `Kernel` event listeners: <http://symfony.com/doc/current/cookbook/service_container/event_listener.html>. Implement your listener as a service and then you could set `$this->user` to desired value if `isGranted` results `TRUE`. Later on, you could easily retrieve the value within the controller using: ``` $myServiceListener->getUser(); ``` On the other hand, if check fails you could easily redirect user to your `home.html.twig`.
211,885
I have this breadboard: [![enter image description here](https://i.stack.imgur.com/Kevaa.jpg)](https://i.stack.imgur.com/Kevaa.jpg) And I need my Integrated Circuit to be connected exactly like this (Don't pay any attention to the wires. Let's focus on the IC in the middle of the breadboard itself): [![enter image description here](https://i.stack.imgur.com/XcH4K.jpg)](https://i.stack.imgur.com/XcH4K.jpg) However, when I connected the power, it didn't work. Then I found out that the IC was pushed up from the breadboard. I tried to push it down and it worked, but when I released my fingers, it stopped working again. **That was like the legs of the IC was not long enough to be buried deeply into the breadboard. I had problems with not only the IC but the pushbutton as well.** Did anybody face that kind of problem like me? Please show me the trick to bury the components deeper in the middle of the breadboard. Thank you.
2016/01/17
[ "https://electronics.stackexchange.com/questions/211885", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/97402/" ]
Normally, these breadboards are built exactly for what you're trying to do. And normally, it works, because there aren't many different lengths of pins on ICs. If more force doesn't help (i.e. your IC just can't be pushed in further), I'm afraid all you could try is use a IC socket; but to be honest, that would sound like a lot of trouble considering the job of holding and connecting your IC is exactly what you use your breadboard for. Considering that you had problems with a button, too, I'd say that stranger things have happened than breadboards with varying build quality :(
One of my breadboards acts this way. I hated it and decided to sacrifice it to make [This Breadboard Video](https://www.youtube.com/watch?v=ME2wgVFYgIs). Also, YES: longer leaded parts will fit into that breadboard. But you shouldn't need to purchase specific ICs to fit into a breadboard. You just need a better breadboard. Spend eight bucks and get a new one. Most breadboards don't exhibit the bad behavior you describe. Cheers!
211,885
I have this breadboard: [![enter image description here](https://i.stack.imgur.com/Kevaa.jpg)](https://i.stack.imgur.com/Kevaa.jpg) And I need my Integrated Circuit to be connected exactly like this (Don't pay any attention to the wires. Let's focus on the IC in the middle of the breadboard itself): [![enter image description here](https://i.stack.imgur.com/XcH4K.jpg)](https://i.stack.imgur.com/XcH4K.jpg) However, when I connected the power, it didn't work. Then I found out that the IC was pushed up from the breadboard. I tried to push it down and it worked, but when I released my fingers, it stopped working again. **That was like the legs of the IC was not long enough to be buried deeply into the breadboard. I had problems with not only the IC but the pushbutton as well.** Did anybody face that kind of problem like me? Please show me the trick to bury the components deeper in the middle of the breadboard. Thank you.
2016/01/17
[ "https://electronics.stackexchange.com/questions/211885", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/97402/" ]
If this is a brand new breadboard, it is possible that the contact tines (the contacts within the breadboard sockets) have a nominal opening that is *smaller* than the size of the IC pins; this will 'push' the IC back out of the breadboard sockets. I have seen this (admittedly many years ago), and a piece of non-stranded wire judiciously used can open the contact a bit so the breadboard will not push the IC back out. Be careful so as not to actually damage the contact; just open it up a bit.
One of my breadboards acts this way. I hated it and decided to sacrifice it to make [This Breadboard Video](https://www.youtube.com/watch?v=ME2wgVFYgIs). Also, YES: longer leaded parts will fit into that breadboard. But you shouldn't need to purchase specific ICs to fit into a breadboard. You just need a better breadboard. Spend eight bucks and get a new one. Most breadboards don't exhibit the bad behavior you describe. Cheers!
26,196,609
I want to use the R chunk code output as the Chapter Name but could not figured out how to do this. Below is my minimum working example. ``` \documentclass{book} \usepackage[T1]{fontenc} \begin{document} \chapter{cat( << label=Test1, echo=FALSE, results="asis">>= 2+1 @ ) } Chapter name is the output of R chunk Code. \end{document} ```
2014/10/04
[ "https://Stackoverflow.com/questions/26196609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/707145/" ]
This works for me ``` << label=Test1, echo=FALSE>>= cn <- 2+1 @ \chapter*{Chapter \Sexpr{cn}} ```
In RMarkdown you can use the following code ``` # `r I(1+2)` ```
43,247,138
I have basically 2 forms in one page. First one is for login and second one is for insert data. Second form action is working fine. i can insert data with it. But same form I'm using for login user but it's not working. On click submit button nothing happens just page refresh. please see my code and help me to solve my first form's action issue. ``` <div class="login_wrapper"> <div id="login" class="animate form login_form"> <section class="login_content"> <form action="login.php" method="post"> <h1>Login Form</h1> <div> <input type="text" class="form-control" placeholder="Username" required="" name="username" /> </div> <div> <input type="password" class="form-control" placeholder="Password" required="" name="password" /> </div> <div> <input type="submit" class="btn btn-default" name="insert" value="Sign In"> <a class="reset_pass" href="#forgetpass">Lost your password?</a> </div> <div class="clearfix"></div> <div class="separator"> <p class="change_link">New to site? <a href="#signup" class="to_register"> Create Account </a> </p> <div class="clearfix"></div> <br /> <div> <h1><i class="fa fa-paw"></i> DiGItal Society</h1> <p>©2016 All Rights Reserved. DiGItal Society is a Web Portal for E-Society. Privacy and Terms</p> </div> </div> </form> </section> </div> <div id="register" class="animate form registration_form"> <section class="login_content"> <form action="insertUser.php" method="post"> <h1>Create Account</h1> <div> <input type="text" class="form-control" placeholder="Username" required="" name="username" /> </div> <div> <input type="email" class="form-control" placeholder="Email" required="" name="email" /> </div> <div> <input type="password" class="form-control" placeholder="Password" required="" name="password" /> </div> <div> <input type="hidden" name="roleid" value=""> <input type="submit" class="btn btn-default" name="insert" value="Log In"> </div> <div class="clearfix"></div> <div class="separator"> <p class="change_link">Already a member ? <a href="#signin" class="to_register"> Log in </a> </p> <div class="clearfix"></div> <br /> <div> <h1><i class="fa fa-paw"></i> DiGItal Society</h1> <p>©2016 All Rights Reserved. DiGItal Society is a Web Portal for E-Society. Privacy and Terms</p> </div> </div> </form> </section> </div> </div> ``` I have also add my action pages.(not working). `login.php` for first form(not working) ``` <?php include 'db.php'; if (isset($_REQUEST['insert'])) { echo $username = $_REQUEST['username']; echo $password = $_REQUEST['password']; $sql = mysqli_query($conn,"SELECT * FROM `accountants` where `acc_email` = '$username' AND `acc_pass` = '$password'"); $data = mysqli_fetch_array($conn,$sql); $_SESSION['role']=$data['roleId']; $_SESSION['username']=$data['acc_name']; $data = mysqli_num_rows($data); if ($data>0) { header('Location: home.php'); } else { header('Location: index.php'); echo 'incorrect login'; } } ?> ``` and `insertUser.php` for second form.(working) ``` <?php include 'db.php'; if (isset($_REQUEST['insert'])) { $acc_name = $_REQUEST['username']; $acc_email = $_REQUEST['email']; $acc_pass = $_REQUEST['password']; $role_id = $_REQUEST['roleid']; $sql = mysqli_query($conn,"INSERT INTO `accountants`(`acc_name`, `acc_email`, `acc_pass`, `roleId`) VALUES ('".$acc_name."','".$acc_email."','".$acc_pass."','2')"); if ($sql>0) { header('Location: home.php'); echo 'data added successfully'; } $row = mysqli_query('SELECT * FROM `accountants`'); $data = mysqli_fetch_array($row); $data = mysqli_num_rows($conn,$data); $_SESSION['role'] = $data['roleId']; } ?> ```
2017/04/06
[ "https://Stackoverflow.com/questions/43247138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7824786/" ]
I assume you are talking about asp.net core. VS2015 and VS2017 are different. VS2015 uses project.json while VS2017 uses \*.csproj But you can convert it: <https://learn.microsoft.com/en-au/dotnet/articles/core/tools/project-json-to-csproj> And for myself, I just recreated in VS2017: <https://github.com/Longfld/ASPNETCoreAngular4>
I found solution. I need to update Tool preview for visual studio 2015. Here is what I wrote in detail <https://asiftech.wordpress.com/2017/04/06/package-restore-failed-in-visual-studio-2015-after-visual-studio-2017-installation/>
29,519,693
I need your help in grammatically expanding a Jquery's Collapsable div I have tried with number of options This is my fiddle <http://jsfiddle.net/jWaEv/20/> I have tried as following ``` <div data-role="content" class="data"> <div class="my-collaspible" id="first" data-inset="false" data-role="collapsible"> <h3>Header 1</h3> <p>Content</p> <p>Content</p> </div> <div class="my-collaspible" id="second" data-inset="false" data-role="collapsible"> <h3>Header 2</h3> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> </div> $(document).ready(function() { var id = 'first'; $("#" + id).trigger('expand').collapsible("refresh"); }); ``` Could you please let me know how to do this ??
2015/04/08
[ "https://Stackoverflow.com/questions/29519693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can use this: <http://jsfiddle.net/jWaEv/37/> ``` <div data-role="collapsible-set"> <div id="first" data-role="collapsible"> <h3>Header 1</h3> <p>Content</p> <p>Content</p> </div> <div id="second" data-role="collapsible"> <h3>Header 2</h3> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> </div> <input type="button" value="Test" id="btn1" /> ``` and JS: ``` $(document).ready(function() { $("#first").collapsible('expand'); //test $('#btn1').click(function(){ $("#first").collapsible('collapse'); }); }); ```
Use following option : **[`collapsible`](https://api.jquerymobile.com/collapsible/#option-collapsed)**, ``` $("#" + id).collapsible( "option", "collapsed", false ); ``` **[Updated Fiddle](http://jsfiddle.net/jWaEv/22/)**
29,519,693
I need your help in grammatically expanding a Jquery's Collapsable div I have tried with number of options This is my fiddle <http://jsfiddle.net/jWaEv/20/> I have tried as following ``` <div data-role="content" class="data"> <div class="my-collaspible" id="first" data-inset="false" data-role="collapsible"> <h3>Header 1</h3> <p>Content</p> <p>Content</p> </div> <div class="my-collaspible" id="second" data-inset="false" data-role="collapsible"> <h3>Header 2</h3> <p>Content</p> <p>Content</p> <p>Content</p> <p>Content</p> </div> </div> $(document).ready(function() { var id = 'first'; $("#" + id).trigger('expand').collapsible("refresh"); }); ``` Could you please let me know how to do this ??
2015/04/08
[ "https://Stackoverflow.com/questions/29519693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`("#myCollapsible").collapsible("expand");` This worked for me when using jQuery 1.11.1 and JQM 1.4.5
Use following option : **[`collapsible`](https://api.jquerymobile.com/collapsible/#option-collapsed)**, ``` $("#" + id).collapsible( "option", "collapsed", false ); ``` **[Updated Fiddle](http://jsfiddle.net/jWaEv/22/)**
2,608,763
While debugging slow startup of an Eclipse RCP app on a Citrix server, I came to find out that java.io.createTempFile(String,String,File) is taking 5 seconds. It does this only on the first execution and only for certain user accounts. Specifically, I am noticing it Citrix anonymous user accounts. I have not tried many other types of accounts, but this behavior is not exhibited with an administrator account. Also, it does not matter if the user has access to write to the given directory or not. If the user does not have access, the call will take 5 seconds to fail. If they do have access, the call with take 5 seconds to succeed. This is on a Windows 2003 Server. I've tried Sun's 1.6.0\_16 and 1.6.0\_19 JREs and see the same behavior. I googled a bit expecting this to be some sort of known issue, but didn't find anything. It seems like someone else would have had to have run into this before. The Eclipse Platform uses File.createTempFile() to test various directories to see if they are writeable during initialization and this issue adds 5 seconds to the startup time of our application. I imagine somebody has run into this before and might have some insight. Here is sample code I executed to see that it is indeed this call that is consuming the time. I also tried it with a second call to createTempFile and notice that subsequent calls return nearly instantaneously. ``` public static void main(final String[] args) throws IOException { final File directory = new File(args[0]); final long startTime = System.currentTimeMillis(); File file = null; try { file = File.createTempFile("prefix", "suffix", directory); System.out.println(file.getAbsolutePath()); } finally { System.out.println(System.currentTimeMillis() - startTime); if (file != null) { file.delete(); } } } ``` Sample output of this program is the following: ``` C:\>java.exe -jar filetest.jar C:/Temp C:\Temp\prefix8098550723198856667suffix 5093 ```
2010/04/09
[ "https://Stackoverflow.com/questions/2608763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/312944/" ]
It might be the intialisation of the secure random number generator which is causing the problem. In particular if a secure random seed is not obtainable from the operating system, then the fall-back mechanism attempts to gain entropy. IIRC, one of the things it does is to list temporary files, so if you have a large number of those that will not help start-up performance.
I'm not a Citrix expert, but I know someone who is, and who conjectures: The accounts may be set up so that application reads/writes are redirected to non-local resources. The latency you're experiencing may be related to the initialization or performance of that resolution. Another possibility is that the application isolation may be in effect, which means file reads/writes happen on virtualized versions of resources.