qid
int64
1
74.7M
question
stringlengths
0
70k
date
stringlengths
10
10
metadata
sequence
response
stringlengths
0
115k
24,210
I rooted and modded my Samsung Prevail (Gingerbread) a couple weeks ago, and all is going well there. However, I am now getting notices about an OTA system update, which I have no intention of installing. I will wait for the makers of my mod to produce a parallel version. In the meantime, is there any way to kill the constant notices about the update?
2012/06/14
[ "https://android.stackexchange.com/questions/24210", "https://android.stackexchange.com", "https://android.stackexchange.com/users/11910/" ]
On my S2 running ICS, there are options available for notification as well as downloading via Wi-Fi. Look under SETTINGS > ABOUT PHONE > SOFTWARE UPDATE If you don't have such options and you have a rooted phone, use software like Titanium Backup to FREEZE the software update module.
6,216,979
I'm trying to use sprof to profile some software (ossim) where almost all the code is in a shared library. I've generated a profiling file, but when I run sprof, I get the following error: ``` > sprof /home/eca7215/usr/lib/libossim.so.1 libossim.so.1.profile -p > log Inconsistency detected by ld.so: dl-open.c: 612: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed! ``` The instructions I was following said that I needed libc version at least 2.5-34, I have libc version 2.12.2 (Gentoo, kernel 2.6.36-r5). I can't find any explanation as to what the error means or (more interestingly) how to fix it, the only half-relevant google results are for a bug in an old version of Skype.
2011/06/02
[ "https://Stackoverflow.com/questions/6216979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/135888/" ]
I got a bit curious since this is still broken in OpenSuse 12.x. I would have thought a bug originally reported in '09 or so would have been fixed by now. I guess nobody really uses sprof. (or maybe dl-open is so fragile that people are scared to touch it :-) The issue boils down to the \_\_RTLD\_SPROF flag used as argument to dlopen. Take any simple program that calls dlopen, or that flag to the second arg and you get the same failed assertion. I used the sample program at the bottom of <http://linux.die.net/man/3/dlopen> as an example ``` handle = dlopen(argv[1], RTLD_LAZY | __RTLD_SPROF); ``` From what I can tell from a quick look at dl-open.c, this flags short circuits some of what dl\_open does. So the r\_flag specified in the assertion doesn't get set to RT\_CONSISTENT.
10,270,902
For example ``` function Model(){}; var model = new Model(); ko.applyBinding(model); model.name = ko.observable('john'); ``` I know the code will not work but is it possible to make it work ?
2012/04/22
[ "https://Stackoverflow.com/questions/10270902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/325661/" ]
I was able to accomplish this by using cleanNode and then reapplying the bindings. ``` function Model(){}; var model = new Model(); ko.applyBindings(model); model.name = ko.observable('john'); var myDiv = $('#myDiv')[0]; ko.cleanNode(myDiv); ko.applyBindings(model, myDiv); <div id="myDiv"> <span data-bind="text: name"></span> </div> ```
2,940,656
I have come across a sum of the following form; $$\sum\_{n=0}^{\infty}\sum\_{m=0}^{\infty}\sum\_{l=0}^{\min(n,m)}a\_{l}b\_{m-l}c\_{n-l}$$ and want to simplify it (in particular to remove the $min(n,m)$). I believe (although am not 100% sure), that it can be reduced simply to; $$\left(\sum\_{i=0}^{\infty}a\_{i}\right)\left(\sum\_{j=0}^{\infty}b\_{j}\right)\left(\sum\_{k=0}^{\infty}c\_{k}\right)$$ I have been trying to get it into the form of the Cauchy product, which for three sums reads; $$ \left(\sum\_{i=0}^{\infty}a\_{i}\right)\left(\sum\_{j=0}^{\infty}b\_{j}\right)\left(\sum\_{k=0}^{\infty}c\_{k}\right) = \sum\_{k\_{1}=0}^{\infty}\sum\_{k\_{2}=0}^{k\_{1}}\sum\_{k\_{3}=0}^{k\_{2}}a\_{k\_{1}-k\_{2}}b\_{k\_{2}-k\_{3}}c\_{k\_{3}} $$ but haven't had any luck. To deal with the $\min(n,m)$ term I have tried splitting up the sum into three parts; $n<m$, $m<n$, and $n=m$, yielding; $$ \sum\_{n=0}^{\infty}\sum\_{m=0}^{n}\sum\_{l=0}^{m-1}a\_{l}b\_{m-l}c\_{n-l} + \sum\_{m=0}^{\infty}\sum\_{n=0}^{m}\sum\_{l=0}^{n-1}a\_{l}b\_{m-l}c\_{n-l} + \sum\_{n=0}^{\infty}\sum\_{l=0}^{n}a\_{l}b\_{m-l}c\_{n-l} $$ Which is close to the Cauchy product form, but unfortunately not close enough. Any help on this would be much appreciated.
2018/10/03
[ "https://math.stackexchange.com/questions/2940656", "https://math.stackexchange.com", "https://math.stackexchange.com/users/599985/" ]
Write your sum in this way $$ \eqalign{ & \sum\limits\_{n = 0}^\infty {\sum\limits\_{m = 0}^\infty {\sum\limits\_{l = 0}^{\min \left( {n,m} \right)} {a\_{\,l} \;b\_{\,m - l} \;c\_{\,n - l} } } } = \cr & = \sum\limits\_{\left( {l,m,n} \right)\; \in \;C} {a\_{\,l} \;b\_{\,m - l} \;c\_{\,n - l} } \quad \left| {\;C = \left\{ {\left( {l,m,n} \right)} \right\}:\left\{ \matrix{ 0 \le l \le \min (n,m) \hfill \cr 0 \le m \hfill \cr 0 \le n \hfill \cr} \right.} \right. \cr} $$ Then $$ \eqalign{ & \left\{ \matrix{ 0 \le l \le \min (n,m) \hfill \cr 0 \le m \hfill \cr 0 \le n \hfill \cr} \right. = \left\{ \matrix{ 0 \le m < n \hfill \cr 0 \le l \le m \hfill \cr} \right.\; \cup \;\left\{ \matrix{ 0 \le n \le m \hfill \cr 0 \le l \le n \hfill \cr} \right. = \cr & = \left\{ {0 \le l \le m < n} \right\}\; \cup \;\left\{ {0 \le l \le n \le m} \right\} = \cr & = \left\{ \matrix{ 0 \le l \hfill \cr 0 \le m - l < n - l \hfill \cr 1 \le n - l \hfill \cr} \right.\;\; \cup \;\;\left\{ \matrix{ 0 \le l \hfill \cr 0 \le n - l \le m - l \hfill \cr 0 \le m - l \hfill \cr} \right. \cr} $$ and the two sets are cearly disjoint. Thereafter $$ \eqalign{ & \sum\limits\_{\left( {l,m,n} \right)\; \in \;C} {a\_{\,l} \;b\_{\,m - l} \;c\_{\,n - l} } = \sum\limits\_{\left( {l,m,n} \right)\; \in \;C\_{\,1} } {a\_{\,l} \;b\_{\,m - l} \;c\_{\,n - l} } + \sum\limits\_{\left( {l,m,n} \right)\; \in \;C\_{\,2} } {a\_{\,l} \;b\_{\,m - l} \;c\_{\,n - l} } = \cr & = \sum\limits\_{0\, \le \,l} {\;\sum\limits\_{1\, \le \,k} {\;\sum\limits\_{0\, \le \,j\, < \,k} {a\_{\,l} \;b\_{\,j} \;c\_{\,k} } } } + \sum\limits\_{0\, \le \,l} {\;\sum\limits\_{0\, \le \,j} {\,\sum\limits\_{0\, \le \,k\, \le \,j} {a\_{\,l} \;b\_{\,j} \;c\_{\,k} } } } = \cr & = \left( {\sum\limits\_{0\, \le \,l} {a\_{\,l} \;} } \right)\left( {\sum\limits\_{1\, \le \,k} {\;c\_{\,k} \sum\limits\_{0\, \le \,j\, < \,k} {\;b\_{\,j} \;} } + \sum\limits\_{0\, \le \,j} {\,b\_{\,j} \sum\limits\_{0\, \le \,k\, \le \,j} {\;\;c\_{\,k} } } } \right) = \cr & = \left( {\sum\limits\_{0\, \le \,l} {a\_{\,l} \;} } \right)\left( {\sum\limits\_{0\, \le \,j\, < \,k} {b\_{\,j} \;c\_{\,k} } + \sum\limits\_{0\, \le \,k\, \le \,j} {b\_{\,j} \;c\_{\,k} } } \right) = \cr & = \left( {\sum\limits\_{0\, \le \,l} {a\_{\,l} \;} } \right)\left( {\sum\limits\_{0\, \le \,j\,,\,\,k} {b\_{\,j} \;c\_{\,k} } } \right) = \cr & = \left( {\sum\limits\_{0\, \le \,l} {a\_{\,l} \;} } \right)\left( {\sum\limits\_{0\, \le \,j} {b\_{\,j} } } \right) \left( {\sum\limits\_{0\, \le \,\,k} {c\_{\,k} } } \right) \cr} $$ result that we could also obtain continuing to manipulate the set of inequalities above.
37,314,831
I saw a lot of question **How to align a div horizontally and vertically center** and i got a answer also. The code which i got: Html- ``` <div class="outer"> <div class="middle"> <div class="inner"> <div align="center"> <h1>The Content</h1> <p>Once upon a midnight dreary...</p> </div> </div> </div> </div> ``` Css- ``` .outer { display: table; position: absolute; height: 100%; width: 100%; } .middle { display: table-cell; vertical-align: middle; } .inner { margin-left: auto; margin-right: auto; background: blue; /*gave blue to know the height and width*/ } ``` And i got it correctly. But i am not able to give a default height to it. When i give `width: 50%;` and `height: 50%;` to `class="inner"` only the width is being accepted. I am not even able to give padding space between top and bottom. Please help. **Please don't give me another code to align a div vertically and horizontally center**
2016/05/19
[ "https://Stackoverflow.com/questions/37314831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6349060/" ]
What (I think) you want, is this : ```css body { margin : 0; } .outer { display: table; position: absolute; height: 100%; width: 100%; } .middle { display: table-cell; vertical-align: middle; text-align: center; } .inner { display: inline-block; width: 50%; height: 50%; background: blue; } ``` ```html <div class="outer"> <div class="middle"> <div class="inner"> <h1>The Content</h1> <p>Once upon a midnight dreary...</p> </div> </div> </div> ``` See also [**this Fiddle**](https://jsfiddle.net/pf4ayt7c/2/)!
27,066,174
**Input:** Say I have two DataTables. The first one: ``` ID Date ValueA ValueB 1 Nov.21 72.4 23.4 1 Nov.22 71.4 24.4 2 Nov.21 74.4 21.4 ``` The second one: ``` ID Date ValueC ValueD 1 Nov.21 42.4 53.4 1 Nov.22 41.4 54.4 2 Nov.21 44.4 51.4 ``` **What I tried:** I tried to do `DataTable1.Merge(DataTable2);`, but I get this: ``` ID Date ValueA ValueB ValueC ValueD 1 Nov.21 72.4 23.4 1 Nov.22 71.4 24.4 2 Nov.21 74.4 21.4 1 Nov.21 42.4 53.4 1 Nov.22 41.4 54.4 2 Nov.21 44.4 51.4 ``` **Desired result:** I'd like to combine rows, if their ID and Date match. I want this: ``` ID Date ValueA ValueB ValueC ValueD 1 Nov.21 72.4 23.4 42.4 53.4 1 Nov.22 71.4 24.4 41.4 54.4 2 Nov.21 74.4 21.4 44.4 51.4 ```
2014/11/21
[ "https://Stackoverflow.com/questions/27066174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1032613/" ]
You can use LINQ to join the two DataTables based on `ID` and `Date` and then project/Load the results into a resultant DataTable using [`LoadDataRow`](http://msdn.microsoft.com/en-us/library/system.data.datatable.loaddatarow%28v=vs.110%29.aspx) method like: ``` DataTable dtResult = new DataTable(); var query = from row1 in dt1.AsEnumerable() join row2 in dt2.AsEnumerable() on new { ID = row1.Field<int>("ID"), Date = row1.Field<DateTime>("Date") } equals new { ID = row2.Field<int>("ID"), Date = row2.Field<DateTime>("Date") } select dtResult.LoadDataRow(new object[] { row1.Field<int>("ID"), row1.Field<DateTime>("Date"), row1.Field<double>("ValueA"), row1.Field<double>("ValueB"), row2.Field<double>("ValueC"), row2.Field<double>("ValueD") }, false); ``` Make sure that the types specified with [`Field`](http://msdn.microsoft.com/en-us/library/bb360891%28v=vs.110%29.aspx) extension method matches with that of your columns in `DataTable`.
18,404,675
I have a block of code that connects to a remote server, passes a few variables to it, and then queries data on the server and then manipulates it. This code works exactly as I would expect it, producing the data I need. However, I need to run the code in a macro loop. This is where it all breaks down. I'm not sure what the issue is, but I suspect it is some sort of variable scope problem. I have tried to research doing this online, but cannot figure it out. The problem occurs in the `data xtemp2` block. When I try to run this, I get the following errors: ``` WARNING: Apparent symbolic reference INTERVAL_SECONDS not resolved. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, INPUT, PUT. ``` and ``` WARNING: Apparent symbolic reference START_TIME not resolved. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, INPUT, PUT. ``` Please also note that I sometimes get similar errors with `rtime`, `iprice`, `oprice`, and `itime`. Once again, this code works perfectly well when I run it by itself. Putting it into a macro with a loop seems to generate these problems, which makes me think I am not initializing these variables properly. I would really appreciate any insight and tips you could provide. ``` %macro getthedata(nrows,ystart,yend); *nrows is the number of rows in the text file; %do i=1 %to &nrows; %do m=&ystart %to &yend; (...) signon username=_prompt_; %syslput VAR1 = &var1; %syslput M = &m; rsubmit; libname abc'/data/sasdata'; *Thisis where the datasets are located; %let start_time = '9:30:00't; * starting time; %let interval_seconds =15*60; * interval is 15*60 seconds, 15min; data all2009; set sas.a_&M.01:; by symbol date time; where symbol = &VAR1 and time between '9:30:00't and '16:00:00't; run; data xtemp2; set all2009; by symbol date time; format itime rtime time12.; if first.symbol=1 or first.date=1 then do; *Initialize time and price when new symbol or date starts; rtime=time; iprice=bid; oprice=ofr; itime=&start_time; end; if time >= itime then do; *Intervalreached; output; *rtime and iprice hold the last observation values; itime = itime +&interval_seconds; do while(time >= itime); *need to fill in alltime intervals; output; itime = itime +&interval_seconds; end; end; rtime=time; iprice=bid; oprice=ofr; retain itime rtime iprice oprice; *Carry time and price valuesforward; *keep symbol date itime iprice rtime; run; proc download data=all2009 out=local.all30 (keep=SYMBOL DATE PRICE SIZE itime); run; endrsubmit; (...) %end; %end; %mend getthedata; Options MPRINT; %getthedata(3,2007,2007) ``` **SOLUTION** (per Joe's Answer) I was able to successfully create the `interval_seconds` and `start_time` variables using the `%NRSTR` solution Joe posted. Here is the relevant modified code section: ``` (...) signon username=_prompt_; %syslput VAR1 = &var1; %syslput M = &m; rsubmit; libname abc'/data/sasdata'; *Thisis where the datasets are located; %nrstr(%%)let start_time = '9:30:00't; * CHANGED LINE; %nrstr(%%)let interval_seconds =15*60; * CHANGED LINE; data all2009; set sas.a_&M.01:; by symbol date time; where symbol = &VAR1 and time between '9:30:00't and '16:00:00't; run; (...) ```
2013/08/23
[ "https://Stackoverflow.com/questions/18404675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2537307/" ]
I am not sure if this will help, but here is some example code of how to use the function itself. I pretty much used [Microsoft's MSDN](http://msdn.microsoft.com/en-us/library/aa376990%28v=vs.85%29.aspx) and [Pinvoke](http://www.pinvoke.net/default.aspx/setupapi.SetupCopyOEMInf) to knock up some quick code. ``` [DllImport("setupapi.dll", SetLastError = true)] public static extern bool SetupCopyOEMInf( string SourceInfFileName, string OEMSourceMediaLocation, OemSourceMediaType OEMSourceMediaType, OemCopyStyle CopyStyle, string DestinationInfFileName, int DestinationInfFileNameSize, ref int RequiredSize, string DestinationInfFileNameComponent ); /// <summary> /// Driver media type /// </summary> internal enum OemSourceMediaType { SPOST_NONE = 0, //Only use the following if you have a pnf file as well SPOST_PATH = 1, SPOST_URL = 2, SPOST_MAX = 3 } internal enum OemCopyStyle { SP_COPY_NEWER = 0x0000004, // copy only if source newer than or same as target SP_COPY_NEWER_ONLY = 0x0010000, // copy only if source file newer than target SP_COPY_OEMINF_CATALOG_ONLY = 0x0040000, // (SetupCopyOEMInf only) don't copy INF--just catalog } static void Main(string[] args) { //Not really needed but I couldn't figure out how to not specify a ref parameter int size = 0; bool success = SetupCopyOEMInf("source.inf", "", OemSourceMediaType.SPOST_NONE, OemCopyStyle.SP_COPY_NEWER, null, 0, ref size, null); if(!success) { var errorCode = Marshal.GetLastWin32Error(); var errorString = new Win32Exception(errorCode).Message; Console.WriteLine(errorString); Console.ReadLine(); } } ``` Assuming your INF file is completely correct with the proper destination directories specified, this function will also try and copy any files that you have specified via the CopyFiles directive (in the INF file) to those destination directories. If the file doesnt exist, the command will fail. One other problem I had was that the function should copy your INF and CAT files to the destination directory specified (I specified an ID of 12, which is [documented](http://msdn.microsoft.com/en-us/library/windows/hardware/ff540023%28v=vs.85%29.aspx) as %windir%\system32\drivers) but instead it copied it to %windir%\system32\DriverStore\FileRepository\source.inf\_amd64\_neutral\_blah. This was probably due to the fact I was testing with an inf file I created by hand and was missing required information. Hope this helps you a bit :)
2,789,116
I have been fighting some code for about a week, and am hoping that someone else may have experienced this problem and can point me in the right direction. I am using the `MPMoviePlayerViewController` to play a video on the iPad. The primary problem is that it works FLAWLESSLY on the iPad Simulator, but will not play at all on the iPad. I have tried re-encoding the video to make sure that isn't an issue. The video I'm using is currently a 480x360 video encoded with **H.264 Basline 3.0 with AAC/LC audio**. The video plays fine on the iPhone, and also does play through Safari on the iPad. The video actually loads, and you can scrub through the video with the scrubber bar and see that it is there. The frames actually display, but just will not play. If you click play, it just immediately stops. Even when I have `mp.moviePlayer.shouldAutoplay=YES` set, you can see the player attempt to play, but only for a split second (maybe 1 frame?). I have tried just adding view with the following code: ``` in .h ------ MPMoviePlayerViewController *vidViewController; @property (readwrite, retain) MPMoviePlayerViewController *vidViewController; in .m ------ MPMoviePlayerViewController *mp=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]]; [mp shouldAutorotateToInterfaceOrientation:YES]; mp.moviePlayer.scalingMode=MPMovieScalingModeAspectFit; mp.moviePlayer.shouldAutoplay=YES; mp.moviePlayer.controlStyle=MPMovieControlStyleFullscreen; [videoURL release]; self.vidViewController = mp; [mp release]; [self.view addSubview:vidViewController.view]; float w = self.view.frame.size.width; float h = w * 0.75; self.vidViewController.view.frame = CGRectMake(0, 0, w, h); ``` I have also just tried to do a: ``` [self presentMoviePlayerViewControllerAnimated:self.vidViewController]; ``` which I actually can not get to orient properly...always shows up in Portrait and almost completely off the screen on the bottom, and the app is only intended to run in either of the Landscape views... If anybody needs more info, just let me know. I'm about at my wits end on this. ANY help will be GREATLY appreciated.
2010/05/07
[ "https://Stackoverflow.com/questions/2789116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/334557/" ]
I see 2 problems here. First you are not setting the frame of the view. Try adding `mp.view.frame = self.view.frame;` This is what fixed it for me. Next the `shouldAutorotateToInterfaceOrientation` does not need to be called. This method simply tells you if the view supports an orientation. Check the Apple docs.
103,467
What is the command `env ls -al` doing? I had a Linux test and there was question: "How to run command directly, but not its alias?" I knew that there exists solution like prefixing command with some special symbol, but I forgot it. Now I know that it is `\`. (read from [this post](https://unix.stackexchange.com/questions/39291/run-a-command-that-is-shadowed-by-an-alias)). But I also remember that somewhere I read that to get rid of alias we can prefix a command with `env`. I did it and it seems works, but my answer was qualified as wrong. I read `info` and `man` on `env`, but didn't understood too much. What is `env` doing and exactly in `env <command>` without any arguments for `env` itself?
2013/12/03
[ "https://unix.stackexchange.com/questions/103467", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/52093/" ]
This command ``` env name=value name2=value2 program and args ``` runs the command `program and args` with an environment formed by extending the current environment with the environment variables and values designated by `name=value` and `name2=value2`. If you do not include any arguments like `name=value`, then the current environment is passed along unmodified. The key thing that happens with respect to aliases is that *env* is an external command, so it has no “knowledge” of aliases: aliases are a shell construct that are not part of the normal process model and have no impact on programs that are directly run by non-shell programs (like *env*). *env* simply passes the `program and arguments` to an *exec* call (like *execvp*, which will search the PATH for `program`). Basically, using *env* like this is a (mostly) shell-independent way of avoiding aliases, shell functions, shell builtin commands, and any other bits of shell functionality that might replace or override command-position arguments (i.e. program names)—unless, of course, `env` is an alias, or shell function! If you are worried about `env` being an alias, you could spell out the full path (e.g. `/usr/bin/env`, though it may vary).
56,674,465
configure: error: "libevent not found" when installing tmux I downloaded the tmux tarball and trying to install it. I cannot connect to git on the server i am trying to install. This for a new Red Hat Enterprise Linux Server release 6.5 (Santiago) server. I am new to Linux and never did installation as a root :) ``` [tmux-master]# ./configure && make ... configure: error: "libevent not found" ``` Can you please suggest me how to get it working?
2019/06/19
[ "https://Stackoverflow.com/questions/56674465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7699279/" ]
The `route()` function expects a single parameter that matches a **named** route. Currently, you don't have a named one. Either use the `url()` function: ``` <a href="{{ url("/download") }}">...</a> ``` or name your route: ``` Route::get("/download", ...)->name("download"); ```
9,301,569
I'm trying a [Spring 3.x tutorial](https://src.springframework.org/svn/spring-samples/mvc-basic) on Eclipse 3.7 with m2e and Maven Integration for WTP plugins installed. I converted the above tutorial to Maven Project, but when i deploy the web application i get the following exception: ``` Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/Level ``` My pom.xml look like this: ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.springframework.samples</groupId> <artifactId>mvc-basic</artifactId> <name>mvc-basic</name> <packaging>war</packaging> <version>1.0.0-SNAPSHOT</version> <properties> <org.springframework.version>3.0.5.RELEASE</org.springframework.version> <org.slf4j.version>1.6.1</org.slf4j.version> </properties> <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework.version}</version> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${org.slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${org.slf4j.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <scope>runtime</scope> </dependency> <!-- JSR 303 with Hibernate Validator --> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.1.0.Final</version> </dependency> <!-- Joda Time --> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>1.6.2</version> <scope>runtime</scope> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time-jsptags</artifactId> <version>1.0.2</version> <scope>runtime</scope> </dependency> <!-- Servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- Test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.7</version> <scope>test</scope> </dependency> </dependencies> <repositories> <!-- For Hibernate Validator --> <repository> <id>org.jboss.repository.release</id> <name>JBoss Maven Release Repository</name> <url>https://repository.jboss.org/nexus/content/repositories/releases</url> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> <showWarnings>true</showWarnings> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <warName>mvc-basic</warName> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>install</id> <phase>install</phase> <goals> <goal>sources</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> ``` I also checked in 'Project Properties' -> 'Java Build Path' -> 'Libraries' but the only log4j jar that i found is the one under 'Maven Dependencies' Seems like i'm messing with jars but i can't find a solution by myself.
2012/02/15
[ "https://Stackoverflow.com/questions/9301569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1212327/" ]
Even if you did have a path (some browsers used to give it to you), there is no way to set the path of a input of type file. Therefore, it is not possible to do what you want with plain JS and the DOM. I said it wasn't possible, but now that you asked I do think there is a way, with new File API. The following steps outline what needs to be done, but have in no way been tested, and I don't expect it to work, it's just to show you the way, also global variables are bad, it's just the simplest way to show you. Here's a good page with examples on using the File API <http://www.html5rocks.com/en/tutorials/file/dndfiles/> **First** You need an input of type file, then you can use once a user selects a file, you are given access to the File object. <http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader> ``` <input type="file" id="files" name="files[]" multiple /> <script> var fileBlobs = []; function handleFileSelect(evt) { var files = evt.target.files; // FileList object // files is a FileList of File objects. You may now read their contents var reader = new FileReader(); for (var i = 0, f; f = files[i]; i++) { fileBlobs.push(reader.readAsBinaryString(f)); } } document.getElementById('files').addEventListener('change', handleFileSelect, false); </script> ``` **Second** Now you have the content as a binary string. You can use the File API to store the file locally in a way that you can access later using the FileWriter and FileSaver interfaces <http://dev.w3.org/2009/dap/file-system/file-writer.html> ``` var bb = new BlobBuilder(); bb.appendfileBlobs.(fileBlobs[0]); window.saveAs(bb.getBlob(), "test_file"); ``` **Third** You need to make an Ajax request passing that blob to the server, tracking how much of the upload is complete. <http://www.w3.org/TR/XMLHttpRequest/#the-upload-attribute>. It doesn't look like tracking progress can be done on the client. Your may have to poll the server for actual progress. A possible solution to know where to start an interrupted upload is to have upload ids and when you restart an upload, you ask the server how much of the file has been uploaded. Sorry I can't provide a full answer, but this is not an easy problem. The steps I gave you should take you in the right direction.
49,888,859
i have a database for university so the students take many courses but each student have id as primary key also each course have an id as primary key its not allowed to have duplicate id at same table what should i use to make a table that same id but different courses id
2018/04/17
[ "https://Stackoverflow.com/questions/49888859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7158597/" ]
Use unambiguous word boundaries, `(?<!\w)` and `(?!\w)`, instead of `\b` that are context dependent: ``` from = "(?<!\\w)" + Pattern.quote(from) + "(?!\\w)"; ``` See the [**regex demo**](https://regex101.com/r/zqaHVr/1). The `(?<!\w)` is a negative lookbehind that fails the match if there is a non-word char immediately to the left of the current location and `(?!\w)` is a negative lookahead that fails the match if there is a non-word char immediately to the right of the current location. The `Pattern.quote(from)` is necessary to escape any special chars in the `from` variable. See the [Java demo](https://ideone.com/3TG8qM): ``` String line = "add, $temp4, $temp40, 42"; String to = "register1"; String from = "$temp4"; String outString; from = "(?<!\\w)" + Pattern.quote(from) + "(?!\\w)"; outString = line.replaceAll(from, to); System.out.println(outString); // => add, register1, $temp40, 42 ```
179,803
I am working on creating a theme from scratch for Drupal 8 and I am 90% of the way there. I do have a question on how to access variables in the ``` {{ dump() | raw }} ``` I have created a page.html.twig and the {{ page.BLOCKNAME }} is working great. But when I try to place {{ title }}, or any variations, I get NULL or nothing at all. I can see the title in the dump(), but it has ["string":protected]=> so I am not able to access. I was able to create a new block region and move the title there, but the title will not be in the same place from page to page. I would also like to access the content type, node ID, and node url, with some other custom fields I created, but I can't seem to get to those either. In summary, how do I use the dump() and actually get to the variables that are presented?
2015/11/04
[ "https://drupal.stackexchange.com/questions/179803", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/53986/" ]
If you wanna see all variables available in your twig template file in Drupal 8 use `{{ kint(_context) }}`. Don't forget, you must enable kint in devel module settings.
27,578,967
This question is related with my previous [question](https://stackoverflow.com/questions/27577922/how-to-pass-a-json-array-as-a-parameter-in-url) I can successfully get the String in json format from the URL to my spring controller Now I have to decode it so I did like the following ``` @RequestMapping("/saveName") @ResponseBody public String saveName(String acc) {jsonObject = new JSONObject(); try { System.out.println(acc); org.json.JSONObject convertJSON=new org.json.JSONObject(acc); org.json.JSONObject newJSON = convertJSON.getJSONObject("nameservice"); System.out.println(newJSON.toString()); convertJSON = new org.json.JSONObject(newJSON.toString()); System.out.println(jsonObject.getString("id")); } catch(Exception e) { e.printStackTrace();jsonObject.accumulate("result", "Error Occured "); } return jsonObject.toString(); } ``` This is the JSON String `{ "nameservice": [ { "id": 7413, "name": "ask" }, { "id": 7414, "name": "josn" }, { "id": 7415, "name": "john" }, { "id": 7418, "name": "RjhjhjR" } ] }` When I run the code then I get the error ``` org.json.JSONException: JSONObject["nameservice"] is not a JSONObject. ``` What wrong I am doing?
2014/12/20
[ "https://Stackoverflow.com/questions/27578967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3237679/" ]
It's not a `JSONObject`, it's a `JSONArray` From your question: ``` { "nameservice": [ { "id": 7413, "name": "ask" }, { "id": 7414, "name": "josn" }, { "id": 7415, "name": "john" }, { "id": 7418, "name": "RjhjhjR" } ] } ``` The `[` after the nameservice key tells you it's an array. It'd need to be a `{` to indicate an object, but it isn't So, change your code to use it as a `JSONArray`, then iterate over the contents of that to get the `JSONObjects` inside it, eg ``` JSONArray nameservice = convertJSON.getJSONArray("nameservice"); for (int i=0; i<nameservice.length(); i++) { JSONObject details = nameservice.getJSONObject(i); // process the object here, eg System.out.println("ID is " + details.get("id")); System.out.println("Name is " + details.get("name")); } ``` See the [JSONArray javadocs](http://www.json.org/javadoc/org/json/JSONArray.html) for more details
44,278,653
I'm trying to use overlay effect for the images, but I'm not able to fit it exactly to the size of the image. here is my link to code pen: <https://codepen.io/saisree/pen/OmKMgm> ``` <div class="row"> <header class="text-center sec-heading"> <h2>Meet the Family</h2> <span class="subheading">We are the ones!</span> </header> <div class="a col-lg-4 col-md-6 mb-sm-50"> <img style="height:100%;width:100%;" class="a img-responsive" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRsl7JTXK1z2ZomjuzpU49t7TlSMdYcioHrQLvHjmuM_3r5oc36" /> <div class="overlay"> <div class="text">Hello World</div> </div> </div> </div> ``` Here is the CSS:/\* . ``` .myjumbotron{ background-color: black; } */ #over img { margin-left: auto; margin-right: auto; display: block; } .jumbotron { background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRygQnWzs3GfysYKie99aTXhbYvGrS7gxQzTAFFu9DN4azC_nwz"); background-position: center; background-size: cover; } h3{ text-color:black; } #family h2{ color: black; text-decoration:none; } #Nav h3{ color: black; text-decoration:none; } /* .wrapper { position: relative; padding: 0; width:100px; display:block; } .text { position: absolute; top: 0; color:#f00; background-color:rgba(255,255,255,0.8); width: 100px; height: 100px; line-height:100px; text-align: center; z-index: 10; opacity: 0; -webkit-transition: all 0.5s ease; -moz-transition: all 0.5s ease; -o-transition: all 0.5s ease; transition: all 0.5s ease; } .text:hover { opacity:1; } img { z-index:1; } */ .text { white-space: nowrap; color: black; font-size: 20px; position: absolute; overflow: hidden; top: 50%; left: 50%; transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); } .a:hover .overlay { height: 100%; } .b:hover .overlay { height: 100%; } .overlay { position: absolute; bottom: 0; left: 0; right: 0; background-color: white; overflow: hidden; width:100%; height: 0; transition: .5s ease; } /* .team-item { display:inline-block; background:red; margin-bottom:10px; } */ ``` Any kind of help would be highly appreciated!
2017/05/31
[ "https://Stackoverflow.com/questions/44278653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4702519/" ]
I came up with a hack that mostly got me the job done. Here goes: Take the original mesh, and for every edge make a new point which is just the midpoint of this edge. Connect both the edge vertices to this midpoint to form a zero area degenerate triangle. Add this triangle, and this point to the mesh file. You guessed it, color this new vertex with the edge color. Once you fiddle with the background color settings of meshlab, you will be able to see the edge colored mesh reasonably well. (The one thing I am still trying to find out is how to increase the thickness of the lines so it appears more clear. Right now, you can just go to vertex view, and see the new points all light up nicely with the edge colors)
57,649
I have a class that always has 14 instances. I'm just wondering if there is a better or more effective way of doing this. In this class I also have an array that is filled by calling 4 functions multiple times. Because this class is instanced 14 times, the array is duplicated a lot. What would be a better way to do this? The following code is just placed at the bottom of the class file. ``` $machine1 = new machine('ZW01001', 41, "192.168.0.223"); $machine4 = new machine('ZW01004', 37, "192.168.0.216"); $machine5 = new machine('ZW01005', 28, "192.168.0.222 "); $machine6 = new machine('ZW01006', 38, "192.168.0.217"); $machine7 = new machine('ZW01007', 30, "192.168.0.16"); $machine8 = new machine('ZW01008', 31, " 192.168.0.220"); $machine9 = new machine('ZW01009', 32, "192.168.0.218"); $machine10 = new machine('ZW01010', 40, "192.168.0.221"); $machine21 = new machine('ZW01021', 13, "192.168.0.215"); $machine22 = new machine('ZW01022', 2, "192.168.0.206"); $machine23 = new machine('ZW01023', 33, "192.168.0.213"); $machine24 = new machine('ZW01024', 34, "192.168.0.227"); $machine25 = new machine('ZW01025', 35, "192.168.0.226"); $machine26 = new machine('ZW01026', 36, "192.168.0.217"); $Cycle = (object) array( 'Machines' => array( array( 'cycle' => $machine1->Cycle(), 'percent' => $machine1->GetM(), 'Data' => $machine1->Data(), 'ip' => $machine1->pingAddress(), ), array( 'cycle' => $machine4->Cycle(), 'percent' => $machine4->GetM(), 'Data' => $machine4->Data(), 'ip' => $machine4->pingAddress(), ), array( 'cycle' => $machine5->Cycle(), 'percent' => $machine5->GetM(), 'Data' => $machine5->Data(), 'ip' => $machine5->pingAddress(), ), array( 'cycle' => $machine6->Cycle(), 'percent' => $machine6->GetM(), 'Data' => $machine6->Data(), 'ip' => $machine6->pingAddress(), ), array( 'cycle' => $machine7->Cycle(), 'percent' => $machine7->GetM(), 'Data' => $machine7->Data(), 'ip' => $machine7->pingAddress(), ), array( 'cycle' => $machine8->Cycle(), 'percent' => $machine8->GetM(), 'Data' => $machine8->Data(), 'ip' => $machine8->pingAddress(), ), array( 'cycle' => $machine9->Cycle(), 'percent' => $machine9->GetM(), 'Data' => $machine9->Data(), 'ip' => $machine9->pingAddress(), ), array( 'cycle' => $machine10->Cycle(), 'percent' => $machine10->GetM(), 'Data' => $machine10->Data(), 'ip' => $machine10->pingAddress(), ), array( 'cycle' => $machine21->Cycle(), 'percent' => $machine21->GetM(), 'Data' => $machine21->Data(), 'ip' => $machine21->pingAddress(), ), array( 'cycle' => $machine22->Cycle(), 'percent' => $machine22->GetM(), 'Data' => $machine22->Data(), 'ip' => $machine22->pingAddress(), ), array( 'cycle' => $machine23->Cycle(), 'percent' => $machine23->GetM(), 'Data' => $machine23->Data(), 'ip' => $machine23->pingAddress(), ), array( 'cycle' => $machine24->Cycle(), 'percent' => $machine24->GetM(), 'Data' => $machine24->Data(), 'ip' => $machine24->pingAddress(), ), array( 'cycle' => $machine25->Cycle(), 'percent' => $machine25->GetM(), 'Data' => $machine25->Data(), 'ip' => $machine25->pingAddress(), ), array( 'cycle' => $machine26->Cycle(), 'percent' => $machine26->GetM(), 'Data' => $machine26->Data(), 'ip' => $machine26->pingAddress(), ), ) ); $fp = fopen('Rag.json', 'w'); fwrite($fp, json_encode($Cycle)); fclose($fp); ```
2014/07/22
[ "https://codereview.stackexchange.com/questions/57649", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/49466/" ]
I've often found myself in this situation (having an instance of an object, and needing an array). A couple of examples of where one might encounter this situation: * DataModels that need to be mapped to a db table (for use in queries with prepared statements) * Objects that represent data that is coming from/or will be sent to a service through an API (XML or JSON are common formats) * NoSQL databases like mongodb Either way, after blundering along and producing awful code, trying to find the best way of doing this, I've often found that extending my model from an abstract class that has a `final public function toArray()` is more than enough (9/10 times). This does require you to write classes in a disciplined fashion, which actually is a good thing, but no matter... Provided your class properties are *not* `private`, and each property has an appropriate getter, I tend to add this method: ``` final public function toArray($asBind = false) { $properties = get_object_vars($this);//only visible, non-statics $array = array(); foreach ($properties as $name => $val) { if ($asBind === true) $array[':'.$name] = $val; else $array[$name] = $val; } return $array; } ``` If you want this applied to your case, just define the four properties you need in that array as `protected` or `public`, and the rest of the properties as `private` and this'll work. Alternatively, you can add an `$arrayMap` property to the abstract level, that you call from the constructor: ``` abstract class ArrayAble { private $arrayMap = array(); final protected function setArrayMap(array $map) { $this->arrayMap = $map; return $this; } final public function toArray($asBind = false) { $array = array(); foreach ($arrayMap as $name) { if ($asBind === true) $array[':'.$name] = $this->{$name}; else $array[$name] = $this->{$name}; } return $array; } } class YourModel extends ArrayAble { protected $foo = 'array-value' private $bar = 'invisible'; public function __construct() { $this->setArrayMap(array('foo')); } } $x = new YourModel(); var_dump($x->toArray());//array('foo' => 'array-value'); ``` Ok, so we've got this working, but you've probably noticed that this requires you to *know* how the `toArray` method works, and how it does what it does. Chances are you'll forget sooner or later. If someone else starts working on this code, it becomes even more likely this will bite you. What we actually want, is for an object to behave like an array. You need a class, to offer an array-like programming interface. Enter: Interfaces ================= PHP has a couple of interfaces as standard that allow you to do just that. All of the interfaces that extend from the generic (non-usable) `Traversable` interface. The interfaces you might want to use are * `ArrayAccess`: Easy to implement, but makes object overloading dangerously easy * `Iterator`: Powerful, relatively easy, but requires some *"constructor magic"* to set up on each instance. Harder to maintain * `IteratorAggregate`: Very easy to work with, albeit at the cost of reduced performance. However: micro-optimization is the root of all evil. I'd recommend you use this interface: ``` abstract class BaseClass implements IteratorAggregate { /** * Implement interface, abstract implementation * means private properties of child remain hidden * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this); } } ``` Extend all your models from this abstract class, and you can then loop over them using a `foreach` construct: ``` class SomeClass extends Base { protected $foo = 'hello'; protected $bar = 'World'; private $spy = 'You can\'t see me!'; } $x = new SomeClass; foreach ($x as $k => $v) echo $k, ' => ', $v, PHP_EOL; //output: foo => hello bar => world ``` Notice, private properties remain hidden, if you need those to be visible, you'll have to override the `getIterator` method in the child class itself. [More details here](http://www.php.net/manual/en/class.iteratoraggregate.php) *On the `Iterator` interface:* As I've mentioned above: it's slightly trickier to implement. Looking at the PHP documentation, this would seem to be an absurd claim. However: all of the examples rely on a single array storing all the data that otherwise would have been separate properties. I won't get all boring and go into too much detail, but distinct properties are faster, safer, and enforce a coding style that gives more control/safety (through setters that check the values etc...). An example of data-models implementing the `Iterator` interface, without relying on an array to carry the actual data [is this class](https://github.com/EVODelavega/freshdesk-rest/blob/feature/composer/src/Freshdesk/Model/Base.php). It's still being developed, but [the child classes](https://github.com/EVODelavega/freshdesk-rest/tree/feature/composer/src/Freshdesk/Model) can all be traversed using a `foreach` loop. I thought I'd share this link here, in case you were thinking of implementing the `Iterator` interface somewhere down the line. Perhaps the code I put on github can serve as inspiration. Other niggles ============= Just some minor remarks on the rest of the code: * As always, I urge you, and everybody else, to subscribe to [the most widely accepted coding standard](http://www.php-fig.org). It's not official (yet), but all major players subscribe to it. As should you. * `fopen` + `fwrite` + `fclose`, as you use them could easily be replaced with `file_put_contents('file.json',json_encode($array));`. It's 1 line instead of 3. * Why create all those instances, and assign them to separate variables? I take it this is not your actual code, but in case it is: arrays are meant to hold *related data*. All these instances represent data that belongs together. Your code should reflect that. * Why are you casting the outer array (assigned to `$Cycle`) to an instance of `stdClass`? You're `json_encoding` it. Get rid of the cast, or assign the json-encoded string to `$Cycle`, write it to the file, and then write `$Cycle = json_decode($Cycle);`. Decoding has the advantage of creating objects recursively (a cast only casts the outer array to an object). * Use meaningful names, for variables, properties, *and* methods: `$machine21->Data()` doesn't mean *anything* to me.
19,485,977
I have a javascript var that returns the value of a input text ID "ven\_prod", with the value of "ven\_prod" I need to make a search in my database without submiting the page. I can't use a javascript var in the java code, so i've setted the value in a hidden input text ID "prod\_hidden", but I need to submit it to get the value with the java code and make the search...How do I do it ? ``` <input id="ven_prod" type="text" placeHolder="Código de Barras" autofocus> <input id="prod_hidden" type="text" value=""> <script> $('#ven_prod').keypress(function (e) { if(e.keyCode==13) { var table = document.getElementById('tbprodutos'); var tblBody = table.tBodies[0]; var newRow = tblBody.insertRow(-1); var prod = document.getElementById('ven_prod').value; var qtd = document.getElementById('ven_qtd'); var barra = prod.substring(0, 12); var num = prod.substring(14, 16); document.getElementById('prod_hidden').value = barra; var ref = <%=pd.getProdutosBarra(request.getParameter("prod_hidden")).getPro_referencia()%>; OR var ref = <%=pd.getProdutosBarra(JS VAR 'barras HERE).getPro_referencia()%>; if(prod.length==16) { var newCell0 = newRow.insertCell(0); newCell0.innerHTML = '<td>'+ref+'</td>'; var newCell1 = newRow.insertCell(1); newCell1.innerHTML = '<td>'+num+'</td>'; var newCell2 = newRow.insertCell(2); newCell2.innerHTML = '<td>'+qtd.value+'</td>'; var newCell3 = newRow.insertCell(3); newCell3.innerHTML = '<td>R$ '+valor+'</td>'; var newCell4 = newRow.insertCell(4); newCell4.innerHTML = '<td>'+barra+'</td>'; document.getElementById('ref').value = '6755'; document.getElementById('imgsrc').src = './?acao=Img&pro_id=1'; document.getElementById('valortotal').value = 'Testando novo valor'; document.getElementById('ven_prod').value = ''; document.getElementById('ven_qtd').value = '1'; } else { document.getElementById('ven_prod').value = ''; document.getElementById('ven_qtd').value = '1'; alert("Código de barras inválido!"); } return false; } }); </script> ```
2013/10/21
[ "https://Stackoverflow.com/questions/19485977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2901691/" ]
you can make ajax call using jQuery as follows. will submit your form data as well along with hidden elements. ``` var form = jQuery("#YourFormID"); jQuery.ajax({ type: "POST", url: form.attr("action"), data: form.serialize(), // serializes the form's elements. success: function(data) { console.log(data); } }); ```
23,700
I just got my new Galaxy S3 today (after a couple of years using BB and iOS) and I installed Samsung Kies on my computer. Kies's interface is quite intuitive (laying out everything almost the same like iTunes) so I created a few playlists and dragged a few songs to each playlist. Then I clicked on the icon for my phone and selected `Sync > Multimedia > Sync Music > Selected Playlist`, chose all the playlists I wanted And clicked `Sync`. It transfered quite fast, but when I checked the phone I found all my songs, but no playlists. I tried searching just now to find an answer, and it appears there are other poeple with the same problem. Some people mentioned some paid app or software to do this, but I don't want to buy an extra app just to do this job. I'd also like to avoid having to re-create the playlists manually on my phone. Could anyone point out what I am missing, or a way around this problem?
2012/06/01
[ "https://android.stackexchange.com/questions/23700", "https://android.stackexchange.com", "https://android.stackexchange.com/users/15578/" ]
i have the same problem with Kies, all music but no playlists! I tried WinAmp but no luck there either, it did crash alot on my PC, and S3. So i tried a few other apps on play store, I'm using Easy Phone Tunes, i paid just over £1.00 for it, now it does all ther playlists... But.. out of 2226 tracks it syncs about 1980 tracks. However it gives me a list of all that it won't copy, it's a shame i can't copy/paste info from that list. I know it won't copy DRM Tracks, but i only have about 3 of those that i've bought from iTunes anyway. I've emailed the DEV of the Easy Phone Tunes app for the PC & S3, i'm running sync again now to generate a log file to send him.
49,389,204
I have a data like below : ``` > dplyr::tbl_df(sbp) Country X1980 X1981 X1982 X1983 X1984 X1985 Albania 132.9270 133.0296 133.1459 133.1868 133.2048 133.2577 Algeria 132.4093 132.1710 131.9649 131.7835 131.6161 131.4345 Andorra 140.8585 140.1076 139.3727 138.6457 137.9525 137.3192 ``` I want to get mean of values for each year for all countries and add a row like World to the end of the dataframe, so that I can plot the change of the mean value through years, in that format. I tried using `gather()` so that I have a data with three columns only, like Country-year-value. However I can not think of a way to calculate the mean for the world. ``` Country year sbp Albania X1980 132.9270 Algeria X1980 132.4093 Andorra X1980 140.8585 ``` Can you please advise?
2018/03/20
[ "https://Stackoverflow.com/questions/49389204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9160911/" ]
This is a great use case for `apply`, no transformations from your original format necessary: `1` means to calculate across rows, and we select columns `2:6` `df1$mean <- apply(df1[,2:6], 1, mean)` ``` Country X1980 X1981 X1982 X1983 X1984 X1985 mean 1 Albania 132.9270 133.0296 133.1459 133.1868 133.2048 133.2577 133.0988 2 Algeria 132.4093 132.1710 131.9649 131.7835 131.6161 131.4345 131.9890 3 Andorra 140.8585 140.1076 139.3727 138.6457 137.9525 137.3192 139.3874 ``` You don't really want to add a summary row to your primary table, that's how you might do it in Excel, but in R it's better practice to calculate it separately. To get the means for each year, we can also use apply, this time using `2` in the `apply` function to calculate down columns: ``` apply(df1[,2:6], 2, mean) X1980 X1981 X1982 X1983 X1984 135.3983 135.1027 134.8278 134.5387 134.2578 ```
43,534,389
php file: ``` <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $('.mark').change(function(){ var data= $(this).val(); alert(data); }); </script> </head> <body > <select class='mark' required> <option value='' disabled selected>Marketplace </option> <option value='Amazon' >Amazon</option> <option value='Flipkart' >Flipkart</option> </select> </body> </html> ``` i want to change placeholder of a input textfield on selection of option.but to do that first of all jquery should be called but above code is not working please suggest me something. i want to change placeholder of a input textfield on selection of option.but to do that first of all jquery should be called but above code is not working please suggest me something.
2017/04/21
[ "https://Stackoverflow.com/questions/43534389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7399082/" ]
Write it like this: ``` style = {{ width : 150, height : 150, marginLeft : 370 }} ``` Instead of using `margin-left` use `marginLeft`. **Reason**: > > In React, inline styles are not specified as a string. Instead they > are specified with an object whose key is the camelCased version of > the style name, and whose value is the style's value, usually a > string. > > > ``` margin-left --> marginLeft padding-top --> paddingTop background-color --> backgroundColor ``` Check the [DOC](https://reactjs.org/docs/dom-elements.html#style).
1,256
Most Stacks do not allow answers in comments. This is for good reason- comments evade quality control and ensure that a controversial answer appears directly below a question. [How do comments work?](https://meta.stackexchange.com/questions/19756/how-do-comments-work) However, my flags of comments that are used to answer questions this way are rejected. Am I right in thinking that Law allows answers in comments? And, if so, why is this the case? Examples: [First comment, declined, no reason given](https://law.stackexchange.com/questions/57419/can-i-sell-a-figurine-of-my-own-design-despite-it-being-a-game-character) [First comment, using comments to bypass quality, no reason given](https://law.stackexchange.com/questions/56118/what-are-your-rights-as-a-father-in-arizona) [First comment, again no reason given](https://law.stackexchange.com/questions/57525/sharing-pricing-information-as-a-customer) [Multiple comments, used as the question had several answers and the poster wanted their answer to be at the top](https://law.stackexchange.com/questions/64455/can-etiquette-prevail-over-the-law)
2021/04/27
[ "https://law.meta.stackexchange.com/questions/1256", "https://law.meta.stackexchange.com", "https://law.meta.stackexchange.com/users/14489/" ]
Law.SE espouses the SE-wide guidelines for comments. I would not read a comment flag that is "declined" with no explanation as a "rejection." It only means that a moderator declined to delete the comment after looking at it. In the case of comments that are flagged as "attempts to answer," the comment might be left alone because it is referenced in further upvoted comment discussion that would not make sense without it (but which, as with all comments, could at any point be deleted or moved to chat). Or a moderator might not delete a comment simply because the mod feels like erring on the side of light moderation. Other users can still flag the comment, which will provoke another look, and which on review will show the previous flag(s) which should prompt more careful scrutiny. You can also reply to the comment and encourage the commenter to post the answer as an answer. And reference [any of the Meta.SE threads on answers as comments](https://meta.stackexchange.com/questions/tagged/answers-as-commentshttps://meta.stackexchange.com/questions/tagged/answers-as-comments).
19,958,532
``` var n = { a: 1, b: function() { return Math.random(); } } ``` How would i get the value of any method or variable in the object **n** in a simpler manner? Right now my solution is: ``` get = 'b'; typeof n[get] === 'function' ? n[get]() : n[get]; //returns a random number get = 'a'; typeof n[get] === 'function' ? n[get]() : n[get]; //returns 1 ``` Is it required to check the type to get the value of either **n.a** or **n.b**? Neither of these suffice on their own: ``` n[get] // fails to retrieve return value of n.b n[get]() //throws an error retrieving value of n.a ```
2013/11/13
[ "https://Stackoverflow.com/questions/19958532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/552963/" ]
If you define your object differently using [`Object.create()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create), you can specify setters and getters for a specific property: ``` o = Object.create(Object.prototype, { a: { value: 1 }, b: { configurable: false, get: function() { return Math.random(); } }}); console.log( o.a ); // just 1 console.log( o.b ); // random value ```
673,108
I need to find the matrix that rotates an arbitrary point around $\begin{bmatrix}5 \\6\end{bmatrix}$ by 35\* anticlockwise. I figure I need to first move the plane to centre it at the origin, perform the rotation and then move it back? But i can't figure out how to do this. Thanks.
2014/02/12
[ "https://math.stackexchange.com/questions/673108", "https://math.stackexchange.com", "https://math.stackexchange.com/users/128107/" ]
Matrices (as we normally use/think of them) represent linear transformations, and what you're looking for is **not** a linear transformation; it is what we would call an [affine transformation](http://en.wikipedia.org/wiki/Affine_transformation). So, you can't quite do this with just matrix multiplication, unless you cheat a little by going up a dimension. **Option 1:** Do things the normal way, without matrices. Let $T(x)$ be the translation of the origin to $\pmatrix{5\\6}$. That is, $$ T(x) = x + \pmatrix{5\\6} $$ We then have $$ T^{-1}(x) = x-\pmatrix{5\\6} $$ From there, if $R$ is the rotation about the origin and $A$ is the rotation about $\pmatrix{5\\6}$, we have $$ A(x) = T(R(T^{-1}(x))) = Rx+\pmatrix{5\\6} - R\pmatrix{5\\6} = Rx + (I-R)\pmatrix{5\\6} $$ As you may verify. **Option 2:** Let $x = \pmatrix{x\_1\\x\_2}$ be our starting point. We may write $$ \pmatrix{R&(I-R)\pmatrix{5\\6}\\\pmatrix{0&0}&1} \pmatrix{\pmatrix{x\_1\\x\_2}\\1} = \pmatrix{A\pmatrix{x\_1\\x\_2}\\1} $$
18,402,993
Please, have a look at this: <http://jsfiddle.net/2bU3R/3/> When I hover over the Magazine list, the first dropdown doesn't show. I want it to work for many dropdowns. ``` $(document).ready( function(){ $('#sub-menu-1').hover( function(event){ event.stopPropagation(); $(".sub-menu-1-open").slideDown("fast"); }); $('.sub-menu-1-open').mouseleave( function(){ $('.sub-menu-1-open').slideUp("fast"); }); $('#sub-menu-2').hover( function(event){ event.stopPropagation(); $(".sub-menu-2-open").slideDown("fast"); }); $('.sub-menu-2-open').mouseleave( function(){ $('.sub-menu-2-open').slideUp("fast"); }); }); ```
2013/08/23
[ "https://Stackoverflow.com/questions/18402993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2460413/" ]
**UPDATE #2** If you keep the HTML markup the way it is now, this should work. All the `jQuery (Javascript)` you need is this: ``` $(document).ready(function () { $("div[class^='sub-menu'] .inner").mouseleave(function () { hideMenu(); }); $(".list-inline li a").mouseenter(function () { hideMenu(); $("." + $(this).parent().attr("id") + "-open").stop().slideDown(); }); }); var hideMenu = function () { $("div[class^='sub-menu']").stop().slideUp(); }; ``` Demo: <http://jsfiddle.net/2bU3R/22/>
67,143,040
I have this string below. It has no spaces. ``` "3.2+.4*5.67/6.145=" ``` I would like for there to be spaces and to keep the floats intact. I'd also like to iterate over it to add elements to a string or a stack (eventual goal is to convert to postfix). So, I think this is the output that I need: ``` [3.2, +, .4, *, 5.67, /, 6.145, =] ``` Any ideas on how to do this? The postfix output should eventually be this: ``` "3.2 .4 5.67 * 6.145 / +" ```
2021/04/17
[ "https://Stackoverflow.com/questions/67143040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7248794/" ]
[`re.split()` keeps capture groups](https://stackoverflow.com/a/2136580/1717828) (things wrapped in parenthesis): ``` import re s = "3.2+.4*5.67/6.145=" [x for x in re.split("(\d*\.?\d*)", s) if x != ''] ``` **Edit**: some more information for OP. The `"(\d*\.?\d*)"` part is saying * `\d`: match any integer (`\d` means integer in regex) * `*` match zero or more of the thing before me * `\.` match a literal period (since in regex `.` means any character) * `?` match zero or one of the thing before me * `\d`: match any integer * `*` match zero or more of the thing before me Wrapping the whole thing in parentheses is the trick. It is saying to capture the matched substring and then keep them. Usually, `.split()` gets rid of the matched delimiters.
29,361,122
I am loading a column chart in 3D with Highcharts. On the inital load, the chart works perfectly. When I use `setData()` to change the series, the chart gains an odd white outline around its edges. **Before:** ![enter image description here](https://i.stack.imgur.com/uWQH7.png) **After:** ![enter image description here](https://i.stack.imgur.com/iJwDu.png) I tried a few fixes such as using `edgeColor` and `edgeWidth`, although they made no difference. **Note:** If I hover over one of the columns, the outline is instantly removed on that particular item until `setData()` occurs again. How can I remove this white outline from the chart?
2015/03/31
[ "https://Stackoverflow.com/questions/29361122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1799136/" ]
`edgeWidth` should be working, however there is a bug. Reported [here](https://github.com/highslide-software/highcharts.com/issues/4055) - thanks. As workaround, set `edgeColor: 'rgba(0,0,0,0)`. Demo: jsfiddle.net/hdghyz2x Bug is fixed already by commit (`4c94d34`) - will be included in next release (4.1.5). Available already in github version: <http://github.highcharts.com/highcharts-3d.js>
15,985,266
I Have Two Array Lists, Declared as: ``` ArrayList<JRadioButton> category = new ArrayList<JRadioButton>(); ArrayList<Integer> cat_ids = new ArrayList<Integer>(); ``` Both of the these fields contain exactly, the Same No of Values, which are infact corresponding in Nature. I know I can iterate over one of the loops like this: ``` for(JRadioButton button: category) { if(button.isSelected()) { buttonName = button.getName(); System.out.println(buttonName); } } ``` But, I would like to iterate over both the LISTS simultaneously. I know they have the exact same size. How do I Do that?
2013/04/13
[ "https://Stackoverflow.com/questions/15985266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1703430/" ]
You can use [`Collection#iterator`](http://docs.oracle.com/javase/8/docs/api/java/util/Collection.html#iterator--): ``` Iterator<JRadioButton> it1 = category.iterator(); Iterator<Integer> it2 = cats_ids.iterator(); while (it1.hasNext() && it2.hasNext()) { ... } ```
65,739,652
I have the following, which works for `int`s: ``` extension IterableInt on Iterable<int> { int get max => reduce(math.max); int get min => reduce(math.min); int get sum => reduce((a, b) => a + b); } ``` I wanted to make this more general to include decimals and created this: ``` extension IterableNum on Iterable<num> { num get max => reduce(math.max); num get min => reduce(math.min); num get sum => reduce((a, b) => a + b); } ``` These mostly fail, using the following tests: ``` void main(List<String> args) { print([1.2, 1.3, 5, 2.2].sum); //works print([1.2, 1.3, 5, 2.2].max); //works print([1.2, 1.3, 5, 2.2].min); //works print([1.2, 1.3, 5.0, 2.2].sum); //does not work print([1, 2, 3].max); //does not work print([1, 2, 3].min); //does not work print([1, 2, 3].sum); //does not work } ``` The error returned for the `decimal` case is: ``` type '(num, num) => num' is not a subtype of type '(double, double) => double' of 'combine' ``` It's similar for `int`, referring to `int` instead of `double` in the message. The pattern seems to be that if there is a mixture of `int`s and `decimal`s in the list then it's fine. If it's all `int`s or all `decimal`s, it fails. I've redefined the properties (and added `multiply`) using `fold` and this works: ``` extension IterableNum on Iterable<num> { num get max => fold(first, math.max); num get min => fold(first, math.min); num get sum => fold(0, (a, b) => a + b); num get multiply => fold(1, (a, b) => a * b); } ``` Can someone explain why the first version of `IterableNum` (using `reduce`) does not work?
2021/01/15
[ "https://Stackoverflow.com/questions/65739652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10301673/" ]
The issue is that `reduce` is *very* picky about its parameter function. A `List<int>`'s `reduce` requires a function of type `int Function(int, int)`. Nothing else will suffice. If you cast this `List<int>` to `List<num>`, you have something which seems like it expects to get a `num Function(num, num)`, but actually requires an `int Function(int, int)`. That's very hard to satisfy both of these (you need an `int Function(num, num)`, which `(a, b) => a + b` is not. (This is all because Dart class generics is *unsafely* covariant. A `List<int>` is always considered a subtype of `List<num>`, even though some of the functions aren't actually usable at `List<num>`). Use `fold` is a good solution. It allows you to specify a return type different from the element type. It also requires you to have a value of that type to begin with, which is why it isn't always possible to use `fold` instead of `reduce`.
58,661,453
\*\*I have a set, get class `UserInfo` which is used to set and get variables. I wanted to set those variables from a method `createNewUser()` and return the `UserInfo` object. when I am trying to return the object it's always giving me null values. when I tried to return it from the then block, the method is complaining that there is no return value.\*\* ``` export default class UserInfo { private accountId!: string; private firstName!: string; private lastName!: string; constructor() {} /** * Gets Account Id */ public getAccountId(): string { return this.accountId; } /** * Sets Account Id */ public setAccountId(accountId: string) { this.accountId = accountId; } /** * Gets FirstName */ public getFirstName(): string { return this.firstName; } /** * Sets FirstName */ public setFirstName(firstName: string) { this.firstName = firstName; } /** * Gets LastName */ public getLastName(): string { return this.lastName; } /** * Sets LastName */ public setLastName(lastName: string) { this.lastName = lastName; } } import UserInfo from '../../d/user-info' export default class QuickPage { constructor() {} lastNameText() { return cy.get('#lastName'); } firstNameText() { return cy.get('#firstName'); } accountIdText() { return cy.get('#accountId'); } public createNewUser(): UserInfo { let userInfo = new UserInfo(); cy.getQuickRegisterUrl().then(url => { cy.log(url); cy.visit(url); this.firstNameText().getText().then((text) => { userInfo.setFirstName(text); }); this.lastNameText().getText().then((text) => { userInfo.setLastName(text); }); this.accountIdText().getText().then((text) => { userInfo.setAccountId(text); }); }); return userInfo; } } ``` I am trying above code and userinfo is always returning undefined!! can someone explain to me how to write this in asynchronous format?
2019/11/01
[ "https://Stackoverflow.com/questions/58661453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4203978/" ]
ContinueWith starts the next Task after the first finished. So both your examples run synchroniously ( first methode A then methode b) EDIT: As an addition to your edit, your error is caused by the `.Wait()` function, which awaits the Task and returns void.
5,813,323
Is it possible to do this in Java ? I want to generate a random number such that given a range say for example: between 1 and 70 - everytime the random number is generated it should be excluded from generation results. so [1,70] rand = 56 (now 56 shouldn't be considered next time) [1,70] = 63 (now 56,63 should be excluded from generation till my code runs)
2011/04/28
[ "https://Stackoverflow.com/questions/5813323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/701441/" ]
This is equivalent to shuffling an array of numbers containing [1..70] and then dealing them out one at a time. Look up "shuffle algorithm" on Google. Here's a link <http://www.vogella.de/articles/JavaAlgorithmsShuffle/article.html>
56,528,353
I've written the following code to create a random number between 0.0 and 10.0. ``` const minRand = 0 const maxRand = 10 v := minRand + rand.Float64()*(maxRand-minRand) ``` However, I would like to set the granularity to 0.05, so having all the digits as the least significant decimal should not be allowed, only 0 and 5 should be allowed, e.g.: * the value 7.73 is NOT VALID, * the values 7.7 and 7.75 ARE VALID. How can I produce such numbers in Go?
2019/06/10
[ "https://Stackoverflow.com/questions/56528353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1264920/" ]
You can divide with the granularity, get a pseudo random integer and then multiply with the granularity to scale the result down. ``` const minRand = 8 const maxRand = 10 v := float64(rand.Intn((maxRand-minRand)/0.05))*0.05 + minRand fmt.Printf("%.2f\n", v) ``` This will print: ``` 8.05 8.35 8.35 8.95 8.05 9.90 .... ``` If you don't want to get the same sequence every time `rand.Seed(time.Now().UTC().UnixNano())`. [From the docs](https://golang.org/pkg/math/rand/#Seed) > > Seed uses the provided seed value to initialize the default Source to a deterministic state. If Seed is not called, the generator behaves as if seeded by Seed(1). Seed values that have the same remainder when divided by 2^31-1 generate the same pseudo-random sequence. Seed, unlike the Rand.Seed method, is safe for concurrent use. > > >
47,524,727
I am planning to setup a portal where end users can create mysql database in there dev environment. I am using XAMPP to setup the portal. Now I need to create a remote DB (hosted on UNIX server) from windows server using the portal. I am using `PHP` to create DB form. Following is the code I use- ``` <?php //Attempt MySQL server connection on remote host server. $link = mysqli_connect("test.server.com", "mysqladmin", "pass"); // Check connection if($link === false){die("ERROR: Could not connect. " . mysqli_connect_error());} // Attempt create database query execution $sql = "CREATE DATABASE vikas "; if(mysqli_query($link, $sql)){echo "Database created successfully";} else{echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);} // Close connection mysqli_close($link); ?> ``` Here `test.server.com` is a remote server hosted on UNIX. I am trying to create from windows server where `XAMPP` is installed. When I run the query I see that instead of going to remote server it is searching on localhost only. > > Warning: mysqli\_connect(): (HY000/1045): Access denied for user > 'mysqladmin'@'dev-windows.server.com' (using password: YES) in > C:\xampp\htdocs\login\create\_db.php on line 4 ERROR: Could not > connect. Access denied for user 'mysqladmin'@'dev-windows.server.com' > (using password: YES) > > > `dev-windows.server.com` is windows server where `XAMPP` is installed and all websites will be created here only. `test.server.com` is remote db server hosted in UNIX
2017/11/28
[ "https://Stackoverflow.com/questions/47524727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7946833/" ]
This is a long custom script that serves the purpose for any remote `https://github.com` hosted repository. I will modify this soon as it is possibly prone to edge case errors. To get this working, save the snippet into a `git_relative.sh` file and place it anywhere, for now place it at `~/` home directory. Now modify your `~/.bashrc` or `~/.zshrc` or `~/.bash_profile` by adding this line **`alias git_remote_path='source ~/git_relative.sh'`** Restart your terminal or execute the corresponding bash script where you added this. Then go to any git repository and execute `git_remote_path`. This print the full path in the git remote server. The example you gave seems to have a different remote url as against the conventional **`github.com`**. To get it working for that, just change the lines I specified in the comments. **NOTE**: The script works for `https://github.com` remote URLs, if you want to get path for a custom URL, you need to modify the code a little to match the needs of the repository URL conventions. One example is included in the snippet as a comment. ``` is_git=false relative_to_git="" check="" initial=$(pwd) current_dir="" count=0 if [ ! $(git rev-parse --is-inside-work-tree 2> /dev/null) ]; then echo "NOT INSIDE A VALID GIT REPOSITORY" return fi git_remote=$(git config --get remote.origin.url) git_remote=${git_remote%.git} git_branch=$(git rev-parse --abbrev-ref HEAD) while [ $is_git=true ] do if [ -d ".git" ]; then break fi current_dir=${PWD##*/} relative_to_git="$current_dir/$relative_to_git" cd ../ done # echo "$git_remote/+/$git_branch/$relative_to_git" # For andoid.googlesource.com uncomment the above and comment the below lines echo "$git_remote/tree/$git_branch/$relative_to_git" cd $initial ```
47,213,283
Why are the following unequal in Go? Is this a bug, or is it by design? If it's by design, why does this occur and is this type of behavior documented anywhere? <https://play.golang.org/p/itEV9zwV2a> ``` package main import ( "fmt" ) func main() { x := 10.1 fmt.Println("x == 10.1: ", x == 10.1) fmt.Println("x*3.0 == 10.1*3.0:", x*3.0 == 10.1*3.0) fmt.Println("x*3.0: ", x*3.0) fmt.Println("10.1*3.0: ", 10.1*3.0) } ``` Produces: ``` x == 10.1: true x*3.0 == 10.1*3.0: false x*3.0: 30.299999999999997 10.1*3.0: 30.3 ``` Note that the same floating point math is being performed, just with different syntax. So why is the result different? I would expect `10.1*3.0` to equal `30.29999...` as in the `x*3.0` example.
2017/11/09
[ "https://Stackoverflow.com/questions/47213283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1492354/" ]
Constants and number literals in Go are untyped and have unlimited precision. The moment it has to be stored as a specific type, the bounds of that type apply. So when you declare `x := 10.1`, that literal is converted into a `float` and loses some precision. But when you specifically do `10.1*3.0` these have their full precision. See the "Floats" header in this article. <https://blog.golang.org/constants> > > Numeric constants live in an arbitrary-precision numeric space; they > are just regular numbers. But when they are assigned to a variable the > value must be able to fit in the destination. We can declare a > constant with a very large value: > > > > ``` > const Huge = 1e1000 > > ``` > > —that's just a number, after all—but we can't assign it or even print it. This statement won't even compile: > > > > ``` > fmt.Println(Huge) > > ``` > > The error is, "constant 1.00000e+1000 overflows float64", which is > true. But Huge might be useful: we can use it in expressions with > other constants and use the value of those expressions if the result > can be represented in the range of a float64. > > > How it actually does this, especially in the given `Huge` case, I do not know.
52,702,975
**Experience with this code** Im a student, and this site, started as a school work. I dont have much experience with it, but im ready to learn if needs to be. **Main problem** I would really like to make a header like this: ![](https://i.stack.imgur.com/OgIyI.png) I don't really know what to code for making something like that, since I tried my best, but it wont work. Down here, the code: ```css header { background-color: #d60000; height: 90px; margin-top: -21px; } nav ul { display: inline; } nav li { display: inline; text-decoration: none; } ul#navleft {} ul#navright { float: right; } img#logo { padding-top: 24px; vertical-align: center; display: block; } ``` ```html <header> <nav> <h1> <a href="https://www.youtube.com/c/Meltix"> <img src="img/logo.png" id="logo" width="200" height="40" alt="Logo Meltix YT" /></a> </h1> <ul id="navleft"> <li class="active"> <a href="index.html">Home</a> </li> <li> <a href="video.html">Video</a> </li> </ul> <ul id="navright"> <li> <a href="contenuti.html">Contenuti & Link</a> </li> <li> <a href="info.html">Informazioni</a> </li> </ul> </nav> </header> ``` With a system like that, the header does this work: ![](https://i.stack.imgur.com/YiFQF.png)
2018/10/08
[ "https://Stackoverflow.com/questions/52702975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10307340/" ]
Something like this? I use flexbox for stuff like this. For a great explanation look at [this](https://css-tricks.com/snippets/css/a-guide-to-flexbox/). ```css nav{ display: flex; background-color:#d60000; padding:20px; color:white; } li{ flex-grow: 1; list-style-type: none; text-align:center; } ``` ```html <nav> <li>Link</li> <li>Link</li> <li><img src="https://via.placeholder.com/60x60"></li> <li>Link</li> <li>Link</li> </nav> ```
22,581,999
given a vector f and a scalar s what is the difference between DCT(f) and DCT(f+s) and between DCT(f) and DCT(f\*s)
2014/03/22
[ "https://Stackoverflow.com/questions/22581999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3450482/" ]
Clojure's compile-time type information is pretty limited. Functions like `map` have no way to specify that it only accepts one-argument functions (and of course that's not even really true, with multi-collection `map` calls). Likewise, `apply` makes everything really really complicated: consider `(apply f (read-list-from-user))`. Does that compile successfully? Of course it must, even though we don't know if the user will enter the right number of args for `f`. Thus, there has to be a runtime exception for that case; then you might as well make all arity exceptions runtime *anyway*, since you can't be protected from them by the compiler.
463,580
I am getting the infamous aacraid: Host adapter abort request error with my new Adaptec RAID Controller under high I/O. I have read several forums, even [Adaptecs](http://adaptec-itic.adaptec.com/app/answers/detail/a_id/15357/~/error:-%22aacraid:-host-adapter-abort-request%22), that setting the /sys/block/sdX/device/timeout value to 45 will fix this. However I am running Ubuntu Server 12.04 which already has this value at 45 by default. I also tried the next suggestion which was to update my mobo's bios to the latest, which I did. I am not sure if anyone else has run into this " aacraid: Host adapter abort request" error before even after taking these steps. This is what I see in my syslog: ``` kernel: [ 5493.523282] aacraid: Host adapter abort request (4,0,0,0) Jan 6 20:29:15 server kernel: [ 5493.523309] aacraid: Host adapter abort request (4,0,0,0) Jan 6 20:29:15 server kernel: [ 5493.523375] aacraid: Host adapter reset request. SCSI hang ? ``` Heres my uname -a ``` Linux server 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux ``` Thanks All, Jim
2013/01/07
[ "https://serverfault.com/questions/463580", "https://serverfault.com", "https://serverfault.com/users/140021/" ]
This powershell script does exactly what your initial request was. Examine one computerGroup and find updates not approved for one or multiple other computer groups. *Note You will need to run this either on a WSUS server or a machine that has the WSUS Admin tools installed.* **Configuration** Set `$targetComputerGroup` to the Computer Group you want to use as a baseline Set `$CheckForMissing` to the names of the group or groups you want to see if they have been approved for. Note: To do multiples just coma seperate ("Group1,Group2") ``` $serverName="localhost" $targetComputerGroup="BaselineGroup" $checkForMissing="MissingGroup1,MissingGroup2" [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") $wsus=[Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($serverName,$false) $computerGroup=$wsus.GetComputerTargetGroups()|ForEach-Object -Process {if ($_.Name -eq $targetComputerGroup) {$_}} $UpdateScope=New-Object Microsoft.UpdateServices.Administration.UpdateScope $UpdateScope.ApprovedStates="Any" $updateScope.ApprovedComputerTargetGroups.Add($computerGroup) $Approvals = $wsus.GetUpdateApprovals($UpdateScope) #At this point we have all of the updates assigned to the $targetComputerGroup $report= @() write-host "Querying for all Updates approved for $targetComputerGroup" foreach ($Approval in $approvals) { $record=""|Select-Object ComputerGroup,UpdateName, UpdateID $record.ComputerGroup=$wsus.GetComputerTargetGroup($Approval.ComputerTargetGroupID).Name $record.UpdateName=$wsus.GetUpdate($Approval.UpdateID).Title $record.UpdateID=$wsus.GetUpdate($Approval.UpdateID).ID.UpdateID $report +=$record } #Now group the results by UpdateName $GR=$report|group -Property UpdateName $CheckForMissing=$CheckForMissing.Split(",") foreach ($entry in $gr) { $groups=@() foreach ($g in $entry.Group) { $groups += $g.ComputerGroup } foreach ($missing in $checkForMissing) { if ($groups -Contains $missing) {} else{ New-Object PSObject -Property @{ Name = $entry.Name UpdateID = $entry.Group[0].UpdateID GroupMissing = $missing } } } } ``` When Completed you will have output an output like: ![enter image description here](https://i.stack.imgur.com/17tJO.png) If instead of outputing to the screen you want to export the list to a CSV replace the bottom portion with the following code: ``` $CheckForMissing=$CheckForMissing.Split(",") $CSVdata=@() foreach ($entry in $gr) { $groups=@() foreach ($g in $entry.Group) { $groups += $g.ComputerGroup } foreach ($missing in $checkForMissing) { if ($groups -Contains $missing) {} else{ $CSVdata += New-Object PSObject -Property @{ Name = $entry.Name UpdateID = $entry.Group[0].UpdateID GroupMissing = $missing } } } } $CSVdata|Export-Csv "FILENAME.CSV" ```
61,559,456
I am running a FutureBuilder with Firebase authentication. i am expecting flutter to check inside a FutureBuilder on the status of the users login. if the user is logged in the widget to display should be a `logout` icon. if the user is logged out then the widget to display should be `login` My function for the Future is as follows: ``` Future<String> setUserStatus() async { userStatus = await FirebaseAuth.instance.currentUser(); uid = userStatus.uid; print('after the query - The user is $uid after'); if(uid == null){ return uid = null; } else if( uid != null){ return uid = userStatus.uid; } } ``` My Future Builder is as follows: ``` FutureBuilder<String>( future: future_user, builder: (BuildContext context, snapshot) { String update_status = snapshot.data; if(update_status == null){ return //Widget for login } else if(update_status != null){ return //widget for logout } ``` This works fine if I click the logout button. The widget updates correctly and gives the user the option to now login. The function for logout is: ``` Future<String> logout() async { await FirebaseAuth.instance.signOut(); setState(() { future_user = setUserStatus(); }); } ``` The issue is that when I login, the user is taken to a separate Login page. After logging in, when I navigate back to the main page, where the FutureBuider is running, it is not picking up the uid of the User (returns null) and still shows the `login` icon. i am calling the Future Builder inside an initState so should it not be running this when i navigate back? ``` Future<String> future_user; @override void initState() { super.initState(); setState(() { future_user = setUserStatus(); }); } ``` when i Re-run the app from Android Studio, it updates the widget correctly.
2020/05/02
[ "https://Stackoverflow.com/questions/61559456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12281377/" ]
initstate will be not called when you navigate back from any other screen bacause of that you are facing that issue. You can call SetState when you came back from Login screen in following way. ``` Navigator.push(context, MaterialPageRoute(builder: (_) => Demo2())).then((value) => { setState(() { future_user = setUserStatus(); }); }); ``` I don't know how your user status is changing, so i just demonstrated how you can call some method or whatever you want to do when you came back from login screen so that you can get new data.
1,857,361
> > Let $p(x) = c\_0 + c\_1x + \cdots + c\_d x^d$ be a polynomial with integer coefficients $c\_0, \ldots, c\_d \in \mathbb{Z}$ and $c\_d \neq 0$, so $p(x)$ has degree $d$. Let $a/b$ be a rational root of $p(x)$ written in lowest terms. How do I see that $a \mid c\_0$ and $b \mid c\_d$? > > >
2016/07/12
[ "https://math.stackexchange.com/questions/1857361", "https://math.stackexchange.com", "https://math.stackexchange.com/users/353669/" ]
We know that $$c\_0 + c\_1\frac{a}{b}+ \cdots c\_d(\frac{a}{b})^d = 0$$ is true. Multiplying both sides by $b^d$, we get $$c\_0b^d + c\_1 a b^{d-1}+ \cdots c\_da^d = 0.$$ Right side is divisible by $a$ and $b$ so left side is also divisible by $a$ and $b$. I believe you can finish it from here!
25,205,871
i am using some simple menu CSS, some parts need to be unpuck and to let my website users know this menu have some submenu options i want to put arrow close to it. It should look like: <http://funedit.com/imgedit/soubory/small_19971213581407508176.jpg> And my code looks like: **CSS** ``` .filter{ margin-left:20px; position: relative; } .filter a{ color: #888888; float: left; width: 120px; height: 35px; text-decoration: none; padding: 0.2em 0.6em; font-size: 120%; text-align: center; } li:after { content: ""; background-image: url("../images/filter_arrow.png"); background-repeat: repeat-x; display: block; width: 25px; height: 13px; margin: 0; position: absolute; right: 480px; top: 100px; vertical-align: middle; } ``` **HTML**: ``` <div class="filter"> <ul> <li><a href="#">Progress</a></li> <li><a href="#">Claimed number</a></li> <li><a href="#">Make</a></li> <li><a href="#">Status</a></li> </ul> </div> ``` EDIT: Yea sorry guys i forgot on some CSS i am using above as well in my other code, its: ``` ul{ list-style-type: none; float: left; width: 100%; padding-left: 0px; } li{ display: inline; } ``` Is here anyone who can help me to fix this problem with arrows? Because on my version they are just randomly separate on website at the moment.
2014/08/08
[ "https://Stackoverflow.com/questions/25205871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834393/" ]
<http://css-tricks.com/snippets/css/css-triangle/> this should help you, insert the triangle using ``` <span class=".arrow-down"></span> ``` or ::after. ``` .arrow-down { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 20px solid #f00; } ```
38,094,553
I've searched around here but I haven't found a satisfying answer so I've decided to ask. I need to search a collection of strings to find expressions like: ``` AB 12345 AC 12345 ``` I've tried this regex ``` [A][BC][ ]\d{5} ``` But unfortunately in the strings there are also ``` #XXAB 1234567890123 GGAB 12345678901 AB 123456 SAB 123456789 ``` And the above expression gets all these as valid. I've found and tried ``` [A][BC][ ]\d{5}$ ``` But this does not match anything. So the question is, is there an expression to find the strings with 5 numbers followed by anything except more numbers? From the answers I think I was really not clear in my exposition, the strings are in the middle of a larger string so I set some possible string that I must match: ``` MY DESCRIPTION WITH DATA XXXAB 12345BCD ``` and also ``` MY SECOND DESCRIPTION WITH DATA REF. AB 12345 ``` and also ``` MY THIRD DESCRIPTION WITH DATA REFAB 12345 ``` and also ``` AB 12345WITH A DESCRIPTION FOLLOWING AB 12345 WITH A SPACE AND DESCRIPTION FOLLOWING ``` The strings are all uppercase in the database.
2016/06/29
[ "https://Stackoverflow.com/questions/38094553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4904669/" ]
Use `?!` lookahead. ``` A[BC] \d{5}(?!\d) ``` See demo. <https://regex101.com/r/oR7zJ6/2>
44,351,904
If I'm using bash and type `bash` I'm in the child shell and need to type `exit` to go back to the original parent shell. If I forget which one I'm in how do I check?
2017/06/04
[ "https://Stackoverflow.com/questions/44351904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6730305/" ]
Use the `SHLVL` environment variable. **man bash:** > > **SHLVL** : Incremented by one each time an instance of bash is started. > > > ``` $ echo "$SHLV" 1 $ bash $ echo "$SHLV" 2 $ exit $ echo "$SHLV" 1 ```
11,694,958
I'm trying to get my head around Javascript array functions. I have a nested array like this, where every row covers the same time period: ``` [{ "category": "fruit", "variety": "apple", "data": [{ "day": 1, "units": 2 }, {"day": 2, "units": 4 }] },{ "category": "fruit", "variety": "orange", "data": [{ "day": 1, "units": 3 }, {"day": 2, "units": 5 }] },{ "category": "veg", "variety": "tomato", "data": [{ "day": 1, "units": 4 }, {"day": 2, "units": 2 }] }] ``` I would like to sum the units by day by category, to get an array like this: ``` [{ "category": "fruit", "data": [{ "day": 1, "units": 5 }, {"day": 2, "units": 9 }] },{ "category": "veg", "data": [{ "day": 1, "units": 4 }, {"day": 2, "units": 2 }] }] ``` I've been tackling this through long looping if statements, and making a bit of a hash of it. Can you see an elegant way to solve this? Many thanks!
2012/07/27
[ "https://Stackoverflow.com/questions/11694958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450420/" ]
The solution is pretty obvious: Loop through the array, and store the data in a key-value pair. Then, loop through the has, and construct the resulting array using [`Array.prototype.map`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map). Finally, if you want a nicely formatted JSON-string, use [`JSON.stringify(result, null, 4);`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/stringify), where `4` is the number of spaced for pretty formatting. Demo: <http://jsfiddle.net/jde6S/> ``` var list = [ ... ]; var hash = {}; for (var i=0; i<list.length; i++) { var obj = list[i]; // This part makes sure that hash looks like {fruit:[], veg: []} var hashObjCat = hash[obj.category]; if (!hashObjCat) { hashObjCat = hash[obj.category] = {}; } // This part populates the hash hashObjCat with day-unit pairs for (var j=0; j<obj.data.length; j++) { var data = obj.data[j]; if (hashObjCat[data.day]) hashObjCat[data.day] += data.units; else hashObjCat[data.day] = data.units; } } // Now, we hash looks like {fruit: {1:5, 2:9} } // Construct desired object var result = Object.keys(hash).map(function(category) { // Initial object var obj = {category: category, data:[]}; var dayData = Object.keys(hash[category]); // This part adds day+units dicts to the data array for (var i=0; i<dayData.length; i++) { var day = dayData[i]; var units = hash[category][day]; obj.data.push({day: day, units: units}); } return obj; }); // Test: console.log(JSON.stringify(result, null, 4)); ```
624
How do I tag answers correctly, which are rather a comment than an answer. The option "is not an answer" which I choose usually has been disputed a number of times. This makes no sense for me, especially when the answert is subsequently deleted (instead of converting it into a comment). The explanation for "is not an answer" says: > > This was posted as an answer, but it does not attempt to answer the question. It should >possibly be an edit, a comment, another question, or deleted altogether. > > > I think it should fit this purpose as well. This kind of "answer-comments" often come from new users. Or should we add a fitting comment and nominate the answer for deletion? What do you think about it?
2014/06/19
[ "https://biology.meta.stackexchange.com/questions/624", "https://biology.meta.stackexchange.com", "https://biology.meta.stackexchange.com/users/5144/" ]
I'm looking through your declined flags and I'll list a few cases and the likely reason why they were declined: * The most recent one is on a post that looks like a comment on first glance, it refers to another answer in the first sentence, but that actually contains something of an answer in the rest of the post. * One flag was cast 20 minutes after the post was already deleted. I declined that one as there is no reason to flag deleted posts as "not an answer" * One is an answer, a rather short one and wrong anyway, but it certainly tries to be an answer. Unless the quality is truly atrocious, moderators generally don't remove wrong answers. This is handled by voting and by community deletion. The last example is probably the most important. Any post that tries to answer the actual question, even if it is wrong or badly written, does not fall under the "not an answer" category. This is also true for posts that refer to another answer, and look a bit like a comment due to that, but that still provide something like a real answer to the question.
14,486,153
I tried to include TinyMCE into my template but if I try to edit the texts in the frontend I have only a html-tag view. Have anybody got some hints for me? That's the website and the template, perhaps this could help a little bit: <http://www.sonnen-center-hermeskeil.de>
2013/01/23
[ "https://Stackoverflow.com/questions/14486153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2004876/" ]
If anything of the above didn't help, chances are that the access to the plugin is restricted. Go to `Plugin-Manager -> Editor - TinyMCE` and check that `Access` is set accordingly. If e.g. a common user is allowed to edit the article but the Access Rule for TinyMCE is set to "Special", Joomla will display the mere HTML Editor **even if there is no other Editor available or enabled**. The same goes for setting Access to "Registered" when a public user is allowed to edit an article.
92,196
Why does my D2009 exe produce emails with attachments named ATTnnnnn.DAT when the same source code compiled in D2007 produces emails with attachments correctly named with the original file name? I am using the respective Indy libraries that come with D2007 and D2009. Not having the original file name on the attachment prevents users from being able to double click the attachment to open it (typically attachments are Excel spreadsheets). Note: code is identical - just the compiler and Indy libraries vary. The attachment sent by the D2009 exe can be saved and renamed to say zzzz.xls and then opens correctly -- ie the email and attachment go through correctly -- it is just the email attachment file name that is messed up. Someone suggested the attachment headers are corrupted. Has Indy been broken? The code to reproduce is stock standard code that can be found on many websites, but I can post if necessary. Thx in advance.
2008/09/18
[ "https://Stackoverflow.com/questions/92196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have found the problem - please see the adug.com.au mailing list for exact details of the solution, but in summary -- the version of Indy that comes with D2009 (version 10.2.5) has 2 errors in the IdMessageClient.pas unit in two lines that set the name= and filename= in the attachment part processing (one line number is 1222 from memory and the other is a few lines earlier; sorry I am at home now; I fixed things this evening at work). The lack of these semi-colons causes the attachment header to be badly formed and Outlook generates a name of its own for the attachment. The fix is to output a semi-colon ( ; ) before outputting the name= or filename= tokens. Then Indy needs to be rebuilt. I compared the D2007 version of Indy (10.1.5) and can see it always puts the semi-colon at the end of the Content-Type line thus avoiding the problem that has crept into the version included with D2009.
46,145,283
I'm trying to create an N-ary tree where I have a char array ex: {A,B,C,D} to insert to a tree. I set the root to be "/" if the command is mkdir /A/B/C => create node A at root, then B at A and C at B. if the command is mkdir B/C/D =>create node D inside C, etc... I simplified the code below so hopefully, there won't be any typo here. Anyway, upon debugging with gdb, it looks like the upon reaching search function will give me a segmentation fault, I made the code below, I'm really sure the insert function will have the same error as well but I haven't been able to test it out yet. head.c ``` #pragma once #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #define len 128 #define num 128 typedef struct tree{ char name; char type; struct node *child, *sibbling, *parentNode; }node; char *baseName[64]; node *root, *cwd; ``` tree.c ``` node *createNode(node * newNode, char ch, char ty){ node *curNode = (node*)malloc(sizeof(node)); curNode->name = ch; curNode->type = ty; curNode->parentNode = newNode; curNode->sibbling = curNode->child=NULL; return curNode; } node * insertNode(node *parent, char name, char type){ if(parent->child == NULL){ parent->child=parent; createNode(parent->child,name,type); } else{ parent->sibbling = parent; createNode(parent->sibbling,name,type); } } node *searchNode(node *curNode, char name){ if(curNode->name ==name){ <------------error here return curNode; } if(name != curNode->name && curNode->sibbling != '\0'){ searchNode(curNode->sibbling, name); } if(name != curNode->name && curNode->child != '\0'){ searchNode(curNode->sibbling, name); } return 0; } void mkDir(){ int index = 0; int flag =0; int baseFlag=0; node *pwd = root; ///// insert while(dirName[index] !='\0'){ if(searchNode(root,dirName[index]) != NULL){ <-- error in this searchNode function //no node exist // insertNode(pwd,"A","D"); <---this probably error too printf("found A"); } else{ //node exist cwd = searchNode(root,dirName[index]); insertNode(cwd,dirName[index],"D"); } index++; } } memset(dirName,'\0',sizeof(dirName)); } ```
2017/09/10
[ "https://Stackoverflow.com/questions/46145283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8588921/" ]
The problem is that you are not passing `fun3on` to `fun2` so it won't be passed to `fun3`. In `do.call(fun2, list(var21, var22))`, change it to be `do.call(fun2, list(var21, var22, fun3on = fun3on, ...))`. Make sure to pass them as named arguments (I added the dots because you seem to have some in `fun3`). PS: don't name your returns unless you use evocative names.
7,725,115
I am about to migrate my Java project from `CVS` to `TFS`. I use eclipse IDE for development and I am unsure about the drawbacks of TFS over CVS. Please let me know if you know any.
2011/10/11
[ "https://Stackoverflow.com/questions/7725115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571260/" ]
As far as I know AS3 doesn't allow you to mix and match, both accessors should be the same. I generally don't supply a setter to make the property read only, and directly set `_name` internally. Because it's protected, it will be accessible to descendants.
56,628,495
I have a table1: ``` u_a_id d_c_s c_nm c_seq r_c_p 1 908 Test1 1 20 10 908 Test1 1 21 11 908 Test1 1 12 12759 908 Test1 1 31 12759 908 Test1 1 32 12861 878 Test2 1 43 12861 878 Test2 1 44 ``` I have SQL which finds the min r\_c\_p and max r\_c\_p which are repeated: ``` select u_a_id, d_c_s, c_nm, c_seq, count(*) cnt, min(r_c_p) min_rcp, max(r_c_p) max_rcp from table1 where c_nm not in ('VOID', 'WRONG') group by u_a_id, d_c_s, c_nm, c_seq having count(*) > 1; ``` I need to update d\_c\_s and c\_nm using output of above SQL as per following: * for min(r\_c\_p) -- d\_c\_s = d\_c\_s + 12000 and c\_nm = c\_nm || '- 1' * for max(r\_c\_p) -- d\_c\_s = d\_c\_s + 12000 and c\_nm = c\_nm || '- 2' The output would be: ``` u_a_id d_c_s c_nm c_seq r_c_p 1 908 Test1 1 20 10 908 Test1 1 21 11 908 Test1 1 12 12759 12908 Test1 - 1 1 31 12759 12908 Test1 - 2 1 32 12861 12878 Test2 - 1 1 43 12861 12878 Test2 - 2 1 44 ``` DB Fiddle - [Link](https://dbfiddle.uk/?rdbms=oracle_18&fiddle=e38f87e736964ee2802bd4c74e6e808e)
2019/06/17
[ "https://Stackoverflow.com/questions/56628495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893394/" ]
You can use following Merge statement. Not sure about performance. But you can try this and then we can think of any performance tuning if required. ``` MERGE INTO TABLE1 T1 USING ( SELECT U_A_ID, D_C_S, C_NM, C_SEQ, MIN(R_C_P) MIN_RCP, MAX(R_C_P) MAX_RCP FROM TABLE1 WHERE C_NM NOT IN ( 'VOID', 'WRONG' ) GROUP BY U_A_ID, D_C_S, C_NM, C_SEQ HAVING COUNT(1) > 1 ) T2 ON ( T1.U_A_ID = T2.U_A_ID AND T1.C_SEQ = T2.C_SEQ ) WHEN MATCHED THEN UPDATE SET T1.D_C_S = T1.D_C_S + 12000, T1.C_NM = CASE WHEN T1.R_C_P = T2.MIN_RCP THEN T1.C_NM || '- 1' ELSE T1.C_NM || '- 2' END WHERE T1.D_C_S = T2.D_C_S AND T1.C_NM = T2.C_NM AND T1.U_A_ID = T2.U_A_ID ``` [DB Fiddle demo](https://dbfiddle.uk/?rdbms=oracle_18&fiddle=38cb00b62cdcb058a9ed16e7bb3a1c0b) Cheers!!
30,722,370
I have a Solr 5.0.0 in production with a custom heap size like this ``` SOLR_JAVA_MEM="-Xms2g -Xmx2g" ``` When I tried to migrate to Solr 5.1.0 with the same configuration and start the server it returned a `OutOfMemoryError`. Looking to the Solr API I saw that the heap size was set to `512m`. My custom heap configuration is not working in Solr 5.1.0 and the server is starting with the default heap size value.
2015/06/09
[ "https://Stackoverflow.com/questions/30722370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4963025/" ]
It's a bug that occurs just in Solr 5.1. There is an issue resolved that fixed this bug in Solr 5.2. <https://issues.apache.org/jira/browse/SOLR-7454> The problem is that Solr 5.1 doesn't use `SOLR_JAVA_MEM` to set heap size. It uses `SOLR_HEAP` to set the min and max heap sizes with the same value like this: ``` SOLR_HEAP="2g" ``` This way solr will start with `-Xms=2g` and `-Xmx=2g` In Solr 5.2 this bug was fixed and the two `SOLR_JAVA_MEM` and `SOLR_HEAP` work fine.
53,569,886
I am working on a menu. I have a menu with many list items. What I want is when I resize the browser to small screens like (laptops and tablets) I want the overflowing `li's` to collapse and appear in a dropdown. Actual Menu. [![CSS navigation menu](https://i.stack.imgur.com/edXyV.png)](https://i.stack.imgur.com/edXyV.png) Responsive view for the same menu. [![Responsive menu navigation](https://i.stack.imgur.com/QSUOY.png)](https://i.stack.imgur.com/QSUOY.png) Here is the code structure. ```js var menuWidth = $('ul').width(); //get actual width of ul var listWidth = $.map($('ul li'), function(val) { return $(val).width(); }); //get width of each individual li in an array var arrayTotalValue = listWidth.reduce(function(a, b) { return a + b; }); //adding above array var totalWidth = Math.ceil(arrayTotalValue); //rounding up total value if (totalWidth > menuWidth) { $('li').css({ color: '#FF0000' }) } ``` ```css ul { display: flex; padding: 50px 0; box-sizing: border-box; align-items: center; width: 700px; overflow: visible; } li { text-decoration: none; color: #000000; font-size: 20px; text-transform: capitalize; border: 1px solid black; margin: 20px 10px; list-style: none; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <ul> <li class="menu-item">menu1</li> <li class="menu-item">menu2</li> <li class="menu-item">menu3</li> <li class="menu-item">menu4</li> <li class="menu-item">menu5</li> <li class="menu-item">menu6</li> <li class="menu-item">menu7</li> <li class="menu-item">menu8</li> <li class="menu-item">menu9</li> <li class="menu-item">menu10</li> <li class="menu-item">menu11</li> <li class="menu-item">menu12</li> <li class="menu-item">menu13</li> <li class="menu-item">menu14</li> <li class="menu-item">menu15</li> <li class="menu-item">menu16</li> </ul> ``` Here is the [codepen](https://codepen.io/Wahed98666/pen/mQvVpK) link of my code. Any kind of suggestion and answers will be helpful.
2018/12/01
[ "https://Stackoverflow.com/questions/53569886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8040185/" ]
First, I would adjust the CSS in way to make it easier. I will enable the wrap (*remove the flexbox*) and hide all the elements that aren't in the first row by setting a `max-height` and `overflow:hidden`. Then I will add the *click* element that we will see only when there is at least one element hidden. I used a pseudo element trick to hide it. ```css ul { padding:5px 40px 5px 5px; box-sizing: border-box; overflow: hidden; max-height:55px; position:relative; } li { display:inline-block; text-decoration: none; color: #000000; font-size: 20px; text-transform: capitalize; border: 1px solid black; margin:10px; list-style: none; position:relative; } li:last-child::after { content:""; position:absolute; left:102%; width:100vw; top:-10px; bottom:-10px; background:#fff; z-index:2; } .click { background:red; position:relative; width:40px; height:40px; margin-left:auto; margin-top:-65px; margin-right:5px; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <ul> <li class="menu-item">menu1</li> <li class="menu-item">menu2</li> <li class="menu-item">menu3</li> <li class="menu-item">menu4</li> <li class="menu-item">menu5</li> <li class="menu-item">menu6</li> <li class="menu-item">menu7</li> <li class="menu-item">menu8</li> <li class="menu-item">menu9</li> <li class="menu-item">menu10</li> <li class="menu-item">menu11</li> <li class="menu-item">menu12</li> <li class="menu-item">menu13</li> <li class="menu-item">menu14</li> </ul> <div class="click"></div> ``` Now you may add some JS in order to show the hidden elements when clicking the red square by adjusting their position to make them look like a dropdown. To select a hidden elements you need to test if its `offesetTop` value is bigger than a certain value. ```js var h = 30; var val = 0; $('.click').click(function() { if ($('ul').hasClass('show')) { $('ul').removeClass('show'); $('ul li.menu-item').removeClass('drop') return; } val = 0; $('ul li.menu-item').each(function() { var of = $(this).offset().top - $('ul').offset().top; if ( of > 20) { $(this).addClass('drop'); $(this).css('top', 'calc(100% + ' + val + 'px)'); val += h; } $('ul').addClass('show'); }) }) ``` ```css ul { padding: 5px 40px 5px 5px; box-sizing: border-box; overflow: hidden; max-height: 55px; position: relative; } ul.show { overflow: visible; } li { display: inline-block; text-decoration: none; color: #000000; font-size: 20px; text-transform: capitalize; border: 1px solid black; margin: 10px 8px; list-style: none; position: relative; } li.drop { display: block; position: absolute; right: 0; } li:last-child::after { content: ""; position: absolute; left: 102%; width: 100vw; top: -10px; bottom: -10px; background: #fff; z-index: 2; } li.drop::after { content: none; } .click { background: red; position: relative; width: 40px; height: 40px; margin-left: auto; margin-top: -65px; margin-right: 5px; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <ul> <li class="menu-item">menu1</li> <li class="menu-item">menu2</li> <li class="menu-item">menu3</li> <li class="menu-item">menu4</li> <li class="menu-item">menu5</li> <li class="menu-item">menu6</li> <li class="menu-item">menu7</li> <li class="menu-item">menu8</li> <li class="menu-item">menu9</li> <li class="menu-item">menu10</li> <li class="menu-item">menu11</li> <li class="menu-item">menu12</li> <li class="menu-item">menu13</li> <li class="menu-item">menu14</li> </ul> <div class="click"></div> ``` The above is a simplified example where I used some hardcoded values that you can easily adjust or make dynamic.
342,290
I have added some code in header.php but it is not showing in shop page. It is showing all other pages. ``` if( is_home() || ! $ed_section || ! ( is_front_page() || is_page_template( 'template-home.php' ) ) ){ echo '<div class = "container"><div id="content" class="site-content"> <div class="tab1"> <a class="cat_button" href="https://packnchew.com/product-category/appetizers-snacks/">Appetizers & Snacks</a> <a class="cat_button" href="https://packnchew.com/product-category/fillers-international/">Fillers International</a> <a class="cat_button" href="https://packnchew.com/product-category/meals-more/">Meals and More</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-indian/">Mains Indian</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-oriental/">Mains Oriental</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-international/">Mains International</a> <a class="cat_button" href="https://packnchew.com/product-category/desserts-drinks/">Desserts And Drinks</a> </div> <div class = "row">'; } ?> ``` This is my code and I added the lines `<div class="tab1"> <a class="cat_button" href="https://packnchew.com/product-category/appetizers-snacks/">Appetizers & Snacks</a> <a class="cat_button" href="https://packnchew.com/product-category/fillers-international/">Fillers International</a> <a class="cat_button" href="https://packnchew.com/product-category/meals-more/">Meals and More</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-indian/">Mains Indian</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-oriental/">Mains Oriental</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-international/">Mains International</a> <a class="cat_button" href="https://packnchew.com/product-category/desserts-drinks/">Desserts And Drinks</a> </div>` This tab class is showing in all pages excepts shop page, category page, product page.
2019/07/06
[ "https://wordpress.stackexchange.com/questions/342290", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170624/" ]
You could use AJAX if you don't want to reload the current page — i.e. upon clicking the "Accept" button, make an AJAX request to update the user metadata, all without leaving the current page. However, the solution I'm proposing is *not* using AJAX; instead, we simply submit the form (set its `action` attribute value) to the homepage and then we use the `template_redirect` hook to update the metadata (and redirect back to the previous or referring page). The Steps --------- 1. Change the `form` tag to: ``` <form method="post" action="<?php echo esc_url( home_url() ); ?>"> ``` and add this [nonce](https://codex.wordpress.org/WordPress_Nonces) field: ``` <?php wp_nonce_field( 'accept-gdpr', 'accept_gdpr_nonce' ); ?> ``` so your `form` now looks like: ``` <form method="post" action="<?php echo esc_url( home_url() ); ?>"> <input name="accept" type="checkbox" value="Gdpr" required /> I accept the GDPR <input type="submit" id="accept-button" value="Accept" /> <?php wp_nonce_field( 'accept-gdpr', 'accept_gdpr_nonce' ); ?> </form> ``` 2. Add this to the theme `functions.php` file: ``` function accept_gdpr() { // Check if the user is authenticated. if ( ! is_user_logged_in() ) { return; } // Check if we have all necessary data. if ( empty( $_POST['accept_gdpr_nonce'] ) || empty( $_POST['accept'] ) || 'Gdpr' !== $_POST['accept'] ) { return; } // Verify the nonce. if ( ! wp_verify_nonce( $_POST['accept_gdpr_nonce'], 'accept-gdpr' ) ) { return; } // Update the meta. update_user_meta( get_current_user_id(), 'META_KEY', '1' ); // Redirect back to the previous page. wp_safe_redirect( wp_get_referer() ); exit; } add_action( 'template_redirect', 'accept_gdpr' ); ``` **Notes:** 1. The `Gdpr` as in `'Gdpr' !== $_POST['accept']` is the same as in the `<input name="accept" type="checkbox" value="Gdpr" required />` above. 2. *Be sure to replace the `META_KEY` with the actual meta key.* 3. I believe that the GDPR acceptance is aimed at logged-in users only, so that's why I used `is_user_logged_in()` and `get_current_user_id()` in the above code/function. UPDATE ------ `wp_safe_redirect()` didn't work for the OP, so he used `wp_redirect()`.
42,745,389
I'm new to C# coming from python, and am unclear on exactly how the `IEnumerable` object behaves, even after having read the MSDN documentation. For instance, the `IEnumerable` requires an int, but the following code works fine: ``` IEnumerable<double> squares = Enumerable.Range(1, 100).Select(x => Math.Pow(x, 2)); ``` However, ``` IEnumerable<double> square_ = Enumerable.Range(1, 100); ``` Throw's the compilation error that you cannot implicitly convert type 'System.Collections.Generic.IEnumerable int' to 'System.Collections.Generic.IEnumerable double' I'm not really sure if this is just a fundamental misunderstanding of how Enumerable works, how objects work in C#, or something else entirely, and would greatly appreciate help and some guidance on where to read for a novice to get a better idea. Thanks very much in advance.
2017/03/12
[ "https://Stackoverflow.com/questions/42745389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1492284/" ]
Because [`Math.Pow`](https://msdn.microsoft.com/library/system.math.pow(v=vs.110).aspx) returns a `double`, so the `.Select(x => Math.Pow(x, 2));` returns a `IEnumerable<double>`, so exactly the type you declared. The [`Enumerable.Range`](https://msdn.microsoft.com/it-it/library/system.linq.enumerable.range(v=vs.110).aspx) returns a `IEnumerable<int>` that isn't compatible with a `IEnumerable<double>`. Clearly you could: ``` IEnumerable<double> squares = Enumerable.Range(1, 100).Select(x => (double)x); ``` This would cast the single elements of the `Enumerable.Range` to `double`, by using a lambda function `int -> double` (that from an `int x` returns a `double`)
70,659,310
I have two python dictionaries, say, ``` d1 = {'k1':'v1', 'k2':'v2', 'k3':'v3'} d2 = {'v1':'w1','v2':'w2','v5':'w5'} ``` what I need is a merged dict like this - ``` mergeDict= {k1:(v1,w1), k2:(v2,w2), k3:(v3)} ``` Whatever I have been able to look up or read has dealt with appending dictionaries, nothing like this. I called this chaining since value of first dict is potentially the key in second dict. So far i have done this through typical loop and lookup on keys(). Wondering if there is a more pythonic way to achieve this that i might be missing here ?
2022/01/10
[ "https://Stackoverflow.com/questions/70659310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459222/" ]
A dict comprehension seems to work: ``` out = {k: (v, d2[v]) if v in d2 else (v,) for k,v in d1.items()} ``` Output: ``` {'k1': ('v1', 'w1'), 'k2': ('v2', 'w2'), 'k3': ('v3',)} ```
12,627,913
I'm stumped on a job my Software Director needs to fill. I am looking for a Developer to create MSI installers using InstallShield. I keep seeing resumes of people who call themselves "Software Packagers" yet they say they wrote the Installers. If the manager sees the title "packager" he says no. What's the difference? Thanks for any help in explaining this! It's a learning curve. Katie
2012/09/27
[ "https://Stackoverflow.com/questions/12627913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1704254/" ]
A "packager" is typically someone who somes from an Enterprise IT background (SysAdmin) who has learned how to use a repackaging tool to create MSI's. He might also have some experience in distribution tools such as SCCM and scripting using VBScript and PowerShell. Maybe an MCSE also. This person tends to work in IT departments of non-tech companies. A "developer" or "engineer" ( or anyone who avoids the use of the word package/packager ) typically has more of a background in SCCM principals such as source control, build automation, release engineering and a more detailed understanding of installers. They typically have a deeper understanding of InstallShield, Windows Installer, Windows Installer XML and they might even have a developement background in C, C++, VB, C# or other languages. This person tends to work for tech companies in a software development organization. These are generalizations and may not fit all candidates. I actually fit the latter but currently work for the former. Take a deeper look at the resumes and see how the skills and experience match my description. Otherwise, yes, I agree. If they call themselves a 'packager' I typically skip right past their resume.
17,055,702
I want to allow only alpha numeric characters and spaces, so I use the following; ``` $name = preg_replace('/[^a-zA-z0-9 ]/', '', $str); ``` However, that is allowing underscores "\_" which I don't want. Why is this and how do I fix it? Thanks
2013/06/11
[ "https://Stackoverflow.com/questions/17055702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2127206/" ]
The [character class](http://ca1.php.net/manual/regexp.reference.character-classes.php) range is for a range of characters between two code points. The character `_` is included in the range `A-z`, and you can see this by looking at the ASCII table: ``` ... Y Z [ \ ] ^ _ ` a b ... ``` So it's not only the underscore that's being let through, but those other characters you see above, as stated in the [documentation](http://ca1.php.net/manual/regexp.reference.character-classes.php): > > Ranges operate in ASCII collating sequence. ... For example, `[W-c]` is equivalent to `[][\^_```wxyzabc]`. > > > To prevent this from happening, you can perform a case insensitive match with a single character range in your character class: ``` $name = preg_replace('/[^a-z0-9 ]/i', '', $str); ```
7,333,815
for some very hard reason i get inserted additional ... before the beggining of my page, before my real `<head>` starts. This comes from another app i cant remove it. So the code looks like this: ``` <html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="http://www.facebook.com/#!/nagradnaigra123.si?sk=app_163054567105477">here</a>.</h2> </body></html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> ... normal content from here on... ``` So im asking how on earth can i remove the additional head on the begginig of my page. i can edit css, add javascript, jquery, php... but i just dont know the solution to this problem. Is this possible at all?
2011/09/07
[ "https://Stackoverflow.com/questions/7333815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189451/" ]
You have to use the Context like this: ``` Context ctx = getApplicationContext(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); ```
10,285,740
When I verify the signature of my application: ``` jarsigner -verify -verbose -certs testapp.apk ``` it gives me the error: `jarsigner: java.lang.SecurityException: invalid SHA1 signature file digest for res/drawable-xhdpi/breadcrumb_grey_white.png` How to resolve this?
2012/04/23
[ "https://Stackoverflow.com/questions/10285740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/611315/" ]
make sure to delete the META\_INF folder in the apk before signing it. Also, if you are using JDK 7, then include the the option -sigalg MD5withRSA when signing with the jarsigner along with -digestalg SHA1 mentioned by Andrejs
69,069,719
I am learning react js. I am a very beginner at this topic. But when I am doing setup to create a react environment I got an error. I have tried to solve the problem by [Charles Stover blog in medium](https://charles-stover.medium.com/resolving-prettier-react-context-getphysicalfilename-is-not-a-function-52a250f68291). But I got an error `Command "up" not found`. Here's my index.js file: ``` import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import reportWebVitals from './reportWebVitals'; ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById('root') ); reportWebVitals(); ``` My package.json file: ``` { "name": "myreact", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "web-vitals": "^1.0.1" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "lint": "yarn add -D prettier && yarn add -D babel-eslint && npx install-peerdeps --dev eslint-config-airbnb && yarn add -D eslint-config-prettier eslint-plugin-prettier" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "babel-eslint": "^10.1.0", "eslint": "7.2.0", "eslint-config-airbnb": "18.2.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-jsx-a11y": "6.4.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "7.21.5", "eslint-plugin-react-hooks": "1.7.0", "prettier": "^2.3.2" } } ``` When I am running `yarn start` in terminal, I am getting an error. ``` Error while loading rule 'prettier/prettier': context.getPhysicalFilename is not a function Occurred while linting F:\react-projects\myreact\src\index.js ``` Now what should I do?
2021/09/06
[ "https://Stackoverflow.com/questions/69069719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16535082/" ]
I got two different solution. 1. remove ``` "prettier/prettier": [ "error", { "trailingComma": "es5", "singleQuote": true, "printWidth": 100, "tabWidth": 4, "semi": true, "endOfLine": "auto" } ] ``` from `.eslintrc` folder and change react script version from 4.0.3 to 4.0.1 and run `npm install`. 2. Use `yarn upgrade -R eslint` and change react script version from 4.0.3 to 4.0.1 and run `npm install`.
7,749,696
Facing an interesting issue when I am using WCF Web API with Hammock and WP7. As you know, WCF Web API allows you to change the response type based on what you specify in the Accept header. For e.g. if you send Accept:application/json, the response is JSON, if you specify application/xml you get XML and so on. So I created my Web API which works perfectly fine from a Web Browser. As expected I get the types I want. Hwoever, when I use this from WP7, it doesn't matter what the Accept header is, it looks like WP7 replaces it to */* and I only get back XML. I know for a fact that it isn't Hammock that is the issue because I tried with Facebook Graph API. If I change the Accept to say: **application/hello**, I get a bad request error. However, when I do that with WP7 in C# code, I get absolutely no errors and the return type is XML irrespective of what I send. To circumvent this issue, I created a JSON.Net Serializer in my WCF Web API. Everything worked great until I started using HttpResponseMessage in my methods as return types. Now even though i have a JSON serializer, I get XML for all methods where I use the HttpResponseMessage. As you can see, I am in lala land now. Can anyone provide any feedback? Any help is highly appreciated.
2011/10/13
[ "https://Stackoverflow.com/questions/7749696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387014/" ]
I would create a server side object matching the JSON object you are posting to the server. ``` public class DataPackage { public string CostType {get; set;} public string CostName {get; set;} public bool isEditable {get; set;} ... } ``` In your webservice you can setup the service definition like this: ``` [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json, XmlSerializeString = false)] public void MyWebservice(DataPackage NewDataSet) { ... } ``` You need to tell your client side posting script that you are sending json: ``` contentType: 'application/json' ``` If I remember correctly this will tell ASP.NET to deserialize your JSON object into the .NET class.
66,938,525
Essentially I'm attempting to display the ID, Title, total quantity, and total sales price of books within a book store. Currently I'm able to display the ID, Title, and Total Quantity - OR the ID, Title, and Total sales price, I can not however figure out how to retrieve both the total quantity and sales price at the same time from this table. This Query successfully gives me the ID, Title and Quantity: ``` SELECT ID,Title,(SELECT Sum(Quantity) from Sale where BookId = Book.id ) as Quantity from Book; ``` This Query successfully gives me the ID, Title and Sales Price: ``` SELECT ID,Title,(SELECT Sum(UnitPrice) from Sale where BookId = Book.id ) as Price from Book; ``` So how could I retrieve both the Quantity and Sales Price in our query? Both values are within the same table, but there are two tables being used here. Heres my current HTML that im using to loop through and display the results of the query: ``` <!DOCTYPE html> <html lang="en"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" href="new.css"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <nav class="navbar navbar-default navbar navbar-inverse"> <div class="container"> <h2> <a class="head" href="base.php" style="text-decoration: none;">Database Project</a> <a class="btn btn-danger btn-sm main" href="login.php" role="button">Sign Out</a></h2> </div> </nav> <div class="container"> <div class="jumbotron"> <h1>Book Report:</h1><br> <table> <tr> <th>ID</th> <th>Title</th> <th>Quantity</th> <th>Total Sale Price</th> </tr> <?php $conn = mysqli_connect("localhost","root","","Zion"); if ($conn-> connect_error){ die("Connection Failed:". $conn-> connect_error); } $sql = "SELECT ID,Title,(SELECT Sum(Quantity) from Sale where BookId = Book.id ) as Quantity,(SELECT Sum(UnitPrice) from Sale where BookId = Book.id ) as Price from Book"; $result = $conn-> query($sql); if ($result = $conn->query($sql)) { while($row = $result->fetch_assoc()) { echo "<tr><td>". $row["ID"] . "</td><td>". $row["Title"]."</td><td>". $row["Quantity"]. "</td><td>". "$".$row["Price"]. "</td></tr>"; } echo"</table>"; } $conn-> close() ?> <!-- Generate a report that for each book, displays the book id, the book title, the quantity and the total sales price, sorts by the book id in increasing order; --> </div> </body> </html> ``` Thanks!
2021/04/04
[ "https://Stackoverflow.com/questions/66938525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15549232/" ]
Good day, You can try this query ``` SELECT ID,Title,(SELECT Sum(Quantity) from Sale where BookId = Book.id ) as Quantity,(SELECT Sum(UnitPrice) from Sale where BookId = Book.id ) as Price from Book; ```
50,177,110
I have the problem at the first Woocommerce page. I don't have any product at the shop. For this reason, Woocommerce shows "No Products" message on the first page. Now I want to change this message. How do I do this? ![enter image description here](https://i.stack.imgur.com/k4pI7.jpg) Shop address: <http://shahroodantenna.ir/shop/>
2018/05/04
[ "https://Stackoverflow.com/questions/50177110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9562846/" ]
Try the following, where you can customize the "No Product" message: ``` add_action( 'woocommerce_no_products_found', function(){ remove_action( 'woocommerce_no_products_found', 'wc_no_products_found', 10 ); // HERE change your message below $message = __( 'No products were found matching your selection.', 'woocommerce' ); echo '<p class="woocommerce-info">' . $message .'</p>'; }, 9 ); ``` Code goes in function.php file of your active child theme (or active theme). Tested and works.
55,893,704
I'm learning about memoization in recursive functions and stumbled upon a fibonacci-example on Youtube. I never saw the person run the code so perhaps he wrote it wrong. When I copied the code and tried to run it, i first got an error since I declared memo without a range, so I simply set the range to the input + 1 (since I'm not using the 0-index) and thus solved that problem. But now I'm stuck at the wrong return value. ``` def fib(num, memo=[]): if num == 0: return 0 elif num == 1 or num == 2: return 1 elif memo[num] != None: return memo[num] else: memo[num] = fib(num-1, memo) + fib(num-2, memo) return memo[num] uInput = int(input("Fibonacci: ")) memo = list(range(uInput + 1)) fibNum = fib(uInput, memo) print(fibNum) ``` The code above throws no error but simply returns the "uInput" value. So if I input 6, for the 6st fibonacci number, the program returns 6 instead of 8, which is the actual 6st number. I am at a loss as to why this occurs. When I have googled the issue I have found threads that suggested using dicts instead of lists. Thats all fine if that is the only way to do it. But if there is a way to make it work with a list I would like to understand how that is done so that I understand why I run in to this problem.
2019/04/28
[ "https://Stackoverflow.com/questions/55893704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11374906/" ]
Accessing `memo[num]` will never return `None`. If `num` is out of range, a `IndexError` will be raised. Moreover, you typically do not want to pass a `memo` argument to your function and instead let it rely on its own `memo` object. In your case, you want to check that the index is in range with `len`. Whenever `num` is out of range, the output must be computed recursively and memoized. Only then can it be returned. ``` def fib(num, memo=[0, 1]): if num >= len(memo): memo.append(fib(num - 1) + fib(num - 2)) return memo[num] print(fib(10)) # 55 ``` By the way, the above can easily be transformed into an iterative function which is typically more efficient in Python. ``` def fib(num, memo=[0, 1]): while num >= len(memo): memo.append(memo[-1] + memo[-2]) return memo[num] ```
30,253,253
I need output of Floyd triangle like: ``` 1 0 1 1 0 1 0 1 0 1 ``` I tried. I didn't get it exactly. Can anyone explain the logic? This is the code I tried: ``` k = 0 for i in 1..5 for j in 1..5 if (i%2)==0; k = (j%2==0) ? 1:0; else; k = (j%2==0) ? 0:1; puts k,''; end end puts end ```
2015/05/15
[ "https://Stackoverflow.com/questions/30253253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4779465/" ]
you should convert your object as a json string to store it, then read the json and transform it back to your object. you can use Gson in order to do so. ``` //store Gson gson = new Gson(); String json = gson.toJson(myObject); jedis.set(key,json); //restore String json = jedis.get(key); MyObject object=gson.fromJson(json, MyObject.class); ```
4,231
I can hobble my way around Illustrator, but I'm far from a pro, so please bear with me here. For most of my work in Illustrator, I use basic shapes. I draw a rectangle; move around the anchors; subtract a circle from the middle; etc. When I'm done, I've got a drawing made up of lots of individual shapes (objects) that compose a picture. I've recently been given an illustration that the artist did with Live Paint. I've never used that feature myself, but it reminds me of virtual stained glass. The outline of all the shapes is one big piece, then the colors were filled in one by one. The problem is that I can't seem to manipulate parts of the illustration like I can with individual objects. Is there a way I can break up that Live Paint mess in to a group of standard objects?
2011/10/19
[ "https://graphicdesign.stackexchange.com/questions/4231", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/2690/" ]
You can use the `Direct Selection Tool` (A) to manipulate the *original* objects that went into the Live Paint object. Also, `Object > Expand...` from the menubar will break the Live Paint object up into component shapes, as if the object were 'flattened', which you can then manipulate. They'll probably be within a couple nested groups, so you'll have to `Ungroup` a few times or use the `Direct Selection Tool` to get at them.
39,043,326
Is it possible to compute feature importance (with Random Forest) in scikit learn when features have been onehotencoded?
2016/08/19
[ "https://Stackoverflow.com/questions/39043326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4502957/" ]
Here's an example of how to combine feature names with their importances: ```python from sklearn.feature_extraction import DictVectorizer from sklearn.preprocessing import FunctionTransformer from sklearn.ensemble import RandomForestClassifier from sklearn.pipeline import make_pipeline # some example data X = pd.DataFrame({'feature': ['value1', 'value2', 'value2', 'value1', 'value2']}) y = [1, 0, 0, 1, 1] # translate rows to dicts def row_to_dict(X, y=None): return X.apply(dict, axis=1) # define prediction model ft = FunctionTransformer(row_to_dict, validate=False) dv = DictVectorizer() rf = RandomForestClassifier() # glue steps together model = make_pipeline(ft, dv, rf) # train model.fit(X, y) # get feature importances feature_importances = zip(dv.feature_names_, rf.feature_importances_) # have a look print feature_importances ```
10,074
A nearby star has crossed Chandrasekhar's limit. How do we come to know when it will undergo supernova explosion? Or has it already undergone supernova explosion?
2015/03/08
[ "https://astronomy.stackexchange.com/questions/10074", "https://astronomy.stackexchange.com", "https://astronomy.stackexchange.com/users/6720/" ]
Just add the prefix "exo-". At least exocomet and exomoon seem to be [established](https://en.wikipedia.org/wiki/Exocomet).
16,779,357
I attempted implementation of a new feature on working code. However, I know from commenting out that the following lines of code are causing my program to crash. ``` tmp = (char*)realloc(list->array[list->size], sizeof(char)*nameLength); list->array[list->size] = tmp; ``` `list->array[list->size]` is defined in a struct in a .h file. `list->size` is an int that increases as the size of the array increases. I know that the .h file is correct and am pretty certain the rest of my code was written correctly because I tested it all. However I can't seem to figure out this `realloc` function. Can somebody please help me? I've searched stackoverflow and couldn't find the answer. This is my first time posting a question on stackoverflow. I hereby promise to help others on this site if I can get some help with this problem. ``` typedef struct ArrayList { // We will store an array of strings (i.e., an array of char arrays) char **array; // Size of list (i.e., number of elements that have been added to the array) int size; // Length of the array (i.e., the array's current maximum capacity) int capacity; } ArrayList; ``` I didn't want to clutter the post with long code. But just in case someone can find something I overlooked I am posting my main.c. ``` int main(void) { int i; char buffer[32]; ArrayList *L1 = createArrayList(-1); FILE *ifp = fopen("names.txt", "rb"); //Read all names from the file and add them to L1. while (fscanf(ifp, "%s", buffer) != EOF) put(L1, buffer); //printf("the size is %d", L1->size); //test for(i=0; i<L1->capacity; i++) { //free columns free((void*)L1->array[i]); } free((void*)L1->array); //free rows free((void*)L1); // free struct system("pause"); return 0; } char * put(ArrayList *list, char *str) { int i = 0,length = 0, nameLength; char* tmp, tmp2; //free((void*)list->array[list->size]); //free columns //list->array[list->size] = NULL; //set old pointer to NULL nameLength = strlen(str)+1; //Aquire length of name +1 tmp = (char*)realloc(list->array[list->size], sizeof(char)*nameLength); list->array[list->size] = tmp; //list->array[list->size] = str; //strcpy(list->array[list->size], str); printf("the name in the .txt file is %s: put \n", list->array[list->size]); //if array is full add space length = (list->capacity)*2 + 1; //if ( list->capacity <= list->size ) { ArrayList *nlist = expandArrayList(list, length); //} list->size ++; } ArrayList *expandArrayList(ArrayList *list, int length) { int i; //create newCharArray char **newCharArray = (char*) malloc(sizeof(char*)*(length+1)); //alocate rows//2 for(i=0; i<length+1; i++) { // should fill ten rows + 1//2 newCharArray[i] = malloc(100 * sizeof(char*)); //alocate Columns newCharArray[i] = "yoO"; } //copy old list-Array into newCharArray for( i=0; i<list->capacity; i++) { //was length newCharArray[i] = list->array[i]; } //print the values you inserted //test for( i=0; i<list->capacity + 1; i++) {//2 printf("the value in slot %d is %s : expandArrayList \n", i, newCharArray[i]); } //free the list->array columns and rows for( i=0; i<list->capacity; i++) { free((void*)list->array[i]); } free((void*)list->array); //set adress of newCh.. = our old Struct list->array = newCharArray; //print to test we did what was asked //test for( i=0; i<length + 1; i++) {//2 printf("value in slot %d is %s : expandArrayList \n", i, list->array[i]); } return list; } ArrayList *createArrayList(int length) { int ncolumns, nrows, i; char stringVar[5]; //set rows = empty if(length < DEFAULT_INIT_LEN) length = DEFAULT_INIT_LEN; nrows = length; ArrayList *theArray; theArray = (ArrayList*)malloc (sizeof(struct ArrayList)); //alocate struct theArray->array = (char*)malloc(sizeof(char*)*(nrows)); //alocate Rows 10th row will be null for(i=0; i<nrows; i++) { // should fill ten rows theArray->array[i] = (char*)malloc(2 * sizeof(char)); //alocate Columns //realloc later theArray->array[i] = '\0'; //(char*)"pointer char will be returned malloc(100*sizeof(char): char*100 will be alocated } //theArray->array[nrows] = '\0'; //should fill the 11'th pointer slot array index 10 theArray->capacity = nrows; //total rows that are available for use ("not including last null") theArray->size = 0; //Amount of rows used printf("capacity = %d :createArraylist \n", theArray->capacity); return theArray; } ```
2013/05/27
[ "https://Stackoverflow.com/questions/16779357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425652/" ]
CAP theorem is actually a bit misleading. The fact you can have a CA design is nonsense because when a partition occurs you necessarily have a problem regarding consistency (data synchronization issue for example) or availability (latency). That's why there is a more accurate theorem stating that : During a *partition* in a distributed system, you must chose between **consistency** and **availability**. Still in practice it is not that simple. You should note that the choice between consistency and availability isn't binary. You can even have some degree of both. For example regarding ACID, you can have atomic and durable transactions with NoSQL, but forfeit a degree of isolation and consistency for better availability. Availability can then be assimilated to latency because your response time will depend on several factors (is the nearest server available ?). So, to answer your question, this is usually marketing bullshit. You need to actually scratch the surface to see what the solution is exactly gaining and forfeiting. If you want deeper explanations you can look [here](http://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed), [here](http://blogs.the451group.com/information_management/2011/12/14/newsql-cap-theorem-and-latency-tolerance/) or [here](http://www.bailis.org/blog/when-is-acid-acid-rarely/).
2,782
I am used to calling this thing "covariance matrix" and only very rarely see and here it being called "variance-covariance matrix". However, our tag here is called [variance-covariance](https://stats.stackexchange.com/questions/tagged/variance-covariance "show questions tagged 'variance-covariance'"). It used to slightly annoy me all the time, so I have recently created a tag [covariance-matrix](https://stats.stackexchange.com/questions/tagged/covariance-matrix "show questions tagged 'covariance-matrix'") and voted to make it the synonym of the main tag. The voting has not finished yet$^\*$, but in the meantime I see that my newly created tag is being used by other people. This makes me wonder: shall we maybe have [covariance-matrix](https://stats.stackexchange.com/questions/tagged/covariance-matrix "show questions tagged 'covariance-matrix'") as the master tag, and [variance-covariance](https://stats.stackexchange.com/questions/tagged/variance-covariance "show questions tagged 'variance-covariance'") as its synonym? I tried some google searches to establish the usus: `"covariance matrix"` search gives 3 mln results, and `"variance-covariance matrix"` only 400k (this is included in 3 mln too). On google scholar the numbers are 900k and 100k respectively. So it seems that "covariance matrix" is indeed a more common expression used over 80% of the times. I am going to post two answers, please upvote the one with your preferred master tag. --- *$^\*$The voting is likely to never finish; apart from me, only one single person (@gung) has taken part in it so far. Sad as it is, we will need a moderator to create this synonym one way or another.*
2015/10/19
[ "https://stats.meta.stackexchange.com/questions/2782", "https://stats.meta.stackexchange.com", "https://stats.meta.stackexchange.com/users/28666/" ]
### The master tag should be [covariance-matrix](https://stats.stackexchange.com/questions/tagged/covariance-matrix "show questions tagged 'covariance-matrix'").
7,387
Has she only her feet loose? Or is she only good all around?
2014/10/10
[ "https://russian.stackexchange.com/questions/7387", "https://russian.stackexchange.com", "https://russian.stackexchange.com/users/4270/" ]
The colloquial expression **хоть куда** means great. Examples: *На Лизавете Григорьевне Муромской, ― отвечал Иван Петрович; ― невеста хоть куда; не правда ли?* (Пушкин, "Барышня-крестьянка"). *Мой Митрофанушка из-за книги не встаёт по суткам... жаль, жаль, да подумаешь: зато будет и детина хоть куда.* (Фонвизин, "Недоросль") *Поглядел на карты: масть хоть куда, козыри есть.* (Н. В. Гоголь. Пропавшая грамота) *губерния Крутогорская хоть куда* (Салтыков-Щедрин) When spoken about a girl, I'd say it means that she is great for marry her. This expression is about marriage, not one-time sex. (Often same about guys.) There is one more sense in "хоть куда": when spoken about relatively old people, it means he/she is perfecly able to do what young people do (work, sex, anything).
14,767,282
I'm developing an app which needs to rotate the mapView with a compass. I know how to rotate the camera but I need to rotate the mapView with the compass. the center point should be the current location. I found codes for Maps V1 but I need to do it with Maps V2
2013/02/08
[ "https://Stackoverflow.com/questions/14767282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/575202/" ]
OK, i figured it out myself. first you need to calculate the bearing from the compass. then the Maps api-2 camera can be rotated. ``` public void updateCamera(float bearing) { CameraPosition currentPlace = new CameraPosition.Builder() .target(new LatLng(centerLatitude, centerLongitude)) .bearing(bearing).tilt(65.5f).zoom(18f).build(); googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(currentPlace)); } ``` set `SensorListener` in your code and call this method in `onSensorChanged` event. i have added a tilt value so the map will rotate in 3D.
1,143,175
I was thinking about, of the derivative as an operator, like $\frac{dy}{dx}$, and i am having trouble thinking on the things you do in courses of differential equations, with the $dx, dy$, like passing them around from one side of the equation, and to the other, with apparently no problem, i don't worry much about it, because in a lot of physics texts they do that, and it works, But when i ask about WHY?, they say, don't worry for now, if it works, don't worry. Once i ask a mathematician, why and he refereed to "high level math" subjects and books, and i couldn't get all he said, so i am looking for a "formal" simplest answer to "Why can we do Algebra with the Differential operators, why does it work, and until what point does it works"
2015/02/11
[ "https://math.stackexchange.com/questions/1143175", "https://math.stackexchange.com", "https://math.stackexchange.com/users/197741/" ]
The derivative and differentials are two different things: ![enter image description here](https://i.stack.imgur.com/bM0wM.png) Consider the above picture, then from $\tan \alpha = f'(x)$ you get: $$dy=f'(x) \Delta x$$ Therefore, differential $dy$ is described as: $$(dy)(x,\Delta x)=f'(x)\Delta x$$ After you describe $\Delta x$ in terms of $dx$ in a similar manner you get: $$dy=\frac{dy}{dx}dx$$ Here, $\frac{dy}{dx}$ is not a division of differentials, it is the Leibniz's notation of derivative. But wait, division of differentials is equal to the derivative. So you can pass differentials from one side to another. **Remarks**: -Recognize that the derivative is defined as an increase in the function whereas the differential is defined as an increase in the tangent line of a function. -The difference between differential and derivative is clear when there are multiple independent variables. -I am not an expert. I may be totally wrong in a rigorous perspective.
12,528,555
i have some jquery code to show iframe in modal window. this code: ``` <script type="text/javascript"> $(document).ready(function() { $("#modalDiv").dialog({ modal: true, autoOpen: false, height: '800', width: '800', draggable: false, resizeable: false, title: 'IFrame Modal Dialog' }); $('#goToMyPage').click( function() { url = '/addnews.html'; $("#modalDiv").dialog("open"); $("#modalIFrame").attr('src',url); return false; }); }); </script> ``` HTML: ``` <a id="goToMyPage" href="#">Go to My Page</a> <div id="modalDiv"> <iframe id="modalIFrame" width="100%" height="100%" marginWidth="0" marginHeight="0" frameBorder="0" scrolling="auto" title="Dialog Title"></iframe> </div> ``` i just can use for 1 link. this link: ``` url = '/addnews.html'; ``` HTML: ``` <a id="goToMyPage" href="#">Go to My Page</a> ``` how i can use this code for 4-5 links?
2012/09/21
[ "https://Stackoverflow.com/questions/12528555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1446718/" ]
you can send url within addition params in a tag ``` <a id="goToMyPage" href="#" data-url="some-url" >Go to My Page</a> ``` and use it in your event ``` $('.goToMyPage').click( function(e) { e.preventDefault(); url = $(this).attr('data-url'); $("#modalDiv").dialog("open"); $("#modalIFrame").attr('src',url); return false; }); ```
17,538,235
Consider (Assume code runs without error): ``` import matplotlib.figure as matfig ind = numpy.arange(N) width = 0.50; fig = matfig.Figure(figsize=(16.8, 8.0)) fig.subplots_adjust(left=0.06, right = 0.87) ax1 = fig.add_subplot(111) prev_val = None fig.add_axes(ylabel = 'Percentage(%)',xlabel='Wafers',title=title,xticks=(ind+width/2.0,source_data_frame['WF_ID'])) fig.add_axes(ylim=(70,100)) for key,value in bar_data.items(): ax1.bar(ind,value, width,color='#40699C', bottom=prev_val) if prev_val: prev_val = [a+b for (a,b) in zip(prev_val,value)] else: prev_val=value names= [] for i in range(0,len(col_data.columns)): names.append(col_data.columns[i]) ax1.legend(names,bbox_to_anchor=(1.15, 1.02)) ``` I now want to save my figure with `fig.savefig(outputPath, dpi=300)`, but I get `AttributeError: 'NoneType' object has no attribute 'print_figure'`, because `fig.canvas` is None. The sub plots should be on the figures canvas, so it shouldn't be None. I think i'm missing a key concept about matplot figures canvas.How can I update fig.canvas to reflect the current Figure, so i can use `fig.savefig(outputPath, dpi=300)`? Thanks!
2013/07/09
[ "https://Stackoverflow.com/questions/17538235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1560035/" ]
One of the things that `plt.figure` does for you is wrangle the backend for you, and that includes setting up the canvas. The way the architecture of mpl is the `Artist` level objects know how to set themselves up, make sure everything is in the right place relative to each other etc and then when asked, draw them selves onto the canvas. Thus, even though you have set up subplots and lines, you have not actually used the canvas yet. When you try to save the figure you are asking the canvas to ask all the artists to draw them selves on to it. You have not created a canvas (which is specific to a given backend) so it complains. Following the example [here](http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html) you need to create a canvas you can embed in your tk application (following on from your last question) ``` from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg canvas = FigureCanvasTkAgg(f, master=root) ``` `canvas` is a `Tk` widget and can be added to a gui. If you don't want to embed your figure in `Tk` you can use the pure `OO` methods shown [here](http://matplotlib.org/examples/api/agg_oo.html#api-agg-oo) (code lifted directly from link): ``` from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure fig = Figure() canvas = FigureCanvas(fig) ax = fig.add_subplot(111) ax.plot([1,2,3]) ax.set_title('hi mom') ax.grid(True) ax.set_xlabel('time') ax.set_ylabel('volts') canvas.print_figure('test') ```
66,678,439
Hi I have a pretty complex kivy application. I was doing some stuff, I started the app but when I was trying to save the data, my app suddenly stopped without any error message: `Process finished with exit code 1` After reflexion, I found out that I deleted a key on the dict I was iterating on ! So I should have seen `RuntimeError: dictionary changed size during iteration` but nothing appeared ! Why and how to prevent this ? (it can take al ong time to debug, I can't imagine without error message !). Here is an example of a code that raise the needed error: ``` d = {"a":"e","b":"c"} for k in d: del d[k] ```
2021/03/17
[ "https://Stackoverflow.com/questions/66678439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
**Azure does not assign a Dynamic IP Address until the Network Interface is attached to a running Virtual Machine (or other resource)**, refer to [this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface#private_ip_address_allocation). So I think that we can't convert the Dynamic IP to the Static one before the VM created because the IP address does not exist for that time being. Instead, we could directly associate some static IP addresses to the Azure VM by assigning some IP address in that subnet range. Read [private IP](https://learn.microsoft.com/en-us/azure/virtual-network/private-ip-addresses#allocation-method) allocation method. > > Azure reserves the first four addresses in each subnet address range. > The addresses can't be assigned to resources. For example, if the > subnet's address range is 10.0.0.0/16, addresses 10.0.0.0-10.0.0.3 and > 10.0.255.255 are unavailable. > > > For example, you may refer this template to configure static private ip's for the vms: ``` variable "vmlist" { type = map(object({ hostname = string IP_address = string })) default = { vm1 ={ hostname = "vma" IP_address = "10.0.2.4" }, vm2 = { hostname = "vmb" IP_address = "10.0.2.5" } } } #... resource "azurerm_network_interface" "staticnic" { for_each = var.vmlist name = "${each.value.hostname}-nic" location = azurerm_resource_group.main.location resource_group_name = azurerm_resource_group.main.name ip_configuration { name = "testconfiguration1" subnet_id = azurerm_subnet.internal.id private_ip_address_allocation = "Static" private_ip_address = each.value.IP_address } } #... resource "azurerm_virtual_machine" "main" { for_each = var.vmlist name = each.value.hostname location = azurerm_resource_group.main.location resource_group_name = azurerm_resource_group.main.name network_interface_ids = [azurerm_network_interface.staticnic[each.key].id] vm_size = "Standard_DS1_v2" # Uncomment this line to delete the OS disk automatically when deleting the VM # delete_os_disk_on_termination = true # Uncomment this line to delete the data disks automatically when deleting the VM # delete_data_disks_on_termination = true storage_image_reference { publisher = "MicrosoftWindowsServer" offer = "WindowsServer" sku = "2016-Datacenter" version = "latest" } storage_os_disk { name = "${each.value.hostname}-osdisk" caching = "ReadWrite" create_option = "FromImage" managed_disk_type = "Standard_LRS" } os_profile { computer_name = each.value.hostname admin_username = "testadmin" admin_password = "Password1234!" } os_profile_windows_config { provision_vm_agent = "true" } } ``` I am using ``` Terraform v0.14.7 + provider registry.terraform.io/hashicorp/azurerm v2.52.0 ``` [![enter image description here](https://i.stack.imgur.com/vBQtC.png)](https://i.stack.imgur.com/vBQtC.png) Update ------ If you want to let Azure assign the dynamic IP and then convert it to a static one, you can use [local-exec Provisioner](https://www.terraform.io/docs/language/resources/provisioners/local-exec.html) to invoke a local executable after a resource is created. ``` resource "null_resource" "example" { for_each = var.vmlist provisioner "local-exec" { command = <<EOT $Nic = Get-AzNetworkInterface -ResourceGroupName ${azurerm_resource_group.main.name} -Name ${azurerm_network_interface.nic[each.key].name} $Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static" Set-AzNetworkInterface -NetworkInterface $Nic EOT interpreter = ["PowerShell", "-Command"] } } ```
11,820
This [question and answer](https://stackoverflow.com/questions/11782/file-uploads-via-web-services) shows how to send a file as a byte array through an XML web service. How much overhead is generated by using this method for file transfer? I assume the data looks something like this: ``` <?xml version="1.0" encoding="UTF-8" ?> <bytes> <byte>16</byte> <byte>28</byte> <byte>127</byte> ... </bytes> ``` If this format is correct, the bytes must first be converted to UTF-8 characters. Each of these characters allocates 8 bytes. Are the bytes stored in base 10, hex, or binary characters? How much larger does the file appear as it is being sent due to the XML data and character encoding? Is compression built into web services?
2008/08/15
[ "https://Stackoverflow.com/questions/11820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
Typically a byte array is sent as a `base64` encoded string, not as individual bytes in tags. <http://en.wikipedia.org/wiki/Base64> The `base64` encoded version is about **137%** of the size of the original content.
57,141,834
I have created a table which has **tbody with 2 tr.** out of which 1 tr is for hide/show of data. I want to fix position of Table header and scroll only table body. **Since i am using angular js ng-repeat on tbody I am not able to scroll table body** I want output similar to this. [Sample output with scrollable table body](https://codepen.io/yavuzselim/pen/LNYrBd) **But my Table structure is similar to this. Below is the code** ``` <thead> </thead> <tbody ng-repeat="a in arr"> <tr> </tr> <tr> </tr> <tbody> ``` **HTML FILE** ``` <thead> <tr> <th style="text-align: center;">Edit</th> <th style="text-align: center;">Case ID</th> <th style="text-align: center;">Company Name</th> </tr> <tr> <th colspan="8"><input class="form-control" placeholder="Search ..." type="text" id="search" ng- model="search.compyNmeEnteredByBDO"/></th> </tr> </thead> <tbody ng-repeat="newOpportunity in opportunitycopy > <tr> <td> <label> <input type="checkbox" value="" ng- model="newOpportunity.isSelected"> <span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span> </label> </td> <td> &nbsp; {{newOpportunity.id}} </td> <td> {{newOpportunity.compyNmeEnteredByBDO}} </td> </tr> <tr ng-show="newOpportunity.hidestatus"> <td colspan="8"> <div class="row"> <div class="col-lg-12 col-md-12"> <div class="ibox" id="mailbox-container"> <div class="mailbox-header d-flex justify-content-between" style="border-bottom: 1px solid #e8e8e8;"> <div> <h5 class="inbox-title">Details</h5> </div> </div> <div class="mailbox-body"> <form> <div class="row"> <div class="col-sm-2 form-group"> <label>Quantum</label> <input type="text" readonly class="form-control" value="{{newOpportunity.quntm}}"> </div> </div> <div class="row"> </div> <div class="row"> <div class="col-sm-2 form-group"> <label>Remarks</label> <input type="text" readonly class="form-control" value="{{newOpportunity.remarks}}"> </div> </div> </div> </div> </div> </div> </tr> </tbody> ```
2019/07/22
[ "https://Stackoverflow.com/questions/57141834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7365860/" ]
You can do this way by setting `position: sticky;` ```css table thead tr th { background-color: orange; position: sticky; top: -1px; } ``` ```html <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <table class="table"> <thead> <tr> <th>column1</th> <th>column2</th> <th>column3</th> <th>column4</th> </tr> </thead> <tbody> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> <tr> <td>td</td> <td>td</td> <td>td</td> <td>td</td> </tr> </tbody> </table> ```
5,316,576
This works in a table where `doc_id` is the primary key: ``` select count(*)+1 from doctor where exp > (select exp from doctor where doc_id='001'); +------------+ | count(*)+1 | +------------+ | 2 | +------------+ ``` But when I'm using the same select query to set a field in the table, it reports the following error: ``` update doctor set rank= ( select count(*)+1 from doctor where exp > (select exp from doctor where doc_id='001') ) where doc_id='001'; ERROR 1093 (HY000): You can't specify target table 'doctor' for update in FROM clause ``` I can't understand which target table reference it is talking of. Can someone explain?
2011/03/15
[ "https://Stackoverflow.com/questions/5316576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This restriction is documented in the [MySQL manual](http://dev.mysql.com/doc/refman/5.1/en/update.html): > > Currently, you cannot update a table and select from the same table in a subquery. > > > As a workaround, you can wrap the sub-query in another sub-query and avoid that error: ``` update doctor set rank= (select rank from ( select count(*)+1 as rank from doctor where exp > (select exp from doctor where doc_id='001') ) as sub_query) where doc_id='001'; ```
10,195,069
I am using Font-Awesome which is iconic font for use with Twitter Bootstrap. Markup - ``` <i class="icon-remove reset-preference-button"></i> ``` CSS - ``` .reset-preference-button { cursor: pointer; } ``` JavaScript - ``` $(".reset-preference-button").on("click", function() { // ... do something }); ``` When I render the page, the cursor does not change to pointer when hovered over the element. Also nothing happens when I click on the icon. I made sure that the icon exists before I bind the event. Note that I am using element & not anything else. Seems like when I explicitly set the style for this element to `"display: inline-block;"` it works fine. This according to my tests happens only on Chrome. Works fine in Firefox & IE. My current Chrome version is 18 but it affects other versions as well. I have already filed a bug at <https://github.com/FortAwesome/Font-Awesome/issues/157>
2012/04/17
[ "https://Stackoverflow.com/questions/10195069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131315/" ]
This will almost certainly break the synchronization abstraction -- I wouldn't be confident that `thread2` will see the change immediately. You should never change the reference of the object you're synchronizing on, much less set it to `null`, which will cause a `NullPointerException` on any further attempts to synchronize on it.
16,111,384
I do not understand why those scripts act differently: ``` class A: x=3 y=5 __z=8 def __init__(self): print "Hi, I am an instance object of A class!" print "I have two components: x i y" print "Component x =", self.x print "Component y =", self.y print 'Component z=', self.__z, 'but z is private' def fun1(self): return self.x+self.y class B(A): pass i=B() print i.x, i.y, i.fun1() ``` If I delete `i=B()` line and change last line to `print B().x, B().y, B().fun1()`, strings in `__init__` are printed three times, as the class A is created everytime I call its methods. Why same thing doesn't happen when I create "i" instance?
2013/04/19
[ "https://Stackoverflow.com/questions/16111384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2300369/" ]
You created only one instance of `B`: ``` i=B() ``` So `__init__` is called only once. In your other example, you created a new instance of `B` three times.
2,915,087
I have a few sites that have SSL Certificates installed. When an SSL request is made with my employer's iPhone, this error message is displayed: > > Accept Website Certificate > > > The certificate for this website is invalid. Tap Accept to connect to this website anyway. > > > I've pulled up the same pages in other browsers, including Safari, and they do not show any issues with the certs. These two URLs exhibit the problem: 1. <https://www.powerlunchbunch.com/index.php?template=join&nav=20> 2. <https://www.councilonagingmartin.org/index.php?template=donate&nav=257> --- **Additional Information:** 1. Both SSL certs are issued by Network Solutions 2. The sites are hosted on Rackspace Cloud Sites --- **Update:** I now have an open ticket with Rackspace for this issue. I browsed the same sites in Firefox 4.0 Beta 7, and got this warning page, telling me that "The certificate is not trusted because no issuer chain was provided.": ![Firefox 4.0 Beta 7 SSL Chain Cert Warning](https://i.stack.imgur.com/XMQiG.png)
2010/05/26
[ "https://Stackoverflow.com/questions/2915087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/244826/" ]
I think it's because you (or your hosting company) haven't configured the full certificate chain on your web server. Take a look at a report from an ssl checker, such as this: <http://www.sslshopper.com/ssl-checker.html#hostname=www.councilonagingmartin.org> ... I can see from this report that you're using Apache2.2. Configuring 'intermediate certificates' on Apache2 goes something like this: SSLCertificateFile /etc/ssl/crt/yourDOMAINNAME.crt SSLCertificateKeyFile /etc/ssl/crt/private.key **SSLCertificateChainFile /etc/ssl/crt/chainCert.xxx** I don't know if you configured the certificate yourself, or your hosting company configured it, so you'll either need to contact your hosting company, or the certificate provider, who can provide the intermediate certificate(s). Hope That Helps
1,025,067
Many sites like Aliexpress and other have a place where I can hover over to view the image. But I cannot seem to download the image. Is there any way to download this type of image in Firefox?
2016/01/12
[ "https://superuser.com/questions/1025067", "https://superuser.com", "https://superuser.com/users/535939/" ]
1. In Firefox go to any product page at the AliExpress website and select a product. 2. Right-click the image and select *Open Link in New Tab*. 3. Switch to the new tab and you will see a large product image, and above it a gallery of thumbnail images, usually 6 thumbnail images, which can be clicked to view the product from different viewpoints. From the Firefox menu select *Web Developer* -> *Page Source*. 4. On the Page Source tab find the line that says `<div class="image layout-left">` 5. Under that line will be the links to all the original size product images on that webpage. If there is an image gallery that contains more than one image, there will be a list of images containing one link for each image in the image gallery. If there are 6 thumbnail images above the large product image, there will be 6 links to original size images in the list. 6. Open the link to the image you want to save in a new tab. 7. A new tab will open containing only one image in the center of the page surrounded by a dark gray background. Right-click on the image and select *Save Image As...* to save the image to your computer.
12,974,630
When overriding the `onPause()` and the `onResume()` methods of the activity, where is the proper location to call the `super.onPause()` and `super.onResume()`? At the beginning of the method or at the end?
2012/10/19
[ "https://Stackoverflow.com/questions/12974630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57735/" ]
From <http://developer.android.com/guide/components/activities.html#ImplementingLifecycleCallbacks>: > > Your implementation of these lifecycle methods must always call the superclass implementation before doing any work, as shown in the examples above. > > > So, for lifecycle callbacks, like `onPause()` and `onResume()`, we should do `super.onPause()` or `super.onResume()` at the very beginning. For other methods, it all depends on the semantics of the super class.
37,172,807
I have an SNS topic that is published to whenever an SES email bounces. I have a CloudWatch alarm set up to trigger when a threshold of notifications is crossed over the past hour. In practice, bounces are rare, and because SNS notifications are only sent when an email bounces, the alarm spends almost its entire time in the `INSUFFICIENT_DATA` state. Ideally, I'd like for the lack of SNS notifications to be treated as a zero value. In other monitoring systems (like graphite/grafana) this is consider "null as zero." Is there any way to treat the (lack of) notifications this way, and keep the alarm out of the insufficient data state?
2016/05/11
[ "https://Stackoverflow.com/questions/37172807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/156/" ]
Amazon SNS does not send metric data to CloudWatch when the value is zero. This results in `INSUFFICIENT_DATA` for Alarms where no emails are send. However, your alarm should work as desired with no change. The `INSUFFICIENT_DATA` message results from two situations: * The alarm has **not been in existence** for the measurement period (eg an alarm that calculates the total over a 1-hour period needs to have existed for at least 1 hour). * There is **no data** within the defined period If there is at least one data point within the past hour, and the alarm has existed for at least an hour, then the state will be either `OK` or `ALARM`. **Therefore, you should treat `INSUFFICIENT_DATA` the same as `OK`.** (It is even possible to trigger alarms based on entering the `INSUFFICIENT DATA` state!) Also, in case you're not already, be sure to use `SUM` rather than `AVERAGE` since your use-case involves looking at the count of messages during a period. My tests show that a `SUM` alarm triggers immediately, whereas `AVERAGE` requires more time.
237,405
I'm trying to save the notebook as PDF with working. I tried all methods in old threads but nothing works. Does anyone know how to make this work? (version 12.0.0.0, windows 64-bit) ``` SetOptions[ SelectedNotebook[], PrintingStyleEnvironment -> "Printout", ShowSyntaxStyles -> True] f[a_, b_, d_] := (a + b)/(a - b) d; tup1 = Tuples@{{1, 0, 0, 1}, {2, 1, 0, 3}}; Quiet@Check[ t = Plot[{f[##, d], 1}, {d, 0, 1}, ImageSize -> 1000, PlotLabel -> Style[StringForm["a= `` b= ``", ##]]]; t, Nothing[]] & @@@ tup1 // Flatten // Partition[#, 2, 2, {1, 1}, {}] & // Grid ``` Also how to print PDF a whole notebook with many inputs and outputs not just graphics?
2020/12/31
[ "https://mathematica.stackexchange.com/questions/237405", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/18805/" ]
In V12.0, I get graphics to be broken across pages if I set their `ImageSize` to be wider than the page width, even though `PageBreakWithin` is set to `False`. For instance, it happens with `ImageSize -> 1000` for me, which setting is the same as in the OP. Try `ImageSize -> Full` if you want the graphics as wide as the page. [In V12.1/12.2, the graphics are not broken at page breaks.]
37,146
Besides flying the plane and talking to the person in the other seat, what other forms of entertainment are (also legally) available to pilots while on the job? I'm thinking of 'activities' like reading, listening to music, watching a movie, or... playing a flight simulator game on a laptop.
2017/04/16
[ "https://aviation.stackexchange.com/questions/37146", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/1379/" ]
I am not aware of any legal requirements, but rules may differ according to the country of jurisdiction. Generally it is up to the company that a pilot works for to establish their own rules to cover "in-flight entertainment" in the flight deck. Most companies do not allow it. It has been my experience that the rules are generally ignored and common sense rules are used instead. During non-critical phases of flight, pilots will often read newspapers, books, iPads etc. Many will do crossword puzzles or Sudoku. A few will even listen to music or watch a video, but it is pretty rare. In 40 years of flying, I can't recall ever seeing a pilot play a video game or flight simulator.
2,262,959
I am only aware of 2: * dumpbin which is included with Visual Studio * PEView from <http://wjradburn.com/software/>
2010/02/14
[ "https://Stackoverflow.com/questions/2262959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269085/" ]
There is [DbgHelp](https://learn.microsoft.com/en-gb/windows/win32/debug/dbghelp-functions), but it's geared more toward the PE file rather than the object file. And Its intended to be used as an API rather than a tool. the COFF format itself originated on unix <https://en.wikipedia.org/wiki/COFF> although Microsoft has extended the format somewhat and the unix seems to have abandoned that format in favor of ELF. But you might find some useful tools in the Unix world, for instance this dump tool from SCO <http://docsrv.sco.com:507/en/man/html.CP/dump.CP.html>
28,319,806
When I am filling out the contact form on the website that I am making, the e-mail will be sent, but I am not receiving it in the inbox of my computer. The code looks like this: HTML: ``` <div id="form"> <form action="mailto:psteintj@xs4all.nl" id="contactForm" method="post"> <span></span> <input type="text" name="name" class="name" placeholder="Enter your name" tabindex=1 /> <span></span> <input type="text" name="email" class="email" placeholder="Enter your email" tabindex=2 /> <span id="captcha"></span> <input type="text" name="captcha" class="captcha" maxlength="4" size="4" placeholder="Enter captcha code" tabindex=3 /> <span></span> <textarea class="message" placeholder="Enter your message" tabindex=4></textarea> <input type="submit" name="submit" value="Send e-mail" class="submit" tabindex=5> </form> </div> ``` JS: ``` if ((captchaVal == captchaCode) && (emailFilter.test(emailText)) && (nameFilter.test(nameText)) && (messageText > 50)) { $.post("mail.php", { name: $(".name").val(), email: $(".email").val(), message:$(".message").val() }); $("#contactForm").css("display", "none"); $("#form").append("<h2>Message sent!</h2>"); return false; } ``` and PHP: ``` <?php $name = $POST['name']; $email = $_POST['email']; $message = $POST['message']; ``` Could someone tell me where I am going wrong?
2015/02/04
[ "https://Stackoverflow.com/questions/28319806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4453523/" ]
Well, you are not sending any emails (or at least you haven't posted any code about it), so of course you are not receiving any emails. You should configure the mailing, and use the [mail](http://php.net/manual/en/function.mail.php) function. The function needs a working SMTP server to actually send out the e-mail.
4,400,642
I've already shown irreducible. I know I need to get intermediate fields since they correspond to subgroups (which I can use for isomorphisms). But how do I get the intermediate fields here? edit: I'm thinking perhaps there is some way to show the order of the extension is $4$, and the only groups of order $4$ are the Klein-$4$ group and cyclic group and eliminating from there. edit 2: Treating $x^4-16x^2+4$ as a quadratic in $x^2$, applying the quadratic formula gives $$\frac{16\pm \sqrt{16^2-4\cdot 4}}{2}=\frac{16\pm 4\sqrt{15}}{2}=8\pm 2\sqrt{15}=(\sqrt{3}\pm\sqrt{5})^2.$$ and this is squared so $\pm(\sqrt{3}\pm\sqrt{5})$ gives the roots and there are four of them. Now what's next..
2022/03/11
[ "https://math.stackexchange.com/questions/4400642", "https://math.stackexchange.com", "https://math.stackexchange.com/users/572734/" ]
$\dfrac{1}{\sqrt{5}-\sqrt{3}}=\dfrac{\sqrt{5}+\sqrt{3}}{2}$. Therefore, any root generates all three other roots. Therefore, the splitting field is of a degree-$4$ extension of $\mathbb{Q}$. Now, since you want three distinct intermediate subfields of degree $2$, $(\sqrt{5}+\sqrt{3})+(\sqrt{5}-\sqrt{3})=2\sqrt{5}$ $(\sqrt{5}+\sqrt{3})-(\sqrt{5}-\sqrt{3})=2\sqrt{3}$ $(\sqrt{5}+\sqrt{3})^2=8+ 2\sqrt{15}$ so you can use $\sqrt{5},\sqrt{3},\sqrt{15}$.
45,504,851
I am working with Oracle PL/SQL. There are two cursors, namely c1 and c2. ``` v_temp VARCHAR(50); For s1 IN c1 LOOP --do something FOR s2 IN c2 LOOP --do something v_temp := s1.s2.xxx; --PLS-00302: component 's2' must be declared END LOOP; END LOOP; ``` `s2.xxx` gives a column name, and with that column name I hope to assign the value of that column from `s1` to `v_temp`. For example: In the first iteration, `s2.xxx` is `'column1'`, I would like to assign `s1.column1` to `v_temp`. In the second iteration, `s2.xxx` is `'column2'`, I would then like to assign `s1.column2` to `v_temp`. I got the error: `Error(191,48): PLS-00302: component 's2' must be declared` while trying to compile. I know that `s1.s2.xxx` is not valid, but is there another way of writing it that can make it work?
2017/08/04
[ "https://Stackoverflow.com/questions/45504851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8416762/" ]
You need to fetch from a `REF CURSOR` and dynamically append the column\_name to the select statement while opening the cursor. Here I am fetching all the column names from `USER_TAB_COLUMNS` for table `EMPLOYEES` and assigning their corresponding values to v\_temp. ``` SET SERVEROUTPUT ON; DECLARE v_temp VARCHAR(50); query1 VARCHAR2(1000); c1 SYS_REFCURSOR; CURSOR c2 IS SELECT COLUMN_NAME xxx FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'EMPLOYEES'; BEGIN FOR s2 IN c2 LOOP --do something query1 := 'SELECT ' ||s2.xxx||' FROM EMPLOYEES'; OPEN c1 FOR query1 ; LOOP FETCH c1 INTO v_temp; DBMS_OUTPUT.PUT_LINE('COLUMN:'||s2.xxx||', VALUE:'|| v_temp); EXIT WHEN c1%NOTFOUND; END LOOP; CLOSE c1; END LOOP; END; / ``` Since lengths of all the columns of `Employees` are < 50 , it is working Fine.The conversion happens implicitly for `NUMBER` and `DATE` data types. Here is a sample Output. ``` COLUMN:EMPLOYEE_ID, VALUE:100 COLUMN:EMPLOYEE_ID, VALUE:101 COLUMN:EMPLOYEE_ID, VALUE:102 COLUMN:FIRST_NAME, VALUE:Eleni COLUMN:FIRST_NAME, VALUE:Eleni COLUMN:LAST_NAME, VALUE:Whalen COLUMN:LAST_NAME, VALUE:Fay COLUMN:HIRE_DATE, VALUE:17-06-03 COLUMN:HIRE_DATE, VALUE:21-09-05 ```
65,203,735
I have a database and an external file. What these two share are reference codes for products. But in the external file I have all my reference codes saved down, whilst plenty are still missing in the database. Is there a way to make a query so that I can check what values are missing in my database, in a given table? There's no need to worry about how the XML interfaces with the database. I already have that down through PHP and simplexml. I am mostly struggling with the query to use in this case. | Database | XML File | | --- | --- | | AJS2S | AJS2S | | ABBB2 | ABBB2 | | | JJI90K | | | JJJJ92 |
2020/12/08
[ "https://Stackoverflow.com/questions/65203735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14436514/" ]
If you have a list of valus at hand and you want to check which ones are missing in your table, you enumerate them in a `union all` subquery, then use `not exists`: ``` select x.product_code from ( select 'AJS2S' as product_code union all select 'ABBB2' union all ... ) x where not exists (select 1 from mytable t where t.product_code = x.product_code) ``` Or, in very recent versions of MySQL (8.0.19 or higher), you can use the `values()` row constructor: ``` select x.product_code from (values row('AJS2S'), row('ABBB2'), ...) x(product_code) where not exists (select 1 from mytable t where t.product_code = x.product_code) ``` Of course, if you have your xml data already loaded in a table, say `xmltable`, then you can use that instead of the subquery: ``` select x.product_code from xmltable x(product_code) where not exists (select 1 from mytable t where t.product_code = x.product_code) ```
10,113,933
Say, I have a vector y, and I want to check if each element in y is integer or not, and if not, stop with an error message. I tried is.integer(y), but it does not work.
2012/04/11
[ "https://Stackoverflow.com/questions/10113933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1043106/" ]
The simplest (and fastest!) thing is probably this: ``` stopifnot( all(y == floor(y)) ) ``` ...So trying it out: ``` y <- c(3,4,9) stopifnot( all(y == floor(y)) ) # OK y <- c(3,4.01,9) stopifnot( all(y == floor(y)) ) # ERROR! ``` If you want a better error message: ``` y <- c(3, 9, NaN) if (!isTRUE(all(y == floor(y)))) stop("'y' must only contain integer values") ```
63,556,962
I'm not sure if my issue is the nested row, but I can't get the inner row vertical aligned centered within it's alert-box. Anyone any hint what I'm doing wrong? <https://jsfiddle.net/d2pg4xta/> ``` <div class="container-fluid"> <div class="row"> <div class="col-md-6 d-flex"> <div class="alert alert-dark"> <div class="row"> <!-- here is my nested row --> <div class="col-md-6"><p class="mb-0">1:</p></div> <div class="col-md-6"><p class="mb-0">A</p></div> <div class="col-md-6"><p class="mb-0">2:</p></div> <div class="col-md-6"><p class="mb-0">B</p></div> <div class="col-md-6"><p class="mb-0">3:</p></div> <div class="col-md-6"><p class="mb-0">C</p></div> <div class="col-md-6"><p class="mb-0">4:</p></div> <div class="col-md-6"><p class="mb-0">D</p></div> </div> </div> </div> <div class="col-md-6 d-flex"> <div class="alert alert-dark text-center"> <p>Lorem ipsum ...Lorem ipsum ...</p> <p>Lorem ipsum ...Lorem ipsum ...</p> <p>Lorem ipsum ...Lorem ipsum ...</p> <p>Lorem ipsum ...Lorem ipsum ...</p> </div> </div> </div> </div> ``` [![enter image description here](https://i.stack.imgur.com/LFbX1.png)](https://i.stack.imgur.com/LFbX1.png) **Update:** It's not about aligning the 2 alert-boxes, it's about the inside of my left alert-box. I expect the inside row containing the content (abcd1234) to be more centered withing it's own alert-box like this: <https://ibb.co/myntK5j>
2020/08/24
[ "https://Stackoverflow.com/questions/63556962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3743899/" ]
Do this: ``` .alert-dark { display: flex; /*add*/ flex-direction: column; /*add*/ align-items: center; /*add*/ color: #1b1e21; background-color: #d6d8d9; border-color: #c6c8ca; } ```
258,301
Install the following package: ``` PacletInstall["EcoEvo", "Site" -> "http://raw.githubusercontent.com/cklausme/EcoEvo/master"] << EcoEvo` ``` The code: ``` SetModel[{Pop[pop] -> { Component[ s] :> {Equation :> \[Nu] - \[Beta]1 i2 s - \[Beta]2 j s - \ \[Mu] s}, Component[ i1] -> {Equation :> p \[Beta]1 i2 s + q \[Beta]2 j s - b1 i1 + \[Xi]1 j }, Component[ i2] -> {Equation :> (1 - p) \[Beta]1 i2 s + (1 - q) \[Beta]2 j s + \[Epsilon] i1 - b2 i2 + \[Xi]2 j }, Component[j] -> {Equation :> p1 i2 - b3 j }, Component[a] -> {Equation :> p2 j - b4 a}}, Parameters :> {\[Nu] > 0, \[Beta]1 > 0, \[Beta]2 > 0, \[Mu] > 0, p > 0, q > 0, b1 > 0, b2 > 0, b3 > 0, b4 > 0, p1 > 0, \[Epsilon] > 0}}] eq = SolveEcoEq[] ``` where ``` r0 = ((\[Beta]1 b3 (\[Epsilon] p + b1 (1 - p)) + \[Beta]2 p1 (\[Epsilon] q + b1 (1 - q))) (\[Nu]/\[Mu]))/(b1 b2 b3 - (\[Epsilon] \[Xi]1 + b1 \[Xi]2) p1); ``` We obtain our equilibrium points: ``` {{s -> \[Nu]/\[Mu], i1 -> 0, i2 -> 0, j -> 0, a -> 0}, {s -> (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2)/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]), i1 -> (-b2 b3^2 p \[Beta]1 \[Nu] - b2 b3 p1 q \[Beta]2 \[Nu] - b3 p1 \[Beta]1 \[Nu] \[Xi]1 + b3 p p1 \[Beta]1 \[Nu] \[Xi]1 - p1^2 \[Beta]2 \[Nu] \[Xi]1 + p1^2 q \[Beta]2 \[Nu] \[Xi]1 + b3 p p1 \[Beta]1 \[Nu] \[Xi]2 + p1^2 q \[Beta]2 \[Nu] \[Xi]2 + ( b2 b3^2 p \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b2 b3 p1 q \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b3 p1 \[Beta]1 \[Mu] \[Xi]1 (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b3 p p1 \[Beta]1 \[Mu] \[Xi]1 (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( p1^2 \[Beta]2 \[Mu] \[Xi]1 (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( p1^2 q \[Beta]2 \[Mu] \[Xi]1 (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b3 p p1 \[Beta]1 \[Mu] \[Xi]2 (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( p1^2 q \[Beta]2 \[Mu] \[Xi]2 (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]))/(-b1 b2 b3^2 \[Beta]1 - b1 b2 b3 p1 \[Beta]2 + b3 p1 \[Beta]1 \[Epsilon] \[Xi]1 + p1^2 \[Beta]2 \[Epsilon] \[Xi]1 + b1 b3 p1 \[Beta]1 \[Xi]2 + b1 p1^2 \[Beta]2 \[Xi]2), i2 -> (-b1 b3^2 \[Beta]1 \[Nu] + b1 b3^2 p \[Beta]1 \[Nu] - b1 b3 p1 \[Beta]2 \[Nu] + b1 b3 p1 q \[Beta]2 \[Nu] - b3^2 p \[Beta]1 \[Epsilon] \[Nu] - b3 p1 q \[Beta]2 \[Epsilon] \[Nu] + ( b1 b3^2 \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b1 b3^2 p \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b1 b3 p1 \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b1 b3 p1 q \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b3^2 p \[Beta]1 \[Epsilon] \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b3 p1 q \[Beta]2 \[Epsilon] \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]))/(-b1 b2 b3^2 \[Beta]1 - b1 b2 b3 p1 \[Beta]2 + b3 p1 \[Beta]1 \[Epsilon] \[Xi]1 + p1^2 \[Beta]2 \[Epsilon] \[Xi]1 + b1 b3 p1 \[Beta]1 \[Xi]2 + b1 p1^2 \[Beta]2 \[Xi]2), j -> (-b1 b3 p1 \[Beta]1 \[Nu] + b1 b3 p p1 \[Beta]1 \[Nu] - b1 p1^2 \[Beta]2 \[Nu] + b1 p1^2 q \[Beta]2 \[Nu] - b3 p p1 \[Beta]1 \[Epsilon] \[Nu] - p1^2 q \[Beta]2 \[Epsilon] \[Nu] + ( b1 b3 p1 \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b1 b3 p p1 \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b1 p1^2 \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b1 p1^2 q \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b3 p p1 \[Beta]1 \[Epsilon] \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( p1^2 q \[Beta]2 \[Epsilon] \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]))/(-b1 b2 b3^2 \[Beta]1 - b1 b2 b3 p1 \[Beta]2 + b3 p1 \[Beta]1 \[Epsilon] \[Xi]1 + p1^2 \[Beta]2 \[Epsilon] \[Xi]1 + b1 b3 p1 \[Beta]1 \[Xi]2 + b1 p1^2 \[Beta]2 \[Xi]2), a -> (-b1 b3 p1 p2 \[Beta]1 \[Nu] + b1 b3 p p1 p2 \[Beta]1 \[Nu] - b1 p1^2 p2 \[Beta]2 \[Nu] + b1 p1^2 p2 q \[Beta]2 \[Nu] - b3 p p1 p2 \[Beta]1 \[Epsilon] \[Nu] - p1^2 p2 q \[Beta]2 \[Epsilon] \[Nu] + ( b1 b3 p1 p2 \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b1 b3 p p1 p2 \[Beta]1 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b1 p1^2 p2 \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) - ( b1 p1^2 p2 q \[Beta]2 \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( b3 p p1 p2 \[Beta]1 \[Epsilon] \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]) + ( p1^2 p2 q \[Beta]2 \[Epsilon] \[Mu] (-b1 b2 b3 + p1 \[Epsilon] \[Xi]1 + b1 p1 \[Xi]2))/(-b1 b3 \[Beta]1 + b1 b3 p \[Beta]1 - b1 p1 \[Beta]2 + b1 p1 q \[Beta]2 - b3 p \[Beta]1 \[Epsilon] - p1 q \[Beta]2 \[Epsilon]))/(-b1 b2 b3^2 b4 \[Beta]1 - b1 b2 b3 b4 p1 \[Beta]2 + b3 b4 p1 \[Beta]1 \[Epsilon] \[Xi]1 + b4 p1^2 \[Beta]2 \[Epsilon] \[Xi]1 + b1 b3 b4 p1 \[Beta]1 \[Xi]2 + b1 b4 p1^2 \[Beta]2 \[Xi]2)}} ``` These are long and tedious. Is there a way to simplify them using each other and `r0`? For example; why does i2 = $\frac{b\_3}{p\_1} j$?
2021/11/15
[ "https://mathematica.stackexchange.com/questions/258301", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/77577/" ]
`eqPts` is the equilibrium points in your question. Start by using [`Simplify`](https://reference.wolfram.com/language/ref/Simplify.html) ``` LeafCount /@ {eqPts, eqPts2 = eqPts // Simplify} (* {1958, 448} *) ``` The variables are ``` vars = Variables[Level[eqPts2, {-1}]] (* {a, b1, b2, b3, b4, i1, i2, j, p, p1, p2, q, s, β1, β2, \ ϵ, μ, ν, ξ1, ξ2} *) ``` Convert the replacement rules in `eqPts2` into the corresponding equations ``` eqns = eqPts2 /. Rule :> Equal; ``` With five equations you can [`Solve`](https://reference.wolfram.com/language/ref/Solve.html) for one variable while eliminating four variables. ``` sol = Solve[#, i2, {s, i1, a, b1}] & /@ eqns (* {{}, {{i2 -> (b3 j)/p1}}} *) ``` The expected result, ``` sol[[2, 1, 1]] /. Rule :> Equal (* i2 == (b3 j)/p1 *) ``` Verifying this relation at both equilibrium points, ``` % /. eqPts2 // Simplify (* {True, True} *) ``` **EDIT:** A more general approach will be **much slower** ``` vars = eqns[[1, All, 1]] (* {s, i1, i2, j, a} *) params = Complement[Variables[Level[eqns, {-1}]], vars] (* {b1, b2, b3, b4, p, p1, p2, q, β1, β2, ϵ, μ, ν, ξ1, ξ2} *) solve[solveVar_Symbol, var_Symbol] := SortBy[ Union[ Simplify[ Solve[eqns[[2]], solveVar, #] & /@ (Append[Complement[vars, {solveVar, var}], #] & /@ params) /. {} :> Nothing]], LeafCount][[1, 1]] ``` To `Solve` for `i2` in terms of `j` ``` solve[i2, j] (* {i2 -> (b3 j)/p1} *) ``` To `Solve` for `i2` in terms of `j` ``` solve[i1, j] // Apart (* {i1 -> (j (b3 p β1 + p1 q β2) ν)/( b1 (b3 j β1 + j p1 β2 + p1 μ)) + (j ξ1)/b1} *) ``` You could then generalize this to solve for a variable in terms of each of the other variables and select the simplest form; however, this would be **very slow**.
41,147,597
I have a program that should read a few Strings from the console. If the String "end" appears, it should start to calculate and write a String in the console. The String which I am reading is a chemical equation. The equation is split with these two characters: `->`. I should prove whether the amount of atoms on both sides is the same. I found [this](https://stackoverflow.com/questions/41129245/parsing-a-chemical-equation) post and tried to implement it but I have a problem with the regex. For example: My regex can read and calculate a chemical equation if there is a digit before the formula: `2 HCl + 2 Na -> 2 NaCl + H2` but if there is no digit, then it doesn't calculate it correctly: `HCl + Na -> NaCl + H2` My Code: ``` public static void main(String[] args) { Scanner s = new Scanner(System.in); List<String> list = new ArrayList<String>(); String input = ""; while (!(input.equals("end"))) { input = s.nextLine(); list.add(input); } int before = 0; int after = 0; list.remove(list.size() - 1); for (int i = 0; i < list.size(); i++) { String string = list.get(i); string = string.replace("-", ""); String[] splitted = string.split(">"); Pattern firstPattern = Pattern.compile("(\\d+) (\\w+)"); Matcher firstMatcher = firstPattern.matcher(splitted[0]); while (firstMatcher.find()) { int element = Integer.parseInt(firstMatcher.group(1)); String count = firstMatcher.group(2); final Pattern pattern = Pattern.compile("\\d+"); // the regex final Matcher matcher = pattern.matcher(count); // your string final ArrayList<Integer> ints = new ArrayList<Integer>(); // results while (matcher.find()) { // for each match ints.add(Integer.parseInt(matcher.group())); // convert to // int } for (int j = 0; j < ints.size(); j++) { before = before + element * ints.get(j); } } Pattern secondPattern = Pattern.compile("(\\d+) (\\w+)"); Matcher secondMatcher = secondPattern.matcher(splitted[1]); while (secondMatcher.find()) { int element = Integer.parseInt(secondMatcher.group(1)); String count = secondMatcher.group(2); final Pattern pattern = Pattern.compile("\\d+"); // the regex final Matcher matcher = pattern.matcher(count); // your string final ArrayList<Integer> ints = new ArrayList<Integer>(); // results while (matcher.find()) { // for each match ints.add(Integer.parseInt(matcher.group())); // convert to // int } for (int j = 0; j < ints.size(); j++) { after = after + element * ints.get(j); } } if (before == after) { System.out.println("formally correct"); } else { System.out.println("incorrect"); } } } ``` Here are some example chemical equations for trying out: **Input:** HCl + Na -> NaCl + H2 2 HCl + 2 Na -> 2 NaCl + H2 12 CO2 + 6 H2O -> 2 C6H12O6 + 12 O2 end **Output:** incorrect formally correct incorrect
2016/12/14
[ "https://Stackoverflow.com/questions/41147597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7297693/" ]
**Example** ``` begin statement; savepoint savepoint1; begin your insert statement exception when others then rollback to savepoint1; end; ROLLBACK TO savepoint1; end; ```
5,523,562
I encounter a problem using `std::string` in parameters : `MyClass` has a method like this ``` public: void loadDatas(string filename); ``` In my `main.cpp` I have the following simple code : ``` #include <iostream> #include <string> #include "myclass.hpp"; using namespace std; int main() { string foo = "test.txt"; cout << foo << endl; // Print Hello Kitty, no problems MyClass i; // The following line raise : // obj/Release/src/main.o||In function `main':| // main.cpp|| undefined reference to `MyClass::loadDatas(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'| // ||=== Build finished: 1 errors, 0 warnings ===| i.loadDatas(foo); return EXIT_SUCCESS; } ``` So it looks like `libstdc++` is well linked (because I'm able to print the text using `cout`), but passing a `string` in parameters raise an error and I don't understand why. Could someone help me please ? EDIT : I made a mistake, in fact it is `i.loadDatas(foo);` (I corrected it). My source code isn't in english so I tryed to made a simple version for you in english. I really call an instance method and not a static method. EDIT 2 : Complete source code **personnage.hpp** ``` #ifndef PERSONNAGE_H #define PERSONNAGE_H #include <iostream> #include <string> #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/xmlmemory.h> #include <libxml/xpath.h> #include <libxml/xpathInternals.h> #include "carte.hpp" using namespace std; class Personnage : public Carte { public: Personnage(); void chargerPersonnage(string nom); virtual ~Personnage(); private: //! Le texte d'accroche de la carte string _accroche; }; #endif // PERSONNAGE_H ``` **personnage.cpp** ``` #include "personnage.hpp" Personnage::Personnage() : Carte("Sans titre") { } void chargerPersonnage(string nom) { } Personnage::~Personnage() { //dtor } ``` **main.cpp** ``` #include <iostream> #include <string> #include <SFML/Graphics.hpp> #include "personnage.hpp" using namespace sf; using namespace std; int main() { string test = "Hello Kitty"; cout << test << endl; Personnage test2; test2.chargerPersonnage(test); return EXIT_SUCCESS; } ``` **error log** ``` obj/Release/src/main.o||In function `main':| main.cpp|| undefined reference to `Personnage::chargerPersonnage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'| ||=== Build finished: 1 errors, 0 warnings ===| ```
2011/04/02
[ "https://Stackoverflow.com/questions/5523562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364316/" ]
The problem is that you've defined `class Personnage` as having a **member function** `chargerPersonnage`, but in personnage.cpp you define a **free function** `chargerPersonnage` instead. You appear to know the correct syntax, as you did `Personnage`'s constructor and destructor correctly, but just to make it clear: Change `void chargerPersonnage(string nom) { }` to `void Personnage::chargerPersonnage(string nom) { }` in personnage.cpp.
18,419,406
In my textbook I can read: If T is any Java type, then `T.class` is the matching class object. For example: ``` Class cl1 = Date.class; // if you import java.util.*; Class cl2 = int.class; Class cl3 = Double[].class; ``` Later on I'm reading: The virtual machine manages a unique Class object for each type. Therefore, you can use the `==` operator to compare class objects. For example: ``` if (e.getClass() == Employee.class) ``` Could you help me find anything about this .class field in the documentation. And another qutstion - I can't understand whether the **`e.getClass() == Employee.class`** is the same as `e.class == Employee.class`. I mean, if it is the same, why the author of the textbook used `getClass` here in the lefthand expression.
2013/08/24
[ "https://Stackoverflow.com/questions/18419406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1684123/" ]
It's one of the basics of SQL - use [join](http://en.wikipedia.org/wiki/Join_%28SQL%29). In your case it's better to use `outer join` so you won't miss people from `people_temp1` who don't have corresponding records in `people_temp2`: ``` insert into people(name, age, profession, location) select p1.name, p1.age p2.profession, p2.location from people_temp1 as p1 left outer join people_temp2 as p2 on p2.id = p1.person_id ```
21,528
I'm new to Bitcoin. I want to use PHP to create a bitcoin wallet on my own website. I came to here <https://blockchain.info/api/create_wallet> but I don't know how to apply it. Would like to have good tutorials from some websites or videos.
2014/02/02
[ "https://bitcoin.stackexchange.com/questions/21528", "https://bitcoin.stackexchange.com", "https://bitcoin.stackexchange.com/users/12996/" ]
You can find your answer [here](http://wiki.uniformserver.com/index.php/SSL_PHP_Server_Key_and_Certificate_generation) [Snippet of code](https://github.com/mikegogulski/bitcoin-php/blob/master/src/bitcoin.inc#L567) Example from [bitcointalk](https://bitcointalk.org/index.php?topic=81626.20) ``` <?php #Below is full list of available characters. #"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" $fp=fopen("/dev/urandom","r") or die; $available_chars="23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz"; do{ $minikey='S'; for($i=0;$i<29;$i++){ while(($c=ord(fgetc($fp)))>=strlen($available_chars)); $minikey.=substr($available_chars,$c,1); } $check=hash('sha256',$minikey . '?') . "\n"; }while(substr($check,0,2)!='00'); fclose($fp); $priv=hash('sha256',$minikey); print "Minikey: $minikey\n"; print "Privkey: $priv\n"; ?> ``` You can find some useful information [here](https://en.bitcoin.it/wiki/PHP_developer_intro)
119,864
I would like to apply a particular label to all incoming messages. Gmail filters apply to both outgoing and incoming messages. So I've added a condition that says `Doesn't have from:me`. This prevents the filter from matching outgoing messages in Sent. However, it also (undesirably) prevents it from matching incoming messages that I send to myself or that someone else has sent to me “from” my own address. Is there a way to only exclude my own outgoing messages? I’ve seen mention of using `in:sent` and `label:sent`, but when creating the filter Gmail warns against this saying that they aren’t applied yet at the time the filter is evaluated. I guess they are only for searching after the fact.
2018/08/21
[ "https://webapps.stackexchange.com/questions/119864", "https://webapps.stackexchange.com", "https://webapps.stackexchange.com/users/10700/" ]
Use the condition "to:me" instead of "Doesn't have from:me". This will capture incoming mail and exclude outgoing mail unless you've sent it to yourself. To include e-mails sent to a mailing list of which you are a recipient, you need to use the "deliveredto:" operator. We can take advantage of the fact that the `Has the words:` field accepts search operators. Leaving the other fields blank, put the following text in the `Has the words:` box: `{(to:YOU@gmail.com) (deliveredto:YOU@gmail.com)}` The inner parenthesis mean that the field is optional (e.g., the mail can be `to:` this address OR it can be `deliveredto:` this address). This is what your filter should look like: [![Filter settings window](https://i.stack.imgur.com/XEppj.png)](https://i.stack.imgur.com/XEppj.png) I believe you only need "to:" in order to capture e-mails sent to yourself, although I'd have to test it more to be sure. Regardless, putting both should capture all incoming e-mail.
325,252
everyone. I have two files: ports.lst and master.tbl ports.lst looks like this: ``` hawaii-P1 hawaii-P2 hawaii-P3 losangeles-P1 losangeles-P3 ``` master.tbl looks like this: ``` #Site 1 Honolulu servername HAWAII-A hawaii-P1 InitFileA OutFileA otherfields servername HAWAII-A hawaii-P2 InitFileA OutFileA otherfields #servername HAWAII-A hawaii-P3 InitFileA OutFileA otherfields servername HAWAII-A hawaii-P4 InitFileA OutFileA otherfields #Site 16 Dallas servername DALLAS-A dallas-P1 InitFileA OutFileA otherfields servername DALLAS-A dallas-P2 InitFileA OutFileA otherfields servername DALLAS-A dallas-P3 InitFileA OutFileA otherfields #Site 8 L.A. #servername LOSANGELES-A losangeles-P1 InitFileA OutFileA otherfields servername LOSANGELES-A losangeles-P2 InitFileA OutFileA otherfields #servername LOSANGELES-A losangeles-P3 InitFileA OutFileA otherfields ``` I need to search the master.tbl file for each port listed in ports.lst, and replace "InitFileA" and "OutFileA" leaving the file looking like this: ``` #Site 1 Honolulu servername HAWAII-A hawaii-P1 InitFileB-hawaii-username-ALPHA-password OutFileB-hawaii-username-ALPHA otherfields servername HAWAII-A hawaii-P2 InitFileB-hawaii-username-ALPHA-password OutFileB-hawaii-username-ALPHA otherfields #servername HAWAII-A hawaii-P3 InitFileB-hawaii-username-ALPHA-password OutFileB-hawaii-username-ALPHA otherfields servername HAWAII-A hawaii-P4 InitFileA OutFileA otherfields #Site 16 Dallas servername DALLAS-A dallas-P1 InitFileA OutFileA otherfields servername DALLAS-A dallas-P2 InitFileA OutFileA otherfields servername DALLAS-A dallas-P3 InitFileA OutFileA otherfields #Site 8 L.A. #servername LOSANGELES-A losangeles-P1 InitFileB-losangeles-username-ALPHA-password OutFileB-losangeles-username-ALPHA otherfields servername LOSANGELES-A losangeles-P2 InitFileA OutFileA otherfields #servername LOSANGELES-A losangeles-P3 InitFileB-losangeles-username-ALPHA-password OutFileB-losangeles-username-ALPHA otherfields ``` Here is where I am, right now, but it fails--clearly. ``` awk 'NR==FNR{z[$0];next}{if ($3 in z && $4 == "InitFileA"){ c=(echo $3| awk -F '-' {print $1});$4="InitFileB-"c"-username-ALPHA-password";$5="OutFileB-"c"-username-ALPHA"}}1' ports.lst master.tbl > output.tbl ``` I have also tried: ``` awk 'NR==FNR{z[$0];next}{if ($3 in z && $4 == "InitFileA"){ c=$3; sub(/-.*/, "", $c);$4="InitFileB-"c"-username-ALPHA-password";$5="OutFileB-"c"-username-ALPHA"}}1' ports.lst master.tbl > output.tbl ``` I have been pulling my hair out over this. Can anyone here offer any insight as to what I'm doing wrong?
2016/11/22
[ "https://unix.stackexchange.com/questions/325252", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/154389/" ]
You have the right basic idea of splitting the task into two rounds, but then you go and invoke awk within an awk rule.. that's where I stopped reading it; it is just too complicated a way to solve such a simple problem. Consider this awk snippet: ``` awk 'BEGIN { RS = "[\t\v\f ]*(\r\n|\n\r|\r|\n)"; FS = "[\t\v\f ]+" } FNR==1 { file++ } /^#/ { next } file==1 { port[$1] = $1 } file>=2 && ($3 in port) { base = $3; sub(/-[^-]*$/, "", base); $4 = "InitFileB-" base "-username-ALPHA-password"; $5 = "OutFileB-" base "-username-ALPHA"; } file>=2 { printf "%s\n", $0 } ' ports.lst master.tbl ``` Note: I added the necessary semicolons, so you can write all of the above in a single line. If you run the above with the example input files, you get ``` losangeles-P1 losangeles-P3 servername HAWAII-A hawaii-P1 InitFileB-hawaii-username-ALPHA-password OutFileB-hawaii-username-ALPHA otherfields servername HAWAII-A hawaii-P2 InitFileB-hawaii-username-ALPHA-password OutFileB-hawaii-username-ALPHA otherfields servername HAWAII-A hawaii-P4 InitFileA OutFileA otherfields servername DALLAS-A dallas-P1 InitFileA OutFileA otherfields servername DALLAS-A dallas-P2 InitFileA OutFileA otherfields servername DALLAS-A dallas-P3 InitFileA OutFileA otherfields servername LOSANGELES-A losangeles-P2 InitFileA OutFileA otherfields ``` The `BEGIN` rule just sets universal newline support, in case the files were transferred from some other system (Windows, for example) with a different newline encoding. The `FNR==1` rule is used to update the `file` variable, so that it reflects the file being processed (1 for first, 2 second). The `/^#/ { next }` rule skips all lines beginning with a hash mark. They are comments, so they don't need to be kept. We could also add a rule `/^[\t\v\f ]*$/ { next }` to skip all empty lines, if you wanted to compact the output file. The `file == 1 { port[$1] = $1 }` rule adds all first fields in the first file to associative array `port`. The value assigned (`= $1`) does not matter, so we could actually just use `= 0` here. The `file >= 2 && ($3 in port)` rule applies to second and any following files, and is executed if the third field matches one of the keys in the associative array `port`. (The values do not matter; only the keys are checked.) In other word, this rule is only applied when the third field is one of the keys specified in the port list. The third field is copied to a variable `base` -- this matched one of the keys in `port[]` --, and everything after the last `-` is removed using `sub()`. Then, we modify the fourth and fifth fields. Note that in awk, there is no string concatenation operator; we just state the strings next to each other. In other words, `("foo" a "bar")` is one string, consisting of "foo", immediately followed by the value of variable `a` converted to a string, immediately followed by "bar". The final rule prints the (possibly modified) record, but ensures a `\n` newline is used. Only the records in the second and subsequent files are used. Now, if `ports.lst` contained the respective usernames and passwords, I'd slightly modify the above (maybe three lines changed?), but I hope you can see the overall approach.
55,326,502
Somewhere in my site I have there folders: * (...)/font-awesome/5.0.6/css/ * (...)/font-awesome/5.0.6/webfonts/ * (...)/font-awesome/5.8.1/css/ * (...)/font-awesome/5.8.1/webfonts/ If I include file `font-awesome/5.0.6/css/fontawesome-all.min.css`, [Font Awesome](https://en.wikipedia.org/wiki/Font_Awesome) works. If I include file `font-awesome/5.8.1/css/fontawesome.min.css`, Font Awesome shows blank squares instead of icons. It is most likely not due to cache as I've cleared the browser cache and .css cache files. I remember that in the past, when integrating Font Awesome into a website, I was required to manually change some relative URLs inside the library, but that, if I remember well, was with Font Awesome 4. I feel however like I'm missing some installation step. I just can't remember since it was "so long ago".
2019/03/24
[ "https://Stackoverflow.com/questions/55326502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1103990/" ]
Do you download the .zip file instead of a single `all.min.css` file? If not, then download the .zip file, unzip it, and link the main CSS file inside the header. On the other hand, you can use the [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) link they provide: ``` <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"> ``` Both work perfectly.