INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
The driver for my Visioneer One Touch 6600USB will not install I have followed all instructions thrice carefully. When I try to install the driver, I get a message that the install failed as the driver is for the One Touch 6600 only. The scanner is not attached to the computer at this time, and I have followed all uninstall instructions. Can anyone help? Thanks. XP Pro, SP3. EDIT: I found the problem, there was a program I had missed. All okay now.
Did you disable antivirus? There are virus patterns in the installation software. Did you uninstall all previous software and drivers, and reboot, before trying again? (Try running Infclear to get rid of any remnants of the driver.) Are you using the most recent version of the driver from the website (software and drivers that comes with hardware on CD's is often first edition and buggy)?
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "windows xp, drivers, scanner" }
presume his place? > After a century of modernization oriented toward the beacon that is Western democracy, the secular Turkish republic founded by Mustafa Kemal Ataturk may be crushed by the first politician to presume his place. > > — _Time_ magazine In this sentence, **presume his place** means someone who think himself or herself is eligible for that place takes that place? Is that correct? I'm so curious..
I think it may be a translation failure. According with Cambridge Dictionary **presume** > to believe something to be true because it is very likely, although you are not certain **assume** > 1. to accept something to be true without question or proof > 2. to take or begin to have responsibility or control, sometimes without the right to do so, or to begin to have a characteristic > Notice that **presume** and **assume** are synonyms in the first acception but NOT in the second.
stackexchange-english
{ "answer_score": 2, "question_score": 0, "tags": "meaning" }
How do you run Chrome while selenium headless script is executing on mac? I have a python selenium script that uses chromedriver in headless mode to test links on a website. I'm running this script on MacOS High Sierra. If I have Chrome open prior to running the script, I can continue to use the browser normally. Headless mode appears to isolate me from the testing. However, if Chrome is closed first, I cannot launch the browser while the selenium script is running. Looking at Activity monitor in the first scenario, it appears to me that chromedriver creates a new process for Chrome to run. So I (perhaps incorrectly) assumed I should be able to launch the browser manually while the script is running. ![]( What am I missing? **How do I launch Chrome while selenium is running on Mac?**
Ah-HA! This post I stumbled upon made it possible to open Chrome while selenium is running (although I don't understand why it works one way but not the other). > For most applications, launching with `open -naF "App Name"` or `open -nF /path/to/application.app` should be sufficient (see Safari, Forklift, Office apps, etc.). > > * `-n` opens a new instance > * `-a` tells open to look in the list of registered apps (no need to specify the full path, but can go wrong if you have multiple versions of an app. I sometimes see issues on my system with differentiating between macOS apps and apps installed by Parallels OSes… I prefer to specify the path directly.) > * `-F` opens a fresh instance (ignores an app save state left over from previous instances) >
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, macos, selenium, google chrome, selenium chromedriver" }
Does number of charging batteries matter Let's say I have excess of 1000 W and I have empty batteries. **Am I going to store the same amount of power if I have 5 or 10 batteries?** Let's say that we do not fulfill the batteries in some time. Aka does it mean that lower number of batteries is charging faster than larger number but **in the end I am going to get the same amount of stored power?** Example of battery info: ![enter image description here](
Yes you will store the same amount of power, the power is equally distributed between all the batteries in this circuit that aren't full yet. You won't store any faster or slower depending on the number of batteries as it only depends on the excess W you have (the more watt, the faster it charges)
stackexchange-gaming
{ "answer_score": 3, "question_score": 2, "tags": "rimworld" }
is there any hook in wp woo-commerce plugin to enable the .js file instead of min.js? I need to load the checkout.js file of the woo-commerce plugin instead of the checkout.min.js, I am modifying the same function. I need to load the modified js. I know it is possible to use the `wp_dequeue_script( 'wc-checkout' );` But is there any filter to load the '.js' instead of 'min.js'?
Maybe it is not exactly what you are asking for but you can add in your wp-config.php define('SCRIPT_DEBUG', true); It debugging constant that apply to use not minified versions for all js files.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, wordpress, woocommerce" }
Power supply amperage I have a small PSU board out of a defunct DVD player that I'd like to use as a supply for my breadboards. It has two rails, +12 and +5 with two GND lines, but there's no current indication. My guess is that it's in the 500mA-1A range, but I really have no clue. What's the best way to test it and determine a safe limit? Also, if it requires a load in order to operate, should I just wire in a big resistor across +12 to ground?
The case for home appliances usually has the power consumption written on it. That will give you an upper bound if you assume say 80% efficiency. You could hook a fat power resistor up chosen to dissipate say 1A and see if the output voltage drops indicating overload. Really, you could do better with a dual-rail PSU from some obsolete computer equipment (eg Zip drive), available really cheaply at flea markets etc. If you only want 5v, old mobile phone chargers are good; prefer switchmode (light, efficient, well regulated) over transformer (heavy, inefficient, poor regulation).
stackexchange-electronics
{ "answer_score": 6, "question_score": 3, "tags": "power supply" }
"field not visible" error in Java i'm new to programming, so i'm just trying out some simple programs... public class simple { public static void main(String[] args) { A ob=new A(10,20); System.out.println("values of a and b are "+ob.a+" "+ob.b); } ^ } ^ public class A { int a; private int b; A(){} A(int c,int d) { a=c; b=d; } } error displayed was `field ob.b not visible`..i'm using eclipse, need to know what is wrong with the above code.. Thank you!
If you notice the variable **b** is declared as private, this will not allow class **simple** to access it directly. Instead you could access it through a method like **getb()** public class A { int a; private int b; A(){} A(int c,int d) { a=c; b=d; } int getb() { return b; } } Now you can rewrite the **print** statement as follows, System.out.println("values of a and b are "+ob.a+" "+ob.getb());
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 2, "tags": "java" }
Bash: for loop, copy, backup Hey, not 100% sure what this error means. % for f in "*" ; do cp $f ../backup/backup$f ; done cp: ../backup/backup* not found The purpose is to copy all the files into a folder into a backup folder and rename the files to backup.
The `*` shouldn't be in quotes: for f in * ; do cp $f ../backup/$f ; done When you use quotes this prevents the shell from expanding it, so it is looking for a file called `*`, not all files in the directory which is what you meant.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 2, "tags": "bash, loops, backup, for loop, cp" }
How to detect whether my Go code is running on Raspberry Pi and which architecture I'm using this code to differentiate the platform my application is running on: import ( "runtime" ) func Get() (string, error) { // Detect platform we are running on. if runtime.GOOS == "windows" { // ... } else if runtime.GOOS == "darwin" { // ... } else if runtime.GOOS == "linux" { // ... } // ... } Now, I intend to detect whether my application is running on Raspberry Pi and if so, which architecture, i.e. ARM, x86, ... What's the most reliable to do so? Any standard practice which I might be missing?
You can try reading Raspberry Pi serial number. For example, Alex
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "go" }
How to find the optimal value of $z$? > Consider the linear programming Problem : Maximize $ z=5x +7y$ such that > > $x-y \le 1$ > > $2x+y \ge 2$ > > $x+ 2y \le 4$ > > $x \ge 0,$$ y \ge 0$ > > what is the optimal value of $z$ ? My attempt : From $x-y \le 1$ and $2x+y \ge 2$ we have $x=0,y=-1$ From $x-y \le 1$ and $x+ 2y \le 4$ we have $x=1, y=0$ From $2x+y \ge 2$ and $x+ 2y \le 4$, we have $x=0, y=2$ Now im confused that what i have to do and im not able to proceed further
You don't mention anything about $x$ and $y$ being integers, so you can't assume much about what their specific values are from inequalities. I assume they can be real numbers. If so, then your first line's attempt of > My attempt : From $x-y \le 1$ and $2x+y \ge 2$ we have $x=0,y=-1$ as well as the next $2$ lines, aren't necessarily true. Also, note having $y = -1$ doesn't satisfy that $y \ge 0$. Instead, consider the $2$ conditions of $$x-y \le 1 \tag{1}\label{eq1A}$$ $$x+ 2y \le 4 \tag{2}\label{eq2A}$$ Note \eqref{eq1A} plus $4$ times \eqref{eq2A} gives $$z = 5x + 7y \le 17 \tag{3}\label{eq3A}$$ Thus, the largest potential maximum value is $17$. To confirm this is the actual maximum, you just need to find one set of values of $x$ and $y$ which satisfy \eqref{eq3A} and all of the other conditions. You can confirm that $x = 2$ and $y = 1$ work, so integral values do suffice in this case. Thus, the maximum value for $z = 5x + 7y$ is $17$.
stackexchange-math
{ "answer_score": 2, "question_score": 3, "tags": "optimization, linear programming, operations research" }
An alternative for "wait"? In my daily report, I would say > I have finished my last work task and **waiting** for a new one. But I think "wait" is not positive. Is there any alternative for here?
_Wait_ is neutral (the phrasal variation _wait on_ might not be). The word you are looking for is probably _ready_ \- this means not only are you waiting but actively want (or are prepared for) a new task.
stackexchange-ell
{ "answer_score": 3, "question_score": 2, "tags": "word request" }
Custom text screensaver Thinking about what would be useful to display in a screensaver, I realized that it would be nice to know how long the screensaver has been running. `gnome-screensaver-command --time` takes care of that. Now, how can I create a simple screensaver based on this value (plus perhaps some `ps` output), updating it at regular intervals?
If you're technically inclined, you can actually write one without too much trouble! Here's the popsquares source. Look how tiny it is! GNOME Screensaver actually does support xscreensaver, so you can do this a few different ways :) Here's a guide for writing an xscreensaver, and some examples, as well as how they're invoked by the screensaver it's self. Here's a bit more from the GNOME website. I'd personally love this app! Perhaps someone could write it!
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 3, "tags": "screensaver" }
Converging zeroes of a $M$-smooth function A function $f: \mathbb{R}^p \rightarrow \Bbb R$ is $M$-smooth, i.e. $$|f(x+h)-f(x) -\langle \boldsymbol\nabla f(x), h \rangle| < M\|h\|^2 $$ Suppose, we have sequence of zeroes of $f$, given by $x_n$ converging to $x^*$, would $f$ be zero in a neighbourhood of $x^*$?
Let $f:\mathbb{R}^2\to \mathbb{R}$ be $f(y,z)=y$. Then $f$ is $M$-smooth for any $M>0$ since $|f(\vec{x}+\vec{h})- f(\vec{x})-\langle\nabla f(x), h \rangle|=0$. There is a sequence of zeroes converging to $x^*=(0,0)$ and yet $f$ is not zero in any neighborhood of $x^*$.
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "real analysis, calculus, multivariable calculus" }
Download attachments as .zip file I need to develop a C# custom webpart which allow users to download attachments from a sharepoint list. My webpart lists the attachments which the user has selected. Then, it must show him a link to download all the attachments as a zip file (similar to outlook.com feature) By doing some research (System.IO.Compression namespace), I found some ways to do it by creating a .zip file inside the server, but i have not found any way to send it to the user (and also, I would like to avoid saving the file in disk to just then send it). PS: I`m using ApplicationPages [webmethods] and a javascript implements the user interface and call my webmethods. Thanks !
What I would do in your situation: 1. Create a custom action in the Files ribbon. 2. When clicked, it redirecs the user to an application page of yours. 3. The redirect is triggered from the custom action, e.g. from JavaScript code that also injects the Ids of current selected files in the query string. 4. In the code of the application page, you can get the Ids from the query sring, retrieve requested documents from the doc lib, and zip them. All that being done from the `OnLoad` event. 5. The application page actually does not display any UI element. Once the zip is ready as a memory stream, you send it to the Response body (with all required headers). 6. As the page does not render any UI, the user should stay on the doc lib main page, and only get a prompt to download the file.
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 0, "tags": "2013, development, javascript, application pages" }
C#. Datetime range with progress bar? So i have some `DateTime's`, `start`, `end` and `now` DateTime start = Convert.ToDateTime(task.issued_in); DateTime end = (Convert.ToDateTime(task.issued_in).AddHours(Convert.ToDouble(task.lead_time))); DateTime now = DateTime.Now; And i wanna do a `ProgressBar`to show the process. (`start` at the beginning of `ProgressBar` and `end` at the `end`) My idea is `progressBar.Value = (now.hours - start.hours) / (start.hours + end.hours)` But i can't do it. Maybe there is a way to do it?
I believe progress is a relation of passed hours to total hours: progressBar.Value = (int)((now - start).TotalHours / (end - start).TotalHours); Or thus you calculate end time as `start + task.lead_time`, you can use lead_time as total task time: progressBar.Value = (int)((now - start).TotalHours / task.lead_time);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, datetime, timestamp, progress bar" }
Squares of Adjacency Matrices in Undirected Networks to Compute 2nd-order connections Suppose I have an undirected adjacency matrix of social connections. Entry $(i,j)$ and $(j,i)$ equal 1 if $i$ and $j$ are friends, and 0 otherwise. Suppose I want to find all the 2nd order peers and build an adjacency matrix of 2nd order peers such that $(k,m) = 1$ if $k$ and $m$ are second order peers (but not first order peers) and 0 otherwise. In this case, since we know that the square of the adjacency matrix with diagonal elements equal to zero gives us the number of walks of length 2 between any two individuals, it should follow that if I square the matrix and transform all entries larger than 0 into 1, and subtract from the adjacency matrix of 2nd order peers the original adjacency matrix (to get rid of 2nd order peers who are also 1st order peers) and set all diagonal elements to zero, I get the desired result. Is there a more elegant way of doing this?
I'd say your approach is already pretty elegant (and correct)! Your method is very easy to implement and approximately $O(|V|^3)$. You can run breadth-first search with depth two, starting from each vertex, to compute the first- and second-order neighbors in $O(|V||E|)$; I might do this instead if the network is sparse ($|E| \ll |V|^2$) but since such a search is more complicated to implement I wouldn't necessarily say it's "better" than the simple manipulation of the adjacency matrix you describe.
stackexchange-math
{ "answer_score": 2, "question_score": 3, "tags": "network" }
Реверс массива С++ Покажите пожалуйста как это сделать красиво используя стандартный массив, очень смущает `int *_arr = new int[len];` <\- вообще честно говоря жутковатый синтаксис, объясните его пожалуйста, почему нельзя просто написать `int _arr[len];` Почему место `for (int i = 0; i < len; i++) _arr[i] = arr[i];` я не могу просто передать копию `_arr = arr` ? include <iostream> using std::cout; using std::endl; void reversed(int *arr, int len); int main() { int arr[] = { 1,2,3,4,5,6,7,8,9 }; reversed(arr, 9); for (int i = 0; i < 9; i++) cout << arr[i]; getchar(); } void reversed(int *arr, int len) { int *_arr = new int[len]; for (int i = 0; i < len; i++) _arr[i] = arr[i]; for (int i = 0; i < len; i++) { arr[i] = _arr[(len - 1) - i]; } }
> почему нельзя просто написать int _arr[len]; В языке С++ размеры в объявлениях массивов должны быть Целочисленными Константными Выражениями, т.е. попросту выражаясь целыми _константами времени компиляции_. В вашем случае `len` не является константой времени компиляции. Это означает, что объявить массив `int _arr[len]` вы не сможете. Создать массив размера `len` в С++ можно только через динамическое выделение памяти, либо явно (напр. через `new[]`), либо неявно (напр. через `std::vector`). Однако задача реверса массива запросто решается in-place, без заведения дополнительного массива-копии. Поэтому метод создания дополнительного массива к данной теме не должен иметь никакого отношения вообще.
stackexchange-ru_stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "c++, массивы" }
How to access the same variable between Activities in Android I'm wondering how I would go about accessing the same `int` variable between all my `Activity` classes in my Android app. My situation is that I have a variable that represents a number of points and I've placed it in its own class and I want the value to be the same between every `Activity` that uses it. When the user gets a point, it increases by 1 so let's say the user gets 12 points, I want it to be the same throughout all the `Activity`s.
**STEP 1:** Extend all your `Activity`s from a common `BaseActivity` class. **STEP 2:** Put your `int` variable in `BaseActivity` and add the `protected` and `static` qualifiers to the `int` variable: public class BaseActivity extends Activity{ .... .... protected static int points; .... .... } Now you can access the `points` variable in every `Activity` and it will have the same value. There is no need to use a singleton here as the other answers are suggesting. Its much simpler to have a common `static` variable. Its programming 101. Try this. This will work.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 4, "tags": "java, android, inheritance, static, code reuse" }
Htaccess Redirect to another page Hi guys I am having trouble redirecting to another page of my test site and passing the variables through to it. This is my link <a href="/dashboard/add_social.html?id=<?=$social_platform->getId()?>&action=delete" class="delete">delete</a> This is the `Rewrite Rule` in the `htaccess` file but it does not seem to be working. I'm sure I've done it wrong so I'd appreciate any help. RewriteRule ^dashboard/add_social.html\.html$ pages/dashboard/smr_add_social.dashboard.php?id=$1 [QSA,L]
Try getting rid of the `/.html` RewriteRule ^dashboard/add_social.html$ pages/dashboard/smr_add_social.dashboard.php [QSA,L] And do note that the `QSA` flag means that if there's a query string passed it will be appended to the new url.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "php, .htaccess, redirect" }
Slide animation only with one div I have a little problem, I want to create a slide animation. You can see my code : click here. But as you can see, when we "mouseover" on just one div all the divs are animated ! I want to : that when we "mouseover" on one div, just THIS div be animate, and no the others. $(".button span").mouseover( function() { $(this).stop().animate({ height:"+5%"}, 500);}); }); $(function() { $(".button").mouseout( function(){ $(".button span").stop().animate({ height:"150px"}, 500);}); $(".button").mouseover( function(){ $(".button span").stop().animate({ height:"+5%"}, 500);}); Thanks for your precious help.
You need to use `this` as the context for selecting the span: < $(function () { $(".button").mouseout(function () { $('span', this).stop().animate({ height: "150px" }, 500); }); $(".button").mouseover(function () { $('span', this).stop().animate({ height: "+5%" }, 500); }); }); Alternatives would be `$(this).find('span')` or `$(this).children('span');`
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "jquery, css, animation, this, mouseover" }
How can I translate only one object of the scene in an OpenGL? I have a wall pattern `DrawWall` and an airplane `DrawAirplane` in my OpenGL game. How can I push and pop the current matrix and translate only the wall in the scene? I expect the airplane to be fixed. private: void DrawWall(){ glPushMatrix(); glBegin(GL_POLYGON); LeftWallPattern(); glEnd(); glBegin(GL_POLYGON); RightWallPattern(); glEnd(); glPopMatrix(); } private: void DrawAirplane(){ glPushMatrix(); glBegin(GL_LINE_LOOP); //... glEnd(); glPopMatrix(); } public: void Display(){ glClear(GL_COLOR_BUFFER_BIT); glTranslatef(0, -0.02, 0); DrawWall(); DrawAirplane(); glFlush(); }
Use `glPushMatrix()` to push the current matrix, do `glTranslate` and draw the wall, then `glPopMatrix()` and draw the plane. This should only translate the wall. The problem is you seem to be doing the translate in display instead of in `DrawWall` where it should be.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c++, opengl, translate" }
Как написать сложный SQL запрос Есть такая база данных. Таблица заказы (Orders) и продукты (Products) связанны через связующую таблицу OrderProducts. ![Схема БД]( Делаю такой вот запрос SELECT Orders.id as NЗаказа, Products.name as НаименованиеПродукта, Products.price as Цена, OrderProducts.quantity as Количество, Products.price * OrderProducts.quantity as Стоимость FROM Orders, OrderProducts, Products WHERE OrderProducts.order_id = Orders.id AND OrderProducts.product_id = Products.id На выходе ![выходная таблица]( Как мне написать такой запрос что бы выводилась стоимость заказа при том что в заказе может быть несколько позиций?
думаю как то так ( если нужна только номер заказа и стоимость) SELECT Orders.id as NЗаказа, sum( Products.price * OrderProducts.quantity ) as Стоимость FROM Orders, OrderProducts, Products WHERE OrderProducts.order_id = Orders.id AND OrderProducts.product_id = Products.id group by Orders.id плюс на мой взгляд через left join выглядело бы понятнее SELECT Orders.id as NЗаказа, sum( Products.price * OrderProducts.quantity ) as Стоимость FROM Orders LEFT JOIN OrderProducts on OrderProducts.order_id = Orders.id LEFT JOIN Products on OrderProducts.product_id = Products.id group by Orders.id
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "sql, sql server" }
How to stop the Maven assembly plugin from deploying the artifact it creates I am using the maven assembly plugin to combine two jars together using the following configuration: <execution> <id>Package jar with dependencies</id> <phase>compile</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>${project.artifactId}-${project.version}</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> </execution> I DO NOT want the JAR that I create with the assembly plugin to be deployed, how can I stop it from being deployed?
You should specify the following configuration option for assembly plugin: <configuration> ... <attach>false</attach> ... </configuration>
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 3, "tags": "maven, maven 3" }
Como saber qual versão do navegador dinamicamente? Estou fazendo um projeto em CORDOVA utilizando basicamente HTML, CSS, JS. Porém em alguns celulares a imagem de alguns ícones estão ficando do tamanho natural delas e em outros não, tenho utilizado basicamente `vh` para definir o tamanho das imagens. Para testar isto estou querendo verifica qual a versão do navegador está aberto, para verificar se existe portabilidade ou não. Teria algum comando em javascript/jquery que faria isto ?
Em javascript é bem simples: alert(navigator.appVersion);
stackexchange-pt_stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "javascript, jquery, apache cordova" }
JS String to html markup Recently I wrote a simple webapp for handling telnet connections with routers. I am using Node.js with Express and WebSockets. After setting up a connection, a stream from terminal goes through websocket as UTF-8 string. And here is my problem: I wrote a simple displaying function that uses `slice('\n')` and adds an html paragraph, but I'm not satisfied with results, everything is a mess (towel.blinkenlights.nl telnet-based Star Wars doesn't look even close to the version from terminal). When I display the data in the browser console it looks fine, but in my html it does not. The main problem is probably caused by these all `\n`'s `\t`'s etc. So now I'm looking for a solution/library/something that converts js string to html markup. Is there anything like that, maybe in jQuery or so?
Put your text into a `pre` block and it will preserve formatting: document.getElementsByTagName("pre")[0].textContent = "string1\n\tstring2"; string1 string2
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, html, utf 8" }
moving lines from one window to another Is there a simple command that will move lines from one window to another. Currently I go to one window, yank the lines, and then paste in the other window. I would like to know if I can do it without switching windows.
I would do this sort of thing with a macro. So to record a macro for a, qa. Then yy to yank the line, :bnext to switch buffers, p to paste the line, then bnext again to switch back to the original buffer (on the line you started on). Then hit q to stop recording. So to copy, switch windows, paste then switch back, you just need to use @a. Or map it to a function key (map @a). N.B. Just noticed in the comments you had multiple buffers, so obviously you would need to record your macro accordingly.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "vim" }
Can I access a USB drive by its name? I have a Powershell script on my windows machine that needs to access data from a USB drive. It reads a file from the USB stick and does its thing. I need to do this over many machines. The problem is that the USB drive can appear under different drive letters, depending on the machine I insert the stick into. My USB drive is called "USBData". Is there a way to reliably access the USB drive using its name rather than its drive letter?
$driveletter = (Get-Volume -FileSystemLabel "USBData").DriveLetter echo "${driveletter}:\"
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "windows, powershell, usb, usb drive" }
2 joins when querying model I have this method which returns all the categories and groups books belonging to that category def self.user_categories_list joins(:books). select('categories.id, categories.name, count(*) AS books_count'). group('categories.id, categories.name'). order('books_count DESC') end Please excuse my question but I am unsure on how to join the users table to get all books belonging to a user by category, or could i do it by book_id belonging to a user? Any help appreciated Thanks
I think you should just had a where clause: def self.user_categories_list(user) joins(:books). where('books.user_id = ?', user.try(:id) || user). select('categories.id, categories.name, count(*) AS books_count'). group('categories.id, categories.name'). order('books_count DESC') end **Note:** This code assumes that your Book model has the `user_id` attribute in its table.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, ruby on rails, ruby on rails 3, rails activerecord" }
Creating a listener in TIBCO Rendezvous I'm trying to create a listener in tibco rendezvous. I want to listen in on a particular subject. I'm aware that its supposed to look something like this: TibrvListener( TibrvQueue queue, TibrvMsgCallback callback, TibrvTransport transport, java.lang.String subject, java.lang.Object closure) throws TibrvException I have this code. However, I don't know a couple of things. How do I create a `TibrvMsgCallback` object? How do I pass in the transport? I have a publisher that sends the message as a seperate program. Do I recreate an identical transport in my subscribe program? queue = new TibrvQueue(); dispatcher = new TibrvDispatcher(queue); queue.setName(key); this.listener = new TibrvListener(queue, null, null, subject, null); TibrvTransport message = this.listener.getTransport();
You first open the Tibrv Tibrv.open(Tibrv.IMPL_NATIVE); Create transport TibrvTransport transport = new TibrvRvdTransport(service, network, daemon); Create Listener new TibrvListener(Tibrv.defaultQueue(), this, transport, subject, null); If your listener is "this", your class needs to implement TibrvMsgCallback Messages can be processed on arrival in the onMsg(TibrvListener listener, TibrvMsg msg) method.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "tibco" }
How to create VSTS work item tags via vsts-node-api module? I need to create work item tags using vsts-node-api module, it seems there is no function in WorkItemTrackingApi for this at the moment. Is there any alternative for this? Following is the location of Work item API wrapper <
It is created automatically when you use "createWorkItem" and "updateWorkItem" method. Referring to the code I provided in your previous question, update the code to following: let wijson = [{ "op": "add", "path": "/fields/System.Title", "value": "Task created from Node JS" }, { "op": "add", "path": "/fields/System.Tags", "value": "Tag1; Tag2" }];
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "tfs, azure devops, azure pipelines build task" }
How well does the jQuery migrate plugin deal with deprecated code? I will soon be tasked with upgrading to jQuery 1.9. That said I know a few places where we have live(); toggle(); hover(); and browser(); with a number of surprises on the way, -I'm sure. If I add the migrate pluggin, will it continue to execute the old code -or just give me messages in the console to help me track down and fix things? Has anyone made such a wide jump from 1.4.1 to 1.8 or 1.9? that has implemented the migrate pluggin and seen how well it works and the limitations?
The oficial jQuery site describes it pretty well < > The uncompressed development version of the jQuery Migrate plugin includes console log output to warn when specific deprecated and/or removed features are being used. This makes it valuable as a migration debugging tool for finding and remediating issues in existing jQuery code and plugins. It can be used for its diagnostics with versions of jQuery core all the way back to 1.6.4. > > The compressed version of the plugin does not generate any log output, and can be used on production sites when jQuery 1.9 or higher is desired but older incompatible jQuery code or plugins must also be used. Ideally this would only be used as a short-term solution, but that's a decision for you to make.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 7, "tags": "jquery, jquery migrate" }
How can I perform IIS stress test 40,000 http requests per second? I'm the co-founder of a startup which is in the beginning and growing rapidly. I want to test an stress scenario on my IIS server to help figure out the resource needed from our cloud service, like 40,000 http request per second any suggestions?
Whilst I don't disagree with people who have one favourite tool, such as JMeter, or ApacheBench, the problem is, from a naïve point of view, you'll run this from one server, probably in the same Availability Zone as your server, and not get an entirely accurate load test. Have a google about for Cloud-based load testing facilities, that way, they'll use lots of different servers, from all over the world, so you'd get a more accurate representation of when your site goes viral.
stackexchange-serverfault
{ "answer_score": 4, "question_score": 0, "tags": "iis, web server, scaling, stress testing" }
How to create Vidio presentation for the android app I have developed one android app and now I wants create one video presentation for that app for the demo purpose. Can anybody please tell me, how can I do this.? Is there any tool to do this..? One guy have asked this question before, but I didn't get the answer suggested there Please see that question here
< Great tool for sharing screen and capturing video.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android" }
How do I prove that that $n \geq \log_2(n) ^{(\log_2(\log_2(n))}$ as n becomes large? More specifically, I am trying to show that the asymptotic complexity of a problem with that has the bounds $\Theta(\log{2}(n) ^{(\log_2(\log_2(n))})$ is less than that of a problem with the bounds $\Theta(n)$. I tried to use L'Hospital's rule but the derivatives become too complicated for that to be a good solution. I suspect that there may be a substitution that I can make, but if there is I cannot see what it is. Edit: I originally stated that the log term was greater, which is clearly an error. ![enter image description here](
I think you mean the inequality should be the other way around ? Take $ \log_2 $ of the inequality \begin{eqnarray*} \log_2 (n) \leq \left( \log_2( \log_2 (n)) \right)^2 \end{eqnarray*} Now let $n=2^{2^N}$ and we get \begin{eqnarray*} 2^N \leq N^2 \end{eqnarray*} which is obviously false for large $N$
stackexchange-math
{ "answer_score": 6, "question_score": 0, "tags": "computational complexity" }
Does the nearest function on a G1000 allow for listing of anything other than nearest airports? In non G1000 GPS systems, I have seen several pages for selecting the nearest airport, VOR, NDB, intersections, and waypoint, but in a G1000, I can only seem to get a listing of the nearest airport, but have to manually enter VORs. Am I missing something, or does the G1000 not have nearest functionality for these other categories of identifiers?
The G1000 and G500 do indeed have pages for the nearest VOR, NDB, Intersections, and user defined waypoints. The G1000 Integrated Flight Deck Pilot’s Guide gives a list and flowchart / interface map for these. ![enter image description here](
stackexchange-aviation
{ "answer_score": 3, "question_score": 1, "tags": "navigation, avionics, g1000" }
toggling "ng-hide" property with condition on button click <input ng-model="email" type="text" class="marginHalf" ng-hide="email==''" readonly> When on edit button click, Show this so user ca add an email.
You need to have a flag in your controller to toggle on and off when your edit button is clicked. $scope.editMode = false; $scope.onEditButtonClick = function(){ $scope.editMode = true; } then you use a condition that checks this variable but I recommend using ng-if instead. <input ng-model="email" type="text" class="marginHalf" ng-if="editMode" readonly> Here is the difference between ng-if and ng-show/ng-hide.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "angularjs" }
Segmentation fault on dd command I ran this command on Ubuntu to resize the `/tmp` and after that there is segmentation fault coming. dd if=/dev/zero of=/dev/xvda1 bs=1024M count=2 Its our live server. Is there any way to get it working or get the data? Thanks.
The segmentation fault was probably related to the selected block size: with `bs=1024M` you asked for 1GB-sized blocks, which can be too much for your server. Anyway, if `xvda1` was your data partition, unfortunately your data are gone. Sorry...
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "linux, ubuntu 14.04, linux kernel, dd" }
Restrict varchar() to range a-z I'm working on implementing and designing my first database and have a lot of columns with names and addresses and the like. It seems logical to place a `CHECK` constraint on these columns so that the DB only accepts values from an alphanumeric range (disallowing any special characters). I am using MySQL which, as far as I can tell doesn't support user defined types, is there an easy way to do this? It seems worth while to prevent bad data from entering the DB, but should this complex checking be offloaded to the application instead?
You can't do it with a CHECK constraint if you're using mysql (question is tagged wth mysql, so I presume this is the case) - mysql doesn't support check constraints. They are allowed in the syntax (to be compatible with DDL from other databases), but are otherwise ignored. You could add a trigger to the table that fires on insert and update, that checks the data for compliance, but if you find a problem there's no way to raise an exception from a mysql stored proc. I have used a workaround of hitting a table that doesn't exist, but has a name that conveys the meaning you want, eg update invalid_characters set col1 = 1; and hope that the person reading the "table invalid_characters does not exist" message gets the idea.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mysql, database, constraints" }
Can not Activate SharePoint Server Publishing feature in communication site of O365 I just trying to activate SharePoint Server Publishing using Manage site features to be able to use Content editor web part. I found the following Error: NB: SharePoint Server Publishing Infrastructure is already activated. ![enter image description here](
If you need Publishing, use a classic Publishing site or classic Team site with Publishing enabled. <
stackexchange-sharepoint
{ "answer_score": 2, "question_score": 2, "tags": "sharepoint online, web part, communication site" }
Calling a function within a view function in Django Is 1 or 2 the correct way to call a function within a view function in Django. Or are both equally ok. Please explain. #1 def function1(request): [some api calls] #Once this process is done I want to call my second function return function2() def function2(): # some hard work return HttpResponse(...) #2 def function1(request): [some api calls] #Once this process is done I want to call my second function function2() def function2(): # some hard work return HttpResponse(...)
The top one (#1) is the one you want. #2 just returns the HTTP response to the original function. It returns `None` to the view itself. It doesn't work and returns this error. ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "django, django views" }
Is there a cleaner way to return just the first element from find? The following code will return a `DS.AdapterPopulatedRecordArray`, but as the `slug` is unique in my model I just want it to return the first object. import Ember from 'ember'; export default Ember.Route.extend({ model: function(params) { return this.store.find('foo', { slug: params.slug }); } }); To get at the first object in my template I write `model.firstObject.slug`. Is there a way to just return the first object from the Route instead of an array with one object? - and thereby only having to write `model.slug` in the template.
Promises give you ability to chain additional promises to them, and the last/deepest result will be the result that's used by the model hook. return this.store.find('foo', { slug: params.slug }).then(function(results){ return results.get('firstObject'); });
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ember.js" }
Can I re-download the default keyboard (iOS 8) after deleting it? I'm planning on making SwiftKey my default keyboard and deleting the "stock/default keyboard" provided by Apple. But first, I want to make sure I'll be able to get that keyboard back if I need to. Will I be able to get it back after deleting, and if so, how? _iPhone 6 Plus (iOS 8.1)_
Yes. You can get back the keyboard without having to redownload the keyboard, It's never gone. You cannot delete the stock keyboard, you are only removing it from the default set of keyboards. The native keyboard can always be added from `Keyboards > Add a new keyboard > English` whenever you want.
stackexchange-apple
{ "answer_score": 14, "question_score": 7, "tags": "keyboard, ios" }
python type error string and nonetype I am writing a program using two None-types and for one of them I get an error. Here is the program: largest = None smallest =None while True: num = raw_input("Enter a number larger than 0: ") if num == "done" : break try: float(num) except: print 'Invalid input' continue if num < 0: print'number is smaller than 0' continue if num > largest: largest = num elif num < smallest: smallest = num else: continue str(largest) str(smallest) print ('Maximum is '+ largest) print ('Minimum is '+ smallest) I always get: TypeError: cannot concatenate 'str' and 'NoneType' objects on line 23. The answer may be simple, but I'm just a 12 year old beginner. Please help me.
At the beginning, `largest` should be `0`, not `None`. Also, `smallest` should be a very huge number, not `None` You need to assign `str(largest)` to a variable ie. largest = str(largest) smallest = str(smallest)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "python" }
Is there a way to make an Oracle Job disable itself? I'm trying to make this happen: declare Contador number; begin ATUALIZAR_VAL_MAT_PENDENTES(Contador); if Contador = 0 then dbms_scheduler.disable('JOB_ATUALIZAR_VAL_MAT_PEND'); end if; end; When the counter returns zero, it will disable this very JOB. But, I'm getting: **"ORA-27478: o job "SPEDO.JOB_ATUALIZAR_VAL_MAT_PEND" está em execução"** This last bit means **"it's executing"**. So, I'm thinking this is because the job is running and it can't shut down itself. I think that another approach could be to alter the end date, but I can't seem to find the syntax to do this. Can anyone help? Is this achievable?
Thanks to @Shankar for the help. This is how I managed to accomplish what I was trying to do: declare Contador number; begin ATUALIZAR_VAL_MAT_PENDENTES(Contador); if Contador = 0 then dbms_scheduler.set_attribute('JOB_ATUALIZAR_VAL_MAT_PEND', 'end_date', systimestamp + 1); end if; end; I had already thought of this, but when the intelisense poped up saying that the "value" parameter was a "boolean", I didn't even try to pass a date to it. Now it's working fine, but there's one think I must add: **This doesn't work if you attempt to set the end date to an hour or minutes ahead in time. You need to actually change the day or it will give you the ORA-27483: "string.string" has an invalid END_DATE.**
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 4, "tags": "oracle, plsql, dbms scheduler" }
C++ - How do i make a form close the application? My Windows Form application has two forms. `Form1` and `Form2`. How to close entire application after the `Form2` is closed? When I close `Form2` it only closes that form.
Try to call `Application::Exit();` See the reference.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": ".net, winforms, c++ cli" }
How to determine the coefficient of $x^{10}$ in the expansion $(1+x+x^2+x^3+.....+x^{10})^4$ I have a question > Find the coefficient of $x^{10}$ in the expansion $(1+x+x^2+x^3+.....+x^{10})^4$ There ARE questions like this on stack exchange already I know, but I'm not able to formulate a pattern or know how to apply that thing here... I've tried making combinations of $1$'s and $x^{10}$'s, $x$'s and $x^9$'s etc but I am unable to solve it. Please help. PS. How to do it using combinations exclusively.
When you multiply out $$(1+x+x^2+\cdots +x^{10})^4$$ you get terms of the form $$x^{a_1}x^{a_2}x^{a_3}x^{a_4}$$ where $a_1,a_2,a_3,a_4 \in \\{0,1,\ldots, 10\\}$ and you want $a_1+a_2+a_3+a_4=10$. Example, you take $x^0$ from the first three terms and $x^{10}$ from the last term would correspond to $a_1=a_2=a_3=0, a_4=10$. So, how many solutions does this have? This is the stars and bars problem. As others have said, the answer is $$\dbinom{10+4-1}{4-1} = 286$$ Look up the stars and bars problem for more information if this method is easier for you to understand.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "combinations, binomial coefficients, binomial theorem" }
Example usage of $at register in MIPS My textbook says that the MIPS assembler must break large constants into pieces and then reassemble them into a register. And that it uses the $at as a temporary register for I've been looking for a concrete example of this, does anyone have one? I've seen some websites say that the `la` pseudo-instruction converts into instructions using `$at`, but that doesn't seem to be needed. For example: la $t0, 0xABCD1234 converts into lui $t0, 0xABCD ori $t0, $t0, 0x1234
Here's an example taken from my answer to an earlier question regarding the use of `li` and `lw`: Given the following code: .data ten: .word 10 .text main: lw $t0, ten SPIM would generate the following instruction sequence for the `lw`: 0x3c011001 lui $1, 4097 ; lw $t0,ten 0x8c280000 lw $8, 0($1) The address of `ten` is first placed in `$1` (`$at`), and then the value is loaded from that address. Perhaps `sw` would be a better example. In the case of `lw` I suppose you could've expanded the `lw` into `lui $8, 4097 / lw $8, ($8)`. But in the case of `sw` you wouldn't want to overwrite `$t0` with the address.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 5, "tags": "assembly, mips" }
Firefox extension icon on the navigation bar using the Add-on builder How do I add an icon to Firefox that opens up a panel on click on the navigation bar. An example is the Firebug extension. The only thing that will be different, is that I want a panel to appear. ![Firebug Icon]( Thanks!
You might want to use or take a look at this toolbarbutton library: <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "firefox, firefox addon, firefox addon sdk" }
How do I navigatin nested json data I need a little help with navigating a json file. I'm looking to get all the country names from a return like this: [{"country": { "225":["United Kingdom","Europe"], "206":["Switzerland","Europe"], "176":["Romania","Europe"], "127":["Madagascar","AMEA"], "217":["Tunisia","AMEA"] } }] How would I get to this when I don't know or have a list of the 225, 206...etc?
var arr = [ { "country": { "225":["United Kingdom","Europe"], "206":["Switzerland","Europe"], "176":["Romania","Europe"], "127":["Madagascar","AMEA"], "217":["Tunisia","AMEA"] } } ] if you have a key (e.g. `225`), then `arr[0]["country"]["225"]` returns an array with `["United Kingdom","Europe"]` if you want to obtain a list of keys (and respective values) just use var countryObj = arr[0]["country"]; for (key in countryObj) { if (countryObj.hasOwnProperty(key)) { console.log(key); /* e.g. 206 */ console.log(countryObj[key]); /* e.g. ["Switzerland","Europe"] */ console.log(countryObj[key][0]); /* e.g. "Switzerland" */ } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "jquery, json" }
Chrome - Javascript sorting inconsistently I'm aware of Chrome's unstable sorting issues, but I'm at a loss on how to address this when sorting strings. myArray.sort(function(a, b){ var typeA=a.toLowerCase(); var typeB=b.toLowerCase(); return (typeA < typeB) ? -1 : (typeA > typeB) ? 1 : 0; }); works fine in FF and Safari, but in Chrome this still returns an incorrect order. That is, Chrome doesn't honor that if typeA == typeB, return 0...it still chooses to move it. Is there a fix out there for dealing with sorting strings?
JS spec doesn't require sorting algorithm to be stable, so you can't count on that. The only definite ways to solve unstable sorting issue is to either manually code different, stable algorithm or to add one additional unique key to sort on to guarantee that comparison function would always treat two elements as either greater or lesser to each other, but never as equal. Original array index would do.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "javascript, google chrome, sorting" }
How to prove that the distance of $n\sqrt{3}$ to an integer is larger than $\frac{1}{3n\sqrt{3}}$? How to prove $\forall n \in \mathbb{N}^*$, the following inequation is correct. $$ \min\\{n\sqrt{3}-\lfloor n\sqrt{3}\rfloor, \lfloor n\sqrt{3}\rfloor+1-n\sqrt{3}\\} \geqslant \dfrac{1}{3n\sqrt{3}} $$
Let $m$ be the integer closest to $n\sqrt3$. Then we have $$ |(n\sqrt3-m)(n\sqrt3+m)|=|3n^2-m^2|\ge1, $$ because $3n^2-m^2$ is an integer, and cannot be equal to zero because $\sqrt3$ is irrational. Consequently $$ |n\sqrt3-m|\ge\frac1{n\sqrt3+m}.\qquad(*) $$ Because $|n\sqrt3-m|<1/2$ we have $n\sqrt3-\dfrac12<m<n\sqrt3+\dfrac12$. Therefore $m<2n\sqrt3$, and the claim follows from $(*)$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "inequality, diophantine approximation" }
Contract states wage is a fixed sum plus respective statutory value added tax What does it mean if a company in Spain agrees to pay a freelancer based in the UK “a monthly fee of 1000 euros plus the respective statutory value added tax” ? Can the company be charged VAT as well for the freelancer services?
It means they will pay 1,000 Euros a month plus VAT on top if 1. You are registered for VAT and 2. The supply of goods is taxable @motosubatsu has a good answer but basically if you are going to work professionally cross borders you need an appropriately qualified accountant to advise you on this type of thing.
stackexchange-workplace
{ "answer_score": 2, "question_score": -3, "tags": "salary, taxes" }
python: combine values in one column on the basis of ids in another column I need to combine values in second column of a tab delimited file based on the ids in first column. The example is given below. What is the fastest way to do this. I can do it using for loop, going through each line, but I am sure there is some smart way to do it, which I am not aware of. 596230 Other postop infection 596230 Disseminated candidiasis 596230 Int inf clstrdium dfcile 596230 Pressure ulcer, site NOS 2846079 Schizophrenia NOS-unspec 7800713 CHF NOS 7800713 Chr airway obstruct NEC 7800713 Polymyalgia rheumatica 7800713 DMII wo cmp nt st uncntr into 596230 Other postop infection, Disseminated candidiasis, Int inf clstrdium dfcile, Pressure ulcer, site NOS 2846079 Schizophrenia NOS-unspec 7800713 CHF NOS, Chr airway obstruct NEC, Polymyalgia rheumatica, DMII wo cmp nt st uncntr
Assuming you have your text in a file: from collections import defaultdict items = defaultdict(list) with open("myfile.txt") as infile: for line in file: id, text = line.rstrip().split("\t") items[id].append(text) for id in items: print id + "\t" + ", ".join(items[id]) This does not keep the original order of your `id`s, but it does keep the order of the texts.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python" }
Akka: Blocking implications in supervisor-child hierarchy I have a supervisor Actor which delegates work to a lower level child Actor using the _tell_ command. The child Actor does some web service logic and when completes sends a response back to the supervisor. Can someone tell me what happens during this interaction in terms of access to the parents onReceive method? For example when the parent calls tell can it then take another message from its mailbox and start processing that or does it need to wait until the child completes and sends response?
All actors are independent from each other: when the parent tells the child to do something, then the child will pick that up asynchronously without the parent having to wait for that to happen. The parent will then go on to react to new messages which come in. You are welcome to take a look at General Section of the Akka documentation for more details.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, akka" }
Patch Management and System Inventory on a Windows network? What are some good ways to have patch management and systems/hardware inventory for a Windows (Server 2003 or 2008) network? For example, at a minimum knowing the basics for all the machines out on the network such as OS version, patch level, what hotfixes they have, processor, ram, etc. Even better would be knowing more details such as peripherals. Ideally if there were a way to push service packs, and hotfixes (and other software?) to the machines, that would be great. What are some options for this?
Take a look at OCS Inventory: < . It does most of what you want, but be warned that the GUI is a little... rough. Something else to consider would be WSUS. It can definitely tell you hotfixes/patches/system information, but it can be a bit tricky to set up. I suspect a combination of OCS Inventory and WSUS would do everything you want.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 4, "tags": "windows, patch management" }
Trane humidifier control switch replacement The control switch that came with bypass humidifier installed with my Trane heat pump started acting up - only turns humidifier water on when I turn the dial all the way to max. I'm thinking I need to replace it. It seems to have only 2 contacts, so my guess is I can just buy any other control switch, like this one and put it in instead: Am I right, or there's more to it? thanks
Replaced control switch, everything works great.
stackexchange-diy
{ "answer_score": -1, "question_score": 0, "tags": "switch, heat pump, humidifier" }
Change image onclick (specific patern) So, I'm new to javascript and I got this assignment: > "Find a figure with the number 1 and name it " **one.jpg** " on a page. Change the figure (figure 2) to " **two.jpg** " when it is clicked. Change after another click to "three.jpg" then back to " **one.jpg** " However, I cannot seem to find a solution for this. All examples I found use buttons.
This is I think what you want to happen. <img src="one.jpg" id="imageid" onclick="img_clicked()"> <script> var clicks = 1; function img_clicked() { clicks ++; switch(clicks) { case 1: document.getElementById("imageid").src="one.jpg"; break; case 2: document.getElementById("imageid").src="two.jpg"; break; case 3: document.getElementById("imageid").src="three.jpg"; clicks = 0; break; } } </script> </script>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "javascript, html, css, image, onclick" }
PyBrain: passing empty floats or switching them with neutral values? Right now, I am trying to pass this for a dataset sample: 7/2/2014,7:30,138.885,138.87,138.923,,,,138.88067,138.91434,138.895,,,,138.89657 14,138.9186042,138.8745387,138.923,138.9046667,138.895,138.8696667 But predictably, it gives me a value error since empty strings can't be converted into floats. What I want to do is to pass those empty variables in such a way the associated nodes will do nothing at all, or there won't be a learning, nothing will change etc. Is there any way to do this? (There is method for converting the timestaps, I just need to handle the empty strings)
There are a number of ways, but one is to calculate the average value of that column, and pass that in any case where there is missing data. You can also add a column that is True/False for whether or not the data is present, so that the network has the ability to learn that the first column is important only when the second column is True.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "artificial intelligence, neural network, pybrain" }
Closed form solution of DE In my systems class we have to use the solution of a dynamical equation to model a system. It is a term project. The equation is given as $$y''(x)+(x+1)y(x)=0\quad\text{ with the initial conditions}\quad y(0)=0\quad y'(0)=1$$ There is a closed form solution with elementary functions? My instructor told me the solution is found to be with some special functions; but as said I need some elementary functions. I tried every method I know but no progress yet. Can you show me some direction? Edit: I need a solution in $[0,1]$
This equation is closely related to the Airy equation \begin{equation} y''(x)-xy(x)=0 \end{equation} And you can express its solutions fairly easily in terms of Airy functions. Don't see how you're going to get anywhere looking for elementary expressions, although they can be expressed as improper integrals of trig functions and exponentials. Is that what you're after?
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "ordinary differential equations" }
Oracle SQL Developer: PL/SQL: ORA-00903: invalid table name I am getting this error: Error starting at line 2 in command: BEGIN DELETE * FROM book_copies; DELETE * FROM books; /* more code here */ END; Error report: ORA-06550: line 2, column 10: PL/SQL: ORA-00903: invalid table name ORA-06550: line 2, column 3: PL/SQL: SQL Statement ignored ORA-06550: line 3, column 10: PL/SQL: ORA-00903: invalid table name ORA-06550: line 3, column 3: PL/SQL: SQL Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action: Which is ridiculous as both tables exist in my database. I can do: SELECT * FROM books; Or: SELECT * FROM book_copies; And both of them work. Why does Oracle SQL Developer says "invalid table name"?
In a `DELETE` statement, at least in Oracle, you don't list columns, and `FROM` is optional. So when you `DELETE * ...`, it is trying to parse the asterisk as the table name. Note that if you count the columns, column 10 is the asterisk, which is where the invalid table name is being reported. Write `DELETE FROM book_copies` or `DELETE book_copies`.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "sql, oracle, plsql, ora 06550" }
Why is there no forward declaration in concepts c++? When I try this example: template <typename T> concept only_int = std::same_as<T, int>; int add_ints(only_int auto&&... args) { return (std::forward<decltype(args)>(args) + ... + 0); } It works... but when I only declare it like this: template <typename T> concept only_int; ... // defined later on... It would throw compilation errors. Is this a missing feature? or it is intended to leave like this?
If you could forward-declare concepts, then you could use them recursively. By preventing forward-declaration, there doesn't have to be an explicit provision in a concept declaration to stop you from using them recursively.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 7, "tags": "c++, c++20, forward declaration, c++ concepts" }
Migration MYSQL to ORACLE right now am working on database migration from `MYSQL` TO `ORACLE`. I have experience in `MySQL` but not in `Oracle`, So help me to convert the following MYSQL query to `ORACLE` Mysql query: SELECT MIN(id) as min_id, Server_Name FROM details WHERE Server_Role IS NOT NULL THEN GROUP BY Server_Name
Try this Just Don't use the THEN clause its not needed. SELECT MIN(id) AS "min_id", Server_Name FROM details WHERE Server_Role IS NOT NULL GROUP BY Server_Name;
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, oracle sqldeveloper, oracle12c" }
Ruby CSV fails on fields like ="1234" I need to import/update/export CSV files which contain fields starting with an equals sign. ...,="20042",... From reading on the web, that is an Excel trick to force a number to stay as a string type (Excel would see digits and auto-format it to a number). Ruby fails on this: ruby/1.9.1/csv.rb:1925:in `block (2 levels) in shift': Illegal quoting in line 1. (CSV::MalformedCSVError) Seems reasonable. What is the best way to handle this? Pre-process the file to remove the =? Here's an full row example: "Product Code","Product Name","Retail Price","Tax Percentage","Option Name","Option Type" ="20042","Blossom Wall Art","245.00",="1","",""
Using `gsub` should be enough: #!/usr/bin/env ruby require 'csv' data = File.read('file.csv').gsub(/=("[^"]*")/, '\\1') CSV.parse(data).each do |e| puts e.inspect end Output: ["Product Code", "Product Name", "Retail Price", "Tax Percentage", "Option Name", "Option Type"] ["20042", "Blossom Wall Art", "245.00", "1", "", ""]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby, csv" }
ClassNotFoundException on main Application So I have a build of an app that uses a custom Application class (extends `android.app.Application`) and use `full.class.path.Application` in the `android:name` attribute of the application section of the manifest.. The app runs fine when I install via adb. However, after exporting it (tried a few times on different phones), I will get a `NoClassFoundException full.class.path.Application` Am I doing something wrong with `android:name`? Thought the system info might be useful: platform-tools 16.0.2, ADT 21.1, OSX & Eclipse.
It turns out, there's something wrong with the latest ADT in Eclipse. I exported it again using IntelliJ and it worked. Hope this helps anyone who is having similar problems!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android" }
Bezier curve taper on independent axes? In the simplified example below I have a straight bezier curve with a bezier circle specified as its bevel object to give a cylinder. I've added a taper object to vary the cylinder's width along its length. ![Simple taper example]( I would really like the taper to vary independently across the horizontal and vertical axes, like this: ![Independent axis taper]( This doesn't seem to be possible since there's only one Taper object option, and no way to lock it to an axis as there is with the Simple Deform modifier. What would be the best way to do this? I suspect I would have to convert the object to a mesh and then scale by hand with proportional editing, but I'd really like to continue using curves because it'll be easier to get things accurate. Might this be possible, or are there other ways this could be done?
You could use a _Lattice_ modifier, it works fine with beveled bezier (just keep in mind that when you create your lattice, adapt its size to the object in _Object_ mode, not in _Edit_ mode): ![enter image description here](
stackexchange-blender
{ "answer_score": 7, "question_score": 2, "tags": "bezier curves, scale, axis" }
TFS - error when trying to add "Windows user or group" to licensed users - adding group I have: Microsoft Visual Studio 2008 Team Explorer Version 9.0.21022.8 When I go to Team->Team Foundation Server Settings->Group Memberships; Double-click on 'Team Foundation Server Licensed Users'; Select "Windows User or Group" in the 'Add Member'; In the "Select Users, Computers or Groups" type in the group name, then 'Check Names', resolved, press 'OK'. Now I can see the group added to the 'User or Group' list. Unfortunately, when I press 'OK' I get the following unhelpful message * * * ## Microsoft Visual Studio Team Foundation Error ## MyGroup ## OK Help (where 'MyGroup' is the name of the Windows group I was trying to add). At the same time, though, adding individual users from that group works fine. Any ideas on where to begin with this error (pressing 'Help' shows the 'Information not Found' page).
As rwmnau said, the WGE is limited to five. If you purchase a new license you can 'Repair' the app and it'll offer you a place to add the new license code - so you don't need to un-install/ re-install.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "tfs" }
Flutter не видит Android SDK Как на Windows решить данную проблему? Установил flutter, установил Android Studio. Kоманда: > flutter doctor выводит такую ошибку: ![введите сюда описание изображения]( но пути у меня прописаны, что ему нужно еще? ![введите сюда описание изображения]( переменные среды ![введите сюда описание изображения](
Нужно убрать знак `$` из имени переменной. Она называется `ANDROID_HOME`, а не `$ANDROID_HOME`.
stackexchange-ru_stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "android, android studio, android sdk, flutter" }
Updating another element on event fire Let's say I have an event attached to one element, but I want to update another element when it fires. var el = document.getElementById("el"), el1 = document.getElementById("el1"); el.onmouseover = function() { // Here I want to update for example the innerHTML property // of el1 but el1 is undefined in this scope } How do I achieve this?
Not so. `el1` is indeed defined in that scope. If it doesn't seem to be, you've probably got an error somewhere. Tested it, even, with this HTML: <p id=el>el <p id=el1>el1 <script> var el = document.getElementById("el"), el1 = document.getElementById("el1"); el.onmouseover = function() { alert(el1); } </script>
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, scope" }
check if the string equals the first letters of a list of words I am confused about a simple task the user will give me a string and my program will check if this string equals the first letters of a list of words ( like this example) >>> html_attr = ["onerror","onload"] >>> example_task(html_attr,"on") ["onerror","onload"] >>> example_task(html_attr,"one") ["onerror"] should I use fuzzywuzzy here or what ? thanks
No need for some weird libraries, Python has a nice builtin str function called `startswith` that does just that. def example_task(words, beginning): return [w for w in words if w.startswith(beginning)] Fuzzywuzzy would come in handy if you don't want an exact match.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 0, "tags": "python, string, matching, text processing" }
Ratio of absolutely continuous functions on [0,1] ## Suppose that $f$ and $g$ are absolutely continuous functions on $[0,1]$ and $g > 0$. Prove that the ratio $\frac{f}{g}$ is absolutely continuous on $[0,1]$. I've tried using the property that a function, $h$, is absolutely continuous if and only if $h(x) = h(a) + \int_{a}^{x}r(t)dt$. But that hasn't seemed to go anywhere. I've also seen where it's shown that the product of two absolutely continuous functions is absolutely continuous. That method involves showing that both functions are bounded and mining the definition of absolute continuity, which I also haven't gotten to work. Am I missing something obvious?
Since $g$ is continuous it has a positive minimum, say $c$. Hence $\sum |\frac 1 {g(a_i)}-\frac 1 {g(b_i)}| \leq \sum\frac 1 {c^{2}} |g(a_i)-g(b_i)|$. Conclude from this that $\frac 1 g$ is absolutely continuous. Since $\frac f g =f \frac 1 g$ it follows that $\frac f g$ is absolutely continuous.
stackexchange-math
{ "answer_score": 4, "question_score": 0, "tags": "real analysis" }
metric spaces and density Rudin _Principles of Mathematical Analysis_ **2.18 Definition** Let _X_ be a metric space. All points and sets mentioned below are understood to be elements and subsets of _X_. . . . ( _j_ ) _E_ is _dense_ in _X_ if every point of _X_ is a limit point of _E_ , or a point of _E_ (or both). Rudin does not offer any examples of this in the entire chapter. I am trying to get an example in order to understand this. If we let X:=${\mathbb R}$ , and E be a subset, say the interval I:=(a,b), with a=0 and b=1 for example. Then every point of E=I is a limit point? Does this satisfy the definition? I could use some guidance.
A working idea of "denseness" in your context -- with the usual metric in $\mathbb{R}$: $E$ is dense in $X$ if $E$ plus it's limit points =$X$. I believe you are confusing the issue of which set the limit points come from. **Every point in $X$** needs to be in $E$ or a limit point of a sequence from $E$.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "real analysis, metric spaces" }
Isset to use php variable in html form I am trying to load instances from a database, to then create buttons out of them, which can be clicked to submit a form and add the name of whichever button is clicked to `$_SESSION['room']`. The buttons are displayed correctly, however, the `isset()` function is not receiving the correct data as there is no output when a button is clicked. <?php if(isset($_GET['$room'])){ $_SESSION['room'] = $_GET['$room']; echo $_SESSION['room']; } ?> <form method="get"> <?php while($rooms > $count){ $room = mysqli_fetch_row($search_rooms)[0]; echo "<input type='submit' value='$room' name='$room'><br>"; $count = $count + 1; }; ?> </form>
> > name='$room' > This appears inside a string quoted with `"` characters, so the variable will be interpolated. This means you will end up with HTML that looks something like: name='a_room_name'> Meanwhile… > > isset($_GET['$room']) > … tests for submitted data from a form field with the name starts with a dollar sign. It is not a variable. You are testing for an input with `name='$room'>` … which you don't have. * * * You need to use a **fixed** name for your submit buttons. `name='room'` and `isset($_GET['room'])` will do fine.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "php, html, forms, isset" }
Representing number domain by a symbol I'd like to represent the number domain by a symbol rather than text word. While Solve[n^2 - 19 n + 99 == k^2 \[And] {k, n} > 0, {k, n}, Integers] works fine, I'd like to replace `Integers` with $\mathbb{Z}$ (ESC dsZ ESC) and of course for other domains such as `Reals`, `Rationals`, and so on. But that doesn't work: ![enter image description here](
Per the documentation you can use `Esc` `i``n``t``s` `Esc` to enter the `StandardForm` symbol for `Integers`
stackexchange-mathematica
{ "answer_score": 7, "question_score": 4, "tags": "equation solving, assumptions" }
What exactly is a kilogram-meter? This question isn't just about kilogram-meters, it's about multiplied units in general. I have a good mental conception of _divided_ units, e.g. meters _per_ second or grams _per_ cubic meter. Meters per second just (usually) means how many meters are traversed by an object each second. Simple. But I don't really have a mental conception of what it means when units are multiplied, e.g. a kilogram-meter. Can anyone explain in simple physical terms what a kilogram-meter is?
By your question you could see divided units as rate, and an amount of one quantity would be changed based on the amount of another. When looking at it that way you could think about multiplied units as conserved quantities, if you would double one you should half the other to have the same effect. Some interesting examples could be: * Power $P = U I$ thus in volt ampere; * Torque $\tau = F r$ thus in Newton meters (rotating a door). Combining these two idea's about divided and multiplied units could be done by division on one of the sides, taking the identity $U = RI$ or in units $$ \mathrm{V} = \Omega \mathrm{A} \Leftrightarrow \Omega = \frac{\mathrm{V}}{\mathrm{A}}.$$ Where you could take two views. From the point of division the resistance is the amount of power required at a certain current. Or from the point of multiplication, you could keep the same voltage difference by increasing the value of the resistor by the same factor as decreasing the current.
stackexchange-physics
{ "answer_score": 16, "question_score": 29, "tags": "units" }
c++/cli calling a native c++ method i have written a c++/cli program which calls my native c++ function which has the struct pointers as parameter to it. so its like i wrote a wrapper for my native c++ using c++/cli so that i can expose it to c# wcf program(which acts a server to another c++ client). now when i compile my c++/cli program, i didn't get any errors and it got compiled and the dll for this c++/cli is generated, but when look at output window i see some thing like this failed in linking(which didn't effect the compilation). Below is the message that i see in the output file. 1>Linking... 1>Embedding manifest... 1>Caching metadata information for c:\windows\system32\msxml6.dll... 1>Could not cache metadata for c:\windows\system32\msxml6.dll: reflection failed. so i want to know like what this message means and whether this will effect my c# wcf program if i am using this c++/cli dll in c# wcf program, and how can i get rid of this message.
I'm pretty sure that MSXML6.DLL is a native DLL, therefore it doesn't have any managed metadata. I verified this with .NET Reflector: // Assembly msxml6 Location: C:\Windows\System32\msxml6.dll Name: msxml6, 'C:\Windows\System32\msxml6.dll' is not a .NET module. Make sure you're listing its import library in the Linker -> Input -> "Additional Dependencies" project option, and not trying to reference it as you would a .NET assembly.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "c#, visual c++, c++ cli" }
Converting hex string to unsigned int issue C++ I am currently designing a code and one of the instructions given is to get the first two digits of a hex string and do a desired operation. Everything that is less than A is taken into account. Anything greater than that is not, it just takes the next number. Which messes up the code. Here is the line which converts it: int x = atoi(hex.c_str); What am I doing wrong?
I'm assuming this is what you meant - you'd like to convert only the first two hexadecimal digits of a string to an unsigned integer. I'm also assuming that the string contains only valid hexadecimal digits. If you want to validate the string, you need to write some extra code for that. Use `strtoul` to convert a hex string to unsigned integer instead. Also use `substr()` method of the string class to extract only the initial 2 digits of the hexadecimal string. #include <string> #include <cstdio> #include <cstdlib> int main() { std::string myhex = "abcdef"; unsigned int x = strtoul(myhex.substr(0, 2).c_str(), NULL, 16); printf("x = %d\n", x); } This would be your output (i.e. `0xab = 171`): x = 171
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 5, "tags": "c++" }
Returning plain text or other arbitary file in ASP.net If I were to respond to an http request with a plain text in PHP, I would do something like: <?php header('Content-Type: text/plain'); echo "This is plain text"; ?> How would I do the equivalent in ASP.NET?
If you only want to return plain text like that I would use an ashx file (Generic Handler in VS). Then just add the text you want to return in the ProcessRequest method. public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("This is plain text"); } This removes the added overhead of a normal aspx page.
stackexchange-stackoverflow
{ "answer_score": 19, "question_score": 11, "tags": "asp.net, http, web applications" }
Type not defined, Visual Studio Express 2013 In Visual Studio Express 2013, I'm making a custom control called "AddressVerifier", which has a custom button called "CustomButton". Every time I modify the form, even just moving a label, it modifies the AddressVerifier.Designer.vb file, which creates a compile error as shown. If I select either of the first two fixes, it compiles fine and all is well until I modify the form again, then it removes the fix for the next compile. I'm virtually CERTAIN this is a bug, but is there a workaround? ![enter image description here](
This may be due to a name clash. It appears that you may have a type and a namespace both called `AddressVerifier`. The IDE is using the name of the namespace in the code but then the compiler is interpreting it as the type. The solution is to not use the same name for two things in the same context. EDIT: The suggestion to add the `Global` qualifier is to force the compiler to interpret the name as the namespace rather than the type. It reverts when the design code file is regenerated because the IDE doesn't scan every possible type and namespace for name clashes, but rather just assumes that you have named things such that they won't happen. It could be considered a limitation but not a bug in the IDE.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "vb.net, winforms, visual studio 2013, visual studio exp 2013" }
How to loop until == true So I'm making a Tic Tac Toe game but I got stuck in the point where if position is already taken => get the user to enter another position. Here is what I'm talking about: int pos[3][3]= { {0,0,0}, {0,0,0}, {0,0,0} }; bool CheckForPos(int x,int y) { if (pos[y][x] == 0) return true; return false; } This is the matrix where I check if position is already entered. And the code in **int main ()** : if( CheckForPos(y,x) ) { pos[y][x] = 1; chess[y][x] = 'X'; } else { while (pos[y][x] = 1) { cout << "Spot already taken." << endl; cin>>get; } } Where is my mistake and how could I fix it ? Any ideas ?
Do something like this.... if( CheckForPos(y,x)) { pos[y][x] = 1; chess[y][x] = 'X'; //take one count variable for counting that how much position has be finished like if count value is greater than your array size than terminate it count++; } else { //simply print your message and again get your position cout << "Spot already taken." << endl; cin>>get; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, loops" }
Is it legal for a package to depend on a development package? I have a package that needs dpkg-dev to be installed. So I've added it as a dependency and it works as expected, but now I'm wondering whether it is legal practice according to the Debian packaging rules. Here is how the result looks like: Package: snapcmakemodules Section: devel Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, dpkg-dev Description: Common Snap C++ CMake modules This package contains common CMake modules to support Snap C++ projects. My package includes a perl script which requires perl files found in the `dpkg-dev`.
Packages in the section `devel` are packages needed for development purpuses. It is absolutely fine when another package (even if itself is in the `devel`-section) depends on a package in the `devel`-section if you need the functionality of this package.
stackexchange-askubuntu
{ "answer_score": 2, "question_score": 1, "tags": "package management, dependencies, packaging" }
Scanning, and overriding autofac registrations that use WithParameter As part of my autofac initialization, I scan a list of assemblies and register any services that match a naming convention: MyClass: IMyClass. This cuts down on the amount of registration code I have so I really don't want to eliminate this feature. The problem is that I have a couple classes that I want to register using some specific initialization data. I'm currently registering these after the scanning process using something like: builder.RegisterType<MyClass>().As<IMyClass>().WithParameter("initData", value) When I examine the container I can see both registrations, the one from the scanning process and the one with the specified parameter. Is this the correct behavior? I was wanting autofac to replace the scanned registration for IMyClass. How can I get autofac to use the registration using the provided parameter? Thanks,
The container will keep both registrations, but only the last registration will be used. Have you made a test to verify the behavior you expect? Something along these lines: var my = container.Resolve<IMyClass>(); Assert.That(my.Data, Is.EqualTo("initData"));
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "autofac" }
How to get the first match String using Regex I have folowing code: public class RegexTestPatternMatcher { public static final String EXAMPLE_TEST = "This is my first photo.jpg string and this my second photo2.jpg String"; public static void main(String[] args) { Pattern pattern = Pattern.compile("\\w+\\.jpg"); Matcher matcher = pattern.matcher(EXAMPLE_TEST); // check all occurance while (matcher.find()) { System.out.println(matcher.group()); } } } The Output is: photo.jpg photo2.jpg I would like to select the first match so only **photo.jpg** , and skip the second photo2.jpg, I tried **matcher.group(0)** , but not worked, Any idea how to do that, Thanks.
Stop iterating after first match. Change `while` to `if` if (matcher.find()) { System.out.println(matcher.group()); }
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "java, regex, pattern matching" }
Natural sort order (human sort order) in R list.files() Is there a simple way to sort files in natural order (otherwise known as human order), i.e. file9.csv comes before file10.csv? list.files() seems to have no options for the sort order. There are plenty of implementations in other languages (e.g. here) , and Rosetta Code only has solutions in C, Perl, Python, etc.
"Human sort" is a mad man's illusion available only on hypothetical AI systems, but only when having proper context knowledge. To this end you should rather use some quick regexp to extract meta-data from file names and use them to order files: files<-c("file9.txt","file10.txt"); as.numeric(gsub('^file([0123456789]*)\\.txt$','\\1',files))->fileNum; files[order(fileNum)]
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 6, "tags": "r, natural sort" }
Preparing Dataset Minority Class vs Majority Class I'm currently doing a binary classification for sentiment prediction. Currently I have the majority class (~90% of the data) as my positive class (labelled 1) and the minority class (~10% of the data) as my negative class (labeled 0). What I'd like to maximize in this experiment is the detection of negative sentiments, hence I'd like to maximize the precision (and recall) of my minority class. However, in many similar datasets (in terms of prioritizing the detection of minority class) out there like credit card fraud detection, cancer detection, usually the minority class is set as the positive class and the majority class set as the negative class. My question is: Does it matter if the minority class is set as the positive or negative label in relation to performance of training a model or affecting a loss function such as cross entropy?
> My question is: Does it matter if the minority class is set as the positive or negative label in relation to performance of training a model or affecting a loss function such as cross entropy? No it doesn't. However in binary classification it's customary to call "positive" the main class of interest, so be careful to be clear about which one is positive/negative when/if you present your results to other people. Also be careful that precision and recall are usually calculated for whatever is called the positive class, so don't inadvertently use the results of the majority class instead of the one you're interested in.
stackexchange-datascience
{ "answer_score": 1, "question_score": 1, "tags": "machine learning, classification, class imbalance, binary" }
Find the singular points of $f$ and determine which are removable Consider the function $$f(z)=\frac{\tan(z)}{z}, \quad z \in \mathbb{C}$$ I want to find it's singular points, determine which are removable and classify the smallest positive non-removable singular point. I know that $f$ has a singular point at $z=0$, which is removable since $\lim_{z \to 0}f(z) \neq0$. How do I find any others and then classify the smallest non removable one though?
**HINT:** Note that $\tan(z)=\frac{\sin(z)}{\cos(z)}$ and $\cos(z)=0$ for $z=(n+1/2)\pi$ where $n$ is any integer. Then, note that $\lim_{z\to (n-1/2)\pi}\frac{z-(n-1/2)\pi}{\cos(z)}=(-1)^n$
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "complex analysis, singularity" }
Are there drawbacks to altering MySQL table data types? I'm wondering that how much worried I should be about data types. I can easily jump from TINYINT to SMALLINT and from SMALLINT to INT, but are there any drawbacks to this? Obviously situations like from text to int will have consequences, but I'm talking about situations like INT->BIGINT, TINYTEXT->TEXT, etc.
Upgrading to a "larger" version of the data type should be harmless. The only "drawback" of course would be that the column requires more storage space. But this shouldn't be a deal breaker unless you have a massive table. Just be sure to check your foreign keys before you make a change like that. Foreign keys must have the same type (even down to specific attributes like `UNSIGNED`)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql" }
is the array stored in disk too or it is just in ram? I'm new in programming and computer science. * When I have an array, is it just in RAM or it has to be in the disk too? for example I have: `int array[100];` Is it only in RAM? If it is in the disk too, how can I implement it to be just in RAM? * If something is in the disk it isn't implemented as an array? Is this definitely a file?
When you have an array int array[100]; It is only residing in the RAM, the physical memory of the system. It can be in the disk if you take the array, and write it in some file. * * * If something is in the disk, it can be read, and then stored it in some array. Then at that point of time, it would be in RAM. If you make some changes in the array, only the copy in the RAM will change. To make the change reflect in the disk, you have to write it back.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c, arrays" }
Why does Property Set throw StackOverflow exception? I know java and would normally put in getter/setter methods. I am interested in doing it in C# with the following code, but it throws a StackOverflow exception. What am I doing wrong? Calling Code c.firstName = "a"; Property Code public String firstName; { get { return firstName; } set { firstName = value; } }
It's because you're recursively calling the property - in the `set` you are setting the property again, which continues _ad infinitum_ until you blow the stack. You need a private backing field to hold the value, e.g. private string firstName; public string FirstName { get { return this.firstName; } set { this.firstName = value; } } Alternatively, if you're using C# 3.0, you could use an auto-property, which creates a hidden backing field for you, e.g. public string FirstName { get; set; }
stackexchange-stackoverflow
{ "answer_score": 127, "question_score": 65, "tags": "c#" }
How can I set the publisher on a PubSub node using Smack? i'm developing a chat with Smack libraries and Openfire server. I would like to set a user to publisher on my pubsub node. I've searched for the web but i can't find anything. I've set the pubsub with this configuration: nodeconfig.setPublishModel(PublishModel.publishers); I've saw that i can create the affiliation: Affiliation af = new Affiliation(mypubsub,Affiliation.Type.publisher); What can i do?
You need to retrieve the Node's `ConfigurationForm` via `Node.getNodeConfiguration()`, create an answer form from it with `createAnswerForm`, and call `Form.setAnswer(String, String)` to set the `pubsub#publisher` option. Then send the answer form with `Node.sendConfigurationForm(Form)`. from.setAnswer("pubsub#publisher", "[email protected]"); See also XEP-60 8.2.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "xmpp, publish subscribe, smack" }
Can Russell's paradox, Halting problem and Godel's Incompleteness theorem be generalized? All these three theorems (I am not 100% sure about the third, but I have heard it has a similar argument with the other two) use self-referentiability as contradiction and they talk about the impossibility to solve everything. Is there anything that generalizes this concept? I think they actually describe the same object.
Yes: see Lawvere's fixed-point theorem. There is an expository paper by Yanofsky covering exactly the results you mentioned (and more): A Universal Approach to Self-Referential Paradoxes, Incompleteness and Fixed Points. See also this MathOverflow question.
stackexchange-math
{ "answer_score": 19, "question_score": 17, "tags": "set theory, model theory, computational mathematics" }
Officejet 5610 prints blank pages in ubuntu I'm trying to get my HP Officejet 5610 working on Ubuntu 10.04. It installed just fine, and when I print I hear the print head moving, but the page is blank. It works just fine on a windows machine. Any ideas? I'm a Linux noob so I apologize in advance
I had the same problem with my HP Officejet 5610xi, which probably uses the same driver. I initially tried use a printer share on my Windows Vista box, where my 5610xi is normally connected, and got the same symptoms: print head activity, but page always blank. I went to this site and downloaded the latest driver file for the 5610xi (even though they claim support for the printer is already in Ubuntu). I then followed the steps to extract the .ppd file from it, and use that to add the printer locally (Sysyem -> Administration -> Printing). That didn't seem to fix my printing over the network, but I can now print to the printer connected locally to my Ubuntu 10.04 laptop using USB.
stackexchange-superuser
{ "answer_score": 1, "question_score": 1, "tags": "ubuntu 10.04, printer" }
Compare date columns I need to retrieve the rows that service_date is greater than prod_date. The data type for prod_date is VARCHAR(10) (2/20/2014 for example) and the data type for service_date is DATE (YYYYMMDD). If I query service_date using "select service_date from service where service_date ='20140201'", the result is showing "2/1/2014" in the result grid. However, it does not work in the query below when I convert service_date to varchar to compare with prod_date. It pulls out all the rows instead of the ones that have greater service_date. SELECT P.PROD_ID, P.PROD_DESC, S.PROD_ID, S.SERVICE_LOC FROM PRODUCT P INNER JOIN SERVICE S WHERE P.PROD_ID = S.PROD_ID AND CAST(S.SERVICE_DATE AS VARCHAR(10)) >= P.PROD_DATE
I suggest you use date ordering instead of string/varchar ordering if possible for simplicity and since its [ probably ] closer to what your interested in and less likely to confuse For example '01/02/2014' >= '04/01/2013' -- if these are dates or cast to dates but '01/02/2014' < '04/01/2013' -- if these are strings So to keep things simple, it makes sense to cast `PROD_DATE` to a date when comparing these two fields like : SELECT P.PROD_ID, P.PROD_DESC, S.PROD_ID, S.SERVICE_LOC FROM PRODUCT P INNER JOIN SERVICE S WHERE P.PROD_ID = S.PROD_ID AND S.SERVICE_DATE >= cast(P.PROD_DATE as date format 'DD/MM/YYYY') ; if theres any doubts on prod_dates quality as valid dates can check the conversion on all dates first ( before running/adjusting above )
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "teradata" }
Как перенести int, double, char в char const*? Как перенести int, double, char в char const* ? Вот есть у меня клас телефон, у него есть свои характеристики. Мне говорят: "Сделай функцию, что будете возвращать все характеристики телефона в одной строке (char*). Внимание, вопрос: "Как?".
Что-то типа этого не подходит? struct Phone { char model[40]; double price; int buttons; }; int main(int argc, const char * argv[]) { Phone p; strcpy(p.model,"Nokia"); p.price = 25.67; p.buttons = 20; char a[100]; sprintf(a,"Phone %s with %d buttons for %.02lf dollars", p.model, p.buttons, p.price); cout << a << endl; }
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c++, массивы, char" }
F# Implement base class I'm new to F# and I wanted to create an F# Forms Application. But the Problem that I have at the moment, is that I don't know how to implement a base class. In C# I would do it like that namespace Test_Form { public class Form1 : Form { public Form1() { } } } But how do I make it in F# so that my Forms is a module and not a type I already tryed open System open System.Windows.Forms type Form1() = inherit Form() but that would result in public class Form1 : Form { public Form1() : this() { } }
Where you would use the constructor method in C# public class Form1 : Form { public Form1() { // Do stuff } } In F#, quoting the docs, > The do-bindings section includes code to be executed upon object construction. you would type Form1() = inherit Form() do // stuff For example: type Form1() as this = inherit Form() do this.Click.Add(fun args -> printfn "%s" <| args.ToString())
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "c#, f#, base class" }
Provide inject with setup function with Vue 3 Anybody knows how to provide a variable that is in the setup function? export default { name: "MyComponent", provide: { myVariableThatIWantToProvide // This is not working }, setup() { const myVariableThatIWantToProvide = ref('test'); return { myVariableThatIWantToProvide }; } }; </script>
You should import `provide` from vue and use inside the setup function : import {ref,provide} from "vue" export default { name: "MyComponent", setup() { const myVariableThatIWantToProvide = ref('test'); provide ('myVariableThatIWantToProvide', myVariableThatIWantToProvide ) return { myVariableThatIWantToProvide }; } }; </script> in grandchild component : import {inject} from "vue" export default { name: "somechild", setup() { const myVariableThatIWantToProvide =inject ('myVariableThatIWantToProvide') return { myVariableThatIWantToProvide }; } }; </script>
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "javascript, vue.js, vuejs3, vue composition api" }
VBA Referring to named range I'm just starting to used named references within my VBA, but have hit a minor problem. I have a named reference called "SiteCount" that counts the number of sites in a column =COUNTA(Data!$B:$B) It is saved as Workbook in scope and works when I use it in a cell as =SiteCount I thought I could use this in my code rather than replicate the calculation, however I can not save the value even just as Sitecount = Range("SiteCount") I have tried using the worksheet name as well, but I get the same 1004 "Method range of object global failed" I'm guessing it's something very simple. but I can't figure it out. Advice is gratefully received :)
Evaluate() should do since it's a formula name not a named range Dim siteCount as Long siteCount = Evaluate("SiteCount")
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "vba, excel" }
What does 原地踏步 mean in Cantonese? Heard this on TVB: . What does the phrase mean? There's nothing in the Cantonese dictionary for this phrase.
Actually, is not a Cantonese phrase, it's just a Chinese phrase. The literal meaning is marking time, and it's often used to describe a situation that one doesn't make progress or fall behind. > . The squad leader ordered the men to mark time. > I could either tread water until I was promoted, which looked to be a few years away, or I could change what I was doing.
stackexchange-chinese
{ "answer_score": 5, "question_score": 2, "tags": "cantonese" }
Relatório no JasperStudio com subReports Preciso criar um relatório com duas `Querys` distintas no `JasperStudio`, para isso pesquisei e vi que a melhor forma para fazer isso seria via sub relatórios porém mesmo fazendo exatamente igual a algumas vídeo aulas que encontrei no eu sempre travo no mesmo erro: ![printscreen com as telas do JasperStudio com um alet](
Como está o nome do seu subreport? Pelo erro ele não está sendo encontrado. Verifique se criou um novo report (que será o subreport) com esse nome: "subreport". Depois de criado, é preciso copilar ele, para poder ger o arquivo ".jasper".
stackexchange-pt_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jasper reports, jasper, jaspersoft studio" }
How Do I Remove My Socket Wrench Between the Idler Pulley and Wheel Well I, like an idiot, was using a socket wrench to remove the bolt from my idler pulley. I unscrewed the bolt too far, wedging the wrench between wheel well and the bolt. I could not even flip the switch to reverse the socket wrench. How can I remove the socket wrench?
I tried numerous things. This is how I finally got myself out of the predicament: I jacked up the engine and then hammered out the socket wrench. Other things I tried or thought of trying: * applying vise grips to the socket, didn't work * jamming something thin, yet strong in between the wheel well trying to switch the ratchet in reverse, didn't work * cut off the socket with a reciprocal saw, didn't work * cut off the bolt with a reciprocal saw, didn't try * fracture the ratchet head with a hammer and wedge, didn't work I'm an idiot. ## Conclusion I ended up knocking it out with a hammer. No damage was done to my car, thankfully.
stackexchange-mechanics
{ "answer_score": 6, "question_score": 4, "tags": "pulley" }
Why does fwrite write two bytes for an uint8_t? Not very skilled in C. This might be just a newbie question. I am trying to write 3 bytes to file, but end up with 4. #include <stdio.h> #include <stdlib.h> struct a { uint8_t x; uint16_t y; }; int main() { struct a record = { 1, 2 }; FILE *fp = fopen("example.bin", "w"); fwrite(&record, sizeof(struct a), 1, fp); fclose(fp); } For some reason I end up with: $ hexdump -C example.bin 00000000 01 00 02 00 |....| 00000004 I was expecting: `01 02 00`. Here is the version of my c compiler in case this is hardware/compiler related. $ cc --version Apple LLVM version 9.1.0 (clang-902.0.39.1) Target: x86_64-apple-darwin17.5.0 Thread model: posix
Structs are often padded by the compiler - empty space has been inserted after `x` so that `y` is aligned to a 16-bit boundary. GCC offers `__attribute__((packed))` to disable this behaviour; see these docs
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c, binary, posix" }