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
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
Implement a function name() in each subclass.
Without using special tricks to give your base class information about derived types, there is no way for it to know what subtype an instance is. The simplest way to do this is, as @Joachim Wuttke suggests, to create a virtual function forcing derived classes to implement a name() method. However, if you want to get a...
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
Since the list can contain any type of animal I am going to assume that it is a list of pointers. [In such case typeid will consider the most derived type of the object if you pass it the dereferenced pointer.](http://www.cplusplus.com/reference/typeinfo/type_info/) ``` typeid(*animal).name(); ``` Is what you are lo...
Implement a function name() in each subclass.
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
You almost certainly don't want to know. What you should do is declare as virtual appropriate methods to interact with these animals. If you need to operate on them specifically, you can either use the visitor pattern to pass a visitor object or function the right data in each concrete class. If you insist on having t...
Needing to know a specific concrete object type is typically a design smell in C++ so I'm going to suggest that you don't attempt to do this. Instead, create an abstract (pure virtual) interface within `Animal` that describes the functionality you want your animals to have. Then you can utilize dynamic dispatch to cal...
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
Needing to know a specific concrete object type is typically a design smell in C++ so I'm going to suggest that you don't attempt to do this. Instead, create an abstract (pure virtual) interface within `Animal` that describes the functionality you want your animals to have. Then you can utilize dynamic dispatch to cal...
Implement a function name() in each subclass.
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
Depending on the concrete code `typeid` returns different things. Additionally `name()` can return anything (including making the first letter uppercase or removing \*), it is only for debuging. Now I have a few different posible answers what `typeid(animal).name()` can return. Version 1 `animal` is a class name: ```...
Without using special tricks to give your base class information about derived types, there is no way for it to know what subtype an instance is. The simplest way to do this is, as @Joachim Wuttke suggests, to create a virtual function forcing derived classes to implement a name() method. However, if you want to get a...
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
Needing to know a specific concrete object type is typically a design smell in C++ so I'm going to suggest that you don't attempt to do this. Instead, create an abstract (pure virtual) interface within `Animal` that describes the functionality you want your animals to have. Then you can utilize dynamic dispatch to cal...
Without using special tricks to give your base class information about derived types, there is no way for it to know what subtype an instance is. The simplest way to do this is, as @Joachim Wuttke suggests, to create a virtual function forcing derived classes to implement a name() method. However, if you want to get a...
17,678,913
I haven't done C++ in at least 7 years and am suddenly knee deep in a C++ project. I would like some guidance with the following: I have a class called Animal, and I have 3 classes that inherit from Animal: Cat, Dog and Bird. I have created a list object and am using it to store type Animal. This list can contain Cat...
2013/07/16
[ "https://Stackoverflow.com/questions/17678913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030185/" ]
``` Dog* dog = dynamic_cast<Dog*>(myAnimalPointer); if (dog == NULL) { // This animal is not a dog. } ```
Without using special tricks to give your base class information about derived types, there is no way for it to know what subtype an instance is. The simplest way to do this is, as @Joachim Wuttke suggests, to create a virtual function forcing derived classes to implement a name() method. However, if you want to get a...
70,130,615
This is a part of my code: ``` a <- data.frame(X1 = c(9, 9, 9, 8, 9, 9, 8, 9, 8, 7), X2 = c(8, 8, 6, 8, 6, 8, 9, 8, 8, 8), X3= c(-3, -3, -3, -3, -3, -3, -2, -1, -3, -3), X4= c(-5, -7, -5, -7, -7, -7, -7, -7, -7, -5), X5= c(1, 1, -1, 1, 1, 1, 1...
2021/11/26
[ "https://Stackoverflow.com/questions/70130615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17205925/" ]
You can match the `p.` before the capture group and capture the numbers. You don't have to escape the parenthesis in the character class, so you can remove `\)` and leave just `)` ``` \(p\.\s*([^)]+)\) ``` See a [regex demo](https://regex101.com/r/BeYtJ9/1). ```js const regex = /\(p\.\s*([^)]+)\)/g; [ "Author Nam...
I'd capture digits (you need `(p.s.)`?), case-insensitive (what about `(P.12)`?): ```js /\(p\.\s*(\d+)\)/ig ``` **Code** ```js const regex = /\(p\.\s*(\d+)\)/gi const string = "Author Name, (p. 123). (2019). Company." console.log(string.match(regex).map(x => x.replace(/\D+/g, ''))) ``` **EXPLANATION** ```js NODE ...
230,147
I'm trying to deploy an embedded system (NISE 110 by Nexcom) based on the Intel EP80579 (Tolapai) chip. Tolapai apparently integrates controllers for Ethernet etc. on a single chip ([Intel homepage](http://intel.com/go/soc)). The machine can't get a network connection. Diagnosis as far as I could manage: **Drivers** ...
2011/02/02
[ "https://serverfault.com/questions/230147", "https://serverfault.com", "https://serverfault.com/users/200/" ]
Ouch. This is what the Nexcom support said: > > The NISE 110 uses dual Marvell GbE LAN ports, you will need to use the driver for these chips instead of the EP80579 driver. > > > So I had set up ethernet controllers (integrated in the Tolapai) that aren't wired to anything. I'm very sorry, guys. Confusion conti...
does `ethtool ethN` report `Link detected: yes`? Which driver are you using? I recall that for some Intel NICs, there are two possible drivers (e1000 vs e1000e), one of which does not work (well) for some chips.
230,147
I'm trying to deploy an embedded system (NISE 110 by Nexcom) based on the Intel EP80579 (Tolapai) chip. Tolapai apparently integrates controllers for Ethernet etc. on a single chip ([Intel homepage](http://intel.com/go/soc)). The machine can't get a network connection. Diagnosis as far as I could manage: **Drivers** ...
2011/02/02
[ "https://serverfault.com/questions/230147", "https://serverfault.com", "https://serverfault.com/users/200/" ]
Ouch. This is what the Nexcom support said: > > The NISE 110 uses dual Marvell GbE LAN ports, you will need to use the driver for these chips instead of the EP80579 driver. > > > So I had set up ethernet controllers (integrated in the Tolapai) that aren't wired to anything. I'm very sorry, guys. Confusion conti...
I would attempt to install [OpenWrt 12.09](https://downloads.openwrt.org/attitude_adjustment/12.09/x86/ep80579/) on the device and attempt the experiment again. In the past I have made the iegbe drivers from openwrt work on in Redhat 6.4. One gotcha that I ran in to was that the PHY's were being matched to the incorr...
8,067
I was recently graced with a new job opportunity in a large higher ed NE department. This is my first job working with a large network of several thousand users. Throughout my education, I followed the idea that **static IP's are useful from time to time in certain applications and historically used more in smaller ...
2014/05/24
[ "https://networkengineering.stackexchange.com/questions/8067", "https://networkengineering.stackexchange.com", "https://networkengineering.stackexchange.com/users/5785/" ]
I’ll keep this post about your situation specifically. First and foremost, managing over 3,000 devices with static IP addresses is just plain foolish. DHCP is a well-known and established protocol that solves the tedious task of manually assigning and fixing manual IP addresses. If they are that concerned about making...
The answer to your question is mostly opinion, which is frowned upon on this forum. But I'm willing to bet real money that the majority of people here will agree with me. I suppose that for some people, spending lots of time with Excel spreadsheets, keeping track of multiple spreadsheet versions, and the intellectual ...
8,067
I was recently graced with a new job opportunity in a large higher ed NE department. This is my first job working with a large network of several thousand users. Throughout my education, I followed the idea that **static IP's are useful from time to time in certain applications and historically used more in smaller ...
2014/05/24
[ "https://networkengineering.stackexchange.com/questions/8067", "https://networkengineering.stackexchange.com", "https://networkengineering.stackexchange.com/users/5785/" ]
I suppose it boils down to what you mean by *networking devices*. Routers, switches, firewalls, access points, etc., etc. do need to have fixed, known locations. It's a bad idea to rely on DHCP and DNS -- even where "sticky" addresses are used. One network fault is all it takes to learn how bad an idea that is... say ...
The answer to your question is mostly opinion, which is frowned upon on this forum. But I'm willing to bet real money that the majority of people here will agree with me. I suppose that for some people, spending lots of time with Excel spreadsheets, keeping track of multiple spreadsheet versions, and the intellectual ...
8,067
I was recently graced with a new job opportunity in a large higher ed NE department. This is my first job working with a large network of several thousand users. Throughout my education, I followed the idea that **static IP's are useful from time to time in certain applications and historically used more in smaller ...
2014/05/24
[ "https://networkengineering.stackexchange.com/questions/8067", "https://networkengineering.stackexchange.com", "https://networkengineering.stackexchange.com/users/5785/" ]
I’ll keep this post about your situation specifically. First and foremost, managing over 3,000 devices with static IP addresses is just plain foolish. DHCP is a well-known and established protocol that solves the tedious task of manually assigning and fixing manual IP addresses. If they are that concerned about making...
I suppose it boils down to what you mean by *networking devices*. Routers, switches, firewalls, access points, etc., etc. do need to have fixed, known locations. It's a bad idea to rely on DHCP and DNS -- even where "sticky" addresses are used. One network fault is all it takes to learn how bad an idea that is... say ...
78,220
What is the meaning of "Raven" [phonetic] heard in use at Reagan National Airport? Most recently heard: The ATC will say "proceed direct raven" or "direct raven maintain" whatever altitude; or "direct raven; raven at 6,000." I've looked in every ATC/Pilot glossary I can find, but nothing. Have not heard at other airpor...
2020/05/18
[ "https://aviation.stackexchange.com/questions/78220", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/49644/" ]
RAVNN (Pronounced Raven) is the name of a waypoint in Maryland. From the [FAA Fixes / Waypoints directory](https://www.faa.gov/air_traffic/flight_info/aeronav/aero_data/Loc_ID_Search/Fixes_Waypoints/) > > RAVNN MARYLAND BAL\*C\*174.00/22.98 OTT\*C\*070.89/12.17 > ENO\*C\*250.66/53.40 DCA\*D\*106.56 38-48-15.9900N 07...
RAVNN is a waypoint on the RAVNN6 STAR ([page 1](http://aeronav.faa.gov/d-tpp/2005/00804RAVNN.PDF), [page 2](http://aeronav.faa.gov/d-tpp/2005/00804RAVNN.PDF)) for KBWI and surrounding airports, which is handled by Potomac Approach.
78,220
What is the meaning of "Raven" [phonetic] heard in use at Reagan National Airport? Most recently heard: The ATC will say "proceed direct raven" or "direct raven maintain" whatever altitude; or "direct raven; raven at 6,000." I've looked in every ATC/Pilot glossary I can find, but nothing. Have not heard at other airpor...
2020/05/18
[ "https://aviation.stackexchange.com/questions/78220", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/49644/" ]
RAVNN (Pronounced Raven) is the name of a waypoint in Maryland. From the [FAA Fixes / Waypoints directory](https://www.faa.gov/air_traffic/flight_info/aeronav/aero_data/Loc_ID_Search/Fixes_Waypoints/) > > RAVNN MARYLAND BAL\*C\*174.00/22.98 OTT\*C\*070.89/12.17 > ENO\*C\*250.66/53.40 DCA\*D\*106.56 38-48-15.9900N 07...
Generally, the idea is that a *waypoint* has a five letter or six letter code that is * unique (within the region) * easy to remember * easy to pronounce as a word * hard to confuse In this case, the code of the waypoint is RAVNN, but it is pronounced "raven", because that is much faster to say, much easier to rememb...
78,220
What is the meaning of "Raven" [phonetic] heard in use at Reagan National Airport? Most recently heard: The ATC will say "proceed direct raven" or "direct raven maintain" whatever altitude; or "direct raven; raven at 6,000." I've looked in every ATC/Pilot glossary I can find, but nothing. Have not heard at other airpor...
2020/05/18
[ "https://aviation.stackexchange.com/questions/78220", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/49644/" ]
RAVNN is a waypoint on the RAVNN6 STAR ([page 1](http://aeronav.faa.gov/d-tpp/2005/00804RAVNN.PDF), [page 2](http://aeronav.faa.gov/d-tpp/2005/00804RAVNN.PDF)) for KBWI and surrounding airports, which is handled by Potomac Approach.
Generally, the idea is that a *waypoint* has a five letter or six letter code that is * unique (within the region) * easy to remember * easy to pronounce as a word * hard to confuse In this case, the code of the waypoint is RAVNN, but it is pronounced "raven", because that is much faster to say, much easier to rememb...
60,027,701
I am entirely new to WPF and the implementation of MVVM Pattern, therefore excuse me if what I did so far can be seen close to blasphemy in certain people's eyes. My (partial) goal as it follows: 1. Open main window which contains two Comboboxes labeled System and Documents 2. Upon loading this window I connect to an...
2020/02/02
[ "https://Stackoverflow.com/questions/60027701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11080136/" ]
You can simply define the shape property on the `FlatButton` using `Border()`. ``` FlatButton( height: 50, child: Text('All Posts'), shape: Border( bottom: BorderSide(color: Colors.black, width: 3) ), onPressed: (){ print('You selected all posts'); }, ), ```
Fixed it. I changed it to a flatbutton and wrapped the widget in a Material() This allowed me to create a bottom BorderSide, setting it to my color preferences: ``` bool changeColor = false; Material( shape: Border( bottom: BorderSide( color: changeColor ? Colors.teal : Colors.transparent, wid...
64,989,610
So this question is to let the user enter the product id, the name, how much in stock and how much is bought from the store. Everything in the code works just fine but when I enter the letters for the name, only the first letter shows up. ``` import java.util.Scanner; public class ProductStock { public static void...
2020/11/24
[ "https://Stackoverflow.com/questions/64989610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14649275/" ]
A `char` in Java represents a single *character*. To have a sequence of characters, you should use a [`String`](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html). With using `charAt(0)` in your snippet, you only take the first character of the name you input, but you want to keep the whole String. By cal...
in code `char name` was storing only the first character and because of `char` which can only store one character and print that one, so you have to use `String` for storing and displaying a complete text. ``` Scanner sc = new Scanner(System.in); int id = sc.nextInt(); String name = sc.next(); int stock = sc.nextInt(...
479,324
I am facing a weird problem. My computer hangs while loading the desktop, and only the background shows up; no icons or bars load. If I power the system on and off about 4-6 times, I may be able to use it normally. The desktop loads normally after rebooting or in safe mode; this only occurs when I start the system nor...
2012/09/25
[ "https://superuser.com/questions/479324", "https://superuser.com", "https://superuser.com/users/161281/" ]
It's good you cleared out your start up items, but there is another way to start items with your PC - Next time you load up Windows successfully, go to your task scheduler - Look through and there is probably something starting up as your PC does (I had an Asus service trying to start and it caused error messages on ea...
Why don't you test a linux live on your system to see if its a really hardware issue or OS's.... If it will appear your OS is really gone made than there is nothing best to do with WINDOWS than re-installing the system. Beleive or not Windows are enemy of old hardware...as your hardware getting older you have to come a...
479,324
I am facing a weird problem. My computer hangs while loading the desktop, and only the background shows up; no icons or bars load. If I power the system on and off about 4-6 times, I may be able to use it normally. The desktop loads normally after rebooting or in safe mode; this only occurs when I start the system nor...
2012/09/25
[ "https://superuser.com/questions/479324", "https://superuser.com", "https://superuser.com/users/161281/" ]
WSearch is messing up try disable Windows Search in services.msc you might lose the search in explorer but what the hey, when the pc dont start then its better than nothing
Why don't you test a linux live on your system to see if its a really hardware issue or OS's.... If it will appear your OS is really gone made than there is nothing best to do with WINDOWS than re-installing the system. Beleive or not Windows are enemy of old hardware...as your hardware getting older you have to come a...
479,324
I am facing a weird problem. My computer hangs while loading the desktop, and only the background shows up; no icons or bars load. If I power the system on and off about 4-6 times, I may be able to use it normally. The desktop loads normally after rebooting or in safe mode; this only occurs when I start the system nor...
2012/09/25
[ "https://superuser.com/questions/479324", "https://superuser.com", "https://superuser.com/users/161281/" ]
Create a new login if you have access to safe mode - Login with new user and copy your stuff over.
Why don't you test a linux live on your system to see if its a really hardware issue or OS's.... If it will appear your OS is really gone made than there is nothing best to do with WINDOWS than re-installing the system. Beleive or not Windows are enemy of old hardware...as your hardware getting older you have to come a...
67,228,572
I would like to round the index values of a pandas dataframe with the name results, such that they do not have any decimal values. I use the followin code that I took from here [Round columns in pandas dataframe](https://stackoverflow.com/questions/31247763/round-columns-in-pandas-dataframe). So basically I have a colu...
2021/04/23
[ "https://Stackoverflow.com/questions/67228572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7133942/" ]
Update the location of the cacert.pem in your openssl.cnf file to point to the latest version you got from curl.se and you should be right.
The solution [described by @tFranz](https://stackoverflow.com/a/69630750/586823) works great! Please note, you can also use your system's cert file instead of MAMP's. This is how I did it: 1. Find the folder that should contain your cert.pem using this line: ```bash $ openssl version -d OPENSSLDIR: "/private/etc/ssl"...
67,228,572
I would like to round the index values of a pandas dataframe with the name results, such that they do not have any decimal values. I use the followin code that I took from here [Round columns in pandas dataframe](https://stackoverflow.com/questions/31247763/round-columns-in-pandas-dataframe). So basically I have a colu...
2021/04/23
[ "https://Stackoverflow.com/questions/67228572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7133942/" ]
Setting the value for "curl.cainfo" didn't help me. Instead i had to set the value in the "openssl"-section of my *current* php.ini (Find the current "php.ini"-file in shell with command 'which php'.): Uncomment and set the **openssl.cafile** (path is for MacOS): ``` openssl.cafile="/Applications/MAMP/Library/OpenSSL...
The solution [described by @tFranz](https://stackoverflow.com/a/69630750/586823) works great! Please note, you can also use your system's cert file instead of MAMP's. This is how I did it: 1. Find the folder that should contain your cert.pem using this line: ```bash $ openssl version -d OPENSSLDIR: "/private/etc/ssl"...
4,976,581
I agree that correct input validation is the only 'fool-proof' way to prevent SQL Injection, however it requires modifying a lot of code in existing applications, possibly might require a badly designed application to be re-structured. There has been a lot of academic interest in automated mechanisms to prevent SQL In...
2011/02/12
[ "https://Stackoverflow.com/questions/4976581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242321/" ]
The company i work for uses [Barracuda Web Application Firewall](http://www.barracudanetworks.com/ns/products/web-site-firewall-overview.php) for what you are talking about. From what I have seen it works fairly well. Basically if it detects suspect input it will redirect the user to a page of our choosing. This allows...
If you aren't going to modify your code then you can only intercept requests. Since there is no such thing as a good or bad SQL command you're pretty limited in options but you could try rejecting multiple queries which initiate from a single string. In other words: **LEGAL** ``` SELECT * FROM foo WHERE bar='baz'; `...
4,976,581
I agree that correct input validation is the only 'fool-proof' way to prevent SQL Injection, however it requires modifying a lot of code in existing applications, possibly might require a badly designed application to be re-structured. There has been a lot of academic interest in automated mechanisms to prevent SQL In...
2011/02/12
[ "https://Stackoverflow.com/questions/4976581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242321/" ]
The company i work for uses [Barracuda Web Application Firewall](http://www.barracudanetworks.com/ns/products/web-site-firewall-overview.php) for what you are talking about. From what I have seen it works fairly well. Basically if it detects suspect input it will redirect the user to a page of our choosing. This allows...
The only way to leave the code untouched while patching vulnerabilities like SQL Injection is to use a web application firewall like the open source project [mod\_security](http://www.modsecurity.org/). Recently Oracle has released a [database firewall](http://www.oracle.com/technetwork/database/database-firewall/index...
4,976,581
I agree that correct input validation is the only 'fool-proof' way to prevent SQL Injection, however it requires modifying a lot of code in existing applications, possibly might require a badly designed application to be re-structured. There has been a lot of academic interest in automated mechanisms to prevent SQL In...
2011/02/12
[ "https://Stackoverflow.com/questions/4976581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242321/" ]
The company i work for uses [Barracuda Web Application Firewall](http://www.barracudanetworks.com/ns/products/web-site-firewall-overview.php) for what you are talking about. From what I have seen it works fairly well. Basically if it detects suspect input it will redirect the user to a page of our choosing. This allows...
The default behavior with PreparedStatements in Java where you pass in each parameter makes it mostly foolproof because the framework escapes the input for you. This doesn't prevent you from doing something like exec spDoStuff <var> where spDoStuff does: exec( <var> ) But if you use normal queries it's very effect...
4,976,581
I agree that correct input validation is the only 'fool-proof' way to prevent SQL Injection, however it requires modifying a lot of code in existing applications, possibly might require a badly designed application to be re-structured. There has been a lot of academic interest in automated mechanisms to prevent SQL In...
2011/02/12
[ "https://Stackoverflow.com/questions/4976581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242321/" ]
If you aren't going to modify your code then you can only intercept requests. Since there is no such thing as a good or bad SQL command you're pretty limited in options but you could try rejecting multiple queries which initiate from a single string. In other words: **LEGAL** ``` SELECT * FROM foo WHERE bar='baz'; `...
The only way to leave the code untouched while patching vulnerabilities like SQL Injection is to use a web application firewall like the open source project [mod\_security](http://www.modsecurity.org/). Recently Oracle has released a [database firewall](http://www.oracle.com/technetwork/database/database-firewall/index...
4,976,581
I agree that correct input validation is the only 'fool-proof' way to prevent SQL Injection, however it requires modifying a lot of code in existing applications, possibly might require a badly designed application to be re-structured. There has been a lot of academic interest in automated mechanisms to prevent SQL In...
2011/02/12
[ "https://Stackoverflow.com/questions/4976581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242321/" ]
If you aren't going to modify your code then you can only intercept requests. Since there is no such thing as a good or bad SQL command you're pretty limited in options but you could try rejecting multiple queries which initiate from a single string. In other words: **LEGAL** ``` SELECT * FROM foo WHERE bar='baz'; `...
The default behavior with PreparedStatements in Java where you pass in each parameter makes it mostly foolproof because the framework escapes the input for you. This doesn't prevent you from doing something like exec spDoStuff <var> where spDoStuff does: exec( <var> ) But if you use normal queries it's very effect...
82,928
The small images I upload to my site seem to have a quality problem in the catalog. I attached images, In the image Its little bit hard to see but there is a big different in the images. I need the image in the site to look the same like the image I upload. One thing strange that in my local test site (in mamp pro and...
2015/09/13
[ "https://magento.stackexchange.com/questions/82928", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/12046/" ]
You can set quality of images on this way: ``` Mage::helper('catalog/image')->init($product, 'small_image')->resize(180, 210)->setQuality(100); ``` or if you using a Varien\_Image object: ``` /* Varien_Image */ $image->quality(100) ``` However, their problem appears to be related to GD2, that the class magento us...
For the best results load the image twice the needed size. So if you need an image that is 300px x 300px, load it at 600px x 600px. After that shrink the image to 300px x 300px with CSS `width:300px;height:auto`. This way it will look good on retina displays.
9,308,072
How can I remove the **whole word** `on` (**not the substring** `on` in the `Confirmed`) from the following string? ``` X-JP409 Confirmed on 13/2/12 ```
2012/02/16
[ "https://Stackoverflow.com/questions/9308072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` "X-JP409 Confirmed on 13/2/12".replace(" on ", " "); ``` [String replace documentation](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace)
What about: ``` String str = "X-JP409 Confirmed on 13/2/12"; str.replaceAll(" on ", " "); ``` The output is what you are looking for: ``` X-JP409 Confirmed 13/2/12 ```
9,308,072
How can I remove the **whole word** `on` (**not the substring** `on` in the `Confirmed`) from the following string? ``` X-JP409 Confirmed on 13/2/12 ```
2012/02/16
[ "https://Stackoverflow.com/questions/9308072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There is special marker of word in regex: `\b`. So the better way is `myString.replaceAll("\\bon\\b", "");` This works when word 'on' is in the beginning, end and in the middle of the text but only if it is a separate word. For example it will not remove "on" from word "one".
``` "X-JP409 Confirmed on 13/2/12".replace(" on ", " "); ``` [String replace documentation](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace)
9,308,072
How can I remove the **whole word** `on` (**not the substring** `on` in the `Confirmed`) from the following string? ``` X-JP409 Confirmed on 13/2/12 ```
2012/02/16
[ "https://Stackoverflow.com/questions/9308072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you want to replace all "on" which are not in a word, you can try to match the **word boundary \b** as well. Hope it helps. ``` String abc = "on X-JP409 Confirmed on 13/2/12 on"; abc = abc.replaceAll("\\bon\\b", ""); System.out.println(abc); ``` or ``` String abc = "on X-JP409 Confirmed on 13/2/...
``` "X-JP409 Confirmed on 13/2/12".replace(" on ", " "); ``` [String replace documentation](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace)
9,308,072
How can I remove the **whole word** `on` (**not the substring** `on` in the `Confirmed`) from the following string? ``` X-JP409 Confirmed on 13/2/12 ```
2012/02/16
[ "https://Stackoverflow.com/questions/9308072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There is special marker of word in regex: `\b`. So the better way is `myString.replaceAll("\\bon\\b", "");` This works when word 'on' is in the beginning, end and in the middle of the text but only if it is a separate word. For example it will not remove "on" from word "one".
What about: ``` String str = "X-JP409 Confirmed on 13/2/12"; str.replaceAll(" on ", " "); ``` The output is what you are looking for: ``` X-JP409 Confirmed 13/2/12 ```
9,308,072
How can I remove the **whole word** `on` (**not the substring** `on` in the `Confirmed`) from the following string? ``` X-JP409 Confirmed on 13/2/12 ```
2012/02/16
[ "https://Stackoverflow.com/questions/9308072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you want to replace all "on" which are not in a word, you can try to match the **word boundary \b** as well. Hope it helps. ``` String abc = "on X-JP409 Confirmed on 13/2/12 on"; abc = abc.replaceAll("\\bon\\b", ""); System.out.println(abc); ``` or ``` String abc = "on X-JP409 Confirmed on 13/2/...
What about: ``` String str = "X-JP409 Confirmed on 13/2/12"; str.replaceAll(" on ", " "); ``` The output is what you are looking for: ``` X-JP409 Confirmed 13/2/12 ```
72,844,424
I am trying to Solve a UseCase using Shell Script:: I have a Sample CSV File Like as Below - ``` Col1|Col2|Col3|Col4|Col5 120 Sam|145678 Sam|Pp|Iss|samrat 134 Jhu|456788 Uip|Tt|Acc|jhurt 678 Pop|120987 Por|Uu|Try|pord ``` I am trying to get the Substrings from Col1, Col2,Col3 and Col4 and create a new file with it ...
2022/07/03
[ "https://Stackoverflow.com/questions/72844424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9256375/" ]
An `awk` solution with `substr`: ```bash awk ' BEGIN{FS=OFS="|"} NR==1 { print; next } {print substr($1,1,3), substr($2,1,6), substr($3,1,1), substr($4,1,1), $5} ' file Col1|Col2|Col3|Col4|Col5 120|145678|P|I|samrat 134|456788|T|A|jhurt 678|120987|U|T|pord ```
With your shown samples, please try following `awk` code. Written and tested in GNU `awk` using `awk`'s `match` function with creating array named `arr` in it. ``` awk ' BEGIN { FS=OFS="|" } FNR==1{ print;next } match($0,/^(.{3})([^|]*\|)(.{6})[^|]*\|(.)[^|]*\|(.)[^|]*\|([^|]*)/,arr){ print arr[1],arr[3],arr[4],arr[...
72,844,424
I am trying to Solve a UseCase using Shell Script:: I have a Sample CSV File Like as Below - ``` Col1|Col2|Col3|Col4|Col5 120 Sam|145678 Sam|Pp|Iss|samrat 134 Jhu|456788 Uip|Tt|Acc|jhurt 678 Pop|120987 Por|Uu|Try|pord ``` I am trying to get the Substrings from Col1, Col2,Col3 and Col4 and create a new file with it ...
2022/07/03
[ "https://Stackoverflow.com/questions/72844424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9256375/" ]
An `awk` solution with `substr`: ```bash awk ' BEGIN{FS=OFS="|"} NR==1 { print; next } {print substr($1,1,3), substr($2,1,6), substr($3,1,1), substr($4,1,1), $5} ' file Col1|Col2|Col3|Col4|Col5 120|145678|P|I|samrat 134|456788|T|A|jhurt 678|120987|U|T|pord ```
This might work for you (GNU sed): ``` sed -E '1b s/([^|])?([^|]{2})?([^|]{3})?[^|]*/\1\2/1;s//\1\2\3/2;s//\1/3;s//\1/4' file ``` Pattern match each field and return the desired format. Or: ``` sed -E '1b s/((([^|]?)([^|]{2})?)([^|]{3})?)[^|]*/\2/1;s//\1/2;s//\3/3;s//\3/4' file ```
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
A bitmap takes up 4 bytes per pixel ==> 13MP equals 52MB of memory. You should use BitmapFactory.Options to get the size only first. By using `inJustDecodeBounds` you get the Bitmap object with all its meta data, but without the actual image. ``` BitmapFactory.Options options = new BitmapFactory.Options(); options.inJ...
I would recommend to use [Picasso](http://square.github.io/picasso/) library from Square. And [PhotoView](https://github.com/chrisbanes/PhotoView) for image zooming.
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
I would recommend to use [Picasso](http://square.github.io/picasso/) library from Square. And [PhotoView](https://github.com/chrisbanes/PhotoView) for image zooming.
Thanks a lot to all for all of ur answers. I thought that I should use inJustDecodeBounds option and load resized bitmap, but In need a fresh view to this problem of more experienced persons. I also thought about using Universal Image Loader for loading and caching large images and something like ScaleImageView for...
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
A bitmap takes up 4 bytes per pixel ==> 13MP equals 52MB of memory. You should use BitmapFactory.Options to get the size only first. By using `inJustDecodeBounds` you get the Bitmap object with all its meta data, but without the actual image. ``` BitmapFactory.Options options = new BitmapFactory.Options(); options.inJ...
Try this for scaling the bitmap ``` final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; /* * If set to a value > 1, requests the decoder to * subsample th...
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
Try this for scaling the bitmap ``` final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; /* * If set to a value > 1, requests the decoder to * subsample th...
Thanks a lot to all for all of ur answers. I thought that I should use inJustDecodeBounds option and load resized bitmap, but In need a fresh view to this problem of more experienced persons. I also thought about using Universal Image Loader for loading and caching large images and something like ScaleImageView for...
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
A bitmap takes up 4 bytes per pixel ==> 13MP equals 52MB of memory. You should use BitmapFactory.Options to get the size only first. By using `inJustDecodeBounds` you get the Bitmap object with all its meta data, but without the actual image. ``` BitmapFactory.Options options = new BitmapFactory.Options(); options.inJ...
``` BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.myimage, options); int imageHeight = options.outHeight; int imageWidth = options.outWidth; String imageType = options.outMimeType; ``` To avoid `java.lang.OutOfMemory` ...
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
A bitmap takes up 4 bytes per pixel ==> 13MP equals 52MB of memory. You should use BitmapFactory.Options to get the size only first. By using `inJustDecodeBounds` you get the Bitmap object with all its meta data, but without the actual image. ``` BitmapFactory.Options options = new BitmapFactory.Options(); options.inJ...
Thanks a lot to all for all of ur answers. I thought that I should use inJustDecodeBounds option and load resized bitmap, but In need a fresh view to this problem of more experienced persons. I also thought about using Universal Image Loader for loading and caching large images and something like ScaleImageView for...
22,987,577
Every time I run my app in Xcode on the iOS Simulator, the folders in the project navigation pane all reset to just showing the closed top-level folders. I then have to re-drill-down to the code, opening all the folders on the way; but then when I run the app again we're back to square one. There's presumably a real...
2014/04/10
[ "https://Stackoverflow.com/questions/22987577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266770/" ]
``` BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.myimage, options); int imageHeight = options.outHeight; int imageWidth = options.outWidth; String imageType = options.outMimeType; ``` To avoid `java.lang.OutOfMemory` ...
Thanks a lot to all for all of ur answers. I thought that I should use inJustDecodeBounds option and load resized bitmap, but In need a fresh view to this problem of more experienced persons. I also thought about using Universal Image Loader for loading and caching large images and something like ScaleImageView for...
9,947,305
I'm trying to write out some dynamic CSS using Jade, like so: ``` style(type='text/css') each item in colors .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } ``` However this gives the following error: ``` ReferenceError: media='print') 7| style(type='text/css')...
2012/03/30
[ "https://Stackoverflow.com/questions/9947305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239488/" ]
Because `style` tags only allow text in Jade, it's treating your `each item in colors` as plain text. Then it encounters the `#{item.class}` and attempts to parse that, but it fails because it didn't define `item` on the previous line. Unfortunately, I'm not sure that there is a good way to do this in Jade. You might ...
You could use Stylus. It's made by the same people that created Jade and is almost identical to Jade within reason.
9,947,305
I'm trying to write out some dynamic CSS using Jade, like so: ``` style(type='text/css') each item in colors .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } ``` However this gives the following error: ``` ReferenceError: media='print') 7| style(type='text/css')...
2012/03/30
[ "https://Stackoverflow.com/questions/9947305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239488/" ]
Because `style` tags only allow text in Jade, it's treating your `each item in colors` as plain text. Then it encounters the `#{item.class}` and attempts to parse that, but it fails because it didn't define `item` on the previous line. Unfortunately, I'm not sure that there is a good way to do this in Jade. You might ...
I ran into a similar issue where I wanted to add a specific class to the body tag depending on the route, similar to what I've done in PHP. In the end, I used jade's template inheritance to achieve a similar result.
9,947,305
I'm trying to write out some dynamic CSS using Jade, like so: ``` style(type='text/css') each item in colors .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } ``` However this gives the following error: ``` ReferenceError: media='print') 7| style(type='text/css')...
2012/03/30
[ "https://Stackoverflow.com/questions/9947305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239488/" ]
Because `style` tags only allow text in Jade, it's treating your `each item in colors` as plain text. Then it encounters the `#{item.class}` and attempts to parse that, but it fails because it didn't define `item` on the previous line. Unfortunately, I'm not sure that there is a good way to do this in Jade. You might ...
Another way is to import your own css stylesheet. In the [Jade doc](http://jade-lang.com/reference/includes/), you can see that you can include a style sheet with such code: ``` html head style include style.css ``` Then, you can define any CSS in a separate file that you can reference.
9,947,305
I'm trying to write out some dynamic CSS using Jade, like so: ``` style(type='text/css') each item in colors .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } ``` However this gives the following error: ``` ReferenceError: media='print') 7| style(type='text/css')...
2012/03/30
[ "https://Stackoverflow.com/questions/9947305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239488/" ]
You could use Stylus. It's made by the same people that created Jade and is almost identical to Jade within reason.
I ran into a similar issue where I wanted to add a specific class to the body tag depending on the route, similar to what I've done in PHP. In the end, I used jade's template inheritance to achieve a similar result.
9,947,305
I'm trying to write out some dynamic CSS using Jade, like so: ``` style(type='text/css') each item in colors .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } ``` However this gives the following error: ``` ReferenceError: media='print') 7| style(type='text/css')...
2012/03/30
[ "https://Stackoverflow.com/questions/9947305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239488/" ]
Another way is to import your own css stylesheet. In the [Jade doc](http://jade-lang.com/reference/includes/), you can see that you can include a style sheet with such code: ``` html head style include style.css ``` Then, you can define any CSS in a separate file that you can reference.
I ran into a similar issue where I wanted to add a specific class to the body tag depending on the route, similar to what I've done in PHP. In the end, I used jade's template inheritance to achieve a similar result.
57,680,852
I have a data frame with numbers of doctors in some cities in Brazil (data frame A). I have another data frame (data frame B) with the cities population (all of them). How can I obtain the value of number of doctors divided by the city population. Note that I have more cities in B than in A. ``` > A City Doctors A ...
2019/08/27
[ "https://Stackoverflow.com/questions/57680852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11518133/" ]
Here's a way using `match` from base R - ``` A$Doctors_Pop <- A$Doctors / B$Pop[match(A$City, B$City)] ``` --- Another way using `merge` - ``` result <- merge(A, B, by = "City", all.x = TRUE) result$Doctors_Pop <- result$Doctors / result$Pop ```
You could also do this with an "update join" using data.table ``` library(data.table) setDT(A) setDT(B) A[B, on = .(City), Doctors_Pop := Doctors/Pop] A # City Doctors Doctors_Pop # 1: A 3 0.0300000 # 2: C 4 0.1333333 # 3: E 5 0.0100000 ```
186,086
I am a Java (Web) Developer. Having knowledge about c#, PHP and Ruby. I am getting confused how to keep myself updated with very fast changing the programming language and their implementation. Like, in the mobile, you can see around 7-8 OS. There are very much finer example of event-driven programming to make scalabl...
2013/02/06
[ "https://softwareengineering.stackexchange.com/questions/186086", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/80692/" ]
> > *Like, in the mobile, you can see around 7-8 OS. There are very much finer example of event-driven programming to make scalable application > like node.js, Ember, Require etc.. Then WebSockets, Socket.io, HTML5.* > > > **Try to be a master of one trade (the trade you works with), then try to be a jack of othe...
Perhaps you should do the selection by domain and not by technology/prog language? What is it that is of interest to you? Databases? Mobile applications? Search? Natural language processing? Big Data (hot right now)? Graphics? Web apps all around? Domain-specific web apps (like social)? GIS? Distributed programming fo...
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
Thankfully in C++11 you can just have the compiler figure it out. The compiler already knows what m\_vect is, so you can tell it: ``` for (auto it= m_vect.begin(); ( it != m_vect.end()) ; ++ it ) { } ``` But wait, there's more. In c++11 you can even just iterate over everything in `m_vect` ``` for (auto it : m_vect...
`T` needs to be an actual type. It should be the type of whatever is stored in the vector. Your `for` loop looks correct. You declared `m_vect` somewhere. The iterator needs the same time as whatever you declared `m_vect` (plus `::iterator` of course).
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
This appears to be in a template function, and `vector<T>::iterator` is a type which is dependent on `T`, which is a template parameter. Since templates can be specialized with unique definitions for any different type, the compiler has no way of being sure, until the template is actually instantiated, whether `vector<...
`T` needs to be an actual type. It should be the type of whatever is stored in the vector. Your `for` loop looks correct. You declared `m_vect` somewhere. The iterator needs the same time as whatever you declared `m_vect` (plus `::iterator` of course).
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
Thankfully in C++11 you can just have the compiler figure it out. The compiler already knows what m\_vect is, so you can tell it: ``` for (auto it= m_vect.begin(); ( it != m_vect.end()) ; ++ it ) { } ``` But wait, there's more. In c++11 you can even just iterate over everything in `m_vect` ``` for (auto it : m_vect...
This appears to be in a template function, and `vector<T>::iterator` is a type which is dependent on `T`, which is a template parameter. Since templates can be specialized with unique definitions for any different type, the compiler has no way of being sure, until the template is actually instantiated, whether `vector<...
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
Thankfully in C++11 you can just have the compiler figure it out. The compiler already knows what m\_vect is, so you can tell it: ``` for (auto it= m_vect.begin(); ( it != m_vect.end()) ; ++ it ) { } ``` But wait, there's more. In c++11 you can even just iterate over everything in `m_vect` ``` for (auto it : m_vect...
This is something compilers are enforcing better now. When you are using something derived from a template, you have to flag if it's being used as a type by adding `typename`. Then if the compiler knows that (for some insane reason) `vector<T>::iterator` is a method, it can immediately flag the error instead of headin...
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
Thankfully in C++11 you can just have the compiler figure it out. The compiler already knows what m\_vect is, so you can tell it: ``` for (auto it= m_vect.begin(); ( it != m_vect.end()) ; ++ it ) { } ``` But wait, there's more. In c++11 you can even just iterate over everything in `m_vect` ``` for (auto it : m_vect...
If you have amodern enough compiler, you can replace `vector<T>::iterator` with `auto`. Else, find the correct type to replace the `T` with for your vector.
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
This appears to be in a template function, and `vector<T>::iterator` is a type which is dependent on `T`, which is a template parameter. Since templates can be specialized with unique definitions for any different type, the compiler has no way of being sure, until the template is actually instantiated, whether `vector<...
This is something compilers are enforcing better now. When you are using something derived from a template, you have to flag if it's being used as a type by adding `typename`. Then if the compiler knows that (for some insane reason) `vector<T>::iterator` is a method, it can immediately flag the error instead of headin...
20,486,416
So based on other examples I've found, I'm led to believe that this would be the proper code to iterate over m\_vect: ``` for(vector<T>::iterator it = m_vect.begin(); it != m_vect.end(); ++it) ``` However, upon attempting to compile, I get the following error on that line: ``` heap.h:167:6: error: need ‘typename’ b...
2013/12/10
[ "https://Stackoverflow.com/questions/20486416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509963/" ]
This appears to be in a template function, and `vector<T>::iterator` is a type which is dependent on `T`, which is a template parameter. Since templates can be specialized with unique definitions for any different type, the compiler has no way of being sure, until the template is actually instantiated, whether `vector<...
If you have amodern enough compiler, you can replace `vector<T>::iterator` with `auto`. Else, find the correct type to replace the `T` with for your vector.
73,441
I have a waterproof DS18B20 sensor that I have connected to a WeMos D1 Mini microcontroller. This controller connects to Wifi and an MQTT broker, sending the temperature from the sensor and goes to deep sleep. Everything works nicely, except for the sensor reading. It returns -127, which means the sensor is disconnect...
2020/03/26
[ "https://arduino.stackexchange.com/questions/73441", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/29860/" ]
this isn't an arduino specific error what you're trying to do is declare and initialize the variable in one statement which is causing the problem. As you've figured it out already. Declaring the variable first ``` String s; ``` and initializing it another statement does the job for you ``` s=blabla ``` Hope this...
I don't have much experience with Arduino's `String` type, however, most people (including myself) don't advise to use it. Because the Arduino only has 1 KB of SRAM and the `String` type has its own hidden memory allocation, you might run out of memory without you know it, resulting in crashing/frozen programs without ...
73,441
I have a waterproof DS18B20 sensor that I have connected to a WeMos D1 Mini microcontroller. This controller connects to Wifi and an MQTT broker, sending the temperature from the sensor and goes to deep sleep. Everything works nicely, except for the sensor reading. It returns -127, which means the sensor is disconnect...
2020/03/26
[ "https://arduino.stackexchange.com/questions/73441", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/29860/" ]
You misunderstand `Serial.read()`: it does not return a `String` or sth. like a char array, but an integer, representing only the last byte in the input buffer that hasn't been read. What you probably want to do is to interpret those incoming bytes as `char`s and accumulate those in a `String`. E.g. like this: ``` S...
I don't have much experience with Arduino's `String` type, however, most people (including myself) don't advise to use it. Because the Arduino only has 1 KB of SRAM and the `String` type has its own hidden memory allocation, you might run out of memory without you know it, resulting in crashing/frozen programs without ...
73,441
I have a waterproof DS18B20 sensor that I have connected to a WeMos D1 Mini microcontroller. This controller connects to Wifi and an MQTT broker, sending the temperature from the sensor and goes to deep sleep. Everything works nicely, except for the sensor reading. It returns -127, which means the sensor is disconnect...
2020/03/26
[ "https://arduino.stackexchange.com/questions/73441", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/29860/" ]
this isn't an arduino specific error what you're trying to do is declare and initialize the variable in one statement which is causing the problem. As you've figured it out already. Declaring the variable first ``` String s; ``` and initializing it another statement does the job for you ``` s=blabla ``` Hope this...
This will fix the problem: `void loop() { if(Serial.available()) { String s=(char*)Serial.read(); } }` This is because in C: Strings are defined as an array of characters. You cannot assign a primitive to an array... I guess the casting into pointer can be implicit as in your second example..
73,441
I have a waterproof DS18B20 sensor that I have connected to a WeMos D1 Mini microcontroller. This controller connects to Wifi and an MQTT broker, sending the temperature from the sensor and goes to deep sleep. Everything works nicely, except for the sensor reading. It returns -127, which means the sensor is disconnect...
2020/03/26
[ "https://arduino.stackexchange.com/questions/73441", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/29860/" ]
You misunderstand `Serial.read()`: it does not return a `String` or sth. like a char array, but an integer, representing only the last byte in the input buffer that hasn't been read. What you probably want to do is to interpret those incoming bytes as `char`s and accumulate those in a `String`. E.g. like this: ``` S...
This will fix the problem: `void loop() { if(Serial.available()) { String s=(char*)Serial.read(); } }` This is because in C: Strings are defined as an array of characters. You cannot assign a primitive to an array... I guess the casting into pointer can be implicit as in your second example..
5,330,909
How do I use DateTime.Parse to parse a datetime with the following format: `08 Feb 2011 06:46` In response to the answer I've received so far, I tried the following: ``` item.ServerDate = DateTime.ParseExact ("08 Feb 2011 06:46", "dd MMM yyyy hh:mm", System.Globalization.CultureInfo.InvariantCulture)...
2011/03/16
[ "https://Stackoverflow.com/questions/5330909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238260/" ]
``` DateTime.ParseExact("08 Feb 2011 06:46", "dd MMM yyyy hh:mm", System.Globalization.CultureInfo.InvariantCulture); ``` In your question's sample code, you forgot to capitalize all of the month "M"s. ### Edit As Anton points out, the "H"s also need to be capitalized to use military time. ``` DateTime.ParseE...
`DateTime.ParseExact` might work for you: <http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx>
5,330,909
How do I use DateTime.Parse to parse a datetime with the following format: `08 Feb 2011 06:46` In response to the answer I've received so far, I tried the following: ``` item.ServerDate = DateTime.ParseExact ("08 Feb 2011 06:46", "dd MMM yyyy hh:mm", System.Globalization.CultureInfo.InvariantCulture)...
2011/03/16
[ "https://Stackoverflow.com/questions/5330909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238260/" ]
`DateTime.ParseExact` might work for you: <http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx>
From the documentation: ``` "hh": The hour, using a 12-hour clock from 01 to 12. "HH": The hour, using a 24-hour clock from 00 to 23. ``` and > > In the .NET Framework 4, the > ParseExact method throws a > FormatException if the string to be > parsed contains an hour component and > an AM/PM designator that ar...
5,330,909
How do I use DateTime.Parse to parse a datetime with the following format: `08 Feb 2011 06:46` In response to the answer I've received so far, I tried the following: ``` item.ServerDate = DateTime.ParseExact ("08 Feb 2011 06:46", "dd MMM yyyy hh:mm", System.Globalization.CultureInfo.InvariantCulture)...
2011/03/16
[ "https://Stackoverflow.com/questions/5330909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238260/" ]
``` DateTime.ParseExact("08 Feb 2011 06:46", "dd MMM yyyy hh:mm", System.Globalization.CultureInfo.InvariantCulture); ``` In your question's sample code, you forgot to capitalize all of the month "M"s. ### Edit As Anton points out, the "H"s also need to be capitalized to use military time. ``` DateTime.ParseE...
From the documentation: ``` "hh": The hour, using a 12-hour clock from 01 to 12. "HH": The hour, using a 24-hour clock from 00 to 23. ``` and > > In the .NET Framework 4, the > ParseExact method throws a > FormatException if the string to be > parsed contains an hour component and > an AM/PM designator that ar...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
``` using System; public class MyBase { int num; public MyBase(int i ) { num = i; Console.WriteLine("in MyBase(int i)"); } public int GetNum() { return num; } } public class MyDerived: MyBase { // This constructor will call MyBase.MyBase(int i) ***//You are missing thi...
You need to pass all arguments back to your parent. ``` class SwimmingEvent : Event { private String m_distance; private String m_inOutVar; public SwimmingEvent(String Distance, String InOrOut, string evName) : base (evName,"b","c", "d", "e") { m_distance = Distance; m_inOutVar = ...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
Since `SwimmingEvent` *is an* `Event`, you need to pass all arguments that you pass to the `Event`'s constructor to the constructor of `SwimmingEvent`, and then some: ``` public SwimmingEvent(String EvName, String EvDate, String EvTime, String EvFee, String EvVenue, String Distance, String InOrOut) : base (EvName, E...
You need to pass all arguments back to your parent. ``` class SwimmingEvent : Event { private String m_distance; private String m_inOutVar; public SwimmingEvent(String Distance, String InOrOut, string evName) : base (evName,"b","c", "d", "e") { m_distance = Distance; m_inOutVar = ...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
Since `SwimmingEvent` *is an* `Event`, you need to pass all arguments that you pass to the `Event`'s constructor to the constructor of `SwimmingEvent`, and then some: ``` public SwimmingEvent(String EvName, String EvDate, String EvTime, String EvFee, String EvVenue, String Distance, String InOrOut) : base (EvName, E...
``` using System; public class MyBase { int num; public MyBase(int i ) { num = i; Console.WriteLine("in MyBase(int i)"); } public int GetNum() { return num; } } public class MyDerived: MyBase { // This constructor will call MyBase.MyBase(int i) ***//You are missing thi...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
``` using System; public class MyBase { int num; public MyBase(int i ) { num = i; Console.WriteLine("in MyBase(int i)"); } public int GetNum() { return num; } } public class MyDerived: MyBase { // This constructor will call MyBase.MyBase(int i) ***//You are missing thi...
May be something like this: ``` public class Event { public Event() {} // public empty ctor .... .... } ``` and derived ``` public class SwimmingEvent : Event { } ``` In this way you will avoid (assuming that is what you want) the compile time error, as a `ctor` with empty arguments list is alread...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
``` using System; public class MyBase { int num; public MyBase(int i ) { num = i; Console.WriteLine("in MyBase(int i)"); } public int GetNum() { return num; } } public class MyDerived: MyBase { // This constructor will call MyBase.MyBase(int i) ***//You are missing thi...
in C#, before constructor of derived class (such as SwimmingEvent constructor) is called, constructor of base class (Event class) must be called too. Arguments of call to base class's constructor are usually specified using "*base*" keyword like this: ``` class SwimmingEvent : Event { .... public SwimmingEvent...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
Since `SwimmingEvent` *is an* `Event`, you need to pass all arguments that you pass to the `Event`'s constructor to the constructor of `SwimmingEvent`, and then some: ``` public SwimmingEvent(String EvName, String EvDate, String EvTime, String EvFee, String EvVenue, String Distance, String InOrOut) : base (EvName, E...
May be something like this: ``` public class Event { public Event() {} // public empty ctor .... .... } ``` and derived ``` public class SwimmingEvent : Event { } ``` In this way you will avoid (assuming that is what you want) the compile time error, as a `ctor` with empty arguments list is alread...
10,142,593
I need to create an inherritance of an Event as a SwimmingEvent however I'm receiving an error that the constructor doens't contain 0 arguments, the problem is I don't know which arguments are meant to be passed through. Any help would be greatly appreciated. ``` //Base Class class Event { private string m_evNam...
2012/04/13
[ "https://Stackoverflow.com/questions/10142593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008693/" ]
Since `SwimmingEvent` *is an* `Event`, you need to pass all arguments that you pass to the `Event`'s constructor to the constructor of `SwimmingEvent`, and then some: ``` public SwimmingEvent(String EvName, String EvDate, String EvTime, String EvFee, String EvVenue, String Distance, String InOrOut) : base (EvName, E...
in C#, before constructor of derived class (such as SwimmingEvent constructor) is called, constructor of base class (Event class) must be called too. Arguments of call to base class's constructor are usually specified using "*base*" keyword like this: ``` class SwimmingEvent : Event { .... public SwimmingEvent...
16,287,416
On my XPage, I have a series of search filters (State, First Name and Last Name). The search button triggers the population of the datatable which is bound to a Managed Bean. The datatable initially gets populated with rows of data. However when I click on Next (in the pager), instead of loading the next 5 rows, it re...
2013/04/29
[ "https://Stackoverflow.com/questions/16287416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2292064/" ]
I'm making some assumptions here without seeing your MBean code, but hope to point you in the right direction nonetheless... Ensure you are restoring the datamodel within the studenLists bean during invocations of the **getStudents()** call. I see you have **value="#{studentlist.students}"** in the XSP fragment above....
Do you also lose the data if you add another button that just partially refreshes the dataTable? That should identify if it's a problem with managed bean properties being reset (in which case the contents of the dataTable would disappear) or a problem with paging (in which case they wouldn't).
33,127,676
I tried to create one page like this: [![enter image description here](https://i.stack.imgur.com/TJcKd.jpg)](https://i.stack.imgur.com/TJcKd.jpg) Of course this is just a summary of my project. I want to show after every div with `class="s1"` ``` (first & 4n+1'th) div with class="s2" in 'white' background (first &...
2015/10/14
[ "https://Stackoverflow.com/questions/33127676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5444746/" ]
If I understood your question.. Use the `element +` selector. <http://www.w3schools.com/cssref/sel_element_pluss.asp> ``` .s1 + div + div + div { //Selects the third div after ".s1" background-color:red; } ```
The `nth-of-class` doesn't exists, and the `nth-of-type` will target them all, so, you'll need to wrap the `.s2` in a div. You can then remove the classes and target them by using `.s1+div>div` ```css body { background: gray; color: blue; position: relative; } * { text-align: center; vertica...
37,501,967
``` module Main where import System.Random import Data.Foldable import Control.Monad import qualified Data.Map as M import qualified Data.Vector as V import Debug.Trace import Data.Maybe import Data.Ord -- Represents the maximal integer. maxBound is no good because it overflows. -- Ideally should b...
2016/05/28
[ "https://Stackoverflow.com/questions/37501967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4364027/" ]
The problem you have linked to has a clean Haskell solution using *right folds*. In other words, you can skip worrying about lazy fromList, memoization and all that by just using a more functional style. The idea is that you maintain a list of `(candy, score)` pairs where `candy` is zero initially for all (`repeat 0` ...
Well, regarding my own question at the top, probably the way to make the thing lazy would be to just use a list (a list of lists or a vector of lists.) The reason why the above is impossible to make lazy is because the Map type is lazy in the values and strict in the keys. More importantly, my analysis that the fold i...
42,845,993
This is the code I have. ``` SELECT CustNum, IFNULL(CustRep, 'None') AS CustRep FROM Customers; ``` The Error I am getting is > > ORA-00904: "IFNULL": invalid identifier > 00904. 00000 - "%s: invalid identifier" > \*Cause: > > \*Action: > Error at Line: 11 Column: 8 > > > I understand the issue is with ...
2017/03/16
[ "https://Stackoverflow.com/questions/42845993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7476775/" ]
I am not sure about `IFNULL` but you can use `NVL` in your scenario : ``` SELECT CustNum, NVL(CustRep, 'None') AS CustRep FROM Customers; ```
I think you want `COALESCE()`: ``` SELECT CustNum, COALESCE(CustRep, 'None') AS CustRep FROM Customers; ```
37,962,158
I'm creating an application to test how many 'steps' it takes for a number to reach 1 using the colatz conjecture. Here is the code: ``` import sys import csv def findSteps(mode): count = 0 while mode != 1: count = count + 1 if mode%2 == 0: mode = mode/2 else: m...
2016/06/22
[ "https://Stackoverflow.com/questions/37962158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2513921/" ]
In addition of the `list.append()` variant, you may also use ``` numbers = range(1, 100) counts = [findSteps(n) for n in numbers] ``` Or, if you like to keep it functional ``` numbers = range(1, 100) counts = map(findSteps, numbers) ```
Both `numbers` and `counts` have a type of `list`, based on how you defined them in your code. So you can use the method of `append` to add the data to both of them. Just remember that the indexes are zero-based. Moreover, I agree with @Evert's comment it looks like a `dictionary` object is better suited for your needs...
61,077,893
I'm kinda lost. I have a postgres database running in a docker container which I started using docker compose. Everything was working fine until recently I get an error saying `FATAL: password authentication failed for user "postgres"` I connected to the database using spring - jdbc. application.properties ``` ## P...
2020/04/07
[ "https://Stackoverflow.com/questions/61077893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12125473/" ]
Plotting discontinuous axis is made difficult for a reason, that reason being that you should avoid doing it whenever possible. While I disagree with your reviewers, you can get down and dirty with the underlying grid graphics if you truly want a y-axis break. First make your plot. The only thing I added was y-axis fo...
To my knowledge ggplot2 doesn't support axis breaks. There is a solution [here](https://www.j4s8.de/post/2018-01-15-broken-axis-with-ggplot2/) with `facet_grid`.
6,381,946
Can any one tell me the query to know data base name already exists or not in mysq. Thank You
2011/06/17
[ "https://Stackoverflow.com/questions/6381946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746190/" ]
are you trying to create a database only if i doesnt exist? here is how ``` CREATE DATABASE IF NOT EXISTS db_name ``` [Read More](http://dev.mysql.com/doc/refman/5.5/en/create-database.html)
``` use mysql; count * from db where db="your_db_name"; ```
6,381,946
Can any one tell me the query to know data base name already exists or not in mysq. Thank You
2011/06/17
[ "https://Stackoverflow.com/questions/6381946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746190/" ]
are you trying to create a database only if i doesnt exist? here is how ``` CREATE DATABASE IF NOT EXISTS db_name ``` [Read More](http://dev.mysql.com/doc/refman/5.5/en/create-database.html)
Query INFORMATION\_SCHEMA.SCHEMATA to know if the database exists or not. Read more here - <http://dev.mysql.com/doc/refman/5.0/en/schemata-table.html>
6,381,946
Can any one tell me the query to know data base name already exists or not in mysq. Thank You
2011/06/17
[ "https://Stackoverflow.com/questions/6381946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746190/" ]
Instead of `Temp` use your DB name. ``` SELECT IF(EXISTS (SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'Temp'), 'Yes','No') ```
``` use mysql; count * from db where db="your_db_name"; ```
6,381,946
Can any one tell me the query to know data base name already exists or not in mysq. Thank You
2011/06/17
[ "https://Stackoverflow.com/questions/6381946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/746190/" ]
Instead of `Temp` use your DB name. ``` SELECT IF(EXISTS (SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'Temp'), 'Yes','No') ```
Query INFORMATION\_SCHEMA.SCHEMATA to know if the database exists or not. Read more here - <http://dev.mysql.com/doc/refman/5.0/en/schemata-table.html>
38,443,125
This Excel formula below can return the last value in row 1. I wonder how does it work. Especially, I don't understand the purpose of using `MATCH(MAX(1:1),1:1,1)-1` in the formula. ``` =OFFSET(A1,0,MATCH(MAX(1:1),1:1,1)-1) ```
2016/07/18
[ "https://Stackoverflow.com/questions/38443125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5700717/" ]
You can use `.AsString()` on the body if you pull in `Nancy.Extensions` ``` var thing = Request.Body.AsString(); ``` This is the Nancy way.
Figured it out, it's accessible under the "Request" field. For the code I can get the Body by doing something like ``` byte[] response = new byte[Request.Body.Length]; Request.Body.Read(response, 0, (int)Request.Body.Length); ``` and ``` string POSTParameters = System.Text.Enco...
38,443,125
This Excel formula below can return the last value in row 1. I wonder how does it work. Especially, I don't understand the purpose of using `MATCH(MAX(1:1),1:1,1)-1` in the formula. ``` =OFFSET(A1,0,MATCH(MAX(1:1),1:1,1)-1) ```
2016/07/18
[ "https://Stackoverflow.com/questions/38443125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5700717/" ]
Figured it out, it's accessible under the "Request" field. For the code I can get the Body by doing something like ``` byte[] response = new byte[Request.Body.Length]; Request.Body.Read(response, 0, (int)Request.Body.Length); ``` and ``` string POSTParameters = System.Text.Enco...
For query params you can use Nancy's Request object on the module. ``` var queryParam = this.Request.Query.ParamName; ``` For an actual post body you can use ``` this.Bind(); ``` Which will create a dynamic with the properties specified in the body.
38,443,125
This Excel formula below can return the last value in row 1. I wonder how does it work. Especially, I don't understand the purpose of using `MATCH(MAX(1:1),1:1,1)-1` in the formula. ``` =OFFSET(A1,0,MATCH(MAX(1:1),1:1,1)-1) ```
2016/07/18
[ "https://Stackoverflow.com/questions/38443125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5700717/" ]
In new versions of NancyFx (1.4+) you can use this solution: ``` using Nancy.IO; ... var yourString = RequestStream.FromStream(Request.Body).AsString(); ``` while ``` var yourString = Request.Body.AsString(); ``` is supported no more.
Figured it out, it's accessible under the "Request" field. For the code I can get the Body by doing something like ``` byte[] response = new byte[Request.Body.Length]; Request.Body.Read(response, 0, (int)Request.Body.Length); ``` and ``` string POSTParameters = System.Text.Enco...
38,443,125
This Excel formula below can return the last value in row 1. I wonder how does it work. Especially, I don't understand the purpose of using `MATCH(MAX(1:1),1:1,1)-1` in the formula. ``` =OFFSET(A1,0,MATCH(MAX(1:1),1:1,1)-1) ```
2016/07/18
[ "https://Stackoverflow.com/questions/38443125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5700717/" ]
You can use `.AsString()` on the body if you pull in `Nancy.Extensions` ``` var thing = Request.Body.AsString(); ``` This is the Nancy way.
For query params you can use Nancy's Request object on the module. ``` var queryParam = this.Request.Query.ParamName; ``` For an actual post body you can use ``` this.Bind(); ``` Which will create a dynamic with the properties specified in the body.
38,443,125
This Excel formula below can return the last value in row 1. I wonder how does it work. Especially, I don't understand the purpose of using `MATCH(MAX(1:1),1:1,1)-1` in the formula. ``` =OFFSET(A1,0,MATCH(MAX(1:1),1:1,1)-1) ```
2016/07/18
[ "https://Stackoverflow.com/questions/38443125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5700717/" ]
You can use `.AsString()` on the body if you pull in `Nancy.Extensions` ``` var thing = Request.Body.AsString(); ``` This is the Nancy way.
In new versions of NancyFx (1.4+) you can use this solution: ``` using Nancy.IO; ... var yourString = RequestStream.FromStream(Request.Body).AsString(); ``` while ``` var yourString = Request.Body.AsString(); ``` is supported no more.
38,443,125
This Excel formula below can return the last value in row 1. I wonder how does it work. Especially, I don't understand the purpose of using `MATCH(MAX(1:1),1:1,1)-1` in the formula. ``` =OFFSET(A1,0,MATCH(MAX(1:1),1:1,1)-1) ```
2016/07/18
[ "https://Stackoverflow.com/questions/38443125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5700717/" ]
In new versions of NancyFx (1.4+) you can use this solution: ``` using Nancy.IO; ... var yourString = RequestStream.FromStream(Request.Body).AsString(); ``` while ``` var yourString = Request.Body.AsString(); ``` is supported no more.
For query params you can use Nancy's Request object on the module. ``` var queryParam = this.Request.Query.ParamName; ``` For an actual post body you can use ``` this.Bind(); ``` Which will create a dynamic with the properties specified in the body.
17,297,101
I am trying to create a histogram using GSL. I get a problem when I try to add to the histogram the value of the division 1470/100. This results in 14.69999999 and when added to the histogram it gets rounded to the lower bin. My question is how can i make 1470/100 result in 14.7 and not 14.69999? Thank you Edit: ``` ...
2013/06/25
[ "https://Stackoverflow.com/questions/17297101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075551/" ]
This is a floating point precision issue. A good way to solve is to set the histrogram points just off the integral values, e.g. `15 - e` where `e` is of the order 10-6.
Yes, Adding 1e-6 usually works, but in general you have to be more careful when truncating float. [This blog](http://blog.frama-c.com/index.php?post/2013/05/02/nearbyintf1) explain all the problems you can face if you want to round float numbers (and also the pitfalls of naive solutions). It also suggest the follow...
18,737,718
I have a screen with animation in my WPF application. I need the animation to run only onceper user session. This means that if a user sees the screen with the animation the first time, it would play, but when the user comes back to it it will be in its final state (skipped to end). I have a boolean value in my ViewMo...
2013/09/11
[ "https://Stackoverflow.com/questions/18737718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1176547/" ]
Rake is a "[software task management tool](http://en.wikipedia.org/wiki/Rake_%28software%29)", similar to Make, etc. in other systems. See: <http://guides.rubyonrails.org/command_line.html#rake> > > Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility 'make', and uses a 'Rakefile' and .rake fi...
Rake utility allows you to create a job/task which uses rails environment. So say, you want to count the votes a user has given to an article and save it somewhere. You write a rake job, in which you can use Rails models and other helpers and get it done without going away from Rails.
24,291,960
I'm trying to read a CSV file from an FTP server and parse it on app engine. I can access the file and read it to `StringIO` but when I try to loop over the files lines it just loops over every character instead of lines. Not sure what I'm doing wrong here: ``` ftp = FTP('ftp.mydomain.com', 'username', 'pwd') ftp.set_...
2014/06/18
[ "https://Stackoverflow.com/questions/24291960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/258564/" ]
Split the long string on newlines; `csv.reader()` expects an *iterable*, where each iteration a line is yielded. You are giving it a string, iteration is over individual characters then: ``` csvfile = csv.reader(r.getvalue().splitlines(), delimiter=',') ``` You don't show how `StringIO()` was imported. If it is the ...
For Python 3.x and csv.DictReader: ``` bio = io.BytesIO() resp = ftp.retrbinary("RETR " + filename, bio.write) bio.seek(0) csv_data = csv.DictReader(io.TextIOWrapper(bio, newline=None), delimiter=',') for row in data: ... ``` It took me a while to find this solution so I'm posting it. The answers I found did not...
6,384,360
I'm trying an update with a conditional sub-select which could return null... ``` UPDATE aTable SET aColumn = ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END FROM ...
2011/06/17
[ "https://Stackoverflow.com/questions/6384360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192999/" ]
``` ... aColumn = ISNULL( ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END FROM ...
``` UPDATE A SET aColumn = B.Value FROM aTable AS A CROSS JOIN ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3...
6,384,360
I'm trying an update with a conditional sub-select which could return null... ``` UPDATE aTable SET aColumn = ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END FROM ...
2011/06/17
[ "https://Stackoverflow.com/questions/6384360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192999/" ]
``` ... aColumn = ISNULL( ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END FROM ...
``` UPDATE aTable SET aColumn = s.Value FROM ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END AS Value FROM bTable WHERE bTable = @someCriteria ...
6,384,360
I'm trying an update with a conditional sub-select which could return null... ``` UPDATE aTable SET aColumn = ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END FROM ...
2011/06/17
[ "https://Stackoverflow.com/questions/6384360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192999/" ]
``` UPDATE A SET aColumn = B.Value FROM aTable AS A CROSS JOIN ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3...
``` UPDATE aTable SET aColumn = s.Value FROM ( SELECT TOP 1 CASE WHEN bTable.someColumn = 1 THEN someValue1 WHEN bTable.someColumn = 2 THEN someValue2 ELSE someValue3 END AS Value FROM bTable WHERE bTable = @someCriteria ...
73,162,726
How do I create a time interval for pizza spawning? During the game time for every 15s start spawning pizza for 5 seconds and stop, then start spawning pizza again after 15s ``` IEnumerator SpawnPizzaCoroutine() { while (true) { int spawnPointX = Random.Range(-18, -5); in...
2022/07/29
[ "https://Stackoverflow.com/questions/73162726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14064508/" ]
You just need to keep track of the elapsed time between pizzas in a float type variable ``` private bool spawningPizza; private float nextSpawnTime; private void Start() { StartCoroutine(SpawnPizzaCoroutine()); } private IEnumerator SpawnPizzaCoroutine() { while (true) { nextSpawnTime += Time.del...
You can use the `InvokeRepeating` for that purpose. Have a look here: <https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html> You could execute the function every 20 seconds then your coroutine for 5 seconds. The result would be, that you spawn pizzas for 5 seconds and after 15 seconds another 5 ...
73,162,726
How do I create a time interval for pizza spawning? During the game time for every 15s start spawning pizza for 5 seconds and stop, then start spawning pizza again after 15s ``` IEnumerator SpawnPizzaCoroutine() { while (true) { int spawnPointX = Random.Range(-18, -5); in...
2022/07/29
[ "https://Stackoverflow.com/questions/73162726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14064508/" ]
You just need to keep track of the elapsed time between pizzas in a float type variable ``` private bool spawningPizza; private float nextSpawnTime; private void Start() { StartCoroutine(SpawnPizzaCoroutine()); } private IEnumerator SpawnPizzaCoroutine() { while (true) { nextSpawnTime += Time.del...
I would use [`InvokeRepeating`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.InvokeRepeating.html) for such a scenario. That calls a method for every x seconds. ``` public class PizzaMaker: MonoBehaviour { public GameObject pizza; void Start() { InvokeRepeating("makePizza", 15f, 15f); ...
21,955,488
I have a game that stores boss kills on easy and hard modes in a MySQL database. There are 14 bosses. I want to store the number of times a player has killed a boss and at what difficulty. I have a few options that I can see.. Option 1 -------- Create an individual column in the table for each boss as well as for eac...
2014/02/22
[ "https://Stackoverflow.com/questions/21955488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/532606/" ]
The third option is the best one by far. The second one is something you should always avoid, you can read [this answer](https://stackoverflow.com/a/21651206/2357411) for more information, but basically, you have to look for database normalization, and that approach is not normalized: > > First normal form (1NF) is...
The first option is not good as you cannot easily add difficulties or bosses. You will need to change the database schema everytime that you want to add a new boss or difficulty The second option is not good as you will not be able to run easily sql statements and find for example which player has the most kills on bo...
32,234,009
I am being asked by my QA team to give them different APKs pointing to different servers and they can install all of them on the same device so that they can compare it side by side. I know it's impossible to have multiple APKs on the device without changing the package name. But then since the app uses services like...
2015/08/26
[ "https://Stackoverflow.com/questions/32234009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/991198/" ]
Have a debug-only screen where they can select the server to connect to...
As per suggested by @Buddy you can do. But I suggest you to take Two device and check side by side . As there no tool that can do that.
32,234,009
I am being asked by my QA team to give them different APKs pointing to different servers and they can install all of them on the same device so that they can compare it side by side. I know it's impossible to have multiple APKs on the device without changing the package name. But then since the app uses services like...
2015/08/26
[ "https://Stackoverflow.com/questions/32234009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/991198/" ]
Have a debug-only screen where they can select the server to connect to...
**My team has 3 servers:** 1. Live server 2. Smoke server 3. Staging server All three has the same code but different database and API. So When I release APK for testing I just change the **applicationId** in my `build.gradle` **Example:** For live server: ``` android { compileSdkVersion 'Google Inc.:Glass Develo...
12,582,710
I have an issue that only affect Chrome. Furthermore its only visible when the screen is at certain widths. I've created a fiddle that can replicate the issue. <http://jsfiddle.net/T8LvA/63/> When you rollover the red box the width of the parent is animated to reveal more of the red box. You may need to adjust the ...
2012/09/25
[ "https://Stackoverflow.com/questions/12582710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/963903/" ]
Use `float:right` instead of positioning it absolutely. <http://jsfiddle.net/T8LvA/70/> It happens because when you change the width, it extends to the right - then it's reflowed and moves back to the left to the correct position, which causes the wobble. Floating it to the right always keeps it there. To clarify: y...
if you use postion you need use `left` and `top`, in this case it is useless. Try fx you css in this way ``` #wrapper{ width: 100%; // was 600px height: 100px; margin: 0 auto; //position: relative; } ```
35,353,350
I am trying to include an AlertDialog builder within a method that prompts for a pin code and when the positive button is pressed, checks it against a database value and returns a true or false value to the method caller. For example: Adding/editing/deleting a user task requires a pin code. I don't want to generate a ...
2016/02/12
[ "https://Stackoverflow.com/questions/35353350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3113200/" ]
You can create your own method to generate dialog with listener: ``` public void isCorrectPin(Context context, String title, String message, String btnPositive, final DialogSingleButtonListener dialogSingleButtonListener) { final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); dialogBuild...
A dialog can't "return" a value in the way that it looks like you're expecting. A dialog can make changes to some other object, but you can't have a bit of code block on it and wait for the user to finish interacting with it. Instead, you'll need to set up listeners for when the prompt dialog is [dismissed](http://dev...