INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Formatting the date in weekday, day month, year format in PHP? How do I format a date in the format such as weekday, day month, year for example Friday, 18th October 2013? I have tried using strotime() and the echoing using date() function but can't achieve this format because weekday is not being returned properly.
This works correctly: // Use string to time to get the date as a unix timestamp $myTime = strtotime("Friday, 18th October 2013"); // Use that timestamp to reform it into a date, in which ever format you want orrding to the date() documentation. $newTime = date('l, jS F Y', $myTime); // Show the date in the format echo $newTime; See it working here: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "php, date" }
How to remove remote origin from Mercurial repository? Similar to this question I'm trying to disconnect my hg repository from a dead remote location, while keeping the local version control. What is the hg equivalent of `git remote remove origin`?
Handwork: remove obsoleted line from the `[path]` section of the repository configuration file, `.hg/hgrc` (and maybe related credentials from `[auth]`, either in `.hg/hgrc` or `~/.hgrc`).
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "version control, mercurial" }
Attached DependencyProperty Accessors - Why? The MSDN documentation says that you must define accessors for your custom attached DependencyProperties: < (the "The Get Accessor" and "The Set Accessor"). Why are the accessors necessary? When you have an instance (non attached) DependencyProperty, the WPF runtime justs calls SetValue and GetValue. Why doesn't it just do the same thing for attached DependencyProperties?
those calls can be easily emitted using actual DPs declaration - after all you ever expect in there is a single line in both get & set calls. I think it's a got to do with XAML consumers/Intellisense. Neither regular DPs nor attached ones can be consumed from XAML without _wrapping_ , for which we use CLR properties with regular DPs and accessors with attached DPs. Sounds like a design flow, specially considering the fact those wrappers get bypassed by XAML loader. But the whole thing works, which is the most important thing:)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wpf, xaml, dependency properties" }
Difference between ('#ID') and $('#ID') selectors in jquery What is the difference between these two selectors: `('#ID')` and `$('#ID')` in jQuery? When I am calling my function `checkSpecialChars('#txtCreateSet')`, it does not work and shows the following error message: error Object doesn't support this property However, when I call my function like the following: `checkSpecialChars($('#txtCreateSet'))`, it works. Why is this the case?
`$` in jquery is a `function` that initiates an object, that object has access to all of jquery's functionality. Without declaring the `$` you are just defining a `string`.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "jquery" }
What is this kind of graph called? (2D grid with a color-coded scale for a 3rd variable) I keep running into these nice pictures: !enter image description here But I have no idea what they are called!
Assuming `C` and `gamma` are distinct from the third variable that is color-coded according to its (probably binned) value for each combination of `C` and `gamma`, this is a heat map. Compare to this: ![]( (source: wikimedia.org) Author: George Halt
stackexchange-stats
{ "answer_score": 5, "question_score": 2, "tags": "data visualization" }
sp_change_users_login 'auto-fix', '<local_account>' How can I execute the sp_change_users_login so that it will auto-fix all local sql accounts? in other words I can run the command to view all local accounts: select * from sys.database_principals where type = 's'; I now want those list of users to be used in the sp_change_users_login procedure.
You could use a cursor to get the list of names, and then loop through the cursor results. Within the loop you would do something like: exec sp_change_users_login 'auto-fix', @nameVariable You'd loop while @@FETCH_STATUS = 0. It returns non-zero when you have FETCHed all the rows from the cursor. Here's more detail: declare @userVar varchar(30) declare users cursor for select name from sys.database_principals where type = 's'; open users fetch next from users into @userVar while @@FETCH_STATUS = 0 begin exec sp_change_users_login 'auto_fix', @userVar fetch next from users into @userVar end close users deallocate users
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, sql server, sql server 2008" }
How can I parse the script code? How do I parse the script tag or script URL I specified? As a result of the parse operation, I will be able to obtain the script global variables and functions within the object. it should be able to show the default values of the variables. ### Example // Input var a = 5; function b(){} var c = function(){ var d=1; }; ### Result // Output { "a":{ "type":"variable", "value":5 }, "b":{ "type":"function", "type":"void" }, "c":{ "type":"function", "type":"void", "scope":{ "d":{ "type":"variable", "value":1 } } } } **Is there a library that will work like the example above?**
ITNOA as you can see in JavaScript parser in JavaScript many library have this, for example * UglifyJS * Esprima * acorn * <
stackexchange-softwarerecs
{ "answer_score": 2, "question_score": 1, "tags": "javascript, node.js, parser" }
Calculate grand total when table is filtered I have a Web Intelligence cross tab report where I show time as columns, customer names as the rows and volume as the measure. I have applied a ranking to show only the top X along with a (sub-)total, however I want to add a row at the bottom to show the total for all customers for that month. I had expected to achieve this by using `[Volume] ForAll ([Customer Name])` but that repeats the sub-total, as did `[Volume] ForAll ([Customer Name]))` (in case it was me getting the parentheses wrong). Am clearly missing something fundamental here which is probably obvious once learned.
Essentially your ranking is a filter although it doesn't show up that way. If you create a variable with the **NoFilter()** function you should have what you seek. [MonthTotal]=NoFilter([Volume]) This is how it looks for me using the eFashion universe... ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "business objects, webi" }
Sending response code to browser in PHP I have follow PHP Code <?php header("HTTP/1.0 200 OK"); if(headers_sent()){ echo "Header Sent"; } else{ echo "Header Not Sent"; } ?> Still I am getting the message "Header Not Sent". means response code is not sent. How to solve it?
Before header use `ob_start();` and after `ob_end_flush();` ob_start(); header("HTTP/1.0 200 OK"); ob_end_flush(); if(headers_sent()){ echo "Header Sent"; } else{ echo "Header Not Sent"; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, header, response" }
QTextEdit with different text colors (Qt / C++) I have a `QTextEdit` box that displays text, and I'd like to be able to set the text color for different lines of text in the same `QTextEdit` box. (i.e. line 1 might be red, line 2 might be black, etc.) Is this possible in a `QTextEdit` box? If not, what's the easiest way to get this behavior? Thanks.
Use text formated as HTML, for example: textEdit->setHtml(text); where **text** , is a HTML formated text, contains with colored lines and etc.
stackexchange-stackoverflow
{ "answer_score": 25, "question_score": 30, "tags": "c++, qt, colors, qtextedit" }
Hazelcast distributed queue In Hazelcast documentation, it's said that: > Hazelcast distributed queue performs no batching while iterating over the queue. All items will be copied locally and iteration will occur locally. < can some one explain what does it mean?
It means that each item is retrieved separately and therefor there is quite a performance hit. A faster approach is to retrieve e.g. 10 items in 1 go to reduce the number of remote calls. Unfortunately this isn't implemented.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "queue, distributed, hazelcast" }
Is there a more efficient to perform this matrix operation in Matlab I want to make the following thing in Matlab: given a matrix H, I want to build a matrix H* of same size such that H*(:,i) is the sum of the next columns (i.e. i+1 -> n) of H. So for example, if H is H = 2 4 7 14 3 5 11 -3 I am expecting H* to be 25 21 14 0 13 8 -3 0 So far, I have done the following piece of code but it involves a `for` loop, so I am not expecting it to be very efficient (especially, my matrix will have a big number of columns in the practical application I will use). H_tilde=zeros(size(H)); for i=1:size(H,2) H_tilde(:,i)=sum(H(:,i+1:size(H,2)),2); end Is there a way to make it better?
Use `cumsum` along the 2nd dimension with the `'reverse'` option, as follows: H_tilde = [cumsum(H(:, 2:end), 2, 'reverse') zeros(size(H,1), 1)];
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "matlab, matrix, linear algebra" }
how to create a xmllist variable in flex? I am trying to create a xmllist variable in action script like this: var _menuData:XMLList; <menuitem label="File"> <menuitem label="Backup Schedule"/> <menuitem label="Restore Schedule"/> </menuitem> <menuitem label="Edit"> <menuitem label="Cut"/> <menuitem label="Copy"/> </menuitem> How do I assign this xml to _menuDAta in actionScript? I dont want to create a string first and then do it all by fixing line break errors. Thanks.
I can't see your code here but here is a sample code for creating an XMLList: var xml:XML = <items><item>1</item><item>2</item><item>3</item></items>; var xmlList:XMLList = xml.item; trace(xmlList); Hope it helps, Rob
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "xml, apache flex, actionscript 3, action" }
Find the area of a parallelogram with the following. We are given the vectors AB=m+2n, AD=m-3n. Where |m|=2, |n|=3 and $\angle(m,n)=\dfrac{\pi}{6}$. Find the area of the Parallelogram.
Hints: * The area of Parallelogram is the cross-product of their vectors. Thus, $AB\times AD$ * Distributive over the addition: $A\times (B+C)=(A\times B)+(A\times C)$ * Cross products of a vector with itself is $0$. Therefore, $m\times m$ and $n\times n$ is equal to $0$ * And the last one $A\times B=|A||B|sin\theta$ (where $\theta$ is the angle between $A$ and $B$) These hints are enough to solve this problem.
stackexchange-math
{ "answer_score": 0, "question_score": 2, "tags": "vectors, analytic geometry" }
Subclassing Control In WINAPI, which is correct/necessary? SetWindowLongPtr(HelpBox, GWLP_USERDATA, static_cast<LONG_PTR>(SetWindowLongPtr(HelpBox, GWLP_WNDPROC, (LONG_PTR)(Subclass)))); OR SetWindowLongPtr(HelpBox, GWLP_WNDPROC, (LONG_PTR)(Subclass)); Then in WM_DESTROY I do both like: SetWindowLong(HelpBox, GWLP_WNDPROC, (LONG) Original); Why should I use the first one over the second? I noticed it had the GWLP_USERDATA and setwindowlongptr twice.. Why? I saw both examples on MSDN and I don't know when to use the first over the second. Any ideas?
use **`SetWindowSubclass`** instead; it handles the burden of associating data with the window. anyway. the first one stores the old window proc address in user data storage associated with the window, and you can't do that unless the window class is one you've defined yourself. i.e. ~~where such storage does exist for the window~~ where you are guaranteed that that storage isn't used for anything else.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c++, winapi, subclassing" }
Merge multiple tsv/csv files or their contents in their respective columns separated by names and names order I have files high-apple.tsv, low-apple.tsv, high-banana.tsv, low-banana.tsv, high-cherry.tsv, low-cherry.tsv. They all have columns green, blue, red and yellow. I want to parse the contents of each file partially matching the file names. For example, I want to aggregate the file contents of high-apple followed by low-apple and so forth. I also want the file that are merged separated (or tagged) by their names so that I could know the part where it has come from. order to aggregate: high-apple.tsv low-apple.tsv high-banana.tsv low-banana.tsv high-cherry.tsv low-cherry.tsv
Assuming by aggregate you mean concatenate unchanged contents, something like this may work... $ for f in apples bananas; do echo "contents of $f" >> fruits; cat $f >> fruits; done the script concatenates the file contents with a header of "contents of {filename}". If all your files are in the same format you don't need any other complexity. You can list the files as "apples bananas ..." in the right order.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "bash, csv, unix, awk" }
Configuring iptables rule I have private cloud with eucalyptus and xen. Generally while creating an instance, eucalyptus tries to contact meta data service at 169.254.169.254. But here in my setup, the service is running at 192.168.1.10. Now I want to forward all request to this ip. I want to create pre routing rule to forward all packets from 169.254.169.254/32 (port 80) to 192.168.1.10:8773.
iptables -t nat -A PREROUTING -p tcp -d 169.254.169.254/32 --dport 80 -j DNAT --to-destination 192.168.1.10:8773 This is the rule you have to place in Iptables. hope that helps.
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 2, "tags": "iptables" }
How to prove the quadrilateral formed by bisectors of a parallelogram is not always square? Given a generic parallelogram $ABCD$ as in the figure, we can extend the angle bisectors to get a central quadrilateral $EFGH$. Now it is easy to show that $EFGH$ is a rectangle using $\alpha + \beta = 90^\circ$. My question is, how do we show it is not always a square and precisely when is it a square? !Diagram of parallelogram I tried showing that $EG$ is parallel to $AD$, but could not figure any way to prove that. Directly showing $EF \neq FG$ if $AB \neq BC$ did not work either. Any hints (without using trigonometry, coordinate geometry, vectors etc. but only geometry)?
!enter image description here Angles in gray triangles are $\alpha, \beta$ and $90^\circ$. Catheti (green and red) are equal, when $\alpha=\beta$. So, central rectangle can be square when $\alpha=\beta ~~$ too.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "geometry" }
linking to comment error There are Posts, Comments and Reports. Report belongs to a Comment(which belongs to a Post). I want to create a link to a comment(together to a post it belongs to) on Report's show page. It should look something like this > .../posts/2/comments/4 I have this on report's show page, which gives me ID for a comment. <%= @report.comment.id %> How do I link to a Comment's show page on Report's show page?
Assuming that you have nested routes as `comments` within `posts`, for e.g.: resources :posts do resources :comments end Then you would have path as `post_comment_path` routing to `/posts/:post_id/comments/:id`. In that case, you can have a link to a Comment's show page on Report's show page as below: <%= link_to "Comment's Show Page" , post_comment_path(post_id: @report.comment.post.id, id: @report.comment.id) %>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails, ruby on rails 4" }
How to find a sequence by its limit? Is there any way to construct non-trivial sequence by its limit? Something like $\begin{cases} a_1=2 & \\\ a_{n+1}=\dfrac1{2}\left(a_n+\dfrac2{a_n}\right) \end{cases}$ for $\sqrt2$. I'm especially interested in square roots, trigonometric functions and alike. By non-trivial i mean that the sequence definition mustn't contain the limit itself - let's say i want to approximate it.
For $\sqrt{x}$, you have already almost it: $$\begin{cases} a_1=2 & \\\ a_{n+1}=\dfrac1{2}\left(a_n+\dfrac{x}{a_n}\right) \end{cases}$$ Generally speaking, given a number $x$, you can easily construct a sequence that converges to it: simply try $u_n=x+\frac1{n}$. But if you want something non trivial like this, it's absolutely not immediate in general. And usually, the way your number is defined is already a sequence or something amenable to a sequence. For example, $\sin x$ and $\cos x$ are often defined as $$\sin x=\sum_{n=0}^\infty (-1)^n \frac{x^{2n+1}}{(2n+1)!}$$ $$\cos x=\sum_{n=0}^\infty (-1)^n \frac{x^{2n}}{(2n)!}$$ These infinite series can be seen as sequences of partial series (you sum up to $m$, and you take growing and growing $m$).
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "calculus, sequences and series, approximation" }
Remove empty fields in an array after foreach in PHP I am new to PHP. This is my code from our mailing.php. When a user submits a request, there are 5-7 select-able fields and 20-25 fields that end up not being selected. The output lists all fields and values regardless of whether they are empty or have been selected. I understand I need to use either `unset` or `array_filter`, but cannot figure out how and where I need to insert into code. if($_POST && count($_POST)) { $body = ''; foreach($_POST as $key=>$value) $body .= $key . ": " . $value . "\r\n"; mail("[email protected]", "Email Received at [email protected]", $body);
You can try this if($_POST && count($_POST)) { $_POST = array_filter($_POST); $body = ''; foreach($_POST as $key=>$value) $body .= $key . ": " . $value . "\r\n"; mail("[email protected]", "Email Received at [email protected]", $body); OR if($_POST && count($_POST)) { $body = ''; foreach($_POST as $key=>$value){ $trim_value = trim($value); if (!empty($trim_value)){ $body .= $key . ": " . $value . "\r\n"; } } mail("[email protected]", "Email Received at [email protected]", $body);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, foreach, array filter" }
MSBuild- How to access a target's Property from a PropertyGroup I am trying to access the Foo Target's "VersionString" property from a PropertyGroup. Is there a way to do this? <Target Name="Foo"> <ItemGroup> <Assembly Include="Foo.exe" /> </ItemGroup> <MSBuild.ExtensionPack.Framework.Assembly TaskAction="GetInfo" NetAssembly="@(Assembly)"> <Output TaskParameter="OutputItems" ItemName="Info"/> </MSBuild.ExtensionPack.Framework.Assembly> <MSBuild.ExtensionPack.Framework.TextString TaskAction="Substring" OldString="%(Info.AssemblyVersion)" StartIndex="0" Count="5"> <Output PropertyName="VersionString" TaskParameter="NewString"/> </MSBuild.ExtensionPack.Framework.TextString> </Target> <PropertyGroup> <FooVersion> $(VersionString) </FooVersion> </PropertyGroup>
The property will only be avilable after the target and the specific task have run. This means that you can only access it in property groups inside targets that run after the task creating the property was run. Your sample tries to access it from a static property group, which is evaluated before any targets are run, therefore the property is not set yet.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "msbuild" }
When to use F#'s typedefof<'T> vs. typeof<'T>? Can someone clarify when to use typedefof<'T> vs. typeof<'T>? Both `typedefof<System.String>` and `typeof<System.String>` return the same `Type` instance. However, they return different instances and different information for `System.Collections.Generic.List<_>`. Can I think of `typedefof` as a new and improved `typeof`? Should I just switch to always using `typedefof`? Or is it more subtle than that?
This ought to illustrate the difference. When you use `typeof`, the compiler infers type arguments and constructs a concrete type. In this case, the inferred type argument is `System.Object`: let t1 = typeof<System.Collections.Generic.List<_>> let t2 = typedefof<System.Collections.Generic.List<_>> printfn "t1 is %s" t1.FullName printfn "t2 is %s" t2.FullName Output: t1 is System.Collections.Generic.List`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] t2 is System.Collections.Generic.List`1 Because `typeof` can only return a constructed type, `typedefof` is necessary if you need a type object representing a generic type definition.
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 22, "tags": "f#" }
Primes of the form 1..1 For $n \ge 1$ an integer, let's denote $u_n = \sum_{k = 0}^{n-1} 10^k$ That is $u_1 = 1$, $u_2 = 11$, $u_3 = 111$, $u_4 = 1111$, ... My question is the following : **Which of them are prime numbers ?** What I know so far : * If $u_n$ is prime, then $n$ is prime (meaning there's an obvious factorization when $n$ is not prime). * When $p$ is prime, $u_p$ can either be prime (2, 19 and 23 being the only examples I found so far) or not prime (all primes up to 67 with the exception of 2, 19 and 23). But I haven't been able to see any pattern. Any thought is welcome. Maybe a sub-question would be to know whether there's a finite or infinite number of such primes. Thanks for your help.
OEIS has a list of the number of 1's where these are prime. It only has eight of them, the next is 317. So you could have looked for a while.
stackexchange-math
{ "answer_score": 11, "question_score": 12, "tags": "number theory, elementary number theory, prime numbers" }
I insist! or Please, go ahead! How do you say when you’re holding the door for someone for example and you’re trying to say the equivalent of “I insist!” when they hesitate to go ahead? Can you just say “S’il vous plait!”?
Informally, you can simply say: > Allez-y > > Vas-y (if you are on a "tu" basis with this person) More politely: > Je vous en prie / je t'en prie More formal, if the person wants you to go first and you want to insist: > Je n'en ferai rien (Note: I have some doubts about using _s'il vous plait_ in such a situation. I come from a region (Belgium) where we use it a lot more than in standard French, and yet I would personally find it a bit awkward in that particular situation. Some may disagree.)
stackexchange-french
{ "answer_score": 3, "question_score": 3, "tags": "expressions, politesse" }
read xml data over tcp i'm developing an application that is listening to tcp to get some xml data coming from other devices. i'm use sniffing c# code, and i can sniff all the packets. my problem is that in every packet i can find a Piece of the data in every packet. like this: 1 packet from ip41 data:< 2 packet from ip41 data:?xml versi 3 packet from ip41 data:on="1.0" 1 packet from ip35 data:< ?xml 4 packet from ip41 data:encoding="UTF-8 the real data looks like this: <?xml version="1.0" encoding="UTF-8"?><alarm><datetime>2010-07-18T11:14:22Z</datetime><textch><textchid>020</textchid></textch><rule>DIR-020</rule><text>020-DIR-Intersection3_Magles_TCS6</text></alarm> i want to be able to get the data in a string like the real data, not in pieces. is there is a method or a library in .net that can do that?
i did it by monitoring one port by thread..and Assembly them by sequence number. thanks for all your help
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, network programming, tcpclient, tcplistener" }
Autodestroy on change Rails For example class User < ActiveRecord::Base has_one :avatar, :dependent => :destroy end class Avatar < ActiveRecord::Base belongs_to :user end What if I have a User with an Avatar and then do something like old_avatar = user.avatar new_avatar = Avatar.new user.avatar = new_avatar user.save old_avatar.destroy So I don't want do the last command manually (destroy). Is there any options for has_many to autodestroy old object? Or many it's better use something else instead of avatar= method? Thank you.
Why not update old avatar instead of creating new one like: avatar = Avatar.find_or_initialize_by_user_id(:user_id => user.id) avatar.attributes = new_attributes avatar.save Also, you might create `after_save` callback inside `Avatar` model if you like.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails 3, activerecord" }
Bugzilla web API for adding a version to a product I want my build server to create a version in our Bugzilla tracker every time a release build is made. Is this possible? So far, I've found the following APIs that come close, but don't provide this functionality: Bugzilla::WebServer::Product \- Allows updating of a couple fields from the product, but not the versions. Bugzilla REST API \- Only provides methods dealing with bugs, nothing with the product.
I think you will have to create your own API. I'd create a simple Perl CGI that uses the Version package. <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "api, continuous integration, bugzilla" }
PHP get variable from url modified with htaccess I have this url: example.com/en/hk/myAccount?Ref=CC0000008 And my .htaccess looks like this: Options +SymLinksIfOwnerMatch RewriteEngine On # Turn on the rewriting engine RewriteRule ^(chin|en)/(hk|kw)/myAccount/?$ user_account.php?lang=$1&loc=$2& [NC,L] #SHOW USER ACCOUNT So I want to get now the variable `ref` passed on the url but when I `print_r` the variabel `$_GET` I only get the variables in the `.htaccess` file. What should I do?
You need to add `QSA` flag Options +SymLinksIfOwnerMatch RewriteEngine On RewriteRule ^(chin|en)/(hk|kw)/myAccount/?$ user_account.php?lang=$1&loc=$2 [QSA,NC,L] Output: Array ( [lang] => en [loc] => hk [Ref] => CC0000008 ) The flag `QSA` means that if there's a query string passed with the original URL, appended it. The flag `L` means if the rule matches, don't process any more rules below this one. The flag `NC` means case-insensitive, that is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI. Apache RewriteRule Flags
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "php, .htaccess, mod rewrite" }
Is it practical to store a gasoline powered scooter in an apartment? From my experience with gasoline powered tools they are quite "dirty" - fuel and oil spill rather frequently and also there's a rather annoying smell of gasoline around. I'd expect the same from a gasoline powered scooter. How realistic is it to own a scooter without having a garage and store the scooter in an apartment?
I guess this is hearsay, but I have a couple of friends who store a scooter and a 125 learner motorbike in their apartments, and they don't leak any oil or petrol - they are quite new though, so what I would advise is to have a good look at the scooter to see how old it is - if the engine is old it may have worn seals etc which may leak. In any case, get yourself a wooden board with a sheet or cloth overlay to park it on, that way you also avoid getting the floor dirty from the tires etc.
stackexchange-mechanics
{ "answer_score": 4, "question_score": 2, "tags": "scooter" }
How good is underscore.js at providing truly random numbers? I need truly random integer numbers in node.js. I was wondering if anyone had experience with how good or bad underscore.js is for providing "randomness" (e.g. with the _.random(min, max) function) ? Reference: < Thanks
> I need truly random integer No pseudo-random number generator will be able to provide you a truly random number. For that, you need something in nature. Check out < They use atmospheric noise to get random numbers as random as you can get.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 3, "tags": "javascript, node.js, underscore.js" }
Pubnub javascript video chat camera and mic mute mechanism? I have used PubNub video chat javascript api and it is doing well.Now I want to manage resources as follows: 1. I want to turn off & on camera during chat. 2. I want to turn off & on mic during chat. And in WebRTC at following **url** we can see how they are making camera and mic mute. For it I could find only one method in webrtc-v2.js that is : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Stop Camera/Mic // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- function stopcamera() { if (!mystream) return; for (let track of mystream.getTracks()) track.stop(); } and If I use it **how can I precisely get track for mic And camera.** And after that **how can initiate them again**.
# Video Camera and Mic mute mechanism? The SDK does not start Pause/Resume on streams. You need to re-connect with a new session. Additionally the SDK does not have a mute method. You can mute the local stream feed by setting the output render volume to 0. let vid; session.connected(function(session){ vid = session.video; // Mute Audio vid.volume = 0.0; // Unmute Audio vid.volume = 1.0; }); The SDK does not provide other methods for mute/unmute.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, pubnub" }
ndk-build ignoring source with errors I'm new to c/c++ and NDK but i can't seem to find what i would have thought to be a well known question/answer. Does the following error on running `ndk-build` mean that the following set of files haven't been compiled: Android NDK: WARNING: Unsupported source file extensions in /cygdrive/d/opt/workspace/ProjectName/jni/Android.mk for module ModuleName Android NDK: CRC32.c, MD5.c, File2.c, File3.c Or, is that a list of files which have successfully compiled? EDIT:: I can confirm after trial and error that those files /are/ being ignored. The delimiter you need to use in the Android.mk file is a single space " " character, not comma space characters ", ".
You should format Android.mk files to compile like below: LOCAL_SRC_FILES+= CRC32.c MD5.c LOCAL_SRC_FILES+= ForkProcess.cpp That is, `LOCAL_SRC_FILES` can be formatted like this for a single list of files to compile: LOCAL_SRC_FILES:= CRC32.c MD5.c Or, if you wish to seperate the list of compiled files (Perhaps there is a logical non modular structure in the source files), as above you can use `+=`. Errors in this variable declaration can give the error in the question.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "android ndk, compiler warnings" }
Where are the Opens stored for Mobile Push messages in Salesforce Marketing Cloud? Hi fellow SFMC developers, I am trying to build a journey that sends two push messages: first one to the entire audience and a Push notification reminder to those recipients who have not opened the first push message. As I understand, the Engagement split activity is not useful in this case, so I need to find a way to access the openers of the Push messages to make this happen using a Decision split activity. Could anyone please tell me how can I access the Opens for Mobile Push? Is there a data view or a data extension or something similar?
There's no data view to query directly, but you can set up an Automation to run the Push Message Detail Report that places a file on the FTP that you can then import to a data extension to use as the basis for decision splits. There's also the MobilePush Detail Data Extract that you can ask Support to provision that extracts much the same data as you see in the report. You will need to add the data extension holding the detail report records to your Contact Model in order to facilitate decision split activities.
stackexchange-salesforce
{ "answer_score": 4, "question_score": 0, "tags": "marketing cloud, journeybuilder, mobilepush" }
Generic way to timeout async operations in boost::asio `boost::asio` provides many async actions i.e. `ip::tcp::resolver.async_resolve`, `ip::tcp::socket.async_{connect, read, write}`. The current way to timeout these operations is to add a wrapper class with a deadline timer attached. Is there a generic way to add timeouts to all these operations - i.e. a templated method/class or something?
boost::asio::basic_deadline_timer::expires_at is for that, and the examples: A collection of examples showing how to cancel long running asynchronous operations after a period of time.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c++, boost, boost asio" }
Pass 'this' as an argument to event handler using on() jQuery method I dynamically add elements with class `.footprint` to DOM and need to add `click()` event to them. My current code looks like this: $("#pcb").on("click", ".footprint", selectFootprint); However, `selectFootprint(sender)` method has a parameter where I would like to pass DOM element (this). How can I do it?
A few solutions (to pass the parents context): 1) using jquerys data parameter: $("#pcb").on("click", ".footprint", this, function(e){ console.log(this, e.data);//data is the parents this }); 2) using a closure var sender = this; $("#pcb").on("click", ".footprint", function(){ selectFootprint.call(this, sender); }); Or if you just want to pass the `.footprint` : $("#pcb").on("click", ".footprint",function(){ selectFootprint(this); });
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, jquery, onclick, event handling, jquery events" }
Collapse jQuery vertical tabs (Collapse div horizontaly) Here is the jsfiddle prototype: < Currently if I press the toggle button, the tabs-only div shows/hide, but the tabs-1 content div stays in place. The click event code is: $("#tabs-left").tabs(); $(function () { $('#hide').click(function () { $('#tabs-only').toggle(); }); }); I would like the content div align left when the tabs-only div is hidden. With other words the tabs-only div should collapse. Thx in advance
As my comment said, you should prefer to do that in CSS. Your Fiddle updated: < I just have changed a bit the CSS #tabs-left { position: relative; padding-left: 0.5em; } #tabs-only { float: left; width: 130px; height: 150px; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery, jquery ui" }
Convert column of date objects in Pandas DataFrame to strings How to convert a column consisting of datetime64 objects to a strings that would read 01-11-2013 for today's date of November 1. I have tried df['DateStr'] = df['DateObj'].strftime('%d%m%Y') but I get this error **AttributeError: 'Series' object has no attribute 'strftime'**
In [6]: df = DataFrame(dict(A = date_range('20130101',periods=10))) In [7]: df Out[7]: A 0 2013-01-01 00:00:00 1 2013-01-02 00:00:00 2 2013-01-03 00:00:00 3 2013-01-04 00:00:00 4 2013-01-05 00:00:00 5 2013-01-06 00:00:00 6 2013-01-07 00:00:00 7 2013-01-08 00:00:00 8 2013-01-09 00:00:00 9 2013-01-10 00:00:00 In [8]: df['A'].apply(lambda x: x.strftime('%d%m%Y')) Out[8]: 0 01012013 1 02012013 2 03012013 3 04012013 4 05012013 5 06012013 6 07012013 7 08012013 8 09012013 9 10012013 Name: A, dtype: object
stackexchange-stackoverflow
{ "answer_score": 51, "question_score": 52, "tags": "python, datetime, pandas" }
Is it possible to merge my storyboard and someone else's storyboard that I downloaded form GitHub? So Im pretty new at coding and so are these 2 other guys that I'm working with. One of them uploaded his part of the project to GitHub. So I downloaded his part and put all his files in my Xcode project(Not sure if that was the right thing to do). Im trying to figure out the method in which I merge his login storyboard and and mine storyboard into one? Again I'm super new at this.
Download and utilize sourcetree with a bithub account. Sourcetree is a great way to handle collaborating on a shared repository.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "ios, xcode" }
Are changes to El Capitan's SIP configuration file persistent? If you toggle System Integrity Protection off to tweak some things, unload daemons, delete apps, etc., will those changes survive toggling SIP back on and re-launching the machine, or will the changes be reverted? This review, based on OS 10.11 beta, suggests that deleting certain apps like Chess.app did not give the system any hiccups. But would this behavior be different for changing launch agents or launch daemons behavior? What about editing `defaults`? If one is accustomed to using "dotfiles," will those changes persist or will some of them revert?
After some experimentation, it seems that changes are persistent. My experience has been that disabling SIP lasts for only one reboot; i.e., you disable SIP via command terminal in OS Recovery mode and reboot the machine, and the SIP will be disabled for that session. SIP will remain disabled even if the computer is put to sleep. However, SIP will re-enable itself following a second shutdown or restart. Whatever changes you make during the period SIP is disabled will persist. The changes you make will also persist after updating, e.g., from 10.11.1 to 10.11.2.
stackexchange-superuser
{ "answer_score": 1, "question_score": 2, "tags": "macos, mac, terminal, sudo, osx el capitan" }
Capture video to a file from webcam using C++ (MFC) I need to add webcam video capture to a legacy MFC C++ application. The video needs to be saved as MP4. Did a bit of googling but didn't come across anything that looked promising. Any suggestions on the best approach? EDIT: Windows platform. EDIT: Must be compatible with XP
There are a few popular options to choose from: * DirectShow API - it does not have stock MPEG-4 compressors for video and audio, neither it has a stock multiplexor for .MP4 format, though there is an excellent free multiplexor from GDCL: < Also there is decent documentation, a lot of samples * Media Foundation API - it has everything you need (codecs, multiplexor) but only in Windows 7 (maybe even not all edtions) * `FFmpeg` and `libavcodec`/`libavformat` are definitely relevant, however H.264 encoder is only available under GPL license, not sure about video capture part right there, and you might have hard time looking for documentation and samples.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, video, mfc, webcam" }
Firefox configure one hop (double) proxy In my office network, all traffic goes through a squid proxy (proxy A). I have another squid proxy (proxy B) on a vps. I can browse internet fine using proxy A when on office network and proxy B when I connect from my home. However, I want to use proxy B from my office network. That is, I would like to tell firefox to use proxy B, but via proxy A. How to achieve this? I am fine with any alternate web browser / custom script that would allow me to do so as well.
i once tried to do the same thing... i never made it, but my alternate solution was to open an ssh tunnel to the server hosting proxy B (through proxy A obviously because i had to), and with this tunnel I was able to do whatever i need to... (i had to use proxytunnel < because my proxy A needed NTLM authentication and proxytunnel was the only one i manage to auth with...)
stackexchange-superuser
{ "answer_score": 1, "question_score": 1, "tags": "ubuntu, networking, firefox, proxy, squid" }
Using single NSTextField in multiple NSViews I've got three NSViews (we'll call them "main", "one" and "two"). The "main" view acts as a container for "one" and "two" which are subviews: [main addSubview:one]; ... // "one" gets replaced by "two" at a later point ... [main replaceSubview:one with:two]; The issue I have is that an `NSTextField` resides on "one" which I would also like to show up on "two", so it's there when "one" is replaced. The problem is that I can't seem to figure out how to reference or duplicate the `NSTextField` so that it can appear on both views and be used by both. !enter image description here Is it possible to use the same `NSTextField` in multiple `NSViews`?
**_Duh_** , the answer was right in front of my face... NSRect textRect = NSMakeRect(0,0,200,22); // X, Y, W, H NSTextField *text = [[NSTextField alloc] initWithFrame:textRect]; [text setStringValue:[NSString stringWithFormat:@"foobar"]]; [main addSubview:one]; [one addSubview:text]; ... // "one" gets replaced by "two" at a later point ... [main replaceSubview:one with:two]; [two addSubview:text] I just used an `NSMakeRect` and initialized it with the `NSTextField` and all is good.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "objective c, xcode, macos, cocoa touch, nsview" }
How is a nameserver chosen when DNS resolution occurs? I have a few domains hosted on nameservers at Zerigo. Zerigo have 5 nameservers and I have all 5 in the nameserver records for my domains. The nameservers are in different geographical locations (3 in the US, one in London, and one in Amsterdam). When someone goes to a domain of mine and the DNS resolution occurs, how will it choose a nameserver? Will it always go to the nearest geographical one? Will it go to the one with fewest hops? Will it just choose one at random? (This is assuming all 5 are functioning perfectly). Thanks **EDIT:** And does it make any difference which order I list the nameservers in on the domain name records?
Pretty much random. ROund robin, but given that they ask their providers server which may or may not have something cached.... NORMAL USERS: Ask their providers dns server for the ip address, which goes most likely to the root servers and gets a dns to ask from there (random, i.e. round robin). COMPANIES: ask their own name server which - again - goes to root and the result is random.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 3, "tags": "domain name system, domain, nameserver" }
How to make math inside preg_replace php I have the following string $str = ".block_1 {width:100px;}.block_2 {width:200px;}.block_3 {width:300px;}"; I want to replace the px values with percentage values according to this formula (pixelvalue / 960) *100 I know that with such regular expression ([0-9]+px) I can find all values + px but then I need to run through it again replacing it with (pixelvalue / 960) *100.'%' Hope you understand what I mean and thank you for any help. Ok, here is the solution: $str = preg_replace_callback( '([0-9]+px)', function ($matches) { return ((str_replace('px','',$matches[0])/960)*100).'%'; }, $str ); echo $str;
Have a look at preg_replace_callback
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 5, "tags": "php, html, regex, preg replace, preg match" }
jQuery menu hover off delay I'm using the below jQuery/javascript to control the hover functionality of a menu. When an "item-wrapper" item is hovered over, it display a tooltip submenu. I wish to add two pieces of functionality to this code: 1) For the Tooltip to only appear after 500milliseconds of hovering over a menu item 2) For the user to be able to move off the tooltip and have it stay visible for about 1 second (thus giving them the option to move back over it before it disappears) $(".item-wrapper").hover(function() { $('#' + $(this).attr("rel") + '-tip').fadeIn("fast").show(); //add 'show()'' for IE }, function() {//hide tooltip when the mouse moves off of the element $('#' + $(this).attr("rel") + '-tip').hide(); }); All help greatly appreciated
You can use `setTimeout` to delay the call. The tricky part is making sure to clear the timeouts correctly if the user re-hovers over the element, or hovers over a different one. var timeouts = {}; $(".item-wrapper").hover(function() { var rel = $(this).attr("rel"); var el = $('#' + rel + '-tip'); if (timeouts[rel]) clearTimeout(timeouts[rel]); timeouts[rel] = setTimeout(function () { el.fadeIn("fast").show(); }, 500); }, function() { var rel = $(this).attr("rel"); var el = $('#' + rel + '-tip'); if (timeouts[rel]) clearTimeout(timeouts[rel]); timeouts[rel] = setTimeout(function () { el.hide() }, 1000); });
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 4, "tags": "javascript, jquery, menu, tooltip" }
WipeDrive Utility? What is the best and fastest wipe drive (zero fill) utility that can be burned to a CD?
Darik's Boot And Nuke is the one I use and highly recommend. EBAN (Enterprise Boot and Nuke) is the commercially supported edition for those that require it.
stackexchange-serverfault
{ "answer_score": 13, "question_score": 5, "tags": "windows, hard drive, secure delete, zero fill" }
Modo de execução da Activity Galera criei uma activity fiz o layout, essa activity vai inserir o valor em um TextView de outro Layout, mas eu queria que ela abrisse como na imagem, alguem sabe como fazer? !img![img][1] tbm não sei se é de outra forma sem ser com activity, já fiz com DatePickerDialog deu certo, mas na activity não consegui
Olá, este componente que abriu como na imagem se chama **AlertDialog** , o dialog padrão pega as fontes e o layout padrão do android, para fazer um Dialog customizado que nem na imagem siga este roteiro da DevMedia. Bem vindo
stackexchange-pt_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android" }
How does one nest Twilio Twiml <Play> inside <Gather> using Twilio\Twiml php How would I nest Play inside Gather ? I have the following Twiml xml: $twiml = new Twiml(); $twiml->gather('gather',array()); $twiml->play(' array("loop" => 5)); $response = Response::make($twiml, 200); $response->header('Content-Type', 'text/xml'); return $response; required result: <?xml version="1.0" encoding="UTF-8"?> <Response> <Gather input="speech" action="/completed"> <Play loop="5"> </Gather>
Use this: $twiml = new Twilio\Twiml(); $gather = $twiml->gather(array('input' => 'speech', 'action' => '/completed')); $gather->play(' array("loop" => 5)); $response = Response::make($twiml, 200); $response->header('Content-Type', 'text/xml'); return $response;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "twilio, twilio php" }
Twig "trim" not working as expected Using this Twig template: {% for line in lines%} {{line}} after trim('.php') is: {{line|trim('.php')}}<br> {% endfor %} Using a controller in Silex to render the above template: $app->get('/try', function () use ($app) { $lines=[]; $lines[]='123.php'; $lines[]='news.php'; $lines[]='map.php'; return $app['twig']->render('try.html.twig', ['lines'=>$lines]); } ); I receive the following output: 123.php after trim('.php') is: 123 news.php after trim('.php') is: news map.php after trim('.php') is: ma Note the last trim: `map.php` should become `map` but is now `ma`.
I think this is expected behavior. `trim()` does not trim a substring but list of characters instead. So: map.php after trim('.php') is: ma map.php -> does it start/end with any of ['.php'] -> TRUE -> map.ph map.ph -> does it start/end with any of ['.php'] -> TRUE -> map.p map.p -> does it start/end with any of ['.php'] -> TRUE -> map. map. -> does it start/end with any of ['.php'] -> TRUE -> map map -> does it start/end with any of ['.php'] -> TRUE -> ma ma -> does it start/end with any of ['.php'] -> FALSE -> ma It acts exactly like: **php's trim()** Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php, symfony, twig" }
C++ Segmentation fault while trying to create a vector of vectors I want to create a vector of vectors in C++ with dimensions nx2 where n(rows) is given by user. I am trying to insert values in this vector using a for loop but As soon as give the value of n(rows), it gives a Segmentation fault error What to do? #include <iostream> #include <vector> #include <cstdlib> #define col 2 using namespace std; int main() { int row; cin >> row; vector<vector<int>> vec; for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) cin >> vec[i][j]; } return 0; }
You need to `resize` a vector before inserting elements. Or use `push_back` to insert incrementally. vector<vector<int>> vec; vec.resize(row); for (int i = 0; i < row; ++i) { vec[i].resize(col); for (int j = 0; j < col; ++j) { cin >> vec[i][j]; } } OR: vector<vector<int>> vec; vec.resize(row); for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) { int value; cin >> value; vec[i].push_back(value); } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, for loop, vector, segmentation fault" }
Predicting price using regression data model I built regression data model to predict house price upon several independent variables. And I got regression equation with coefficient. I used StandardScaler()to scale my variables before split the data set. And now I want to predict house price when given new values for independent variables using my regression model for that thing can I directly use values for independent variables and calculate price? or before include values for independent variables should I pass the values through StandardScaler() method??
To answer your question, yes you have to process your test input as well but consider the following explanation. StandardScaler() standardize features by removing the mean and scaling to unit variance If you fit the scaler on whole dataset and then split, Scaler would consider all values while computing mean and Variance. The test set should ideally not be preprocessed with the training data. This will ensure no 'peeking ahead'. Train data should be preprocessed separately and once the model is created we can apply the same preprocessing parameters used for the train set, onto the test set as though the test set didn't exist before.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, machine learning, regression, data science, data modeling" }
Calculate $\frac{1+i\tan \alpha}{1 - i \tan \alpha}$ I have been asked to calculate $\frac{1+i \tan \alpha}{1-i \tan \alpha}$, where $\alpha \in \mathbb{R}$. So, I multiplied top and bottom by the complex conjugate of the denominator: $\frac{(1+i \tan \alpha)(1+ i \tan \alpha)}{(1-i \tan \alpha)(1+ i \tan \alpha) } = \frac{1 + 2 i \tan \alpha + i^{2} \tan^{2} \alpha}{1-i^{2} \tan^{2} \alpha} = \frac{1 + 2i \tan \alpha - \tan ^{2} \alpha}{1 + \tan^{2} \alpha} = \frac{(1-\tan ^{2} \alpha)+2 i \tan \alpha}{\sec ^{2} \alpha} =\displaystyle \frac{1-\tan^{2} \alpha }{\sec ^{2} \alpha} + 2\sin\alpha\cos\alpha i$ Is this all that there is to do? Have I simplified it enough?
I'll continue from where you left to get a simpler form : * The real part : $$\frac{1-\tan \alpha^2}{1+ \tan \alpha^2}=\frac{\cos^2 \alpha-\sin^2 \alpha}{\sin^2 \alpha+ \cos^2 \alpha}=\cos2\alpha$$ * The imaginary part : $$2\sin \alpha \cos \alpha=\sin 2\alpha$$ A simpler form is thus : $$\frac{1+i\tan \alpha}{1-i \tan \alpha}=\cos2 \alpha+i \sin2\alpha$$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "complex analysis, complex numbers" }
General Lambda syntax question So I seem to be confident that the following 2 statements are the same List<object> values = new List<object>(); values.ForEach(value => System.Diagnostics.Debug.WriteLine(value.ToString())); AND List<object> values = new List<object>(); values.ForEach((object value) => { System.Diagnostics.Debug.WriteLine(value.ToString()); }); AND I know I can insert multiple lines of code in the second example like List<object> values = new List<object>(); values.ForEach((object value) => { System.Diagnostics.Debug.WriteLine(value.ToString()); System.Diagnostics.Debug.WriteLine("Some other action"); }); BUT can you do the same thing in the first example? I can't seem to work out a way.
Yes you can :) List<object> values = new List<object>(); values.ForEach(value => { System.Diagnostics.Debug.WriteLine(value.ToString()); System.Diagnostics.Debug.WriteLine("Some other action"); } );
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 4, "tags": "c#, .net, c# 4.0, syntax, lambda" }
How to grab the user's device token and attach it to an email as PDF file? My app has a voting topic and to avoid cheating I'm planing to let the user to vote by email which includes his/her device token so I can find out if the user voted more than one time. Is there any way to grab the user's device token and attach it to this email as a PDF file for example? if so can anyone please provide me with a sample code? Thanks in advance.
First of all this seems to be a really bad idea, sending an email and attaching a file... just ugly. Better open a URL on your voting server including the ID of the device. You can get the unique ID of the device like [[UIDevice currentDevice] identifierForVendor] or prior to iOS 6 you could use OpenUDID. Then use NSURLConnection to do the voting.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone, ios, xcode, sdk, email attachments" }
Is an iframe's srcdoc always an HTML document? I am trying to work around a cross-origin problem with Chrome which is produced by having an iFrame tag with a src attribute that has data uri in it. I am wondering if I can work around this with the srcdoc attribute. Which is why I am curious to if the default content type for a srcdoc 'text/html'?
Yes, the default content type is in fact `text/html`. According to the HTML5 specification, > If the srcdoc attribute is specified: > > Navigate the element's browsing context to **a resource whose Content-Type is text/html** , whose URL is about:srcdoc, and whose data consists of the value of the attribute. The resulting Document must be considered an iframe srcdoc document.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "javascript, html, iframe" }
What materials are fake coals for gas fireplaces made of? My new gas fireplace looks remarkably realistic! I'm curious what the "glowing embers" are made of. I have found replacement sets, but I've been having a hard time figuring out what materials comprise these fake embers. One description on a similar set suggests some type of ceramic material, however, I'm curious what technology goes into these rocks.
Originally (back in the old days), they (like gas grills) used volcanic rock aka lava rock. Several current vendors use a mixture of rockwool fiber material and vermiculite. Others list sand and vermiculite. Having them on the bottom helps diffuse the gas (by scattering the gas as it rises, so you don't see jets of gas). The glowing aspects is a nice side benefit. The newer 'glass' bead gas outdoor fire pits do a similar diffusion and look good when not in use (not so much for vermiculite and rockwool, which look 'ashy' (on purpose)).
stackexchange-diy
{ "answer_score": 3, "question_score": 3, "tags": "heating, fireplace, natural gas" }
Correct syntax to use new for char* array I have the following typedef struct { int titleCount; char** titles; } myStruct; And then ... struct1->titleCount = 2; struct1->titles = (char**) malloc(sizeof(char *) * (str->titleCount + 1)); ... What would be the correct syntax for using `new` instead of `malloc`?
in the example, titles points to an array of pointers to char or most probably actually strings. So I would expect something like: titles = new char*[str->titleCount]; // or maybe keep the +1 followed by a loop to allocate the individual strings and put pointers to them into the array pointed-to by titles.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c++, memory management, malloc" }
Converting "Textarea" object from iPython wigdet to a list or iterable array I have created several Textarea widgets in Jupyter/Python in order to capture some string inputs. In the highlighted in yellow that you can see below, the idea is that the user puts a list of numbers here (copied from Excel) and later I need to convert this text into a list or an array that contains these numbers (an iterable object). I have no idea how to do this. See: ![enter image description here]( When I print the type of this object that is called "plus" I get this: print(type(plus)) <class 'ipywidgets.widgets.widget_string.Textarea'> But, I am expecting to have something like this: plus = [454, 555] Can I bounce some ideas off you to get this? Thanks a lot!!!
If you have an ipywidget in general, you can observe its change and get its value as following. foo = widgets.Textarea() # to get the value foo.value # to do something on value change def bar(change): print(change.new) foo.observe(bar, names=['value']) You will then have to format the string you get from the products value, but that shouldn't be too difficult. Hope this helps
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "list, widget, ipython, textarea, iterable" }
WPF ListBoxItem double-click? The WPF ListBox doesn't have a DoubleClick event, at least not as far as I can tell. Is there a workaround for this issue that would let me double-click on an item to have an event handler do something with it? Thanks for your help.
You could always override the ListItem Control Template and handle the double click event inside the template, for example in an invisible border that contains the normal contents of the ListBox. This article shows you how to use a ControlTemplate with a ListBoxItem. Beyond that, simply add the handler to the outermost element of your control template. If you have Expression Blend, you can use it to extract the existing control template for you to modify so that you do not have to do as much work to ensure that the new list box behaves the same as the old.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 35, "tags": "wpf, wpf controls" }
IBM Mobile First server failed to provide access token I am using IBM Mobile First from around 1 month. I have implemented login security checks & called resources from apdaters. It was all working fine. Yesterday suddenly i got an issue while getting an access token on below method : WLAuthorizationManager.sharedInstance().obtainAccessTokenForScope. Error Domain=WL_AUTH Code=0 "The operation couldn’t be completed. No such file or directory" UserInfo={networkMetadata={ "$bytesSent" = 776; "$category" = network; "$outboundTimestamp" = 1468470845495; "$path" = " "$requestMethod" = POST; "$trackingid" = "C6B9FA4E-CFDD-42C4-ADF3-8FB0F43C8FFD"; }, NSLocalizedDescription=The operation couldn’t be completed. No such file or directory} Please explain why i am getting this?
You seem to have updated your client SDK to GA-level of MobileFirst Foundation 8.0, while continuing to use the beta-level server. The beta and the GA releases are **not compatible**. See this question on how to upgrade both your client and server: How to move a MFP 8 Beta Mobile App to the MFP 8 GA Version?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ios, ibm mobilefirst" }
JQUERY - Get data from multiple checkboxes How could I do to get data from this HTML code : <div id="indic"> <fieldset> <legend>Statistiques collecte :</legend> <input type="checkbox" name="indication[]" value="nbApp" />Nombre <input type="checkbox" name="indication[]" value="nbApp2" />Nombre2<br /> <input type="checkbox" name="indication[]" value="nbTel" />Nombre3 </fieldset> </div> Thank you :) **EDIT :** This is the solution : $.each($('#indic input[type="checkbox"]:checked'), function(i, v) { console.log($(v).val()) });
Not sure what data you are talking about but you could get the value of each checkbox by the following: $.each($('input[type="checkbox"]'), function(i, v) { console.log($(v).val()) });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "jquery, checkbox" }
CoffeeScript compiling: Unexpected IF I am writing some CoffeeScript code for an API, and in the error catching section of my code I placed an IF statement. Now, during the compilation process CoffeeScript is saying that the IF statement was unexpected. # Handle Errors app.error (err, req, res, next) -> if err instanceof NotFound res.send '404, not found.' else res.send '500, internal server error.' app.get '/*', (req, res) -> throw new NotFound NotFound = (msg) -> this.name = 'NotFound' Error.call this, msg Error.captureStackTrace this, arguments.callee The error is /home/techno/node/snaprss/application.coffee:22:5: error: unexpected if if err instanceOf NotFound ^^ Does anyone have any ideas where the issue is within my code?
Unexpected 'INDENT' in CoffeeScript Example Code This issue looks somehow similar. Consider therefore checking tabs and spaces in your editor.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 7, "tags": "javascript, coffeescript" }
In android studio is there a way to disable a module without deleting it? I have several modules in a project in android studio. Sometimes when there are compiler errors etc I want to disable other modules so that only certain modules are compiled for example I want to only focus on independent libraries etc and want their dependent modules to be unloaded/not included in the compile etc. How can I do that ? I know there is a way to delete them but I don't want them deleted. Just like in visual studio or eclipse we could unload certain projects in a work space.
in order to disable the module you should follow these steps * in the settings.gradle remove the library from include * also remove the using of it from build.gradle
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 4, "tags": "android, android studio" }
Downloading flash movies from any source! i was wondering if its possible? There are many extensions to firefox which help you to download vides from e.g; youtube etc but there are many websites which offer video training tutorials etc e.g; lynda and vtc. How you can download videos from them?
Well i have found that realplayer browser plugin is best for this.
stackexchange-superuser
{ "answer_score": -2, "question_score": 2, "tags": "video, download" }
PHP - How to use GeoLite2 IP CSV databases in MySql? How do you get the CSV databases of GeoLite2 City and Country to work? I have seen you must import it into a table. However I have seen some people takeout the IPv6 addresses. I have also seen some people attempt to combine both the blocks and the location databases... What I want to do is take an IP and get the GPS coordinate and the City, State, Country data. What table structure should I use? Once the data is imported how to I do a lookup using a PHP page?
I was able to figure it out... I removed all IPv6 IP records. Then I calculated the start and ending IP ranges and figured out where the IP fit in there. After that it was self explanatory.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, mysql, geolocation, geocoding, maxmind" }
How to make clang not substitute #define macro I'm calling the `Success` method on the pointer `result`, but clang substitutes the macro `Success` from `X11.h`: /home/dev/common/src/flutter_orwell_plugin.cc:42:10: error: expected unqualified-id result->Success(&response); ^ /usr/include/X11/X.h:350:21: note: expanded from macro 'Success' #define Success 0 /* everything's okay */ I can't change the name "Success", it's from the library. Why this is happening?
You can use the undef directive to remove a previously-defined macro. For example: #undef Success return result->Success(&response);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, clang" }
How can we avoid gac installed third party components? We are developing software which uses third party components with build and runtime licencing (if the software is not installed on the developer machine, visual studio complains when trying to generate a licence). Are there any general ways to register the required information in the registry without installing the third party components? The reason for asking is because the difference between a developer machine and the typical client/tester machine is the biggest reason for the "works on my machine"-syndrome. We want to emulate the client enviroment, which means avoiding as many locally installed third party components as possible on the dev machines.
The proper solution is a VM. Registry hacks won't magically create licenses.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "visual studio, registry" }
FindBLAS and FindLAPACK usage in CMake I am a bit confused by the utility of find_package(BLAS) and find_package( LAPACK) within CMake. It seems that depending on the vendor found, different source code is necessary. For example, mkl has mkl.h and/or mkl_lapacke.h but at least one other implementation of lapack has a header which is just called lapacke.h so different headers are needed. and also somatcopy for mkl is mkl_somatcopy whereas other libraries clearly wont have the mkl_ prefix. How do you reconcile this in a generic fashion as to make a tool such as find_package( LAPACK) work effectively? Is there a standard header, because it doesn't appear to be lapacke.h for the lapacke interface..? Finally, Accelerate is listed as an option, but, Accelerate includes LAPACK 3.2.1 equivalent features which misses the LAPACKE interface which _is_ available in MKL and current netlib lapacke 3.5..
Ok, so the example I gave is an example of blas extension. The blas functions themselves are all the same. The only issue is the different header between mkl and other blas/lapack interfaces. As far as cmake is concerned the find_package() routines mentioned are a bit out of place. I found it easiest to search for mkl, use it if found, otherwise fall back to the findblas routines of cmake, then I use add_definitions to define a preprocessor macro to change between mkl and other Implementations...
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c++, c, cmake, lapack, lapacke" }
Correct use of the superlative degree Kindly tell me whether I used the superlative degree correctly in these two sentences: 1. He enjoyed all _the sweetest and most charming_ scenery. 2. He enjoyed all _the sweetest and **the** most charming_ scenery.
charming is not really use for scenery, but makes for a good metaphor. If you want to use **most** , you could write: He enjoyed the sweetest and most charming of scenery.
stackexchange-english
{ "answer_score": 1, "question_score": 1, "tags": "conjunctions, superlative degree" }
LINQ: Find if one item in List appears in a string array I have a string array and another object that has a list of objects, on of the properties is a string. public string[] allowedroles; foreach (var role in allowedroles) { if (user.RolesList.Exists(r => r.Name == role)) { authorize = true; break; // if one match that break out of loop } } Is there a way to perform with just a LINQ statement, without the foreach loop?
It sounds like you want: var authorize = user.RolesList.Exists(r => allowedRoles.Contains(r.Name)); Or transform the list of roles into their names, and see whether that intersects with the allowed roles: var authorize = user.RolesList.Select(r => r.Name).Intersect(allowedRoles).Any(); Note that you could use `Any` instead of `Exists`, which would stop it being specific to `List<T>`: var authorize = user.RolesList.Any(r => allowedRoles.Contains(r.Name)); Also note that even though the `foreach` loop is no longer in the code, using LINQ won't make this code any _faster_ \- there's still a loop, it's just in the LINQ code rather than in your code. But hey, readability is still a big win :)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c#, linq" }
.dynamicType is deprecated. Use 'type(of ...)' instead I've just updated to Xcode 8 and iOS 10 (using legacy Swift Language Version). Trying to compile again my project has been an agony, even still using the old Swift syntax. This time one of my functions uses `NSBundle(forClass: self.dynamicType)` but now appears that `.dynamicType` is deprecated and Xcode doesn't even want to compile it. His suggestion is to use `type(of: self)` but that fails as well. Anyone knows the solution? Thanks.
@dfri answer works perfectly for Swift 3. Regarding Swift 2.3, my solution was to clean Xcode (Command+Option+Shift+K) and delete everything in `~/Library/Developer/Xcode/DerivedData`. The problem doesn't disappear instantly but after some time it will stop giving that error. Maybe it's a bug, after all we are in 8.0. I hope it gets fixed in next releases. Thank you everyone.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 33, "tags": "swift, xcode" }
Excel VB script to print all workbooks' sheets is there using excel's vb script (or macros) to print all its sheets to a given printer ? The number of sheets is variable. Excel's version is 2007. Thanks
See if something like this is what you are looking for. You'd just need to set up a loop to select all of the sheets, and use that `select false` method on all but the first. Here's what I cobbled together (I did not test it extensively, and my VBA is a little rusty) Sub loopandprint() Dim ws As Worksheet Dim i As Integer i = 0 For Each ws In ActiveWorkbook.Worksheets If (i = 0) Then ws.Select Else ws.Select False End If i = i + 1 Next ws ActiveWindow.SelectedSheets.PrintOut Copies:=1 End Sub
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "excel, vba" }
How can I serialize cv::Mat objects using protobuf? Is there a gentle solution? (Such as an existing Mat.proto file.)
That is a tricky one. The question is do you need all the data and properties from cv::Mat? If yes my condolences, because you would need to map everything to the new protobuf structure. if you want to have something like this: // make a 7x7 complex matrix filled with 1+3j. Mat M(7,7,CV_32FC2,Scalar(1,3)); The you need something like: message Mat { required uint32 xSize = 1; //7 required uint32 ySize = 2; //7 required string encoding = 3; //CV_32FC2 message Scalar { // this is optional required uint32 x = 1; required uint32 y = 2; required uint32 z = 3; } repeated Scalar matrix = 4; // 49 elements //note here that the Scalar is a 4-element vector derived from Vec //and the matrix should consist of scalars }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "opencv, protocol buffers" }
Lua table to function arguments I have a redis command that uses the format: red:msetnx(key1, val1, key2, val2, key3, val3, ...) I would like to set this up behind a function that takes a table of key / value pairs and runs that through `red:msetnx()` \-- How would I reformat my table into an alternating key/value comma separated argument list and pass that to the function?
Make one table that has the keys and values in order, and pass it using `unpack`: args = { 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' } red:msetnx(unpack(args))
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "lua, redis" }
Stretch font vertically in React Native I'd like to stretch some font like the below image (only vertically stretch, not horizontally). Is it possible? Or will I have to use an SVG/Image instead. Thanks ![Stretched Image](
For vertical stretching, you can use the css `transform` property and scale it along the Y axis like so p{ font-size:50px; transform: scale(1, 5); } <p>Some Text</p> Hope this helps !
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "reactjs, react native" }
How can retrieve the date value of the opportunity history record in reporting? Is there a way to return the date (and time) of the opportunity history record, i.e., when it was saved/created? I am currently unable to build a report of opportunities that have moved to a certain stage in a certain period of time.
Reports -> New Report -> Opportunity History Report (NOT Opportunity field history report) !enter image description here Opportunity history records only expose Last Modified Date, which is fine because they are read only.
stackexchange-salesforce
{ "answer_score": 1, "question_score": 1, "tags": "reporting, date, analytics" }
Can I fold with an infix operator without writing out an anonymous function? If I wanted to add up a list I could do this: - List.foldr (fn (x, y) => x + y) 0 [1, 2, 3] val it = 6 : int Is there any way to write something more along the lines of: List.foldr + 0 [1, 2, 3] I tried something like this: fun inf2f op = fn (x, y) => x op y;
You're close. Add the `op` keyword in the second example. - List.foldr op + 0 [1,2,3]; val it = 6 : int
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "sml, syntactic sugar" }
NAS to video projector - do I need a Raspberry Pi? My partner and I will be buying an apartment and moving into it soon, and because we don't really watch TV or play on screen-dependant consoles, we're thinking of installing a video projector on the ceiling and using the wall as a screen. A colleague of mine had told me of all the upsides of having a NAS, and it does seem quite advantageous. I was wondering if it would be possible to hook a NAS (don't know which brand or model I would need) to a videoprojector via an HDMI cable or equivalent, or if I would need to use a computer to link the two together, for example a Raspberry Pi with very basic software installed. Big upside if the setup can also handle audio, both playing alongside the video being sent to the projector, and independantly just as back ground music.
Most NAS don't have HDMI,DisplayPort or etc output. This is your biggest challenge. Maybe you can find a projector that will connect to your NAS directly, but it is likely your going to find you have limited video format support. This is where a raspberry Pi or similar comes in handy as you can load Plex or Kodi or one of a hundred other thing onto it which will convert the video for you to whatever your projector supports. A Pi 4 has wifi support so it could connect to the NAS wirelessly and the Pi 4 has HDMI and an audio port for you to connect to your projectors. You will likely need samba for file sharing. So the Pi 4 idea will likely offer significantly more options. If you need to decode h264 or h265 you will likely need something faster than a raspberry Pi 4.
stackexchange-hardwarerecs
{ "answer_score": 1, "question_score": 0, "tags": "audio, raspberry pi, video, nas" }
single or double quote in javascript append i am beginner in Jquery, confused about using single quote or double quote to call the value of myName Textbox, i want to catch the value of text box . this is my code, calling function save_order is not working, because failure syntax in document.getElementById( **'myName'** ).value what is the right syntax ? <script> var param=3; $('#saveList').append( '<p>FullName : <input type="text" id="myName"></p>'+ '<p><input type="button" value="SAVE" onClick="save_order('+ param +',document.getElementById('myName').value)"></p>'); </script> pls help me anybody thank you
The problem is in calling document.getelementById. With escaping, you can achieve your result. <script> var param=3; $('#saveList').append( '<p>FullName : <input type="text" id="myName"></p>'+ '<p><input type="button" value="SAVE" onClick="save_order('+ param +',document.getElementById(\'myName\').value)"></p>'); </script> Check your part: `document.getElementById('myName')` ... And my part: `document.getElementById(\'myName\')` When you use `'` as start and end character of string, you have to use `\'` if you want to use `'` inside as string literal.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, jquery" }
create a client with the wifly shield and an arduino and WiFly.begin() failed I have a problem. I set my wifly shield with TerraTerm, but i can not connect and create a client. When I use example, my program stop on WiFly.begin() and nothing else... I would like to create a communication with a server, and send some data to it. I have a server (with its IP and port), I have a C program wich listen on IP and a specific port. But now, I want to connect my arduino to this server. Have you got an issue ? Thanks you and merry christmas :)
If someone had the same problem, here my solution : I used the WiFlyHQ library, and now it works.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c, arduino, wifi" }
"extern" keyword usage I have the following code snippet: #include<iostream> int main() { extern int a; printf("a = %d", a) } int a = 10; Above sample code print 10. My guess was it should print garbage value. Can someone explain this ?
Global variables have static duration and statics are initialized before `main` runs. Therefore `a` already has it's value set to `10` by the time `printf` is called.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 0, "tags": "c++, extern" }
Why am I getting error 'not declared'? I'm trying to show a `DropDownList` (`cbb_conj_habitacional`) if the selected value of another `DropDownList` (`cbb_area_verde`) equals 7... But, when I try this code, I get the following error: `Name 'cbb_area_verde' is not declared` and it also goes to cbb_conj_habitacional. Protected Sub cbb_area_verde_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim selecionado As Integer selecionado = cbb_area_verde.SelectedItem.Value If (selecionado = 7) Then cbb_conj_habitacional.Visible = True End If End Sub And yes, I'm in my partial class.
I know now what I did wrong... My "cbb_conj_habitacional" is inside of a formview, so I just declared it by findControl. Dim cbb_conj_habitacional AS DropDownList = formView.FindControl("cbb_conj_habitacional") I hope it can help someone.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": ".net, vb.net, drop down menu, selectedindexchanged" }
Get data from JSON by using a variable JavaScript/jQuery I'm trying to get data out of a JSON using a value. I have an array of objects: "fruits": [ { "Name": "Orange", "Quantity": "5" }, { "Name": "Apple", "Quantity": "2" } ] And I also have the name "Apple". How can I get the quantity of Apples? I'm stuck on this.. Thanks!
`fruits.find(fruit => fruit.Name==="Apple").Quantity` is what you are looking for: const fruits = [ { "Name": "Orange", "Quantity": "5" }, { "Name": "Apple", "Quantity": "2" } ] console.log(fruits.find(fruit => fruit.Name==="Apple").Quantity);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -2, "tags": "javascript, jquery, json" }
Making scheduled requests to Google APIs with service accounts I have a flask website. i would like the user to be able to schedule repeated requests for data from one of their Google accounts (let's say Gmail). From within the website, the user would first authorize the application to access their private Gmail data. From then on, the application, would retrieve the user's Gmail data on a re-occurring basis, without needing to get authorization each time. Is this possible? I know it would require a service account but can anyone point me in the direction of documentation that describes how this particular scenario might work. Would such a scenario be allowed to persist long term? Or will their come a time when Google will require the user to reauthorize the application?
Correction, you should not use App Passwords. OAuth is the correct way to do it I believe: < Here's Google's docs on it, which is more specific to your need: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "flask, google cloud platform, google api, service accounts" }
Combining functions in xpath selector I have a selection I want to make in xpath and can't seem to get it right. So I have: `//td[starts-with(@id, '16276688381') and not(ends-with(@id, '_name'))]` This is the simple html <td id="16276688381_name">I don't want this</td> <td id="16276688381_B3" >What I want</td> <td id="16276688381_B4" >More of these...I want them</td> Once I add the and my selection disappears. Any idea what is going wrong here?
As Martin points out, XPath 1.0 does not support `ends-with`, but you can simulate it with some string length calculations: //td[starts-with(@id, '16276688381') and not(substring(@id, string-length(@id) - 4) = '_name'))]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "html, xpath" }
send value from popup('open') to 'popupbeforeposition' I've a function that is triggered from a on click event. It's open up my popup, and im woundering how to send my date to my 'popupbeforeposition'. module.selectedDay = function($this) { var date = $this.data('date'); $('#popupWorkSelect').popup('open'); }; $('#popupWorkSelect').on({ popupbeforeposition: function (event) { //Get date sended to this function? console.log(event); }, popupafterclose: function(event) { } }); I know that I can work with my 'module.selectedDay' function like this but it's not the way I want to do it. module.selectedDay = function($this) { var date = $this.data('date'); $('#popupWorkSelect').find('#myElement').innerHTML = date; $('#popupWorkSelect').popup('open'); };
* When the click happens, store the value in `data` of the popup. $popup.data("mydata", date); * in the `popupbeforeposition` event, take it out from data and use it. (Here the context would be within the popup so `data` you need would lie in `$(this)`. So the way of access would be this: $this.data("mydata") **Demo** : `< **PS** assume $popup and $this are the popup elements
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, jquery mobile" }
Need some help on document template creation in word I need some help/suggestion or pointing to some resources about creating a template in word. The template I am trying to create is to share with third parties. The idea is the fist page has a header that is not repeated, the third page is the only page that has a header that repeat in odd pages. the second, fourth and all even pages doesn't have a header. This is the link to the sample of the document in pdf <
When setting the header and footer, you may only need to go to the **Header & Footer** tab and check the **Different First Page** and **Different Odd & Even Pages** in the **Options** group. ![enter image description here]( Any misunderstandings, pelase let me know.
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "microsoft word, templates, documents" }
Plotting the difference of two columns in the same file I have a file with 12 columns. I'd like to plot the data with x axis being my 1st column and y axis being the difference between the 2nd and the 8th columns. I tried `plot "test.dat" using 1:(8-2)` but naturally, it is interpreted as `1:6`. How can I do this?
You are missing `$`, just add them and they will allow you to reference the column contents plot "test.dat" using 1:($8-$2) w linespoints `$1` is a shortcut for `column(1)` and if the column numbers are stored in variables `i` and `j` you _must_ use the `column` statement to select the respective columns: i = 8 j = 2 plot "test.dat" using 1:(column(i)-column(j)) w lp
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "plot, gnuplot" }
PostgreSQL: Replace string from specific position to end of string I have the following string: String 1: abcde?dafsdfdsfsd String 2: absdfcde?dafsdfdsfsdsfdsdfd Want to remove anything after "?" Expected output: String 1: abcde String 2: absdfcde
Use `split_part()`, e.g.: with my_data(col) as ( values ('abcde?dafsdfdsfsd'), ('absdfcde?dafsdfdsfsdsfdsdfd') ) select split_part(col, '?', 1) from my_data; split_part ------------ abcde absdfcde (2 rows)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "postgresql" }
(Python) Go to a line within the function So, I've got this going on: def pickClass(): print('What class are you? FIGHTER, MAGE, or THIEF?') classChoice = raw_input() if classChoice == 'FIGHTER': print('You are a mighty warrior. Are you sure? YES or NO.') _confirm = raw_input() if _confirm == 'YES': print('So be it.') elif _confirm == 'NO': pickClass() else: print('YES or NO only!') #go back to '_confirm = raw_input()' The part where I'm stuck is at the very end -- how do I go part to that specific part of the code without going through the entire function again? (I know it's a little redundant with that print, but whatever, maaaaan)
You will need to restructure your function. Try something like this: def pickClass(): valid_classes = ["FIGHTER", "MAGE", "THIEF"] while True: print('What class are you? FIGHTER, MAGE, or THIEF?') classChoice = raw_input() if classChoice not in valid_classes: print("Invalid class") else: print("Are you sure you want to be a %s?" % classChoice) while True: _confirm = raw_input() if _confirm == 'YES': print('So be it.') return classChoice elif _confirm == 'NO': break else: print('YES or NO only!')
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, function, line, goto" }
What is the best tool to draw out large inheritance pieces of code? I have started doing a code review for someone, and there is a large inheritance model (many layers deep). After filling up my white board, I realized that I need a tool to draw this out. What is the best tool (preferably free) to draw this out, so I can visualize what's happening in the code base. The code is in Python, but I think my question or the solution should be generic. I don't mind drawing it out by hand as the value for me is the scalability around the visualization.
You can also look for Epydoc to generate an UML diagram from the source code (see this Stack Overflow question) Also, AutoDia and HappyDoc claims that can generate Dia UML diagrams from the Python source
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "inheritance, drawing, modeling" }
Standalone multi/handler reverse_tcp Sorry for my english. Using metasploit I generated an exploit for windows 7 with windows/shell/reverse_tcp payload. Then I waiting connection using msfconsole: use exploit/multi/handler set PAYLOAD windows/shell/reverse_tcp set LHOST 192.168.182.129 set LPORT 4444 exploit I am successfully connected to command line of windows. However I need to expect connection without using metasploit. I found how to create standalone module, but it was only for an exploit. I need standalone multi/handler reverse_tcp or simply the code which listens to a certain port and then gives access to command line.
I don't really know what your **constraints/restrictions** are. My guess is that, you want to "receive shells" on a computer without metasploit installed on it. If that's the case, you could use **msfd** ( _metasploit daemon_ installed on a different computer) or simply netcat,socat,... What do you think of this: * listening with netcat on 192.168.1.2 `# nc -l -p 4444` * Using a _shell_reverse_tcp_ instead `# msfpayload windows/shell_reverse_tcp LHOST=192.168.1.2 LPORT=4444 X /root/darkbird.exe` * Execute darkbird.exe on the target
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "metasploit" }
How to enable auto-increment with Sql compact & C# I'm using C# 2010 Express. I have created a SQL Server CE database file (`.sdf`) then created Information table and ID, Name, City columns with Database Explorer. I want to save names and city user will write to the form. The auto-increment option is disabled in Database explorer and Properties windows. When I'm saving something to that database i must change the ID manually, how can I make ID column auto-increment enabled?
There is a simple way for SQL CE: ALTER TABLE TableName ALTER COLUMN ColumnName IDENTITY (/*seed*/1, /*increment*/1)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, auto increment, compact database" }
Highcharts - Skip date in series So I'm pulling some data from a database and getting a UNIX Timestamp and a number. So lets say N (number) was sold on D (date). There are days missing, like the weekend. I need it to still display the day, but not require any data. It's a line chart. April 1 2010, 50 sold April 2 2010, 53 sold April 7 2010, 10 sold (I have over a 1,000 records spanning a several years - so I will add a zoom as well) So the chart should still show April 1-7 but have no data for 3-6. (the line would just go from 2-7). Any ideas on how to do this? Thanks, Josh
take a look here: < second example of 'data' property. You just have to convert mysql date, convert it to UNIX timestamp (UNIX_TIMESTAMP()), and then multiply it by 1000 (JS needs time in microseconds)...
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "javascript, jquery, graph, charts, highcharts" }
How to display metadata about single commit in git? I'd like to parse meta information from git repository. I'd like to fetch a single information for a commit, as in git log --pretty=format:%an HEAD^..HEAD Problem is, this is not working for the first commit in repository. git show --pretty=format:%an HEAD^..HEAD is also close to what I want, except I'm not interested in parsing actual diff. Any idea how to make git log work for the first commit or how to disable git show from showing commit content? Or, is there any better way how to retrieve metadata about given commit?
Supply the quiet option to show to suppress the diff. git show --quiet HEAD So for your example, author name: git show --quiet --pretty=format:%an
stackexchange-stackoverflow
{ "answer_score": 85, "question_score": 57, "tags": "git" }
View::make in Phpunit I've a function that returns a `View::make($string)`. I want to test that this function did indeed return an instance of View object. `$string` points to a file that does exist. When I try to run this function within Phpunit it doesn't seem to finish. How can I test in Phpunit that a View object was created?
The issue stemmed down from usage of `var_dump` as I wanted to see the object in question. As nothing was presented in output, I assumed that had to do with `View::make` rather than outputting the object to the console.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "laravel, phpunit, laravel 5.4" }
Infinite while loop counting tokens Java I'm trying to write a little program that counts the number of words in the string `words` and prints it to the console. But every time I run it, it's an infinite loop. What am I missing? public static void main (String[] args){ String words = "This is the sentence I want to use"; Scanner s = new Scanner(words); int count = 0; while(s.hasNext()){ count ++; } System.out.println(count); }
You are not actually parsing anything, you need to fetch tokens from the scanner through `next()` function: while (s.hasNext()) { ++count; s.next(); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "java, loops, while loop" }
Prawn + Russian fonts I have a Rails app and I use Prawn gem there. I need to make it to generate pdf with Russian alphabet (mix of Russian and English words, in fact). I did a research and found some time ago it was fairly tricky. What about it now, how do I do that? def about respond_to do |format| format.html format.pdf do pdf = Prawn::Document.new pdf.text "не ну ни фига sebe" send_data pdf.render end end end
This is an issue with fonts, you need to install a font that supports the characters you wish to display, and tell `prawn` to use it. `prawn` version 0.12.0 comes with one font which will at least display something: pdf = Prawn::Document.new pdf.font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf" pdf.text "не ну ни фига sebe" send_data pdf.render If you want it prettier, you need to find and use another font, and modify the `pdf.font` line to use it.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "ruby on rails, ruby, prawn, cyrillic" }
Debug Assertion Failed on \$InstallDir\VC\atlmfc\src\mfc\appgui3.cpp, line 385 when loading MFC view In my task, I have to load a MFC view in WPF windows. When I run the code, there is an error show this: Debug assertion failed at appgui3.cpp, line 385: BOOL CWinApp::EnableTaskbarInteraction(BOOL bEnable) { if(AfxGetMainWnd() != NULL) { ASSERT(FALSE); **TRACE0("Windows 7 taskbar interacrion must be called before creation of main window.\n");** return FALSE; } m_bTaskbarInteractionEnabled = bEnable; return TRUE; } Thank you for your help
You don't have a main window. Creating a view inside a WPF window still requires a frame window. And as long as you have a EXE you need a main frame window for some frame tasks like task bar interaction. As long as you have no mainframe window there is no window the taskbar can interact with.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c, wpf, mfc" }