INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Load content without refreshing page in views i am trying to create a view with pagination. In this view i have images and fivestar rating for it. When user clicks on next i want next image and fivestar to load with out refreshing page. Thanks.
What you need is the views load more module > This module has some very key differences then the other load more module. > > * Provide ajax/no-ajax views load more > * Works with views default ajax implementation, no hacks (check/uncheck ajax) > * Supports the Waypoints module for loading on various points, Such as when the scroller is visable on the page. > * Supports the Fade effect when loading new content >
stackexchange-drupal
{ "answer_score": 4, "question_score": 1, "tags": "views, media" }
How to obtain $V_1$ and $V_2$ such that $f(V_1 \times V_2) \subseteq U$? Let $X$ be a topological vector space and $x^\star, y^\star\in X$. Let $\lambda \in (0, 1)$. We define a map $f: X \times X \to X$ by $f(x, y) = \lambda x + (1-\lambda)y$. Then $f$ is continuous. Let $z^\star := f(x^\star, y^\star)$ and $U$ be an open neighborhood of $z^\star$. Then there is an open neighborhood $V$ of $(x^\star, y^\star)$ such that $f(V) \subseteq U$. In this answer, @Seirios goes further and asserts that there are some open neighborhood $V_1$ of $x^\star$ and open neighborhood $V_2$ of $y^\star$ such that $f(V_1 \times V_2) \subseteq U$. Could you elaborate how to obtain such $V_1$ and $V_2$?
If $V$ is open, it is (by definition) the union of basic open neighborhoods of the form $V_1 \times V_2$. As $V$ contains $(x^*, y^*)$, one of these basic neighborhoods must contain $(x^*, y^*)$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "general topology, topological vector spaces" }
I'm trying to change placeholder in WordPress theme, but I can't find where it's existing I use a WordPress Woo-commerce template called "KuteShop", and I am trying to change the Placeholder Text "I'm searching for..." and "All Cate." as in the picture below: ![]( but I can't do that, I searched everywhere, NOT in the Advanced editor, NOT in the Theme Options, NOT in the WordPress Settings, Nor in any place. How can I modify it?
The process is really simple, KuteShop include a language file: "languages/kuteshop.pot" You simply should open this file with the PoEdit application (that is distributed for free: < and create the language file for your website's language, entering a hypothetical translation of this text with the text you want to display on your website.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, html, wordpress" }
jQuery display form alert box Hi i'm trying to display an alert or style-able popup box that says Empty Fields when the submit button is press. The code below stopped working after I added `alert("Empty Fields!!");` var validator = $("#reg_form").validate({ errorLabelContainer: $("#reg_form div.error"), meta: "validate", alert("Empty Fields!!"); });
I assume that < is the jQuery plugin that your code referes to. You can't use alert in class declaration. You will have to rewrite it like this: var validator = $("#reg_form").validate({ errorLabelContainer: $("#reg_form div.error"), meta: "validate", submitHandler: function( form ) { alert("Empty Fields!!"); } }); or use invalidHandler: function(form, validator) instead of submitHandler
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "jquery, jquery validate, alert" }
Como colocar codigo html na pergunta Estou com um bloco de codigo html e preciso por aqui no corpo da pergunta
De uma olhada na forma que fiz, tente entender, e veja se consegue fazer de outras formas para aprender melhor :) section{ background-color: red; width: 100%; height: 100vh; padding: 2%; display: flex; flex-wrap: wrap; } div{ background-color: orange; width:47.5%; height: 45%; margin: 1%; } .box{ background-color: black; width:47.5%; height: 45%; margin: 1%; position: absolute; top: 0; position: absolute; left: 24%; right: 24%; top: 30%; } <section> <div> </div> <div> </div> <div> </div> <div> </div> <div class="box"></div> </section>
stackexchange-pt_stackoverflow
{ "answer_score": -1, "question_score": -4, "tags": "html, css, div, posicionamento, responsivo" }
How do I perform the following SQL sum? Suppose we have the following table match_id, user_id, score 1000, 1, 359 1000, 52, 290 1001, 1, 429 1001, 59, 374 Basically in match_id 1000, user_id 1 wins 359-290, in match_id 1001, user_id 1 wins 429-374 To work out the total points user 1 is easy select user_id,sum(score) as pointsfor group by user_id How do I determine how many points were scored against? Basically what should X in the following SQL be? select user_id,sum(score) as pointsfor,sum(X) as pointsagainst group by user_id
I can't test right now, but try something like: SELECT PointsFor.user_id, sum(PointsFor.score) as pointsfor, sum(PointsAgainst.score) as pointsAgainst FROM TABLE_NAME PointsFor JOIN TABLE_NAME PointsAgainst on PointsFor.match_id = PointsAgainst.match_id and PointsFor.user_id <> PointsAgainst.user_id GROUP BY PointsFor.user_id Obs: Replace `TABLE_NAME` above with the actual name of your table.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql" }
CMAttitude roll and pitch calculation The question itself is simple. When using the CMDeviceMotion motion it contains an object named attitude of type CMAttitude which contains roll and pitch. Roll and pitch describe the rotation of the object around the Y and X axis. When the iPhone lies on a table with the display pointing up roll and pitch are both 0. When rotating the iPhone around Y or X axis these values get updated. I want to know how these values are calculated.There is a way to calculate roll and pitch from the current gravity vector of the device. The pitch seems to be: **pitch = -asin(motion.gravity.y)** but I can not figure out how to calculate the roll. Thanks for your help
It's likely something like: roll = -atan(x / z); though you need to alter the sign depending on which orientation you're in, and be careful around the asymptotes where z=0. I believe Core Motion in reality uses gyro measurements in addition to the accelerometer readings to calculate the attitude more accurately (and maybe also to deal with gimbal lock).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone, core motion, pitch" }
pulse audio sink, what are they? Call it cultivating curiosity but what do the sinks stand for exactly, when i run pactl list sinks | egrep 'Sink|State|Mute|Volume' I get the output below, what I'm not understanding is sink #0 is running, but i have no sound running, and no audio inputs are plugged into my machine. if i had to guess I'd say sink #0 was my internal card and sink #1 was any outputs but that's a wild guess. Sink #0 State: RUNNING Mute: no Volume: front-left: 32768 / 50% / -18.06 dB, front-right: 32768 / 50% / -18.06 dB Base Volume: 65536 / 100% / 0.00 dB Sink #1 State: IDLE Mute: no Volume: front-left: 32768 / 50%, front-right: 32768 / 50% Base Volume: 65536 / 100%
I propose you remove the `egrep` part or add `Name|Description` to it. this will shed some light. e.g. for my `Sink #0` I get Name: alsa_output.pci-0000_01_00.1.hdmi-stereo Description: Caicos HDMI Audio [Radeon HD 6400 Series] Digital Stereo (HDMI)
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 1, "tags": "pulseaudio, alsa, soundcard" }
EF's DatabaseGeneratedOption.Identity attribute doesn't work for the ulong type [Table( "User" )] public class User { [Key] [DatabaseGeneratedAttribute( DatabaseGeneratedOption.Identity )] public ulong Id { get; set; } // other columns } For this code I get the exception: > System.Data.Entity.Edm.EdmEntityType: : EntityType 'User' has no key defined. Define the key for this EntityType. But changing the Id's type to int, everything works fine. //... [DatabaseGeneratedAttribute( DatabaseGeneratedOption.Identity )] public int Id { get; set; } //... How to get the possibility for autocreating tables with an Id having a ulong type capacity ? (using ef's code first obviously)
Given that numeric sql server types are : > bigint, numeric, bit, smallint, decimal, smallmoney, int, tinyint, money it becomes clear that CLR type `UInt64` (`ulong`) does not map to any of these types.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c#, asp.net, asp.net mvc, entity framework, ef code first" }
vba strings replacing OK Starting all over again and hopefully a bit more straight forward. Var = 24 string = "var" x = string This results in x = "var" **NOT** x = 24 Is it possible to retrieve the value of **var** , by using the string stored in **string** Thank you Aaron
I don't believe you are able to do that. As a solution you can use a collection to mimic this behaviour: Sub TestCollection() Dim Values As New Collection Values.Add "24", "Var" Values.Add "Alexander", "Name" MsgBox Values("Var") & " " & Values("Name") End Sub
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "string, vbscript" }
Keyboard shortcut for copying filepath in MsOffice 2013 For example, in Word2010, you can copy the document filepath pressing: `Alt`, `F`, `Tab` , `Ctrl+C`. In Word 2013, the last `Ctrl+C` does not copy the filepath because then you have the options of: a) Copy link to clipboard b) Open link location I tried the `application key` but it didn't work either. Any idea?
It's complicated, but here it is... `Alt`, `F`, `Tab`, `Enter`, `C` You could just get a simple macro to do it, and assign a simple shortcut.
stackexchange-superuser
{ "answer_score": 2, "question_score": 1, "tags": "microsoft word, keyboard shortcuts, microsoft word 2010, microsoft word 2013" }
Disjunctive Constraint , Using Binary Variable to Replace a If or condition I am trying to use a binary variable based on an inequality. The value of binary variable $q $ is 1 or 0 based on the following equation. > [ $q $ = \begin{cases} 0,& \text{if } b \geq \pi ,\\\ 1, & \text{otherwise} \end{cases} Here, b and $\pi$ are real numbers. Sample value b = 20 , $\pi$ = 30. I have tried to represent this by: \begin{equation} q \geq \dfrac { (\pi - b )} {M} \end{equation} \begin{equation} q \leq 1 + \dfrac { (\pi - b )} {M} \end{equation} By using these two equations I am able to cover the cases for when $b > \pi $ and when $b < \pi $. Unfortunately I am unable to set $q$ as 0 when $b=q$ without violating other conditions.
The usual approach to this requires that $b$ be bounded, say $L \le b \le U$ for some constants $L$ and $U.$ You can come close to what you want with the following: $$b \ge \pi (1-q) + L q$$ $$b \le \pi q + U (1-q).$$ If $b > \pi,$ the second constraint forces $q=0.$ If $b < \pi,$ the first constraint forces $q=1.$ The tricky part comes when $b=\pi,$ in which case $q$ can be either 0 or 1. Because you cannot enforce a strict inequality in a MIP model, if you can't accept the ambiguity when $b=\pi$ then you can change the second constraint to $$b \le (\pi - \epsilon) q + U (1-q),$$ where $\epsilon > 0$ is a small constant. Now $$b\ge \pi \implies q=0,$$ $$b \le \pi-\epsilon \implies q = 1,$$ and $\pi - \epsilon < b < \pi$ is forbidden.
stackexchange-or
{ "answer_score": 2, "question_score": 3, "tags": "modeling, binary variable, logical constraints, big m" }
Vote counts in iOS app From the nosy neighbor department: View number of 'Up' and 'Down' Votes of a question/answer - Android App I want what they have! !Screenshot of the feature in Android Can we see vote counts in the iOS app too?
Coming soon to an iOS device near you: > !Better Than Android™ To use the feature, press on the question score and hold your finger there until the vote count appears.
stackexchange-meta
{ "answer_score": 6, "question_score": 9, "tags": "feature request, status completed, ios app, vote count" }
What information to include when calculating the HMAC of ciphertext I'm aware that it's crucial to include the IV when calculating the HMAC of a ciphertext (assuming an IV is used). Can anyone explain, in simple terms, why this is? Furthermore, assume that there is other metadata associated with the cipher, which needs to be known to correctly decrypt the ciphertext (for example, the type of algorithm used, the mode, options such as configurable block size, etc). Is there any sense in including this information when calculating the HMAC? Or on the contrary, is the any reason not to?
Yes, it is best to include all that information in the HMAC. Otherwise an attacker can change those values and you would not get the correct plain text. This would mean that you get either incorrect information, or you leak information that could be used for padding oracle attacks. In case of the IV, if you don't include it in the HMAC then the attacker can change the first block of plain text you get when you decrypt the first block (assuming CBC mode encryption here).
stackexchange-crypto
{ "answer_score": 2, "question_score": 2, "tags": "hmac" }
Select Timestamp By Time Ignoring Date I am trying to "SELECT" a time range while ignoring the date portion of a "TIMESTAMP" field (09-09-11 10:23:03). The query below works but has huge performance costs... SELECT * FROM Table WHERE Time LIKE '10:09:13' What is the fastest way to do this on a table with 1/2-1 million rows without using the "LIKE" command?
SELECT * FROM Table WHERE TIME(Time) = '10:09:13' That should do it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql, select, time, timestamp" }
$f\in M(\mathbb{R})$ but $\hat{f}$ is not I am studying Fourier analysis. I noted some problems state $f,\hat{f}\in M(\mathbb{R})$ as assumption, where $M(\mathbb{R})$ denote the collection of all **continuous** and of moderate decrease functions on $\mathbb{R}$, which means $$\exists A \in \mathbb{R}\, \text{such that}\, \forall x\in \mathbb{R}, \ |f(x)| \lt \frac{A}{1 + |x|^{1+\epsilon}}$$ Hence I think there must be some function in $M(\mathbb{R})$ whose Fourier transform doesn't. Since I only know the Fourier transform for a few functions, may you give me an example?
$M(\mathbb{R})\subset L^1(\mathbb{R})$. This post shows the existence of a continuous function $f$ with compact support (hence $f\in M(\mathbb{R})$) with $\hat f\notin L^1(\mathbb{R})$, and hence $\hat f\notin M(\mathbb{R})$. An explicit example of such an $f$ is $$ f(x)=\bigl(1-\log(1-x^2)\bigr)^{-\alpha}\cdot\mathbb{1}_{[-1,1]},\quad0<\alpha\le1. $$ According to the answer of T. Tao to a question of mine, the behavior at infinity of $\hat f$ is like $$ \frac{1}{|\xi|(\log|\xi|)^\alpha}. $$
stackexchange-math
{ "answer_score": 2, "question_score": 3, "tags": "fourier analysis" }
How to tar all files in current directory using tar but without inputing names of tar file and all files? # ENV: * macOS Sierra 10.12.6 # Raw input(example): . f1.md f2.md f3.md f4.txt f5.csv f6.doc 0 directories, 6 files In a test folder, there are 6 files. # Expected output: . all.tar f1.md f2.md f3.md f4.txt f5.csv f6.doc 0 directories, 7 files # Trying and Problem tar -cvf all.tar f1.md f2.md f3.md f4.txt f5.csv f6.doc Though I get the result from the above method but I have to inputing all file names and the compressed file name, which is inconvenient. For example , I can select all files and right click, then choose compressed option without inputing `all.tar` (I don't mind the .tar filenames.) # Hope command-line method without inputing specific file names.
In case you want all files, including those in the subdirectories (or if you have no subdirectories), you would run: tar -cvf all.tar * Then, `bash` would expand `*` into the list of all files in the current directory, including subdirectories. In case you want only those files in the current directory, but NOT in the subdirectories, then you would have to use `find`, in a more complicated command. Let me know if this is the case for you, and I can take the time to find that combination of commands for you.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "unix, command line, tar" }
How to start a specific mode with emacs? Users use 'M-x auto-revert-mode' for starting auto revert mode. How can I set the .emacs file to do the same thing when emacs starts? How to start a specific mode, when a major mode starts? For example, how to set the .emacs file when I want to start the auto revert mode when LaTeX mode starts?
If you want auto-revert-mode on for all files, add: (global-auto-revert-mode 1) If you want it for files for specific modes, try: (add-hook 'latex-mode-hook '(lambda () (auto-revert-mode 1))) and substitute the mode name for `latex`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "emacs, major mode" }
How can I dynamically select a class property using a string variable? Suppose my class has a couple of similar properties and I want to select one dynamically based on a string variable: **MyClass properties:** PropertyOne PropertyTwo **Some generic code:** myString = "One" MyClass.Property & myString = "blah" 'this doesn't work
CallByName MyClass, "PropertyOne", vbLet, "blah" <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "excel, vba" }
Match vectors on subset of digits in each element I am trying to see whether the elements in vector match with the first four digits of elements within a second vector (they are nested identifiers) and I'm not quite sure how to run the match. For example: X Y 1111 111120 1111 890933 2222 780777 2222 222247 I would like to create code to tell me whether the first four digits of element i in vector y match the digits in element i in vector x. Extending the example, I hope to see: True False False True Thanks for any thoughts.
Using `apply` to loop over the rows and use `grepl` will work... apply( df , 1 , function(x) grepl( x[1] , x[2] ) ) #[1] TRUE FALSE FALSE TRUE
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "r, match, digits" }
How to remove part of a string Monogdb I am trying to delete everything after the first \n in this string: \n \n \n Collection; { id:.... class: "Apples" Url: " < \n < \n < \n" So the desired output is, filter on class: "Apples" and turn url into: Any assistance would be greatly appreciated. Thanks!
$indexOfBytes returns first occurence of given substring so you can use it along with $substr to find your first `\n` and get a substring: db.collection.aggregate([ { $project: { newString: { $substr: [ "$str", 0, { $indexOfBytes: [ "$str", "\n" ] } ] } } } ]) Mongo Playground
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "mongodb, mongodb query, aggregation framework" }
Animation hangs when pushing UIViewController to UINavigationController I have a custom UITableViewCell I created entirely in code. This project doesn't use autolayout at all, all drawing is done in code. When the user taps a button in my custom cell it calls a delegate which the UITableViewController implements and then pushes a new view controller to the navigation controller. It works fine, but when it's transitioning the animation freezes half way and then segues all at once as seen in this gif. ![]( I've worked on projects using storyboards and know it's not supposed to look like this. I've tried using dispatch_after and dispatch_async which lead to the same outcome. This is the code I'm using. let vc = UIViewController() self.navigationController!.pushViewController(vc, animated: true) How can I fix this bug? Thanks in advance for any help!
This bug is weird beyond understanding, but inserting the following line of code in the viewDidLoad of the viewController being shown fixed it. self.view.backgroundColor = UIColor.whiteColor()
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "ios, uitableview, uiviewcontroller, uinavigationcontroller" }
OpenStack Dashboard (Horizon) Fails to Allow Log In I cannot log in to the OpenStack Dashboard; attempting to do so results in a re-direct back to the log-in page. Entering the wrong details will throw an "incorrect user/pass" error; the correct details will show nothing. I cannot see any issues in `/var/log/nova-api.log` or similar. My `apache2/error.log` does show some 401's relating to Cinder, but I'm not sure if these are a red herring: < `nova-manage service list` shows smiley faces, and `keystone service-list` shows the expected services with no errors. I'd appreciate some advice here—a Google hasn't helped.
Those unauthorized errors in the error log might be the problem. A start would be to validate that the user you are logging into Horizon with has (in keystone) the role that you've specified in the /etc/openstack-dashboard/local_settings.py ( OPENSTACK_KEYSTONE_DEFAULT_ROLE = "some role name" )
stackexchange-serverfault
{ "answer_score": 2, "question_score": 0, "tags": "ubuntu, openstack" }
Ways to add up 10 numbers between 1 and 12 to get 70, where order is unimportant How would I solve this: "Ways to add up 10 numbers between 1 and 12 to get 70" if order is unimportant? Thank you!
Let $f(n,k,s)$ be the number of ways to add up $n$ numbers from $\\{1,\ldots,k\\}$ to get $s$. Then you want $f(10,12,70)$. We have the recursion $$f(n,k,s)=\sum_{j=1}^{\min\\{k,s\\}}f(n-1,j,s-j)$$ and base cases $$f(1,k,s)=\begin{cases}1&\text{if }k\geq s\\\0&\text{if }k<s\end{cases}.$$ (Also one can use $f(n,k,s)=0$ if $s>n$ or $nk<s$ to simplify)
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "combinatorics" }
RAM as a attack target What is the simplest or most common method to read a value, for example a text, from the RAM of a personal computer? What access requirements are necessary for this? Is a search in a hex dump always required or are there shorter ways?
Since you tagged this question as "cold boot attack" and "forensics", I presume you're asking about a physical memory dump. These dumps are usually acquired by something like pcileech, using a special hardware device as an interface to the target system's memory. You may also acquire a memory dump from a crash dump or some other forensic tool. Generally you're copying the entire contents of physical memory into a dump file for later analysis. Once you've got a memory dump, it's possible to just search through it using a hex editor, but generally people use tools like volatility to analyse them. This provides much more information about the state of the system, since it can parse various operating system structures.
stackexchange-security
{ "answer_score": 1, "question_score": 0, "tags": "attacks, access control, forensics, cold boot attack, swap" }
how to git add -up changes from only specific files For adding changes to index from working directory, I use `git add -up`. Now I want `git add -up` to only show changes from specific files. How to do that? Or Rather ignore few specific files and show changes from all others? Note: I dont want to add the specific files to `gitignore` list, I just want to ignore them certain times as they also contain settings for debugging which I dont want to commit
Maybe it's a little slow, but you could use the `--interactive` add: git add -i And choose which file to add, and even which part of the file add.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "git" }
Scriptaculous autocompleter problem In Scriptaculous Ajax autocomplter it chooses the first entry by default . how do i stop it from choosing the first option by default??
In **controls.js** of the Scriptaculous library, on line 286: change "this.index = 0;" to "this.index = -1;". That will fix your problem. It's a pain that there's no option along the lines of { autoSelectFirst: false }. Hopefully in a future release :) On another note, you might want to have a look at: < which lets you disable selecting the first option out of the box.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ajax, autocomplete, scriptaculous" }
Flask Post method 405 Why is Post method not being called i can use only get method @Admin.route("/upload-image",methods=["GET", 'POST']) def upload_image(): if request.method == 'POST': if request.files: pdf = request.files["pdf"] print(pdf) return redirect() return '''<form action="/Admin/upload-image" method='POST'> <div class="form-group"> <label>Select PDF</label> <div class="custom-file"> <input type="file" class="custom-file-input" name="pdf" id="pdf"> <label class="custom-file-label" for="image">Select PDF</label> </div> </div> <button type="submit" class="btn btn-primary">Upload</button> </form>'''
I get a similar issue in my project and this is the solution I found :-) Get call for login @app.route("/login") def getCall(): response = {} response['result'] = '0' response['messege'] = 'response from get' return response post call for login @app.route("/login", methods=['POST']) def postCall(): response = {} response['result'] = '0' response['messege'] = 'response from post' return response
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, html, flask" }
Is it possible to slove problem with norm constraints using only linear programming? The problem is $\min_x w^Tx$ s.t. $Ax=b$ $||x||_2=1$ Is there any tricks to handle the norm constraints such that the problem can be solved by only using linear programming tools?
Unless you can get rid of the two-norm, I doubt it's possible. You can however get it to work with a $||\bullet||_1$ or $||\bullet||_\infty$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "linear programming" }
Objective C to Python Serialization I have an NSMutableArray filled with BeziarPaths. I'd like to serialize it so that its accessible on Python. Someone suggested to me that I can try GZIP + InkML or GZIP +JSON. I was wondering what the best way to do this is. I am also really new to this, so example code would be extremely helpful. Thanks
Choose what you like most. Both are standards, but JSON is a generic format used for serializing dictionaries and arrays, while InkML focuses on drawing related objects. JSON support is available in both Python and Objective-C, while InkML has no built-in support in either.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, objective c, serialization" }
How to make xpathSApply output vector of length nodes using xmlValue? Lets say I have following: library(XML) my.xml <- ' <tv> <show> <name>Star Trek TNG</name> <rating>1.0</rating> </show> <show> <name>Doctor Who</name> </show> <show> <name>Babylon 5</name> <rating>2.0</rating> </show> </tv> ' doc <- xmlParse(my.xml) xpathSApply(doc, "/tv/show/rating", xmlValue) # [1] "1.0" "2.0" There are three 'show' nodes. How can I instead make the output be: # [1] "1.0" NULL "2.0" so as to account for Doctor Who not having a rating in the xml but the length still being 3?
If you supply the path all the way to 'rating', the node list will already only have the 2 elements to begin with. So when you apply `xmlValue()` to this node list, the output will also only have 2 elements. You can get around this by just starting from one level up in the tree: > xpathSApply(doc, '/tv/show', function(x) xmlValue(xmlChildren(x)$rating)) [1] "1.0" NA "2.0"
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "r, xpath" }
mysql insert where data from combine two table with no relation I have two table Table1 NO | CITY 1 | city1 2 | city2 Table2 NO | PRODUCT | CODE 1 | product1 | 1 2 | product2 | 2 3 | product3 | 1 and I want to combine table1 and table2 where table2 code is 1 and insert it into table3 like this Table3 NO | CITY | PRODUCT 1 | city1 | product1 2 | city1 | product3 3 | city2 | product1 4 | city2 | product3 Thank you for any help.
If your `NO` is the `AUTO_INCREMENT` column, we can try to use `INSERT INTO ... SELECT` with `CROSS JOIN` to do that. INSERT INTO Table3 (CITY ,PRODUCT) SELECT t1.CITY ,t2.PRODUCT FROM Table1 t1 CROSS JOIN Table2 t2 WHERE t2.CODE = 1
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "mysql" }
Search for all [{my value here}] and put them in an array in PHP I have the following HTML code below, which acts as a template for a module on my php application. The following HTML code is stored as the string: $parsedTemplate Here is the HTML <td> [{item3}] </td> <td> [{item2}] </td> <td> [{item3}] </td> I want php to search the $parsedTemplate string and make an array like the following 'item1','item2','item3' How can I achieve this in an efficient way? Regex maybe?
Try this regex: (?s)\[{\K.*?(?=}]) Regex live here. Explaining: (?s) # allows . to match new line \[{ # your open-delimiter \K # you do not need the delimiter, then clear it .*? # till the first-next occurrence where (?=}]) # is possible to see the close-delimiter Hope it helps. * * * **Edit** : To test, it would be like: preg_match_all('/(?s)\[{\K.*?(?=}])/', $parsedTemplate, $match); print_r($match);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, regex" }
Strange wiring found in old bathroom I'm swapping out some old switches in my bathroom and have run into something I've never seen before. The middle light switch here has both a black and red wire connected to the load terminal. ![enter image description here]( Currently the leftmost switch turns on the main lights, the middle switch turns on the shower light and fan, and the rightmost switch does nothing. I'm assuming the previous owner must have wanted the shower light and fan to come on at the same time and changed the wiring. Can I change this so the fan and shower light is controlled separately? I'm obviously not an electrician but I want to do this safely and learn how to fix this myself in the future.
Assuming that the wiring is as you think it is, which you can verify by disconnecting one wire (red or black) at a time to see what the switch does, yes that is perfectly normal (provided the screw terminal can handle two wires, which may or may not be the case) and, yes, you can split. Replace the single switch with a double like this one: ![Leviton double switch]( A double switch will often have a removable tab on the "line" side so that you can have one hot in and two switched hots out without having to do anything special. The other thing to do is make sure that both switched hots (red and black) and a matching neutral (white) are together in one cable/conduit. That is critical (for code and for safety), but sometimes things are not wired correctly.
stackexchange-diy
{ "answer_score": 4, "question_score": 1, "tags": "switch, light" }
Which primepowers can divide $a^a+b^b$, when gcd(a,b)=1? Does every primepower $p^n$ divide some number of the form $$a^a + b^b$$ where a and b are natural numbers and gcd(a,b)=1 ? Without this restriction, the answer is clearly yes. If not, what are the conditions for $p^n$ ? I checked various primepowers and always found a solution, but I would like to have a general proof.
The answer is yes, there are infinitely many solutions even for $a=1$. You can give an example solution explicitly: $a=1$ and $b=(p-1)p^n-1$ does the job. The reason is that the modulus of $a^a \bmod m$ only depends on $a \bmod m$ and $a \bmod \varphi(m)$. So $a^a \bmod m$ will be the same if the value of $a \bmod lcm(n,\varphi(n))$ is the same. In the case of $m = p^n$, we have $M:=lcm(n,\varphi(n)) = (p-1)p^n$. Now $1^1+(-1)^{-1}\equiv 0 \bmod M$, therefore any assignment of $a$ and $b$ such that $a \equiv 1 \bmod M$ and $b \equiv -1 \bmod M$ leads to $a^a + b^b \equiv 0 \bmod p^n$. Note that this approach is not restricted to prime powers but works for arbitrary numbers instead of $p^n$.
stackexchange-math
{ "answer_score": 2, "question_score": 4, "tags": "number theory, prime numbers" }
Whats the difference between initialising a variable before and after onCreate()? For example, if I want to make a list called `List<String> stringList;`, whats the difference if I call it `stringList = new ArrayList<>();` in onCreate() and just doing `List<String> stringList = new ArrayList<>();` ? And if I use `List<String> stringList;` before onCreate(), why declare it `private`?
The objects which are not dependent on Activity creation process can b created and initialized and define before onCreate() method. But the things or objects which are dependent with that Activity are declared before onCreate() but must be initialized in onCreate(). For example if your registering a view (like button) in Activity, then you have to initialize it in MainActivity. Hope so first thing is cleared. 2nd one, it is not necessary to make a variable/function private or public. But best practice is that if you are using variable/function which relate only with that activity then you should make it private.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "java, android, android studio, oncreate" }
How can I download files to my trigger.io app? How can I download files to my trigger.io app? My app shows offline data, but I need the way how my app can download and store localy fresh data from server. Data are one js fole with array of items and some images, each one for each product item from array. For Phonegap there is something like this < is there anything for trigger.io? David
You can cache the file(s) locally - < And/or you can utilize user preferences - < Also, check this out - < cacheURL
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "trigger.io" }
Trying to plot frequency response of a filter Transfer Function in MATLAB, it looks wrong I have the transfer function below which is for a IIR filter and trying to plot its frequency response for omega<pi. r=0.99 and theta=pi/3: ![enter image description here]( Here is my attempt at implementing it in MATLAB: N=5000; W=(0:pi/(N-1):pi); r1=0.99; theta=pi/3; z= exp(j*W); num= (1-r1); den= (1-2*r1*cos(theta)*z.^(-1)+r1^(2)*z.^(-2)); TF=num./den; TFdb= 20*log10(TF); plot(W,TFdb) Here is what I get: ![enter image description here]( Apparently it should look like this: ![enter image description here]( I am very new to this and can't tell what I'm doing wrong, would appreciate if anyone can help.
How did you derive the second figure? I got the different result using the following code: b = 1 - r1; a = [1, -2*r1*cos(theta), r1^(2)]; figure; freqz(b, a) ![enter image description here]( The only problme I can find in your code is that `TFdb= 20*log10(TF);` should be `TFdb= 20*log10(abs(TF));` Did you take the wrong sign of $a_1$ when calculating second transfer function? b = 1 - r1; a = [1, 2*r1*cos(theta), r1^(2)]; The above code generates the second figure.
stackexchange-dsp
{ "answer_score": 0, "question_score": 0, "tags": "filters, transfer function, frequency response" }
infinite recursion when printing instance in python I get a Runtime error (maximum recursion) when I execute the following code. I'm trying to generate a list of instances; then I would like to print each one. I'm not sure what's going on here. Anyway, what is the correct way to access each instance from the instance list? I do realize I'm using a string of digits to name the instances and this is not cool. But say each number on the list is associated with a bunch of information. Then having attributes for each could make things accessible. I tried using a dict but I end up with nested dicts and I just didn't like it. Thanks in advance. class MyClass(object): def __str__(self): stuff= str(self) return stuff mylist = ['1234567','8910111','1213144','7654321'] inslist = [MyClass() for i in mylist] print inslist[0]
The problem is in your `__str__`. If you call `str(self)`, it will call itself. I think you meant was this: class MyClass(object): def __init__(self, i): self.i = i def __str__(self): return str(self.i) mylist = ['1234567','8910111','1213144','7654321'] inslist = [MyClass(i) for i in mylist] print inslist[0]
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, recursion, instance" }
Multiple lines in detail text label of table view cell I am trying to have multiple lines in a cell's detailTextLabel but with discrete information on each line. In order to get multiple lines in the detailTextLabel I would use cell.detailTextLabel?.numberOfLines = 0 cell.detailTextLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping But I am looking to have specific text on each line. I know swift doesn't have a line break so I believe it would have to look like this: cell.detailTextLabel!.text = "Line 1" + "Line 2" + "Line 3" + "Line 4" + "Line 5" But this returns Line1Line2Line3Line4Line5 in the detailsTextLabel. I can successfully have multiple lines by putting in a super long string and have it wrap down to multiple lines. Is there a simple way to accomplish this? Or just not possible?
Thanks to Shoaib all you have to do is implement "\n" into the string cell.detailTextLabel!.text = "Line 1" + "\n" + "Line 2" + "\n" + "Line 3" + "\n" + "Line 4" + "\n" + "Line 5"
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "ios, swift, uitableview" }
Is chromecast stuck at chrome version 31 For my chromecast app I need a few HTML5 APIs that are available (or stable enough) in Chrome >= 33. But `navigator.userAgent` when run in the chromecast dev console reports: "Mozilla/5.0 (CrKey armv7l 1.8.17977) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.0 Safari/537.36" Does the `Chrome/31.0.1650.0` part mean that chromecast devices are running that old version of chrome? If yes can we expect an update in the future?
Yes you can expect an update in future. Btw, the proper place for these types of questions which are non-technical is our Cat Developer G+ community.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "chromecast, google cast" }
Draw graphs with DELPHI and Graviz I#m going to use the project GRAPH VIZ WITH DELPHI for drawing graphs with DELPHI. Compile is fine , but run gives error as shown below !DUBUGGER ERROR , what class to register and how ??? Never done this before
This looks like you are missing a COM registration. The actual component is implemented in a COM component and needs to be registered with `regsvr32` or similar. It looks like you are using WinGraphviz which can be downloaded here: < You need to get the compiled .dll installed and register it with `regsvr32`. regsvr32.exe WinGraphviz.dll The link above contains all the documentation you need to install and register the component.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "delphi" }
A problem based on number theory? If 'p' is a prime greater than 3, then show that 2p + 1 and 4p + 1 cannot be primes simultaneously. Do I have to use Fermat's Little Theorem to solve this?
**A HINT** $$p >3 \Leftrightarrow p \not \equiv 0 \pmod 3$$ $$p \equiv 1 \pmod 3 \Leftrightarrow 2p+1 \equiv 0 \pmod 3$$ $$p \equiv 2 \pmod 3 \Leftrightarrow 4p+1 \equiv 0 \pmod 3$$
stackexchange-math
{ "answer_score": 7, "question_score": 0, "tags": "elementary number theory, prime numbers" }
How to select questions which have no answers, in sqlalchemy I've two classes: Question and Answer. A question may have 0 or many answers. class Question(Base): __tablename__ = "questions" answers = relationship('Answer', backref='question', primaryjoin="Question.id==Answer.question_id") class Answer(Base): __tablename__ = "answers" Now I want to find all the questions have no answers, how to do it? I tried: Session.query(Question).filter('count(Question.answers)==0').all() It is incorrect. What is the right one?
Just use session.query(Question).filter(Question.answers == None).all() which basically is a `NULL` check (common filter operators). Here's a gist example: < The query generates the following SQL: SELECT questions.id AS questions_id FROM questions WHERE NOT (EXISTS (SELECT 1 FROM answers WHERE questions.id = answers.question_id))
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, sqlalchemy" }
Using DynamicNode and need a lifecycle hook to run after all tests have completed I'm using `DynamicNode` very successfully in a framework that dynamically generates tests and executes them. Now I have a need to execute some code after all `DynamicNode` collections have executed. This can mean that I have a single JUnit5 class with multiple methods that return `Iterable<DynamicNode>`, but I want to run something only after all the test methods have completed. Is there a way to do this automatically ? EDIT: ideally I would like my framework to inject the code to be executed automatically, without the user needing to add a `@AfterAll` annotation on a method and write some extra code.
Each method that is annotated with `@TestFactory` takes part in the default lifecycle. That means in your case an `@AfterAll` annotated method should do the trick. > **`@AfterAll`** > > Denotes that the annotated method should be executed after all `@Test`, `@RepeatedTest`, `@ParameterizedTest`, and `@TestFactory` methods in the current class; analogous to JUnit 4’s `@AfterClass`. Such methods are inherited (unless they are hidden or overridden) and must be static (unless the "per-class" test instance lifecycle is used). Copied from <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "junit5" }
Is there any way to use LaTex formulas in a programming language to make a real calculation We may write down the calculation formula of a distance measurement with the following LaTex string: dist_{12} = \sqrt{ x^2 + y^2 } dist_{13} = \sqrt{ z_{33}^2 + y^2 } total = dist_{12} + dist_{13} This looks good so far. If I really need to make a computer calculate these equations, then I need the following - eg. Python - code: x = 1 y = 2 z_33 = 3 dist_12 = sqrt(x**2 + y**2) dist_13 = sqrt(z_33**2 + y**2) total = dist_12 + dist_13 print "Total distance is: ", total As a result, I spent as twice as the effort actually needed. However, if there was a way to use exact same LaTex formula (which may include integrals, derivatives, limits etc.) in a programming language (preferably Python, Javascript and Julia) we would re-use our efforts later in our real-world applications. Is there any way to make this happen?
You can 1. Use latex2sympy to translate latex equations to SymPy objects 2. Just use SymPy printing tools to get the same equations as latex Both alternatives avoid you having to re-type the equations.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "javascript, python, latex, julia" }
Closed form for a summation. Mathematica says $\displaystyle\sum_{k=1}^{n} \dfrac{\binom{n-1}{k-1}}{n^k} = \dfrac{(n+1)^{n-1}}{n^n}$. I would like to know how to show this equality. The left hand side is the solution to a probability problem: Select integers (with replacement) from {1,2,...,n} until the cumulative sum of your selected integers is at least n. What is the probability that your cumulative sum is exactly n? The right hand side is the ratio of labeled trees on n+1 nodes to functions from [n] into [n]. A combinatorial proof to the equations would be great. I would settle for an analytic proof.
According to the Binomial Theorem we get as a series expansion for $(n+1)^{n-1}$ the following $$(1+n)^{n-1}=\sum_{k=0}^{n-1}\binom{n-1}{k}n^{n-1-k}$$ By applying the index shift $k'=k+1$ \- and therefore $k=k'-1$ \- we further get $$\sum_{k=0}^{n-1}\binom{n-1}{k}n^{n-1-k}=\sum_{k'=1}^{n}\binom{n-1}{k'-1}n^{n-k'}$$ One may note that within the term $n^{n-k'}$ the $n^n$ is independed of the index. By reshaping the whole equality we get $$\begin{align} (1+n)^{n-1}&=\sum_{k'=1}^{n}\binom{n-1}{k'-1}n^{n-k'}\\\ &=n^n\sum_{k'=1}^{n}\frac{\binom{n-1}{k'-1}}{n^{k'}}\\\ \Leftrightarrow \frac{(1+n)^{n-1}}{n^n}&=\sum_{k'=1}^{n}\frac{\binom{n-1}{k'-1}}{n^{k'}} \end{align}$$ which is your desired result.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "probability, combinatorics" }
How to solve this problem with nltk regular expression? In the W3C Date Time Format, dates are represented like this: `2009-12-31`. Replace the `?` in the following Python code with a regular expression, in order to convert the string `'2009-12-31'` to a list of integers `[2009, 12, 31]`: [int(n) for n in re.findall(?, '2009-12-31')]
[int(n) for n in re.findall(r'\d+', '2009-12-31')]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, regex" }
What's wrong with this JavaScript object literal assignment? Perhaps I'm just being dense, but I don't understand why Netbeans is telling me this is bad syntax: var events = { 'onkeyup' : 0, 'onchange' : 0, 'onclick' : 0 }; Lines 2-4 are squiggled red.
D'oh! I failed to realize that this JavaScript is being parsed by PHP and contains some PHP code prior to the object literal assignment. Apparently the JavaScript Debugger is not too happy about statements like: var foo = <?php print $bar ?>; Go figure. :P
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, netbeans" }
How to add fields to array that have no property react js I have an array like this: [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3}] the question is, how can i define name like this [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3, name: ''}] using array.map ?
You can map to loop over the objects and then using the method hasOwnProperty on object check if there is name property or not , if not add that property to the object var arr = [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3}]; arr.map(obj => { if(!obj.hasOwnProperty("name")){ obj['name'] =""; } return obj; }) console.log(arr);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, reactjs" }
bash - count and output lines from command I'm writing a small script that needs to run a program that outputs multiple lines, and then display the count of those lines. The program, however, can take several seconds to run and I would rather not run it twice, once for the output and another for the count. I can do it running the program twice: #!/bin/bash count=$(program-command | wc -l) program-command printf "$count lines" Is there a way to get the count and output while only running the program once? This output has formatting, so ideally that formatting (colors) would be preserved.
Use `tee` and process substitution: program-command | tee >(wc -l) To preserve color, prefix the command with `script -q /dev/null` as per this answer: script -q /dev/null program-command | tee >(wc -l)
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 7, "tags": "bash" }
Using jquery to swap out contents of a div I have this bit of html: <div id="storeBtn"> <a href=" target="itunes_store" class="button">Download on iTunes</a> </div> If I detect Android, I want to change it to this: <div id="storeBtn"> <a href=" class="button">Download on Amazon</a> </div> This is my attempt: var ua = navigator.userAgent.toLowerCase(); var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); if(isAndroid) { $("#storeBtn").html("<a href=' class='button'>Download on Amazon</a>"); } But nothing changes. I also tried replaceWith() instead of html().
Don't put your code in the head section but in a script element at the end of the body. ... <script> var ua = navigator.userAgent.toLowerCase(); var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); if(isAndroid) { $("#storeBtn").html("<a href=' class='button'>Download on Amazon</a>"); } </script> </body> </html> When your code is in the head, it's executed before the addition of your div to the DOM.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, html" }
UDP Packet size and packet losses I've been writing a program that uses a stop and wait protocol on top of UDP to send packets over LAN and also over WAN. I've recently been testing my program and have noticed that the packet loss rate is higher for larger packets (approaching 64k bytes). Intuitively this makes sense but what are the actual reasons for this?
UDP packets greater than the MTU size of the network that carries them will be automatically split up into multiple packets, and then reassembled by the recipient. If any of those multiple sub-packets gets dropped, then the receiver will drop the rest of them as well. So for example if you send a 63k UDP packet, and it goes over Ethernet, it will get broken up into 47+ smaller "fragment" packets (because Ethernet's MTU is 1500 bytes, but some of those are used for UDP headers, etc, so the amount of user-data-space available in a UDP packet is smaller than that). The receiver will only "see" that UDP packet if all 47+ of those fragment-packets make it through okay. If just one of those fragment-packets gets dropped, the whole operation fails.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "networking, network programming" }
Multiple ListView Example I am working on an application where I have to display the list of songs in an Activity. I know I can do that using the ListView but actually the problem is that I want to display them in a Particular Manner. I want to display them AS PER THE ARTISTS NAME. i.e. I WANT TO DISPLAY THE MULTIPLE SONGS OF A PARTICULAR ARTIST IN ONE ROW AND SIMILARLY THE OTHER BELOW THE ONE. IN THE LIST VIEW FIRST NAME IS SUPPOSED TO BE THE NAME OF THE ARTIST THEN THE LIST OF HIS SONGS, AGAIN THE NAME OF THE SECOND ARTIST AND HIS LIST OF SONGS BELOW HIS NAME AND SO ON. Can anyone please help me on this. Thanks, david
Basically it is not a good idea to use multiple ListViews here. One method would be to use multiple rows in the ListView (and use different types for the rows, which ListView supports). The other method would be to inflate a whole LinearLayout/RelativeLayout as a view and put your children there. I would recommend the first one - multiple rows, different types.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "android, listview" }
inserting data to influxdb by nifi is too slow I have data pipeline in NiFi , which listen to system log and process received data and extract attributes by "ExtractText" processors Then make influx input format by "ReplaceText" and at the end insert to influxdb by "PutInflux" processor. But I get a long queue before putInflux processor because insert speed is too slower than produced data. Please help me to increase insert speed. Data PipeLine ReplaceText processor configuration : (view_stat -> measurement , Listing_id -> tag, event_id -> value , Timestamp -> time ) PutInflux processor configuration
Thanks Mattyb, I increased number of threads in PutInfluxDB processor and solved the problem :)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "apache nifi, influxdb" }
Android XML values - String Array :: Placing a quote in the value? I have a string array in strings.xml, in the values I need to have shutter speeds. For example: > 3"2 or > 0"8 I try to enter the data in the xml, but that does not work. Alternatively; when I enter the value in the graphical interface of the strings.xml file, it places the data as !screen dump Which does not display when I place the array in a spinner later on. Basically, I would like to know how to display a single quotation mark in a string of a string array and have it display in a spinner later on. Thanks for any help, have a nice day.
Try: 3\"2 and 0\"8 Check out String Resources > Formatting and Styling on the official docs.
stackexchange-stackoverflow
{ "answer_score": 31, "question_score": 12, "tags": "android, xml, arrays" }
How to throw an underflow exception? In C# I can throw an overflow exception: throw new System.OverflowException("Cannot push onto a full stack."); How do I throw an underflow exception? throw new System.UnderflowException("Cannot pop from an empty stack."); It doesn't look like `UnderflowException` is a method of `System`.
There is no `UnderflowException`. If you do following: var stack = new Stack(); stack.Push(1); var x1 = stack.Pop(); var x2 = stack.Pop(); You will get `InvalidOperationException` : > Stack empty. But you completely free to create your own `Exception` class: public class UnderflowException : Exception { public UnderflowException(string message): base(message) { } } and throw it if you need: throw new UnderflowException("Could not pop from empty stack");
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "c#, .net, exception" }
Constructor on type 'System.String[]' not found I defined in my BuildTemplate.xaml a new Argument with Type of String[][]. !new Argument in my BuildTemplate Now when I open the build template and try to fill the argument I got the error: > Constructor on type 'System.String[]' not found. !Constructor on type not found What's the problem?
Try using an IEnumerable<string>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "tfs, arguments, build automation, tfsbuild" }
Knockout changing data-bind based on user selection I have some knockout code that consists of a list object and item object. There could be multiple lists and each list has an array of objects. I made this fiddle to demonstrate what I am trying to explain. What I want to be able to do is have a select box where the user can select a list and then the items from that list will be loaded. Currently I have my data-bind set up like this `data-bind="foreach: lists[0].items"`. The index of the list is hard codded into the bind. Is there some way that I could dynamically assign the index of the list I wish to use?
Just put an observable instead of `0`: data-bind="foreach: lists[selectedIndex()].items" With `selectedIndex`: `self.selectedIndex = ko.observable(0);`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, arrays, data binding, knockout.js" }
$\min\{h(t),1\}$ represented as an algebraic expression This function just blew my mind, how can it be derived? $$min\,\\{h(t),1\\}=\frac{h(t)+1-|h(t)-1|}{2}\\\ h(t)=\frac{1}{3}=\frac{\frac{1}{3}+1-|\frac{1}{3}-1|}{2}=\frac{\frac{4}{3}-\frac{2}{3}}{2}=\frac{2}{3*2}=\frac{1}{3}\\\ h(t)=2=\frac{2+1-|2-1|}{2}=\frac{3-1}{2}=1$$
Arguing in cases (as Randall suggested in the comments) is the best formal way to go about proving that formula. But if you are looking for a more intuitive way, here is one approach: Take two real numbers $a$ and $b$. The midpoint between them is at $\dfrac{a+b}{2}$. Also, since $|b-a|$ is the distance between $a$ and $b$, both of the numbers $a$ and $b$ are $\dfrac{|b-a|}{2}$ away from this midpoint. So to get to the smaller of $a$ and $b$, you need to start at $\dfrac{a+b}{2}$ and "go backward" by $\dfrac{|b-a|}{2}$. Thus, $\min\\{a,b\\} = \dfrac{a+b}{2} - \dfrac{|b-a|}{2}$. You can think in a similar manner to see that $\max\\{a,b\\} = \dfrac{a+b}{2} + \dfrac{|b-a|}{2}$.
stackexchange-math
{ "answer_score": 4, "question_score": 0, "tags": "real analysis" }
Display and move image I have this piece of code that makes an image move, but I want this to be displayed 5 seconds after I open a page. How do I do this? Thanks @IBOutlet weak var moveobj: UIImageView! override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) let orbit = CAKeyframeAnimation(keyPath: "position") var affineTransform = CGAffineTransformMakeRotation(0.0) affineTransform = CGAffineTransformRotate(affineTransform, CGFloat(M_PI)) let circlePath = UIBezierPath(arcCenter: CGPoint(x: 198 - (100/2),y: 135 - (100/2)), radius: CGFloat(155), startAngle: CGFloat(255), endAngle:CGFloat(M_PI * 2 ), clockwise: true) orbit.path = circlePath.CGPath orbit.duration = 18 orbit.additive = true orbit.repeatCount = 0.15 orbit.calculationMode = kCAAnimationPaced moveobj.layer .addAnimation(orbit, forKey: "orbit")
To wait 5 seconds before you do anything you can use a `Timer`, see below how to use it: override func viewDidLoad() { super.viewDidLoad() // start a new timer with an interval of 5 seconds Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(ViewController.showImage), userInfo: nil, repeats: false) } // after 5 seconds this class will be called and here you can do your work func showImage(){ print("Showing") }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "swift" }
Does System.Windows.Forms.Application.Run(form); require form.Dispose()? According to MSDN > Dispose will be called automatically if the form is shown using the Show method. If another method such as ShowDialog is used, or the form is never shown at all, you must call Dispose yourself within your application. What happens if I launch a form via `System.Windows.Forms.Application.Run(form);`? Closing the form allows execution to continue. If I call form.ShowDialogue() after the block it throws up an `ObjectDisposedException`. To be sure, do I need to call `form.Dispose()` when launching a form via `Application.Run()` or is there any advantage or disadvantage to doing so?
The ApplicationContext class controls the lifetime of the UI thread. Its ExitThread() method initiates a shutdown that exits the internal message loop. When you use the Application.Run(Form) overload then Winforms creates an ApplicationContext with the ApplicationContext(Form) constructor. Which subscribes the form's HandleDestroyed event, the event handler calls ExitThread(). So the lifetime is purely based on whether the native Windows window for the form is alive. The two common ways to destroy that window is the user clicking the window's Close button or your app calling the Close or Dispose methods. Either way, the form is automatically disposed. The form object is dead after this, trying to revive it throws ODE.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "winforms" }
Gradient in linear regression with weights From 3.3 in Pattern Recognition in Machine Learning, I am asked to obtain weights for a regression with a weighted square loss function. That is, $E(w,x) = \sum_{j=1}^n r_j(y_j - x_j^Tw)^2$ where $r_j$ is the weight for example $j$. I'm trying to formulate this as a vector problem and take its gradient. If we let $R =\begin{bmatrix} r_1 & 0 & \dots & 0 & 0 \\\ 0 & r_2 & 0 & \dots &0 \\\ 0 & \dots & \dots & \ddots & 0 \\\ 0 & \dots 0 & \dots & 0 & r_n \end{bmatrix} $ be a diagonal matrix with weights on the diagonal, we can rewrite $E(w,x) = (y-Xw)^TR(y-Xw)$. Then $\nabla_w E(w,x) = 2RX^T(y-Xw)$ Solving for $w$, I don't get the desired answer of $X(X^TX)^{-1}\sqrt{R}y$ Where am I wrong?
The gradient is $-2X^\top R (y - Xw)$. (Note that $RX^\top$ does not make sense since $R$ is $n \times n$ and $X^\top$ is $p \times n$.) Setting this equal to zero yields $\hat{w} = (X^\top R X)^{-1} X^\top R y$, which is the solution for weighted least squares. Not sure where your "desired solution" comes from.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "linear algebra, linear regression" }
XCode: Stack View breaking with custom control I am looking to layout multiple components in a stack view. The layout is working perfectly until I add a custom control, which is removing all elements below it in the stack. I'm not sure what could be causing this (perhaps it's from constraints?), any ideas would be appreciated! Storyboard (the custom control is "Rating Control", in between the Name Text Field and the Photo Image View): ![Storyboard]( Simulator without custom control: ![Simulator without custom control]( Simulator with custom control: ![Simulator with custom control](
This was caused by the following function in my custom control: override var intrinsicContentSize : CGSize { let buttonSize = Int(frame.size.height) let width = (buttonSize + spacing) * stars return CGSize(width: width, height: buttonSize) }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, xcode, storyboard" }
Controlling Two Circuits with One Switch I'm trying to build a circuit with multiple timers, each with an SPST output relay. I want to connect up my circuit so that if any of the timers reaches their set point, they turn on a beacon. It doesn't matter how many timers reach their set point, as long as one has I want the beacon to be on. Additionally each timer will turn on its own light when it reaches the set point. I've drawn up a circuit, but have a question, is it possible to control two lights with one SPST switch? The simplest form of the circuit I'm visualizing is shown below: (All the Lights and Beacon and Power Supplies are 12V) ![enter image description here]( The outsides (including the switches) are the timer circuit section, while the middle part is the beacon and its power supply. I'm particularly confused about what happens in the red path. Would that be bad for the lights? Or turn them on before the timer switches close?
No real need for 3 power supplies here, so I simplified. Specific parts are circuit-lab defaults for the part type, not suggested part numbers. !schematic simulate this circuit - Schematic created using CircuitLab Add 2 diodes and I think you could make it work. As it stands either switch will turn on all three lamps. In the "red path" the voltage sources (as drawn) cancel, so no current should flow. The "beacon" needs a diode pointing at each switch which will permit it's current to flow through the switch, but prevent the current from the "individual timer" light on the opposite side from flowing to the switch beyond.
stackexchange-electronics
{ "answer_score": 1, "question_score": 3, "tags": "switches, circuit analysis" }
SASS - iniciante (dúvida pequena) Olá! Estou aprendendo SASS e me deparei com um problema que era pra ser simples,. heehehe. Isso não está compilando: $purple: #9b0aa8; #fofo{ width:40px; height:40px; background: $purple; } #fofo:hover{ @include transform(translateY(50%), scale(0.5)); } <div id="fofo"></div> Ele apresenta prblema na linha: `@include transform(translateY(50%), scale(0.5));' dizendo: stdin 10:3 root stylesheet on line 10 at column 3 Alguma ideia? parece tudo certo pra mim. =//
Acredito que primeiramente vc deve criar o seu @mixin, e depois fazer o @include como vc pode consultar no guia: < Dessa forma: $purple: #9b0aa8; @mixin transform($property, $propertyx) { transform: $property, $propertyx; } #fofo{ width:40px; height:40px; background: $purple; } #fofo:hover{ @include transform(rotate(30deg), scale(0.5)); } Vc pode testar aqui que vc vai ver que vai compilar direitinho <
stackexchange-pt_stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "sass" }
How to markdown multiline code blocks in VS Team Services How can I write multi line code blocks in in VS team Services that maintains the new lines. For instance I have two lines of code like this. line one line two But no matter what I try the result always renders in one line like this. line one line two I have tried following the guide lines here. I have tried before and after back quotes ``` line one line two ``` four leading spaces line one line two Leading & trailing empty lines, triple back quotes on every line, wrapping every line in back quotes, and several other options but the result is not what I want. Is there some trick to multi line markdown block quotes in VS Team Services to make this work?
The same content/code works fine in dashboard and file explorer (Code > Files > Select README.MD) pages, but doesn’t work fine for project page. I submit a feedback here: VSTS Markdown in project page multiple line of code issue, you can follow it.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "markdown, azure devops" }
Limited fields at registration time and full profile after logged in I want to display limited fields at registration time say username email and password And when user get registered then he can edit his profile with rest of the fields like Phone no., Address, Date of birth etc. I tried adding field in admin/config/people But that fields are visible at the time of registration. How can I do that any help.... I am using drupal 7
You can do this without installing another module. It's good practice to avoid installing additional modules if you don't have to. 1) Go to the Manage Fields screen for user accounts at admin/config/people/accounts/fields 2) Edit the fields you want to hide/display from the user registration form. There is a setting at the top of the form called "Display on User Registration Form". View the attached screenshot for example. 3) If a field is marked as "required", it has to be displayed on the user registration form. Certain form fields on the user registration form are not managed through the "Manage Fields" screen. So they can't be changed without getting in to modules. These include username, password, and a few others depending on your set up. But fields that you add yourself, like phone number, address, etc., can be edited. !enter image description here
stackexchange-drupal
{ "answer_score": 1, "question_score": 1, "tags": "7, users" }
Assigning a view to a specific record type I want to have 2 different record types for my Account object. Say 'A' and 'B'. They are related to each other i.e. my Account objects have many-to-many relationship. I want to create a view say 'All B Accounts' which displays all B accounts for an A account and hence the view should only be available to select for an A type account. How can I achieve this?
I'm not sure if I get you right, but what you are looking for sounds more like a related list to me, which shows all B Accounts for a given A. This would be pretty much standard functionality available in the wizard where you define the relation (Lookup or Mastet/Detail) or later on if you edit the layout and select related lists. But I wonder if this is really what you're looking for. If not, please elaborate.
stackexchange-salesforce
{ "answer_score": 2, "question_score": 0, "tags": "record type, custom view" }
Постраничная навигация 1-10,10-20,20-30 > Получаю count(id) пример **60** **Как сделать так чтобы вывести в виде:** 1-10,10-20,20-30,30-40,40-50,50-60
Возможно я не прав, но есть велосипед на webew и я сказал бы очень даже не плохой. > Страницы: предыдущая 1-20 21-40 41-60 61-80 81-100 следующая
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, mysql" }
Drawing the plot of $N(30,20)$ by given the plot of $N(20, 36)$ I have the following problem: I'm given the plot of normal distribution $N(20,36)$. ![enter image description here]( I am asked to draw the plot of $N(30,20)$ next to it. I know that the mean is 30, so it's top is going to be on the right. I also know that it has smaller standard deviation so it's going to be more pointy (sharper). When I see it's plot on Minitab, I see that not only it is sharper, but it also has higher probability for the mean. * How do I determine how high the plot gets (what's the probability for the mean)? * What other advices would you give me for making the second plot as accurate as possible?
The pdf is given by $$f(x)=\frac{1}{\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)$$ The maximum value is $f(\mu)$. For the second part you could make a table of values.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "statistics, probability distributions, normal distribution, graphing functions, descriptive statistics" }
managing options using radio button I am having a number of options that a user can select only one at a time, so I chose to use radio buttons to present them. For some reason I do not know, all the radio button can be selected at the same time. I wish to know what I must do to select on one radio at a time. I use blade template alongside twitter bootstrap 3.0.
To be mutually exclusive the radio inputs must have the same name (for each group of mutually-exclusive inputs): <!-- mutually exclusive group --> <input type="radio" value="1" name="group1" /> <input type="radio" value="2" name="group1" />
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, radio button" }
How can I increase the number of hardware UARTs in a design with a single UART MCU? I am using a TI CC430 MCU because it contains an embedded CC1101 radio frontend. I would really like to stick with this MCU. However, I need to simultaneously interact with a separate serial radio, a FTDI (uart->USB), and an RS232 GPS. So it would be nice to have 3 separate UARTS on the MCU. What are my options for increasing the number of UARTs? I have considered adding a CPLD and muxing the single UART to 3 outputs, but I really don't like that approach because it not really 3 simultaneous connections.
You could add an extra UART over SPI or I2C. These have internal FIFO buffers inside them so you periodically check them for content and let them handle some buffering. NXP, TI, Maxim probably offer these parts. MAX3100, SC16IS752 etc. You could also add a second MCU to do this, but as you're already using quite a simple microcontroller with 1 UART and want to stick to that, that seems overkill. You could also use a multiplexer to choose between the UART your micro talks to. But as you mentoined data is transmitted simultaneously , that won't work. Software serial could be your last option but it can be very annoying to deal with if your microcontroller is doing other stuff as well.
stackexchange-electronics
{ "answer_score": 8, "question_score": 5, "tags": "microcontroller, uart, rs232, programmable logic, ftdi" }
Is it safe to run an operating system from an USB flash drive? I've got a laptop that has a broken harddisk controller. Replacing the motherboard is quite expensive. I thought about buying a flash drive and installing & running the system from it. However, I'm concerned about some things. * Speed: Are they fast enough for swap memory (I've got only 1GB RAM installed.) I'm considering buying 2 or 3 of them and making them into a RAID. * What about limited write cycles? How long will it last for a system that has a filesystem with journaling enabled? I'd hate to abandon it. * Are there significant differences between internal SSD which are used in modern laptops like MacBooks and USB flash drives? * What should I expect in 10 years when the memory wear starts kicking in?
There is nothing unusual about running an operating system from a USB flash drive; many Linux distros are optimised for this very purpose. In fact there is a laptop being sold without any internal storage - you can boot a variety of operating systems from USB keys. Meet the **Gdium Liberty** : !alt text 'Broken' like yours, by design. The short answer: yes, it is safe to run an operating system from a USB flash drive. As for your worries about the life expectany of flash memory, this has been discussed ad nauseam. The interwebs are full with more or less conclusive discussions regarding the matter.
stackexchange-superuser
{ "answer_score": 4, "question_score": 3, "tags": "boot, usb, usb flash drive, operating systems" }
Manually apply patch If I manually apply a patch due to an error when trying to install the patch via SSH, should I update the "applied_patches" file manually also?
It is not mandatory , but its a good practice so that other dev that might work on project will know that the patch is applied and can be used to get of list of applied patches like $ grep -F '|' app/etc/applied.patches.list|cut -f 2,1 -d'|' 2017-06-01 07:28:34 UTC | SUPEE-9765 2017-01-21 22:18:17 UTC | SUPEE-8788
stackexchange-magento
{ "answer_score": 1, "question_score": 0, "tags": "magento 1.8, patches" }
Nginx + iptables redirect and block I'm confused by nginx and iptables, I'm not sure when I should redirect or block specific ports with nginx or iptables, e.g. I want to keep ports 443 and 8443 open for traffic and redirect all traffic form other ports to them, should I block the other ports with iptables or redirect with nginx?
You almost certainly don't want to redirect traffic from all other ports to 443/8433. If you have a web application running on those ports then just configure nginx to listen there and block everything else with iptables. If you have connection attempts to your server on other ports then it could be anything - misconfigured software from anywhere on the internet, or someone port scanning, just block it and your life will be simpler.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "nginx, iptables" }
SQL Azure database connection issue My problem is, I am getting below error when I try to connect the SQL Azure database by using SQL authentication from the Azure VM. The problem is interesting because I can connect same database from different Azure VM. SQL Server has a firewall and both VM IP addresses are whitelisted. I tried to make tcpping to SQL destination from both VM works fine. Unfortunately, I don't have access to grab the azure diagnostic log from the destination SQL Server. Does anyone have any clue what could be the problem? Error message: > Cannot open server "XXXXXX" requested by the login. The login failed.
Congratulations that you resolved the issue: "Yes, I was able to resolve the issue by moving VM to another vnet. It was using private IP even though it has public IP, I believe because of subnet service endpoint configuration" I help you post it as answer and this can be beneficial to other community members.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql server, azure" }
PostgreSQL ALTER VIEW AS I need to alter the view because of the table have been changed I left the code I used that doesn't work here ALTER VIEW view1 AS SELECT bolum.bolumid, bolum.bolumad, fakulte.ad, dersler.dersad, dersler.kontenjan FROM bolum JOIN fakulte ON bolum.bolumf = fakulte.id JOIN dersler ON bolum.bolumid=dersler.bolumid; Got an error:`Syntax error near 'AS'`
Try simply using `CREATE OR REPLACE VIEW...` CREATE OR REPLACE VIEW view_name AS SELECT a_column FROM a_table;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "postgresql, view, sql view, alter" }
In Python, how to slice a list to get the first element, and all elements except the last? Given: a = [1, 2, 3] b = [4,5] How to get: [1, 2] [4] In the above example, I know this works: a[:-1] b[:-1] However, when: c = [1] c[:-1] The result is an empty list.
You want the following code fragment: c[:1] + c[1:-1] For example: >>> c = [1] >>> c[:1] + c[1:-1] [1] With `c[:1]` you get a list consisting of the first element (if it exists, otherwise the empty list), and with `c[1:-1]` you get from the second until the end except the last. If there isn't a second element `c[1:-1]` will just return the empty list.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "python, python 3.x" }
React-Native Release APK Not Installed ![enter image description here]( My react native android app live in play store (v1.5). and I installed the app in my device and it is working fine, Now I created new release apk(v2.0) and try to install in my device, it is showing error message app not installed. The issue is that, the release apk not updating the previous version downloaded form play store. if you have any idea about this, please help me, Thanks
`release-apk` can not update a `app from play store`. if you need to install the `release-apk` you need to uninstall the `app from play store`. And upload the `release-apk` to play store then you can update the the previous version as normal.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, reactjs, react native" }
How to run custom appender in separate thread i just created my own appender as base of Logback document chapter 4 (see Writing your own Appender section). Whatever is being logged at `INFO` level in my application, My appender gets invoked and post that message as http message to the `servlet` running on other end. these kind of logic makes my application to slow down. because the appender runs on same thread which application is running. How do i make my appender to run in separate thread ?
Since Logback is based on Log4J, you should be able to used asynchronous logging option. See here This makes sure that your logging process runs in a separate thread.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, multithreading, logging, logback" }
How to determine $\sigma$-Algebra? Let $\Omega$=$\Bbb R$ and $\mathcal R$ = {$A \subseteq \Omega : A \cap \Bbb R_+ $is Borel-set and $A \cap \Bbb R_- \in${$\emptyset, \Bbb R_-$} } What is the $\sigma$-Algebra generated by $\mathcal R$? I have no idea how to find it. We always get those weird looking sets $\mathcal R$ and I don't know how to find their $\sigma$-Algebra's. Is there a method or formula of how to determine a $\sigma$-Algebra?
Hint: $\mathcal{R}\cup\left\\{ R\cup\left\\{ 0\right\\} \mid R\in\mathcal{R}\right\\} $ is a $\sigma$-algebra. (Check that and draw conclusions).
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "calculus, measure theory" }
How do I format an internal hard drive to exFAT in Windows 10? I have an internal hard drive that I use as storage where I dump the stuff I need backed up. I want to format it to exFAT instead of NTFS so that it doesn't have to deal with permissions. The problem is, it only appears to be available to format as NTFS. Is there a way to force it to be formatted as exFAT?
1. By Command prompt `Format D: /A:64K /FS:ExFAT` 64k is cluster size, D is target drive letter. 2. By Diskpart: list disk `select disk '#'` (where # is the number of the targer drive) If you want that for a partition: list part select part # (where # is the number of the partition) format fs=exfat -q If you want it for the whole drive just erase it all and make a single partition clean create partition primary _`active` (you many not need to make it active, so you can skip this)_ format fs=exfat -q Update: for Windows 10, use QUICK instead of -q
stackexchange-superuser
{ "answer_score": 17, "question_score": 11, "tags": "hard drive, windows 10, ntfs, windows 10 v1511, exfat" }
Can you provide a code example of a neural network and how it works on some sample inputs? Could you give a sample of NN ? I mean something like implemented ORC but easier. And could you explain how does it work with examples.
Check out this site: < It has an excellent explanation of Neural Networks in addition to a minesweeper program that is built using it. The original code is in C++, but there are links to ports of the code to VB.Net and Delphi. Also check out the main page < to find excellent articles on genetic algorithms and Self Organizing Maps - this one is found under the Neural Network button. Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "neural network, sample" }
Loading .txt file within JAR I've got a `db.properties.txt` file with my package `com.noteu` Within the same package as the file I'm trying to load it in the constructor of a properties object within a Database class like as follows : properties.load(Database.class.getResourceAsStream("db.properties.txt")); However I get a `java.lang.NullPointerException` as follows : Exception in thread "main" java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Unknown Source) at java.util.Properties.load0(Unknown Source) at java.util.Properties.load(Unknown Source) at com.noteu.Database.get(Database.java:24) at com.noteu.menus.Signin.checkSignedInStatus(Signin.java:52) at com.noteu.menus.Signin.<init>(Signin.java:253) at com.noteu.Main.main(Main.java:33)
Change type of file to `.properties`, `properties.load();` loads `properties` file not `txt` file as stream. public void load(InputStream inStream) throws IOException Reads a property list (key and element pairs) from the input byte stream. Modified code : properties.load(Database.class.getResourceAsStream("db.properties")); To load `.txt` file instead of properties file you have to create `FileInputStream` instance. FileInputStream fis new FileInputStream("myfile.txt"); props.load(fis) > If my solutions are not working please make sure that your path is correct.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, properties, fileinputstream" }
Build a string from 2 hashes I have 2 hashes like the following hash1: key value part0 company0 part1 company1 part2 company2 hash2: key value part0 2B part1 4B part2 6B What I would like is to build a string using the 2 hashes like this "part0 company0 2B, part1 company1 4B, part2 company2 6B" (without quotes) How can I achieve this ?
Well, assuming that you're guaranteed that both hashes have the same keys, you can do something like this: foreach my $key (sort keys %hash1) { print "$key $hash1{$key} $hash2{$key}\n"; } If they might have different keys you will need to find a way to get either a list union or intersection, which there's probably a function for in List::Compare.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "perl" }
Something like pwgen-win for linux? Ok, is there some kind of pwd generator for linux like this one for Windows that has a nice GUI and options like this win-version has? I know that there is pwgen but as far as I know it does not support mouse/keyboard entropy and it does not have any kind of front end GUI-s.. or does it? < thank you
You may have some luck with pwxgen on Linux.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "linux, security, passwords" }
Diff between a pipe and a filter? I'm new to shell scripting and I want to know what the difference is between pipe and filter. They both seem to do the same things. Even the format is the same. ls -l | grep user |cat >user A pipe or a filter?
In your example, the whole command is a pipeline: ls -l | grep user | cat > user `ls` is acting as the source of data. `grep` is then acting as a filter - a filter performs some kind of transformation on the data. The pipe (`|`) passes the data from `ls` to `grep`, performing buffering etc. Finally `cat` (which is extraneous in your example) outputs the filtered data to something (terminal, file, variable).
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "bash, shell" }
Can armature/bones be edited without edit mode? I was looking after some information about armature and bones, so I can continue my importer script. I found some nice info here; no BMesh, and simple enough for my needs as beginner, so just perfect. But while looking at the code I saw that it uses "edit mode" (line 120), what I wanted to avoid. So my question is: can I programmatically add/manipulate bones, without edit mode? Is there any better way then in this code? I also tried to use the "bones" collection, but I could not append/new/add items into them.
**No** , The armature must be in Edit mode for us to be allowed to add or remove bones. We can switch into and out of it, using `bpy.ops.object.mode_set`. An idiom I use a couple of times in my addon, is to store initial mode in a variable (`prev_mode`), then restore it when I'm finished: prev_mode = armature.mode # save bpy.ops.object.mode_set(mode='EDIT') for bone in context.selected_bones: # do anything in edit mode hook_name = PRF_HOOK + bone.name hook = armature.data.edit_bones.new(hook_name) bpy.ops.object.mode_set(mode='POSE') for bone in context.selected_pose_bones: # do anything in pose mode hook = armature.pose.bones[PRF_HOOK + bone_name] ct_constraint = hook.constraints.new('COPY_TRANSFORMS') bpy.ops.object.mode_set(mode=prev_mode) # restore This way, we can access any editing mode, any number of times, without the user even notice when the script is finished.
stackexchange-blender
{ "answer_score": 10, "question_score": 10, "tags": "scripting, bones" }
Отправка письма со статусом Как отправить письмо со статусом ?? Например важно или срочно??
Можно добавить в хеадер письма: Importance: high X-Priority: 1
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php" }
'tuple' object has no attribute 'sort.......Sort function not working in jupyter notebook? new_list=("a","g","x","e","s","s") #created a list a=new_list.sort() #try to sort it and error is: AttributeError Traceback (most recent call last) <ipython-input-3-6eb33c65fab6> in <module>() ----> 1 a=new_list.sort() AttributeError: 'tuple' object has no attribute 'sort' I get this Attribute error. I've restarted my kernel and also tried it on sublime-text-CMD. I still get the same error
If you see here "Tuples and Sequences" you can see that your data structure is a tuple. You can see here "More on Lists" that `sort()` is a function only for arrays. You can use sorted() to sort arrays or tuples new_list=("a","g","x","e","s","s") a=sorted(new_list) # ['a', 'e', 'g', 's', 's', 'x']
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, python 3.x, sorting, jupyter notebook, attr" }
change default python version with virtualenvwrapper (& virtualenv) I've recently changed my python setup so that's it's now installed with brew. Previously when using virtualenv and virtualenvwrapper it would default to setting up a new virtualenv using python3 (used for most of my projects). Now unfortunately the default is python2. I can install python3 using: mkproject -p python3 projectname however how can i make python3 the default?
> To automatically use a custom Python binary instead of the one virtualenv is run with you can also set an environment variable: > > > $ export VIRTUALENV_PYTHON=/opt/python-3.3/bin/python > $ virtualenv ENV > > > It’s the same as passing the option to virtualenv directly: > > > $ virtualenv --python=/opt/python-3.3/bin/python ENV > Source: <
stackexchange-stackoverflow
{ "answer_score": 31, "question_score": 20, "tags": "python, virtualenv, virtualenvwrapper" }
Rails Datagrid - NoMethodError when trying to create datagrid form Getting a NoMethodError when trying to do the following in your view with datagrid- <%= datagrid_form_for @foods_grid %> Which is strange because the datagrid itself is tested and working fine- <%= datagrid_table @foods_grid %> The error details will say something like... undefined method `foods_grids_path' for ... And reference the _form partial.
Solution: You need to manually pass in the path that you're using to display the datagrid, like so - <%= datagrid_form_for @foods_grid, :method => :get, :url => foods_path %> They don't mention these parameters in the tutorial!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails, ruby, datagrid, rubygems" }
Inaccurate tint of RatingBar using progressTint I figured that with `android:progressTint="@color/ratingColor"` on `AppCompatRatingBar`, I can change the color of filled stars. But then I noticed green color towards left edge of the filled star. I tried with other tints but can not get rid of that. This is screen shot of AS Preview but issue remains the same when I run on the device. Anyone faced this issue? How did you remove that unwanted green color of the edge? ![preview of review]( Zoomed in: ![enter image description here](
Well. I guess I did not try all the tints when I posted the question. I solved this with `android:secondaryProgressTint="@color/transparent"`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, android layout, androidx, ratingbar" }
Is ASP.Net hard to learn or working on for a person who knows PHP since 6 years? If I have 6 years php working experience and 2 years c# .net experience. Will it be hard for me to learn and working on ASP .net or VB .net? What steps would you recommend me to learn that?
well not it is surely not that hard because of 1. You are much familiar with web-technologies and how the response and request works. 2. your score on SO shows that you re enthusiastic to learn and help and get help. 3. You already worked with C# so you just need to put Asp.Net fundamentals in action with your web knowledge already exists. In asp.net there are two main category 1) Asp.net web forms and 2) asp.net MVC; you can pick any but MVC will be easy for you because it is somewhat similar what yo do in PHP while Web-Forms are easy to work on and likewise. Best of luck,
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "php, asp.net, asp.net mvc 3" }
Which function to hash 128 bit API key with? I'm generating 128 bit API keys. AFAIK 128 is totally secure for generated key. In the DB I want to store hashes, not the plain text (to be protected against DB leak), but what hashing algorithm should I use? MD5 and SHA-1 are not considered secure. SHA-256 produces bigger output than the key itself so it seems like it doesn't make sense to use a 128 bit key with SHA-256.
In theory, it should be safe to use MD5 here since it is only vulnerable to collision attacks, not the much more dangerous preimage attacks which would be required to forge an API key. However, it's certainly not a _bad_ thing to avoid MD5 on principle, since it looks bad for auditors. Assuming the value you are hashing is randomly generated and is not a human-provided and potentially weak _password_ , then you can use SHA-512 and truncate the output. If you want to use a standard, then there is a SHA-512/t hash defined in FIPS 180-4 in section 5.3.6 which outputs a digest of _t ≤ 512_ bits. If a standard is not important to you, then it's fine to just truncate the output of the hash to 128 bits. I specify SHA-512 rather than SHA-256 because, paradoxically, it's actually _faster_ on 64-bit systems. If your system is not 64-bit, then you will probably have better performance with SHA-256.
stackexchange-security
{ "answer_score": 4, "question_score": 1, "tags": "hash, databases, sha, sha256, key" }
Byte Order Mask: confusing the UTF encoding The Byte Order Mask (BOM) uses the Unicode character U+FEFF to determine the encoding of a text file according to the following rule: +-------------+-----------------------+ | Bytes | Encoding Form | +-------------+-----------------------+ | 00 00 FE FF | UTF-32, big-endian | | FF FE 00 00 | UTF-32, little-endian | | FE FF | UTF-16, big-endian | | FF FE | UTF-16, little-endian | | EF BB BF | UTF-8 | +-------------+-----------------------+ My question is: is there any combination of bytes that can make one UTF encoding to be confused with another UTF encoding? For example, if I have a UTF-16 big-endian encoded file without BOM and with the characters U+EFBB and U+BF40 (EF BB BF 40) can it be confused with an UTF-8 encoded file with BOM and the ASCII character `@`?
Sure, without knowing the encoding, a sequence of U+0000 characters has an unknown length. 00 00 00 00 UTF-8 U+0000 U+0000 U+0000 U+0000 00 00 00 00 UTF-16 U+0000 U+0000 00 00 00 00 UTF-32 U+0000 BTW—Bytes that look like a byte order mark cannot be used to determine the encoding of a text file. In general, it's an unsolvable problem—data loss.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "unicode, utf 8, utf 16, byte order mark" }
Not able to use the win32gui module from pywin32 in Pycharm I'm using Python 3.7 with Pycharm. I've installed the `pywin32` package for this project because `win32api` isn't compatible with Python 3.7+. import win32con import win32gui I'm trying to import these modules with `pywin32` installed but this doesn't work. The problem only started happening after I uninstalled and reinstalled Pycharm and had to reinstall all my packages for this project. I'm using the exact same interpreter as I was before. Why would this be happening?
There is a post installation step to follow: > To install pywin32 system files, run `python.exe Scripts/pywin32_postinstall.py -install` from an elevated command prompt. Did you run this command? See also
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, pycharm, pywin32, win32gui" }
Error when splicing a vector C++ I'm trying to splice a vector in C++ using the following code: `sequence(sequence.begin() + i, sequence.end());` where `sequence` is a vector containing integers and `i` is an integer, but when I run my code it gives the following error: `error: no match for call to ‘(std::vector<int>) (__gnu_cxx::__normal_iterator<int*, std::vector<int> >, std::vector<int>::iterator)’ sequence(sequence.begin() + i, sequence.end()); ^` I don't understand what is wrong with my code. I used the following stack overflow questions to help write this code: Creating a new C++ subvector? Slicing a vector
You can't do that, because `sequence` doesn't have an overloaded call operator. You can only use that syntax when initializing objects when you are defining them: int i(1); // ok i(2); // nope! You are trying to do the second line above, which fails because it's not a valid form of initialization in this context. If you want to splice a vector, you can use `std::vector::erase`; sequence.erase(sequence.begin() + i, sequence.end()); // erases [start, end)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "c++, vector, c++14, splice" }
ECMAScript 6 loop 'for-of' in Microsoft Edge It looks like a problem with ECMAScript 6 loop 'for-of' in Microsoft Edge. In fact, when i loop with a [key, value] pair, Edge return this error : SCRIPT1010: Expected identifier For example with the code below : var myMap = new Map(); myMap.set(0, 'zero'); myMap.set(1, 'one'); for (var [key, value] of myMap.entries()) { console.log(key + ' = ' + value); } The part of code is from < And i use Edge 25.10586.0.0 to test it. Any idea?
I found that [key, value] pair in the loop return an error in old version of Microsoft Edge (<= 25.10586). It needs to use an array instead like this : var myMap = new Map(); myMap.set(0, 'zero'); myMap.set(1, 'one'); for(var pair of myMap.entries()) { console.log(pair[0]+ ', '+ pair[1]); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, ecmascript 6, microsoft edge" }