INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Prove that a Lipschitz function is continuous Define $f:[a.b] \rightarrow \mathbb{R}$ as Lipschitz By definition, then, $\exists M>0, M \in \mathbb{R}:|f(x)-f(y)\leq M|x-y|$ $ $ $\forall x,y\in[a,b]$ Rearranging this, we have $\frac{|f(x)-f(y)|}{x-y} \leq M$, positing that the slope must be finite on the interval $[a,b]$ I understand conceptually that Lipschitz functions must be continuous but I'm having trouble showing it. Should I go about this by showing assuming the negation of Lipschitz and showing that for some $\epsilon, \exists \delta>0: |f(x)-L|>\epsilon$ ?
We first show that Lipshitz continuity implies uniform continuity, from which it follows that Lipshitz continuity implies continuity, because uniform continuity implies continuity. Let $(X,d_X)$ and $(Y,d_Y)$ be metric spaces and suppose $f:X\to Y$ is Lipshitz continuous. Then exists a $K\geq 0$ such that for all $x,y\in X$, we have $d_Y(f(x),f(y))\leq K\,d_X(x,y)$. Fix $\varepsilon>0$. Choose $\delta=\frac{\varepsilon}{K}$. Then if $v,u\in X$ satisfying $d_X(v,u)<\delta$, we have $$d_Y(f(v),f(u))\leq K\,d_X(v,u)<K\delta=K\frac{\varepsilon}{K}=\varepsilon$$ If $K=0$, then choose $\delta=\varepsilon$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "real analysis, continuity" }
Create a timezone dropdown with Ember.js Are there any Ember.js addons that would make it easy to create a timezone dropdown? I'm thinking about a `Ember.TimezoneSelect` view for example. If not, then how should I go about doing it myself? One way would be to just have the timezone array in `App`: `App.timezones = [...]`. And then in the view: `{{view Ember.Select contentBinding="App.timezones"}}`. Is there a better solution? Or should I create a TimezoneController, bind the Select to one of its property, so that I could later just do an ajax request to get all the timezones, and it would update the select field?
If you're talking about IANA/Olson time zones (see here), then I would recommend against a drop-down list. There are so many, it can be overwhelming to a user. Picking the right one can be challenging. Map-based timezone pickers provide a much better user experience. Here is one in Javascript that I use a lot. See here for a live demo. If you're talking about Windows time zones, then yes - you could just return the list from `TimeZoneInfo.GetSystemTimeZones()` using the `Id` as the key of the dropdown, and the `DisplayName` as the value. I don't think you'll find anything specific to Ember in this regard, but I could be wrong.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, ember.js, timezone" }
Is "bestfriend" an acceptable spelling now? I'm a non-native speaker and I'd like to know if it has been grammatically acceptable in the UK or the US to write "best friend" as "bestfriend". I've seen such spelling used a lot on the Internet. Has "bestfriend" been considered one word instead of two (best friend)? Or is it still incorrect to spell like so?
The words best and friend combine to form a compound word, that is best friend. 'Best' is an adjective and 'friend' is a noun. So best friend is an example of an adjective/noun compound word. Bestfriend, although accepted widely is somewhere awkward. 'Best friend' should be used. Both Oxford dictionary and Merriam Webster dictionary include the word 'best friend'. It is an example of open compound word.
stackexchange-english
{ "answer_score": 1, "question_score": 1, "tags": "word choice, word usage, orthography, writing" }
How much wiggle room should I give when creating a package design? I'm designing box art for a card game but I've never really designed packages before. The layout, I think, is really simple to create, but I don't know how much room to give to let the cards slide in ant out relatively easily and to have the game instructions not too tight. the dimensions of the cards are business card size (3.5" x 2") and stacked two piles high to make the box a little thinner. So I have the front measuring 3.5"x4". I measured out the height of the two stacks to be about .78". Is there some standard or suggested measurements when making this type of packaging and how much room to give? !enter image description here
As a packaging designer, I tend to leave around 1 to 2mm around the product depending on the thickness of the material, always do prototypes and test before final production.
stackexchange-graphicdesign
{ "answer_score": 2, "question_score": 4, "tags": "packaging" }
Fix jQuery scrolling Page **must be scrolled after clicking on link with id** (let it be #link). Here is my code, which **doesnt work** : $(document).ready(function(){ $("#link").click(function () { $(this).animate({ scrollTop: 2000 }, 'slow'); }); }); But **this one works** , after the page loads it slowly scrolls to the bottom of the page: $(document).ready(function() { $('html, body').animate({ scrollTop: 6000 }, 'slow'); }); Height of the body is 6000px.
In your first example, You're setting the scrollTop of the actual link element which has nothing within it to scroll. ( no overflow ) $(document).ready(function(){ $("#link").click(function () { $("body").animate({ scrollTop: 2000 }, 'slow'); }); }); Hers's a pretty good explanation of <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "jquery, scroll" }
SQL JOIN - Map value from one table to its equivalent in another during the JOIN I have the following scenario: Table 1 - Holds product meta data about products. Table 2 - Holds sales data about the products. Each table has a unique ID for the products, however for historical reasons the ID's in the tables are different. For example: In Table 1, "Red Hat" -> 1 In Table 2, "Red Hat" -> 3. I want to join Table 2 to Table 1, and map the rows based on product ID. Is there a way to 'map' these values, so that all rows with Id 3 in Table 2 will be mapped to all rows in Table 1 with Id 1?
Use `case` statement in the join `ON` clause for mapping. **Demo.** Prepare tables: hive> create table testt1 as select 1 as key; hive> create table testt2 as select 3 as key; Join using case: select t1.key, t2.key from testt1 t1 left join testt2 t2 on t2.key=case when t1.key=1 then 3 --add more cases --when t1.key=<some value> then <mapped value> else t1.key --default mapping t1.key=t2.key end ; Result: OK 1 3 Time taken: 41.191 seconds, Fetched: 1 row(s)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "mysql, left join" }
How to reduce soft page faults by increasing the size of the working set in a .NET process? We are having problems with soft page faults interrupting our application. As a soft page fault can be caused by the act of increasing the working set for a program, is there a method to increase the working set of the program, on startup, in advance? **Update:** There is a couple of excellent answers at How to set MinWorkingSet and MaxWorkingSet in a 64-bit .NET process?. **Update:** This question is also being discussed at Is there a way to expand the current WorkingSet of a process to 1GB?
You can set the working set size using Process.CurrentProcess().MinWorkingSet. The documentation says that doing this doesn't _guarantee_ that the memory will be reserved or resident. See < for more information.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c#, .net, .net 4.0" }
Boundedness of the projection operator. Let $X$ be a Banach space. A linear operator $P :X\to X$ is called a projection if $P^{2} = P$. Show that $P$ is bounded if and only if $\ker P$ and $\text{Ran } P$ are closed.
Suppose that $P$ is bounded, it is equivalent to say that $P$ is continue, this implies that $I-P$ is continue and $Ker(P), Ker(I-P)=ran(P)$ are closed. On the other side, suppose that $Ker(P)$ and $ran(P)$ are closed, let $(x_n,P(x_n))$ a converging sequence, the sequence $x_n$ converges towards $x$ and the sequence $P(x_n)$ converges towards $y$. Let $z_n=x_n-P(x_n)$, $z_n\in Ker(P)$ The sequence $z_n$ converges towards $z=x-y\in Ker(P)$ since it is closed. We deduce that $P(x-y)=P(x)-P(y)=0$ and $P(x)=P(y)=y$ since $y\in ran(P)$. So the graph is closed and the closed graph theorem implies that $P$ is continue.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "real analysis, functional analysis, operator theory, banach spaces" }
2D Normal PDF with ggplot and R I'm trying to make a contour/image plot using ggplot but with no success til now. Consider the following piece of code in R that creates a matrix `z` with the PDF of a bivariate normal: require(mvtnorm) x1 = seq(-3, 3, length.out=200) x2 = seq(-3, 3, length.out=200) z = matrix(0, length(x1), length(x2)) for (i in 1:length(x1)) { a = x1 b = x2[i] z[,i] = dmvnorm(cbind(a,b)) } image(x1,x2,z) !2D normal pdf image plot Is it possible to plot the matrix `z` using ggplot? Thanks!
# reshape the data require(reshape2) dat <- melt(z) # use geom_raster to mimic image gg <- ggplot(dat, aes(x=Var2, y=Var1, fill=value)) gg <- gg + labs(x="", y="") gg <- gg + geom_raster() gg <- gg + coord_equal() gg <- gg + scale_fill_gradient(low="red", high="yellow") gg <- gg + scale_x_continuous(expand = c(0, 0)) gg <- gg + scale_y_continuous(expand = c(0, 0)) gg <- gg + theme_bw() gg !enter image description here You can change the axis labels pretty easily if you need to.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "r, ggplot2, contour, probability density" }
How to add html and js file to image How do I add a file to an image so when the image is clicked it runs the file? I would like when I click on a picture of a battleship it runs that game I wrote. The image is on line 30. There's two files, an html and JavaScript file. I tried looking it up myself but being so new to this I really could use some advice. Thank you! my page is josephhyatt.com if you can review it.
You can use `<img src="" onclick=functionName()/>` as @MCVNOOB said. This calls a certain function whenever the image is clicked on. If you change `functionName()` to the function that begins your game, your game will be executed when the image is clicked on.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, jquery, html, css" }
Why does a paper towel absorb water upwards? When I touch a paper towel to a drop of water I can see the water move upwards into the paper towel. What force is responsible for this gravity defying phenomenon?
Capillarity, or capillary action, occurs when intermolecular bonding between water molecules and molecules of another material is greater than the intermolecular bonding among water molecules themselves. This is called adhesion, and when it happens water will tend to spread over the surfaces of the other material, even climbing against gravity to do so. Cohesion among the water molecules will drag along those water molecules not in direct contact with the material, and surface tension will hold the water together as it adheres to the surface. Adhesion may be strong enough to raise the water against gravity. If a material is porous enough, the water can continue to climb for quite a distance. But on a smooth non-porous surface, the water will stop climbing when the weight of the cohered water is greater than the adhesion can support.
stackexchange-physics
{ "answer_score": 1, "question_score": 2, "tags": "water, capillary action" }
Make QSliders ignore mouse wheel/scrolling I have a `QScrollArea` with a set of custom sliders arranged on it. I have noticed that when trying to scroll through the scroll area, one of the sliders often ends up moving instead, which is not desirable. To make the custom sliders ignore the scroll wheel, I think I need to override `QAbstractSlider::wheelEvent` and just call `ignore` in there. This might be a silly question, but is there a way to get this behavior without deriving yet another slider-related class?
You may install an event filter on each of the sliders. When your filter receives a wheel event, just return true to filter this event out.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "c++, qt, derived class, qslider" }
How can i 'insert' a small ruby app into Ruby on Rails to make a web page? I have a small ruby application that I made on my local machine. It uses a text file insted of a database. It's a simple app that takes in a word, processes it against the text file, and then outputs the results using `puts`. I would like to fit it into a RoR framework, hosted on my personal machine. I have run through some lessons and tutorials in a few books and online materials I have, but they all involve databases. I read thru the notes in **config/environment.rb** and found at line 19 instructions to uncomment the line that removes ActiveRecord. I am currently looking for the appropriate directories to put the text file itself, and the code from the ruby app that reads this text file. Thank you.
You probably want to do something like the following: * Have a controller that takes the word as a parameter. * Turn you app into a function that takes the word as a parameter and returns the results (instead of doing puts) * Call the function from your controller and render the results (e.g. something like: render :text => my_func(word)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ruby on rails, ruby" }
GCC dependency generation for a different output directory I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me? gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP)
The answer is in the GCC manual: use the `-MT` flag. > `-MT target` > > Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletes any directory components and any file suffix such as `.c`, and appends the platform's usual object suffix. The result is the target. > > An `-MT` option will set the target to be exactly the string you specify. If you want multiple targets, you can specify them as a single argument to `-MT`, or use multiple `-MT` options. > > For example, `-MT '$(objpfx)foo.o'` might give > > > $(objpfx)foo.o: foo.c >
stackexchange-stackoverflow
{ "answer_score": 23, "question_score": 23, "tags": "c++, gcc, makefile, dependencies" }
HTML form with only hidden inputs create extra white space in FireFox I have a simple form with two hidden inputs that is causing extra white space in Firefox. I've been in trouble with this for few days. <form name="DemoForm" method="get"> <input type="hidden" name="isposted" value=""> <input type="hidden" value="2" id="SelectedTab" name="SelectedTab"></form> It is rendered in cell. After that, there is a div with content, but in firefox there is a extra white space above the div. Only in Firefox. I try to fix this putting the form in a div with display:none, its elements in div with "dispay:none" and other things that I have found in the net, but nothing help... Has anyone met this issue before?
I have fix this issue using div container with "display:none" but removing the "type:hidden" from each element. The final code looks as follows: <div style="display:none"> <form name="DemoForm" method="get"> <input name="isposted" value=""> <input value="2" id="SelectedTab" name="SelectedTab"> </form> </div> Sure, this could be useful for someone. :- ]
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "html, forms, whitespace, hidden, extra" }
Assign first item of queue to int I am trying to assign the first item of a queue to an int queue<int> q; int cur = q.pop(); put it gives me an error Types 'int' and 'void' are not compatible
It helps to read the documentation, that would have told you queue<int> q; ... int cur = q.front(); q.pop();
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -8, "tags": "c++, int, queue" }
Creating a Dynamic Horizontal Menu I'm trying to create a horizontal menu in WordPress that can be changed on the fly by non-technical users without editing the theme directly. i.e. The graphics department :). I'm a .net developer and the way I would do this in .net is to create a database with the attributes of the link, and make a user friendly back-end to display the contents with CRUD. Is there an easier way of doing this in WordPress?
I assume you're building a theme? Base your menu on the new default WordPress › TwentyTen theme's menu; it has easily configurable drop down CSS menus. For IE support, see < There are other plugins, too, that provide easy menu generation in the Admin section for themes in general: CSS Dropdown search WordPress Plugins
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "wordpress, wordpress theming" }
Connect to Outlook button missing from Sharepoint I am using IE 11 to access a Sharepoint site with a calendar. On IE 10 I could see the option to connect the calendar to Outlook, but on IE 11 this option is missing. On Windows 7, downgrading to IE 10 would solve the issue, but on Windows 8.1 I haven't found a way to downgrade to IE 10. So is there another way to link a Sharepoint calendar to Outlook?
According to the MS support site this has to do with the security settings in IE11: > 1.Open Internet Explorer > > 2.Click on Tools at the top and select Internet Options > > 3.Click the Security Tab > > 4.Click Local Intranet > > 5.Click Sites > > 6.Click Advanced and all of the intranet sites will reappear in the websites box, make sure there is a check box in the Require server verification box > > 7.Click Close > > 8.Click Ok > > 9.Click Ok [done]
stackexchange-superuser
{ "answer_score": 2, "question_score": 1, "tags": "microsoft outlook, internet explorer, calendar, microsoft outlook 2013, sharepoint" }
Please explain 要不了多久 Please help me explain how is translated into "It won't be long" Literal meaning would be "Could not demand how long?" I am not sure how works in this context.
Your confusion came from only thinking as "how" as in: * ? (how many?) * (how fast?) * (how long?) * time However, can, and mostly means "many/much" as in: * (many days) * (many people) * (much time) In , you don't see a question mark, which mean it is not a question, and here means " much" and means " long time" The structure of this phrase is: (would not take) (much) (long time) here function as " **very** "
stackexchange-chinese
{ "answer_score": 2, "question_score": 4, "tags": "grammar" }
Can the term ちわ be used as slang for こんにちわ? The term was used in a chat and I can't find the meaning.
is an abbreviated form of , when written using hiragana
stackexchange-japanese
{ "answer_score": 2, "question_score": -2, "tags": "word choice, slang, internet slang" }
malformed pdf document asks to save changes We have this big web project where the user can print the html to pdf. We are using dompdf, and have somewhat fixed the long cell issues that cause the pdf to have several blank pages. Now the issue is that the saved pdf, when closing, always asks if the user wants to save changes. I have verified that the pdf has the proper %%EOF, and have checked for object consistency. What else could be causing this problem?
After reading this introduction to pdf I realized that if the pdf was modified, I had to accomodate all the object offsets so that they would point to the object start location.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "pdf, save, eof, dompdf, malformed" }
What are directional derivatives used for in economics? In a basic mathematics for economists course one is exposed to the concept of directional derviative. Recall that a directional derivative is defined as: $$\nabla f \frac{\mathbb{v}}{\|\mathbb{v}\|}$$ I know that it mathematically tells you the direction the function is increasing on a two or three dimensional graph, however I am yet to see an application of such a formula in any economics problems. What are some applications of the directional derivative in Economics?
Recall, that the directional derivative of a function is defined as the the rate at which the function $f(x,y,z)$ at a given point $(x_0, y_0, z_0)$ changes in direction of the vector $v$, where $||v||$ is the norm of $v$1. # What comes to mind Applications of the directional derivative can be used in determining the rate of switching inputs in production functions, which can be very helpful in determining/forecasting switching costs for a given bundle of inputs. **Though it does not tell you where the optimum points are** it does tell you the rate of change (i.e. the switching costs) of moving to a different bundle. Hope this is helpful 1 <
stackexchange-economics
{ "answer_score": 1, "question_score": 3, "tags": "mathematical economics" }
A break working on all platforms > **Possible Duplicate:** > PHP Echo Line Breaks There is a `\n` for Windows and a `PHP_EOL` for UNIX (I _think_ ), but is there a break which works on every platform in a webapp? Or is the `PHP_EOL`-snippet the one I'm looking for?
yes, `PHP_EOL` is what you are looking for
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "php, windows, unix, break" }
Seeking a RegExp to replace every seventh comma by \n I have a list that looks like this: 11, 11, 12, 12, "abc", 3, 1, 25, 25, 30, 30, "def", 1, 1, ...... and I want to change it so it looks like this: 11, 11, 11, 11, "abc", 3, 1 25, 25, 30, 30, "def", 1, 1 .... So I want to replace every seventh comma by \n. I tried using sed for this but can't get it to work. Can anyone give me a hint? Thanks in advance
Try this: sed -e -r 's/(([^,]+,){6}[^,]+), /\1\n/g'
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "regex, bash, sed" }
json_encode returns invalid json format (for me) <?php $a = 'aa,ss'; $b = explode(',', $a); $c = json_encode($b); echo $c; This code is returning: ["aa","ss"] I need: {"0":"aa","1":"ss"}
JSON has two **equally valid** styles of formatting: * **Objects** * **Arrays** What you have is an array. What you seem to think as "valid" is an object. To output an object with PHP's `json_encode()`, you can do like this: json_encode($b, JSON_FORCE_OBJECT); And you will have what you want.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php, json" }
DatabaseConnecton issue in GRDB swift I would like to use SQLite database in my iOS app and there are different frameworks available. So my current focus is on GRDB and I have successfully created, inserted values, and received back with SQL commands as shown here. However, once the app is closed, how am I going to access the same `DataBaseQueue` and what should be the constant path to my database? import GRDB // Open a simple database connection if let dbQueue = try DatabaseQueue(path: "what should be the correct path ")!= nil{ setupDatabase() } else { dbQueue = DatabaseQueue() }
The GRDB FAQ answers your question: > **How do I create a database in my application?** > > The database has to be stored in a valid place where it can be created and modified. For example, in the Application Support directory: > > > let databaseURL = try FileManager.default > .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true) > .appendingPathComponent("db.sqlite") > let dbQueue = try DatabaseQueue(path: databaseURL.path) >
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, swift, grdb" }
Zu Heilig Abend, oder Zum heiligen Abend Do you say: > zu Heilig Abend or > zum heiligen Abend or > zum Heiligen Abend or something else? The usage shoud be like the example > Zu Heilig Abend gingen wir in die Kirche. I'm not sure, about the usage of _zum_ in combination with the proper name.
Most common usage: > Am/An Heiligabend gingen wir in die Kirche. _Heiligabend_ with _zu_ is not commonly used: > Zu Heiligabend gibt es bei uns immer Fisch. > An Heiligabend gibt es bei uns immer Fisch. > Am Heiligabend gab es dieses Jahr bei uns Fischstäbchen. _An_ / _Zu_ in this context is used to make a general statement true for all instances of Heiligabend or for future instances of Heiligabend. The statement above would mean that you have fish for christmas eve every time. _Am_ would mean a specific instance of a Heiligabend, in the above example the next christmas eve is bound to include fish sticks for supper/dinner. Colloquially, you could even omit the preposition and leave it up for interpretation/assumption, what you want to express: > Heiligabend gibt es bei uns Fisch. * * * Please verify whether _an_ / _am_ can be used with your intended date/event, as commentors have pointed out, _Ostern_ is not common with _an_ in some regions.
stackexchange-german
{ "answer_score": 3, "question_score": 1, "tags": "grammar, preposition" }
leanModal.js - Close Modal on X Click Need a bit of help with this query Any way you guys can help? -R
You must modify the `leanModal.js` source and add an `<img>` with some styling and `click()` handler calling `close_modal()`. **Code:** $("<img />").css({ // styling for the img 'position': 'fixed', 'top': o.top + 'px', 'left': '50%' }).click(function() { // onclick behaviour - just close it close_modal(modal_id); // icon URL vvvvvvvvvvvvvvvvvvvvv }).attr('src', ' See working code **HERE**. Styling and icon-placement is very primitive, but you should be able to modify it how you like. It is only a demonstration :).
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "javascript, jquery, modal dialog" }
Orthogonal eigenvectors of the matrix Whether there is a variable $\alpha$ such that the eigenvectors of the matrix $A$ are orthogonal? $A=\begin{bmatrix} 3&1&1\\\0&2&1\\\0&\alpha&4\end{bmatrix}$
Find the expressions for the eigenvectors in terms of alpha (I've replaced all alpha's with a's for less typing): $$v_1 = (1,0,0),$$ $$v_2 = \left(\frac{1-a+\sqrt{1+a}}{a\sqrt{1+a}}, \frac{-1-\sqrt{1+a}}{a}, 1\right),$$ $$ v_3 = \left(\frac{-1+a+\sqrt{1+a}}{a\sqrt{1+a}},\frac{-1+\sqrt{1+a}}{a},1\right). $$ Now, using the orthogonality conditions for the pairs of vectors, you should find three equations in terms of $a$ from the inner product expressions, and if any of them conflict, then there exists no such $a$. If there is one such $a$, then it is possible.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "linear algebra, eigenvalues eigenvectors" }
How to keep footer always at the bottom of a page? I have an image that is 115px that I want at the very bottom of my page. I searched online how to make it stay at the bottom of the page always and got a lot of complicated answers. I made with code of my own one that works (at least in my browser). I realize it might be an immature way to do it, and wanted to see if there were any potential problems with it. Here is my code <div id="footer" style="position:fixed;top:100%;margin-top:-115px;left:0%;repeat:repeat-x;background:url( &nbsp; </div>
you may want to consider what will happen if the body text is as long as the viewport height. The text might go behind the fixed footer and you may not be able to see it I would recommend; #footer { position: relative; margin-top: -150px; /* negative value of footer height */ height: 150px; clear:both; } then make sure to give the div wrapping all the content has a padding bottom the same as the height of the footer. #main { padding-bottom: 150px; } /* must be same height as the footer */
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "html, css, footer" }
How to properly replace a character in a string using java regex? I my java app, I have a following character sequence: `b"2` (any single character, followed by a double quote followed by a single-digit number) I need to replace the double quote with a single quote character. I'm trying this: Pattern p = Pattern.compile(".\"d"); Matcher m = p.matcher(initialOutput); String replacement = m.replaceAll(".'d"); This does not seem to do anything. What is the right way of doing this?
First off, `d` represents a literal character. You're looking for `\d`, which represents a numeric digit. The other issue is that you're replacing variable characters with the string literal `".'d"`. One solution is to _capture_ the variable portions and reference them in the replacement: String replacement = initialOutput.replaceAll("(.)\"(\\d)", "$1'$2"); Another approach is to use _lookarounds_ to check the surrounding characters without actually matching them for replacement: String replacement = initialOutput.replaceAll("(?<=.)\"(?=\\d)", "'");
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "java, regex" }
Try different odbc connect calls I would like to try to connect to a database (using odbc) where I necessarily don't know the exact password. That is, I have a couple of different alternatives what the password might be, and I want my code to figure out which one is right. How can I do this using PHP?
Just wrap the call to `odbc_connect` in a foreach loop trying all the passwords: function my_odbc_connect($dsn, $user, array $passwords) { foreach ($passwords as $password) { $connection = odbc_connect($dsn, $user, $password); if (is_resource($connection)) { return $connection; } } return false; } and then just do $connection = my_odbc_connect('blah', 'user', array('foo', 'bar', 'baz'));
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, odbc" }
Torsion subgroup of $\mathbb{Z}\times\mathbb{Z}_n$ Fix some $n\in{\mathbb{Z}}$ with $n>1$. Find the torsion subgroup of $\mathbb{Z}\times\mathbb{Z}_n$. Show that the set of elements of infinite order together with the identity is not a subgroup. I've seen a solution of this where $0\times\mathbb{Z}_n$ is the torsion subgroup, but there was no explanation. I don't understand where this comes from or what it means, and I'm not even sure what the group operation is.
The group operation for a product of groups is just "do the operations for each group separately". So if $(a, x)$ and $(b, y)$ are in $\Bbb Z \times \Bbb Z_n$, then their product* is $(a + b, x + y)$. An element $g \in G$ is "torsion" if $g \cdot g \cdots g = 1$ for some non-zero number of $g$s. If $G$ is abelian, then the set of all torsion elements forms a subgroup. This is called, naturally, the torsion subgroup. So, knowing this, what is the torsion subgroup of $\Bbb Z \times \Bbb Z_n$? What elements, when repeatedly added to themselves, eventually make their way back to $(0, 0)$? * * * *Of course, since this is abelian, we'll usually call it a sum.
stackexchange-math
{ "answer_score": 2, "question_score": -1, "tags": "abstract algebra, group theory" }
EPPlus missing dependency I added EPPlus and usage of OfficeOpenXml to my project. However, when I run my project I get this errors and warning : Warning : The referenced assembly "EPPlus" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. Errors : The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?) The type or namespace name 'ExcelPackage' could not be found (are you missing a using directive or an assembly reference?) Can someone help me figure it out?
The problem, like the warning says, is that EPPlus references an assembly (`System.Web`) that is not in the .NET v4.0 Client Framework. You might want to target the full .NET v4.0 instead of the Client framework. **Update** This has step-by-step instructions on changing the target framework for a project: < In your project that's trying to reference EPPlus, instead of .NET 4.0 Client Profile, choose .NET 4.0.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 7, "tags": "c#, epplus" }
How can I chain two rails Queries together elegantly? I have the following model object: #<Insight id: 155, endorse_id: 15, supporter_id: 15, created_at: "2011-09-22 02:27:50", updated_at: "2011-09-22 02:27:50"> Where Endorse has_many insights and Supporter has many insights. I can query the db in the following way: > > Endorse.find(15).insights.count >> >> Insight.find_all_by_supporter_id(15).count **How can I elegantly chain both of these queries together where I can search for all Insights created by Endorse 15, and Supporter 15?**
Rails2: insight_count = Insight.count(:conditions => {:supporter_id => 15, endorse_id => 15}) insights = Insight.all(:conditions => {:supporter_id => 15, endorse_id => 15}) Rails3: insight_count = Insight.where(:supporter_id => 15, endorse_id => 15).count insights = Insight.where(:supporter_id => 15, endorse_id => 15).all
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ruby on rails, activerecord, count, find" }
If $A>0$ is symmetric and has exactly one positive eigenvalue, then $a_{ij} \ge \sqrt {a_{ii}a_{jj}} \ge \min\{a_{ii},a_{jj}\}$? Let that $A\in M_n$ * $A>0$ (all $a_{ij}>0$). * $A$ is symmetric. * $A$ has exactly one positive eigenvalue. Why does $a_{ij} \ge \sqrt {a_{ii}a_{jj}} \ge \min\\{a_{ii},a_{jj}\\}$? for all $i,j=1,2,....,n$
HINT: $A$ has eigenvalues $$\lambda_1 \le \lambda_2 \le \ldots \le \lambda_n$$ and the smallest $(n-1)$ of them are $\le 0$. Using the Cauchy interlacing theorem we have that the smallest eigenvalue of any principal $2\times 2$ matrix of $A$ is $\le \lambda_{n-1} \le 0$. That implies that the determinant of such a matrix is $\le 0$ ( since the diagonal elements are $>0$)
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "linear algebra, matrices" }
Changing java service wrapper conf file property inside a pom I'm using java service wrapper in a project and want to change **wrapper.logfile.maxsize** property of the wrapper.conf file.The thing is that it would be better if I can change it inside **maven pom.xml** file. So can anyone please tell me whether this is possible and if so how to do it ? Thanx...
Use Maven Resource Plugin's Filtering feature. Let's say the line that needs to be configured by Maven looks like wrapper.logfile.maxsize=500 Replace it with: wrapper.logfile.maxsize=${wrapper.logfile.maxsize} add filtering in the `project/build/resources/resource/` section with: <filtering>true</filtering> and populate the right value from command line: mvn resources:resources -Dwrapper.logfile.maxsize="500"
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "maven, java service wrapper" }
Create a new column for Repeated elements in pandas **I have a pandas data frame like** DAYA TARIF SUBSIDI COUNT 450 B1 YES 8247 450 R1 YES 456 450 R1 NO 45 450 B1 NO 37 **CONVERT TO DATAFRAME** DAYA TARIF YES NO 450 B1 8247 37 450 R1 456 45
Try this, using `pivot_table`: import pandas as pd new = (pd.pivot_table(df,index=['DAYA','TARIF'],columns = 'SUBSIDI',values='COUNT')).reset_index() will get you: SUBSIDI DAYA TARIF NO YES 0 450 B1 37 8247 1 450 R1 45 456
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "pandas, dataframe" }
c# excel AddCanvas problem hi can you help me to find the problem at this line of my code where i try to add canvas to excel sheet from c# Line 1 Excel.Worksheet ws = (Excel.Worksheet) Globals.ThisAddIn.GetActiveWorksheet(); Line 2 ws.Shapes.AddCanvas(100,100,100,100); at line 2 it gives me exception... am i doing smth wrong? thanks a lot!
See this - < It says "This method supports the .NET Framework infrastructure and is not intended to be used directly from your code"
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, visual studio, vsto, excel 2007" }
slick plugin is not working for dynamically created content but works well for static content <div id="id1" class="scroll-footer"> <dynamically created div1></div> <dynamically created div2></div> <dynamically created div3></div> <dynamically created div4></div> </div> $(document).ready(function(){ $('.scroll-footer').slick({ slidesToShow: 2, slidesToScroll: 1, autoplay: true, autoplaySpeed: 2000, arrows: true }) }); we have added slick class to id1 div dynamically but it doesn't work? How can I add slick class after loading the dynamically created div1, div 2etc??
You need the initialise the function again while adding the dynamic element Suggest you to do this function sliderInit(){ $('.scroll-footer').slick({ slidesToShow: 2, slidesToScroll: 1, autoplay: true, autoplaySpeed: 2000, arrows: true }); }; sliderInit(); Call the function here for default load of function and call the same function `sliderInit()` where you are adding dynamic element. **NOTE** : Remember to write this function after adding the element.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 7, "tags": "jquery, jquery plugins, slick.js" }
how function that pass to sort method of array access property of object in that array? function comParison(propertyName){ return function(obj1,obj2){ var value1 = obj1[propertyName]; var value2 = obj2[propertyName]; if (value1 < value2){ return -1; }else id (value1 > value2){ return1; }else{ return 0; } } }; var data = [{name:n1},{name:n2}]; data.sort(comParison("name")); this will compare name, but how does comParison function access name property and why it have to pass as string?
Above example is based on closures. Step by step it's roughly like this: 1. `comParison` function accepts `propertyName` as an argument 2. Anonymous function created inside `comParison`, that function has access to `propertyName` and everything else inside `comParison` (and global variables). 3. This anonymous function is then returned as a sorting function 4. By the time this anonymous function is called it _still_ has access to `propertyName` variable due to closure, and is, therefore, able to access `obj[propertyName]` Hope this makes it a bit clear. Another useful answer.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, arrays, object" }
Detailed Valgrind internals documentation I'm thinking of making a D interface to Valgrind's client request API. By mucking around in the header files and de-compiling stuff, I could eventually figure out what it's doing but _I'm wondering if their is a authoritative document on how things work?_ (BTW I already found this document but it doesn't have enough info) What I'm looking for would answer questions like: How do I generate the macros to wrap/call a function that returns a 32bit machine word and takes a 64bit float?
In the valgrand manual, it describes the existing client request prototypes at the bottom of < but none of these support passing 64bit floats. You could split it into two longs and pass it that way. It does look pretty hairy. The authoritative document on how it works is the source code. If the tech docs are incomplete, then use the source. I would also suggest looking at the sources of libraries that use the client request mechanism.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "api, documentation, d, valgrind" }
Microsoft.Web.Administration on Windows XP Is it possobile to use / reference **Microsoft.Web.Administration** in Visual Studio on **Windows XP** ? I know, that is not possible to install IIS 7 on XP, but I (must) use Windows XP as a development machine.
Well technically you will not be able to, Microsoft.Web.Administration only ships with the OS (ie Windows Vista/2008, or Windows 7/2008R2). You can conceptually be able to reference it if you copy the DLL and will be able to compile, however you will NOT be able to run your application even for managing remote servers since MWA requires other objects to be locally available to work, namely a COM library that actually implements the IIS configuration system. You will need to hack a bit to try to make it work since you will need the DCOM type libraries (ahadmin), but even if you make it work, the solution will still be considered not supported.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "windows xp, visual studio, iis 7" }
Printing Time since Epoch in Nanoseconds So I know how to print time since epoch in seconds, and evidently even milliseconds, but when I try nanoseconds I keep getting bogus output of an integer that's way too small, and it sometimes prints numbers smaller than the last run. #include <stdio.h> #include <time.h> int main (void) { long int ns; struct timespec spec; clock_gettime(CLOCK_REALTIME, &spec); ns = spec.tv_nsec;; printf("Current time: %ld nonoseconds since the Epoch\n", ns); return 0; } For instance, with a run from this I got 35071471 nanoseconds since epoch. Any help with getting this to display correctly would be appreciated.
The nanosecond part is just the "fractional" part, you have to add the seconds, too. // otherwise gcc with option -std=c11 complaints #define _POSIX_C_SOURCE 199309L #include <stdio.h> #include <time.h> #include <stdint.h> #include <inttypes.h> #define BILLION 1000000000L int main(void) { long int ns; uint64_t all; time_t sec; struct timespec spec; clock_gettime(CLOCK_REALTIME, &spec); sec = spec.tv_sec; ns = spec.tv_nsec; all = (uint64_t) sec * BILLION + (uint64_t) ns; printf("Current time: %" PRIu64 " nanoseconds since the Epoch\n", all); return 0; }
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "c, time, epoch" }
How to draw a line (1D) with labeled subdivisions I want to draw a simple line with some symbols, but so far have had no luck finding an easy way to do it in _Mathematica_. Does anyone know if _Mathematica_ can easily implement e.g. the example below? !example
Just to show some basics using `Text`, and `Line`: text[s_String, s1_String, pos_] := {Text[s, {pos, .04}], Text[s1, {pos, -.04}]} tick[pos_] := Line[{{pos, .01}, {pos, -.01}}] Show[Graphics[{Line[{{0, 0}, {1, 0}}]}], Graphics[{ text["", "0", 0], text["σ2(m1)", "x/2", 1/4], text["", "x/2+1/4", 2/4], text["σ2(m2)", "x/2+1/2", 3/4], text["", "1", 1], tick /@ Range[0, 1, 1/4]}]] !Mathematica graphics
stackexchange-mathematica
{ "answer_score": 3, "question_score": 3, "tags": "graphics" }
Android: Save a photo into photo gallery I went onto Facebook in my Genymotion emulator and saved down a photo. It went into my photo gallery but I cannot find it in my Android Device Monitor. ![facebook pic]( Where is it saved in my emulator? My emulator: ![genymotion](
Via Android Device Monitor you can find your image in this path: /mnt/shell/emulated/0/DCIM/Facebook/FB_IMG_1446233000157.jpg As you can see in this screenshot: ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "android, genymotion" }
Lines in a rectangle with a specific point $P$ ![enter image description here]( I came across this interesting problem that might teach me something new. On the above diagram, $ABCD$ is a rectangle and point $P$ such that $PB = 4\sqrt{2}$, $PC = 4$ and $PD= 3$. Our goal is to find $PA$. If this was a problem that has good description I would just search up it, however, this is not easy to describe to a search engine, so here's my _actual_ question: How do you find a length of a given line that is in a rectangle connected to some point inside the rectangle and knowing how long each of the other lines connecting the rectangle's corner with the specific point? (Hopefully you didn't have a headache reading this) I suspect there is some sort of formula to figure this out, so any help would be greatly appreciated!
## Hint Draw parallel lines from point $P$ to the all four sides of the rectangle. Apply the Pythagorean Theorem four times and solve the system of equations. > You should obtain: $PB^2+PD^2=PA^2+PC^2$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "geometry, quadrilateral" }
How to specify the DNS server in host command I want to use linux `host` command to query all records (A, TXT, etc.) of a domain. I find this possible using `-a` option as in: `host -a google.com` However, I need to specify my own DNS server by its IP. I could not find any way to specify the resolver or the name server. I find this in dig as in: `dig MX google.co.uk @ns1.google.com` where the string after `@` is the name server. But I did not find a way to query all records (TXT, A, etc.) in `dig`. I prefer to use `host`. How can I specify the name server n `host` command?
Just use: `host -a google.com my.dns.server.com` host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W wait] [-m flag] [-4] [-6] {name} [server]
stackexchange-superuser
{ "answer_score": 7, "question_score": 5, "tags": "linux, networking, dns, domain name" }
How to get ID of HTML element? So the code below will get the ID of the BODY elementL var bodyId = document.body.id; How can I get the ID of the HTML element using plain ole' JavaScript?
`document.documentElement.id`
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 2, "tags": "javascript" }
iOS - Clickable UITableView with Custom Cell Good day! I have an app that has UITableView with Custom Cell in it. What i want to do is when i click on a specific row it will do an action based on what is the text on that row or cell if possible. For example. lets say this is a tableview. Flowers 12 Red Meat 30 Dry Mouse 10 Alive Pen 12 Black Then i clicked on the Meat row and i have a blank text box, it will show the text "Meat" in the Textbox or label. is that possible? thanks!
Could do something like this: Remember to have a datasource and a delegate of `UITableView` and declare your `UITextField` as a `mainTextField` property. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; mainTextField.text = cell.textLabel.text; } If you need a more complex structure, you can create `UIButtons` for each row and with a `UITableViewCell` subclass with a custom delegate you can catch the events within a custom cell.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, objective c, uitableview" }
How to enable HTTPS on a SpringBoot 2.0.5 application I need to enable HTTPS on a Spring Boot 2.0.5 application with a self-signed certificate, however, everything I've found so far in configurations is related to setting a property named `security.require-ssl=true` but it seems that on this Spring Boot version that property is deprecated... is any other way for enabling HTTPS on a Spring Boot app?
Check the Spring Boot 2.0 Migration Guide which recommends to use `WebSecurityConfigurerAdapter` instead of the `secure.*` properties. Using matchers you can have fine grained control when to enforce SSL, or just do something similar to ... http.requiresChannel().anyRequest().requiresSecure() (...) ... in your Adapter configuration to enforce _https_ for any request.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 4, "tags": "java, spring boot, groovy" }
Can I use a 15 A, 125 VAC switch to replace a 16 A, 125 VAC 1/4 HP rocker switch in my electric fireplace? ![enter image description here]( Old switch: 16A 125 VAC 1/4 HP 16A 250 VAC 1/4 HP New switch: 15A 125 VAC 1/2 HP 250 VAC 1 HP
The ratings are adequate for the job. 1500W @ 120VAC = 12.5A. Electric Fireplace load will be almost entirely resistive so we don't need to worry about HP rating. Assuming it fits safely and has similar connections and function it should be okay.
stackexchange-electronics
{ "answer_score": 3, "question_score": 2, "tags": "switches" }
Silverlight + WCF. Streaming audio and video files I am creating project using Silverlight + WCF. I'm new in both technology so any suggestion will be appreciate. My goal is to stream video and audio files with WCF and simultaneously show (play) to the client. How it can be done with these technologies? Or any tutorial or book suggestion will be appreciate.
Typically you don't use WCF, you use WMS, IIS Media Services, or plain old file transfer to accomplish this. If you need to use WCF for some reason you need a `MediaStreamSource` that hooks into your WCF service.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "c#, .net, silverlight, wcf" }
Change filenames in bulk I have 233 files where I need to change the file names. Just look for a hyphen (-) in the filename and replace the text from right of the hyphen until dot (.) to left and left of the hyphen right. Here is a sample filename and the pattern/naming convention used Name Of Movie (9999) - Name of Song.kam where 9999 is the year All files are of the same pattern. I want to reverse the order to Name of Song - Name Of Movie (9999).kam where 9999 is the year Note: In the filename, every word after a is in CAPS If it is not possible, I will have to do it manually. Can someone give me a batch script to execute this or tell me if it is possible to do? Thank you.
@ECHO OFF SETLOCAL SET "sourcedir=U:\sourcedir" FOR /f "tokens=1,3delims=)-." %%a IN ( 'dir /b /a-d "%sourcedir%\*) - *.kam" ' ) DO FOR /f "tokens=*" %%u IN ("%%b") DO ECHO REN "%sourcedir%\%%a) -%%b.kam" "%%u - %%a).kam" GOTO :EOF This should solve your problem. You'd need to change yur sourcedir of course. The required REN commands are merely `ECHO`ed for testing purposes. **After you've verified that the commands are correct** , change `ECHO REN` to `REN` to actually rename the files.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "batch file, batch rename" }
Regex picking up string that contain 2 dash I am new to regrex. Will want to pick up a list of bank number with many others text in it. The bank number can be e.g 111-123456-1 or 111-12345-1 or 111-1-123456 How should i write this regex. Thanks in advance
Use this regular expression \d+-\d+-\d+ It will match the bank numbers that you gave as examples: 111-123456-1 // Matches 111-12345-1 // Matches 111-1-123456 // Matches If you want a better understanding of the regex, check this out: < Credits to @ALFA
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -4, "tags": "regex" }
Visual Studio Workflows and Sharepoint I am new to designing workflows in Visual Studio (2010) for MOSS 2007. I have a "best practices" question: I have two separate, unrelated processes on one content type I need to manage with WFs. The first is sending and collecting approvals from users. The second is sending emails to users at 30, 60, 83, and 90 day intervals notifying them of a pending expiration of thier list item. My question is should these be handled in the same workflow by adding a parallel sequence with delay activities or should I create two workflows and attach both to the content type? It seems to me that a workflow is focused on one set of related tasks.
I have a similar scenario, and even though it would make sense to throw it all in one workflow, I would (and did) separate it out into two workflows, one for Approvals, and one for Notifications. You can handle the Notifications with Pausing the workflow, and not tie up the Approval process.
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 0, "tags": "2007, workflow, visual studio" }
Transfer a file/directory from local computer to remote computer via SSH in C? I have my local computer and I also have a remote computer. I want to make a C program that moves a file or folder to that remote computer. How can I do this in C? Or is this only possible though Terminal commands?
Depending on how complex your requirements are, you could use libssh (LGPL, used in various ssh clients), investigate modifying dropbear (MIT), or quick 'n dirty: system("scp myfile host:/some/path/to/file");
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c, ssh" }
converting std::string to double with negative values results in zero or throws an exception ## Context A number is read from an input file as a `std::string` and converted into a `double`. ## My solution I tried a variety of approaches based on what I could find on the web: std::string str = "­‐12.5799"; std::cout << str << std::endl; double d; std::stringstream(str) >> d; std::cout << d << std::endl; std::cout << atof(str.c_str()) << std::endl; std::cout << stod(str) << std::endl; ## Problem It seems to work well when positive number are read from the file, but results in strange errors and exceptions when there is a sign "-" at the beginning of the `std::string`. Output: ‐12.5799 0 0 stod I'm obviously missing something?
That is not an ordinary ASCII hyphen/minus character. It is instead the following sequence of codepoints: * U+00AD : SOFT HYPHEN [SHY] {discretionary hyphen} * U+2010 : HYPHEN Your parsing attempts are therefore failing. When in doubt, copy/paste your text into a hex editor, or an online tool such as < Always consider this as a debugging step if you encounter some mysterious problem with characters such as hyphens (which are accompanied by a myriad of visually-similar yet distinct characters). So-called "smart" quotes are another good example of characters far less innocent than they claim to be.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 1, "tags": "c++" }
Как изменить параметр в Animator c помощью кнопки интерфейса UI? не могу добавить на кнопку, запуск анимации меню, есть параметр `isOpend` нужно изменить его на `false` как это сделать ? ![введите сюда описание изображения](
У аниматора есть метод SetBool(string, bool). Этот метод принимает соответственно имя переменной и значение, которое нужно установить. Документация Unity по параметрам аниматора (с примерами изменения из кода). Напрямую из кнопки этого не сделать т.к. OnClick в инспекторе принимает только один параметр, а значит он и не сможет вызвать нужный вам метод. Следовательно у вас есть два варианта решения: 1. Создать класс, в этом классе будет ссылка на нужный вам аниматор и публичный метод, который будет менять bool на нужное вам значение. Вызывать этот метод привычным вас способом через инспектор. 2. Изучить возможность подписки на событие кнопки OnClick из кода. В этом случае вы сможете более гибко настраивать реакцию на нажатие кнопок. Вот вам соответствующая документация с примером.
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "unity3d" }
Which files should be added to version control after setting up service worker using workbox-cli After installing workbox and running the following to generate a service worker, there are 5 new files generated. I want to know which files should be version controlled or if they should be generated during the build process. * `workbox wizard` * `workbox generateSW public/SW.js` The files generated are: * sw.js * sw.js.map * workbox-config.js * workbox-ec19d65c.js * workbox-ec19d65c.js.map
`workbox-config.js` contains the configuration created by `workbox wizard`. You should check that in to version control so that you don't need to run `workbox wizard` again in the future. The other files are all build artifacts, and I'd normally recommend not checking them in to version control. They will be regenerated after each build.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "progressive web apps, service worker, workbox" }
radiobuttonfor with data- with strange behaviour i'm trying to make a checkbox with bool value from my model. it works, but now I'm trying to add some data-* field to the checkbox In order to add parameters to the nice bootstrap-switch component, and it doesn't work: <input data-val="true" id="actionList_0__efficacity" name="actionList[0].efficacity" type="radio" value="{ data_on_text = YEAH}"> And it should be <input data-val="true" id="actionList_0__efficacity" name="actionList[0].efficacity" type="radio" data-on-text = "YEAH"> so this is what I've done: @Html.RadioButtonFor(x => x.efficacity, new { data_on_text = "YEAH" } ) I already tried the EditorFor for I can't put data_ with EditorFor apparently... Thanks for the help
The html and the helper you have shown don't quite match up (the html suggests your generating radio buttons for a collection because it contains an indexer or perhaps you have an `EditorTemplate` for the type represented by property `actionList`?) but the 2nd parameter of `RadioButtonFor()` is the object that sets the 'value' attribute. You need to change the helper to @Html.RadioButtonFor(x => x.efficacity, someValue, new { data_on_text = "YEAH" } ) where `someValue` is the value that will be assigned to property `efficacity` (for example a `string` or an `enum`)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net, asp.net mvc, asp.net mvc 4, razor" }
Splitting numbers from letters I have a column that contains values such as: 7D 13M 24D 55D I want to split the values into a group of the digits and another with the letter so I can further evaluate. I am pretty close using the built in regex with this function def string_split(type: str): res = re.findall(('\d+'), type) if ["d"] in res: return "days" if ["m"] in res: return "months" right now my `re.findall` is only returning the digits and not the letters.
Don't use `re.findall()`. Your strings are always a number followed by a letter. So use a regular expression that matches just that pattern, rather than splitting it. def string_split(type: str): m = re.match('(\d+)([A-Z])', type) if m: num = m.group(1) unit = m.group(2) if unit == 'D': return num, 'days' elif unit == 'M': return num, 'months' else: raise ValueError('Invalid unit ' + unit) else: raise ValueError('Invalid interval ' + type)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "python, regex, python re" }
script to tell me who, and how many users, are online In my research to find a way to make PHP tell me how many people are 'online' on my site I've discovered that there are ways to 'estimate' this. I've chosen to log everything that happens on the site, also for error-management sake, but now i'm stuck at writing my SQL query. Basicly I have a database with 'IP', 'userid' and 'datetime' and I figured that a query like this would do the trick: SELECT distinct(IP), datetime FROM `bigBrother` WHERE datetime BETWEEN DATE_SUB(NOW(), INTERVAL 3 MINUTE) AND NOW() The problem is that my site is mostly viewed and used by students on the school network, and well... they all have the same IP. So the question is, am I doing this right, and can I select two distinct rows from my database, so that I can sort out the registered users (who will have a 'userid' - others will have userid = 0)?
Just use the session id instead of the IP.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 5, "tags": "php, sql, mysql" }
SRAM eTAP cassette compatibility I'm having trouble understanding SRAM road component compatibility "map" as they call it, specifically the cassette and rear derailleur part. ![]( For example, the PG-1130 cassette has no black box marker for the 11-28 size. What exactly does that mean? How can specific casette sizes be incompatible with ANY derailleur size (neither medium nor short)? In my specific case, I'm upgrading to eTap and since I have a spare new PG-1130 11-28 cassette with PC-1130 chain, I was going to use that, but now after checking the chart it does not make any sense to me. Anyone could explain this?
My interpretation: dots indicate availability. Bars under the cassette sizes indicate compatibility with medium and short cage derailleurs. I assume in previous years SRAM made a 11-28 PG 1130 cassette. ![enter image description here](
stackexchange-bicycles
{ "answer_score": 2, "question_score": 2, "tags": "compatibility, sram" }
Music Files not getting visible in Google Play music I am developing an app that is used to download the songs. I am able to download the songs and as the download is completed I am moving that song to a different folder programmatically. The issue that I am facing is that if I am moving song to another folder it does not become visible in google play Music and if I do not move it to another folder it is visible in Google Play Music but if the song is not moved it is getting deleted once the app is uninstalled. Please help me out what can be done to resolve this. I am stuck in this functionality. Thanks.
After searching for 3 days. I finally got the solution to this. Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "/FolderName/"+inputFile))); context.sendBroadcast(intent); I am sending broadcast to the default Google Music Library once the downloading and moving is completed.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, google music" }
How to understand the usage of "so that" in this context? > The lake froze solid and the Weasley twins were punished for bewitching several snowballs **so that** they followed Quirrell around, bouncing off the back of his turban. I'm confused by the usage of " **so that** " in this sentence. " _So that_ " usually means " _in order that_ ", but " **bewitching several snowballs** " is unnecessary for them to follow Quirrell around. In other words, they don't really have to bewitch snowballs in order to follow Quirrell around. Anyway, I may simply misunderstand what the whole sentence is trying to convey. Can someone help me to understand it? \--excerpted from Harry Potter.
It is the magic snowballs that follow Quirrell around, not the twins. They bewitched the snowball to give those snowballs the power to follow Quirrell and to bounce off his turban.
stackexchange-ell
{ "answer_score": 2, "question_score": 0, "tags": "sentence meaning, phrase usage" }
How do I change the UIView programmatically? I have created View A and View B. My window has View A displayed on the screen. I also have a UIButton on View A. I want to switch from View A to View B when I click on the Button. I am not using any UIViewController. Is it possible to switch the views without using controller? I am calling buttonAction method on TOUCHUPINSIDE The problem is that it doesn't do anything when I say [ViewA removeFromSuperView]; What should I do now?
If viewB is not in the view hierarchy: [[viewA superview] addSubview:viewB]; If viewB is in the view hierarchy: [[viewA superview] bringSubviewToFront:viewB]; Once viewB is in the view hierarchy, then remove viewA: [viewA removeFromSuperview];
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "iphone, objective c, uiview" }
Variable rows and columns in SSRS Matrix (SSRS 2008) I have a dataset with results looking like this: FUNCTION | EMP-NMB ------------------ A | 100 A | 101 A | 103 B | 102 I want to display this data in my report in this way: A | B ------------ 100 | 102 101 | 103 | I am managed to display it this way: A | B ------------ 100 | 101 | 103 | | 102 But that table becomes very large with more data. The number of employees and functions can vary. For now I am using a Matrix, but I don't know how to configure it to work the way I want.
I think the problem is that you are probably using **EMP-NMB** as you **Row Group** grouping. Since you want the report to display different ones on the same line, you need to something else. Unfortunately, there isn't anything is the data you list but you can add a **ROWNUMBER()** to the query. SELECT FUNCTION, EMP-NMB, ROW_NUMBER() OVER(PARTITION BY FUNCTION ORDER BY EMP-NMB) AS ROW_NUM FROM ... Then change the tablix **Row Group** Group On to use the new ROW_NUM field.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ssrs 2008" }
Define key when buffer is read-only I'm trying to use the keys "n" and "p" the same way as "C-n" and "C-p" when my buffer is read-only (yes, I'm lazy). I use this code in my .emacs file : (when buffer-read-only (local-set-key "n" 'next-line)) (when buffer-read-only (local-set-key "p" 'previous-line)) which is working when the buffer is automatically set as read-only (i.e. like within w3m) but it seems it doesn't work when I run C-x C-q (toggle-read-only). It keeps saying Buffer is read-only: #<buffer buffername> and I have no idea of how this could work otherwise...
Your key definitions are evaluated during load of `.emacs`, whereas you want them evaluated each time a read-only file is visited, and each time `toggle-read-only` is executed. Furthermore, you want them _undone_ whenever a buffer is made read-write again. Instead of implementing all that, you can make use of the fact that Emacs already supports automatic activation of `view-mode` in read-only buffers. All you need to do is enable that functionality, and define your keys in `view-mode-map`: (setq view-read-only t) ; enter view-mode for read-only files (define-key view-mode-map "n" 'next-line) (define-key view-mode-map "p" 'previous-line)
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 5, "tags": "emacs, dot emacs" }
Fibonacci's Code with ACM Library Hello i have a question about this code i've found in this page. I have already done the Fibonacci by my own but i think this is better. The idea is that you have to choose "n" and the code works until you reach n. It works with the first numbers, but i dont know why when i choose for example n = 70 there are negative numbers!! I dont know why this hapens but i can't resolve it, and im trying to resolve all the exercises of my book because the methods are hard to me. Sory for my poor english. public class NewFibonacci extends ConsoleProgram { int a = 0; int b = 1; public void run() { int n = readInt ("n: "); for(int i = 0; i <= n; i++) { println (fibonacci (n)); } } private int fibonacci(int n) { int c = a + b; a = b; b = c; return c; } } Thank you!
An int is limited to a certain number of bits. If you are using Java, then an int can hold 32 bits (range is from -2,147,483,648 to 2,147,483,647). Once the Fibonacci numbers get higher than the max value of an int, you're going to start seeing negative values.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, numbers, fibonacci, acm java libraries" }
VNC software, which only gives access to certain applications? I would like to give a user in a competing company access to one of our computers via VNC or similar so that he can utilize one specific application. The VNC should function in such a way that if he tries to interact with a different application, it simply will not work. Does such software exist? I know there are other, more proper ways to solve the same problem, but if such software exists, it seems like the easiest option to get started with.
Yes. It's called Windows Group Policy. It can only be done if you are running a windows server as a domain controller. Create a user in your domain, then apply a policy to it that only allows the user access to the one program. There are plenty of resources on the web to teach you how to work with group policies.
stackexchange-superuser
{ "answer_score": 2, "question_score": 0, "tags": "remote desktop, vnc, remote, remote access" }
Disable dates in pickadate (JavaScript) after enabling some specific dates I am using the pickadate library so the user can select dates. All dates should be disabled by default. This works by adding `disabled: [true]`. var myPicker=$("#inputDatetime").pickadate( { format:"dd. mmmm yyyy", formatSubmit:"yyyy-mm-dd", min:dt, selectYears:2, close:"Schliessen", today:"Heute", selectMonths:!0, disable: [true] } ), picker = myPicker.pickadate("picker"); After this I am enabling some dates: picker.set('disable', activeDays); Now I want to be able to have blacklisted weekdays. For example all mondays and all wednesdays should always be blocked. I have this data in another variable: var disabledDates = [1, 3]; How do I make sure the weekdays are disabled after that I enabled some specific dates?
See the code below: var $input = $("#datepicker").pickadate({ format: 'dd-mm-yyyy', formatSubmit: 'dd-mm-yyyy', editable: false, min: new Date(), firstDay: 0 }); var picker = $input.pickadate('picker'); picker.set("disable", [ 1, [2016, 5, 29], [2016, 6, 9], [2016, 8, 8] ]); picker.set("enable", [ [2016, 5, 19], [2016, 5, 26] ]); You can test it here: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "javascript, calendar, pickadate" }
Texture Packer pvr.ccz files Can Texture Packer's pvr.ccz files be used in a non cocos2d app? I'd like to use them with core animation. Is this possible?
Out of the box? No. You can write your own .pvr.ccz texture loader respectively adapt the .pvr.ccz texture loading code from cocos2d. The key part really is just the compression format (ccz) which uses the zlib compression provided by the iOS/Mac SDK. After inflating the compressed file, you end up with a regular PVR texture that you can use in Core Animation.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "ios, cocos2d iphone" }
Entity Framework 5 add property to join table Using EF5 and migrations. I want to add a property to my join table ProjectUser. I set up the models as below, but the migration does not generate the property. Thanks or ideas were be greatly appreciated. User { public int UserGuid { get; set; } .... public virtual IColllection<Project> Projects { get; set; } } Project { public int ProjectId { get; set; } .... public virual ICollection<User> Contacts { get; set; } } ProjectUser { public int Project_ProjectId { get; set; } public guid User_UserGuid { get; set; } public string ProjectRoles { get; set; } }
Did you remember to add ProjectUser to the DbContext? You also need to make your User and Project collections refer to the join table, not each other. EF doesn't natively support many to many relationships with payload. How do you think you would be able to access the ProjectRoles property?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "asp.net mvc, entity framework" }
how to assign a value to a variable in the template? I have the following code: <img src = "{{MEDIA_URL}} {{get_item_news.image}}" alt = "" style = "float: {% If get_item_news.inner_image_position == 'left'%} left {% Elif get_item_news.inner_image_position == 'right'%} right {% Endif%} "/> help please move if-endif block of attribute and put them before img
This should work: {% with get_item_news.inner_image_position as alignment %} <img src = "{{MEDIA_URL}} {{get_item_news.image}}" alt = "" style = "float: {{ alignment }};"/> {% endwith %}
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, django" }
Cron server and BigQuery Authentication I am trying to run a R script in `cron server` which connects to my `Big query` tables and returns some value. But it fails due to authentication problems. I get this error Error in httpuv::startServer(use$host, use$port, list(call = listen)) : Failed to create server Calls: query_exec ... init_oauth2.0 -> oauth_authorize -> oauth_listener -> <Anonymous> Execution halted Any work around for this kind of authentication related issues with `R` in `BigQuery`? I have heard of `httr`, don't know if that might solve the problem, if so any idea how do I implement it? my R script is very simple as follows: library(bigrquery) project <- "xxx" sql <- "SELECT col1 FROM [xxx:yy.zzz] LIMIT 5" query_exec(sql, project = project)
I solved it. By adding this line in the `R` script: set_service_token("/pathToTheFile/token.json") where `token.json` is a `json` file which has all your connection credentials that you can get from your google console account of bigquery. It helps to get the authentication and does the job automatically without any interaction.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r, cron, google bigquery" }
Riddle: Beyond the greatest tower > It is I all should thank > who gives you so much power > > In the age of the ankh > I was loved by the sower > > High up the firmament > beyond the greatest tower > > Be it any instant > half a world I devour Probably a little easy.
**Answer** > The sun It is I all should thank who gives you so much power > No life without the sun's energy (= power) In the age of the ankh I was loved by the sower > The Egyptian sun god Ra. The ankh was an important symbol in that era. High up the firmament beyond the greatest tower > The sun is high in the sky, way beyond mortal reach. Be it any instant half a world I devour > One half of Earth has the sun (day), the other does not (night)
stackexchange-puzzling
{ "answer_score": 4, "question_score": 5, "tags": "riddle" }
get warning of Matrix Calculation in Xcode I am now writing a code to do matrix calculation in Xcode4.3. I could build and run the code below, but I always get the warning saying, " Incompatible pointer types passing 'float (*)[3][2]' to parameter of type 'float *' " Can someone explain what that means and how I can avoid the warning? float num1[3][2] = { {1,5},{2,6},{3,7} }; float num2[3][2] = { {2,2},{2,6},{3,3} }; float resA[3][2]; vDSP_vadd(&num1, 1, &num2, 1, &resA, 1, 6); for (int i = 0; i<3; i++) { for (int j = 0; j<2; j++) { NSLog(@"resA[%d][%d]:%f",i,j,resA[i][j]); } }
Well, technically, an array is **not** a pointer, is only decays to a pointer. If you want to avoid the warning, you can use: vDSP_vadd(&num1[0][0], 1, &num2[0][0], 1, &resA[0][0], 1, 6);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "objective c, xcode, matrix" }
rml reports in openerp I use Openerp 6.0.I have a date field named x_podate in account.invoice form.In account_print_invoice report form i call the date field using the following code: <td> <para style="terp_default_6">[[ o.x_podate ]]</para> </td> and it shows the date value entered. But the problem is when the datefield is not supplied with any value the repot print out shows as False.Can someone suggest any solution for this am i missing something?
you can type in Python code between the square brackets, and then you can take advantage of Python's evaluation rules for boolean expressions. So if you want to display an empty string if `o.x_podate` is not provided, use `[[ o.x_podate or "" ]]`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, report, odoo, rml" }
SSH opening file error - no idea why Running Debian Linux - newest version. cp /included/filename /usr/bin/ It gives me error "cannot stat '/included/filename': No such file or directory I don't get why there should be an error. I am doing it as superuser.
From your latest comment i conclude you got the paths mixed up. If you want to copy the file `install.sh` located under `/usr/bin/included/` you would need to do cp /usr/bin/included/install.sh /usr/bin/ to make something similar to your provided command work, id assume you are in /usr/bin and the first argument needs to be a relative one cd /usr/bin cp ./included/install.sh /usr/bin/ Please provide more information on what you are trying to do and provide realworld example code.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -4, "tags": "ssh, file not found" }
Uninstalling Emacs on OS X (Snow Leopard) I have several versions of Emacs installed in my system, some of which do not work, and I would like to get rid of all but one (or maybe all of them and then start from scratch again). I tried looking for instructions on how to uninstall Emacs and, suspiciously enough, didn't find any. So the question is, how do I uninstall Emacs? More background info: I have macports installed, but didn't install Emacs through there; I compiled it from source (several times). For that I've used curl and cvs at different times to get the sources. I also tried with the binary from the emacs-for-mac-os-x site, but it won't let me copy it, after extracting it, to the Applications folder. Aquamacs has not been an option and I don't mind keeping it that way. Any and all help is appreciated!
Depending on how your versions of emacs were built, there are two different procedures. If you built an OS X app (Emacs.app), all you should need to do is drag the app to the trash. All of emacs' support files are contained withing the app If you just have an emacs binary sitting around, you need to delete that and the corresponding support files. For instance, the emacs binary that comes with OS X is in `/usr/bin/emacs`, and its support files are in `/usr/share/emacs`. The contents of the second directory should contain subdirs named `site-lisp` and named after version numbers (e.g., 22.1). If you want to be complete, you might want to search your disk for directories named `site-lisp` to make sure you found everything. As a side note, the version of emacs that is available through MacPorts now seems to be pretty good. I've been using it for a while, and haven't had any major issues.
stackexchange-superuser
{ "answer_score": 6, "question_score": 3, "tags": "osx snow leopard, emacs, uninstall" }
Why / When do I have to log in to Google? Installed MyDocs, I can select my Google-account and see listings of my documents, but to edit something I need to enter a password. Why is this? When does it happen? (I am constantly logged in to GMail) I use Android because all this Google stuff is supposed to be integrated! * * * **Edit** : How can i know if an app is really integrated, and won't require separate authentication.
From the reviews on that app, it sounds like they're doing part of it in their app, and part of it by sending you to the website. This may well be two separate authentications. The official Google Docs app is now part of Google Drive, have you tried that to see if it works more how you'd want? It doesn't ask me for any authentication when I use it.
stackexchange-android
{ "answer_score": 2, "question_score": 1, "tags": "google account" }
Stuck on last puzzle of level 7 The puzzle, with two moves to solve, is: !enter image description here My keyboard is: !enter image description here The nature of the puzzle dictates I get to the second `(` in a single move so that I can expend my last one moving up. (For those familiar with `vim` but not the game, my starting square is the yellow highlighted `-`.) This level is mostly about the `f`/`F`, `t`/`T`, `;` and `,` keys. The ability to recall `f`/`F` and `t`/`T` commands with `;` and `,` persists in between attempts and puzzles. Clearly I'm supposed to enter in some command, retry the puzzle, and back-peddle to the second `(` with `,` but I can't find a command that takes me there. I thought `t``3` would do the trick but when I rerun it with `,` it places me on the first `*` for some reason. I would also expect `T``3`; `;` to work but I meet with the same fate.
It turns out `%` is smart enough to know what to do in this situation.
stackexchange-gaming
{ "answer_score": 7, "question_score": 9, "tags": "vim adventures" }
How can I center align an element correctly when it contains a child element floated right? I have a heading and an image. I want them to both appear on the same line as each other. I want the heading to be aligned center and the image to be aligned to the right. My attempts so far have resulted in the following: ![enter image description here]( As you can see the heading 'Generate a URL' is pushed slightly to the left due to the image. How can I avoid this happening and keep it centered? My HTML mark up is the following: <h1 class="renault-title text-center bottom-margin-med"> Generate a URL <img class="pull-right" src="{{ asset('bundles/urlBuilder/images/renault_english_logo_desktop.png') }}" style="height:49px;" alt="Renault logo"> </h1> I am using Twitter Bootstrap. Appreciate any help.
Depending on what the rest of your HTML looks like, you could use columns. CodePen. <div class="col-md-8 col-md-offset-2"> <h1 class="renault-title text-center bottom-margin-med"> Generate a URL </h1> </div> <div class="col-md-2"> <img class="pull-right" src="{{ asset('bundles/urlBuilder/images/renault_english_logo_desktop.png') }}" style="height:49px;" alt="Renault logo"> </div>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "html, css, twitter bootstrap, alignment" }
SetOptions accepting one number variable, rejecting another number variable Gmaps APIV3 accepts my `x` variable, but rejects my `weight` variable, although both are numbers. Whats going on here? google.maps.event.addListener(map, 'zoom_changed', function() { var zoomLevel = map.getZoom(); //something between 18-12 var weight = zoomLevel - 5; var x = 3; console.log(typeof(x)); // number console.log(typeof(weight)); //number $.each(paths, function(i, path){ path.setOptions({strokeWeight: x}); //works // path.setOptions({strokeWeight: weight}); //doesn't work }) }); Added javascript as a tag because I am unsure of whether this is strictly Gmaps related or a language thing I'm unaware of. Remove it if I'm wrong.
can it be that `zoomLevel` sometimes has not the expected value(18-12) and is <6 ? If yes, `weight` would be <=0 what is an illegal value. Assign at least 1: var weight = Math.max(1,zoomLevel - 5); With a zoomLevel >5 your script works for me.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, google maps, google maps api 3" }
preg_match RegExp in beginning, inside or end of word I'm very new to this regular expression bit. I've been trying these online services but at loss. I need it explained to me how to write a pattern that match deroot, derooted, rooted and root anywhere in string when searching for 'root'
preg_match("/root/s", $input_line, $output_array); you can use this to find any string that contains `root` . demo here : <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, regex, preg match" }
How do we configure another browser to use Tor? How do we configure Google Chrome (or another web browser) to use Tor Browser? By that I mean that we are using Chrome, but the traffic is routed through Tor (and thus anonymous).
Follow these steps: 1. Download OperaTOR from here. 2. Install OperaTOR - a TOR client for the Opera browser. 3. Verify that TOR is working correctly using the pre-installed bookmark "`Are you using Tor?` 4. Start Google Chrome. 5. Using the Tools menus (it looks like a wrench), choose options, "Under the hood". Scroll down to "Network" and click the "Change Proxy Setting" button. 6. Under the "Connections" tab, choose "LAN Setting" - Select Use Proxy server and enter "Localhost" and port 8118. 7. Save your work and return to the Chrome web browser. Check that you are using TOR by going here. 8. A Green message will indicate that TOR is operating correctly. A Red message will indicate that TOR is not set up correctly. 9. Continue to surf using TOR References: * How to configure Google Chrome for Tor * How to configure Google Chrome to Tor
stackexchange-superuser
{ "answer_score": 6, "question_score": 12, "tags": "browser, proxy, privacy, tor" }
Vector memory on Program close c++ I just had a quick question about using vectors when programming in c++. If you create a vector do you need to clear it or delete it before the program closes or will the vector be deleted and the memory freed when you close the program? Thanks Steven
This depends on how you declared your vector. 1. If you use RAII (your vector is a stack object, `std::vector<...> myVec;`) 2. Or if you created it on the heap (`std::vector<...>* myVec = new std::vector<...>();`) In the first case you will not have to do anything, because as soon as the vector runs out of scope (which is always the case when the application terminates), its desctructor will be called and it will clean up its ressoruces. In the second case youll have to call `delete myVec;` so 1) the vector becomes uninitialized (the same as in the first case, destructor gets called etc.) and 2) the memory of your vector becomes freed.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c++, vector" }
Как через js записать стиль css? Я пробовал через `document.write()` записать в тег `<style></style>` стиль css, но не вышло. Как еще можно попробовать?
Сочувствуем. function addStyle() { var s = document.createElement("style"); s.textContent = ".two{background:lightgreen;}"; document.body.appendChild(s); } .one { border: 1px solid black; display: inline-block; width: 200px; height: 100px; } <div class="one two"></div> <br/> <button onclick="addStyle()">Click</button>
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, css" }
The MDK-5 (Keil-5) cannot build my project! I'm trying to build my project but the MDK-5 give me this error: !figure And also as you can see, in target you just can see Xtal. What happened? What's the problem?
Thanks to my friends, jippie and PeterJ I found the problem. the time and date of my PC had changed to past. I modified the time and the date and finally the keil works again.
stackexchange-electronics
{ "answer_score": 0, "question_score": 0, "tags": "compiler, keil" }
Pasar un array en un input por Post en php tengo este pequeño formulario que me arroja una serie de códigos pero no estoy recibiendo bien el array : <form action="" method="post" accept-charset="utf-8"> <div class="row float-right"> <input type="hidden" name="SucursalID" value="<?echo $id ?>"> <input type="hidden" name="CodigosArray" value="<? echo $ArrayCodigos ?>"> <input type="submit" style="position: relative ;" class="btn btn-primary position-realtive end-50" value="Agregar todos los productos" > </div> </form> y lo recibo con un if hice un pequeño foreach para solo ver los datos que arroja pero este no funciona dado a que el array no se manada: if (isset($_POST['CodigosArray'])) { $codigos = $_POST['CodigosArray']; foreach($codigos as $row){ echo $row; } }
Un array es un objeto de PHP, HTML no soporta ese tipo de datos. Una forma de enviarlo es serializando el array. -Edit- Me di cuenta que debido a la codificación de la serialización, HTML no escapa correctamente las comillas. Una forma de resolverlo podría ser convirtiéndo la cadena a base64. <input type="hidden" name="CodigosArray" value="<?php echo base64_encode(serialize($ArrayCodigos));?>"> Y luego lo obtienes revirtiendo: $codigos = unserialize(base64_decode($_POST['CodigosArray'])); PD. Puedes también probar con `json_encode`/`json_decode` en vez de la serialización. Y con htmlentities en vez de base64.
stackexchange-es_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, array, post" }
Should I be able to review Close Votes on a question that I have answered? Whilst doing some reviewing of the Close Vote queue, I came across a question that I just answered. I thought it was a simple question but not worthy of closing, hence I answered it. I know I could still vote to close it via the question directly, but should it show me a question from the queue that I've clearly already seen and answered? I suppose I could be bias, and say it should stay open, so it should be up to other people that haven't answered it to vote on if it should be closed. By answering it I'm indirectly saying it shouldn't be closed. Ps I've tagged this as a bug, but it might just be by design?
Servy and others have explained this rather well. Voting to close questions is _independent_ of answering them. To quote gunr2171, "If the question should be closed, regardless of the answers (even your own), it should be closed." This was discussed in the past \- quoting Mad Scientist: > I don't see this as a conflict of interest, if you answered the question you should be convinced that it is a reasonable question that should stay open, and voting in review that way would be the correct course of action.
stackexchange-meta_stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "bug, status bydesign, review queues, vote to close" }
Populate UITableView from private core data child context This is a follow up question to this one: Core Data concurrency with NSPersistentContainer I am creating `NSManagedObjects` in a child context (using `NSPrivateQueueConcurrencyType`) that I would like to display in a `UITableView` backed by an `NSFetchedResultsController` before saving them to the store. Creating the objects works, and I am fetching them from the child context. But I get a crash when I am populating the cells using the info in the managed objects. I am guessing because the objects were created on a different thread? I don't want to save the objects until the user taps the Save button. In the question above I came up with a workaround, but it feels like a hack. So how could I fix this? is it even possible to update the UI with objects from a private child context?
Make the child context a mainQueue concurrency type. Since you need to display the data in the UI it must be on the main thread.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, core data" }
How to format a double into thousand separated and 2 decimals using java.util.Formatter I want to format a double value into a style of having 1. Currency Format Symbol 2. Value rounded into 2 decimal places 3. Final Value with thousand separator **Specifically using the java.util.Formatter class** Example :- double amount = 5896324555.59235328; String finalAmount = ""; // Some coding System.out.println("Amount is - " + finalAmount); Should be like :- `Amount is - $ 5,896,324,555.60` I searched, but I couldn't understand the Oracle documentations or other tutorials a lot, and I found this link which is very close to my requirement but it's not in Java - How to format double value into string with 2 decimal places after dot and with separators of thousands?
If you need to use the `java.util.Formatter`, this will work: double amount = 5896324555.59235328; StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); formatter.format("$ %(,.2f", amount); System.out.println("Amount is - " + sb); Expanded on the sample code from the `Formatter` page.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 0, "tags": "java" }
How to parse this type of JSON Response in ios? I am new in iOS. I want to parse that type of JSON response in iOS. It's a PayPal response. I want to access all data and make to dictionary and store it for another purpose. How can i access all fields and make it dictionary? { client = { environment = sandbox; "paypal_sdk_version" = "2.0.1"; platform = iOS; "product_name" = "PayPal iOS SDK"; }; response = { "create_time" = "2014-04-12T05:15:25Z"; id = "PAY-72670124ZX823130UKNEMX3I"; intent = sale; state = approved; }; "response_type" = payment; }
You need to parse the JSON using `JSONObjectWithData:options:error:` NSData *data = responseData; // Data from HTTP response NSError *error; NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; if (!dictionary) { // An error occured - examine 'error' } NSString *responseType = dictionary[@"response_type"]; // Will extract "payment" out of the JSON NSDictionary *client = dictionary[@"client"]; NSDictionary *response = dictionary[@"response"]; NSString *paypalSDKVerion = client[@"paypal_sdk_version"];
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": -3, "tags": "ios, objective c, json" }
Using setTimeout to obfuscate a form from spam bots Not really a coding question, more theoretical and code is not needed as I know how to do it, but I'm not sure where else to ask this. I have an idea for preventing spam bots from seeing that I have a form, but I cannot test this in local code. Can I just make the form completely javascript generated, and then write it to the inner html of a tag after a one second timeout? Seems too easy so there must be some reason why this wouldn't work. I can't find where anybody tried this and tested it for a while so I don't know if it will work or not. So based on what anybody knows about how bots work, can they still see that I have a form, especially if the js is obfuscated? I would think that the bot would never wait around to receive this or detect the change in the html, but would it find the form in obfuscated js?
Google's search spider claims that it can run some/most JavaScript when it evaluates a page, so I think it is reasonable to expect that at least some spam bots can do this now, and more so in the future. Additionally, some spam bots are actually real people working for a pittance, using real browsers, so overall this will not work in the long term.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "javascript, bots, spam prevention" }
Dirac's delta composition with function Reading this I see that the statement: $ \delta \left( f(x) \right) = \sum_i \dfrac{\delta(x - a_i)}{|f'(a_i)|} $ is equivalent to showing that: $ \int_{-\infty}^{\infty} g(x)\delta \left( f(x) \right) = \sum_i \dfrac{g(a_i)}{|f'(a_i)|} $ Where $ f(a_i) = 0 \:\: \forall i $ Can somebody explain to me why these two statements are equivalent? Thanks in advance (I understand some of the proofs in that post, I just don't get why the statements are the same)
This is the definition of the Dirac delta : $$\int_{-\infty}^\infty g(x) \delta(x)dx = \lim_{\epsilon \to 0^+} \int_{-\infty}^\infty g(x) \frac{1_{|x| < \epsilon}}{2 \epsilon}dx=g(0)$$ whenever $g$ is continuous, which means $\delta(x)$ is the limit **in the sense of distributions** of $\frac{1_{|x| < \epsilon}}{2 \epsilon}$ as $\epsilon \to 0^+$. Thus it is natural to define $\delta(f(x))$ as the limit **in the sense of distributions** of $\frac{1_{|f(x)| < \epsilon}}{2 \epsilon}$ as $\epsilon \to 0^+$, which means $$\int_{-\infty}^{\infty} g(x)\delta \left( f(x) \right)dx =\lim_{\epsilon \to 0^+}\int_{-\infty}^{\infty} g(x)\frac{1_{|f(x)| < \epsilon}}{2 \epsilon}dx= \sum_{f(\alpha)=0} \dfrac{g(\alpha)}{|f'(\alpha)|}\\\=\int_{-\infty}^\infty g(x)\sum_{f(\alpha)=0} \dfrac{\delta(x-\alpha)}{|f'(\alpha)|} dx$$ whenever $g$ is continuous and $f$ is $C^1$ and has finitely many zeros.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "dirac delta" }
bash: unable to trim path with "dirname" - path is a directory According to `dirname --help`, command `dirname /usr/bin/sort` will output `/usr/bin` So I tried this: 1 #!/bin/bash 2 3 rawPath="${1}" 4 trimmed=dirname $rawPath 5 echo $trimmed And ran the script: bash ./trimPath.sh /files/data/swx_i/raw/2020/03 Output: ./trimPath.sh: line 5: /files/data/swx_i/raw/2020/03: is a directory Is it because I store the path in the variable or something else? GNU bash, version 4.1.2(2)-release (x86_64-redhat-linux-gnu)
This line: trimmed=dirname $rawPath will temporarily set the `trimmed` environment variable to be `dirname` and then try to run `$rawPath`. _That's_ what it's complaining about, the fact that you're trying to run the directory. If you want the output of that command placed in a variable, you're looking at something like: trimmed="$(dirname "$rawPath")"
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "bash, dirname" }
Adding double quotes around a string adds the closing quote on a new line I am just starting with Ruby and working on adding double quotes around a string. print "Enter the name of the file to use (including the file type)" file_name = gets.to_s puts "\"#{file_name}\"" and I get an output of "test1.txt " Any ideas on what could be going wrong are greatly appreciated. Thank you!
This doesn't have to do with the quotations you're adding, but rather that you're not using String#chomp to remove the trailing newline that is included with _every_ `gets`: gets # I type foo # => "foo\n" gets.chomp # I type foo # => "foo" You don't actually need the `to_s` here because `gets` will always return a string.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "ruby" }
Remove sqlite locking in SVN I am using svn 1.8 server and client version. We have some huge repositories for which checkout takes quite a long time in a distributed file system. Thinking of performing parallel checkouts to reduce the checkout time. However, svn 1.8 doesn't support parallel checkouts as the sqlite db inside .svn folder will be locked and will allow only one write operation at a time. Is there any way I can remove the sqlite locking to allow parallel checkouts?
SQLite has no write concurrency, and this is inherent in its design (a single database-wide lock). And Subversion cannot use any other database for the working copy metadata. You could try to reduce the locking overhead by a small amount by enabling exclusive locking. However, the easiest way to change the checkout behaviour would be to switch to another version control system like git.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "svn, sqlite" }