INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How to use Composer in PHP Google App Engine Can anyone explain how I can get Composer working in Google App Engine (PHP)? I understand what composer is and how it works but I have no idea on how to get it onto my App Engine.
You need to run composer locally, and then upload the entire application that has been build by composer to production using the appcfg command.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "php, google app engine, composer php" }
How to use v-for variable from slot in the parent component? How to solve this error when I try to use variable in `slot` from `v-for` in `Vue.js`? > Property or method "slide" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property This is how I use component: <Slides v-model="slides"> <AnotherComponent v-model="slide.someproperty" /> In `Slides` component I have `v-for`: <div v-for="(slide, index) in value" :key="slide.id"> <comp1 v-model="slide.prop1"></dropper> <slot></slot> </div>
This is exactly what scoped slots are for. For example, in your `Slides` template <slot :slide="slide"></slot> and in the parent... <Slides v-model="slides"> <AnotherComponent slot-scope="{ slide }" v-model="slide.someproperty"/> * * * Note: If using Vue < 2.5, you can only use `slot-scope` on a `<template>` element.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, vue.js, vue component" }
Which real numbers are contained in $\mathbb{Q}(\cos40+i\sin40)$? I have a field extension $\mathbb{Q}(\cos40+i\sin40)$. I would like to find all the real numbers in this field and prove that they form a subfield (S) and find $|S:\mathbb{Q}|$. And also calculate the splitting field of S. I know that $\mathbb{Q}(\cos40) \leq \mathbb{Q}(\cos40+i\sin40) = \mathbb{Q}(\cos40, i\sin40)$. And that $|\mathbb{Q}(\cos40):\mathbb{Q}|=3$. And $\mathbb{Q}(\cos40)$ only contains real numbers. ($\cos40+i\sin40$ is a primitive 9th root of unity) My assumption is that S = $\mathbb{Q}(\cos40+\sin40)$. I have to show that $\cos40+\sin40$ could be written with the help of elements from $\mathbb{Q}(\cos40+i\sin40)$. I believe I could calculate these in question if I knew $S$. I would be grateful if you could help me.
In their series of comments, @diracdeltafunk seems to have led you almost all the way to the full answering of your questions. To cut to the chase, your number, call it $\zeta$, is a primitive ninth root of unity, and thus is a root of the _Cyclotomic Polynomial_ $\Phi(X)=X^6+X^3+1$, known to be irreducible. If we set $\xi=\zeta+\zeta^{-1}=\zeta+\overline\zeta$, then it’s not at all hard to see that the minimal polynomial of $\xi$ is $X^3-3X+1$. The Galois group of $\Bbb Q(\zeta)$ over $\Bbb Q$ is isomorphic to $(\Bbb Z/9\Bbb Z)^\times$, a cyclic group generated by $5$. Since a cyclic group has just one subgroup of each possible order, there are only the two proper subfields of $\Bbb Q(\zeta)$, the quadratic field generated by the cube roots of unity (it’s imaginary) and the other, generated by $\xi=2\cos(40^\circ)$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "abstract algebra, field theory, extension field, roots of unity, splitting field" }
Why 'sort{$a-$b}(list of floats)' doesn't work in Perl? $, = ' '; print sort {$a-$b} qw/1.5 2.5 2 1/; Produces `1.5 1 2.5 2`. I know about `<=>`, I just wonder what's going on and if this behavior is documented. Even this doesn't work: $, = ' '; print(sort{(sqrt$a)-(sqrt$b)} qw/1.5 2.5 2 1/); Something to do with `$a` and `$b` magick, as if they are evaluated as strings. OTOH, list of integers is sorted correctly with `-` instead of `<=>`.
From the Perl documentation > If SUBNAME is specified, it gives the name of a subroutine that returns an **integer** less than, equal to, or greater than 0 , depending on how the elements of the list are to be ordered. If you use `-` with `floats`, it returns a `float` result, not an `integer` as required by the above.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 0, "tags": "perl, sorting" }
Laravel custom controller not found when changing the controller directory When changing the controller directory location like so: Route::group([ 'prefix' => 'report', 'middleware' => 'auth', ], function() { Route::get('/summary','IOS\ReportController@index'); }); It returns an error message: Error Class 'App\Http\Controllers\IOS\Controller' not found But it's working perfectly the below way: Route::group([ 'prefix' => 'report', 'middleware' => 'auth', ], function() { Route::get('/summary','ReportController@index'); }); After changing directory location, i try to `composer dump-autoload` but it's still getting error.
every `Controller` on laravel should `extends` the base laravel `Controller` the base controller is in this path: `App\Http\Controllers` so when you create a controller on another folder, the created controller wants to extend from the base controller but can not find it in folder so you should do this on `ReportController` namespace App\Http\Controllers\IOS; //namespace of your controller use App\Http\Controllers\Controller; //the path of base Controller class ReportController extends Controller //your controller extends from base controller
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "laravel controller" }
gem install with archflag and version mysql2 frustrated. Is this wrong? env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 --version '0.2.6' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config want to install 0.2.6 Why the hell it keeps installing 0.3.2????
env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 --version '=0.2.6' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config note the > \--version '=0.2.6'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ruby, mysql2" }
Freedom of speech and the N-word Is it true that in US you can be jailed if you will say the N-word to some black person? Because I heard some stories from some people and I really doubt but still I really not know much about the U.S. laws (and about it's states laws, of course).
No, it's not technically true. Though going up to a person and insulting them might be considered threatening or menacing behavior, precipitating into a conflict. You can't pick a fight with somebody and then claim free speech, especially if you choose fighting words. And verbally assaulting people on private property is going to be handled by the property owner (e.g. kicked out by security guards). However, it's incredibly disrespectful and rude. It may result in the loss of jobs and even friends. But it is not akin to Holocaust denial in Europe or blasphemy in the Middle East. You are free to say the word, privately or publicly, without fear of arrest (or at least the First Amendment ought to have protected your expression). But you can't incite a brawl with a racial slur and point to the First Amendment.
stackexchange-politics
{ "answer_score": 16, "question_score": 1, "tags": "united states, law, freedom of speech" }
Why does my PC sometimes think I am constantly pressing the control key? I was browsing the web with Chrome and pressed f. A search box appeared. I then pressed s, after which Chrome asked if I wanted to save the web page. I soon realized that my PC was thinking that I was constantly pressing the `Ctrl` key regardless of what program I was using. In response, I tried clicking both of my `Ctrl` keys a few times to no avail. This problem arises sporadically as I work. I am not sure what is triggering it. Why could this problem be occurring? Is it the keyboard or software? How should I respond?
This could be caused by the 'Sticky Keys' function (an accessibility option). If you are on Windows 7, click on the start button go to Control Panel, ease of access, change how your keyboard works. Under the option 'Make it easier to type', uncheck 'Turn on Sticky keys' and see if this solves your problem.
stackexchange-superuser
{ "answer_score": 8, "question_score": 13, "tags": "keyboard" }
Unable to Create ORACLE-ODBC DSN on Window 7 64 bit using SysWow64/odbcad32.exe I am trying to create a DSN but I can't do it. The processes I am applying these are as follows: 1\. Oracle 12c (64bit) Installed in Remote PC 2\. Using Oracle 12c Client on Windows 7 64 bit 3\. Trying to Create DSN from Syswow64/odbcad32.exe becuase I want to use this DSN from my Excel 2013 VBA program and the office is 32 bit. 3\. After pressing the Add button on the Microsoft ODBC Administrator from Syswow64/odbcad32.exe, I don't find the Oracle In OracleClient12Home2 in the driver list. Please suggest me what should I do in this regard.
I have solved this. Basically due to security reason, my registry was not configured properly at the time of installation. I have removed my previous installation and Set new ORACLE_HOME and run install As Run As Administrator. After that the problem is solved.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "excel, odbc, vba" }
Importing template file in JavaScript by using smarty Hi guys i want to import my script template with JavaScript by using smarty but this my code not work and i have an error can some one tell my how i can do that in true way? Thank you. JS: var tpl = {include file="myscript.tpl"}; $('.plus').html(tpl); ERROR: Uncaught SyntaxError: Unexpected identifier in var tpl = {include file="myscript.tpl"};
Your Javascript is probably within literal tag, so what you need to do is: {literal} <script> .... var tpl = '{/literal}{include file="myscript.tpl"}{literal}'; /* it will be a string */ .... </script> {/literal} This topic may also help you.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, smarty" }
Rails / Scope search on joined table Attempt to setup a lightweight search engine, having no problems setting up scopes on the model with it's own attributes. Having some roadblocks on getting a joined table to play nice scope :seniority, -> (seniority) { where seniority: seniority } # merged scopes scope :edu, -> joins(:candidate_schools).where("candidate_schools.degree = #{edu}") } Seniority works fine as it is a normal attribute. My ultimate goal is to render user objects back from an associate table such as Where passing params for "edu", would be searching the "candidate_schools" table and filtering based on the "degree" attribute, if the edu params match a record it would process a "user" object
Change your scope to this: scope :edu, -> (edu) { joins(:candidate_schools).where("candidate_schools.degree = ?", edu) } # usage User.seniority("jr").edu("master") Don't do `"candidate_schools.degree = #{edu}"`, look into sql injection for why.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails, search, activerecord, scope" }
Reason for white lines in tile-based game ![enter image description here]( My game is tile-based. I am getting this lines between two tiles. They don't look nice. How can i resolve this issue?
These lines are caused by the interpolation in the texture sampler which samples texels from adjacent tiles in your tile atlas. Both bilinear and trilinear (mipmaps) interpolation (and some rounding errors within the GPU) will cause this. You need to add a border to your tiles consisting of N repeating pixels from your tiles on all sides & corners. For example: ![enter image description here]( Where N is 2 to the power of (mipmap levels). So if you want 3 mipmap levels you need to add a border of 8 pixels (1 << 3) all around your tiles in your atlas to ensure the texture sample will not sample texels from adjacent tiles. You also need to limit the mipmap level by calling `glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_mipmap_level);` The first level is 0, level 1 is (width/2, height/2), level 2 is (width/4, height/4), and so on.
stackexchange-gamedev
{ "answer_score": 5, "question_score": 0, "tags": "opengl, c++, tilemap" }
MySQL query equivalent of "AND", whereas "IN" is "OR"? I'm trying to find a query that selects every row of an associative table where the second column indicates different values that must all be matched with the first column's. Example: I have column X and Y. I want to get the values of X where X is defined with every Y specified. x y ====== a 1 a 2 b 1 a 3 c 2 c 3 `SELECT DISTINCT x FROM table WHERE y AND (2, 3)` This query of course isn't valid. I would expect to get `a` and `c` somehow. As I'm also trying to learn MySQL queries better, I would appreciate if you could give an explanation of the logic behind your answer if you can provide one. Thanks! :)
I hope this is what you're looking for. If you confirm it,I'll explain you the query. select x from table where y in (2,3) group by x having count(distinct(y)) = 2
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 5, "tags": "mysql, sql" }
DateFormat problem in pocket pc emulator While converting a date value in a datatable such as "4/20/2011 7:10:39 PM" into a string by using ToString(),it becomes 4/20/11.How can i solve that problem?I want it as 4/20/2011.I am using Pocket Pc application in .net 2008 and using windows ce 5.0 emulator.
Most actions on `DateTime` are supported by the .NET Compact Framework: < You could use one of the built in ones, or one of the overrides of `ToString` and specify your own formatting arguments: < The default action of `ToString` on `DateTime` takes into account the current culture of the process. Try: `DateTime.Now.ToString("d/MM/yyyy");`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": ".net, windows mobile, pocketpc" }
Strange format of interval value returned by PostgreSQL I have PostgreSQL 9.5.0 and I observe strange interval values returned by very similar queries. I thought that then interval is bigger than 24 hours then it is returned with `days` part like this: SELECT (1000 * ('2016-02-04 12:00:11'::timestamp - '2016-02-03 12:00:00'::timestamp)::interval)::interval 1000 days 03:03:20 But sometimes hours are not converted to days: SELECT (1000 * ('2016-02-04 11:00:11'::timestamp - '2016-02-03 12:00:00'::timestamp)::interval)::interval 23003:03:20 How can I force the same output format with days part?
Use `justify_hours()`: SELECT justify_hours(1000 * ('2016-02-04 11:00:11'::timestamp - '2016-02-03 12:00:00')) justify_hours ------------------- 958 days 11:03:20 (1 row) or `justify_interval()`: SELECT justify_interval(1000 * ('2016-02-04 11:00:11'::timestamp - '2016-02-03 12:00:00')) justify_interval --------------------------------- 2 years 7 mons 28 days 11:03:20 (1 row) See also: Why postgres show two different format for same interval value?
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "sql, postgresql, time, intervals" }
bad operand types for binary operator & I am trying to print even and then odd using bitwise & operator, but don't why it is not working with ternary operator. class Geeks { static void evenOdd (int a,int b) { int e = (a&1==0)?a:b;// error: bad operand types for binary operator '&' System.out.println(e); int o = (a&1==1)?a:b;// error: bad operand types for binary operator '&' System.out.print(o); } }
It's due to the precedence of operators being used. Since == has higher precedence than &, 1==0 is evaluated. It evaluates to a boolean result. Since & is getting 2 operands - one boolean and one integer. It results in the compilation error as & can be performed on alike types. It is the same reason why multiplication is performed before addition(known as BODMAS) Parenthesis has to be used in such cases : System.out.println(e); int o = ((a&1)==1)?a:b; System.out.print(o);
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "java, bitwise operators, ternary" }
Regex add leading zeros to DD.MM.YYYY string I was sure something like this had been answered before in some manner however I only managed to find reveresed versions like MM/DD/YYYY etc or special characters like / - and had little luck converting them as my regex knowledge is terrible. The closest thread I found was this I am struggling to find a clean approach using regex and javascript to add trailing zeros to the below string format? dd.mm.yyyy Eg 1.1.1998 => 01.01.1998 || 10.1.1998 => 10.01.1998 my current approach is along the lines of const addLeadingZeros = (input: string) => { return input.replace(/.([1-9])(?!\d)/g, '.0$1'); }
How about: input.replace(/(?<=^|\.)(\d)(?=\.|$)/g, '0$1'); It means: "replace all digits preceded by the beginning of a line or a dot _and_ followed by a dot or the end of the line". This example works only for day and month parts. Example (browser console outputs): "01.01.1998".replace(/(?<=^|\.)(\d)(?=\.|$)/g, '0$1'); ← "01.01.1998" "1.01.1998".replace(/(?<=^|\.)(\d)(?=\.|$)/g, '0$1'); ← "01.01.1998" "1.1.1998".replace(/(?<=^|\.)(\d)(?=\.|$)/g, '0$1'); ← "01.01.1998" _( **Note:** this is not a solution I particularly recommend, I just focused on the asked point.)_
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript, regex" }
Migration from AWS Aurora to a local Postgres 9.6 database I am considering using AWS Aurora, however I am concerned for being locked into AWS indefinitely. So I am wondering how difficult it would be to transfer data from Aurora to my own Postgres database. Thanks!
This is a very valid concern. Firstly, there is no seamless migration like there is from Postgres to Aurora. Following, needs to be considered: 1. How to do it: You will have to take a dump of your aurora db and then import it into postgres. 2. Because of 1 above; you cannot have concurrent CURD operations running on your aurora during migration. Hence, you need to shut down all products connecting to your aurora till you migrate to Postgres. Hence, there will be downtime. 3. Because of 2 ; Depending on size of your DB; it might take few mins ( few GB of data ) to many hours if you have huge DB. Hence, you need to consider how much data you have and how much downtime you can live with if you want to migrate back to Postgres.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "postgresql, amazon web services, amazon aurora" }
Python - \n appearing in concatenated strings I've been having an issue with my Python code. I am trying to concatenate the value of two string objects, but when I run the code it keeps printing a '\n' between the two strings. My code: while i < len(valList): curVal = valList[i] print(curVal) markupConstant = 'markup.txt' markupFileName = curVal + markupConstant markupFile = open(markupFileName) Now when I run this, it gives me this error: `OSError: [Errno 22] Invalid argument: 'cornWhiteTrimmed\nmarkup.txt'` See that \n between the two strings? I've dissected the code a bit by printing each string individually, and neither one contains a \n on its own. Any ideas as to what I'm doing wrong? Thanks in advance!
The concatenation itself doesn't add the `\n` for sure. `valList` is probably the result of calling `readlines()` on a file object, so each element in it will have a trailing `\n`. Call `strip` on each element before using it: while i < len(valList): curVal = valList[i].strip() print(curVal) markupConstant = 'markup.txt' markupFileName = curVal + markupConstant markupFile = open(markupFileName)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "python, string, concatenation" }
How to implement flatten as an extension on an Array without type casting? extension Array { func flatten<T>() -> T[] { let xs = (self as Any) as Array<Array<T>> return xs.reduce(T[](), +) } } It works, but I'm not sure if all those casts are required. Is there a better way? For comparison, here is the implementation in one of the swift extension libraries. I'm not sure if they have it all figured out too -- their implementation begins with the following comment: > // There's still some work to do here
You can't extend a specific type of a generic type in Swift: extension Array<Int> { } > > error: non-nominal type 'Array' cannot be extended But you can write a function that takes a specific type of array. If you want to flatten an array of arrays (`Array<T[]>`, `T[][]` or Array>) your functions signature would look like this: func flatten<T> (array: Array<T[]>) -> T[] It takes an array of arrays of `T` and returns an array of `T`. You can then use your approach with `reduce`: func flatten<T> (array: Array<T[]>) -> T[] { return array.reduce(T[](), +) }
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "arrays, swift, generics" }
Javascript Promise and Async code I'm struggling to wrap my head around the concept of async and promises in js. I can't figure out why the code below doesn't print anything on my console. I'm assuming it's because the code inside my Promise is not asynchronous, but isn't that the point of a promise: to make something synchronous become asynchronous? If that's not the case, how could I truly "transform" a sync code into async without using any built in js functions (setTimeOut,etc)? function countdown(seconds) { return new Promise(function(resolve, reject) { for (let i = seconds; i >= 0; i--) { if (i > 0) console.log(i + '...'); else resolve(console.log("GO!")); } } }; count = countdown(5).then(() => console.log('Completed'), (err) => console.log(err.message));
> how could I truly "transform" a sync code into async without using any built in js functions (setTimeOut,etc)? **By it's nature, javascript code is synchronous** _(waits for howls of protest to abate)_ ... Every (non-native) function that is asynchronous is due to that function, either 1. directly calling one of those native asynchronous functions, or 2. calling other functions that call functions etc that eventually call one of these asynchronous functions directly the only way to transform some code from synchronous to asynchronous is to use one of the many "native" functions that are asynchronous in nature (again, either directly, or indirectly via other functions that eventually will have to call one of these asynchronous functions directly)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, asynchronous, promise" }
Direct proof for the independence of $\operatorname{Tor}$ It is known that $\operatorname{Tor}$ is independent of the choice of the resolution. More specifically, I am trying to do the exercise 1 (c) of Vick's homology theory. The author gives the definition of free resolution right after proving the right exactness of tensor. That means I need a direct proof of it without a lengthily reference of commutative algebra (which I poorly known). (I copy that page in the book below for the definition and properties.) It is helpful if anyone could also give me some hints about Exercise 1 (b) and 2. !exercise 1\(c\)
For 1 b), the exact sequence $0 \to A \to A \to 0$ is a free resolution of $A$, tensoring by $B$ and taking homology gives you $Tor(A,B)=0$. For 2, use the fact that $\mathbb{Z}$ is a commutative ring, that gives you an isomorphism of abelian groups $A \otimes_{\mathbb{Z}} B = B \otimes_{\mathbb{Z}} A$, for all abelian groups $A$ and $B$. For 1 c), use the fact that if $0 \to C \to B \to A \to 0$ and $0 \to C' \to B' \to A \to 0$ are free resolutions, you can lift the identity $1_A:A \to A$ to a morphism $f:B \to B'$ such that the corresponding diagram commutes, and you may find a morphism $g: C \to C'$ that makes the new diagram commute. For there it is easy to find the required isomorphism. I also recommend you to take a look at commutative algebra basics in order for you to understand better the homological algebra basics.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "abstract algebra, homological algebra" }
CSS: float content next to a table I'm trying to float some content left, with a table to the left-hand side. Here's a JSFiddle: < I'd like the text content that's currently below the table to be to the right of the table. What am I doing wrong? Full CSS for reference: .container { width: 100%; border: 1px solid red; } .table-container { width: 60%; float: left; overflow-x: scroll; overflow-y: none; } table { width: 100%; border: 1px solid #ccc; } #aside { float: left; border: 1px solid blue; }
change it: #aside { float: left; border: 1px solid blue; width:39%; /* this line added */ } < and you can use 40% but if you have border or padding you must use `box-sizing` and it's need `css3`. and `box-sizing` Compatibility here: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "css" }
Java security policy set from code Using this bit of code to try and set a policy file: ClassLoader cl= getClass().getClassLoader(); URL policyURL =cl.getResource("res/policy/new_policy.policy"); System.setProperty("java.security.policy", policyURL.toString()); And I get a `java.lang.NullPointerException` on the last line. The file is in my project directory in the correct path. _Question: What could cause this exception?_ Answer: _Running from eclipse, the path was constructed relative to the main project folder, not the project's bin folder. Considering that, moving the res folder in the bin folder solved the issue without changing any of the code above._
If the path is in you project, add a `/` cl.getResource("/res/policy/new_policy.policy") But I would suggest you print the value of `policyURL` to check that you retrieve the file ok. If you are executing in Eclipse, remember that the resources must be in a resources folder so they go to classes folder when build. Eclipse only execute classes, and the classes live in output folder (`bin`).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "java, security policy" }
What is the square root of $i^4$? What is the $\sqrt{i^4}$? $i^4$ = $(i^2)^2$ So is $\sqrt{i^4}$ = $\sqrt{(i^2)^2}$ = $i^2$ = $-1$? Or is $\sqrt{i^4}$ = $\sqrt{1}$ = $1$? When I plug it into my TI-89 Titanium, I get $1$. **Edit:** I now see why $i^4 \neq -1$. $$\sqrt{x^2} = \left|{x}\right| $$ So$$\sqrt{(i^2)^2} = \left|i^2\right| = \left|-1\right| = 1$$
The answer is $1$. The reason it is not $-1$ is because, to get there, you inherently split up the square root into a product of square roots as $$\sqrt{(i^2)^2} = \sqrt{i^2} \sqrt{i^2}$$ This is not valid for nonreal numbers.
stackexchange-math
{ "answer_score": 6, "question_score": 5, "tags": "complex numbers, arithmetic" }
Earley recognizer to Earley parser I managed to create Earley recognizer, everything works fine. I have all proper sets of situation. But I only can use it to decide if word is accepted by grammar. How to make it to parse? I need some article or explanation, it seems that I need to create associations to situations that made new situations. Any help would be appreciated. My implementation it's based exactly on: <
Whenever you do an inference, keep track of where you came from, ie. what items where used to form the new item. Then the parse forest can be found by exploring the top element spanning the entire input. If you are parsing with ambigous grammars, you should also consider ambiguity packing, ie. do not recombine (locally) equivalent analyses together. I really recommend Klaas Sikkel's excellent book "Parsing Schemata" for the theoretical side of things.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 5, "tags": "algorithm, parsing, nlp, earley parser" }
Kendo dropdownlist trigger change event I am trying to set the value of my Kendo dropdownList using the code below and expecting the "Change" event to be raise but it doesn't. Can someone please help. Added additional Code as requested. HTML Code <div class="col-md-12 no-padding"> <select id="serviceAccounts" kendo-drop-down-list k-ng-model="vm.customer.serviceAccountId" k-value-primitive="true" k-options="vm.setServiceAccountOptions" style="width: 100%"> </select> </div> Thanks in Advance !
$("#serviceAccounts").trigger("change"); Does not trigger the "change" event of the Kendo DropDownList because $("#serviceAccounts") Is not your Kendo DropDownList...it is just a jQuery selector. You need to get a reference to the actual DropDownList before you can trigger one of its events, i.e.: var dropDownList = $("#serviceAccounts").getKendoDropDownList(); dropDownList.trigger("change"); Example showing difference between selector.trigger() and dropdownlist.trigger(): < Example showing how to trigger the change event using angular widget reference instead of jQuery widget reference: <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 7, "tags": "javascript, kendo ui" }
How are these two sentences related? Let $T$ be a transformation from $\mathbb{R}^2$ to $\mathbb{R}^2$, represented by the matrix: $$ T = \left [ { \begin{array}{cc} 0 & -1 \\\ 1 & 0 \\\ \end{array} } \right ] $$ > The eigenvalues of this matrix are $i$ and $-i$. In this video by 3Blue1Brown, he says that this particular fact has directly related to another fact: > Multiplying a complex number by $i$, is equivalent to rotating the complex plane by $90^0$ and checking where the original complex number (point in complex plane) lands. How are these two facts related? How could a fact about matrices in $\mathbb{R}^2$ having complex valued eigenvalues be related to a fact about complex planes and a relationship between complex numbers?
This matrix $T = \left [ { \begin{array}{cc} 0 & -1 \\\ 1 & 0 \\\ \end{array} } \right ]$ corresponds to $i$ in complex number. Consider $T^2$, it is equal to $- I$, just like $i^2 = -1$ in ordinary number. Another way to think of it is by change of coordinates, the rotation matrix $T = \left [ { \begin{array}{cc} \cos \theta & \- \sin \theta \\\ \sin \theta & \cos \theta \\\ \end{array} } \right ]$, plug in $\theta = \pi /2 $, this corresponds to rotation by $\pi /2$, which is equivalent to $i$ * * * Just added: Next, by the matrix equation $Av=\lambda v$. Left side means rotation by $\pi /2$, if you relate $v$ to a complex number, this just means $i$ times $v$, so $Av=i v$, equivalent to the fact that eigenvalue is $i$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "linear algebra, matrices, complex numbers, linear transformations" }
How to form a Regex to get the numbers from a giving string with certain conditions I have a string like this `(THQ836721='Yes' and BRQ836716='Yes') or (BRQ836717='Yes') and (THQ836728='Yes' and BRQ836756='Yes') or (BRQ836117='Yes') and (SYSQ123='No')` I need a Reg Ex to get the numbers after THQ,BRQ and SYSQ My string may smaller or shorter or may have any times of this THQ,BRQ or SYSQ. So please help to form a Reg eXpression to get the numbers . The length of numbers may vary I am using VB.Net in VS2008
Try this expression: (?<=THQ|BRQ|SYSQ)\d+
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "regex, vb.net" }
What does this one-line, macro function, 'static_assert' do? This is the code I found static_assert(sizeof(struct File) == 256); The definition of the macro is this: #define static_assert(x) switch (x) case 0: case (x): 1. How does this perform assertion? 2. Why not just use the regular assert() function?
This performs an `assert` by triggering a compile-time error. Consider this code: switch(0) case 0: case 0: The compiler will tell you that you have a duplicate `case` label, because zero is listed twice. If, on the other hand, you would put any number other than zero in place of `x`, you would get switch(1) case 0: case 1: which is perfectly legal, and would not trigger a compile-time error. Unlike the regular `assert` which happens at run time, this assert happens at compile time. In other words, if the regular assertion is false, the program would crash; if this assertion is false, the program would not even compile.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 3, "tags": "c" }
Can I use Microsoft.Office.Interop.Excel to create Excel file on the system where Microsoft Office pack is not installed? I am adding `Microsoft.Office.Interop.Excel` from the .net tab of the Add Reference option of Visual Studio to create Excel file. Everything is working fine and I am getting quite good and fast Excel reports. Now my only concern is that can I use this `Microsoft.Office.Interop.Excel` in the System where Microsoft office Pack is not installed. Will I be able to create an Excel file in this condition? Please help me.
> can i use this Microsoft.Office.Interop.Excel in the System where Microsoft office Pack is not installed.Will i be able to create Excel in this condition ? No. Office would have to be installed. Instead, use EPPlus (it's free): > Create advanced Excel 2007/2010 spreadsheets on the server. EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx). I've used EPPlus in several projects and it works well.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": ".net, excel, visual studio 2010, com" }
Use fputcsv create a .csv file and also update the page with table data I am using `fputcsv` to create a .csv file and download it automatically for the user. This works great: function create_csv($data, $not_valid, $csv_old_count, $file_name) { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename="'.$file_name.'"'); $fp = fopen('php://output', 'w'); foreach ( $data as $line ) { fputcsv($fp, $line); } fclose($fp); exit(); } But, I would also like to update the page with a table that shows the data that was put into the csv file. When trying to do this by removing `exit()` and adding a loop to write the table, that data also get written to the csv file instead of writing to my page. **How can I create and download the .csv and also write some HTML to the page?**
You can add the output to your `foreach()` \- foreach ( $data as $line ) { fputcsv($fp, $line); $newLines .= $line . "<br />"; // you'll have to figure out formatting } fclose($fp); echo $newLines; // place this where you want to display the lines
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, csv, fopen, fputcsv" }
Create a word cloud on linux command-line I'd like to create a word cloud on the linux command-line, similar to wordle and similar services. How can I do that? I have plain-text files and I'd like to create a word-cloud for each one.
See this word cloud generator written in Python: < It can be easily installed with pip using this command: pip install wordcloud
stackexchange-superuser
{ "answer_score": 21, "question_score": 13, "tags": "linux, command line, images" }
Naming and meaning of exponential power functions I apologize if something like this has already been asked, but I don't have any ideas on search terms for this family of functions. I'd like to know two things: 1) Is there a name for the family of functions of the form $$f(t)= \exp{(-kt^n)}$$ Specifically, for $n=1$, it's just an exponential decay, and for $n=2$, it's a Gaussian (or Normal) distribution. What about situations where n is fractional ( _i.e._ ${3}/{2}$)? 2) Is there any physical meaning for these types of functions? I realize this portion might belong on the Physics.SX site, so if no one has ideas, I can transfer part 2 over there. To elaborate on what I mean by "physical meaning", I work with NMR signals, and an exponential decay $(n=1)$ indicates a system with homogeneous broadening of lifetimes, and a Gaussian decay indicates inhomogenous broadening of lifetimes.
The function is (for my specific case) a compressed exponential function, and the general function family is the generalized normal distribution. For a physically relevant application of the compressed exponential, see the cross-posting here. Essentially, it comes from the observed relaxation curve being comprised of a distribution of Gaussian decay curves.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "probability distributions, exponential function" }
How do I troubleshoot booting into black screen? > **Possible Duplicate:** > My computer boots to a black screen, what options do I have to fix it? I installed Lucid Lynx over PXE onto this dell server seemingly successfully, but booting from the HD results in a black, unpowered screen. There appears to be no network connectivity to the box either. It may have landed at a textual busybox type prompt, but I can't see it. `Ctrl`-`Alt`-`Delete` seems to reboot. On my last attempt I held shift and the grub menu came up, but recovery mode produced the same results. Should I drop into the grub prompt and give the kernel a magical boot option? Should I boot from a rescue cd and munge some bits on the HD? Give up and install windows?
Here are a couple of "magical boot options" to try: * `nomodeset` * `i915.modeset=0 xforcevesa` I'd remove `quiet splash` when trying these and only one at a time, not together as they'll likely conflict. * * * Edit: for an explanation of _how_ to use these: * When booting, hold left-`Shift` * Highlight the first option and press `e` * Go down to the line that looks like: /boot/vmlinuz-3.0.blah-generic root=UUID=blah ro quiet splash * Replace `quite splash` with your boot option of choice. If that works out well, you can make the changes to `/etc/default/grub` by editing the `GRUB_CMDLINE_LINUX_DEFAULT` value. After saving, run `sudo update-grub`.
stackexchange-askubuntu
{ "answer_score": 4, "question_score": 8, "tags": "10.04, boot, pxe" }
Android: passing parameters between classes I have a **class2** which is involved by **class1** when clicks are made. I have to pass some parameters/objects from **class1** to **class2**. I only know the standard way which does not have an option of passing parameters. // launch the full article Intent i = new Intent(this, Class2.class); startActivity(i);
You can use `Intent.putExtra` (Which uses a `Bundle`) to pass extra data. Intent i = new Intent(this, Class2.class); i.putExtra("foo", 5.0f); i.putExtra("bar", "baz"); startActivity(i); Then once you're inside your new `Activity`: Bundle extras = getIntent().getExtras(); if(extras !=null) { float foo = extras.getFloat("foo"); String bar = extras.getString("bar"); } This allows you to pass basic data to Activities. However, you may need a bit more work for passing arbitrary objects along.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 7, "tags": "android, parameters, android intent" }
Simple scraping / data collecting with C# Selenium not working So im trying to collect some data with Selenium using C# and I am fairly new to it, atleast the collecting data part, what im trying to achieve is, when I press a button is collects some data and puts it in a textbox, simple as that, the only thing is when I run my code it doesnt collect anything im using a label as a button private void label11_Click(object sender, EventArgs e) { var getTopFive = new FirefoxDriver(); getTopFive.Navigate().GoToUrl(" foreach (var item in getTopFive.FindElements(By.TagName("a"))) //this is where I left off { activeTextBox.Text = (item.GetAttribute("class")); } I think I messed it with the FindElements & GetAttribute but im not sure
Using the tag `<a>` will give you many elements that doesn't connected to the movies. You need to find unique identifier for them, like `[itemprop='url']`. IList<IWebElement> movies = getTopFive.FindElements(By.CssSelector("[itemprop='url']")); Will give you a list of all the movies. You can extract the movie name using `Text` property for (int i = 0 ; i < 20 ; ++i) { activeTextBox.Text = movies[i].Text; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, selenium" }
I need to turn my phone off through a computer. Help, please! I need to turn my mobile device off through my PC and currently I can't access my mobile phone. My sensor was bugged, and any calls made via messenger, viber or whatsapp would mean my mobile's device turning black. If I could restart my device, or even just turn it off, the problem wouldn't persist. Please help!
Force restart your phone > Firstly, unplug the charger if your phone is connected to a charger. > > **Press and hold both the Power and Volume Up buttons for at least 8 seconds, until the phone is turned on.** * Remove the phone case if there is one to avoid phone buttons being stuck. * If you cannot force restart your phone, plug in your phone with the original charger and let it charge for up to 30 minutes, then try again. * Pictures, settings and paths might differ from those of your phone, but that do not affect the description in this article. Reference Link
stackexchange-android
{ "answer_score": 0, "question_score": 0, "tags": "remote control, remote access" }
Can i flash indian rom in korean galaxy note? I got the Samsung Galaxy Note shv-e160l (Korean version) as a gift, running the stock ICS 4.0. I want to flash official indian JB ROM (of the GT-N7000) on it. Is it possible if I root my device?
No, do not try to do this, or you will brick your device. SHV-E160L and GT-N7000 have completely different processors (Qualcomm Snapdragon APQ8060 for SHV-E160L, and Samsung S5PC210 for GT-N7000); e.g., see this comparison. There are some custom ROMs for SHV-E160L in the xda-developers section for AT&T Samsung Galaxy Note I717 (this device is closer to SHV-E160L, but also not 100% compatible, so look carefully and use only ROMs which are made for SHV-E160L).
stackexchange-android
{ "answer_score": 2, "question_score": 0, "tags": "rooting, custom roms, rom flashing, samsung galaxy note" }
Grammar for 看來妳忘了發一個訊息。還是妳有用一些避忌的說話所以中國政府阻擋的 This message was not understood by a friend: The goal was to say this: It looks like you forgot to send a message. Or else you used some taboo words blocked by the Chinese government. 1) Where is the Mandarin grammar wrong for this sentence? 2) Is the Cantonese version different?
> _It looks like you forgot to send a message. Or else you used some taboo words blocked by the Chinese government._ > > __ There are too many different ways to phrase this text, the following is just one of them > Mandarin: > > Cantonese: Basically, the only serious grammar mistake is using '' instead of '' for final particle. * '' indicates 'complete action' , '' (blocked) indicates the action of 'blocking' is completed. * '' indicates 'change of situation' '' (blocked) indicates your message's status changed from 'being allowed' to 'being blocked' * '' as a final particle add affirmative tone at the end, Since you started the sentence with "Or else", '' is out of place here because "Or else" implies it is just your guess. If the sentence was ", ()()" then it would have no problem. The other mistakes are mostly poor choice of word. For example, () is much better than () when it comes to 'texting'. But it doesn't mean using () is grammatically incorrect .
stackexchange-chinese
{ "answer_score": 1, "question_score": 0, "tags": "grammar, mandarin, cantonese" }
Why is nodejs silently failing on an undeclared variable? Why is nodejs silently failing on an undeclared variable? It doesn't say anything, no stack trace, etc. This is the worst situation for debugging. How do I get it to be noisier like any other language? This is a little command-line utility written in nodejs. It's not a web app like most people are making. I'm fine with that. It's working as expected and I'm happily porting code over and everything works nice except when I make a typo and then it silently fails. // Typo: should be var or const foo but I missed it and I want nodejs to error about it like any other language foo = func(); I got a hint somewhere that promises are silencing errors like this. If so, why, and is there a workaround, preferably to make it die loudly. Thanks
Shoot me. I missed logging the result of a promise rejection higher up. Once I put that in I started seeing the error and stack trace which was very helpful. If I remember to log all rejection errors this will be fine. The magic bit is that promises will use exceptions and send them to the rejection handler as the result object automatically. This question+answer was helpful: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "node.js, debugging" }
Background image not showing on gh pages Hello i searched for answers but i didnt find any that arent case sensitive related. Locally all works great but when i upload to gh pages it doesnt add background image. I checked case sensitive and everything to tie it all, first isaw maybe image is too big or something but now i see thats not the problem if someone can check and tell me what may be causing the problem thx in advance. My repo of project < and my gh page <
Line 9 of your css reads `background: url("/images/drums.jpeg") bottom center;`. This means the file is being searched for in the same folder as where style.css is held: ` which isn't where it is. To have the code search for the image in the root folder add `..` before the /images folder so it reads as below and this should fix it. `background: url("../images/drums.jpeg") bottom center;`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "html, css, github" }
Checking amount of booleans that are true, and executing differently depending on the amount So I'm trying to check multiple booleans (6), and want to execute different code if more than one, two, three, etc. are true. So here is an example: public static boolean x; public static boolean y; public static boolean z; public static boolean a; public static boolean b; public static boolean c; public static int amtTrue; //if x & y are true, then set amtTrue to 1 //if y & z AND x & y are true, then set amtTrue to 2; //keep iterating though all possiblilites What would be the most efficient way to do this? Thanks for your time!
int i = 0; for(boolean b : array) if(b) i++; switch(i){ case 0: case 1: case 2: }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -7, "tags": "java" }
Listen to incoming HTTP messages on iPhone I have to do a simple iPhone project as part of an university exam which consists in creating a simple instant messenger based on a client/server system using the Java Servlet technology (required). What I would like to know is if there is a framework or some simple classes that make me able to listen for incoming http message from a server without make a request so that an iPhone can send directly to another iPhone an instant message. Thanks in advance and have a nice day! L.
From what I understand from your question, you need a listener. There are several 3rd party implementations that provide what you need. Basically you just need to open a socket for listening on a HTTP server running on your iPhone. Try these, it should provide you with what yo need 1. CocoaHTTPServer. 2. MongooseDaemon
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "iphone, ios, http, servlets, listener" }
Add a percent symbol to label in specific ggplots and not in other plots I have a shiny app, with multiple ggplot, few show percent labels others rounded numbers. All are getting returned by same function that creates the ggplot. `percent_flag` is passed as a parameter to function for same. I tried below logic but it doesnt works. I don't have option of creating additional column to satisfy the creiteria. geom_text(aes(label = ifelse(percent_flag == 1, paste(round(BIAS_contribution, 2), "%", sep = ""), comma(BIAS_contribution)), y = (start + end) / 2)
I would suggest to use a basic if-clause: library(ggplot2) percent_flag <- 1 # base plot p <- iris %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width)) # with percent flag if(percent_flag == 1){ p2 <- p + geom_text(aes(label = paste0(Petal.Width, "%"))) # withput percent flag } else { p2 <- p + geom_text(aes(label = Petal.Width)) } p2
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r, ggplot2" }
What happens after using Spinal Embrace on a Theros God? Spinal Embrace: > Cast Spinal Embrace only during combat. Untap target creature you don't control and gain control of it. It gains haste until end of turn. At the beginning of the next end step, sacrifice it. If you do, you gain life equal to its toughness. Phenax, God of Deception > As long as your devotion to blue and black is less than seven, Phenax isn't a creature. If I have Phenax in play, and my opponent plays Spinal Embrace targeting it, and then gains control of it, but does not have enough devotion to make Phenax a creature, what happens? Do they gain control of Phenax permanently?
Your opponent will gain control of Phenax, then at the end of your turn they will sacrifice it and gain zero life. When Spinal Embrace resolves, it creates two continuous effects: 1. You control that Phenax. 2. Phenax gains haste until end of turn. and a delayed triggered ability: > At the beginning of the next end step, sacrifice Phenax. If you do, you gain life equal to its toughness. So, right after Spinal Embrace resolves, your opponent controls Phenax and it has haste. Then, at the beginning of the next end step, the delayed triggered ability triggers and they sacrifice Phenax. Then they gain life equal to its toughness. However, rule 302.4 says > Power and toughness are characteristics only creatures have. and rule 107.2 says > If anything needs to use a number that can't be determined, either as a result or in a calculation, it uses 0 instead. When you sacrifice Phenax, it is not a creature, so it doesn't have a toughness. So, they gain zero life.
stackexchange-boardgames
{ "answer_score": 4, "question_score": 3, "tags": "magic the gathering" }
Create a "view" of a Java List When doing something like // creating list1, adding items LinkedList slist = new LinkedList(); slist = subList(list1, 2,5); I will have a second object (a "copy" of the elements 2 to 5 of "list") returned by subList and contained in slist. However, I would like to have something that only gives me a "view" of list1, without creating a new object and without allocating new memory, for performance/memory reasons.
I think List#subList does exactly what you want: > Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. List slist = list1.subList(2, 5); Of course, a new (wrapper) object needs to be created, but the data structure for the list, and all the elements will be re-used. The wrapper just keeps track of the start and end pointers.
stackexchange-stackoverflow
{ "answer_score": 16, "question_score": 8, "tags": "java, list" }
SQL Query Between with or well i have a table in mysql that i want to get the data between a date range but when a execute this query: select * from cartap c inner join rastreo r on (c.idCartaporte=r.idcartap) inner join contratistas ct on (ct.NoContrato=c.NumeroContrato) inner join datosfiscales df on (ct.DatosFiscales_ClaveUnicaDF=df.ClaveUnicaDF) where creationdate between '$begdate' and '$enddate' and idper ='2001' or idper ='2002' and estadopago like '%$estadocp%' and estadoliquidacion like '%$estadoliq%' order by $order i get data out of that range, i know is because of the OR condition because it gives me the correct idper values but return values from dates out of the range and i need to use that or something similar because what i want to get is a report between two dates and apply a filter for two (or more) clients (that is the idper) but between those dates
You don't seem to understand the rules of boolean conditions. So, I would recommend in general that you always use parentheses when your conditions mix `and`s and `or`s. They are like training wheels. In your case, though, `in` fixes the issue: where creationdate between '$begdate' and '$enddate' and idper in ('2001', '2002') and estadopago like '%$estadocp%' and estadoliquidacion like '%$estadoliq%' And you should learn to use parameters so your code is not subject to unexpected syntax errors and SQL injection.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, mysql, sql, between" }
How to catch NULL value in length mysql? I have table like this Table : test column1 | column2 aaaaaa | 113323 (NULL) | 2331233 2 | 899999 99999 | 222222 abc | 13123 jul | 98282 I tried to find where the length of word in column1 less than 4, so i used this queries. select * from test where length(column1) < '4' I only get this : column1 | column2 abc | 13123 jul | 98282 2 | 899999 why my queries didn't catch the NULL value ? is there something wrong with my queries ? what i expect was like this column1 | column2 (NULL) | 2331233 abc | 13123 jul | 98282 2 | 899999 I have another solution like used the `where column1 is null` but its not working to
You could also use `COALESCE` here to replace `NULL` with empty string, and then do the length comparison: SELECT * FROM test WHERE LENGTH(COALESCE(column1, '')) > 4;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "mysql, sql, null" }
How to copy plots in R when working in Ubuntu? I am working on the most recent of R on Ubuntu. After I created some plots, the cursor became a '+' and won't let me access the copy and paste options. Moreover unlike the R in Windows, it does not have a toolbar that have the 'Copy' option. What can I do to copy my plots? Thank you.
The default graphics device when using R under Linux is something called "X11": basically, it creates the window in which you see your plot. It's a very basic window without many features so the answer is: you can't copy/paste from it. Instead, you need to create a different graphics device and write the plot to it. Most people would choose something like a PNG file, like this: png(file = "myplot.png") # create PNG device plot(x) # do the plot dev.off() # return to default device (X11) And you now have a PNG file named "myplot.png" in the current directory.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "r, copy, plot" }
Why cannot I directly use returned pointer as parameter in function call of insert? Here's the prototype of the function: void BinaryDimonTree::insert(int x, int y, int level, TreeNode *&cur) in the function, I tried to call: insert(x, y, ++level, cur->getLeftChild()); and here's `getLeftChild`: TreeNode* TreeNode::getLeftChild() const { return this->left; } Then, it reports an error: > no instance of overloaded function "BinaryDimonTree::insert" matches the argument list -- argument types are: (int, int, int, TreeNode *) If I change my code this way: TreeNode *child = cur->getLeftChild(); insert(x, y, ++level, child); No error would be reported. I wonder why this problem occurs and how to solve it if I want to directly use the function return value as the parameter? Thanks a lot!
The last argument of your `insert` function is non-const reference to a pointer. In the call: insert(x, y, ++level, cur->getLeftChild()); the last argument is a temporary value of `TreeNode *` type, that cannot bind to the `TreeNode * &`. You can find a good explanation here
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c++, pointers, data structures, function parameter" }
How i can bake the entire cloth simulation to shape keys? When I give "apply as the shape key" it seems that it only takes a part of the cloth simulation, I want it to take the whole simulation, my cloth simulation has 200 frames and it seems that in the shape key it has only 20
If you do "Apply as Shape Key" it will create a snapshot of the vertex positions from where you are on the timeline as save that as a shape key. The shape key have no animation data. It interpolates from the base shape key to the cloth shape key linearly. That is, if you place the Value on the Cloth shape key on 0.5, each vertex point will be in between the Base and the Cloth.
stackexchange-blender
{ "answer_score": 1, "question_score": 0, "tags": "baking, cloth simulation, shape keys" }
Which governmental bodies to inform if leaving UK My family and I are leaving the UK. Which governmental bodies must I inform about this?
GOV.UK has a webpage about moving abroad: < In short, you will have to inform * your local council * relevant benefits offices * the International Pension Centre * HM Revenue and Customs (HMRC)
stackexchange-expatriates
{ "answer_score": 2, "question_score": 2, "tags": "united kingdom, relocation" }
Redirecting a page via javascript It seems like it's more appropriate to use a meta redirect: <meta http-equiv="refresh" content="0;url=$new_url" /> but there's no page lag with a javascript redirect (in the header) document.location.href = $new_url; My question is, which has the best payoff? I don't actually want SEO to ignore this page, I just want the user to be redirected if they ever get here. Which should I do?
SEO-friendly redirects send a HTTP response code of 301 or 302 (moved permanently). You cannot send a 301 response via javascript. The page will load, giving a 200 "page found" response, then it will run the javascript. Plus, I'm not sure search engines follow javascript re-directs. Meta-tags are also not best for SEO. The page loads (giving a 200 "page found") then a new page is loaded. SEO benefits are lost. Best to use server side redirects to be SEO friendly. You can do so using an .htaccess file on an Apache web server. Here are some best practices for SEO-friendly redirecting: * <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, redirect, meta tags" }
Appending a node to end of tail with Java I am working on a basic Hackerrank problem where we append an element to the end of the linked list. /* Insert Node at the end of a linked list head pointer input could be NULL as well for empty list Node is defined as class Node { int data; Node next; } */ Node Insert(Node head,int data) { if(head == null) { Node node = new Node(); head = node; head.data = data; head.next = null; return head; } while(head != null) { head = head.next; } head.data = data; head.next = null; return head; } For some reason, this solution does not compile. I was looking problems other people solved, and they used a temporary node in the non-empty linked list solutions.
You need to create a new node at the end as well. Also, don't wait until "`head==null`" or you'll reach the end of the list and you won't know where to insert the node. You need to go until "`head.next==null`" so that you end up at the current last node. Also, if you must always return the Head of the list, you should copy the reference before starting the iteration, as noted in the comments. Node Insert(Node head,int data) { if(head == null) { Node node = new Node(); head = node; head.data = data; head.next = null; return head; } Node current = head; while(current.next != null) { current = current.next; } Node node = new Node(); node.data = data; node.next = null; current.next = node; return head; }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "java, linked list" }
How to install python3-django in 14.04? `python3-django` is a package available in the repos for Ubuntu 15.04. It isn't in the default repos for Ubuntu 14.04. How can I install it in Ubuntu 14.04?
If you wish to install the latest version of Django globally, a better option is to use pip, the Python package manager. First, you need to install the pip package manager. Refresh your apt package index: sudo apt-get update Now you can install pip. If you plan on using Python version 3, install using the following commands: sudo apt-get install python3-pip Now that you have pip, we can easily install Django. If you are using Python 3, you can type: sudo pip3 install django You can verify that the installation was successful by typing: django-admin --version 1.7.5 The Source.
stackexchange-askubuntu
{ "answer_score": 2, "question_score": 1, "tags": "14.04, python3, django" }
Как сделать, чтобы снимался чекбокс? Способ может показаться костыльным, вместо описанного используют радио-кнопки, но так требует ситуация. Как сделать, чтобы снимался чекбокс, при выборе соседнего, если они лежат в одном родителе? <div class="parent-1"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> </div>
document.querySelectorAll('.parent-1 input[type="checkbox"]').forEach(item => { item.addEventListener("change", function(e) { if (this.checked) { this.parentNode.querySelectorAll('input[type="checkbox"]').forEach(item => { if (item != this) item.checked = false; }); } }); }); <div class="parent-1"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> </div> document.querySelector('.parent-1').addEventListener("change", function(e) { if (e.target.checked) { this.querySelectorAll('input[type="checkbox"]').forEach(item => { if (item != e.target) item.checked = false; }); } }); <div class="parent-1"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> </div>
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "javascript" }
Where to put helper functions when not using models and an ORM? I have to use PyMongo in a Django project, althought I have always used either Django's ORM or Mongoengine. With the old setup, every model had its own method which did some actual work. This time, having to use PyMongo, I don't have the models, and I don't know where to put the helper functions. Currently I'm writing them inside the `models.py` file, but I'm not even halfway done that already I feel that this way I'm cluttering the models file (too many little functions). Do you know a better solution to the problem?
You are not using django ORM, you don't have any models - you should leave `models.py` empty. Here's one option you may consider to use. Create a package called, for example, `db`. Divide your helper functions into separate scripts according to the entity/collection they are working with. E.g.: db/ __init__.py user.py customer.py role.py Other generic helper function you can leave in `__init__.py` or create a separate module for them. Additionally, while splitting your current `models.py` file into these python modules you may notice that most of your helper functions are similar - in that case, think about going with OOP approach, create a python class for each collection, define generic methods etc (and it will look like inventing your own ORM layer). Hope that helps.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "python, django, django models, pymongo" }
ASP NET Как правильно указать картинку в html для веб хостинга? Добрый день я прописываю картинку в html <img src="~/Resources/MyImage.jpg" Height="200" Width="300"> Но когда переношу проект на хостинг он её не находит. Куда её поместить чтобы видеть или в свойства/дополнительно надо что-то менять у картинки или с JS?
Зашел на веб хостинг и посмотрел файлы проекта, оказывается данная папка с картинкой не опубликована, опубликовал и всё сразу заработало)
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, html, asp.net" }
javascript scroll not working I want my link to scroll down the page to the target content. This is my script (inside the head tag): <script type="text/javascript"> jQuery(document).ready(function($) { $(".scroll").click(function(event){ event.preventDefault(); $('html,body').animate({scrollTop:$(this.hash).offset().top},1200); }); }); </script> And these are my links (inside the body tag): <%= link_to 'Plataformas', root_path + '#plataformas', class: "scroll" %> <%= link_to 'Contato', root_path + '#contato', class: "scroll" %> This chunks of code are inside my application.html.erb. Thank you in advance!
My problem wasn't in the code above, but actually my application.js was missing the require_tree line so it wouldn't load the other js files. Though the answer below it's not the solution for my problem (and that's why I didn't select it) @yodfz_cn was very helpful, thanks!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "javascript, jquery, html, ruby on rails" }
hibernate named queries In hibernate, when we do, session.getNamedQuery(QUERY_NAME), we do not need to pass in the name of the hbm.xml file where the named query is stored. The name of the hbm.xml is mentioned in the cfg file. The question is, if there are 5 hbm.xml files for named queries, and there is a name conflict with respect to the query name(i.e. same QUERY_NAME in all 5 files), how hibernate will resolve it? Intuitively, it appears before doing session.getNamedQuery(QUERY_NAME), one should need to explicitly load the particular hbm.xml file where the query is written.
Hibernate aggregates all the named queries across all hbm file it has loaded under one logical namespace (think of it as a Map with name as the key but with a duplicate check on the key before put(..)). So the names should be unique across a given session factory. So make sure all your named queries are unique.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "hibernate" }
What does it mean when a spell gives two durations? For example, Anticipate Peril gives a duration of "1 minute/level or until activated." Does that mean it lasts for a maximum of 1 minute per level but ends when activated? Or does it mean it lasts forever until activated and the 1 minute per level is superfluous?
The answer's in the description: > The first time during this spell's duration that the target has to make an initiative check, the creature adds an insight bonus on that initiative check equal to the spell's caster level (maximum +5). **Once this bonus applies, the effects of the spell end.** Emphasis mine. The spell ends immediately after an initiative check (activation of the spell's effect). You must also make this initiative check before the duration ends, or the spell expires and has no effect.
stackexchange-rpg
{ "answer_score": 10, "question_score": 2, "tags": "pathfinder 1e, spells" }
Gibbs free energy and chemical potential ![enter image description here]( I would like to know when is the summation term zero. Can it be non-zero in a closed system that does additional work (so PV work + chemical work). I would really appreciate an explanation about this term. Thanks
If you add a particle to a system, then the internal energy will change by an amount which we call the chemical potential $\mu$. Thus we add a term $\mu dN$ to the expression $$dU=TdS-pdV+\mu dN$$ > I would like to know when is the summation term zero. The summation term would be zero if $$\sum_i \mu_idN_i=0\Rightarrow dN_i=0 \ \ \ \ \ \text{closed system}$$ > Can it be non-zero in a closed system? Yes! In chemical reactions such as $$A\rightarrow B$$ $$dG=\mu_AdN_A+\mu_BdN_B$$ However, since an increase in B is always accompanied by a corresponding decrease in $A$, we have that $$dG=(\mu_B-\mu_A)dN_B\not=0$$ In equilibrium at constant temperature and pressure, we have that the Gibbs function is minimized $$dG=0\Rightarrow \mu_A=\mu_B$$ * * * In a similar way, the closed system might be composed of different phases of different substances. In general $dG\not=0$ unless there is an equilibrium between different phases.
stackexchange-physics
{ "answer_score": 1, "question_score": 0, "tags": "thermodynamics, energy, work, chemical potential" }
Notification Access Android? How to use it? I see that apps can request to have Notification Access which states that they can dismiss app notifcation and stuff like that. But what does that mean? Like how would one go about dismissing app notifications and stuff like that within your application.
I believe you are looking for the NotificationListenerService added in Android 4.3. With it you can listen to new notifications being posted, and manage them, including dismissing them. You can find the documentation **here**. To dismiss a notification, for example, you would call the `cancelNotification` method, and provide it with the key, that you previously got from the getKey() method, of a notification. These notification objects can be obtained by calling the `getActiveNotifications()` method.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "android, android notifications" }
Angular dynamic select return promise when no option selected In my application, there is a from, in the form, there are two selects. The options of the second one depends on the first one. I use a `$http.get(url)` to fill the second options dynamically. All work except in this case : The use is alowed to select nothing and submit the form. In this case, I expect the select should be a null or a blank string. But it is a promise object. How would this happens? Do you have any idea for changing the promise object to a empty list a blank string, if nothing selected? For more information, I use the chosen for the select. Here is a updated plunker example. Thanks in advance!
yes `$scope.formData.depart` is a promise object because u assign `$scope.formData.depart` to a `$http`, in angular `$http` returns a promise, see the doc here > The $http service is a function which takes a single argument — a configuration object — that is used to generate an HTTP request and returns a promise with two $http specific methods: success and error. so I think you need to print the form input values inside the `submit()`function, see the forked demo, see the console.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "angularjs" }
unauthorized root access through emergency mode When booting, I can get root access to my Ubuntu 18.04 system without authorization by booting into emergency mode, i.e. by taking the following steps: 1. Boot the machine, and in the GRUB menu, press `e` to edit the commands before booting 2. Search for the line starting with `linux` 3. At the end of that line, delete `$vt_handoff` and add the `systemd.unit=emergency.target` 4. Press `ctrl+x` to boot; you are now root. This should not be possible, right? P.S.: I guess this isn't possible if you disable the GRUB menu
Yes and no. If you go in that direction, then the next statement is "Well, you can password protect grub", then the reply is "But then you can yank the drive and slave it in to something else". Then, "Should have used full disk encryption", and the reply is "cold boot memory scrapers". It goes on and on. End result being, if you can touch it - you can make it yours. So, everything is operating as designed. Rescue mode without a password is by design and partially your fault for not putting in/setting a grub password.
stackexchange-askubuntu
{ "answer_score": 2, "question_score": 0, "tags": "boot, grub2, permissions, root" }
Subset or filter data.frame per indices e.g. column-wise per row Assume you have such a data.frame: df <- data.frame(matrix(1:12, 4)) df X1 X2 X3 1 1 5 9 2 2 6 10 3 3 7 11 4 4 8 12 which have to be filtered row-wise by these column indices: b=c(2,1,3,2) So the expected output should be this: c(5, 2, 11, 8) Using following approach is not the solution, obviously. df[ 1:nrow(df), b] So far I'm using an approach with mapply which is working: mapply(function(x, y) x[y], as.data.frame(t(df)), b, USE.NAMES = F) [1] 5 2 11 8 But I'm wondering whether there is a more elegant solution out there?
You can use numeric matrix indexing; check _?"["_ under the section _Matrices and arrays_ : > A third form of indexing is via a numeric matrix with the one column for each dimension: each row of the index matrix then selects a single element of the array, and the result is a vector. Negative indices are not allowed in the index matrix. NA and zero values are allowed: rows of an index matrix containing a zero are ignored, whereas rows containing an NA produce an NA in the result. The original data frame has 2 dimensions, so you can construct an index matrix with two columns, the first column will represent the row index, and the second column will represent the column index, each pair extracts one element from the data frame as stated in the documentation: b=c(2,1,3,2) df[cbind(seq_len(nrow(df)), b)] # [1] 5 2 11 8
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "r, dataframe, filter, subset, rowwise" }
Cloning JavaScript with for() Example is this and this is not working. What is my mistake ? var i=1; for(i; i <=165; i++){ jQuery(".tekAlan"+i).click(function() { jQuery(".tekAlan"+i).addClass("tekAlanSecildi"); }); } Thanks.
I guess you want to add to only the clicked item the class. However, it always adds the class to the last one. That's because i is accessed **after** the end of the for, so it always contains 165. Do this to solve your problem: var i=1; for(i; i <=165; i++){ jQuery(".tekAlan"+i).click(function() { jQuery(this).addClass("tekAlanSecildi"); }); } `jQuery(this)` is a reference of the element affected by the event (in this case, `click`)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, jquery, for loop, cloning" }
In JavaScript what is a ',' in a conditional In this example: for (var c = 0, e = a.length; c < e && !(d = b(c, a[c]), !1 === d) And in this other: if (d = b(c, a[c]), !1 === d) Do those conditions return the first part, the second or both?
It is the comma operator, and is not specific to conditionals or loops.
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 6, "tags": "javascript, conditional statements" }
Check if dynamically created textbox is dirty with Javascript I'm working on MVC 3 application, I have managed to create a dynamically created textboxes using partial view with validations for these dynamic boxes, however, I want to check if these dynamic textboxes are changed and change a hidden field value to 'dirty' accordingly, I use the following code to detect any changes on textboxes and it works OK on any already existed textboxes, but it doesn't work on dynamically created textboxes: <script type="text/javascript"> $(document).ready(function () { $("input[type='text']").change(function () { $("#FormState").val('dirty'); }); }); </script> Is there anyway to do this with javascript?
Use: $("input[type='text']").live('change',function () { $("#FormState").val('dirty'); }); JQuery Live
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, javascript, asp.net mvc, asp.net mvc 3" }
How many connections are on my web server? I have a Rackspace load balancer running a couple of servers. Before I update my site and restart the web server I drain the connections to one of the servers but I'm not sure when the server is completely drained. Is there a way to tell?
Use `netstat` , for example: `netstat -tapn |grep -c nginx` to check how many connections (plus one listening) you have on nginx (or apache2 etc), you can also grep for the different (ESTABLISHED etc) statuses. You could besides follow the tail of your web server's access log (for ex: `tail -f /var/log/nginx/access.log` ) to see if there are more requests coming in.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 0, "tags": "ubuntu, nginx" }
Is reverse engineering legal? Few weeks ago, I started reverse engineering libraries and binaries from a commercial copyrighted product (a game). And, I would like to post the code on an open source platform like GitHub. I've searched a lot on the Internet, and found that in some cases it was legal to share the reversed-material, and in other cases illegal. Is it legal to post reverse-engineered code from a copyrighted product on an open source platform?
Disclaimer: IANAL. Usually the answer is “it depends.” Are you creating a derivative commercial game? Probably it is not so legal. Are you doing that to be “compatible” with that game? It's legal. Are you just researching the internals of the game? It's legal. For example: I know people who ported game engines by reverse engineering and even copying parts by decompilation & adaptation and, except when they tried to distribute copyrighted things (libraries, graphics, etc…), it was considered legal. Also, please remember that if you're using, say, SAMBA in MacOSX/Linux or Open/LibreOffice, you're actually using code that was reverse engineered from their commercial counterparts and published in open source codes. In short: derivative products or anything with the aim of damaging a company or getting an economic benefit, is probably not so legal. Research, compatibility and porting is.
stackexchange-reverseengineering
{ "answer_score": 4, "question_score": 6, "tags": "decompilation, law" }
How can you create GitHub gists that live under an organization account instead of a personal account? I manage an organization < I see we actually have one gist under < ; I can't figure out how to get any more gists there though. Is there a way?
I don't think you can currently create gists as an organization account, but in my experience, if your account was a personal account and you created a gist under that account and then upgraded the account to an organization account, the gist stays but no new gists can be created. Also, seems like this answer on WebApps confirms my experience.
stackexchange-stackoverflow
{ "answer_score": 96, "question_score": 114, "tags": "github, gist" }
How can I implements ProgressBar class? I want to edit `onDraw` method for my progressbar. But in my class I use `extends` to `Activity` class. When I search on the internet I see , I should extend to `ProgressBar` class. But I etends activity so How can I implements ProgressBar class? my reason: I want to use progress bar which is filling right to left. my code : @Override protected void onDraw(Canvas canvas) { canvas.save(); canvas.rotate(180,MainActivity.phone_width/2,MainActivity.phone_height/2); super.onDraw(canvas); canvas.restore(); }
A ProgressBar is a child of View. Activity is not, but it can contain one or more ViewGroups made up of one or more Views. Create a subclass of `ProgressBar` and then include it in the View that is rendered by the `Activity`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, android, progress bar, extends, implements" }
Evaluate $\sum_{r=1}^{m} \frac{(r-1)m^{r-1}}{r\cdot\binom{m}{r}}$ Evaluate:$$\sum_{r=1}^{m} \frac{(r-1)m^{r-1}}{r\cdot\binom{m}{r}}$$ Using the property:$$r\binom{m}{r}=m\binom{m-1}{r-1}$$ It is same as $$\sum_{r=2}^{m} \frac{(r-1)m^{r-1}}{m\cdot\binom{m-1}{r-1}}$$ How I do now?
Let $$S=\sum_{r=1}^{m} \frac{(r-1)m^{r-1}}{r\cdot\binom{m}{r}}$$ Multiply both sides by $m+1$. $$S(m+1)=\sum_{r=1}^{m} \frac{(m+1)(r-1)m^{r-1}}{r\cdot\binom{m}{r}}$$ $$S(m+1)=\sum_{r=1}^{m} \frac{(mr-(m-r+1))m^{r-1}}{r\cdot\binom{m}{r}}$$ $$S(m+1)=\sum_{r=1}^{m} \frac{(rm^r-(m-r+1)m^{r-1})}{r\cdot\binom{m}{r}}$$ $$S(m+1)=\sum_{r=1}^{m} \frac{m^r}{\binom{m}{r}}-\frac{(m-r+1)m^{r-1}r!\cdot(m-r)!} {r\cdot m!} $$ $$S(m+1)=\sum_{r=1}^{m} \frac{m^r}{\binom{m}{r}}-\frac{m^{r-1}(m-r+1)!(r-1)!}{m!}$$ $$S(m+1)=\sum_{r=1}^{m} \frac{m^r}{\binom{m}{r}}-\frac{m^{r-1}}{\binom{m}{r-1}}$$ Now this becomes a telescoping series. $$\boxed {S(m+1)=m^m-1}$$
stackexchange-math
{ "answer_score": 5, "question_score": 1, "tags": "algebra precalculus, summation, binomial coefficients, telescopic series" }
Finding Phone Number to test with I am not quite sure if this is a question for Stack Overflow, so if you think it's not, please just transfer it somewhere where it fits. So, for my UI tests, I need 5 unique phone numbers _without_ SMS receving capabilities. I need real, valid phone numbers, but at the same time, I don't want to get into legal trouble. Is there any "list" of such phone numbers I can use just for testing? Thanks
I always use xyz-555-1212 where xyz is an area code. 555 is a reserved exchange but a valid number. You can also use 888-555-1212 which is the toll free directory assistance.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "testing, ui testing" }
Disabling waiting for idle state in UI testing of iOS apps Basically the problem is the same as this one: XCTestCase: Wait for app to idle I am using perpetually repeating "background animations" in my views. The UI testing of Xcode/iOS wants to wait for all UIView animations to end before it considers the app idle and goes on with stuff like tapping buttons etc. It just doesn't work with the way we've designed the app(s). (Specifically, we have a button that is animated with `UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse` options, so it never stops.) But I'm thinking there might be some way to **turn off** and/or **shorten** the state "Wait for app to idle". Is there? How? Is there any other way around this?
Unfortunately using Apple's UI Testing you can't turn 'wait for app to idle' or poll other network activity, however you can use environment variables to disable animations in your app to make the tests more stable. In your setup method before your test set an environment variable like this. override func setUp() { super.setUp() continueAfterFailure = false let app = XCUIApplication() app.launchEnvironment = ["UITEST_DISABLE_ANIMATIONS" : "YES"] app.launch() } Now in your source code: if (ProcessInfo.processInfo.environment["UITEST_DISABLE_ANIMATIONS"] == "YES") { UIView.setAnimationsEnabled(false) } You can place that check in a specific view if you only want it to disable animations for that specific view or in a delegate file to disable animations throughout the app.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 14, "tags": "ios, xcode ui testing" }
Problem installing my Android apps I don't know what is happening with my apps. It never happened before. I see errors like this: > [2011-04-10 11:53:22 - Rocket Project] Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED > > [2011-04-10 11:53:22 - Rocket Project] Please check logcat output for more details. > > [2011-04-10 11:53:22 - Rocket Project] Launch canceled! How can I resolve this?
If i'm not mistaken, there are some "new line" characters in your Manifest. Example you declare new Activity: <activity android:name=".Activities.AAWidget" android:theme="@android:style/Theme.Dialog" android:screenOrientation="portrait"> Ok, if so, try to make all these declarations in only 1 line: <activity android:name=".Activities.AAWidget" android:theme="@android:style/Theme.Dialog" android:screenOrientation="portrait">
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "android" }
Async HTTP post gps cordinates I want to send gps cordinates to a web service whenever the gps position on the phone gets updated. Should i create a class that extends `AsyncTask` that sends the data to the webservice from the `onLocationChanged` event? Or do you guys suggest something else? I started coding apps yesterday, so please tell me if im on the right track. Thanks
Yes, I think this would be the right approach. Extend `AsyncTask` and in `doInBackground()` make the `POST/PUT` to your web server. Another approach may be to use a `SocketConnection`, but this will still have to be operated in a background thread, and may add overhead, to thread `Socket` disconnection etc. Just be sure to `unregister` your `BroadcastReceiver` in `onPause` and also handle your `AsyncTasks` to get cancelled when a new one will be executed, or the `Activity` stopped... etc, depending on your application needs. If you would also like to send the location while your app is in background you should consider implementing a `Service`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, android" }
VMwareのホストとCUIのみのゲスト間のクリップボード共有 VMware Player CUIdebain(windows)OS(debian)emacsvim VMware tool emacsvim CUI
Unix OS X CUI OS lemonade lemonade < < < <
stackexchange-ja_stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "linux, vim, emacs, debian, vmware" }
Add Rect from another class in c# I want to draw a rect from another class in c# into my mainWindow <Window x:Class="MyApp.MainWindow" xmlns=" xmlns:x=" Title="MainWindow" Name="mainWindow" Height="768" Width="1366" > </Window> Here is my Class code snippet which I tried to draw a rect to mainWindow private UIElement container; private Rect rect1 = new Rect(); public TestPage(UIElement cont) { this.container = cont; } private void init() { this.container.Children.Add(rect1); } How to handle it?
A Window can have only one content so you have to set `Content` property of Window.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, wpf" }
Javascript Complex graph I was trying to find a special type graph for my project. It's something similar to the sun :) I tried libraries like highchart and canvas but with this, this is not possible. You can see the design in the below link !Graph modal If somebody has some idea please let me know. any help would be appreciated.
You can achieve something similar in Highcharts using `gauge` chart (< I have prepared a demo for you, which can be found below. API Reference: < < Example: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, jquery, graph, charts, highcharts" }
Int cannot be cast as String issue at runtime Running my code results in the following error: `java.lang.Integer cannot be cast to java.lang.String` This is what I have: for(Map<String, Object> record: list) { if(((String)record.get("level")).equals("1")) { rootList.add(record); } } I have tried converting that little snippet to an Int using toString but it just gives me a compiling error. I'm new to java (and I did not write this code either) so forgive me if it's a stupid mistake.
Your `Map`s holds values of type `Object`, meaning they can really hold anything as values (since everything extends `Object`); there's no guarantee that a given value will be a `String`. By your error, it would appear that one of the values in one of your maps is an `Integer`, which evidently cannot be cast to a `String`. The quick-fix is to use `toString`: record.get("level").toString().equals("1") But note that this will yield true for _any_ object whose `toString` returns `"1"`, not just strings. If you want to only check for equality with the _string_ `"1"`, then you can use `"1".equals(...)`, since `equals` can take any object as an argument.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "java" }
Javascript Verbs Detection I've the following problem. I need to find **verbs** in a string using `JavaScript`. I would like to know, if there is something like (JAWS), the Java API for `Wordnet`, but for JavaScript. More specifically, i'm searching for some kind of RESTful webservice able to return the list of verbs in a text or webpage. If you know something useful, please don't hesitate to post your answers.
Have a look at the Natural Language Processing APIs. They seem to have an API. There is even a service for larger amounts of requests (has a free plan as well). It is based on simple POST requests and returns JSON, so it would be easy to use in JavaScript.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "javascript, nlp" }
An endomorphism $f$ such that $f\circ f=1$ What is the name for an endomorphism $f$ of a category such that $f\circ f=1$? Note that I work with category $\mathbf{Set}$.
A mapping $f:X\to X$, for a set $X$, which satisfy $f\circ f=1$ is called **involution**.
stackexchange-math
{ "answer_score": 3, "question_score": 4, "tags": "category theory, terminology" }
reflections.getTypesAnnotatedWith works fine on Tomcat but not Weblogic My application runs fine on Tomcat but on Weblogic one of the dependencies (< is failing. JsonDB internally calls reflections.getTypesAnnotatedWith(Document.class); to get all the classes I annotated with @Document annotation As per title: the same WAR file works fine on Tomcat, but when deployed to Weblogic my classes are not detected and API calls fail. Any help is appreciated.
Fixed by adding the following to weblogic.xml <container-descriptor> <prefer-web-inf-classes>true</prefer-web-inf-classes> </container-descriptor>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, reflection, weblogic" }
Excel VBA - For Each - In & end(xltoright) So here's what I got so far: Sub SortByGen() Dim Gen As Range For Each Gen In Worksheets("Sheet1").Range("B3:G3") If Gen.Value = "XXX" Then Gen.EntireColumn.Copy _ Worksheets("XXX").Range("A2").End(xlToRight).Offset(0, 1).EntireColumn If Gen.Value = "YYY" Then Gen.EntireColumn.Copy _ Worksheets("YYY").Range("A2").End(xlToRight).Offset(0, 1).EntireColumn End If Next Gen End Sub I'm trying to sort certain columns from one worksheet to multiple worksheets based on a certain criterion. I accidentally placed a values on Worksheets("XXX").Range("B2") and Worksheets("YYY").Range("B2") so when the .end(xltoright) ran, the code worked. Now when I try to get rid of the values in B2, the code will get an error.
If you use `xlToRight` and you're starting from the last occupied cell in that row then it will go to the very end of the row: you can't offset 1 more column from there... Use this instead: Gen.EntireColumn.Copy _ Worksheets("XXX").Cells(2, Columns.Count).End(xlToLeft).Offset(0, 1).EntireColumn
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "excel, vba" }
How should these ceiling repairs be finished? Need a 2nd opinion around the effectiveness of ceiling repair done. This repair is made of 3 patches. Despite my request, the workman did not cut the ceiling to make it one patch and did 3 smaller patches. Leaving the last one not covering the water marks that were left. Should I tear it own and get just one patch or should I just paint/texture it and move on? !! 3 Patches
Those patches are not ready for paint _or_ texture. You (or your hired hand) need to properly finish the taping work. It all needs to be feathered out at _least_ 10" from the repair joints using a wide knife, then sanded. The nature of the patch is largely irrelevant. I may have done something very similar to this. The finishing work is the same in either case. You want the transition from joint compound to existing texture perfectly smooth. That's the only way you hide this. Really, the entire patch repair area should be scraped flat before you begin. It's very difficult to skim over bumps. Focus sanding on the edges, and be sure you can't see a line where the compound ends. When you're done you won't even be able to tell how many patches there were. It'll be one wide, smooth white repair. To answer your question directly, **neither**. Finish the taping, _then_ texture.
stackexchange-diy
{ "answer_score": 3, "question_score": 2, "tags": "drywall, repair, ceiling, texture" }
How to replace number data within a string to a different number? There is a string variable containing number data , say `$x = "OP/99/DIR";` . The position of the number data may change at any circumstance by user desire by modifying it inside the application , and the slash bar may be changed by any other character ; but the number data is mandatory. How to replace the number data to a different number ? example `OP/99/DIR` is changed to `OP/100/DIR`.
$string="OP/99/DIR"; $replace_number=100; $string = preg_replace('!\d+!', $replace_number, $string); print $string; Output: OP/100/DIR
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php" }
"Decision can match input such as "'?'" using multiple alternatives: 1, 2" in xText I'm using xText for writing a new eclipse plugin for a new language. But when I try to generate the code Antlr give me this warning: Decision can match input such as "'?'" using multiple alternatives: 1, 2 I'm sure, after commenting much code, that the problem is in the following code snip: ... Expression: operatorExpr=OperatorExpr (condExpr=CondExpr)? |exprPrimary=ExprPrimary (condExpr=CondExpr)? ; CondExpr: '?' ; ExprPrimary: Identifier ; OperatorExpr: '+' expression=Expression ; ... How can i solve the warning?
If you have this expression: `+x?`, it can be analyzed two ways : Expression -> operatorExpr : OperatorExpr -> + -> expression : Expression -> exprPrimary : ExprPrimary = x -> condExpr : ? Expression -> operatorExpr : OperatorExpr -> + -> expression : Expression -> exprPrimary : ExprPrimary = x -> condExpr : ? The condExpr may be set at the top Expression or the inner one. To solve the problem, you may leave only the second condExpr in your main rule. Anyway, it is the default way xtext will solve your ambiguity (meaning that with your current grammar it will choose the second parsing). If you do the other way, leaving only the first condExpr, you get two problems: 1) grammar is still ambiguous for an OperatorExpression with an inner OperatorExpression (`++x?` for example), and 2) `x?` will not match anymore.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "parsing, eclipse plugin, antlr, context free grammar, xtext" }
Display content with the same format i entered into the text area in java or jquery I have a text area and enter some content in this text-area I want to display the content on jsp page in the same format in which I have entered the content in text-area. So its like I entered the text in text-area then save it in mysql database then retrieve it from database and display it on Jsp page. I google it also but can't find the solution. I am using Spring MVC with mysql database.
Enclose the text into a `pre` tag: <pre><c:out value="${theTextFromDatabase}"/></pre> The `c:out` JSTL tag is necessary to HTML-escape all the HTML special chars: `<` become `&lt;`, `>` becomes `&gt;`, `&` becomes `&amp;`, etc.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "java, jsp, textarea" }
operator priority? String ntohl(int i) { int i1 = i % (256); int i2 = (i %(65536))/(256); int i3 = (i %(16777216))/(65536); int i4 = (i)/(16777216); int i5 = i % (2^8); int i6 = (i %(2^16))/(2^8); int i7 = (i %(2^24))/(2^16); int i8 = i/(2^24); Log.d(TAG, "i:"+i+" "+i1+"."+i2+"."+i3+"."+i4); Log.d(TAG, "i:"+i+" "+i5+"."+i6+"."+i7+"."+i8); return ""+i1+"."+i2+"."+i3+"."+i4; } Hi, I have a method listed above which returns an ipv4 address. I've done the calculation however i5 i6 i7 i8 is not like i1 i2 i3 i4.
Using modulus can return negative numbers which you might not expect. Try using the following pattern int i0 = i & 0xFF; int i1 = (i >> 8) & 0xFF; int i2 = (i >> 16) & 0xFF; int i3 = (i >> 24) & 0xFF;
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "java, operators" }
Декомпиляция apk Есть ли какой-нибудь способ полной декомпиляции? У меня есть apk tool, который отлично декомпилирует resourse, но без исходников java, и есть show java на телефоне, он отлично декомпилирует в java код, но без ресурсов. Может быть, есть программа, которая и то, и другое готовым предоставляет?
Онлайн декомпилер. На выходе получаете не только `smali`, но и `.java` с ресурсами
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "apk, android, компилятор" }
How reliable is bluetooth on Android phones? How reliable is bluetooth on Android? I have written a draft game with bluetooth on Libgdx. But 25% of packets disappear. So movements of actors are jerky. Then I add confirmation for received packets. But it slows down the performance. Sometimes packets are resending few times. The devices are just near each other. Thanks.
If it were the case then file transfer between two devices might never be successful since you will never get the complete file on other side. What matters is what BT Profile you implement. The HID is used for gaming mouse, keyboard etc. But most android phones, atleast sometime back didnt have HID profile implemented ,had some experience with samsung mobile phones but tablets may be different I guess.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "android, bluetooth, libgdx" }
How Order By Id works in SOQL I am surprised to see below results. ![select id, createddate from account order by id ]( And below code prints a>b String a = '0014K000002axOZQAY'; String b = '0014K000002axOaQAI'; if(a>b){ System.debug('a>b'); } else { system.debug('b>a'); } So why 'order by Id asc' is not doing what it is asked to do? On what basis it is ordering Id fields. PS 1: Created date looks the same but these accounts are created in the same transaction in order so it looks like the query is following the insertion order while I gave "order by Id asc". PS 2: I read How to query records by insertion order in SOQL? and I hear that we should not rely on order by Id because Ids are in random order, I get that. Still, it doesn't answer why "order by Id asc" doesn't put Ids in ascending order. Only thing I can think of that I should not consider Id same as String so Id follows some other ordering rules, but what they are?
The ordering is being done appropriately. The issue is that you're thinking that the `Id` and `String` types are equivalent to one another. If you disregard the last 3 characters of the Id, or change your `a` and `b` variables to be the appropriate type (i.e. `Id`, not `String`), then you'll see that your test returns the same result as the query that is, `Id a < Id b` as the comparison boils down to the ascii value of 'Z' (90) is less than the ascii value of 'a' (97)
stackexchange-salesforce
{ "answer_score": 4, "question_score": 0, "tags": "apex, soql, query" }
CSS: 100% height of inner div Here is working solution for Chrome and probably Firefox: < Adding `height:100%` to all tables gives the div required data to calculate the actual `height` of parent. But why this doesn't work in Internet Explorer and Opera... Don't want to use javascript for this. Is there any simple cross-browser solution?
First off, you should NOT be using tables for layout. It's bad practice, and will not work well across different browsers. If all you want to achieve is getting the divs to expand 100%, you could do something like this: <div style="height:300px"> <div style="float:left;height:100%;background:green;">block1</div> <div style="float:left;height:100%;background:red;">block2</div> </div> <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "css" }
What is the best way to stop Uvicorn server programmatically? In Docker, I run uvicorn with bootstrap.sh & command line. In code there is a condition about public key file, if exception occurs, server needs to shutdown. So what I want to do in main.py is here (It is FastAPI). public_key = None try: with open(PUBLIC_KEY_FILE) as public_key_file: public_key = public_key_file.read() except Exception as f_error: logger.exception(f_error) module = util.find_spec("uvicorn") if module: uvicorn = import_module('uvicorn') uvicorn.stop() # what I want to do However, I couldn't find a way to shutdown uvicorn server programmatically. What would be the best approach?
Raising an exception (or re-raising f_error) inside your except clause would terminate the current application unless there's another level of exception handling outside of the code you've included. When the python interpreter receives a top level exception (i.e. one that isn't caught by `except`), the interpreter terminates. You can use this to shut down your script and trigger your container runtime to restart the application as necessary.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "fastapi, uvicorn" }
Continuity of integral on two variables Is the function $$ A:t\in [0,1]\longrightarrow A(t)=\int_0^t e^{s-t} f(s)\,ds\in\mathbb{R} $$ always continuous or do we need hyphothesis on $f$ such as $f$ Riemann-integrable? I know that the fundamental theorem of calculus would imply the continuity if the integrand depends only on $s$, but I don't know any result in this case.
If the integral exists for every $t$ in question (i.e. you may consider this on bounded intervals) then $$A(t+h)-A(t) = \int_0^{t+h}e^{s-t-h}f(s) \, ds - \int_0^t e^{s-t}f(s) \,ds$$ Now $$\int_0^{t+h}e^{s-t-h}f(s) \, ds =e^{-h}\left( \int_0^{t}e^{s-t}f(s) \, ds + \int_t^{t+h}e^{s-t}f(s) \, ds\right ) \\\ = e^{-h}\left( \int_0^{t}e^{s-t}f(s) \, ds + h b(t)\right )$$ where $b(t) $ is some bounded function, so $$|A(t+h) - A(t)| \le |(1-e^{-h})| \int_0^{t}e^{s-t}f(s) \, ds + |h||b(s)$$ This tends to $0$ if $h\rightarrow 0$ and $f$ is integrable, (e.g. Riemann integrable) so yes.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "real analysis, integration, continuity, riemann integration" }
Wordpress Avada theme Hi all I am facing a problem wit avada theme while the theme is perfect at localhost but when I upload it on live server it get's the localhost links so when I change localhost links on live server theme's maximum part gets reset is there any proper way of uploading the avada theme.
Changing URLs in a text database .sql dump will break the serialized data that stores widget settings, theme options and more. Use interconnectit.com WordPress Serialized PHP Search Replace Tool to correctly find/replace URLs in the database. If that tool does not work, and your theme still breaks after use, it means the theme does not correctly serialize data in the database.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "wordpress" }
REST API: No route was found matching the URL and request method I'm having issues adding a custom REST API route to Wordpress. Using my own plugin, i've registered the route as followed: add_action( 'rest_api_init', function() { register_rest_route( $namespace, 'handler_mijnenergie', array( 'methods' => '\WP_REST_Server::CREATABLE ', 'callback' => [ $this, 'handle_energie_data' ] ), false ); } ); When calling the namespace "/wp-json/watz/v1" I get a correct response in Postman that the route is shown. ![enter image description here]( However, when i try to access the route request directly, i get thrown a 404 error. So far I've tried: * Rewriting the permalinks * Using standard Wordpress .htaccess * Disabling plugins * Changing method/namespace & request * Testing other plugin routes like Yoast or Contact Form 7 (they work) Any idea what could be causing the issue here and what I need to alter to get this working?
It's because of how you've defined the accepted methods: 'methods' => '\WP_REST_Server::CREATABLE ', You shouldn't have quotes around it. `WP_REST_Server::CREATABLE` is a string that equals `'POST'`, but by putting quotes around it you're literally setting the method as `'\WP_REST_Server::CREATABLE'`, which is not a valid HTTP method. You can see this in the response to the namespace endpoint. Set it like this: 'methods' => WP_REST_Server::CREATABLE Or, if your file is using a PHP namespace, like this: 'methods' => \WP_REST_Server::CREATABLE Or add this to the top of the file: use WP_REST_Server; Then make sure that when you're accessing the route directly, that you're using the correct method. If you're using `WP_REST_Server::CREATABLE` then the endpoint will only respond to `POST` requests, so `GET` requests will return a 404, which includes when you access it via the browser.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "404 error, rest api, routing" }