INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Grid with a number I know how to create a grid by using TikZ and the following: \documentclass[a4paper,10pt,table]{book} \usepackage{tikz} \usetikzlibrary{arrows,plotmarks} \def\quadrill#1{\smallbreak\textcolor{gray} {\setlength\unitlength{5mm}\begin{picture}(36,#1) \multiput(0,0)(1,0){37}{\line(0,1){#1}} \put(0,0){\line(1,0){36}} \multiput(0,1)(0,1){#1}{\line(1,0){36}} \end{picture}}\medbreak} \newenvironment{Quadrill}[1]{\quadrill#1}{} \begin{document} \Quadrill{12} \end{document} My aim is now to add a counter, for example a big number in the upper left corner area of my grids. Unfortunately, I am not able to adapt the previous code.
\documentclass[a4paper,10pt,table]{book} \usepackage{tikz,tikzpagenodes} \usetikzlibrary{calc} \newcommand{\quadrill}[2][]{\smallbreak\noindent\begin{tikzpicture}[gray] \draw (0,0) grid[step={\linewidth/36}] (\linewidth,{\linewidth/36}); \node[anchor=south west,gray] at (0,{\linewidth/36}) {#2}; \end{tikzpicture}\medbreak} \newenvironment{Quadrill}[1]{\quadrill{#1}}{} \begin{document} \Quadrill{12} \end{document} ![enter image description here](
stackexchange-tex
{ "answer_score": 1, "question_score": 1, "tags": "grids" }
Scala type inference fail? How is this possible: import scala.util.{Try, Success} import reflect._ case class FooA extends Dynamic { def get[T: ClassTag]: Option[T] = Try(x.asInstanceOf[T]) match { case Success(r) => Some(r) case _ => None } } object Foo extends App { val test = Foo("hi") val wtf: Option[Int] = test.get[Int] assert(wtf.isInstanceOf[Option[String]]) assert(wtf == Some("hi")) // how???? // val wtf2: Option[String] = wtf // does not compile even if above assert passes!! } Inspired by this question: Scala check type of generics
1. Due to type erasure, `wtf.isInstanceOf[Option[String]]` can only check that `wtf` is an instance of `Option`, but not the type parameter. Similarly, `asInstanceOf[T]` is actually a cast to `Object` at the runtime, and so it succeeds. You need to do classTag[T].runtimeClass.cast(x) instead. 2. The compiler can't use the information from asserts passing (you can imagine a compiler which _could_ , but Scala simply isn't designed like that). It only knows that the type of `wtf` is `Option[Int]`, so of course you can't initialize an `Option[String]` with it. If you want to get something like that, you need wtf match { case wtf2: Option[String] => ... } Of course, this doesn't work correctly due to point 1.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "scala, generics, type inference, scala 2.10, type erasure" }
C - Printing first letter of a string using pointers Im currently working on a project for college and i have the following function, which receives a line (string) and divides it into words: static const char separators[] = {' ','\t',',',';','.','?','!','"','\n',':','\0'}; void split(char *line){ char *token = strtok(line, separators); while(token!=NULL) { strtolower(token); printf("%s \n", token); /* rest of code belongs here */ token = strtok(NULL, separators); } } For testing purposes, I wanted to print the first letter of the string `token`, however it prints the whole string and whenever i use other methods `(*token, token[0])` it creates an error stating that `%s` expects type `*char` and not `int`. How can i print only the first letter of the string, for future implementation in my code?
Very simply: printf("%c\n", *token); or printf("%c\n", token[0]);
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 1, "tags": "c, string, pointers" }
Estimates involving a holomorphic function on the unit disc Assume that $f$ is an analytic function on the unit disc $\mathbb{D}$ and continuous up to the closure. Therefore $f(z)=\sum\limits_{n=0}^\infty c_nz^n$ for all $z \in \mathbb{D}$. If $f$ have $m$ zeros in $\mathbb{D}$ how can you prove that $$ \min\\{|f(z)| : |z|=1\\}\leq |c_0|+\ldots+|c_m| $$ To begin with, the minimum of the funcion in $|z|=1$ shold be equal to the minimun on the whole $\overline{\mathbb{D}}$. Then I tried using the mean value principle around the zeros, or the expansion near a zero, but I couldn't do it.
Let $P(z)=c_0+\dots +c_m z^m$ and $g(z)=f(z)-P(z)$. Suppose that $|P(z)|<|f(z)|$ for all $z\in\partial D$. Then the Rouche theorem says that $g$ has $m$ zeros in $D$. This is absurd; $g$ has a zero of order $m+1$ at the origin. Therefore, $|P(z)|\ge |f(z)|$ for some $z\in\partial D$.
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "complex analysis" }
can SQL insert using select return multiple identities? I am insertnig into a table using a selection INSERT california_authors (au_id, au_lname, au_fname) SELECT au_id, au_lname, au_fname FROM authors WHERE State = 'CA' say i have an identity column in `california_authors`. Can i get all the ids inserted by the above particular insertion just like i can get @@IDENTITY for last `single insertion` ? I can't use select command for `california_authors` as there may exists previously inserted records with filter `State = 'CA'`
You can use the output clause. Something like this if your identity column is named `IdentityCol' will return you id's as a result set. INSERT california_authors (au_id, au_lname, au_fname) OUTPUT inserted.IdentityCol SELECT au_id, au_lname, au_fname FROM authors WHERE State = 'CA' You can insert the id's to a table using `output ... into`. Here is a sample that stores the id's in a table variable. declare @IDs table (id int) INSERT california_authors (au_id, au_lname, au_fname) OUTPUT inserted.IdentityCol INTO @IDs SELECT au_id, au_lname, au_fname FROM authors WHERE State = 'CA'
stackexchange-stackoverflow
{ "answer_score": 29, "question_score": 12, "tags": "sql server, sql server 2008, lastinsertid" }
new line on comma within string I have an EditText view which will allow the user to edit an address field. I want any text with a comma before it to be put on a new line so for example the following: `Some St., Some City, Some post code` would be presented as: Some St., Some City, Some post code Anyone know how I could do this?
Perhaps you could perform a `String.replace()` to replace all commas with `,\n` so, String s = "Some St., Some City, Some post code" s = s.replace(",",",\n"); You then might have to do something to remove the whitespace Alternatively, to remove all whitespace: String s = "Some St., Some City, Some post code"; String strings[] = s.split(","); for(int i = 0; i < strings.length; i++){ strings[i] = strings[i].trim(); strings[i] += ",\n"; } s = ""; for(int i = 0; i < strings.length; i++) s += strings[i];
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "android" }
How to pass values from one view to 2 controllers? I am beginner with MVC .net 4 I have doubt regarding: How to pass values from one view to 2 controllers?
U can pass values from view to controller using form collection or model. U can also pass by using ajax json.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "asp.net mvc 4" }
How to "clean" an B&W image using opencv? I have a binary image, but it is all messy, I would like to know if there is a way to "clean" the image. How/what I can do to turn the first exemple image in something like the second one using OpenCV? 1. < 2. <
When working with B&W images, it is a usual practice to use image morphology. In your case you can extract connected components. You shall then leave only the large connected components. You also can erode the image, to make sure digits are not connected to any noise. However, the most robust way is to exploit OCR capabilities, since you're looking for digits. I.e. you can use your prior knowledge of how the significant areas should look like. But in your example it seems like simple morphology would be enough.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c++, image, opencv" }
Do I need to reset a DDR's DLL when I change clock frequencies? I have a system that boots at one frequency and then the main PLL is reloaded to continue boot at a higher frequency. When this is done, the DDR is put in to self refresh. After the main PLL locks, the DDR clock will change from 100Mhz to 133Mhz. It seem that the DLL inside the DDR is related to the clock frequency. Should I re-run the MRS sequences to lock again before operating at the higher frequency? Bonus: What exactly is the function of the DLL with-in the DDR? I thought everything was run off of CK/CK#. I know the host DDR controller needs some delays for latching data, but I thought DDR was designed so the RAM could be simpler. The specific DDR2 I am using is Micron MT47H32M16 and Samsung K4T51163QG-HC.
The datasheet for the RAM chips covers changing clock frequencies. For example, the Micron DDR2 datasheet says on page 40: > Operating frequency is only allowed to change during self refresh mode (see Figure 79 (page 124)), precharge power-down mode, or system reset condition (see Reset (page 125)). There are sections in the datasheet that cover each of these situations, with timing diagrams. You should read them to understand exactly what conditions you need to meet. Note also that the minimum frequency spec for DDR2 is 125 MHz. It may work at 100 MHz but it is out of spec and therefore not guaranteed. As for why DLLs, according to this article it keeps the RAM simple but moves complexity into the controller. (The author's company sells memory controller IP though so they may be biased.) Since output data is aligned to CK, a DLL is needed to manage the CK to DQ output delay.
stackexchange-electronics
{ "answer_score": 1, "question_score": 1, "tags": "clock, sdram, ddr" }
RSpec testing Time objects I have failing specs relating to time. I understand that times are calculated as seconds from epoch, but I would like this spec to pass if the object representations are close enough. For example: expect( @model.end_date ).to eq end_date expected: Wed, 08 Feb 2017 20:13:30 UTC +00:00 got: Wed, 08 Feb 2017 20:13:30 UTC +00:00 Does anyone have any advice on testing time so that a slight offset won't fail the test?
You can use RSpec's built-in `be_within` matcher, which can be also be used for floating point numbers and other data types prone to slight discrepancies: expect(@model.end_date).to be_within(1.second).of(end_date)
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "ruby on rails, rspec rails" }
Convert GMT date to timestamp I have a date formatted in this way: $data = 'lun, 19 giu 2017 16:30:00 GMT'; What I need is to convert this date, first to timestamp and after to another format, that's my code: $date = DateTime::createFromFormat(DateTime::RSS, $data); $timestamp_date = $date->getTimestamp(); $postdate = date("Y-m-d H:i:s", $timestamp_date); I get this error on the second line: FATAL ERROR Uncaught Error: Call to a member function getTimestamp() on boolean in I tried to change this value `DateTime::RSS` with many others but no results yet.
The `IntlDateFormatter` class can be used to parse international date formats: $fmt = new IntlDateFormatter( 'it_IT', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Europe/Rome', IntlDateFormatter::GREGORIAN ); $ts = $fmt->parse('lun, 19 giu 2017 16:30:00 GMT'); echo $ts, PHP_EOL, date('Y-m-d H:i:s', $ts); 1497889800 2017-06-19 18:30:00
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "php" }
Oracle sql - update case I have the following data set: ITEM | LOCATION | STATUS iPhone 13 | 10000 | Inctive iPhone 13 | 20000 | Active iPhone 12 | 20000 | Inactive iPhone 11 | 10000 | Active I first want to check on Location: 10000, what is the status and get that. If the record doesn't exist for location: 10000, it should check for Location: 20000 The Result Would be **ITEM | STATUS** iPhone 13 | Inctive iPhone 12 | Inactive iPhone 11 | Active How to do that ?
Assuming you just want to _view_ your data this way, this is a basic `ROW_NUMBER` query: WITH cte AS ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY ITEM ORDER BY STATUS DESC) rn FROM yourTable t ) SELECT ITEM, LOCATION, STATUS FROM cte WHERE rn = 1;
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "sql, oracle" }
I want to alert all p elements' text (basic jquery) I'm learning JQuery. I'm a new Jquery Student as it is seen. This is my html page: <html> <head> <title>Jquery 1</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $("document").ready(function(){ var num = 0; $("p").each(function(){ var data = data + $(this:eq(num)).html(); num =+1; }); alert(data); }); </script> </head> <body> <p> Deneme </p> <p> Deneme2 </p> </body> </html> I want to alert all p elements' text. This code not working.. How can i do?
Change the code to this: $("document").ready(function(){ var data = ""; $("p").each(function(index, element) { // note that the .each() handler has two parameters that can be used also data += $(this).html(); // "this" inside the .each() handler function is the current DOM element in the iteration }); alert(data); }); Inside the `.each()` handler function, the `this` value is the current DOM element in the iteration. Also, the `.each()` handler has two parameters on it that can also be used. `index` is where you are in the iteration (from 0 to length-1) and `element` is the current DOM element (same value as `this`). You can read more about `.each()` here.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "javascript, jquery, html" }
How to save a knn model? I need to save the results of a fit of the SKlearn NearestNeighbors model: knn = NearestNeighbors(10) knn.fit(my_data) How do you save to disk the traied `knn` using Python?
import pickle knn = NearestNeighbors(10) knn.fit(my_data) # Its important to use binary mode knnPickle = open('knnpickle_file', 'wb') # source, destination pickle.dump(knn, knnPickle) # close the file knnPickle.close() # load the model from disk loaded_model = pickle.load(open('knnpickle_file', 'rb')) result = loaded_model.predict(X_test) refer: <
stackexchange-datascience
{ "answer_score": 9, "question_score": 5, "tags": "python, scikit learn, k nn" }
Deploy a Report Builder report automatically I have created a report in Report Builder (*.rdl). I know that I can deploy that report in SSRS on the test server with transfering the report to that server and import the report by using SSRS. But, I wan't to deploy the report automatically without starting the SSRS. Is that possible? The RDL file is just an XML file so maybe there is a way to deploy that report automatically. The ultimate way for me to deploy a report is to deploy it when commiting the report to git.
Use Visual Studio to deploy your reports. Or you can use a powershell script from here <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "reporting services" }
Where to find reference about IP range of China? Is there any document that's accurate about this?
MaxMind seems to be the best amongst all IP database providers. **<
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "ip geolocation, country" }
Smooth zoom in Android MapView? I have a MapView with one overlay. Overlay renders tile based map over the MapView. I use MapView.getZoomLevel() to retrieve current zoom level for Google map and for my tiles. Everything works just perfect, but only if user don't zoom the map using multitouch gestures. As I understand, the MapView control don't render actual tiles during zooming process, but just show stretched screen content. So, the question is - How to get this scale ratio which I can use to render my tiles exactly in same way as Google do? Thank You!
Although the method `MapView.getZoomLevel()` isn't aligned with zoom changes animation and multitouche, the methods `MapView.getProjection().fromPixels()` and `MapView.getProjection().fromPixels()` are. So you have several option to adress the issue. From the methos above, you can find the direct `(x,y)` coordinates (and size) where to render the tiles or you can find the zoom ration using something like: int lonSpan = projection.fromPixels(0,mapView.getHeight()/2).getLongitudeE6() - projection.fromPixels(mapView.getWidth(),mapView.getHeight()/2).getLongitudeE6(); which gives you the longitude span at map vertical center. Then, you divide the value after zoom starts from the value before zoom starts. Regards.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android, android mapview" }
Begining with Cordova I'm begining in the world of develop with the latest version of Cordova in Windows (PhoneGap). I understand whow it works (html5,js and css to generate mobile apps) but i don't know how to use the Cordova library, how to implement code, etc I'm looking for tutorials, firsts steps but all that I found only "How to install this and how to run". Curiosly, all examples for install and run it are based on command lines, but the latest version (for windows) do itself. Can anybody help me and give me some web sites for start in this way? Regards,
To kick start your first Cordova application development, official documentation is your friend. Check out this link for getting started - <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "cordova, phonegap plugins" }
Arithmetic in Go templates I am trying to achieve a very simple thing in a Go template and failing! The `range` action allows me to iterate through an array along with its zero-based index, as so: {{range $index, $element := .Pages}} Number: {{$index}}, Text: {{element}} {{end}} However, I am trying to output indices that start counting from 1. My first attempt failed: Number: {{$index + 1}} This throws an `illegal number syntax: "+"` error. I looked into the go-lang official documentation and did not find anything particular regarding the arithmetic operation inside the template. What am I missing?
You have to write a custom function to do this. < package main import ( "os" "text/template" ) func main() { funcMap := template.FuncMap{ // The name "inc" is what the function will be called in the template text. "inc": func(i int) int { return i + 1 }, } var strs []string strs = append(strs, "test1") strs = append(strs, "test2") tmpl, err := template.New("test").Funcs(funcMap).Parse(`{{range $index, $element := .}} Number: {{inc $index}}, Text:{{$element}} {{end}}`) if err != nil { panic(err) } err = tmpl.Execute(os.Stdout, strs) if err != nil { panic(err) } }
stackexchange-stackoverflow
{ "answer_score": 54, "question_score": 39, "tags": "go, go templates" }
Here-API: How find the Air and road distance between two locations? I am using developer.here API. My endpoint is discover.search.hereapi.com/v1/discover?apiKey=###&q=delhi&at=13.08362,80.28252&limit=5 it's returning the distance. but there is no identification of the distance calculated by road or air? is there any way to send the param specifically by road, or by air?
It is by air. You can get the road distance if you use the routing API and supply your initial position and the position of the result.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "here api" }
Do we need “about” in “Employees are unhappy with about low wages”? I saw the following lead copy of today’s New York Times (May 24) article titled, “Union Effort Turns Its Focus to Target “ “The retailer's employees are unhappy with _about_ low wages and short workweeks.” I have a simple question. Do we need “ _about_ ” after "with"? Isn't this redundant?
It looks like a simple mistake. Writer originally wrote **with** , and changed it to **about** , but forgot to delete the unwanted word. Disregarding whether that conjecture is actually what happened, there's no question but that using _both_ words is incorrect. As _music2myear_ says, there are semantic/grammatic reasons for preferring **about** ; it may be these are what caused the writer to change his wording. However, it's worth pointing out that over the last 100 years there has been a significant shift in favour of **with**... !my ngram
stackexchange-english
{ "answer_score": 15, "question_score": 6, "tags": "grammaticality, prepositions" }
Finding an error estimation for central difference formula Given a central difference formula: $$f'(x)\approx D(x)=\frac{f(x+h)-f(x-h)}{2h}$$ How can I find the closest error estimation $R(x)$ such that: $$|D(x)-f'(x)|\le R(x)$$ I'm not much experienced in mathematics, so I prefer a simple and clear explanation.
If you write a Taylor expansion of $f(x + h)$ around $x$, $$ f(x + h) = f(x) + hf'(x) + \frac{h^2}{2}f''(x) + \frac{h^3}{3!}f'''(x) + \cdots \tag{1} $$ Replacing $h\to -h$ in (1) $$ f(x - h) = f(x) - hf'(x) + \frac{h^2}{2}f''(x) - \frac{h^3}{3!}f'''(x) + \cdots \tag{2} $$ Now, subtracting (1) from (2): $$ f(x + h) - f(x - h) = 2f'(x)h + 2\frac{h^3}{3!}f'''(x) + \cdots \tag{3} $$ Rearranging $$ f'(x) = \frac{f(x+h) - f(x-h)}{2h} - \frac{h^2}{3}f'''(x) + \cdots \tag{4} $$ Or $$ \left| f'(x) - \frac{f(x+h) - f(x-h)}{2h}\right| = \left|\frac{h^2}{3}f'''(x) + \cdots \right| $$
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "calculus, derivatives" }
Does moving affect incense? If I have incense active is there a difference in standing still or actively moving around? Would moving around make the incense ineffective or increase its effectiveness in any way?
Yes, it does. This is a part from game code that defines how incense works. Simply, it spawns 1 Pokémon when you walk 200 meters (1 minute minimum between 200m movement spawns) or wait every 5 minute while not moving. You can stay still and get 6 Pokémon, or get up to 30 Pokémon by moving. ![Info from game code](
stackexchange-gaming
{ "answer_score": 5, "question_score": 5, "tags": "pokemon go" }
Solving Differential Equations faster I'm currently taking a differential equations course and we've had a few quizzes and exams where I'm solving a High Order Differential Equation (non-homogeneous) and I have to stop mid-problem because what I'm currently doing will not work. (I'm talking about, for example, if the equations is $$ y''''+2y'''+2y''=3x^2 $$ then I will get the complement solution, no biggie, but when I try to get the particular solution, I do $(Ax^2 + Bx + C)$ , and after attempting to solve it, we know it won't work. So then I try $(Ax^3 + Bx^2 + C)$, and after doing the work again, STILL IT DOESN'T WORK! Not until I do $(Ax^4 + Bx^3 + Cx^2 + Dx + E)$ Does it work, BUT AFTER ALL THAT TIME I'VE LOST LIKE 7 MINUTES OR MORE AND MY EXAM/QUIZZES SCORES ARE AFFECTED. Is there a way of knowing ahead of time to start with $Ax^4....$ rather than $Ax^2$ ?
The lowest order derivative in $y'''' + 2y''' + 2y''$ is second-order. That means any $n$th degree polynomial for $y$ will result in an at most $n-2$th degree polynomial. Since your inhomogeneous term is degree 2, you need at least a fourth degree polynomial for your trial function. In general, if your differential operator has constant coefficients and lowest order $n$, and your inhomogeneous term is a polynomial of degree $m$, your trial function will need to be a polynomial of degree $n+m$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "ordinary differential equations, differential, homogeneous equation" }
How to restore default Jenkins plugins? I do a lot of testing in my Jenkins VM which I have on my local laptop. I found this time-consuming to remove Jenkins and installing again from scratch. It would be better if I have a simple way to restore my Jenkins. Is there a way to remove all the plugins that I have installed manually and keep the plugins that were installed during Jenkins installation?
One could use ansible geerlingguy.jenkins role. When this role is applied, a Jenkins system will be created without any plugins. Subsequently, one could install plugins manually, but also define them in ansible, i.e. plugins as code.
stackexchange-devops
{ "answer_score": 2, "question_score": 8, "tags": "jenkins, jenkins pipeline, jenkins plugins, jenkins2, jcac" }
difference between switch and switchcompat in android? Can someone please explain the real difference between `Switch` and `SwitchCompat`.Can I use both as toggle button. can both support lower versions of android. thanks in advance
As beardedbeast already mentioned in comment, these widgets differ from each other only by the supported API level. You can use both of them for the same purpose but not simultaneously to avoid unnecessary complication. As for known issues when using Compat widgets, there is an answer from developers.blogspot: > You don’t need to do anything special to make these work, just use these controls in your layouts as usual and AppCompat will do the rest (with some caveats; see the FAQ below). And one points, which is not mentioned there. To have correct look and behavior of `SwitchCompat` (and other Compat widgets) check if the parent `Activity` (or `LayoutInflater` which you are using to inflate Compat view) is styled with `Theme.AppCompat`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android, uiswitch, switchcompat" }
how to export the file names of several files into an excel sheet? I have a folder full of files like "stackoverflow_2010_A.gif" "stackoverflow_2010_RU.gif" etc and I would like to export the list of file names (that is "stackoverflow_2010_A.gif" etc) into an excel sheet so that I can work on them. Do you know how to proceed on windows 7? many thanks
You could create a text file with the filenames and then import it in Excel. Try this in a command prompt in the directory where the image files are located: DIR /B Stackoverflow*.gif > files.txt Edit: to add a prefix to the file names in the output file you can use the sed utility. I tested the following using GNU sed 4.2.1 for Windows which is available from here. The command will add `prefix_`to all file names. dir /b Stackoverflow*.gif | sed "s/^/prefix_/" > files.txt
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "windows, file, filenames" }
Leaky windows: How to know where the leak is? Our rented apartment has double pane windows in PVC frames. They are of good quality, I think. However, during the current weather (lots of rain and heavy winds), two windows let in some water. It seems to be coming from the bottom of the frame. How do I figure out where the water is actually going through? On the outside there are these little inlets -- I guess for allowing air exchange and letting humidity out? I have actually no idea. The inlets are tiny: about 2cm x 1cm and have a little rain cover. Could the water be getting in through this? Can a carpenter/window maker repair this?
I would suggest the opposite of wallyk. Instead of trying to back track the leak, which probably goes through sealed off areas, try to reproduce it. Dry it, then use a hose on different parts of the outside window, once you have identified what part of the window is admitting the water, look for any ingresses. You basically need to divide the possible areas the water could be coming entering into zones, and then test each zone separately. Once you KNOW which exterior zone is responsible, then you can look for cracks.
stackexchange-diy
{ "answer_score": 3, "question_score": 3, "tags": "windows, leak, rain" }
JPA Entity use index hint Is it possible to specify a database index hint on a play framework Entity query. My code looks like: public static List<Transaction> findOnInactive(Date date) { return Transaction.find( "date = ? and account in ( select d.acctNb from account d " + " where d.date = ? and (d.inactive = true or d.blocked = true)" + " group by d.acctNb )", date, date).fetch(); } Running the generated query takes 20 sec. However running the same query manually with select * from transaction with (INDEX(_dta_index_k1_1)) ... only take 1 sec. Anyway I could specify the index hint in my JPA query?
You need to use native SQL query, something like this: return JPA.em().createNativeQuery( "select * from transaction with (INDEX(_dta_index_k1_1)) ...", Transaction.class).getResultList();
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql server, hibernate, playframework, hint" }
Command injection — filtering bypass I am testing a python script that provides a ping function `os.system('ping ' + command)` all of this characters are filtered '&', ';', '-', '`' , '||', '|' i can't use null bytes like `%0A` i'm passing arguments `script.py -p` any idea how to bypass the filter to run command like `/bin/sh` or `nc -e` ?
**Use`$( )`** The `$( )` construct is equivalent to the backticks, executing the inner command: $ python -c 'import os; import sys; os.system("ping " + sys.argv[1])' '$(cat /etc/passwd > /dev/stderr)' root:x:0:0:root:/root:/bin/bash ...
stackexchange-security
{ "answer_score": 2, "question_score": 0, "tags": "injection, python, reverse shell" }
C - binary reading, fread is inverting the order fread(cur, 2, 1, fin) I am sure I will feel stupid when I get an answer to this, but what is happening? cur is a pointer to a code_cur, a short (2 bytes), fin is a stream open for binary reading. If my file is `00101000 01000000` what I get in the end is code_cur = 01000000 00101000 Why is that? I am not putting any contest yet because the problem really boils down to this (at least for me) unexpected behaviour. **And, in case this is the norma, how can I obtain the desired effect?** P.S. I should probably add that, in order to 'view' the bytes, I am printing their integer value. printf("%d\n",code_cur) I tried it a couple times and it seemed reliable.
As others have pointed out you need to learn more on endianness. You don't know it but your file is (luckily) in Network Byte Order (which is Big Endian). Your machine is little endian, so a correction is needed. Needed or not, this correction is always recommended as this will guarantee that your program runs everywhere. Do somethig similar to this: { uint16_t tmp; if (1 == fread(&tmp, 2, 1, fin)) { /* Check fread finished well */ code_cur = ntohs(tmp); } else { /* Treat error however you see fit */ perror("Error reading file"); exit(EXIT_FAILURE); // requires #include <stdlib.h> } } `ntohs()` will convert your value from file order to your machine's order, whatever it is, big or little endian.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 5, "tags": "c, binaryfiles" }
How can I access and use multiple javascript libraries? I am new to javascript and programming in general. I have been working on a web app that solves simple algebraic equations. I am using two libraries, algebra.js and katex.js. How do I use both libraries in my script? I would like to keep this as a client-side application. I have looked at node.js but my understanding is that node is for server-side development. I have looked at RequireJS but that doesn't seem to handle directories well. Recently I found Enderjs which seems to use npm and allow for client-side development and still make use of require(). What should I use to make a web app like this? Please let me know if there is anymore information that is needed.
The most basic way to do this is to include multiple script tags at the top of your html file. So: <head> <script src="path/to/library1.js"></script> <script src="path/to/library2.js"></script> <script src="path/to/my/javascript.js"></script> </head> <body> <button onclick="myFunction()">Click me</button> </body> This will load more than one onto the page. The order might matter - be wary of which dependencies your chosen libraries have. For example, some will depend on jQuery, so you should load jQuery first then those that depend on it. Order is top down. In my example, if we pretend library2 depends on library1, then the example would work. However if library1 depended on library2, it would not.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, html" }
Profiling an application that uses TopShelf I am running a .net application using TopShelf, part of which is to process and save data into a Sql Server database. I've found that the process is quite slow so I want to look into profiling the application to see if there are any major bottlenecks in terms of method calls etc, however, since TopShelf is running the application, any profiling tools I use just sit on the Run method in the main program and do not show any results from the remainder methods. Is there a way to allow a profiling tool to continue profiling past the point where TopShelf runs the application?
With Topshelf, you can run your service as a console application for debugging and profiling purposes. To do this, make sure that your service is not installed, and just run it from the console (or set it as the program to profile inside your profiler). Then once your service has run for enough time to get a good profile trace, stop it with Control+C in the console, and it will exit gracefully allowing the profiler to get a good trace. I do this all the time with dotTRACE on my system.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": ".net, profiling, topshelf" }
Count occurence of string in a series type column of data frame in Python I have a column in data frame which looks like below ![enter image description here]( How do i calculate frequency of each word. For ex: The word 'doorman' appears in 4 rows so i need the word along with its frequency i.e doorman = 4. This needs to be done for each and every word. Please advise
I think you can first flat list of lists in column and then use `Counter`: df = pd.DataFrame({'features':[['a','b','b'],['c'],['a','a']]}) print (df) features 0 [a, b, b] 1 [c] 2 [a, a] from itertools import chain from collections import Counter print (Counter(list(chain.from_iterable(df.features)))) Counter({'a': 3, 'b': 2, 'c': 1})
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, pandas" }
I have selected an html theme on theme forest which is fulfilling all my business needs. Which CMS should i go with? I have heard that drupal is not user friendly and hard to adjust with. Is it safe to use these cms?
Yes both WordPress & Drupal are safe to use as CMS. Yes WordPress might be more user friendly. You will need to get your html theme converted into WordPress theme to use WordPress as CMS for your website.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "wordpress, drupal, content management system" }
Postgres limit param, default to infinite I am passing a parameter into a Postgres query which allows the user to set the `LIMIT` of the result set. This parameter is optional and I would like to set the default `LIMIT` to infinite (no limit) but I'm not sure what to pass in this case. Would a limit of -1 be viewed as no limit?
Quote from the manual > If the count expression evaluates to `NULL`, it is treated as `LIMIT ALL`, i.e., no limit So just pass `NULL` for the limit and you'll get all rows.
stackexchange-stackoverflow
{ "answer_score": 40, "question_score": 20, "tags": "sql, postgresql" }
VirtualBox and CentOS 6, cannot connect to httpd after reboot VirtualBox and CentOS 6, cannot connect to httpd after reboot from host. if I do a **iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT** then it works but everytime I reboot I have to log in as root and do this. how can I fix this so I dont have to do it after every reboot
As Rikih said - run "service iptables save" after issuing the "iptables -I INPUT ..." command. That will save your ruleset to the /etc/sysconfig/iptables file, which is what is read at startup.
stackexchange-serverfault
{ "answer_score": 5, "question_score": 1, "tags": "iptables, centos6, httpd" }
How to set DateTime field as not required? I have an entity with a DateTime property that is not required. When the form is submitted validation fails if this feld is left blank. I have set ClientValidationEnabled = false but validation still fails.
You probably need to set the field as nullable. The `ClientValidationEnabled` is related to using JavaScript to validate the fields.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, .net, entity framework, asp.net mvc 5" }
Login Form for Angular Material I've been playing around with Angular Material and been reading through the documentation but I can't seem to figure out how to design the layout I have in mind. Essentially I want a form in which all the elements are aligned in a column and of an equal width. I'd also like all elements or the item that holds them all to have a max width of 500px, for example. And it should also be centered both vertically and horizontally on screen. Is there any way to achieve this in Angular Material? ![enter image description here](
Is this what are you trying to achieve? < **HTML:** <div layout="row" layout-align="center center" layout-fill class="outer"> <div layout="column" class="wrapper" flex> <md-input-container> <label>Placeholder</label> <input> </md-input-container> <md-input-container> <label>Placeholder</label> <input> </md-input-container> <md-button class="md-raised md-primary" flex> Primary </md-button> </div> </div> **CSS:** html, body { width: 100%; height: 100%; } .wrapper { max-width: 500px; } .outer { padding: 12px; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript, html, css, angularjs, angular material" }
Functions where critical numbers equal points of inflection My question is this. What properties does a function need to have such that it has some c that satisfies the relationship $$ f'(c) = f''(c)=0 $$ In other words what functions would have their one or more of their critical numbers equal to their points of inflection. Any polynomial function that does not have a quadratic or linear term would satisfy the relationship, but that seems trivial. [Edit] Trivial here means that the solution only includes terms that are easily manipulated at specific values such as using $sin(x)$ at $x = 0$. So $x^3-3x^2+3x-1$ is trivial because it is just $x^3$ shifted to the right one unit. This is a link to what I would consider non-trivial polynomial examples. However, I am looking for an answer that either, involves any of the following: logarithms, trigonometric, other non-elementary functions. Or a polynomial example where $f'(c) = f''(c)=0$ occurs more than once.
Take for example $\,f(x) = g(x^3)\,$ at $\,c=0\,$ for any suitably differentiable $\,g\,$. * * * [ _EDIT_ ] The most general description you can probably get is that $\,f\,$ is of the form $\,f = \int g\,$ where $\,g\,$ is a differentiable function that has a critical point $\,c\,$ where its value $\,g(c)=0\,$. * * * [ _EDIT #2_ ] More examples below. > either, involves any of the following: logarithms, trigonometric, other non-elementary functions. * $\sin(x)-x\;$ at $\;c=0$ * $\log(1+x^n)\;$ at $\;c=0\;$ for $\,\forall n \ge 3$ * $\log( 1 + \sin^2(x^2))\;$ at $\;c=0$ > Or a polynomial example where $f'(c) = f''(c)=0$ occurs more than once. * $x^6 - 9 x^5 + 33 x^4 - 63 x^3 + 66 x^2 - 36 x + 8\;$ at $\;c=1\,$ and $\,c=2$ * $(x-x_1)^{n_1}(x-x_2)^{n_2} \ldots\;$ for any distinct $\,x_1, x_2, \ldots\;$ and odd $\;n_1, n_2, \ldots \ge 3\;$
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "ordinary differential equations, functions, derivatives" }
Set legacy database in Aegir context Im fairly new to aegir and I have some hard time finding out the proper way to set a legacy database in aegir context. As far as I can see settings.php inside a platform is automatically generated so if I edit this file and run verify all changes will be lost. Other option is to insert it into drushrc file but Im still not sure what the syntax should be there. I see that database is inside the options array. Anyone with similar experience and few advice how to tackle this properly?
Such definitions can be placed in a `local.settings.php` file, alongside the generated `settings.php`. You'll find an include statement at the bottom of the generated `settings.php`
stackexchange-drupal
{ "answer_score": 2, "question_score": 0, "tags": "drush, migrations, aegir" }
Loading php file and then run function I am trying to pass some parameters to a php file and then load it on my page. After I do that I need to run a function. My problem is that jQuery runs the function before it loads the php file. I can get it working by adding a delay to my function using setTimeout(function() { addSet(id); }, 500); Instead I want it to run when my load function is done running. I have tried using $('#exer'+id).ready(function() { with no luck. This is my code function addExercise(id, name, type, factor, desc) { $("<div id='exer"+id+"' class='exer'>lala</div>").insertAfter("#beforeExercises"); var php_file = "modules/ExerciseSearchTest2/addExercise.php?id="+ id + "&name=" + name + "&type=" + type + "&factor=" + factor + "&desc=" + desc; $("#exer"+id).load(encodeURI(php_file)); addSet(id); }
`.load()` accepts a callback function to be fired only after the load has been completed. $("#exer"+id).load(encodeURI(php_file), function(){ //this is the callback function, run your code here. addSet(id); });
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "jquery" }
How to get UITableviewcell value on click on button I want to get UITableviewCell value on click of Login button. When user press on Login button then i want to fetch first cell(Email) and second cell(password) value. Please help me. !enter image description here Thanks! Shailesh
Please try to use this one.I hope it may help you. But you should assign tag 1 to email and 2 to password text field. -(IBAction)loginBtnPressed:(IBAction)sender { UITableViewCell *emailCell = [self.tblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; UITableViewCell *passwordCell = [self.tblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]] ;//pass UITextField *emailTxtFLd = (UITextField *)[emailCell viewWithTag:1]; UITextField *passwordTxtFLd = (UITextField *)[passwordCell viewWithTag:2]; NSLog(@"Email : %@",emailTxtFLd.text); NSLog(@"Password : %@",passwordTxtFLd.text); }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "ios, uitableview" }
Can jQuery UI Tabs load new complete HTML pages? I created an index.html page that have 3 different tabs. With the function `tabs()` of jQuery UI I want to load an html page with Ajax. Every HTML page use jQuery library, so every page have this code: <link type="text/css" href="css/redmond/jquery-ui-1.8.5.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.4.3.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.5.custom.min.js"></script> If I click on a tab the page is loaded but the JavaScript function of the page doesn't work! So can I load in a tab a new complete HTML page (HTML+JS)?
Ok, the problem is to understand what the tabs do. With Ajax I can load some content in a tab. If I declare a `<div>` for a tab, Ajax loads the content in that `<div>` so I can't load a new complete HTML page becouse the DOM after the load have two open `<html><head>` ecc. So now I understand the function of the Ajax in the tab, and the load of complete HTML page is a big mistake! Thanks Tobias.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, html, jquery ui, jquery, jquery tabs" }
phpstorm - @import "compass" cannot resolve I'm on Windows7, I've installed Compass and configured it correctly in my project folder. I'm new to Scss and Compass but when I launch `compass watch` from CMD my style.scss gets automatically compiled and everything seems fine. [ver. compass 1.0.1 // sass 3.4.3]. But when I open my style.scss from phpstorm `@import "compass"` comes up with an error `cannot resolve import into sass/scss`; opening up phpstorm's compass support it looks like the default options are correct: compass executable file: C:\Ruby200-64\bin\compass config path: is pointing to local server and is correct this is my watcher setting: !file watcher setting I've tried changing it but I can't get compass support to work....
Eventually the only way I found to get it working is creating a Symlink between my sass folder and my compass executable; I found an old answer on this that helped me... * * * in detail: 1.Open Cmd (as admin) and change dir to your sass folder in your project . 2.From your sass-folder create a symlink with `mklink /d compass C:\Ruby200-64\lib\ruby\gems\2.0.0\gems\compass-1.0.1\bin\compass` . Now phpstorm works fine (with default filewatchers)_
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sass, compass sass, phpstorm, compass" }
Normal states are dense in $B(H)$ Can someone explain/sketch the proof of the fact stated in the title : The set of normal states (in some $B(H)$) is weakly dense in $B(H)$ ? Or, if possible, some reference. Thank you very much.
The normal functionals of $B(H)$ can be identified with the elements of the predual of $B(H)$, which are the trace-class operators $T(H)$, via the duality $$ T(H)\ni X\longmapsto \text{Tr}(X\ \cdot). $$ So the question is why $T(H)$ is weakly dense in $B(H)$. There are several ways of proving this. The easiest is to notice that $T(H)$ contains all rank-one operators, which implies that $T(H)'=\mathbb C I$. Then $$ \overline{T(H)}^{w}=T(H)''=(\mathbb C I)'=B(H), $$ where the first equality is von Neumann's Double Commutant Theorem. Note that the assertion as stated in the title cannot be true: weakly limits of positives are positive, so only positive operators can be limits of normal states.
stackexchange-math
{ "answer_score": 4, "question_score": 2, "tags": "operator algebras" }
Как сделать выемку в линии на css? !введите сюда описание изображения Подскажите, пожалуйста, как сделать такую линюю на css?
div { height:10px; width:300px; margin:0 auto; border-bottom:3px solid purple; position:relative; } div:after{ content:''; width:10px; height:10px; position:absolute; left:50%; bottom:-13px; transform:rotate(45deg) translateX(-50%); border-bottom:3px solid purple; border-right:3px solid purple; background-color:#fff; } <div></div>
stackexchange-ru_stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "html, css, css3, html5" }
How to use foreach in PHP? I am trying to write my below code using `foreach` statement in PHP. I just started with PHP so still learning. $myarray = array ("Hello World", "Hello Tree", "Hello, Proc!"); for($i = 0; $i < count($myarray); $i++) { $myarray[$i] .= " ($i)"; } How can I do this?
$myarray = array ("Hello World", "Hello Tree", "Hello, Proc!"); foreach($myarray as $key => &$item) { $item .= " ($key)"; } `&$item` makes the $item a pointer instead of a copy of the array item. So any changes you make to $item will be reflected in the original. `$key` is equivalent to your array index counter `$i`. See the foreach reference for more information.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "php" }
How to access last upgrade date and version in postgres Is there any way i can get information about upgrades, downgrades performed on a postgres 12.3 database : such as the last upgrade date and version ? I'm thinking of something that mimicks DBA_REGISTRY_HISTORYin oracle
In general there are no "patch set" or "service pack" for PostgreSQL but only full releases: every quarter a new release that includes bug fixes is released (see < To install these new releases executables are just replaced as a whole: no patching of current executables is done and this change for related instances and databases is not registered in any system catalog.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "postgresql, upgrade" }
Rails Catchall Route (app allows username in URL) I have a simple blogging app where a user's username is part of the URL (i.e. myapp.com/username). How do I create a catchall route for all usernames not found. Currently, an invalid username causes: NoMethodError in UsersController#show undefined method `articles' for nil:NilClass I'd like that to redirect to the 404 page.
Try this one Write following function into your application controller def not_found raise ActionController::RoutingError.new('Not Found') end Then write down something as below into your users controller User.find_by_username(params[:username]) || not_found Hope, this will help you.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ruby on rails" }
What is rails stack? I've run into _rails stack_ term for many times but I still can't get what do people call _rails stack_ furthermore what is a _good knowledge of the rails stack_?
A "rails stack" refers collectively to all the software needed to run a webapp using Ruby on Rails, most importantly: * Operating system * Webserver * Ruby implementation * Rails itself * Database You'll also often see more project-specific libraries mentioned (e.g. here). This means that the expression "knowledge of the rails stack" is misleading, because different Rails projects may use quite different stacks. What is probably meant is "knowledge of Rails as well as various frameworks and libraries commonly used with Rails".
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 4, "tags": "ruby on rails, ruby on rails 3, ruby on rails 3.1" }
Body falling off a smooth hemisphere - simple but I'm missing something. What is it? So here's the question that I'm stuck on. > A particle slides from the top of a smooth hemispherical surface of radius $R$ which is fixed on a horizontal surface. If it separates from the hemisphere at a height $h$ from the horizontal surface the speed of the particle when it leaves the surface is: I can simply apply Conservation of Mechanical Energy(or Work-Energy Theorem, if you think like that) and get the first option as my answer =$ \sqrt{2g(R-h)}$ But, if I make a free body diagram at any arbitrary angle from the vertical I make the following equation- $mg\cos(x) - N= (mv^2)/R$ The particle leaves the surface when $N=0$ This gives us $v=\sqrt{Rg\cos(x)}$ and as $R\cos(x) =h\Rightarrow v=\sqrt{gh}$, which isn't an option. Maybe I'm missing some concepts about circular motion and I can't understand what it is? Please help.
Actually, both of them are true! The one with $$v=\sqrt{2g(R-h)}$$ and $$v=\sqrt{gh}$$ But How? See the leaving condition $$mg\cos\theta =\frac{mv^2}{R}\Rightarrow \cos \theta =\frac{v^2}{Rg}$$ and from the energy conservation at two points $$v^2=2g(R-h)$$ $$\Rightarrow \cos\theta =\frac{2(R-h)}{R}$$ If you look at the diagram, You will find from simple geometry that $$\cos \theta =\frac{h}{R}=\frac{2(R-h)}{R}$$ $$\Rightarrow h=\frac{2R}{3}$$ If you put this into both of the expressions for $v$, You find the same result. $$v=\sqrt{\frac{2}{3}Rg}$$
stackexchange-physics
{ "answer_score": 2, "question_score": 0, "tags": "homework and exercises, newtonian mechanics, forces, energy conservation, free body diagram" }
how to display web browser console in a webpage I just want to create the same replica what we have seen on the web console, there is any option for that? I am making a debugging tool so I want to show all the error messages using console.log(). Currently, users can only view the errors by looking into the console by inspecting, i want to directly display all console things into a webpage
**It will print whatever in console inside div tag.(ERROR FIXED!)** <html> <head> <title>Console In Webpage</title> <script src=" </head> <body> <div class="output"></div> <script language="javascript"> var realConsoleLog = console.log; console.log = function () { var message = [].join.call(arguments, " "); $(".output").text(message); realConsoleLog.apply(console, arguments); }; console.log("hello", "my", "name", "is", "shantharuban"); </script> </body> </html>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, html, google chrome, console" }
Why is $\vec a\downarrow\vec c=\vec a\downarrow(\vec b\downarrow\vec c)$? I know how to draw a driagram to show that it's true, but I can't really explain it mathematically / algebraically. This is about projection vectors, if the notation is unclear. EDIT: This is the notation I've learned, but after having read about more standard notation, I see that more people would prefer it this way: $$Proj_\vec c\vec a=Proj_{proj_\vec c\vec b}\vec a$$
The projection can be written as $$\vec a \downarrow \vec c=\frac{\vec c\cdot \vec a}{\vec c \cdot \vec c}\vec c$$ What do you get if you let $\vec c=\vec b \downarrow \vec c$?
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "vectors" }
jNIce - stop executing I'm using jNice to enhance some forms on my site. jNice is called by adding class to the form (). My question is - **how can I stop jNice from convering the form only in some parts of the form**?? I cannot see this option on the spec. Any help much appreciated. Pete
Found the way of changing calling of the jNice script: In one before last line of the script we have: $(function(){$('form.jNice').jNice(); }); if we change that to (form - > div(or whatever we want)) $(function(){$('div.jNice').jNice(); }); That way we can call jNice on whatever we want(element wrapper or element it self). Reg
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, jquery plugins" }
How could I calculate this sum of series Could you please help me to calculate this finite sum ? \begin{align} S=\sum _{n=1}^{\text{Nmax}} n*P^n \end{align} where $P\leq 1$ and $\text{Nmax}>1$.
$$S=P.\sum_{n=1}^N nP^{n-1}=P.\frac{d}{dP}\sum_{n=1}^NP^n=P.\frac{d}{dP}\frac{P(1-P^N)}{1-P}$$ So $$S=\frac{(1-P)(1-(N+1)P^N)+P(1-P^N)}{(1-P)^2}$$ Simplify to get the answer. Another way to do this ( and this does not need derivatives ) is $$S=1.P+2.P^2+3.P^3\cdots +(N-1)P^{N-1}+N.P^N$$ Now $$S.P=1.P^2+2.P^3\cdots+(N-1)P^N+(N+1)P^{N+1}$$ So $$S-SP=P+P^2+P^3+\cdots+P^N+(N+1)P^{N+1}$$ Which implies $$S(1-P)=\frac{P(1-P^N)}{1-P}+(N+1)P^{N+1}$$ Now simplify to get the value of $S$
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "sequences and series, power series, divergent series" }
how to disable macOS prompt menu animation(or add speed)? In most apps macOS, there is a prompt menu, e.g. when I saving files by a TextEdit, this prompt will show, and there is an animation, I don't want the animation, since its somehow slow, how to disable or add speed of this? I've searched, that I can check "reduce motion" in "accessibility", but this will eliminate all animations such as mission control animation(four-finger swipe up), and I don't want to disable mission control animation, how to achieve this? the prompt menu
The UI element you're calling a "prompt menu" is officially known as a "sheet" in macOS UI terminology. Sheets are a kind of dialog box that are drawn as emerging from a window's title bar. The "Save" sheet is one of the most common sheets users see. From Super User's sister site apple.stackexchange.com, a.k.a "AskDifferent": How to turn off all animations on OS X < # showing and hiding sheets, resizing preference windows, zooming windows # float 0 doesn't work defaults write -g NSWindowResizeTime -float 0.001 I tried it in macOS Mojave 10.14.6 and it works. Apps that are already running will not get the change until you quit and re-launch them.
stackexchange-superuser
{ "answer_score": 2, "question_score": 1, "tags": "macos, macos mojave, osx leopard, macos sierra, macos catalina" }
I don't see vlc in app store I don't see vlc or inkscape in the app store. They are installable with synaptic. Is this a bug? It seems that many things are not there. These apps are standard. I thought the USA repository was athe problem so I switched to Using main Ubuntu repo. The problem is still there. Eos 5.1
the appCenter has a search input on the topper right corner. Type inside `vlc` or `inkscape` and you will find both of them. ![vlc]( ![inkscape](
stackexchange-elementaryos
{ "answer_score": 1, "question_score": 0, "tags": "appcenter" }
Character theory - Exercise5.12 (Martin Isaacs) This asks: Let $\varphi^{G} = \chi \in {\mathrm{Irr}}(G)$ with $\varphi \in {\mathrm{Irr}}(H)$. Show that $Z(\chi) \subseteq H$. Here is my solution: Fix a right coset transversal $T$ of $H$ in $G$ with $1 \in T$. Let $x \in Z(\chi)$. Then $$|\varphi^{G}(x)| = \varphi^{G}(1) = |T| \varphi(1)$$ and $\varphi^{G}(x) = \sum_{t \in T} \varphi^{\circ}(txt^{-1})$. If $T(x) = \\{ t \in T ~:~ txt^{-1} \in H \\}$, then by triangle inequality we have $$|T| \varphi(1) = |\varphi^{G}(x)| = |\sum_{t \in T(x)} \varphi(txt^{-1})| \leq |T(x)| \varphi(1)$$ This proves $|T| \leq |T(x)|$ and hence $T(x) = T$. Therefore $txt^{-1} \in H$ for every $t \in T$. In particular, we have $x \in H$. I fail to see where am I using any of the characters are irreducible. Any idea?
Your proof is OK and yes you do not need $\chi$ being irreducible. Analogous to $(5.11)$ Lemma in Isaacs' book one can prove that if $\varphi$ is a character of a subgroup $H$ of $G$, then $$core_G(Z(\varphi))=Z(\varphi^G)=\bigcap_{x \in G}Z(\varphi)^x.$$ It follows that $Z(\varphi^G) \subseteq H$.
stackexchange-math
{ "answer_score": 2, "question_score": 5, "tags": "group theory, finite groups, representation theory, characters" }
How to change file parmater by input in bash I have a file that contain this line SELINUX = enforce I want to change this by given input to permissive How i do that without demage?
If [[ "$1" == "Y"]] then sed -ri 's/(^.*SELINUX=)(.*$)/\1enforce/' file else sed -ri 's/(^.*SELINUX=)(.*$)/\1permissive/' file fi If the first passed parameter ($1) is equal to "Y" use sed to split SELINUX line into to 2 sections. Substitute the line for the first section followed by "enforce". If the passed parameter is not "Y" substitute the line for the first section followed by "permissive".
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "linux, bash, unix, vim, linux kernel" }
How to use Toast when I cant use "this" as context I have a location listener activity and I want to make toast notifications. But it will not let me pass `this` as the context. How should I make toast work?
If the toast is located inside your activity class, you could use `YourActiviy.this` where `YourActivity` is the class name. If it's outside your class, you'll need to get your activity context (pass it in the constructor etc).
stackexchange-stackoverflow
{ "answer_score": 26, "question_score": 21, "tags": "java, android, toast" }
How to handle any iterator without putting the code in the header file? Here is the problem: Header file (part of a library's API): template <typename IterType> void foo(const IterType &begin, const IterType &end); CPP file: template <typename IterType> void my_really_large_implementation_specific_function(const IterType &begin, const IterType &end) { // ... } Is is possible to make `foo()` call `my_really_large_implementation_specific_function()` without including `my_really_large_implementation_specific_function()`'s code in a header file and without making more than one instance of its template? Maybe using some kind of wrapper iterator class, but I'm not sure how.
If you want your function to be able to operate on arbitrary iterator types then the body needs to appear in the header. If you need to support only one iterator type then it doesn't need to be a template and can appear in the source file.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, templates, stl, iterator" }
Are all kinds of cookie signed and thus cannot be altered or only session cookie in Play? In the documentation it says that Play signs the session cookie so that the client cannot alter the session information. However, it doesn't not mention anything about non-session cookies. So my question is, does Play sign all kinds of cookies or only the one for sessions?
It only signs the one for session check < the signed field is defaulted to false. On the other side for the session it's defaulted to true: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "security, session, cookies, playframework, playframework 2.0" }
Prove the positive sequence $a_{n+1} = \sqrt{1+\frac{a^2_n}{4}} $ is strictly increasing for $0 \leq a_0<\frac{2}{\sqrt{3}}$ My attempt: $a_{n+1} - a_n= \sqrt{1+\frac{a^2_n}{4}} -a_n > \frac{a_n}{2}-a_n = -\frac{1}{2}a_n$, which doesn't tell me any thing. How do I prove that this sequence is strickly increasing? Thank you!
$a_n^2=1+\frac{a_{n-1}^2}{4}=\frac{1}{4}\left(4+a_{n-1}^2\right)=\frac{1}{4^2}\left(4^2+1\cdot4+a_{n-2}^2\right)=\frac{1}{4^3}\left(4^3+4^2+4+a_{n-3}^2\right)$ Hence, a recursive formula can be written as follows: $$ a_{n+1}^2=\frac{1}{4^n}\left(4^n+4^{n-1}+...4+a_1\right)=\frac{4}{3}\cdot\frac{4^n-1}{4^n}+\frac{a_1^2}{4^n}$$. $\therefore\lim\limits_{n\to\infty}a_n=\frac{2}{\sqrt3}$ irrespective of the choice of $a_1$. Also $a_{n+1}^2-a_n^2=\frac{4-3a_n^2}{4}>0 \forall a_n<\frac{2}{\sqrt3}$. Can you do the rest?
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "real analysis" }
Is はおる a commonly used verb > ...... > ...she put on a dress suitable for the trip and while putting on her coat... I've not seen the verb before and it does not appear in any of my more basic dictionaries. Is it a commonly used word for putting on an item of clothing or is it a more obscure word that was used to avoid repeating ? Basically, would I sound weird if I used it in everyday conversation? For what items of clothing can it be used?
and are somewhat close **but not the same words**! () means **to wear clothes over another, as if you're covering them.** So I'd say someone "" his/her coat when they do so _without closing its zipper / buttons._ It's kind of hard to explain in words, but **there's a very similar word** {}, which is a noun. is similar to coat. Try googling how they look like. Notice there's no zippers or buttons or _obis_ closing the front? The word originates from this kind of clothing. It is to wear clothes like . So you **can't** use against clothes whose 'front' can't be kept opened (T-shirts for example). And as long as you're catching the meaning of which I explained, it is fine to use in everyday conversation.
stackexchange-japanese
{ "answer_score": 19, "question_score": 22, "tags": "words" }
Flow wait Element time frame When I am using a wait element in a flow, what are some of the options I could use for the time frame? I don't see it clearly explained anywhere, but all the documentation seems to indicate waiting days to continue a flow. I'm wondering if you can set it to wait 30 seconds or 1 minute.
Days or hours are your options See offset unit on relative or absolute time alarms under the flow event type documentation page Where they say Manually enter Days or Hours. You can’t use a merge field or flow resource for this value.
stackexchange-salesforce
{ "answer_score": 1, "question_score": 0, "tags": "visual workflow, wait element" }
Save spreadsheet ID to model using Drive Picker I would like to use the Driver Picker widget to select a spreadsheet and save the file ID of the spreadsheet to a data model. I have the selectedDocUrl field of the Drive Picker set to the fileID column in my model (`@datasource.item.fileID`) but as expected this saves the entire URL of the file to the model. I am looking to capture the file ID only. **Full URL:** ` **File ID:** `1Q4z5ZsE5eDm14MysAdb-CnApSNlzToMdXTTCgrN6BNA`
Use the **onDocumentSelect** event handler of the drive picker and do the following: widget.datasource.item.fileID = result.docs[0].id; Keep in mind that the above will work if the datasource is properly binded.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "google app maker" }
Angular $timeout for delay I want the browser to wait for 3 seconds before executing the next line of code. $timeout(3000); in script is not seeming to do the trick. Am I doing anything wrong here. I use it inside a $scope function app.expandController = function ($scope,$interval, $timeout) { $scope.nextLevel = function () { //stop numbers $scope.StopTimer(); $timeout(function(){return true;},3000); //restart timer with new numbers $scope.StartTimer(); $scope.thresholdwatch == false } } and I split controller file by passing $scope and $timeout to another function app.controller('myCtrl', function ($scope, $interval, $timeout) { app.expandController($scope, $interval,$timeout); });
If you are using `$timeout` you need to place your next executing code in timeout callback. But a simple hack with vanila js would be, function sleep(ms) { var dt = new Date(); while (Date.now() - dt.getTime() <= ms) {} return true; } console.log('timer start'); sleep(3000); console.log('Printing after 3000ms');
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, angularjs" }
TCL: Check file existance by SHELL environment variable (another one) I have a file contain lines with path to the files. Sometimes a path contain SHELL environment variable and I want to check the file existence. The following is my solution: set fh [open "the_file_contain_path" "r"] while {![eof $fh]} { set line [gets $fh] if {[regexp -- {\$\S+} $line]} { catch {exec /usr/local/bin/tcsh -c "echo $line" } line if {![file exists $line]} { puts "ERROR: the file $line is not exists" } } } I sure there is more elegant solution without using _/usr/local/bin/tcsh_ - _c_
You can capture the variable name in the regexp command and do a lookup in Tcl's global `env` array. Also, your use of `eof` as the while condition means your loop will interate one time too many (see < set fh [open "the_file_contain_path" "r"] while {[gets $fh line] != -1} { # this can handle "$FOO/bar/$BAZ" if {[string first {$} $line] != -1} { regsub -all {(\$)(\w+)} $line {\1::env(\2)} new set line [subst -nocommand -nobackslashes $new] } if {![file exists $line]} { puts "ERROR: the file $line does not exist" } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "tcl" }
Apollo GraphQL + DataLoader with array and multiple subsystems If I have a schema looking like this: A { Values: [B] } B { ValueFromSubSystemX: Float ValueFromSubSystemY: Float } If the client do a query that looks like this: A { Values { ValueFromSubSystemX } } I want to do a `ServiceX.GetAll()` and then do `ServiceX.load(id)` to load the cached data, but I don't want to do `ServiceY.GetAll()`, since I never do a `ServiceY.load(id)` (since the client never requested any information about SystemY). Is there anyway to do this kind of dataloading?
One, not so pretty, solution that I've found is to request all in each request, and let the dataloader keep track of if we should go to subsystem for the call or not. A solution could look something like this: const resolvers = { B: { async ValueFromSubSystemX (root, args, context) { await context.loaders.subSystemX.getAllValues('all') return await context.loaders.subSystemX.valueById(root.id) }, async ValueFromSubSystemY (root, args, context) { await context.loaders.subSystemY.getAllValues('all') return await context.loaders.subSystemY.valueById(root.id) } } } `getAllValues` is now calling `valueById.prime(idFromSubSystem, valueFromSubSystem)` Don't forget to turn off batching on `getAllValues`. If it isn't disabled, your dataloader could be really slow, depending on how you implemented it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "graphql, apollo, graphql js, apollo server" }
discerning /æ/ and /e/ sounds As I am a foreigner, I have great difficulty differentiating the sounds /æ/ and /e/ . When spoken softly, it becomes almost impossible for me to discern the sounds. Such as this one from movie Inception at 2:06 (...Saito knows. He's playing with us. Dicaprio: It doesn't "MATTER".) < _Matter_ here almost sounds like "MEtter". As such, I am frustrated by such hardship. Are /æ/ and /e/ always distinguished when spoken? I always make sure that I emphasize the vowel sound when I speak so as to achieve the best clarity I possibly can. However, it seems that when native speakers speak, the difference becomes extremely subtle or just indistinguishable. Is it only me? And if so, what should I do to attain the ability to hear such difference?
Phonology works together with word sense and context. In your example, there is no need to mark /æ/ from /Ɛ/ much: "m æ tter" or "m Ɛ tter", the word sense remains the same. I do not mean to support unclear pronunciation. This is just how it happens (along with recording quality; in your example, I hear /æ/). You would hear more difference, when the sounds are distinctive, i.e. make divergent word senses. Compare afferent < efferent < The website has audio pronunciation. I understand your language does not have /æ/. It sure has /a/ and /e/. Telling /æ/ comes easier when we can say it ourselves. Try saying /e/ and lowering your jaw, gradually, as for /a/. You should get /æ/, I've tried with students. :)
stackexchange-english
{ "answer_score": 0, "question_score": 2, "tags": "pronunciation, phonetics, vowels, ae raising" }
expanding jooq's row value query Using jooq to generate query for MySQL and checking if the row value clause generated by it can be expanded since mysql is not able to use indexes properly in row value queries for example DSLContext context = new DefaultDSLContext(SQLDialect.MYSQL); SelectQuery<Record> select = context.selectQuery(); select.addSelect(field("Col1")); select.addFrom(table("Table1").as("T1")); select.addOrderBy(field("Name"), field("Sid")); select.addSeekAfter(param("p2", "John"), param("p3","123")); String generated = select.getSQL(ParamType.NAMED); produces following query where (1 = 1 and (Name, Id) > (:p2, :p3)) order by Name asc, Id asc but will like to be where Name > :p2 or (Name = :p2 and Id > :p3) order by Name asc, Id asc
It's currently (jOOQ 3.9, see #6230) not possible to override this behaviour. You'll have to add an explicit predicate of the form you'd like it to be.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "java, sql, jooq" }
select a value in all listbox in jquery I'd like to create a jquery function which select the same value in all listbox I'm looking for something like this but it doesn't work var myArray = $("#form :select"); myArray.each(function(item) { item.val(value); });
You just need to use `.val()` directly, not need to iterate. $("#form select").val(value) $("#form select").val(2) <script src=" <form id='form'> <select> <option>1</option> <option>2</option> </select> <select> <option>1</option> <option>2</option> </select> <select> <option>1</option> <option>2</option> </select> </form>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "jquery" }
Не могу закрепить сообщение пользователя, Aiogram @dp.message_handler(commands=['pin']) async def piim(message: types.Message): await message.reply(f"{bot.pin_chat_message}")
Я так понимаю, вы хотите закрепить сообщение, на которое пользователь ответил командой: /pin, если да, то вот решение: @dp.message_handler(commands=["pin"]) async def pinHandler(message: types.Message): await bot.pin_chat_message(message.chat.id, message.reply_to_message.message_id) await message.answer("Прикрепил")
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, telegram bot, aiogram" }
print spaces with String.format() how I can rewrite this: for (int i = 0; i < numberOfSpaces; i++) { System.out.print(" "); } using `String.format()`? _PS_ I'm pretty sure that this is possible but the javadoc is a bit confusing.
You need to specify the minimum width of the field. String.format("%" + numberOfSpaces + "s", ""); Why do you want to generate a String of spaces of a certain length. If you want a column of this length with values then you can do: String.format("%" + numberOfSpaces + "s", "Hello"); which gives you numberOfSpaces-5 spaces followed by Hello. If you want Hello to appear on the left then add a minus sign in before numberOfSpaces.
stackexchange-stackoverflow
{ "answer_score": 74, "question_score": 53, "tags": "java, string, format" }
Split File Geodatabase in Arcgis How can I split large **File Geodatabase(FGDB)** in Arcgis, It contains **many Feature datasets and Feature classes**. I want to split it without missing any feature or attribute and after some work I could be able to merge it into one FGDB. Purpose of splitting is, I have one FGDB and 8 staffs.If I split it into 4 parts it would be helpful to finish job earlier. Say I have 1 GDB,10 datasets and 200 Feature classes.. GDB 1 should contain 10 datasets and 50 feature classes GDB 2 should contain 10 datasets and 50 feature classes like that. Feature datasets should remain same because all 10 datasets contains all type of feature classes.
To accomplish what you describe in your clarified question you could: 1. Make four copies of your file geodatabase (and keep the original so that you have an online backup to go to, in case your proof of concept proves otherwise). 2. Decide which quarter of the feature classes are going to stay in each of the file geodatabases, and delete the other three-quarters of the feature classes from each. This solution makes no suggestions for dealing with standalone tables or any other data types/composites like rasters, topologies, networks, etc. To return your edited data to a single merged file geodatabase you could: 1. copy one file geodatabase to a new "to be merged" file geodatabase; and 2. copy in the feature classes (to the correct feature dataset) from the other three file geodatabases
stackexchange-gis
{ "answer_score": 1, "question_score": 0, "tags": "arcgis desktop, arcmap, file geodatabase, feature class" }
Using C# Class Library On Non-Development Machine I have a C# class library that is COM visible and can be called from Visual C++ 6. It works fine. Probably a stupid question, but even after Googling for an answer I can't find one. How do I copy and register this on another non-development machine? My machine has `gacutil` and `regasm` on it which I am using. However, these are not on the other machine. The only answers I seem to be able to find on Google talk about creating an installation app, but this is overkill for something that will only ever be used internally.
`Regasm` and `Gacutil` are both installed with the .NET Framework (in `C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727` for 3.5sp1, for example, by default). Since you'll need the framework installed anyways, this should exist on every system.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c#, installation" }
Tkinter, ejecutar una funcion al dar enter en un Entry sin un boton soy nuevo en tkinter. Quiero escribir un numero de serie en un Entry Widget y despues dar enter y que se ejecute una funcion, por ejemplo mostrar una venta emergente. Todo esto sin la necesidad de tener un boton que lea el texto en el entry y ejecute un comando. Como interfaz quiero dejar algo asi de sencilo: import tkinter as tk window=tk.Tk() window.title("FT Files") window.geometry("500x300") texto=tk.Label(window,text="Introduce un numero de serie:") texto.pack() #NumSerie=StringVar() serialEntry=tk.Entry(window) serialEntry.pack() window.mainloop()
Solo necesitar usar la función `bind` en tu `entry` y asignarle a la tecla `enter` una función import tkinter as tk window=tk.Tk() window.title("FT Files") window.geometry("500x300") texto=tk.Label(window,text="Introduce un numero de serie:") texto.pack() #NumSerie=StringVar() serialEntry=tk.Entry(window) serialEntry.pack() def newWindow(event): print("the new window is open") new_window = tk.Toplevel(window) new_label = tk.Label(new_window) new_label.config(text="El codigo de serie es: " + serialEntry.get()) new_label.place(x=30,y=30) window.iconify() serialEntry.bind("<Return>", newWindow) window.mainloop()
stackexchange-es_stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, tkinter" }
rails - Create new job within a delayed job I am creating a delayed job in my controller using the delay method as below: JobProcessor.delay(:run_at => Time.now).process_job(options) Now inside the process_job method I am doing chunks = options[:collection].each_splice(10).to_a chunks.each do |chunk| self.delay(:run_at => Time.now).chunk_job end This is giving me error `stack level too deep` when I send request to the URL What might be the issue? Please help.
I was able to make it work for me by doing some changes. * I changed the outer method `process_job` to be an instance method * And kept the rest of the code as it is. So now my code looks like JobProcessor.new.process_job(options) in the controller, and inside the `JobProcessor` class I have class JobProcessor def process_job(options) chunks = options[:collection].each_splice(10).to_a chunks.each do |chunk| self.class.delay(:run_at => Time.now).chunk_job(options) end end handle_asynchronously :process_job, :run_at => Proc.new { 2.seconds.from_now } def self.chunk_job(options) # perform chunk job here end end This works for me.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails 3, recursion, delayed job" }
What does the '#' sign mean in jQuery? I'm new to Javascript and I'm try to understand some code. I don't understand and I can't find any documentation about the `#` sign. $(function () { $("#searchTerm").autocomplete({ What does $("#searchTerm") mean?
In JavaScript? Nothing special. It is just part of a string. The `$` function might do something with it, but it is hard to tell what the `$` function is. There are a lot of libraries which provide a `$` function that acts as a kitchen sink for that library. They include Prototype, Mootools and jQuery. This one looks most like jQuery, in which case the argument is a string containing a CSS selector, so the `#` indicates the start of an id selector. This "Selects a single element with the given id attribute".
stackexchange-stackoverflow
{ "answer_score": 20, "question_score": 34, "tags": "javascript, jquery" }
Autocompletion in FlashDevelop doesn't work in included files Why doesn't autocompletion work for function's local variables in included *.as files? For example: Main.mxml: <fx:Script> <![CDATA[ include "code.as"; // or <fx:Script source="code.as"/>, doesn't matter ]]> </fx:Script> code.as: import mx.controls.Button; var foo:Button = new Button(); foo. <---- autocompletion is working here function myFunc() { var bar:Button = new Button(); bar. <----- doesn't work }
Autocompletion will only work if a code class was imported, or if a class extended an .as class. **Has to be a Class**. When you use _'include code.as'_ , code.as is not a class, its basically just a collection of variables, imports and functions, so autocomplete cannot access it like a class. The **code-behind pattern** is similar to what your doing (seperating logic from the mxml), and allows for atuocompletion. To use it: 1. Create an Actionscript class that extends an MXML control that you want to use e.g. HBox or UIComponent 2. Put all of you logic within this Actionscript class. 3. Then create an MXML class that extends the Actionscript class. Code completion will work in your new custom MXML class for accessing public/protected variables and functions.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "apache flex, actionscript 3, flashdevelop" }
Calling a library from inside a helpers function in Codeigniter Can I load a library from inside a helper? $this->load->library('name'); Thanks, Max
No. The purpose of helpers is to "perform one specific task, with no dependence on other functions." Quoted from CI's helpers page. If you need to include a library inside of your helper, consider making it a library instead.
stackexchange-stackoverflow
{ "answer_score": -6, "question_score": 21, "tags": "php, codeigniter" }
Can't set background-image for a specific div Some strange behavior about background image **HTML** <body> <div id="divGaLL"> <ul id="ulGaLL"> <li>...</li> <li>...</li> </ul> </div> </body> **CSS** body{ background:url(img/back01.jpg); //works } #divGaLL{ background:red; // works background:url(img/back01.jpg); //doesn't work } #ulGaLL{ background:url(img/back01.jpg); //works } Why I can't set **back01.jpg** as background for `#divGaLL`?
That is because you are using the same property and different values. When you are using `background:` you can write color and image in same line #divGaLL{ background:url( red; } **DEMO**
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "html, css, background image" }
Error when trying to move to next element of a Linked List I am dealing with linked lists, and am having issues moving to the next element of the Linked List. the error that I get is: `error: incompatible types when assigning to type 'item' from type 'struct item *` Here is the code: typedef struct item { float size; struct item *next; } item; item head, curr, tail; ... head.next = (item*) malloc(sizeof(item)); curr = head.next; Thanks for your help.
In this assignment statement curr = head.next; `curr` has type `item` while `head.next` has type `item *`. That is the first one is a structure object and the second one is a pointer. They are incompatible. Thus the compiler issues an error. You should declare variable `curr` like pointer item *curr;
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c, pointers, linked list" }
Common deadlocks on stored procedure with no index I'm investigating some deadlocks on a production SQL server 2008 R2 box that all seem to be related to the same stored procedure. The procedure is very simple.. it updates one column on a table row and finds the row using the identity column (ID). Looking further into this strangely the Clustered index isn't even set to the identity column and there is no non-clustered index for the column either. I've looked at the Execution Plan which says it's doing a Clustered Index Scan. Could this be the cause of the deadlocks? And if so would someone mind explaining why? Could it be acquiring page locks? Looking at MSDN documentation it says U locks should prevent common deadlocks.
This will explain this kind of deadlock and how to correct it: < You are right, it's due to the clustered index scan. You need to just put a non-clustered index on the identity (ID) column and that should fix it.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql server, sql server 2008, indexing, deadlock" }
IIS 7 : Add PHP Code Automatically to Every Page In IIS 7, is there any way for me to add a snippet of PHP Code to every page delivered, without having to add it manually?
No. There is no way to add a snippet of PHP Code to every page delivered.
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "iis, iis 7" }
Does this power sequence converge or diverge? If it converges, what is the limit? Say I have this sequence: $$a_n = \frac{n^2}{\sqrt{n^3 + 4n}}$$ Again, I don't think I can divide the numerator and denominator by $n^{1.5}$... that seems like it complicates things. What else can I do? I can't square the top and bottom because that changes the value of the general sequence. Can I divide by $n^2$? Is this valid: $$a_n = \frac{1}{\sqrt{\frac{n^3}{n^4} + \frac{4}{n}}}$$
You can easily find a divergent minorant: $$\frac{n^2}{\sqrt{n^3 + 4n}} \ge \frac{n^2}{\sqrt{n^3 + 4n^\color{blue}{3}}} = \sqrt{\frac{n}{5}} \to +\infty$$
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "sequences and series" }
Create a navigation window in Access I'm looking to create "Welcome" window of sorts for the database I'm working on. The window would have four buttons. My current issue is with a button that I want to use to open a form I've already created. The trick is this form is meant to be the input window to a table, so I don't want the form to come pre-populated with any data, it would (if completed) create a new record, but only once the form is completed. Opening the form isn't the trouble (DoCmd.OpenForm "form name"), what I'm not sure is how to have it open blank.
DoCmd.OpenForm "form name",,,,acFormAdd This opens the form to a "new" record.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "forms, ms access, macros, vba" }
What is `${1- hour}`? From < date -d "next ${1- hour}" '+%H:00:00' What is `${1- hour}`? Is it some shell parameter expansion, or input format of date and time? Why does `${1 hour}` not work? Thanks.
It's a parameter expansion, expanding to the text `hour` if the first positional parameter is unset. Had the expansion been `${1:- hour}`, then it would have expanded to `hour` also if the first positional parameter was empty (but set). The code in the StackOverflow answer that you are linking to expects the first positional parameter to be something like `day` or `week`, but defaults to `hour` using this expansion if the argument is not provided.
stackexchange-unix
{ "answer_score": 3, "question_score": -2, "tags": "date, coreutils" }
Did this player need to draw? We've just played a game of Fluxx, where the following occurred. There was a Draw3 and a Poor Bonus in play, so this player got to draw 4 cards. He then removed the Poor Bonus and changed the Draw3 to Draw4. Option A: Since he raised the number of drawn cards, he needed to draw an extra. Option B: Since the resulting rules require 4 drawn cards and he already had drawn that many he did not need to draw another. So which one is it?
Option A, the player should draw an extra card. Here's why: The Poor Bonus happens at the start of a player's turn. Since the player already drew for Poor Bonus, and removed the Poor Bonus after the draw, that card is fully resolved. But the Draw X cards always say to draw extra cards during a turn, so the player would need to draw one more card to meet that rule change.
stackexchange-boardgames
{ "answer_score": 15, "question_score": 9, "tags": "fluxx" }
Check if ContentPage is currently shown Is there a way to tell if a ContentPage is currently shown? I need code inside an event handler in the ContentPage to check whether the page is currently shown and act accordingly.
In addition to GBreen12's answer, you could also do it this way... bool isShowingMyPage = Application.Current.MainPage is MyPage || (Application.Current.MainPage is NavigationPage navPage && navPage.CurrentPage is MyPage); //If you are using a MasterDetailPage or something else, then you would have to handle this differently //I think the below will work for checking if any modals are showing over your page but you should definitely test it in different scenarios to make sure. I am not sure if the modal is immediately removed from ModalStack when it gets popped or not isShowingMyPage = Application.Current.MainPage?.Navigation?.ModalStack?.LastOrDefault() == null;
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "c#, xamarin, xamarin.forms" }
Can't login to asp.net web, Jmeter I am new in jmeter, I want to see performance when the user logs into my web. But when I see the results using **_'View Result Tree'_** and see **_'Response Data'_** and get this error. I developed using asp.net MVC > The Anti-forgery token could not be decrypted. screenshoot is below. Thanks :) ![enter image description here]( ![enter image description here](
Please use authorization manager for authentication. Also, it seems header is missing in your request. Use jmeter recording to capture the requests and then perform the required correlation like anti-forgery token. Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net mvc, jmeter" }
replace a text with another within a tag I'm sure it's stupidly easy, but how can I replace just the text within an html tag. For instance, from this: <div style="display: block;">blah blah</div> <a href="#" style="display: inline; ">(Old text)</a> to this: <div style="display: block;">blah blah</div> <a href="#" style="display: inline; ">(New text)</a> replace Old text => New text Many thanks in advance.
Just select the element and change its contents $("a").html("(New Text)"); **References** * html * text * jQuery selectors
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, jquery" }
Handling null values where not allowed I have the following code in the mClass constructor: public mClass(Context ctx) { super(); this.ctx = ctx; } The context can't be null because its necesary for the object operation. So if I allow the creation of an new mClass(null) it will break later. I'd like to crash when the object is create because is when the incorrect situation is happening. Whats the standard way of doing this? For example making public mClass(Context ctx) { super(); if(ctx==null) throw new Exception ("...."); this.ctx = ctx; } forces to declare the method as exception thrower and I dont wan't to do this because passing a null value is not usual
Throw `java.lang.IllegalArgumentException`, which is a runtime exception so you don't need to forcibly handle this, and if it is thrown application will get crashed (if it is not handled)
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "java, android" }
How can I increase the size of the table? I'm trying to display a pandas dataframe as an image, but when I use plt.show(), I got a small picture of the table, inside a big (invisible) subplot, occupying 90% of the generated window. I used this code: # ... ax = plt.subplot() ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.spines['left'].set_visible(False) ax.spines['bottom'].set_visible(False) coeficientes_real_2 = coeficientes_real.transpose() table(ax, coeficientes_real_2, colWidths=[0.1, 0.1, 0.1], loc='center') plt.savefig('mytable.png') plt.show() #... And got this result: ![Result]( How can I increase the size of the table?
Based on this post, you can scale the whole table with tb = table(ax, coeficientes_real_2, colWidths=[0.1, 0.1, 0.1], loc='center') tb.scale(2,2) Or change the column width and font size individually: tb = table(ax, coeficientes_real_2, colWidths=2*[0.1, 0.1, 0.1], loc='center') tb.set_fontsize(24)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, pandas, matplotlib, matplotlib table" }
Linux command line for ssl server? I always use the socket command line tool to do quick socket tests for programs I'm writing. < I was wondering if there was a similar command line tool to set up a quick ssl socket client/server to test things. ## Edit: Easy Answer So to make it easy on people who may wonder the same thing: **If you want to be a client use openssl's s_client:** openssl s_client -connect host:port **If you want to be a server use openssl's s_server:** openssl s_server -accept <port> -key <keyfile> -cert <certfile> **Quick And Dirty cert and key for the server to use for testing:** openssl req -x509 -nodes -days 365 -newkey rsa -keyout keyfile.key -out certfile.crt
Quick SSL Client: openssl s_client -connect <host>:<port> Quick SSL Server: openssl s_server -accept <port>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 10, "tags": "linux, ssl, command line interface" }
Solve some equation in scala using pattern matching I'm very new to Scala, and while reading the ScalaTutorial.pdf Section 6: _Case classes and pattern matching_ I find no information on how to run its example which is: package my abstract class Tree case class Sum(l: Tree, r: Tree) extends Tree case class Var(n: String) extends Tree case class Const(i: Int) extends Tree object TestTree { type Environment = String => Int def eval(t: Tree, env: Environment): Int = t match { case Sum(l, r) => eval(l, env) + eval(r, env) case Var(n) => env(n) case Const(v) => v } def main(args: Array[String]){ val s : Sum = Sum(Var("x"), Const(10)) // Then how to define a variable of type environment to pass it to the `eval` function: //eval(s, Environment) ?? } } I don't know how to pass the Environment to the `eval` function
type Environment = String => Int This says that the type `Environment` is equal to the type `String => Int`, i.e. the type of functions that take a `String` and return an `Int`. It should be noted that in Scala a map is a kind of function (which is to say `Map[K,V]` is a subtype of `K => V`). So any function that takes a function as an argument can also take a map instead. So to use `eval` you can pass it a function of type `String => Int`, which might either be an actual function that you defined and that takes a string and returns an int, or a map that maps strings to integers.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "scala, pattern matching" }
Alternatives for empty macros In my C++ header file, I have the following: #ifdef _DLL #define DLL_API __declspec(dllexport) // Being compiled as a DLL. #else #define DLL_API // Not being compiled as a DLL. #endif Later on, I have things like: DLL_API int GetNumber(); I'm oversimplifying, but the basic question here is whether there's a way to get the compiler to just skip over `DLL_API` if it's not defined.
No. When DLL_API is defined as preprocessor macro that contains nothing then preprocessor replaces DLL_API with nothing and compiler will see nothing there. If it is undefined for preprocessor then preprocessor does nothing with it. Then compiler will see it unchanged and you get compiler error about unknown identifier DLL_API, because such thing is not part of C++ language. Attributes like __declspec() are platform specific extensions and it is common convention to wrap their usage in interfaces into preprocessor macros.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "c++, macros, c preprocessor" }
Silly detail enquiry about Prolog unification In Prolog: ?-P=[A|B], P=[1,_]. P = [1, _G1091], A = 1, B = [_G1091] B is shown as [_G1091] showing it's an uninstantiated variable. However, if I change a tiny bit... ?-P=[A|B], P=[1|_]. P = [1,B], A = 1, All of a sudden it's not interested in showing me that B is uninstantiated but still a variable ready to unify with anything.. how come? (I like to focus on weird details sometimes :) )
The precise details of Prolog syntax are sometimes quite subtle. To get used to it use `write_canonical/1` which shows you the term in functional notation: ?- write_canonical([A|B]). '.'(_1,_2) true. ?- write_canonical([1,_]). '.'(1,'.'(_1,[])) true. May I recommend a "drill"-exercise to get used to Prolog's list notation: Take some list like `[[1,2],3]` and now try to write it down in as many variants you can imagine. ?- [[1,2],3] == [[1,2],3|[]]. true. etc. In many Prologs the toplevel lets you take the last input (often: cursor-up) such that you can re-edit the right-hand side rapidly.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "list, prolog, unification, cons" }
Log rotation with Plone The log rotation for Plone product installation would be a nice feature. What are the current best practices regarding the log rotation integration into Plone? I found this article: < but as there are no documentation on plone.org I'd like to ping the community for the good known best practices not to fill up their hard disks.
Similar to what Laurence said above but keeps size under 10mb and saves only 1 old file. <eventlog> level INFO <logfile> path /path/to/plone4/var/log/client1.log max-size 10mb old-files 1 </logfile> </eventlog> plone.recipe.zope2instance can generate this now. For example, you can specify the following options: event-log-max-size = 10mb event-log-old-files = 3
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "plone, zope" }