INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Chicken marinade with soy sauce - have I done something wrong? I have made a chicken marinade with soy sauce, olive oil, dry herbs and spices. I put it to marinate for 3-4 hours (like I mostly do), but I couldn't cook it that night so I left the chicken in the marinade over night. The chicken was left to marinate in the refrigerator, in a sealed ziplock bag. The next day the chicken had some brown dry parts (almost like a burn). I expected it to be brown, but the dry parts were looking awful. I threw away the chicken at that time because I thought it wasn't safe to eat. Have I done something wrong? Is it safe to marinate in soy sauce for more than a few hours? Could I have prepared that chicken without any worries?
Soy sauce is pretty salty. It sounds like a great deal of water diffused out of your chicken and into the marinade, which significantly changed the texture of the meat. It's not uncommon to do something like this on purpose. When you make gravlax, for example, you cover a piece of salmon with quite a bit of salt and refrigerate it for a day or two. The salt draws out a lot of moisture, causing the fish to firm up considerably. Even though your soy sauce marinade was liquid, it still had a much higher salt concentration (or to think of it another way, a much lower water concentration) than the chicken, and would have had the same effect.
stackexchange-cooking
{ "answer_score": 7, "question_score": 3, "tags": "chicken, marinade, soy" }
$_SESSION variable rewritten I'm having a really weird behavior with php's session variables. The problem is that the session value is being rewritten automatically with no apparent reason. Code snippet illustrating is something like this: <?php session_start(); $_SESSION["id"] = 5; echo $_SESSION["id"]; // Echoes 5 $id = $_REQUEST["id"]; // Being for example $_REQUEST["id"] = 3 echo $_SESSION["id"]; // Echoes 3 ?> May it be something misconfigured? P.S.: Running PHP version is 5.3.3
You probably have `register_globals` set to on in your php.ini configuration. That means you can reference `$_SESSION['id']` just using the variable `$id`, leading to the problem you're seeing in your example above. Set `register_globals` to off in php.ini and try again.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php, session, session variables" }
Moment.js creating a popup at a specific time this is the first time i am using moment.js, but im trying to create a time period for a popup or a button to appear. As this is my first time using this its very unclear through the docs how to go about this: < the way i have in mind is through the duration section or manipulate $('.button').hide(); if(moment.duration(9, 'hours')){ $('.button').show(); } else{ $('.button').hide(); } so something like this but i am unsure and I am trying to get it so that the time should start at 9am
I've ended up using the get set functions off the site so it will look like this: $('.button').hide(); if(moment().hours() >= 9 && moment().hours() <= 11){ $('.button').show(); } else{ $('.button').hide(); } which worked fine for momentjs
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, jquery, html, momentjs" }
Do you use internal energy or enthalpy to calculate energy required to boil water from saturated liquid to saturated vapor The water stream is heated in a boiler, at some constant pressure. When entering the boiler, the water flow is in a saturated liquid state. After heating the outflow fluid has become saturated vapor. My question is if I want to calculate how much heating energy is needed, do I use $$Qb = Ug - Uf$$ or $$Qb = hg - hf$$ U is Internal Energy, h is enthalpy, and f and g refer to saturated liquid and saturated gas
Use enthalpy. $Q_b$ is then $h_{fg}$ from the steam tables. $h_{fg}$ is the latent heat of vaporization, the heat required per unit mass to convert the mass from saturated liquid to saturated vapor. Specific enthalpy and specific internal energy are related by $$h=u+pv$$ Hope this helps.
stackexchange-physics
{ "answer_score": 1, "question_score": 0, "tags": "thermodynamics" }
correct concurrency pattern I have made an OS simulator for a project, for the next part I have to modify the simulator to include 4 CPUs in place of only 1 CPU from the previous part, so that all the processes get done in a faster time. So I have to add concurrency but I am not sure what the right design pattern is for this kind of thing. I need to know if the following will actually give me a speed up. CPU extends Thread //in main get process1 get process 2 get process 3 get process 4 cpu1.run(process1) cpu2.run(process2) cpu3.run(process3) cpu4.run(process4) am I right in assuming that because cpus are extending thread they will all run concurrently for finish the 4 processes or will it be just like running the 4 processes on a single CPU?
By the nature of the question, this is a class project and that your representation of a cpu is relatively simple. For example, just runs a series of instructions like thread class. If however, you are trying to emulate real world CPUs and microprocessors, we need to know more about the cpu features: scheduling, event handling and other low level aspects that are normally hidden. But, in the simple case, the answer is generally yes. Note, depending on the tasks in those processes and the CPU you run this code on, you may see different behaviors because of how the CPU and JVM are actually implementing threads. But, I think in your case it isn't relevant.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java" }
Name an Armor Stand using the Standard Galactic Alphabet The Standard Galactic Alphabet is what appears in the Enchanting Table. Is there a way to give a name to an Armor Stand using these character. I know there is a LingoJam Translator that give ASCII characters that look like the SGA, but that is not what I'm looking for. Can I use the same characters as the Enchanting Table?
Unfortunately, there is no way to name any entity using the Standard Galactic Alphabet. The closest you will get is to use the LingoJam translator characters. You can only name an entity with Unicode characters so you can not name an armor stand with Standard Galactic Alphabet characters. You could create a texture pack and change some of the Unicode characters to look like Standard Galactic Alphabet Characters. Here is some more information on that. <
stackexchange-gaming
{ "answer_score": 2, "question_score": 0, "tags": "minecraft java edition" }
How to check if a value exists in any of the columns in a table in sql Say, I have 100 columns in a table. I do not know in which columns a particular value could exist. So, I would like to check across all columns, if it exists in any of the 100 columns, I would like to select it. I searched around a bit, and in most places the solution seems to be something like the following select * from tablename where col1='myval' or col2='myval' or col3='myval' or .. or col100='myval' I also read a few forums where having to do this is said to be a bad case of database design, I agree, but I'm working on an already existing table in a database. Is there a more intelligent way to do this?
One way is by reversing the `In` operator select * from yourtable where 'Myval' in (col1,col2,col3,...) If you don't want to manually type the columns use `dynamic sql` to generate the query declare @sql varchar(max)='select * from yourtable where ''Myval'' in (' select @sql+=quotename(column_name)+',' from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='yourtable' select @sql =left(@sql,len(@sql)-1)+')' --print @sql exec sp_executesql @sql
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 4, "tags": "sql" }
custom validation to compare the float value of two text box I am using a custom validator to compare value in two text box. This is comparing the values fine. But it says "025" and "25" are different.. can this do a float comparision. the custom validator i am using is <asp:CompareValidator id="compval" runat="server" ControlToValidate="txtBox1" ErrorMessage="There values are not equal." Enabled="False" ControlToCompare="txtBox2">*</asp:CompareValidator></TD> Please let me know if this is possible.
Use System.Double.Parse(value) to convert both to a floating point number, and compare those numbers. You can also use TryParse if you don't want to handle exceptions if the value is not a valid floating point number. See also: * < * <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, .net, asp.net, vb.net" }
How to Separate Object From Arrayed Parent To make object scale intact I arrayed a plane around a curve and parented my object to that plane. It worked but now I need to separate these objects from arrayed plane because I am going to animate them. I tried to use Clear and Keep Transformation but it did not work in this case.
You need to `Ctrl``A` > _Make Instances Real_
stackexchange-blender
{ "answer_score": 1, "question_score": 1, "tags": "modeling, animation, parent" }
PHP array from loop to string I import a CSV file with the following code (extract): while(($line = fgetcsv($csvFile, 0, "\t")) !== FALSE){ //some mysql insert $aff[] = $line[12]; } Now I need to get some items to use them later in the code. I added the $aff variable, but was not able to create a string from the items. The final string should be seperated with a comma: a, b, c How can I do that? If I print the $aff out, it only says "Array".
Use php's implode function - < $string = implode(",", $aff); That will create a string separated by commas from your array.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php, arrays, loops" }
N white and black balls and N boxes Probability Given $N$ boxes , $N$ white balls and $N$ black balls chooses one box randomly and one ball from it randomly Find the probability of getting white ball.
It depends on how the balls are distributed among the boxes. We will assume each box has at least one ball. Then we could put a white into $N-1$ of the boxes, and all $N$ black and the remaining white into the last box. The probability of white is then $\frac{N-1}{N}+\frac{1}{N(N+1)}$. This is close to $1$ if $N$ is large. Similarly, by an analogous distribution, we can make the probability of black close to $1$. If on the other hand we put $2$ balls in each box by a process that does not pay attention to the colours of the balls, then by symmetry the answer is $1/2$.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "probability" }
Посоветуйте 3D библиотеку для Android разработки Необходима библиотека для вывода 3d графика функции. Или выводила 3d график в 2d плоскость с выделением уровней цветом. Библиотека на Java.
Для вывода графиков активно используется Achartengine Легко кастомизируется, имеет множество различных графиков. Про 3d-графики возможно подскажут тут Есть еще такая либа - charts4j
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "android, java, 3d" }
how to send fax (pdf) from the command line using SIP? (Linux) I would like to integrate a system with a SIP phone, the system generates pdf files, that should be faxed to specific fax numbers (e.g. sale orders) via SIP. Is there an easy way to accomplish this? The system is run under Linux. Unfortunately, I don't have any experience with SIP.
Hylafax is what you want to look at. It's the preeminent open source fax server. If you must fax using SIP then make sure your SIP Provider supports T.38. Without it your faxes will be sent as a standard call with the fax carried over RTP and it only takes a few lost packets here and there to corrupt your fax or cause the transmission to be aborted altogether.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "sip, fax" }
What is the scope of "$this" and what are the drawbacks of using it? Having basic knowledge of JAVA, I understand that usually **"this" keyword** is used for **local references** made within a class. But as far as PHP OOP is concerned, and more specifically **as far as Magento** is concerned, what is the **scope of "$this"** which is used to make references (for example, calling methods, etc.) everywhere within block files, template files.. and so on?? What are the drawbacks if we make this kind of direct references through "$this"?? Thanks in advance :)
`$this` still refers to the current object in PHP (and Magento also). The fact that you see it outside a class is just a side effect of how Magento works. Technically you are still inside a class when using it in template file. See how this method looks `Mage_Core_Block_Template::fetchView()`. This is the method responsible for rendering a block via a template. Notice this code: $includeFilePath = realpath($this->_viewDir . DS . $fileName); if (strpos($includeFilePath, realpath($this->_viewDir)) === 0 || $this->_getAllowSymlinks()) { include $includeFilePath; } else { Mage::log('Not valid template file:'.$fileName, Zend_Log::CRIT, null, null, true); } The template file is actually included in the method. The think that must look strange to you if you come from the world of JAVA is how `include` works for PHP.
stackexchange-magento
{ "answer_score": 4, "question_score": 1, "tags": "magento 1.7, template" }
How to manage code conversion? I have to convert an application with about 100k lines of code from one programming language to another (java to c++). I'm looking for a solution to track my progress and make sure that nothing falls through the cracks. So far I've thought about two approaches, but neither seems to be optimal: * copy the old code as comments into the new source files, and delete the portions that are converted (this gets messy) * print out the old code, and use a highlighter to mark converted code (not efficient) Probably the best solution would be some text editor where I could keep the old code base and digitally highlight/mark up the code that's already converted. Does a utility like this exist? Or is there a better solution for managing code conversion?
You can check your old code into a VCS (e.g. Git, SVN, etc.), then start deleting the parts which you've already converted. The VCS diff tool will tell you clearly what parts have been deleted, acting like this "digital highlighting" approach but simpler (because the old code base will shrink as you convert it). The most pragmatic approach would be to convert the tests first (if you have any tests...). Then you can write the new code against the tests. If you don't have tests, strongly consider making some. Converting 100KLOC without tests is a recipe for subtle bugs months later.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "code conversion" }
How to safely delete a system partition? I got the following disk ![enter image description here]( `sda9` contains a new Linux installation which I'd like to keep, while `sda5` is the old installation which I'd like to **free** (and successively merge with `sda4`, but we don't care). `sda4` contains a Windows installation which I'd like to keep. The question, made to be sure of **avoiding (grub) problems at boot** , is: _do I need just to delete_ `sda5` _without any other operation, and nothing will break ?_
Be sure that you run sudo update-grub **immediately after** you make any changes to the partition table. That is not necessary in some cases but it is always safe to do it. In your case it is better to make all changes from your new Linux installation: delete a partition and then update grub. If you are going to use Live CD instead you need to update grub by chroot-ing to your new Linux installation (you don't need to reinstall it, only update). That _should_ work unless you made any unsafe changes to your configuration files (e.g., if you ever made any changes to /etc/fstab, you **must** check that all partitions there are identified by UUID, not by their names). Anyway to be on the safe side it is always better to have Live CD in case something goes wrong. Good luck!
stackexchange-unix
{ "answer_score": 2, "question_score": 0, "tags": "partition, grub2, shared disk" }
Query SQL Server with IN (NULL) not working When I define a "User-Defined Table Type", as: CREATE TYPE [dbo].[BitType] AS TABLE( [B] [bit] NULL ) I place 0 and null in this table-variable. Then I do this query: SELECT something FROM theTable WHERE item IN @theBitTypeTable Will only get `item=0` not `item is null` Simply put: `SELECT something FROM theTable WHERE item IN (0, NULL)` is not working (no error although) It has to be `SELECT something FROM theTable WHERE item=0 OR item IS NULL` So, my question is, if I like to use **User-Defined Table Type** , but I also need to use NULL value. How can I perform the query correctly to get result include null item. Thanks (btw, I use MS SQL Server 2008 R2)
The only valid comparison operations with `NULL` values are `IS NULL` or `IS NOT NULL`, others always return false (actually - Unknown, see the @Damien_The_Unbeliever's comment) So, try the following CREATE TYPE [dbo].[BitType] AS TABLE( [B] [tinyint] NOT NULL ) GO declare @theBitTypeTable BitType insert @theBitTypeTable VALUES(0), (2 /* instead of NULL*/) SELECT something FROM theTable WHERE IsNull(cast(item as tinyint), 2) IN (select B from @theBitTypeTable)
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 8, "tags": "sql, sql server, sql server 2008, tsql, table variable" }
System.TypeException: Invalid date/time: 2018-09-18T16:57:37Z I'm getting Invalid date/time: 2018-09-18T16:57:37Z in the developer console. please help me with this DateTime dt = Datetime.now().addMinutes(-10); String formatedDt = dt.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\''); DateTime myDateTime = DateTime.valueOf(formatedDt); system.debug('date *****'+myDateTime);
`dt.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');` formats the date in a way that is incompatible with the `DateTime.valueOf()` method. `DateTime.valueOf()` expects the string to be formatted as `yyyy-MM-dd HH:mm:ss` and in the local timezone. Since your string isn't formatted that way, you're getting an error when that line runs. To get the correct format you should update this line `String formatedDt = dt.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');` to this: `String formatedDt = dt.formatGMT('yyyy-MM-dd HH:mm:ss');`
stackexchange-salesforce
{ "answer_score": 5, "question_score": 0, "tags": "soql, batch, datetime" }
Minifying CSS, JS, and HTML - together Minifying JS and CSS is quite common. The benefits of minifying JS are much greater that those seen with CSS because with CSS you can't rename elements - and same goes for HTML. But what if all 3 were minified together so that the benefits of using shorter names can be brought to CSS and HTML? That is, instead of minifying without any regard to the relationships between the 3, these could be preserved and made simpler. I imagine that the implementation could be quite difficult but if it were possible, do you think it would provide a significant advantage over traditional minification?
> I imagine that the implementation could be quite difficult but if it were possible, do you think it would provide a significant advantage over traditional minification? Minification does matter and this largely depends on amount of scattered pieces of text. Yahoo's YSlow and Google's Page Speed both do talk about all three and provide solutions such as saving the minified version from within themselves. So it is good idea to minify where there is room for it and performance is critical.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 7, "tags": "javascript, html, css, minify" }
Angularjs with $sce.trustAsHtml not working I'm filling the contents of a element using data retrieved from the DB. This is done within the controller of the page. The HTML simply looks like: <select class="form-control" id="maxsize" style="width:50px"> {{List_of_Possible_Sizes}} </select> Within the controller, the string "List_of_Possible_Sizes" is properly built (I know because I replaced the {{...}} with the result of the JS and got the correct result), but when looking at the elements within the browser I see complete string generated from the JS as an actual string (i.e. something like: " <option value.....</option><option....>...." and this in spite of the fact that the assignment is: List_of_Possible_Sizes = $sce.trustAsHtml(MyString); Any clues you can suggest? Thanks.
If you put the string inside curly braces `<select>{{some html}}</select>` it will be displayed as literal string. Instead you need to use the `ng-bind-html` attribute for displaying html. <select ng-bind-html="your html"></select> Note: this will only work with trusted html.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, angularjs" }
Capacitive AC voltage detection As I understand it, a non-contact voltage tester works by creating a capacitive connection from a power line to ground, via the detection circuit and the operator's hand/body. This connection passes a tiny amount of current which the detection circuit can pick up. I'd like to use my Arduino to detect the presence of mains voltage (120v) in a wire without actually connecting to the conductor (for safety and isolation reasons). Because there may not be any current in the wire, current transformers/hall effect sensors would not work. Is it possible to use a similar approach to the non-contact voltage testers to detect the voltage? I couldn't find any schematics online for commercial testers to see and understand how they work.
I ended up going with a circuit based on the design here. With my modifications, it seems to work well, and does not pick up other RF emissions as false positives. !schematic simulate this circuit - Schematic created using CircuitLab The antenna is a 4-inch length of solid 22 gauge wire. Out is high until voltage is detected. D2/C1/R1 filter out the 60Hz pulses from the 4011 output, so that the output stays constant.
stackexchange-electronics
{ "answer_score": 3, "question_score": 6, "tags": "arduino, ac, capacitive" }
LDAP: How to authenticate user with sAMAccountName? I am not able to authenticate when user passes `sAMAccountName` and `password`. If I do follwoing: env.put(Context.SECURITY_PRINCIPAL, "CN="+username+",OU=Service Accounts,OU=TECH,DC=wawalab2,DC=ins"); env.put(Context.SECURITY_CREDENTIALS, password); it throws exception: > javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece Note: I can use Spring LDAP framework too.
First off, the 525 error is bad DN. You can see a list of the LDAP errors AD returns at this link: AD LDAP Error codes So you have a bad DN. What you want to do is search for samAccountName=username, get the DN from the returned value, and bind with that proper DN.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 4, "tags": "java, spring, ldap, spring ldap" }
JQuery plugin help I am building a little plugin for jquery and on the default options I want to give if it should be used "bind" or "live" for the click event. So I have var defaults = { method: 'bind' /* or live */ }; var options = $.extend(defaults, options); and the plugin continues $(selector).**method**('click', function(event) { /* code */}); Now, how can I make that the method is chosen by the default method value, without having to write the following. if(options.method == 'live') { $(selector).live('click', function(event) { /* code */}); } else { $(selector).bind('click', function(event) { /* code */});} Thanks.
You should do this: $(selector)options.method { /* code */ }); Cheers
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "jquery" }
An example about finitely generated modules and finitely cogenerated modules I am studing the book "Rings and Categories of modules" written by Frank W. Anderson and Kent R. Fuller. On page 124, I am at a loss for an example. **Example.** The abelian group $\mathbb{Z}$ is finitely generated but not finitely cogenerated. The abelian group $\mathbb{Z}_{p^\infty}$ is finitely cogenerated but not finitely generated. I post my effort here. (1).We can regard them as modules over $\mathbb{Z}$. (2).$\mathbb{Z}$ is finitely generated is clear. (3). By the chain $0 \subset \left({1 \over p}\mathbf{Z}\right)/\mathbf{Z} \subset \left({1 \over p^2}\mathbf{Z}\right)/\mathbf{Z} \subset \left({1 \over p^3}\mathbf{Z}\right)/\mathbf{Z} \subset \cdots$ of $\mathbb{Z}_{p^\infty}$. We know $\mathbb{Z}_{p^\infty}$ as $\mathbb{Z}$-module is Artinian but not Noetherian. Any help will be appreciated.
_Ad (1):_ You mean you regard them both as modules over ${\mathbb Z}$, no? _Ad (3)_ : The chain you provide indeed shows that ${\mathbb Z}_{p^{\infty}}$ is not finitely generated, but to show that it is artinian and hence finitely cogenerated, you still need to note that you've actually listed _all_ submodules.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "abstract algebra, modules" }
Automatic Service Recovery (Linux) **What is an easy convenient automatic service recovery option?** Basically if for example iptables stops I wish it to be automatically start soon after. I would like to apply this to 6-10 services.
we have used monit in the past. Its syntax looks like this: check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/ssh start" stop program "/etc/init.d/ssh stop" if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout Now we use the processes capabilities of CFengine to restart/kill processes for a very broad range of reasons, but you need to have an existing CFengine infrastructure to do that.
stackexchange-serverfault
{ "answer_score": 3, "question_score": 1, "tags": "linux, centos" }
Grails controller variables not visible in the views I am quite new to grails. I just noticed that variables in the controller are not visible in the view. I only can get the variable values when I assign it to a scope. Is this the standard Grails way or am I doing this wrong. Also, is the params scope the correct one to use or should I use sessions, servletContext? In the Controller String uploadLocation = grailsApplication.config.uploads.location.toString() params.put "upLoc", uploadLocation In the View <td> <input type="text" value="${params.get('uploc')}/${fileResourceInstance.decodeURL()}"></input></td> I'm very familiar with Ruby on Rails and this is handled very differently in RoR. Thanks.
You can do it like Maricel say, but there's another way (I think it's a default way to do): return the values you want to pass to the view in action function. For example def test = "abc" def num = 3 return [testInView: test, numInView: num] Then in view you can access ${testInView}, ${numInView} Another slightly different way: you can neglect the "return" keyword, it's "groovy way" to return the last value of the function.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 7, "tags": "grails, view, controller" }
Matmul in Fortran I obtain different results from matmul in Fortran and Python. How to get the right one in Fortran. B is probably not understood as a 3x3 matrix. How to solve it, please? k = 1 m = 3 In Fortran, I have: A(k:m,k): 0.88807383397711526 0.32505758367186816 0.32505758367186816 B(k:m,k:m): 1.0000000000000000 1.0000000000000000 1.0000000000000000 -1.0000000000000000 0.0000000000000000 1.0000000000000000 1.0000000000000000 0.0000000000000000 1.0000000000000000 matmul gives 1.5381890013208515 -0.56301625030524716 1.2131314176489834 In Python, I have: A[k,k:m] [ 0.888074 0.325058 0.325058] B[k:m,k:m] [[ 1.000000 1.000000 1.000000] [-1.000000 0.000000 1.000000] [ 1.000000 0.000000 1.000000]] matmul gives [ 0.888074 0.888074 1.538189]
It depends on the order of the multiplication. Numpy considers 1D arrays without treating it as a row or column vector. import numpy as np A = np.array([0.88807383397711526, 0.32505758367186816, 0.32505758367186816]) B = np.array([[1, 1, 1], [-1, 0, 1], [1, 0, 1]], dtype=float) If you do `A@B`, which is the same as `np.matmul(A,B)`, assuming `A` is actually a "1D row array", you get >>> A@B array([0.88807383, 0.88807383, 1.538189 ]) But if you do the opposite, i.e. `B@A` which is the same as `np.matmul(B,A)`, assuming `A` is actually a "1D column array" you get >>> B@A array([ 1.538189 , -0.56301625, 1.21313142]) * * *
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, fortran" }
2 tables with more than one relationship I have 2 tables, an events and users. These 2 tables has 2 types of relationship. > 1 event can have 1 creator (user) 1 user can create many events and > 1 event can have many members (users) 1 user can join many events for the many-to-many relationship, I will create another table to link them. Probably named it `participants`. But I'm not sure how should I put my first relationship (1-to-N above) into this. How should I design it?
The creator is not related to your `participants`, so I would not try to mix them. Add the reference to the creator as another column to the `event`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "database design" }
Call one python script from inside the other script I have 2 python scripts, First script runs like this on Windows: %python script1 -d dir1 Second script runs like this: %python script2 -d dir1. Both are working fine. Instead of running both sequentially I want that script1 at the end call script2. Note: in script1 I parse dir1 as sys.argv[2] I used like this at the end of the script1 : os.system("c:\ipython\ipython\ipy.exe script2 -d sys.argv[2]") It failed because treated sys.argv[2] literally When I replaced sys.argv[2] for hard-coded dir1 it worked correctly. The error I've got: WindowsError: [Errno 2] [Errno 3] Could not find a part of the path 'N:\Scripts\deleteMe\sys.argv[2]' My 2 questions: 1. How could I fix it? 2. How could I replace hard-coded path to 'ipython' to something more appropriate? Thanks
You can use subprocess.Popen: subprocess.Popen(['python', 'script2', '-d', sys.argv[2]])
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python" }
Should I use the 'use' keyword in this code My code tree. > src : > > > main.rs > modA : > mod.rs > a.rs > main.rs : mod modA; fn main() { println!("Hello, world!"); } mod.rs : pub mod a; a.rs : dummy function This code compile. But I have understood that I should write in mains.rs > use mod modA instead of > mod modA ; (as it indicated in this link :< But the compilator has said :unresolved import. Should I keep the code as he currently is or should I do otherwise?
That's not quite right, you should only use the `use` keyword to prevent having to type full path to items within the sub module in other modules outside main. To pull the submodule into the hierarchy, your first approach was correct: mod modA
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "rust" }
Changes in data are not reflected to DropDownList in Internet Explorer We have DropdownLists in our Asp.Net Mvc views. We fill them with data through jquery ajax posts. In Internet Explorer, changes in data would not be seen in DropdownList UNTIL we press Ctrl + F5. Since we could not go to production with it, we needed to solve this problem.
Problem was that Internet Explorer is caching ajax posts by default. Solution is to add `cache: false` to your post, like below: $.ajax({ cache: false, url: "ourUrl", type: "GET", success: function(data) { //stuff } });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "jquery, ajax, asp.net mvc" }
Sort string values delimited by commas in a column using pandas I have this dataframe, and I'm looking a pythonic way using Pandas to sort these values. Column 2 is a string. C1 C2 0 b,g,f 1 a,f,c 2 f,e,a,c The Output should look like: C1 C2 0 b,f,g 1 a,c,f 2 a,c,e,f
import pandas as pd data = [ { "C1":0, "C2":"b,g,f" }, { "C1":1, "C2":"c,b,a" }, { "C1":2, "C2":"f,e,a,c" } ] df = pd.DataFrame.from_dict(data) df.C2 = df.C2.sort_values().apply(lambda x: ",".join(sorted(x.split(",")))) print(df)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, pandas, dataframe, sorting, delimited" }
Split by RegExp I need to find a way to split this string based on comma ','. "saleHours.sunTo(saleHours.satTo, saleHours.satFrom), saleHours.funTest(saleHours.sunFrom)" However this is the desired result: `["saleHours.sunTo(saleHours.satTo, saleHours.satFrom)", saleHours.funTest(saleHours.sunFrom)"]` Not this: `["saleHours.sunTo(saleHours.satTo", " saleHours.satFrom)", " saleHours.funTest(saleHours.sunFrom)"]`. So I somehow need to escape the commas within '()'. Any help is greatly appreciated, thank you.
var input = "saleHours.sunTo(saleHours.satTo, saleHours.satFrom), saleHours.funTest(saleHours.sunFrom)"; var m = input.split(/\),/); var l = m.length; for(i in m) { if(i<l-1) m[i] = m[i]+")"; } console.log(m); output: [ 'saleHours.sunTo(saleHours.satTo, saleHours.satFrom)', ' saleHours.funTest(saleHours.sunFrom)' ]
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, regex" }
DATEADD() not working in sqlfiddle? I am trying to return data from the past year from the current date, for example the table... Orders OrderID CustomerID OrderDate 1 23 2015-10-11 the OrderDate is in format date, I am using SELECT * FROM Orders WHERE OrderDate BETWEEN (DATEADD(yyyy, -1, GETDATE())) AND (GETDATE()); But keep getting the error FUNCTION db_9_9bcca.DATEADD does not exist Does DATEADD() work with < ? Thanks.
`DATEADD()` should work with sqlfiddle if you have specified an `MSSQL` Server in the DDL. I did so with the following DDL to build the schema: CREATE TABLE Orders (OrderID int, CustomerID int, OrderDate date); and ran the following query SELECT * FROM Orders WHERE OrderDate BETWEEN (DATEADD(yyyy, -1, GETDATE())) AND (GETDATE()); and received the following result: > Record Count: 0; Execution Time: ms
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, dateadd, sqlfiddle" }
How can I be notified whenever a new site leaves Area 51? Can I be notified whenever a new site leaves Area 51? If so, how?
If you are committed to the proposal, you'll get an email. Alternatively, you can follow the beta feeds.
stackexchange-meta
{ "answer_score": 3, "question_score": 1, "tags": "support, area 51" }
Python: fastest way to find the largest element is a DS smaller than a given value then delete it If we use `list`, then finding the element takes `O(log n)` time but deleting takes linear time. If we use `set`, then deleting takes constant time but finding the element takes linear time (I believe there is no build-in function for such purpose and we need to loop over all elements). Is there a suitable data structure in python to achieve both steps in `O(log n)` time?
Built in, I don't know, you'll find a library for everything. But you should check out Binary Trees. Elements can be found in `O(log n)`, but making one takes time, so don't use it untill you plan searching multiple times. Also there are varieties, to handle strings, objects, not just numbers. Radix tree, Red Black Tree, etc. Wikipedia Example I found a library for that: binarytree.
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -1, "tags": "python, data structures" }
Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials I want to connect PowerShell to Azure with the command Connect-AzAccount. I am connected successfully with a warning: _Unable to acquire token for tenant 'xxx'_. When I run commenad Get-AzVM I have error message: _et-AzVM: Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials._ Any tips and help please?
There could be possibility that your account is associated with the more than one tenant. In one of the tenant you may not have the desired permissions. Rather than connecting to all the tenants, you could specify the tenant you would like to connect to : Connect-AzAccount -Tenant <Your Tenant ID> If you are still encountering the issue for your tenant as well. More likely there is a permission issue.I would suggest you reach out necessary stake holder (Tenant Admin for instance) to grant you the necessary permissions to run the powershell commandlet.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "azure, powershell" }
Alias grep "$1" filename doesn't work, somehow "$1" went missing Normal `grep` wolf@linux:~$ egrep 4.4.4.4 data.csv A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4 wolf@linux:~$ Since I've a lot of data to grep, I've put it on alias. wolf@linux:~$ alias z="egrep $1 data.csv" wolf@linux:~$ But it doesn't work wolf@linux:~$ z 4.4.4.4 grep: 4.4.4.4: No such file or directory wolf@linux:~$ It turns out that `$1` was missing from the alias. wolf@linux:~$ alias z alias z='egrep data.csv' wolf@linux:~$ What was the reason behind this?
Try a function instead of alias z() { egrep -- "$1" data.csv; } Output $ z() { egrep -- "$1" data.csv; } $ z 3.3.3.3 A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4 B,1.1.1.1,1.1.1.1,1.1.1.2,1.1.1.3,3.3.3.3 $
stackexchange-unix
{ "answer_score": 5, "question_score": -1, "tags": "alias" }
Objective C unsharp mask filter Xcode What would be the most efficient way to create an unsharp mask filter in Objective C targeting iOS? Would it be best to implement some open source like ImageMagick or build from scratch. I think the basic formula is generally as follows (please comment if I have not gotten it right). 1. Duplicate original 2. Blur duplicate (Gaussian) 3. blend with original via "difference" 4. use result to mask original 5. Increase contrast in the unmasked areas of the original.
Core Image has the CIUnsharpMask filter built-in, although I'm not sure if it's available on iOS yet. Brad Larson's GPUImage framework also has an unsharp mask filter. Both methods should be very fast and much easier to implement than cross-compiling ImageMagick or writing your own.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "objective c, ios, filter, photo, imaging" }
Can I connect these two different types of drain material together? If so, what sealant should I use? I'm preparing to replace a bathtub and the new one requires a different drain assembly (the overfill drain is a wide-mouth connector). Anyway, I'm noticing that the new drain pipe material itself is different - a white plastic (PVC?) compared to the old drain which is a black plastic (not sure what it is). !Old drain on the left, new on the right Is it OK to mix these two types of materials? I seem to recall that some plastics can't be interconnected together or that a special glue is required. If it IS OK, what type of sealant should I get? Just a standard silicone glue?
Black plastic drain pipes are typically ABS. White, usually PVC. There is a special cement that can join the two which will be found in the area with regular PVC cement at the plumbing supply. Just check the label carefully. Not silicone - no way, no how, don't go there.
stackexchange-diy
{ "answer_score": 2, "question_score": 0, "tags": "plumbing, bathroom, bathtub" }
Show that the set $B$ is a basis for vector space $V$ I was reading a proof for rank-nullity theorem and a set $B$ was introduced. The goal was to show $B$ is a basis for vector space $V$. First, it was shown every vector in $V$ can be written as a linear combination of vectors in $B$ and then $B$ is a set of linear independent vectors. I wonder that is there a need for prove every linear combination of vectors in $B$ lies in $V$? I thought it is necessary but as I searched over other problems, regarding to show a set is a basis, there was no proof.
As $V$ is a vector space, it is closed under scalar multiplication and addition of elements (a fundamental property of vector spaces) and consequently also under linear combinations of elements. Since most likely $B\subseteq V$, you get the closure of $V$ under linear combinations of elements of $B$ for free.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "linear algebra, vector spaces, linear transformations" }
How to change mouse click to mouse hover? Here is the **jsfiddle link** in which I got the code for the animated tooltips, but the problem is that on `click` only they are working, I want that to be animate when I `hover` the mouse on it.
JSFiddle. Use mouse events `mouseenter` and `mouseleave`. $('.popover-example li a').mouseenter(function() { $(this).trigger("click"); }).mouseleave(function() { $(this).trigger("click"); })
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "jquery, html, css, mouseover" }
How can I view <binary data> contents in Sql Data Tools Visual Studio 2010? I have a problem viewing binary data field in SQL query results. The field values are exactly MD5 falues. Is there any features in SQL Data Tools to view this data? Example is near <
You can add calculated field with code `CONVERT(VARCHAR(35), YourField, 2)` Try: DECLARE @bin VARBINARY(MAX) = 0x5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8 SELECT CONVERT(VARCHAR(35), @bin, 2)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, visual studio 2010, tsql, binary data, sql data tools" }
Objective C - How to Stringify an id I need to compare a key object from a div to a string. I access the key object in a `for` loop: for (id key in _photosDic) { ... } In the loop, I want to compare the key with a string. Do I have to convert the key to a string?
`id` type can be anything so the first step would be to check if it is actually a `NSString` or not. for that you can use this: if ([idObject isKindOfClass:[NSString class]]) { //Now do a simple casting NSString *myString = (NSString *)idObject; //Now compare the strings NSComparisonResult result = [myOtherString compare:myString]; }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "objective c, string" }
java: join all hashmaps from an array list I have an aray list of hashmaps and I'd like to merge these hashmaps into a single one (keys should be unique). How would I have to do it? Can anybody give me a hint?
one way to do it would be to create a new instance of `HashMap ubermap`, iterate over the `ArrayList<HashMap>` and call `putAll()` method of ubermap, one map at a time. A smart optimization would be to give a large initial capacity to `ubermap` in question so you would avoid many rehash calls.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, list, hashmap" }
Поведение UDF в Spark/Pyspark Почему мы получаем результат из первой UDF, если в Spark/Pyspark, используются ленивые вычисления и по идеи мы должны получать вызов второй функции, а не первой при вызове метода show на DataFrame df1? ![Тест](
Вычисление результатов - да, ленивое. Но план строится когда выполняется `spark.sql`, так что `df1` ссылается на первую функцию которая была связана с `functionD`, которая и будет вызвана при `.show()`.
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, scala, apache spark, pyspark" }
Finding number of days between two dates having format as 'mm/dd/yyyy' in PHP I am getting random numbers on converting to days **CODE** $myDateValue = sql::readOne("SELECT `myDateValue` FROM table WHERE id = Value"); // the myDateValue is collected as TEXT in MYSQL $futureDate =$myDateValue->myDateValue; $now =time(); $futureDateTimestamp = strtotime($futureDate); $days = number_format(($futureDateTimestamp - $now)/86400,2,'.',' '); echo $days ; This is giving random numbers **OUTPUTS** OUTPUT1: -14566.25566 OUTPUT2: 1452.33655
Everything else is fine, Just add This $diff = $futureDateTimestamp - $now; $days = intval($diff /86400) ; // to find the remaining hours $rem_sec = $diff % 86400 $rem_hr = intval ($rem_sec/3600); <p> You have total of <?php echo $days .'days and' $rem_hr ?> hours Left </p>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, mysql, date, timestamp" }
Does vertical-align:middle; property work on <div> elements I have a divison element whose `vertical-align` property is set to `middle` in the css. But, still the text in the divison appears on the top. Does this property work on divisons or not? Following is the HTML <div class="compare-table-column">Seller</div> Following is the CSS .compare-table-column { float:left; width:150px; height:36px; font:11px; vertical-align:middle; }
You could do line-height:36px; if it is only one line of text
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "html, css" }
Find signal power in a band by integrating the PSD in a frequency band (and zeroing the out-of-band DFT bins) I know that directly zero DFT bins outside a frequency band has the side effect of introducing ringing, as this post says Why is it a bad idea to filter by zeroing out FFT bins?. But what about calculating the power by summing the PSD in a frequency band. In my opinion, this is similar to first setting the out-band PSD amplitudes to zeros (which may cause ringing in time domain) and then summing the remainning nonzero amplitudes. I guess it is different from first applying a bandpass filter to the time domain signal(which has no ringing) and calculating the power by averaging the squared time domain samples. Can you point out how much error the frequency domain method has? or maybe these two methods are equivalent?
For a DFT that was computed with only a rectangular window (no further windowing beyond the selection), the power in the "out of band" bins contains signal energy from "in-band", so by zeroing those out, you are not including the power that should be in the computation. The challenge however is that if there is energy out of band, it will similarly have components within your band of interest! Here we see that the real flaw is trying to compute the power within a bandwidth without windowing the signal in the time domain first to reduce the effects of sidelobes in the DFT. More details on doing this accurately, and specifically accounting for the power loss due to the windowing, and the change in the equivalent noise bandwidth of each bin, please see this post here: How can I get the power of a specific frequency band after FFT? and How to calculate resolution of DFT with Hamming/Hann window?
stackexchange-dsp
{ "answer_score": 0, "question_score": 0, "tags": "dft, power spectral density" }
Equation with floor function How would one solve an equation with a floor function in it: $$a - (2x + 1)\left\lfloor{\frac {a - 2x(x + 1)}{2x + 1}}\right\rfloor - 2x(x + 1) = 0$$ $a$ is a given and can be treated as a natural number, and all $x$ other than integers can be discarded. At least one non-trivial solution would be sufficient. Maybe an algorithmic method could be used?
Rearranging we get, $$\frac{a - 2x(x + 1)}{(2x + 1) } =\left\lfloor{\frac {a - 2x(x + 1)}{2x + 1}}\right\rfloor $$ This means,$\frac{a - 2x(x + 1)}{(2x + 1) }$ is an integer. $$\frac{a - 2x(x + 1)}{(2x + 1) }=k$$ $$a=2xk+k+2x^2+2x$$ $$2x^2+2(k+1)x+k-a=0$$ Applying the quadratic formula, $$x = \frac{-2(k+1)\pm\sqrt{4(k+1)^2-8(k-a)}}{4}$$ $a$ is known, now we substitute integers in place of $k$ to obtain solutions.
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "discrete mathematics, ceiling and floor functions" }
Prove $|\sum_{j=0}^n \frac{5^j}{c^j}-\frac{c}{c-5}|\leq\frac{(5^{n+1})}{|c|^n(|c|-5)}$ Determine whether the statement is true or false. Let $c\in C,$ and $n\in \Bbb N$ \ {$0$}. Suppose $|c|\gt5$. Then $|\sum_{j=0}^n \frac{5^j}{c^j}-\frac{c}{c-5}|\leq\frac{(5^{n+1})}{|c|^n(|c|-5)}$. As the LHS looks like a geometric series, so I tried to get a common ratio $r=1+\frac{5(c-5)^2}{c(c^2-5c+25)}$.(I'm not sure did I calculate correctly tho) However it seems that it's not useful. Or it actually does not related to sum of geometric sequence? Any help/hints to start the proof? Any inequalities can be applied? Thanks.
$\sum_{j=0}^n \frac{5^j}{c^j}=\frac {1-(5/c)^{n+1}} {1-5/c}$ by the formula for geomertic sum with common ratio $5/c$. So the left side of the inequality is $|\frac {1-(5/c)^{n+1}} {1-5/c}-\frac c {c-5}|$ which simplifies to $|\frac {c^{n+1}-5^{n+1}}{c^{n}(c-5)}-\frac {c^{n+1}}{c^{n}(c-5)}|=|\frac {5^{n+1}}{c^{n}(c-5)}|$. I will let you finish using the fact that $|c-5| \geq |c|-5$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "proof writing, geometric series" }
TrueCrypt FDE Password Recovery I have a computer with a TrueCrypt full disk encryption and I can't remember the password. I have a pretty good idea of what the password is, meaning I know the words and numbers and symbols used in it but I can't get it right, spent over an hour trying different combinations. I could make a dictionary that would crack the password and I know how to do this with TrueCrack our Hash Cat on Kali Linux with a normal TrueCrypt file container, but I just can't get it to jive with this fisk with FDE. I'm not stuck on using these methods. What's the easiest way to crack it with a dictionary attack?
In Unix, everything is a file! Just use the partition with your encrypted data as the filename. So if for example your encrypted partition is `/dev/sdb3` just use truecrack -t /dev/sdb3 -w passwords_file But actually you only need the first 512 byte of the partition to crack the password! Just copy them to a file and use this file for `truecrack` or `hashcat`. dd if=/dev/sdb3 of=~/header_sdb3 bs=512 count=1 conv=noerror,sync Then you can use the file `~/header_sdb3` to crack the password! If you need a complete step-by-step tutorial, try this
stackexchange-security
{ "answer_score": 4, "question_score": 2, "tags": "disk encryption, password cracking, truecrypt" }
Why did I failed to connect to websocket? The code of Node server with `ws` module: show = console.log WS = require('ws').Server wss = new WS port: 8080 wss.on 'connection', (ws) -> show 'a connection' ws.on 'message', (message) -> show 'received: %s', message ws.send 'something' I can connect to websocket by running the code below on the same server, and it gives out `"a connection"`: WS = require 'ws' ws = new WS 'ws://localhost:8080' But when I run these lines of code from browser, there's no respose: s = new WebSocket('ws://184.82.253.196:8080'); s.send('nothing'); What's problem, how can I fix it?
Websocket server start listening only `127.0.0.1` by default. Use this code to start listen all interfaces. show = console.log WS = require('ws').Server wss = new WS port: 8080, host: '0.0.0.0' wss.on 'connection', (ws) -> show 'a connection' ws.on 'message', (message) -> show 'received: %s', message ws.send 'something'
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "node.js, coffeescript, websocket" }
Python: Testing for unicode, and converting to time() Sometimes self.start is unicode: eg. >>>self.start u'07:30:00' Which makes datetime.combine complain start = datetime.combine(self.job_record.date, self.start) How does one: 1. Test for unicode? 2. Convert from u'07:30:00' to datetime.time?
`datetime.combine` is complaining because it expects the second argument to be a `datetime.time` instance, not a string (or unicode string). There are a few ways to convert your string to a `datetime.time` instance. One way would be to use `datetime.strptime`: t = datetime.strptime(self.start, "%H:%M:%S").time() start = datetime.combine(self.job_record.date, t)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "python, django" }
C# How to properly remove event handler code? I have a `keyup` event that I want to remove from my C# Winform: private void txtInputBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Return) { cmdSend.PerformClick(); } } If I comment out or delete this function I get an error in the design view of the form: > "The designer cannot process unknown name 'txtInputBox_KeyDown' at line 66. The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again." The program also will not compile. It happens if I try to delete any event handler code on my form. I am teaching myself C# from my background in VB.NET and in VB.NET I could remove event handler code without issue.
thats because in C#, the functions are added to the events programatically by the designer, when you add it in the designer. In the solution explorer window, Expand `Form1.cs` and open the `Form1.Designer.cs` file there: !enter image description here then locate the function : private void InitializeComponent() and delete the line that registers your event handler to the event. it will have a `+=` operator in the middle like this: !enter image description here your event will be located at line 66 and will look like this: this.txtInputBox.KeyDown += new System.EventHandler(this.txtInputBox_KeyDown);
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "c#, .net, winforms, visual studio, visual studio 2013" }
oracle sql - get difference between 2 dates (sysdate minus the datevalue of a other table) I want to know the difference betweeen 2 dates. I need something like this: "sysdate minus the datevalue of a other table" Currently I have something like this, but it's not working SELECT something FROM myTable1 WHERE mydate >= sysdate-(SELECT latestExport FROM myTable2 WHERE id=1); The 2nd select statement prints the date of the latest export. Example "27-JUL-21". thanks for your help.
It can not work. Because the result of sysdate-(SELECT latestExport FROM myTable2 WHERE id=1) is a decimal value. For example 5121.2 days difference between `SYSDATE` and `latestExport` and you can not compare your Date value `mydate` with a decimal. This is the logic you used: Is "25-10-2020" >= 5121.2 ? You need to think again about the result you want to get from this query.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "sql, oracle" }
UPDATE variable and OUTPUT TO filepath I'm trying to ask a user to insert a filepath and then output the result to that filepath: DEFINE VARIABLE outputPath AS CHARACTER FORMAT "x(50)". UPDATE outputPath. OUTPUT TO outputPath. This doesn't seem to be working. But when I do for example: OUTPUT TO "C:\temp\test.txt". It seems to work.
To use the value of a variable in an OUTPUT statement: OUTPUT TO VALUE( outputPath ). VALUE is also used with INPUT FROM, INPUT THROUGH and INPUT-OUTPUT THROUGH. (A "naked" variable name will be treated as a file name, no quotes needed -- a result of one of those "makes a good demo" decisions 30 years ago...)
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 0, "tags": "openedge, progress 4gl" }
(Magento\Customer\Model\Customer\Interceptor) with the same ID "16" already exists. Error keeps showing in Health Monitor Suite (Magento\Customer\Model\Customer\Interceptor) with the same ID "16" already exists. Error keeps showing in Health Monitor Suite.![enter image description here](
I recently ran in to this problem. It was caused by duplicate newsletter subscribers. Because of this the MySQL join resulted in two customer records being returned with the same ID when searching in the customer repository via the API.
stackexchange-magento
{ "answer_score": 1, "question_score": 0, "tags": "debugging, bug, id" }
How to use SSH import database into mysql? I have a bigger database(2.1GB). I want input it into mysql in server part. If I output it from mysql in local part with `tar.gz` format, it has 420MB, if left a `sql` format, it has 2.1GB. How to use SSH import database into mysql? some method here support sql format only: # mysql -u username -p database_name < file.sql transfer a 420MB tar.gz to server part, than do a unziped?(maybe a long time during unzipped) cut sql to many pieces? Or better idea? Another question, should I modify the `my.cnf` to support a large size file input? Regards.
Yes, if you have disk space, transfer the compressed file to the server, uncompress there, and then import. There's no obvious need to cut the file into smaller pieces. It's not like you're posting to Usenet. If your connection is slow, you can use "rsync", which can resume interrupted transfers, e.g., `rsync file.sql.gz server:/tmp/file.sql.gz`
stackexchange-serverfault
{ "answer_score": 2, "question_score": 0, "tags": "mysql, ssh, database" }
Does JBOSS EAP 6.3 support spring + websocket? I am trying to implement websocket using JBOSS and I understand for enterprise edition websockets are supported from JBOSS EAP 6.3. I am also trying to integrate websockets with spring. I was wondering, does JBOSS EAP 6.3 supports integration of websockets with spring? I have followed and configured all the steps mentioned at < except that, the application is deployed in JBOSS EAP 6.3. When I execute and try to connect, I am hitting with the following error. GET < 404 (Not Found) sockjs-0.3.4.min.js:27 u._startsockjs-0.3.4.min.js:27 (anonymous function) stomp.js:134 Whoops! Lost connection to undefined
the Atmosphere Framework supports JBoss 6.3. Just take a look at this: < Just jump on our mailing list for more information. \-- Jeanfrancois
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "spring, spring mvc, websocket, jboss6.x" }
How to not display duplicate values from database table to client form in php I have a database table **video_tbl** as follows id vdate vname 1 2016-01-05 dssfsd 2 2016-02-11 vxc 3 2016-02-16 vgjhgh 4 2015-06-12 xcbcvxb 5 2014-12-03 gjm vcb I want to show **_vdate_** years only in drop down list like 2016 2015 2014 But my output was like this 2016 2016 2016 2016 2015 2014 in dropdown list. <?php $sql_videodate = mysql_query("SELECT * FROM cf_crane_video ORDER BY cf_vdate",$con); while($row1 = mysql_fetch_object($sql_videodate)) $vdate = $row1->cf_vdate; $orderdate = explode('-', $vdate);$month = $orderdate[1];$day = $orderdate[2];$year = $orderdate[0]; ?>
Try this;) SQL Fiddle **MySQL 5.6 Schema Setup** : CREATE TABLE video_tbl (`id` int, `vdate` datetime, `vname` varchar(7)) ; INSERT INTO video_tbl (`id`, `vdate`, `vname`) VALUES (1, '2016-01-05 00:00:00', 'dssfsd'), (2, '2016-02-11 00:00:00', 'vxc'), (3, '2016-02-16 00:00:00', 'vgjhgh'), (4, '2015-06-12 00:00:00', 'xcbcvxb'), (5, '2014-12-03 00:00:00', 'gjm vcb') ; **Query 1** : SELECT DISTINCT YEAR(`vdate`) year FROM video_tbl ORDER BY `vdate` DESC **Results** : | year | |------| | 2016 | | 2015 | | 2014 |
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, mysql" }
How can I get the value of an attribute called xlink:href of an xml node by using Scala How can I get the value of the `xlink:href` attribute in an SVG path using Scala? Input: `<use style="fill:#4b0082;stroke:#4b0082;" x="57.6" xlink:href="#mbcc2581984" y="307.584"/>` Output: `#mbcc2581984` `Node \@ "xlink:href"` doesn't seem to work. My question is pretty same as this SO question, just the language is different.
I found the answer pretty quick, just keeping it here for future use. This should be `Node \@ "{
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "xml, scala, svg" }
Почему иконка из FontAwesome не работает? Помогите плиз. Первая иконка из FontAwesome работает, а вторая - никак нет. Почему? <head> <link rel="stylesheet" href=" integrity="sha384- fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"> </head> <body> <span class="clock-span"><i class="far fa-clock"></i> 15mins</span> <span class="easy-span"><i class="fad fa-signal-alt-3"></i> Easy</span> </body>
Проблема явно в том, что в подключаемом вами CSS (< нет нужного класса (.fa-signal-alt-3). Может иконка платная, а может вы указали неправильный класс, но в файле её нет)
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "html, fontawesome" }
Print into file descriptor using perl s/.../.../e I am encountering an error with the following `perl` code: #!/usr/bin/perl open $fh, '>', 'myfile.txt' or die; s|(.*)|print $fh "Hello",$1," how are you"|e; close $fh or die > String found where operator expected at ./script.pl line 3, near "$fh "Hello"" > (Missing operator before "Hello "?) I use the `s|(.*)|...|e` to write the start of the string another time, like `Hello Hello`. The expected output the file `myfile.txt` is > Hello Hello, how are you? Is there a way to make it run with the actual operations? Or must I change the `s|(.*)|...|e` operation in another way?
Interestingly, what works is to enclose the filehandle in curly brackets: s/(.*)/print {$fh} "Hello",$1," how are you"/e; It's a good practice to use them always, anyway.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "perl" }
How to call original method after it got prepend from outside I'm refactoring some old code to fit to Ruby > 2. And there is some `alias_method_chain` which I want to remove. But there is some part where the without method get called. Inside the method I have to `super` for sure but from outside? Following is given: module ExtraLog def log puts "ExtraLog" super end end class Klass prepend ExtraLog def log puts "Log" end end a = Klass.new a.log #=> "ExtraLog" #=> "Log" How can i call the original log method now without that the prepended method get called? Something like `a.original_log`?
Method#`super_method`: a.method(:log).super_method.call #=> Log
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "ruby, class, prepend" }
Can geoNear in MongoDB return a subset of fields in a document? When using geoNear it returns all the fields/entire document for the objects it finds, is there any way to limit it to a subset of fields?
That is currently not supported. The only workaround is using $near and do the distance calculation (dist = sqrt(dx * dx + dy * dy)) yourself
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "mongodb" }
How to see sfdx commands processing indicator in VSCode Is it possible to see some processing/loading indicator when I do sfdx commands in vscode terminal?
Like with any terminal command, I do not believe there is a way to see a loading indicator. Some commands like `sfdx force:package:install` or `sfdx force:mdapi:deploy` will provide continuous status feedback in terminal: ![enter image description here]( The Salesforce CLI Integration for VS Code provides a status notification and additional details in the Output panel when clicking on buttons like the **org open** button: ![enter image description here]( Additionally, any command made using the Command Palette will show in the Output panel and provide a status notification: ![enter image description here](
stackexchange-salesforce
{ "answer_score": 5, "question_score": 4, "tags": "salesforcedx, vs code" }
Gnome-shell and extensions error I install and enable some gnome-shell extensions. Then I restart computer and gnome-shell doesn't working. It display only desktop background. I wonder how to disable or delete this extensions in unity?
If you login using unity and go to /home/user/.local/share/gnome-shell/extensions Or /usr/share/gnome-shell/extensions And just delete the extension folder that is causing the problem
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 1, "tags": "11.10, gnome, extension" }
HBase aggregation, Get And Put operation, Bulk Operation I would like to know how can I map a value of a key. I know that it can be done with Get and then Put operations. Is there any other way to do it efficiently? 'checkAndPut' is not ver helpful can it be done with something like : (key,value) => value+g() I have read the book _HBase the Definitive Guide_ and it seems like Map Reduce Job interpreted to Put/Get operations on top of HBase. Does it means that it is not a 'Bulk Operation' (since it's an operation per key) ? How /Does Spark relevant here ?
1. HBase has scans (1) to retrieve multiple rows; and MapReduce jobs can and do use this command (2). 2. For HBase 'bulk' is mostly [or solely] is 'bulk load'/'bulk import' where one adds data via constructing HFiles and 'injecting' them to HBase cluster (as opposed to PUT-s) (3). 3. Your task can be implemented as a MapReduce Job as well as a Spark app (4 being one of examples, maybe not the best one), or a Pig script, or a Hive query if you use HBase table from Hive (5); pick your poison.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "hadoop, mapreduce, hbase" }
Adding Spot Instances to the Security Group of an RDS Instance I have an RDS MySQL persistant instance, and I am trying to run spot instances which are created once every 8 hours and then destroyed. The issue I am having is that I don't understand how can I add those spot instances which have dynamic IPs to the security group of my RDS Instance in order to let them perform queries,etc. Should I grab the IP as soon as the spot instance is created and the add it to the security group of the RDS instance each time a new spot instances is created? Also destroy it every time the spot instance is terminated? Any tip on what approach to take will be much appreciated! Thanks!
Assuming that both your spot instances and RDS are in the same region: when setting up an RDS security group, you can also allow machines in EC2 security groups to connect to your RDS machine. Simply add all your spot instances to a EC2 security group and grant access to RDS for this security group. If your RDS and spot instances are in different regions, you could use the AWS API or an AWS API client like boto for Python to add the IPs automatically.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "amazon ec2, amazon web services, amazon rds" }
How to get the text from textarea of Anjular an JS element, When i tried using getText() it is returning empty text and if i used ng-model Html code of Element I want to get text: <textarea ng-model="event.additionalInfo" maxlength="255" rows="1" md-no-autogrow="false" md-no-resize="false" data-ng-disabled="eventNotEditable" class="ng-valid md-input ng-valid-maxlength ng-dirty ng-valid-parse ng-touched ng-not-empty" id="input_30" aria-invalid="false" style=""></textarea> How I'am trying: WebElement element= driver.findElement(By.id("input_30")); String s = RandomStringUtils.randomAlphanumeric(256); element.sendKeys(s); Thread.sleep(2000); System.out.println(element.getText()); If there is any best way please let me know, Thanks in advance for any help
Sorry for not being clear in my Question, This Post solved my Problem How to getText() from the input field of an angularjs Application Actually input element contains their value in value attribute, So you should try as below :- List<WebElement> values = driver.findElements(By.xpath("//input[@ng-model='controller.model.value']")); for(WebElement el : values) { String theTextIWant = el.getAttribute("value"); System.out.println(theTextIWant); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "selenium webdriver, cucumber java" }
Fixed Layout Banner Image I want to insert a banner image in a content editor, is it possible to have this image resize based on the size of the respective user's screen? Any help is appreciated
Usually you can have the image relative to the screen page. Just use the content editor to also insert a tag to allow that image to be 100% width, display block, and set a max-height, then it should shrink based on the browser's size or resolution. <style> .imgbanner { display: block; max-height:95px; width: 100%; height: auto; } </style> <img class="imgbanner" src=" />
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 0, "tags": "2010, page layout, image, image display" }
"Destination Path Too Long" when moving an AndroidStudio project I have recently started to learn on Android application programming using Android Studio. I have my recent projects in `C:/`. However, every time I want to copy or move these projects into another folder, Windows complains that the destination path is too long (the folders name are `color` and `drawable`). So, how can I move these folder from `C:/` to somewhere else?
I fixed this problem by moving the project via AndroidStudio Refactoring. 1. Open the project that you want to move. 2. Change to _Project_ view. 3. From there you can Refactor, Move your project to your desired directory. AndroidStudio will take care of this path to long problem.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "windows, path" }
Application Debugging is disabled in Visual Studio 2012 on Classic ASP Debugging I'd like to debug `Classic ASP` website at `Visual Studio 2012` with `IIS Express`. Hence, I attached the `iisexpress.exe` in `VS 2012`, but it shows `Application Debugging is disabled`. What could be a problem ? Do I want to enable any configuration settings? !enter image description here
I don't have visual studio 2012 to test it on as far as I know visual studio cannot debug asp classic code natively. The way I debug my asp classic code is to put in stop statements on the line above the one I want to debug like this post says. the break point is just typing in stop. function DoDate(inp) stop if isnull(inp) then DoDate = "Never" exit function end if In the above example the page when loaded will stop at the breakpoint and pop up a dialog asking if you would like to debug it, you can then step through the function and even see variables like you normally would. note: The link says visual studio 2005 but it also works in 2010(and should also work in 2012), you also do not need the DEBUG extension. also ensure you have server side debugging activated in IIS or this will not work.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 7, "tags": "debugging, visual studio 2012, asp classic, iis express" }
Opening a numbered file in c The issue I am having is simply opening a file which has a number based on an input. Example included: int main(int argc, char *argv[]) { int argument = atoi(argv[1]); FILE *fp; fp = fopen("/folder/item'argument'file", "r"); //do stuff to the file } Example passing 4 will open the file called "item4file" for use How would I address this? Sincere thanks for any and all help
int argument = atoi(argv[1]); FILE *fp; char address[50]; // choose the size that suits your needs sprintf (address, "/folder/item%dfile", argument); fp = fopen(address, "r"); As you can read from the reference, a terminating null character is automatically appended to the string. If you want to **avoid buffer overflows** , however, you should use `snprintf` (which is shown in the same reference page as above), declaring the maximum size of the buffer so that the input doesn't overflow it. int argument = atoi(argv[1]); FILE *fp; char address[50]; // choose the size that suits your needs snprintf (address, 49, "/folder/item%dfile", argument); // 49 since we need one index for our null terminating character
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "c, file, char, fopen" }
Display posts using post ID's in an array I currently have an array of post ID's stored as **$recenty_viewed** that looks like this: Array ( [0] => 3164 [1] => 3165 [2] => 3168 [3] => 3176 ) I'd like to display each post thumbnail and title using the ID's above, but I can't seem to figure out how to get the data from each post. Any idea?
Get post thumbnail by id = get_the_post_thumbnail($id); Get the title by id = get_the_title($id);
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "php, functions, array" }
Issues with social login with vuejs and django-rest-auth I am working with APIs for the first time and was looking at how to set up social app authentication for the project. I have `django-rest-auth` set up for the backend that basically uses the django allauth framework. So when I pass an access token to the backend using the API view, it works. Now that I have moved to vuejs for the front end, I am absolutely clueless on how to make it work with my API. Any help would be greatly appreciated. I'm a total beginner for vuejs and have been working on django framework for a bit more than a month. Thanks in advance! My URL settings in VueJS: ![my url settings in vuejs based on a tutorial]( The error I get is: ![The error I get](
Cross origin content is blocked by same origin policy. Use < to allow cross origin access. If you are interested in details <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "django, vue.js" }
Group By - How to retrieve an associated field? Expected result of the here below SELECT statement: ('2015-01-15',110,'John') Here below some code to help me out... DECLARE @MyTableVar table( arrival_date date, nb_sales int, name varchar(255) ) insert into @MyTableVar values ('2015-01-15',121,'James'), ('2015-01-15',110,'John') select arrival_date, MIN(nb_sales) as nb_sales, name <<-- What should I put knowing I can't put MIN or MAX ? from @MyTableVar group by arrival_date
You could use windowed function: ;WITH cte AS ( SELECT *, r = ROW_NUMBER() OVER(PARTITION BY arrival_date ORDER BY nb_sales) FROM @MyTableVar ) SELECT arrival_date, nb_sales, name FROM cte WHERE r = 1; `**`LiveDemo`**` If ties are possible and you want both of them use `RANK()` instead of `ROW_NUMBER()`
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "sql, sql server, tsql, greatest n per group" }
JMeter: the same UUID between several samplers How can a Jmeter thread group with several HTTP requests uses the same UUID value per thread? I've tried to create 'user defined variables' element with `${__UUID}` and java preprocessor with `vars.put("uuid", UUID.randomUUID().toString())`; (independently) ![thread group]( but every http request in the same thread using its own UUID.
Move the java PreProcessor as the **child** of the first HTTP Request(start session) and then call it as `${uuid}` in all requests to get only one UUID value. Another option is without code: Add User Parameters as PreProcessor of the first HTTP Request(start session) with Name as `uuid2` and Value `${__UUID()}` and you can use `${uuid2}` to get only one UUID value.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 5, "tags": "random, jmeter, uuid" }
Is it possible to attach commands to a programme I want to run? UBUNTU 20.04 I have PCSX2 but in order for it to run correctly I need to open the terminal and run: vblank_mode=0 /usr/games/PCSX2-linux.sh having to do this every time is a bit of an annoyance so is it possible to attach this command to PCSX2 so when it runs it automatically applies this fix? PS: brand new to ubuntu so apologies if this is a stupid question.
There are a few ways of doing it. For instance you can edit the `PCSX2-linux.sh` file and add there export vblank_mode=0 after the shebang. The first 2 lines should look this way: #!/bin/sh export vblank_mode=0 Another way is to add `vblank_mode=0` to the `Exec=` line of the `.desktop` file.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 1, "tags": "command line, gnome terminal, execute command, pcsx2" }
iOS - Push segue incorrectly coming from bottom I have a push Segue with identifier "LoginSegue" that is meant to transition from "Login View Controller" to "View Controller." Here is my storyboard: ![storyboard]( and here is the Segue: ![segue]( After a user successfully logs in, I call the following from within the LoginViewController: performSegueWithIdentifier("LoginSegue", sender: self) in order to transition from the "Login View Controller" to the "View Controller." I would expect this transition to occur from right-to-left as it is a Push segue, but for some reason it happens from bottom-to-top. How can I correct this behavior?
You dont have **LoginViewController** in the navigationController. If you push another viewcontroller in any viewcontroller which is not inside navigationController it will present modally. You might have set **LoginViewController** as a rootViewController of a **window** programitically or make sure navigationController is initialViewController not the **LoginViewController** in storyboard. You can always check if any view controller is in navigationController or not by simply: `print(self.navigationController)` inside viewDidLoad method of view controller.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "ios, iphone, swift, storyboard, segue" }
Python Request.Post to API not working I am trying to send a simple POST to an api. import requests url =" payload = {'username': '', 'password': ''} s1 = requests.post(url, headers={"content-type":"application/x-www-form-urlencoded"}, data=json.dumps(payload)) print s1.status_code I keep getting status code 401. Same steps Works fine in POSTMAN. ![enter image description here]( ![enter image description here]( Any Ideas/pointers ?
Post data in raw format. payload = "username=;password=;" s1 = requests.post( url, headers={"content-type":"application/x-www-form-urlencoded"}, data=payload) **FWIW,** you can click on _Code_ below the _Save_ button on the top right corner of Postman to view code in a couple of languages for your request.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, python requests" }
convert a key value object to a single array I need to convert a object {score: 77, id: 166} to an array, [77,166] I tried, Object.keys(obj).map((key) => [obj[key]]); but seems like, it returns as 2 arrays. [[77][166]]
You just had an extra pair of square brackets in your code const obj = {score: 77, id: 166}; const result = Object.keys(obj).map((key) => obj[key]); console.log(result)
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "javascript" }
How to ensure only one file is returned by checking for newline What is the _simplest_ way to check if a string contains newline? For example, after FILE=$(find . -name "pattern_*.sh") I'd like to check for newline to ensure only one file matched.
To refer to your example: Note that filenames could contain newlines, too. A safe way to count files would be find -name "pattern_*.sh" -printf '\n' | wc -c This avoids printing the filename and prints only a newline instead.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 10, "tags": "bash, unix, newline" }
How to find out the location of a failed assert? (Calling debug-build DLL in Unity) Writing a C++ DLL to use from Unity3D. If I build the DLL as release, I currently get some undefined behavior nonsense. If building as debug build, the following popup shows: ![enter image description here]( Unfortunately the error redirects into the vector class and not the place where it is actually used in my own code. I know what DLL function causes this, but I cannot find out why this happens because there is a lot of vector handling. I do suspect some multithreading issue. However how do I find out which particular line, aka which assert failed? I do not seem to be able to catch asserts with the try-catch block. Huge thanks in advance :)
Turns out it is possible to debug the Unity editor as a whole with attached DLLs. 1. Find out where the actual editor is (in the rightclick menu of the installs tab in Unity Hub) 2. Open that EXE with Visual Studio (literally the "Open project" selection) 3. Go to the solutions properties -> parameters and add: -projectPath "PATH_TO_YOUR_UNITY_PROJECT_DIRECTORY" 4. Debug -> Start Debugging (or F5) 5. If you get an assertion etc. click "Retry". Step 3 is important because for whatever reason, Unity does not show the "open a project" option if started as debug and just closes itself instead. That's what made me think that external debugging is not supported.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c++, unity3d, vector, assert" }
PHPExcel how to use data from reader I'm trying to understand how to get data from cells in PHPExcel but I have no idea. I read all documentation and I made this: <?php include('PHPExcel/Classes/PHPExcel/Reader/Excel2007.php'); class MyReadFilter implements PHPExcel_Reader_IReadFilter { public function readCell($column, $row, $worksheetName = '') { // Read title row and rows 20 - 30 if ($row == 1 || ($row >= 20 && $row <= 30)) { return true; } return false; } } $objReader = new PHPExcel_Reader_Excel2007(); $objReader->setReadFilter( new MyReadFilter() ); $objReader->setReadDataOnly(true); $objPHPExcel = $objReader->load("sample_mymails222.xlsx"); print_r($objPHPExcel); ?> print_r show very big array. I think there is some functions to get data from cell in $objPHPExcel. How to do it? Thanx!
Please read the documentation chapter 4.5 (included in the PHPExcel download package)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "php, phpexcel" }
A simple sql query question suppose I have a table like this: table1: name favorite_music a country b rock a jazz b jazz How can I do this query: find the names whose favorite_music style has _both_ "country" _and_ "jazz". For the example above, it should be only "a".
This should get them: select name from table1 where favorite_music = 'country' intersect select name from table1 where favorite_music = 'jazz' **EDIT** : The question is not very clear. The query above will return every name thas has both jazz and country as favorite music styles (in your example table, name='a') **EDIT 2** : Just for fun, one example that should do it with one single scan, using a subquery: select name from ( select name, count(case when favorite_music = 'country' then 1 end) as likes_country, count(case when favorite_music = 'jazz' then 1 end) as likes_jazz, from table1 where favorite_music in ('country', 'jazz') group by name ) where likes_country > 0 and likes_jazz > 0
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "sql" }
Does the expression "stall speed" have a definition? I read, not only on this site, that the _stall speed_ of an airfoil doesn't exist, and I usually make the effort to stay away from this expression. While an airfoil can stall at any airspeed, it's clear that the stall speed refers to the airspeed at which the stall occurs in an horizontal 1G flight. ![enter image description here]( Stall speeds for B747-200 (n=1). (Source). This speed is the lowest one that can generate a vertical component of lift equal to the weight with the airfoil at its stall angle of attack. I would compare this implicit assumption with the maximum airspeed of an aircraft: It's clear we are assuming at least an horizontal flight and a standard atmosphere, etc, else this speed can be anything too. So what's wrong with this definition of the "stall speed"? Is the stall speed defined in the aerodynamics field? Example of use: Stall Speed (Dr. Mustafa Cavcar).
'Stall speed' is defined only with respect to the aircraft as it is the case where it has a physical meaning. We define stall as the point where the airfoil or wing stops producing the necessary lift due to flow separation (This is an extremely simple definition, which will suffice for now), i.e where the lift coefficient is maximum. For aircraft, the stall speed is given as where the wing reaches the max. lift coefficient. Basically, we are using the stall speed because it is directly available to the pilot i.e. it is a derived quantity, based on the angle of attack, configuration etc. among others. On by itself, the value has no meaning, as you pointed it out yourself. Now, coming to the airfoil, the same (or similar) definition cannot be used as there is no way of saying lift equals weight due to the nature of airfoil itself. Thus, the stall speed is a performance term, not an aerodynamic one.
stackexchange-aviation
{ "answer_score": 4, "question_score": 6, "tags": "aerodynamics, terminology, stall" }
Нужно в цикле for сгенерировать 4 названия функций в PHP Добрый вечер, друзья. Нужна помощь. Мне нужно внутри цикла for в PHP выводить function, в названии которых будут сгенерированные числа-дополнения. То есть мне нужно сделать что-то вроде этого: for ( $i = 1; $i <= 4; $i++ ) { function block_content_$i (){ // func body } } Этот код должен выдать в итоге такое: function block_content_1() { // func body } function block_content_2() { // func body } function block_content_3() { // func body } function block_content_4() { // func body } Естественно, это не работает. Помогите, разобраться. Заранее, спасибо!
Непонятно, зачем вам куча одинаковых функций, но можно вот так: for ( $i = 1; $i <= 4; $i++ ) { ${"block_content_$i"} = function () use ($i) { echo $i; }; } $block_content_1(); // 1 * * * Без переменных я вижу лишь один путь, который не должен быть упомянут) for ( $i = 1; $i <= 4; $i++ ) { $func = "function block_content_$i(){}"; eval($func); }
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php" }
Android - Change UTC time to local time I am getting from a service - Date object that contains an UTC time zone date. How can i change it to the current phone time zone?
Something like this: SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a"); Date getDateTime = fmt.parse(utcDateAndTime); fmt.setTimeZone(TimeZone.getDefault()); String getLocalDateTime = fmt.format(getDateTime); System.out.println("Local date/time: " + getLocalDateTime);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "android" }
If condition for ?? operator on null object I have the following `string` list: List<string> Emails = new List<string>(); Trying to see if it has any values, or return an empty string: string Email = Emails[0] ?? ""; The above code throws an exception: > Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index But changing the `??` operator to a simple `if` statement, it works fine: if (Emails.Count > 0) Email = Emails[0]; else Email = ""; What am I missing here? When the list is empty, should `Emails[0]` not be `null` ? Thanks.
I suggest to change it to: string Email = Emails.FirstOrDefault() ?? ""; If your list is empty, `Emails[0]` is not null, it just doesn't exist. **Edit** : that works for strings and ref types, if you do have a value type, for example int, you will get default(int) that is 0 as result of FirstOrDefault of empty collection
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 3, "tags": "c#, .net, null" }
Center group of images not working ( classes ) No matter what I have tried - I can not seem to get a group of images to center on my page. Anyone have any thoughts? This is wracking my brain. breakwatersurf.com is where the uncentered images are. You will see the shop mens and shop womens don't line up with the bottom divider lines. Stack overflow doesn't like my code and wont allow me to use code tags so please inspect the elements on my webpage for html / css I Have tried so many variations of css without any luck. I know the answer is simple but I can't seem to find out why my won't center anywhere. Thanks for the help!
Give to the shop womens image a `float: right` style in your **CSS**. I did this with the element inspector and it works: <img class="groupcenter" src=" alt="righthalf" width="565" height="500" style="float:right"> !enter image description here And learn how to use the site. People here don't like to help if you don't follow the site rules.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "html, css, wordpress" }
Redirecting Joomla Links to New ExpressionEngine Links Fails I'm running into an issue where 301 redirects on site I switched from Joomla to EE are not working. The link style on the old version of the site is: For the redirect, I'm using this line in the .htaccess: `Redirect 301 /index.php?option=com_user&view=reset&Itemid=14 /contact` Since index.php is valid with EE, my assumption is the issue revolves around the query string since a more basic redirect works as indended: `Redirect 301 /about /` routes traffic from the about page to the home page. How can I redirect these links to the new ExpressionEngine-powered pages or, if the issue is more generic, links containing "index.php?"?
You need to use **%{QUERY_STRING}** RewriteCond %{QUERY_STRING} ^option=com_user&view=reset&Itemid=14$ RewriteRule ^(.*) /contact? [L,R=301]
stackexchange-expressionengine
{ "answer_score": 3, "question_score": 2, "tags": "redirects, redirection" }
Can a SELECT performed with READ COMMITTED trigger an exception in Postgresql? I need to take a snapshot (SELECT) of some table rows for display. These rows will never be modified or deleted in that same transaction, or transmitted to another transaction which could modify those rows. I only want a simple snapshot-like read in a Postgresql function. For example: SELECT * FROM "my_table" WHERE "amount" < 1000; I was thinking about setting the READ COMMITTED transaction level in my Postgresql function: SET TRANSACTION ISOLATION LEVEL READ COMMITTED; Will this make sure I won't ever face an exception with my SELECT, no matter if other heavy and complex transactions are running simultaneously? I believe that yes, but I am not a Postgresql expert. **UPDATE:** After doing more reading, I am wondering whether this could to the trick too? SET TRANSACTION ISOLATION LEVEL READ ONLY DEFERRABLE
Using Daniel's information, if I perform the following to create the table and to fill it: CREATE TABLE IF NOT EXISTS "my_table" (amount integer); TRUNCATE "my_table"; INSERT INTO "my_table" VALUES (100); INSERT INTO "my_table" VALUES (200); INSERT INTO "my_table" VALUES (1000); INSERT INTO "my_table" VALUES (2000); CREATE OR REPLACE FUNCTION my_function() RETURNS SETOF "my_table" AS $$ BEGIN RETURN QUERY SELECT * FROM "my_table" WHERE "amount" < 1000; END; $$ LANGUAGE plpgsql; I can set an transaction level on the client's side to retrieve the rows I want with the isolation I want (though this might be redundant in my case for a simple SELECT): SET TRANSACTION ISOLATION LEVEL READ ONLY DEFERRABLE; SELECT * FROM my_function();
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "postgresql, select, read committed snapshot" }
column to be hidden while creating list item but visible while editing the list item in sharepoint 2007 for a sharepoint list . i want a column to be not visible when creating new item of the list , but it should be visible when the item is edited . How can i do this ? any help appreciated.
You should just set ShowInNewForm to FALSE If you're creating the list using CAML then just add ShowInNewForm="FALSE" to the element for the field If you're using the UI to create the field then you can use the object model or SharePoint Manager to change the ShowInNewForm property of the field
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sharepoint" }
What edge-set is required to make a non-cyclic directed disconnected graph initial? Is there an algorithm to find the minimum set of edges required from a new node in order to make a disconnected directed graph initial? Example - input: a -> b; b -> c; b -> d; e -> f; f -> g; !input output: n -> a; n -> e; !output Result: !result Thanks!
Assuming that "initial" means connected and having a single source, you can do no better than adding an edge to each source.
stackexchange-cs
{ "answer_score": 0, "question_score": 0, "tags": "graphs" }
Objective-C Swift interoperability with Realm I'm adding new functionality to an app written in Objective-C with Swift. The new features require a data base so I'm using Realm-Swift. The problem is that the models that have relationships e.g. `dynamic var points = List<Point>()` don't translate to Objective-C on the `{Project}-Swift.h` file. I get the error: `Type name requires a specifier or qualifier` on the line `@property (nonatomic) /* List<Point> */ points;` Does anybody know a workaround for this problem?
If you need Objective-C interop, your best bet is to continue using Realm Objective-c. Since `List` is a generic type, it can't be represented in ObjC at all.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ios, swift, realm" }
How to add text at the start of each paragraph (e.g. a paragraph mark) I want to add a mark (e.g. `X` or `¶`) at the start of each paragraph which is inside a custom environment. MWE: \documentclass{memoir} \newcommand{\sometext}{ This is some text This is some text in a new paragraph. This is even more text in yet another new paragraph } \newenvironment{paragraphmarked}{% % Magic command goes here? }{% % Maybe reset paragraph behaviour here? } \begin{document} \begin{paragraphmarked} \sometext \end{paragraphmarked} \end{document} ## What I currently see: ![What I currently see]( ## What I would like to have ![What I want to see]( * * * I tried doing \let\oldpar\par \let\par{\par X} % Text goes here \let\par\oldpar But this resulted in TeX running out of memory in my (rather large) document.
There is the TeX command `\everypar{...}` for exactly that purpose: \documentclass{article} \begin{document} \everypar{X} Text Text Text \end{document} By means of a user-defined environment, the scope of `\everypar{}` can be limited: \documentclass{article} \newenvironment{paragraphmarked}[1]{\everypar{#1}}{} \begin{document} \begin{paragraphmarked}{X} Text Text Text \end{paragraphmarked} Text Text Text \end{document}
stackexchange-tex
{ "answer_score": 3, "question_score": 2, "tags": "paragraphs" }
Is there a real widescreen patch for Warcraft 3? Is there a _"real"_ widescreen patch or hack for Warcraft 3 to e.g. allow playing in 16:10/1680x1050? The only solutions I've found (like changing the resolution in the registry) give me either 4:3 with black bars or stretch to 16:10.
No, there is no way to play it in widescreen with the correct aspect ratio.
stackexchange-gaming
{ "answer_score": 5, "question_score": 6, "tags": "warcraft 3" }
Environment font size is too small So I've chosen a font by System Settings -> Application Appearance -> Fonts And there I've adjusted all fonts to be of 14th size. And also checked "Use my KDE fonts..." in Gtk+ appearance. I've also did the same using kdesudo systemsettings But still some fonts are tiny! It's not the 14th size! !enter image description here **Edit 2** : I thought it might be one of Gnome font settings. So I've increased all fonts in gnome-tweak-tool sudo gnome-tweak-tool gconf-editor sudo gconf-editor No help! **Edit** : Ubuntu tweak also gives no help (note the tiny fonts!): !enter image description here **Edit** : It looks like the problem is with gtk3: when I compile emacs 24.0.92 with gtk3 - i get small menu fonts. When I do the same with a default gtk2 - everything is all right.
The problem is resolved by installing gtk3-engines-oxygen-git gtk2-engines-oxygen-git from here.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 4, "tags": "fonts, kubuntu" }