INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Create and redirect subdomain for a parked domain? I have a domain `parked.com` which is parked onto `real.com`. I have created the subdomain `m.parked.com` by editing `parked.com`'s named file: m 14400 IN A ip-address www.m 14400 IN A ip-address This works somewhat: if I go to `m.parked.com` it redirects to ` This is my question: I would like to redirect this subdomain to `real.com` as that is the domain it is parked on. I do not know how to do this as `parked.com` does not have its own .htaccess file, etc. (due to it being a parked domain) so I can't do any mod_rewrite magic. Can anyone help me? Thanks EDIT: Clarification
I have solved this issue. 1. Edit `parked.com`'s DNS record so it has a subdomain: `m 14400 IN A ip-address` 2. Add `m.parked.com` to `real.com`'s `ServerAlias` in `httpd.conf` 3. Restart both `Bind` and `Apache` 4. Going to `m.parked.com` will now bring you to `real.com` 5. You can then use `real.com`'s `.htaccess` for your normal URL rewriting.
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "domain name system, redirect, subdomain" }
Problem with a basic lemma in Lambda Calculus I have some serious problems with Lambda Calculus. In an introduction by Barendregt and Barendsen at page 11 there is the following lemma, whose proof I do not completely get. > $\mathbf{\lambda} \vdash ( \lambda x_1 \dots x_n . M) X_1\dots X_n = M [ x_1 := X_1] \dots [x_n := X_n]$. Even if I find the result intuitive, the proof, which should be obvious by induction and $\beta$-reduction, is not clear. In particular, I really don't get **_why the order is preserved in the manipulation_** , that is, from LHS we get on the RHS that $x_1 := X_1$, $x_2 := X_2$, etc (and I think here the order has to be important). I have the feeling that this is the symptom of a deep misunderstanding of how lambda calculus works in general. Any feedback is greatly appreciated.
Note that $(\lambda x_1 x_2. M)X_1 X_2$ is actually shorthand for the following: $$((\lambda x_1 . (\lambda x_2 . M)) X_1 ) X_2$$ Considering the second $\lambda$-term as being opaque - say it's $Q$ - that is $((\lambda x_1 . Q) X_1 ) X_2$, which is just $(Q[x_1 := X_1])X_2$ by $\beta$-reduction. Now substitute back $Q = \lambda x_2 . M$, so we have $$((\lambda x_2 . M)[x_1 := X_1]) X_2$$ Since $x_1$ does not appear in the phrase "$\lambda x_2$", we can move the substitution inside the $\lambda$-term: $$(\lambda x_2 . M[x_1 := X_1]) X_2$$ And now we are in a position to use induction: we've shown that $$(\lambda x_1 x_2 .M)X_1 X_2 = (\lambda x_2 . M[x_1 := X_2])X_2$$ and we can just keep going in the same way.
stackexchange-math
{ "answer_score": 2, "question_score": 6, "tags": "logic, computer science, lambda calculus" }
Find the length of a line with triangles and squares Is there a way to do this without sin/cos/etc? I've gotten as far as the diagram but I'm not sure how to approach or solve this problem. > Suppose that ABCD is a square with AB=6. Let N be the midpoint of CD and F be the intersection of AN and BD. What is the length of AF? diagram
![enter image description here]( From above figure, consider $ \Delta ADN $, Using Pythagoras theorem, $AN^2$ = $AD^2$ \+ $DN^2$ = $6^2$ \+ $3^2$ = $ 45$ So, $ AN = 3\sqrt 5$ Draw a perpendicular line from point $F$ to $DN$ at point $P$ Again, using Pythagoras theorem in $ \Delta FPN $ , we get, $FN^2$ = $FP^2$ \+ $PN^2$ = $2^2$ \+ $1^2$ = $ 5$ So, $FN = \sqrt 5$ Since, $ AN = AF + FN$ Therefore, $AF = AN - FN = 3\sqrt 5 -\sqrt 5 = 2\sqrt 5$
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "geometry, trigonometry" }
Scaling down a raster image I have a raster image (A) of size 20x20 and I want to scale it down to a size of 10x10 (B). Naturally in the resulting picture B one pixel will represent 4 pixels shaped 2x2 from A. Is it possible to give a canonical answer to how the pixel values of B have to be calculated if no neighbouring pixels (surrounding the 2x2 subset) in A should be taken into account? Mean, maximum or something else?
Bilinear is the most widely used method. The nearest neighbor down-sampling algorithm is the fastest but least accurate. Note that when you are trying to down-scale an image by half, the bilinear sampling algorithm becomes the average (mean as you mentioned): x1[i/2][j/2] = (x[i][j] + x[i+1][j] + x[i][j+1] + x[i+1][j+1]) / 4;
stackexchange-dsp
{ "answer_score": 4, "question_score": 2, "tags": "image processing" }
Is there a function that will allow to get the difference between rows of the same type? I want to find the difference in the values of the same type. Please refer to the sample dataframe below: df <- data.frame( x = c("Jimmy Page","Jimmy Page","Jimmy Page","Jimmy Page", "John Smith", "John Smith", "John Smith", "Joe Root", "Joe Root", "Joe Root", "Joe Root", "Joe Root"), y = c(1,2,3,4,5,7,89,12,34,67,95,9674 ) ) I would like to get the difference in the each value for e.g. Jimmy Page = 1 and Jimmy Page = 2, difference = 1. And present **NA** for difference between dissimilar names.
You can use `diff` in `ave`. df$diff <- ave(df$y, df$x, FUN=function(z) c(diff(z), NA)) df # x y diff #1 Jimmy Page 1 1 #2 Jimmy Page 2 1 #3 Jimmy Page 3 1 #4 Jimmy Page 4 NA #5 John Smith 5 2 #6 John Smith 7 82 #7 John Smith 89 NA #8 Joe Root 12 22 #9 Joe Root 34 33 #10 Joe Root 67 28 #11 Joe Root 95 9579 #12 Joe Root 9674 NA
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "r, dataframe, dplyr, tidyverse, tidyr" }
How to amend this powershell script to include the password? The below code will prompt the user for the password but I want to insert a password in the script (hidden would be preferable). Therefore, the script will run with user inervention and will create and add the user to the admin group. $Password = Read-Host -asSecureString New-LocalUser -Name User -password $Password Add-LocalGroupMember -Group "Administrators" -Member User I modified the script to the below, however I received a secure script error: New-LocalUser -Name User -password Password Add-LocalGroupMember -Group "Administrators" -Member User
You can use `ConvertTo-SecureString -AsPlainText -Force` to convert a string value to a `[SecureString]` instance: $Password = "th3d3f4ultP4$$W0rd!!!" |ConvertTo-SecureString -AsPlainText -Force
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "windows, powershell, powershell 2.0, powershell 3.0, powershell 4.0" }
Request types on iPhone || Android? Is it possible to send GET, POST, PUT and DELETE requests from iPhone || Android applications to a third party server? I want to build a web service to reuse on all 3 platforms (3rd being the web app itself).
Yes, making HTTP requests on mobile devices running iOS or Android is no different from desktop Java or Cocoa. Both platforms offer API's that enable you to change the request method. Checkout `NSURLConnection` on iOS and the `org.apache.http` package on Android.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "iphone, android" }
Can I invert the argument in this way? Is it permissible for me to invert the argument as follows: $$f(1/z) = \frac{c}{z^n}\implies f(z) = \frac{c}{\frac{1}{z^n}}\implies f(z) = cz^n$$
Yes, this is correct. But I feel I should point out one extra step: $$f(1/z) = \frac{c}{z^n} \implies f(z) = \color{red}{\frac{1}{\left(\frac{1}{z}\right)^n}} = \frac{c}{\frac{1}{z^n}} = cz^n.$$
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "calculus, algebra precalculus" }
When is the firebase_campaign event triggered? < states in passing that `firebase_campaign` is auto-generated. Unfortunately ‘Automatically collected events’ doesn’t document that particular event. When is it triggered?
_firebase_campaign_ event is automatically triggered by user interaction and is not intended to be shown on the Firebase console. The data corresponding to event in form of the parameters is passed to Ads framework for further analysis and generating quality content. The only way to obtain the data related to that event is via the Big Query export.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "firebase, firebase analytics" }
Asp.net how to Delete specific List Items from a Model I have a model which contains a list and I need to remove/delete all items from the model based on the `MarkedForDeletion` value. So far I've tried the following but this is not valid, I would prefer to not loop through the records using a for loop. ### Models cs public class CategoryModel { public string Label { get; set; } public List<ItemModel> Items { get; set; } } public class ItemModel { public string Label { get; set; } public bool MarkedForDeletion { get; set; ) } ### Attempted Solution (not a valid statement) CategoryModel.Items.Where(x => x.MarkedForDeletion = true).Remove;
Have you tried `RemoveAll()` which will remove all the elements that match the conditions defined by the specified predicate? CategoryModel.Items.RemoveAll(x => x.MarkedForDeletion);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c#, asp.net mvc, asp.net core" }
pyspark udf rlike condition in if error I am using spark 2.1 scripting is pyspark scripting My Dataframe is given below dataframe name:df a Naveen Naveen123 Now my output should be as a Naveen I am using below udf for this def fn(a): if((a==rlike("[0-9]"))|(a==' ')): return s df.withColumn("FLG",fn("a")).show() I am getting error like :global name 'rlike' is not defined Please help me in crossing this hurdle
You want a `filter` not a `withColumn` that adds an extra column. If you want strictly alphabetical : import pyspark.sql.functions as psf df = df.withColumn("isCharString", df.a.rlike("^[a-zA-Z]+$")) If you want to keep strings that don't have numbers df = df.withColumn("isCharString", ~df.a.rlike("[0-9]")) The error you're getting using your function is because you use `rlike`as a standalone function which is not, it is an attribute for class pyspark columns. To rewrite your function in spark: df = df.withColumn("isCharString", psf.when( df.a.rlike("[0-9]")| (df.a == " "), psf.lit("s")).otherwise(df.a))
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "python, hadoop, apache spark, pyspark" }
ColdFusion Facebook Share button with Title using Custom image and description Currently, I use this `anchor` to create a `facebook` share button where I can customize its image, Title and Description. <a target="_blank" href=" [url]=#CGI.SERVER_NAME##CGI.PATH_INFO#?#CGI.QUERY_STRING#p [images][0]=MySiteImage.jpg&amp;p [title]=#PageTitleGoesHere#&amp;p [summary]=My Site Facebook Button Sharer"> <img src="/images/chicklets/FaceBook_Share.png"> </a> How can I get my current Page Title where I can put in the `#PageTitleGoesHere#` value?
Why not make your current page title a variable and then output it both in your URL and tags? <cfset pageTitle = "Your title"> <title>#pageTitle#</title> <a target="_blank" href=" [url]=#CGI.SERVER_NAME##CGI.PATH_INFO#?#CGI.QUERY_STRING#p [images][0]=MySiteImage.jpg&amp;p [title]=#pageTitle#&amp;p [summary]=My Site Facebook Button Sharer"> <img src="/images/chicklets/FaceBook_Share.png"> </a>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "facebook, coldfusion" }
How do effect the same youtube app? **why know how can I develop the same effects?** !enter image description here
Have a look at this control: Sidepanel. It does similar to what you want. Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ios, objective c, xcode" }
Custom domain name of SharePoint 2013 app Let's say our SharePoint 2013 online url is ` Is it possible to add a subsite (like an application under IIS website) that launches a SharePoint app? I created a sample SharePoint 2013 app in Visual Studio and deployed it to SharePoint online, and got a long isolated url like ` I'm wondering if the app can be accessed under the same root domain as shown in the picture below, something like ` If this is not possible, how are users supposed to access the app? Like the developer provides the isolated domain link to the app in a page? And how do I set the master page of the app page to the master page being used on SharePoint online? !enter image description here
**URL** : The App Model depends on the fact that each App has it's own domain. This ensures that Apps are isolated from the host SharePoint site collection and from other Apps. It also helps prevent cross-site scripting. **Link to access App** : Users access an App the way they would access a List or Library, from a link in Site Contents. **Master page** : Even though the have a unique domain name, SharePoint-Hosted Apps are actually just sub-sites of the site where the App was installed. So, the pages in the App automatically uses the master page of its host site collection.
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 0, "tags": "2013, sharepoint online, sharepoint addin, domain" }
Create Windows 10 install USB with Boot Camp Assistant I cannot create a Windows 10 install USB from OSX. I only get Windows 7 as an option in the Bootcamp USB wizard and it fails to boot from the USB when I try it. The ISO is downloaded from Microsoft and I've tried to re-download it. The USB flash drive worked with a Ubuntu LiveUSB created with unetbootin. ![enter image description here]( **Note:** My intent is to install this on a PC, Bootcamp Assistant just seemed to be the easiest way to create the USB key on a Mac.
First, you're not getting an option for Windows 7. You're getting an option for **Windows 7 or Later**. Bootcamp can be used with Windows 8, 8.1, and 10. However with that said, it is not a general utility for making a bootable Windows USB disk. It's for making installing Windows alongside OSX **on a Mac**. Apparently, according to this answer and the subsequent comments and sources, you could do this (use the USB disk on a normal PC) but only for **Windows 7 ISOs**. **My suggestion** to you, since I can't seem to find any utilities for Mac for creating _bootable_ Windows USB drives from ISOs, is to simply install Windows alongside Mac using Bootcamp, then on that install of Windows download the media creation utility and use it to create a proper bootable USB drive.
stackexchange-superuser
{ "answer_score": 1, "question_score": 1, "tags": "windows 10, usb flash drive, iso image, osx el capitan" }
Display table with data in it after product detail Magento 1.9.1.0 I am new to magento. i want to display data in table after product detail. I have created table in database. I can add data from backend/admin panel side. now i want to display this data in product detail page after product. Below is attached image with data that i want to display. !enter image description here
if you are working with user defined module, then in frontend layout xml, you can write code like ... <catalog_product_view> <update handle="content"/> <reference name="content"> <block type="tabledata/tabledata" after="-" name="tabledata" template="tabledata/tabledata.phtml" /> </reference> </catalog_product_view> If not using module, then go to catalog layout and override the layout file, and add the above content's section code. you will need to create a phtml file for template, that 'll show the data. and xml used where to show the data.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, magento, magento 1.9" }
how can i have a text field which have text in it and when the user clicks on the text field the text inside the field vanishes i want to add a text inside a text-field which vanishes when user clicks on the text-field. How can i do it? I am using django-form form.py class CategoriesForm(ModelForm): class Meta: model= Categories model.py class Categories(models.Model): category_name=models.CharField(max_length=200, unique=True) def __unicode__(self): return self.category_name Thank you in advance
You should use `attrs` parameter for form field widget like this: from django.forms import TextInput class CategoriesForm(ModelForm): class Meta: model = Categories widgets = { 'category_name': TextInput(attrs={'placeholder': 'PLACEHOLDER TEXT HERE'}) } Here is documentation
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, html, django, aptana" }
Convert ByteArray to Base64 in Kotlin I am trying to convert a ByteArray to Base64 in a Spring project, written in Kotlin. I have checked existing posts but they didnt help me. Actually I am trying to convert a blob to base, but I converted the blob to byteArray so far and am struggling now to convert the bytearray to base64. This is what I am currently trying: var inByteArray = Base64.encodeBase64(blobAsBytes) //inByteArray : ByteArray! var inByteArrayFormatted = Base64Utils.decode(inByteArray) //inByteArrayFormatted : ByteArray I tried the things from this post How do I convert a byte array to Base64 in Java?, but they are just encoding strings but not directly to Base64. How can I convert a byte array to Base64? Not encoded strings but Base64? Thanks for every help!
If you are using Kotlin with Java, you can use `java.util.Base64` to encode a `ByteArray` into a `String`. I wrote an extension function to do this: fun ByteArray.toBase64(): String = String(Base64.getEncoder().encode(this)) // Use: val b64 = "asdf".toByteArray().toBase64() // YXNkZg==
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 5, "tags": "java, spring, kotlin, base64" }
Blender ignores SHIFT+MMB (panning) after switching to another window? So this is not a major problem, but it is an issue that gets pretty annoying. Whenever I'm using Blender and I need to switch to another window or application on my PC (to pause a video, look something up, send an email, etc), It always ignores me initially whenever I want to `⇧ Shift` \+ `!MMB MMB` (panning). It only ignores the initial keyboard command, and I can pan around my scene just fine after that— but it is still extremely annoying. Is there a fix for this? Or something in the settings to prevent this?
When you go back to blender, the 'active window' is still on the other window so all keyboard commands will go to that one. Which is why it works on the second try(the active Window becomes blender) A good way is to `⎇ Alt` \+ `↹ Tab` to blender instead.
stackexchange-blender
{ "answer_score": 1, "question_score": 0, "tags": "interface, settings" }
How can I install adhoc .ipa build with iTunes because new iTunes version 12.7.0.166 did not have Apps option New iTunes version 12.7.0.166 did not have Apps option as you can see in the attached screenshot of the new iTunes ![enter image description here](
Just install them using Xcode under Window -> Devices and Simulators. Just drag and drop your .ipa over a device you have and that's it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ios, iphone, itunes" }
adding label number to first and last observation I have created the following graph. I would like to annotate the first value and the last value for each of the line created in the graph. The value would be annotated for each line just before the line and at its end How to? data = {'Time':['1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2' , '1', '2'], 'Country':['Italy', 'Italy', 'Italy', 'Italy', 'Italy', 'Italy', 'Italy', 'Italy', 'Russia', 'Russia', 'Russia', 'Russia' , 'Russia', 'Russia', 'Russia', 'Russia'], 'Score':[20, 21, 14, 15, 19, 18, 5, 9, 5, 8, 3, 3, 5, 1, 3, 8]} df = pd.DataFrame(data) sns.lineplot(x="Time", y="Score", hue="Country", data=df)
Without more details on what you exactly want you can use the axes object returned by `sns.lineplot` and then use the `text` method of the axes object. In the following I calculate the mean 'Score' for each country at 'Time' = 1 and then then add this as text to the graph. You can customise this as needed: ax = sns.lineplot(x="Time", y="Score", hue="Country", data=df) means = df.groupby(['Country','Time']).mean() times = ['1', '2'] x_positions = [0.02, 0.9] for country in df['Country'].unique(): for time, xpos in zip(times, x_positions): mean = means.loc[(country, time)].values ax.text(xpos, mean-1.1, mean[0]) ![example_text_to_axis](
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, pandas, matplotlib, seaborn" }
JQuery UI datepicker not sitting over dropdowns in IE 6 For some reason our datepicker is falling behind the dropdowns below it in IE6 www.senegal.co.uk Every search I have done seems to suggest the datepicker should deal with this. We do have the following css in place: .ui-datepicker-cover { display: none; /*sorry for IE5*/ display/**/: block; /*sorry for IE5*/ position: absolute; /*must have*/ z-index: -1; /*must have*/ filter: mask(); /*must have*/ top: -4px; /*must have*/ left: -4px; /*must have*/ width: 200px; /*must have*/ height: 200px; /*must have*/ } I have tried adding bgiframe and calling: > $("#ui-datepicker-div").bgIframe(); But it doesn't solve the issue. Any ideas? I'm thinking we're going to need someone with experience using jquery ui datepicker to help us out on this one!
Couldn't find a solution to this in time, so in the end just put in some code to hide the dropdowns beforeShow: function() { $('.searchPanelGroup6').css('visibility', 'hidden'); }, onClose: function() { $('.searchPanelGroup6').css('visibility', 'visible'); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, internet explorer 6, datepicker, drop down menu" }
real part of analytic function Assume $f(x) \in D$ is analytic, where $x \in R$ and $D$ denotes the unit circle, which means $x$ is real and $f(x)$ is complex. Then what kind of function is the real part of $f(x)$? harmonic or analytic or...? Can Ref(x) be extended to a analytic function g(Z) on the strip |Im z|< c, for some constant c?
Clearly $Re(f)$ is not analytic if $f$ is nonzero. To show this you can just show that it cannot admit a derivative : for any $z \in D$, $h \in \mathbb{C}$, suppose f is analytic, then $$Re(f)'(z) = \text{lim } \, \frac{Re(f(z + h) - f(z))}{h}$$ But then by setting $h1 = \epsilon$ and $h2 = i \epsilon$ and letting $\epsilon \rightarrow 0$, we get, since then numerator is real, that the limit must be both real and imaginary, thus zero. However, it is indeed harmonic. Indeed, $f$ being holomorphic, it satisfies the Cauchy-Riemann equations, ie. $$(\frac{\partial}{\partial y} - i\frac{\partial}{\partial x}) f = 0$$ Applying $(\frac{\partial}{\partial y} + i\frac{\partial}{\partial x})$ to the above, we get that $\Delta Re(f) + i \Delta Im(f) = 0$, so both the real imaginary parts are harmonic.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "analyticity, analytic functions, analytic continuation" }
calling gawk from an R script Hi i am using R on windows XP i have cygwin on my shell path what i want to do is send a command to gawk via R shell command this way: shell("gawk "{print $1}"", m[1],"_", h[i]."_79.7.dat""} i get this error Error: unexpected '{' in "shell("gawk "{" how can i fix this problem? Thank you
escape your quotes. Example only (not sure what R shell syntax is) shell("gawk \"{print $1}\"", m[1],"_", h[i]."_79.7.dat"") experiment with escaping the quotes to get the correct result. The other way is to build your gawk command string first , then pass to `shell()`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "unix, shell, r, cmd, gawk" }
404 page if submitting an edit suggestion to a post that already has one If in the course of writing an edit suggestion another user submits a suggestion on the same post first, submitting your suggestion leads to a 404 page. As does going back to the edit page, because `/posts/#/edit` returns a 404 if you don't have edit rights and suggesting an edit is blocked for whatever reason. `/posts/#/edit-submit` (and probably `/edit` too) should say something like "You can't suggest an edit because another edit is already in the queue/the queue is full/etc."
I changed this so it displays a text message: "There is a pending suggested edit in the queue, try again in a few minutes."
stackexchange-meta
{ "answer_score": 5, "question_score": 15, "tags": "bug, status completed, suggested edits, 404 not found, 500 server error" }
Oracle Regexp_replace string Let's say I have the following string: > > notNull(devhx_8_other2_name_2) AND notNull(devhx_8_other2_amt) > How can I use `regexp_replace` to change it to: > > (devhx_8_other2_name_2) is not null AND (devhx_8_other2_amt) is not null >
Use regexp_replace(col, 'notNull(\([^)]+\))', '\1 is not null', 1, 0) This looks for 'notNull' followed immediately by an opening parenthesis, other characters and a closing parenthesis. It replaces this with the string including the parentheses, but without 'notNull' and appends 'is not null'.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, regex, oracle, regexp replace" }
GA: Unique visitors of two websites I have two websites (different domains) and I want to know how many unique users are visiting both sites. The best result would be: number of unique visitors * on website A * on website B * on website A and B The websites have their own GA tracking ID. Do I have to implement the cross domain tracking?
Yes cross domain tracking is made for exactly the same purpose. <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "google analytics, analytics" }
How to copy the permissions of a file to another? Say I have two files: -rw-rw-r-- 1 webapp webapp 215 Jun 21 2012 index.php -rw-rw-rw- 1 root root 58 Dec 17 11:02 patch.log I would like to give `patch.log` the same permissions as `index.php`. I can do it manually: chown webapp:webapp patch.log chmod 664 patch.log But this should be part of a script, where I don't necessarily know what the exact permissions of `index.php` are. **Is there a way to copy permissions of a given file to another file?**
You can use a file as a reference file for both chown and chmod chown --reference=index.php patch.log chmod --reference=index.php patch.log It's all in the man pages btw chown > \--reference=RFILE use RFILE’s owner and group rather than specifying OWNER:GROUP values chmod > \--reference=RFILE use RFILE’s mode instead of MODE values
stackexchange-serverfault
{ "answer_score": 12, "question_score": 5, "tags": "linux, file permissions" }
Does updating VkGraphicsPipelineCreateInfo after the pipeline creation affect the currently rendering scene? I'm currently working on a graphics engine and I wish to update the pipeline state at runtime. Creating a new pipeline for each single resource update (ie: enabling depth clamp, enabling color blend) at runtime and then re-binding everything to the command buffer takes up a considerable amount of performance. So what I planned on doing was, to create a single pipeline and store all the attributes needed for its creation (ie: Rasterizer state, Multisampling state, Color blend state, etc..) and update those individual structs at runtime. After all we are passing in the address of the structs, not by value. This brings me to my question, does the updates to a struct which is passed on in the pipeline creation, reflect on the actual draw call at runtime, without the need for recreating the pipeline again? Thank you!
No, this does not work that way. The structures that specify pipeline creation state information (like blending, multi sampling, vertex input state, etc.) are consumed at pipeline creation time and baked into the pipeline. So changing these after the pipeline has been created, won't update the pipeline at all. This means that you have to rebuild the pipeline and also rebuild all command buffers using this. One exception though are the dynamic states (see spec) that allow you to change certain pipeline state related values at runtime during command buffer creation.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c++, vulkan" }
Query database using result from previous query and combining them I am using dynamic sql, to query the database: DECLARE @VALUE VARCHAR(5000); SET @VALUE = '123' DECLARE @SQL5 NVARCHAR(MAX) = 'Select distinct item_id, attr_val from [dbo].[CONTRACT_ATTR] WHERE [ATTR_VAL] LIKE ''%@VALUE%'' AND [FIELD_ID] = 413 ORDER BY [attr_val]'; SET @SQL5 = replace(@SQL5, '@VALUE', @VALUE); EXEC SP_executesql @SQL5; These are the results: ![enter image description here]( I am trying to take the resulting (item_id) and run another select query. Something like this: UNION Select Column3 From @SQL5 where other_column = 1234 The results would be 3 columns for each row returned, the 2 original and the new one found in the 2nd select. What am I doing wrong and how do I fix it?
Here is an answer without dynamic SQL: DECLARE @VALUE VARCHAR(100) SET @VALUE = '123' SELECT myuser.item_id, myuser.attr_val, parent.attr_val FROM [dbo].[CONTRACT_ATTR] AS myuser JOIN [dbo].[CONTRACT_ATTR] AS parent ON parent.item_id = myuser.item_id AND myuser.item_id = parent.item_id WHERE myuser.field_id = 239 and parent.[ATTR_VAL] LIKE '%' + @VALUE + '%' I also moved join conditions wholly into the `on` clause.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, sql server" }
How to Display Array Values using Nested For loops? Before we begin, i am new at programming and C# language, So please bear with me. The problem i am having is to display two individual array values in front of each other like this : Integer Type : sbyte, byte, short, ushort Real Floating point types : float, double The Code I have tried is : string[] VariableTypes = { "Integer Type", "Real Floating Point Types" }; string[] IntergerTypes = { "sbyte", "byte", "short", "ushort" }; for (int i = 0; i <= VariableTypes.Length - 1; i++) { for(int j=0; j<=IntergerTypes.Length - 1; j++) { Console.Write(IntergerTypes[j] + " "); } Console.WriteLine(VariableTypes[i] + " : "); } Output i am getting : sbyte byte short ushort Integer Type : sbyte byte short ushort Real Floating Point Types :
string[] VariableTypes = { "Integer Type", "Real Floating Point Types" }; string[][] NumberTypes = { new string[] { "sbyte", "byte", "short", "ushort" }, new string[] { "float", "double" } }; for (int i = 0; i < VariableTypes.Length; i++) { Console.Write(VariableTypes[i] + " : "); for(int j = 0; j < NumberTypes[i].Length; j++) { Console.Write(NumberTypes[i][j] + " "); } Console.WriteLine(); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, arrays, loops, nested" }
How to merge dicts in list of dicts with similar keys I have a list of dicts like this: list_of_dicts = [ {"id": 1, "color_positive": "green"}, {"id": 1, "color_negative": "red"}, {"id": 2, "color_positive": "blue"}, {"id": 2, "color_negative": "yellow"}, ] And I want to make: [ {"id": 1, "color_positive": "green", "color_negative": "red"}, {"id": 2, "color_positive": "blue", "color_negative": "yellow"}, ] Are there any ways?
You can use **`defaultdict`** for this. from collections import defaultdict result = defaultdict(dict) for item in list_of_dicts: result[item["id"]].update(**item) result = list(result.values()) print(result) **Output:** [{'id': 1, 'color_positive': 'green', 'color_negative': 'red'}, {'id': 2, 'color_positive': 'blue', 'color_negative': 'yellow'}]
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python" }
How Angular get parameter name? I just started to learn Angular, and I found this code below: var app = angular.module('myApp', []); app.controller('siteCtrl', function($scope, $http) { $http({ method: 'GET', url: ' }).then(function successCallback(response) { $scope.names = response.data.sites; }, function errorCallback(response) { }); }); Now this has been a bit of problem, since if I change the signature of the function in the second parameter of `app.controller` to `function($scope, myHttp)`. It failed to work properly. But why?? Does the parameter name of `$http` matter? Doesn't it just a symbol that I can replace freely?
As it turn out, this is some technology called `Dependency Injection`. And Angular turn `function($scope, $http)` into a string and use regex to match its parameter name. Which in this case is `$scope` and `$http` And then search in Angular's internal cache to determine wether or not Angular hold the instance of an object named `$scope` and `$http` So the parameter name can't be change freely
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, angular" }
Can't a website/server owner read the passwords out before hashing? I just read many articles about hashing and that client-side hashing is not necessary when using SSL. So I have a website where I hash passwords with bcrypt i.e. salting. But I can just read out the passwords plain-text before hashing. (In my case just: `console.log(req.body.password`) How I can prevent this?
The problem is, why would you. You are the site owner and responsible for such actions. Of course you can just add such lines to your code and receive all the information and no, there is no way to prevent it. On every site you register, the clear-text password will always be passed to the code at some point. People do fix such trust issues, by using a password manager, which randomly generates a good password.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "security, hash, passwords, bcrypt" }
Combobox value null on first launch When my app launches I get null on first launch from combobox, but when I change it I get the right result on launch public partial class MainScreen : Page { SQLReader sql; public MainScreen() { InitializeComponent(); sql = new SQLReader(); List<string> st = sql.getQuery("SELECT Name FROM Positions"); PrCombo.ItemsSource = st; PrCombo.SelectedIndex = 0; } private void PrCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { string st = PrCombo.Text; //is null when the app starts } }
Try access to selected item except of combobox text. string st = PrCombo.SelectedItem.ToString();
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, wpf, combobox" }
Fill a large gap I would like to know how to fill a large gap between wood and cement. I have attached some pictures. This is outside on the front covered entry. I am going to try and fill the gap so that rain water does not seep through the gap. Two long boards are nailed to the beams that support the roof over the entry. They are above the cement walk. There is an uneven gap between the boards and the cement. I was going to put closed cell backer rod in the gap and then caulk it with Sika Self-Leveling Sealant which was suggested by an employer at Lowe's. My problem is, what kind of material can I use to make a form so that the sealant doesn't run all over the place on each side of the boards as I am applying it? Thank you so much. Billie![Gap between boards and cement]( ![Another angle](
DMoore is right, if you have a grading problem you should get that fixed if you can afford it. That said, in your other comment you mention that its just water blowing in? If the water drains toward the wood normally and you only flood because of wind blowing it in, I would definitely not plug the gap. Get a piece of plastic trim and screw it to the outside of the wood. Cut out a few notches for drainage.
stackexchange-diy
{ "answer_score": 0, "question_score": 0, "tags": "gap" }
Visually mapping mysql database schema I need to visually understand the database schema of an open source erp software (Dolibarr), for that have found a java based tool dbschemaviewer which make use of eclipse and GEF to map out an existing database. I let it do the process overnight but no results I need some other software that can map existing database schema visually and that shows connections, and allow me to edit it too once i have studied its connections i am currently using wampserver 2 on which i have installed the erp software any solutions, ideas or software that i can use to map the schema? Please help, Renee
You could try the MySQLWorkbench tool from MySQL. It has been a Windows only for for a while but there are now Alpha releases for Linux and MacOS. I haven't used these Alpha versions so I don't know how stable they are. There are free and pay-for versions, but the free version does allow you to create an ERD from a SQL script.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 9, "tags": "database design" }
How to partially change condition value in dataframe I have a data frame with updown and step columns. If the value of the updown column is "DOWN" I want to add "-" before the value of the step column. The current state is df["updown"][0] = "DOWN" df["step"][0] = "18" after df["updown"][0] = "DOWN" df["step"][0] = "-18" Is there any way? I tried this method but it failed df.loc[df["updown"]=="DOWN"] = df["step"].apply(lambda x: "-" + x)
df1['step']=np.where(df1['updown'].str.contains(r'\DOWN\b'),'-'+df1['step'],df1['step'])
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, pandas" }
How to set a password security limit in Postgresql? In Oracle we can set a password limit like this: create Profile security_pass Limit failed_login_attempts 5 password_lock_time 1 password_life_time 90 password_grace_time 3 password_reuse_max 5 password_reuse_time 365 password_verify_function func_pwd_vfy; But can we do the same in PostgreSQL? I can't find anything about it. Thanks for reading me.
There is a module with the name "passwordcheck" in Additional Supplied Modules. Have a look at the following link: < It will work just like PASSWORD_VERIFY_FUNCTION of Oracle. Using this module you can write your own function for password verification. Disclaimer: I worked for EnterpriseDB.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "database, oracle, postgresql, passwords, plpgsql" }
Remove "Set as desktop background" from Windows context menu When I right click an image file in Windows, one of the context menu options is "Set as desktop background". I know some entries can be hidden with registry edits, so I'd like to know if it's possible to remove the "Set as background" option. Note that while most context menu entries can be found under `HKEY_CLASSES_ROOT\`, the "set as background" option seems to be located somewhere else.
While it's possible to remove the "Set as desktop background" option by editing the registry manually, it's much easier to do using ShellMenuView. Simply run the program, search for the Menu Key `setdesktopwallpaper`, and right click each entry to disable them. ![Disabling "set desktop background" with ShellMenuView]( If you _do_ want to try manually editing the key with Regedit, it should be listed as `HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.‌​png\Shell\setdesktop‌​wallpaper`. Be warned that removing this key may disable the ability to change your wallpaper altogether. Source: The How-To Geek
stackexchange-superuser
{ "answer_score": 7, "question_score": 9, "tags": "windows, context menu" }
Remove symbols from text with field calculator I'm attempting to remove € symbols from values in the attributes of a geopackage. For example, I have a value 240 123€ that I want to turn into 240 123. I'm using the field calculator to do this. So far here's what I have written down. `regexp_replace("myfield",'(^.*[0-9]+)','\\1')` This gives the same results as `regexp_replace("myfield",'([0-9]+)','\\1')` Both of these result in 240 123€.
Try this instead: `replace("field_name", '€', '')`
stackexchange-gis
{ "answer_score": 7, "question_score": 2, "tags": "qgis, field calculator, attribute table, regex" }
Unrecognised XML Characters when parsing in Classic ASP Hey I am having issues parsing XML file, Theres seems an unrecognised symbol after each new line. When im parsing this is Classic ASP and print out to screen it is appearing as "?" but when i do I.e replace(text,"?","LOL") its not replacing so its not a normal "?" I think. How can I capture and filter out this symbol ? Note this is done in classic ASP
Sounds to me like the document encoding isn't perhaps what you expect it to be. Does the XML file have an encoding defined? Check out this for more info on encoding: Internationalization and Classic ASP
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "xml, parsing, asp classic" }
Logging errors with Elmah and nHibernate I'm working on an Asp.Net MVC3 application and we are looking at using Elmah to do our data logging. We are using fluent nHibernate to handle all interaction with mainframe DB2 database. So any other DB provider, is not an option. I've been doing some research on this topic and cannot find any information on how to do it. Would rewriting one of Elmah DB providers to handle interfacing be appropriate? I'm looking for some guidance on how to start this or where to look for the guidance.
I agree with the commenters on your question. Use log4net instead of ELMAH if at all possible. NHibernate requires log4net, so it will already be present. In addition to error logging, you can log copious NHibernate stuff (in particular the SQL statements it generates), which I find very useful while building and debugging an application. With log4net you can send log messages to an Oracle database with the AdoNetAppender.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "asp.net mvc 3, nhibernate, logging, elmah" }
singular locus of semi-normal variety Let X be a seminormal variety and S be the singular locus of X. Is Blow$_S X=$ the normalisation of X? Is the singular locus given by the conductor ideal?
First, definitely the singular locus is not equal to the conductor. If $X$ is normal, the singular locus of $X$ is definitely not given by the conductor (which is the unit ideal and doesn't vanish anywhere). For the first question however, Greco-Traverso actually studied blowing up the _conductor_ in a seminormal variety $X$. For example, they showed the following. **Theorem** _Suppose $X$ is an S2 seminormal scheme and $B$ is the conductor. If the normalization of $X$ is factorial (for example regular), then the normalization is equal to the blowup of the conductor._ See section 7 of Greco-Traverso's _On seminormal schemes_ for this and some slightly more general results. They also have some references to some other papers where blowing up the conductor is considered, for example Wilson, _On blowing up conductor ideals_
stackexchange-mathoverflow_net_7z
{ "answer_score": 3, "question_score": 1, "tags": "ag.algebraic geometry, reference request, ac.commutative algebra" }
AES encrypt not working in php below code runs in PHP it will returns empty string. But same query run in mysql it shows some values. <?php $encrypt_query = "select aes_encrypt('$string','$key') as encrypt_data"; $encrypt_result = mysql_query($encrypt_query); print_r($encrypt_result);// it returns resource id #7 $row = mysql_fetch_array($encrypt_result); return $row['encrypt_data'];//it return empty ?>
Try <?php $encrypt_query = "select aes_encrypt('$string','$key') as encrypt_data"; $encrypt_result = mysql_query($encrypt_query); print_r($encrypt_result);// it returns resource id #7 while($row = mysql_fetch_array($encrypt_result)){ echo $row['encrypt_data']; } ?> //Or $row = mysql_fetch_row($encrypt_result); echo $row[0];
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php" }
Where is "in honoring" or "to honor" more appropriate as an idiom? > The practice of renaming a street Martin Luther King Boulevard has been adopted by many cities **in honoring/to honor** the civil rights leader. Please give explanation.
I think it's usually either "to honor" or "in honor _of_ " (and not "in honoring"). > Please give explanation Just because that's what's idiomatic, I guess. Maybe "to honor" implies something more timeless (even eternal), or a "perfect" tense, whereas "honoring" would imply a present continuous.
stackexchange-english
{ "answer_score": 2, "question_score": 1, "tags": "grammar" }
Filter for Spectrum Analyzer I want to build a data acquisition device to collect electromagnetic interference signatures of household appliances on the home electrical network (power line). In fact I hope to harvest datasets similar to the ones presented in this competition. I want to build a power line interface like this one described in the paper titled _"An In Depth Study into Using EMI Signatures for Appliance Identification"_. Now I seemed to have stumbled right at the start: I live in Belgium and unlike other parts of the world we have no Neutral in the mains network (single phase): we have two phases and we have 220V between the two. How should I modify this wiring diagram so that there is a high pass filter on both of the phases and make sure I don't fry the spectrum analyzer?
Buying a mains isolation transformer is definitely one of the first things you should get when doing this type of testing. My though would be that you could measure the spectral density by measuring the total harmonic distortion (THD) of the current. This will give you spectral content where you want to see all the content mains frequency (ideal situation). All about circuits has a decent enough article to get you thinking about these topics. < You could use a current transformer for mains current measurements, rectify the signal, and then do some digital signal processing (fast fourier transform) to get the harmonic content. This approach would keep your controller isolated from main since you'd be using a current transformer.
stackexchange-electronics
{ "answer_score": 2, "question_score": 1, "tags": "spectrum analyzer, high pass filter, power line communication" }
Installation Requirements to Setup PCF on a Local Server Do you have recommendations to where can I read a good reference on what are the hardware and software requirements, as well as installation procedures of Pivotal Cloud Foundry(not the PCF dev) on a local server?
Links below will get you started. For PCF on vSphere < For PCF on Azure < For PCF on AWS < For PCF on GCP < Installing PCF depends on lot of factors. But this is good for an out of the box installation.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "cloud foundry" }
innerHTML not showing html from database I have an issue where I have an iframe masking a textarea almost like a WYSIWYG scenario. So its all well and good and posts html into the database field. But when I call it back in to the iframe from the databse it does not show? Are there limiters on putting in html into the iframe? <script> var iframe = document.getElementById('editor'), iframedoc = iframe.contentDocument || iframe.contentWindow.document; iframedoc.body.innerHTML ="<?php echo ($row[2]); ?>"; // Here is how I retrieve the table content - but does not display inside of the iframe. </script> If I change it to `innerText` it will just spit out raw html as plain text.
You need to use an escape function whenever you move data from one language to another. If you move data from PHP to JavaScript you can use `json_encode`: iframedoc.body.innerHTML = <?php echo json_encode($row[2]); ?>; Imagine if the string is `"; document.location.href="hxxp://naughty.hackers.xxx";"` you're gonna have a problem if you don't escape it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, html" }
Prove if $F \subset E$ is a finite dimensional field extension then $\operatorname{Gal}(E/F)$ is finite My idea is that since $F \subset E$ is finite dimensional then the set of roots (call it $R$) of $E$ is finite so $\operatorname{Sym}(R)$ is finite and since the Galois group can be embedded in the symmetric group, $\operatorname{Gal}(E/F)$ must be finite, but I'm struggling with the details.
A Galois automorphism is determined by its restriction on the basis since it is linear. If $(e_1,...,e_n)$ is a basis, the image of $e_I$ is an element of the set $S_i$ of root of its minimal polynomial. Let So the number of Galois automorphisms is finite since it has the cardinality of a subset of $S_1\times...\times S_n$.
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "abstract algebra" }
Retrieving values form a nested list I have a list b which contains the values (0,3,[(1,0),(0,-1)]) How would I go about iterating through this list so i can get the values from both the outer list and the tuples? My current idea would be to make a variable equal to b[0] and b[1] as this will not expand and it will only hold 2 values. The list of tuples however, can expand so how would i go through the list to get the tuples?. Thanks for the help.
You can do it by defining a custom method: b = (0, 3, [(1,0),(0,-1)]) def print_list(l): for i in l: if isinstance(i, list) or isinstance(i, tuple): print_list(i) else: print i >>> print_list(b) 0 3 1 0 0 -1
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, list" }
How to get return (status) value of an external command in Vim I want to get the exit value (returned by `$?` on a shell; usually 0 or 1 for success or failure) of a external shell command in Vim. Note that I want to get its standard output too. So I can use the output and the also the exit value in a Vim conditional expression. Is this possible?
There is `v:shell_error` variable that has exactly the same value as `$?` in shell scripts. Works at least after `:!`, `:read !`, calling `system()`.
stackexchange-stackoverflow
{ "answer_score": 37, "question_score": 21, "tags": "linux, shell, vim" }
How to get the array of RGB values for each pixel of the client area of a window Is there a way to receive the colour values for each pixel in the client area of a window, with gdi?
As noted in comment by @JerryCoffin. Here's a simple example hDC = GetDC(hwnd); hBitmap = CreateCompatibleBitmap(hDC, width, height); hMemDC = CreateCompatibleDC(hDC); hOld = SelectObject(hMemDC, hBitmap); BitBlt(hMemDC, 0, 0, width, height, hDC, x, y, SRCCOPY); // Clean up DeleteDC(hMemDC); ReleaseDC(hwnd, hDC); You should have a bitmap object selected into memory DC for which you can use GetPixel GDI function and then you can also extract the color values using `GetRValue()` , `GetGValue()` , and `GetBValue()` macros.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "c++, winapi, gdi, pixel" }
Doctrine update php models according to db I need to maintain a symfony 1.4 app , the app uses doctrine (1.2 I guess). The problem is that people modified the databse without using doctrine. To fix this i tried to update the doctrine models this way: symfony doctrine:build-schema symfony doctrine:build-model Both does not show any errors but when I access the website everything fails due to db problems. I got errors like 'unknown aliases'
following sriniwas advice everything went well , i guess ORM are not meant to do everything :(
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, symfony 1.4, doctrine 1.2" }
how to create android popup window? I am trying to create a popup/floating window in my app. like the android app switcher when you long press the home key. It doesnt really count as an activity. How can this be done? Thanks!
Hello please search before asking go here nice tuto <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "android, popup, window, floating" }
Django profile page for every user I'm trying to show a page for every user in my app. I have these lines in views.py: from django.contrib.auth.models import * def profiler(request, username): k = get_object_or_404(User, username=username) return render_to_response("profil.html", locals(), context_instance=RequestContext(request)) urls.py: url(r'^people/(?P<username>\d+)/$', profiler, name = "profiler"), but it says page not found when I go to /people/m which should be a page for my user 'm'. How can I make this work? Thanks.
`\d+` matches digits only. You want `\w+` to match alphanumeric characters, or perhaps even `[\w_-]` to match underscores and dashes as well.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "django, django views" }
Is it possible to restore files accidentally removed after `git add`? After adding all my changes using `git add --all`, I accidentally deleted files of more than one depth with `mv -f app/* members && rm -rf app` (instead of using `cp -rf app members`). When I run `git status`, it tells me: deleted: app/more/than/one/depth/file.php ... Is it possible to get those files back from the Git cache?
Trivially, yes. git checkout -- app ...will restore everything in the tree.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "git" }
How to use images in Angular2 with Webpack Application was created in Angular2 RC5. In RC5 (without webpack) everything worked fine. Images appeared as expected. After upgrading to the final release of Angular 2.0.0 along with Webpack, images in my public folder no longer work anywhere in the application. Upgrade was done by creating a new fresh install of Angular2 with Webpack using the Angular CLI. 404 (Not Found) The same exact path works fine in RC5. What has to be done to be able to see images in the /public/images folder (Where they worked in RC5), or where should images be placed? In my template I am calling the images with: <img class="img-responsive" [src]="asset.thumb_local_path" >
After some more searching, It seems that the image folder MUST be placed within either the src folder or the assets folder. This wasn't the case in RC5. Once I moved all of my images/videos/etc to the /assets folder I was now able to see them in the browser.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "image, angular, webpack" }
How to connect to a third party VPN from Google Cloud Platform? **Requirements** 1. I am trying to connect to a third party VPN from my back end on Google Cloud Platform. 2. Since my IP has to be whitelisted by the third party, the source IP for all requests must be a single static IP address. **My plan so far...** Currently I plan to run a Kubernetes service that runs as a "proxy", such that the service is connected to the VPN and the rest of my back end can send requests to the proxy. Requests from my back end to the proxy service should obviously not run via the VPN, but requests from the proxy service to the third party should run on the VPN. **The challenge** I know how to reserve an IP address, but I don't even know where to begin to set up a VPN client. Any help would be greatly appreciated!
The VPN Interoperability Guides documentation offered by Google is a great place to start exploring the VPN connectivity with third party solutions. The main idea is to make sure that your networks and subnets from each side of the VPN do not overlap. For instance, if you use 10.0.1.0/24 for your Kubernetes deployment, you cannot have the same 10.0.1.0/24 range on the remote side as well. Once you have decided on the ranges to you use, you can set up the VPN. You can follow this how-to for more in-depth explanation on the parameters required. Also make sure you review and modify the corresponding rules in the Firewall in both networks for the traffic to be allowed.
stackexchange-serverfault
{ "answer_score": 4, "question_score": 2, "tags": "security, vpn, google cloud platform, kubernetes, google kubernetes engine" }
Insert query in nodejs I want to insert the value in this way any help me out this code. It doesn't work for me . Error occurred as unknown column 'Fname1' in field list app.post('/insert',function (req,res){ var Fname1=req.body.fname; var Passwor1=req.body.pwd; var sql="insert into test(Fname,Passwor) values(Fname1,Passwor1)"; con.query(sql,function(err,rows){ if(err) throw err; res.send("Value has been inserted"); }) }) I don't want to insert in this way. var data = { Fname:req.body.fname, Passwor:req.body.pwd }; con.query("insert into test set ?",[data], function (err,rows){ if(err) throw err; res.send("Value has been inserted"); })
Try this as your `sql` emit the Fname1 and Passwor1 as variables; app.post('/insert',function (req,res){ var Fname1=req.body.fname; var Passwor1=req.body.pwd; var sql= "insert into test(Fname,Passwor) values ('"+Fname1+"', '"+Passwor1+"')"; con.query(sql,function(err,rows){ if(err) throw err; res.send("Value has been inserted"); }) })
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mysql, node.js, express" }
Does CDN and Bandwidth in Azure are the same? I just like to confirm if CDN and Bandwidth in Azure are the same? Many Thanks.
No. CDN and Bandwidth are entirely different concepts. CDN stands for Content Delivery Network which allows you to serve your blob storage contents from a server closest to your application user. More about CDN here: < Bandwidth is the amount of data transferred (usually in bytes).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "azure" }
"Hit", "Strike" or "Beat" After searching many dictionaries and reading some articles, still I'n not able to tell these three worda apart so that I could fill in the blank below! Please have a look on the following sentences and let me know which choice is more suitable for each blank: > 1 - During the competition, my rival.............hard my leg with his stick! > 2 - During the competition, my rival ............ his stick to my leg! a) hit b) beat c) struck
1. The past tense of _beat_ is _beat_ , not _beated_. 2. Your first sentence is unidiomatic, because the adverb _hard_ does not normally come between the verb and its object. 3. All three will do in your first sentence (though the meaning varies slightly), and none of them will do in your second sentence. 4. Using _beat_ in your first sentence implies that the rival hit your leg repeatedly. _Hit_ and _struck_ do not imply that (though they do not exclude the possibility). The only difference I can find betwen _hit_ and _struck_ here is that _struck_ is more formal: people wouldn't say it in ordinary speech.
stackexchange-ell
{ "answer_score": 1, "question_score": 0, "tags": "word usage, word choice, word meaning, verbs, word difference" }
Complement of list comprehension in python I'm wondering if there is not a way to compute the complement of a list comprehension in Python. Something like: evens = [i in range(10) if i % 2 == 0] odds = [i in range(10) if i % 2 != 0] is there a way to get both evens and odds in one call? For a very large list, or a more expensive if statement, I think this would save a lot of time.
I believe this question has been asked before, but I am not finding the link currently. If you are trying to get more than one predicate and you **only want to iterate once** over the original generator, then you will have to use a simple `for` loop. evens = [] odds = [] for i in xrange(10): if i % 2 == 0: evens.append(i) else: odds.append(i) As @dawg pointed out, the logic inside the loop can be made more concise using clever indexing. for i in xrange(10): (evens,odds)[i%2].append(i)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "python, list comprehension" }
My Perl split function is returning individual numbers and characters. How can I fix this? I've got a character string that looks like this: `803|804` and `7|7` This is my PERL code: `my @vpid = split /|/, $vpid; my @quantity = split('|', $quantity);` My results are: `8 0 3 | 8 0 4` and `7 | 7`. The results I'm looking for are `803 804` and `7 7` as the content of the arrays. Why is this happening and how can I fix it?
`|` is a regex special character denoting "or". You must escape it. my @vpid = split /\|/, '803|804'; my @quantity = split '\|', '7|7'; use Data::Dump; dd @vpid; dd @quantity; Outputs: (803, 804) (7, 7)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "arrays, perl, split" }
I am struck in a problem and need help in finding monotonicity of sequence I have done few steps while finding the monotonicity of sequence .My work is in attachment.kindly helpimage contains the question and the step I applied
You have two opportunities to know. You can divide $\frac{a_n}{a_{n+1}}$ if you get something, that less than 1, then the sequence is decreasing ( if greater than 1, then increasing) or you can subract $a_n-a_{n+1}$ if you get something negative, then the sequence is decreasing (if something positiv, then increasing)
stackexchange-math
{ "answer_score": 0, "question_score": -2, "tags": "sequences and series" }
How to get a \mid binary relation that grows This question relates to one about getting a vertical bar longer than `\mid`. How to get a vertical bar which is longer than \mid ? However while the given `\middle|` solution works for me, it no longer behaves as a binary relation and so loses the space to the left-and-right of it that `\mid` puts in. (I know I could manually add space, but I want the _right_ way to do this.) In fact I want a "growable `\mid`" that works like `\left\{` and its relatives.
If you want to get `\middle|` to behave exactly as `\mid` on all accounts (spacing, stacking in the form `\mid\mid`, etc.), you need to use `\mathrel{}` on both sides of `\middle|` (manual spaces like \; won't do the job correctly in all situations): \newcommand{\relmiddle}[1]{\mathrel{}\middle#1\mathrel{}} Here's a code that compares `\mid` and the new command `\relmiddle` on two different formulas and shows that the spacing is identical: !alt text \documentclass{article} \newcommand{\relmiddle}[1]{\mathrel{}\middle#1\mathrel{}} \begin{document} \nulldelimiterspace=0pt% to kill the little space before \left and after \right (not a good idea in a real document) $a \mid -b$\par $\left. a \relmiddle| -b \right.$ $a \mid\mid -b$\par $\left. a \relmiddle|\relmiddle| -b \right.$ \end{document}
stackexchange-tex
{ "answer_score": 21, "question_score": 29, "tags": "math mode, symbols" }
How do determine key presses in C++ I am working on a CHIP-8 emulator to be used on a Linux system. As I understand it, I need to get keyboard input from (any) 16 keys and map these to a hex keypad. Once I get the inputs, I have no trouble mapping them to the 16 CHIP-8 keys. However, I cannot figure out how to actually tell if a key is pressed. I believe in Java I would use keylistener, but I cannot find anything analogous for Linux in C++. Is there a way I can tell what (if any) specific keys are pressed at any given time? Something like a getKeyState function I could call? Thanks in advance.
There is this tutorial on `ncurses`. NCURSES Programming HOWTO. I have confirmed that on my MacBook Pro, Mavericks 10.9.1, with the Xcode Command Line Tools installation, that the `ncurses.h` is a symbolic link to `curses.h`, both located in `/usr/include`. This is the NCURSES Introduction page. I have not created a specific class myself. However, some searching on `/dev/input/eventX`, where X seems to be either a zero or one finds these two separate posts:Read from /dev/input and linux keypress events.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c++, linux, keyboard, emulation, keylistener" }
Prevent a page from fully loading in codeigniter I have separate views for my navbar (I'm using materialize), home, etc. This is what my navbar looks like ![enter image description here]( It has tabs. When I click a another tab, a method in my controller does this $this->load->view('navbar'); $this->load->view('payables'); However, it reloads my whole navbar which prevents my jquery to fulfill it's duty to change the active tab, the page loads but the tab that is selected is still 'HOME'. How can I prevent my navbar from reloading and load another page at the same time using `$this->load->view()`. I researched that there is something called `ng-route` and `ng-view` in Angular JS that will accomplish this. Is there a counterpart in codeigniter?
If you click in a tab and you "load a method", it means you're launching a whole HTTP request, and you will reload the full page. To avoid that, you'll need to do it asynchronously. You'll need to create an AJAX request, to load only the part you want. In your view, you'll have to code the JS request that launches a call to the server to render only the part you want to show. When the server answers, your JS will have to allocate that into the page.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, jquery, angularjs, codeigniter, materialize" }
Flex 4 - Add component to title bar of Spark Panel or Spark TitleWindow I'm looking to add a couple of buttons to the title bar of a Spark Panel or Spark TitleWindow. Is this possible to do without making the panel from scratch?
I've done this in the past by creating a custom Panel or TitleWindow skin that adds the additional buttons. You would then extend the Panel/TitleWindow class and add your buttons as skin parts. That way you can attach listeners, set icons, etc via your custom Panel/TitleWindow. Here's a similar question/answer that adds an icon to a title bar: Adding an image on the right side of the title bar of a panel in flex 4 And an example that uses ActionScript rather than skins: ActionScript example Hope that helps.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "apache flex, flex4, components" }
PDE Tools (Create Ant build file) not generating ant script(build.xml) I have created one plugin project "com.example.first" and one plugin feature project "com.example.first.feature" for the plugin. I am able to generate build.xml(ant build file) for "com.exilant.first" by following below steps: right click on build.properties---->Plug-in-tools--->Create Ant build file. I am following same steps to create build.xml for "com.exilant.first.feature" (feature project) but after clicking 'Create Ant build file' noting is happening(not generating build.xml). Please help! Thanks in Advance.
If you look in the .log file in the workspace .metadata directory you will probably see the message: Could not find valid manifest file to create ant build file The 'create Ant Build file' will only work if it finds a META-INF/MANIFEST.MF in the project. However feature projects don't normally have these so I don't understand what this code is trying to do. Try using 'File > Export > Plug-in Development > Deployable features'. On the 'Options' tab you can ask it to save the Ant script it generates.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "apache, ant, eclipse plugin, eclipse rcp" }
Python Float Lost with Big Numbers I am working with some large numbers and have run into a problem with lost floating values. When multiplying large numbers, the float portion seems to go missing, lost, becomes zero. When using the same code with smaller numbers, this does not happen. Trivial example: import math f_ProNum(31 * 61) ## Correct: DEBUG float: 314.833333 f_ProNum(5915587277 * 3367900313) ## Incorrect: DEBUG float: 3320518040297852928.000000 def f_ProNum(v_Num): """Syntax: (int); Returns: (float)""" print("DEBUG float: %f") %((v_Num - 2.0)/6.0) # DEBUG v_PDNum = (v_Num - 2.0)/6.0 return v_PDNum As seen in the second call, the float seems to get lost, or set to zero. Why is it doing this, and how may it be addressed, fixed?
Larger float values lose precision. To simplify a bit, floats have a fixed number of "digits" that are used, called the mantissa or significand, so large enough numbers are essentially going to use all their digits on the part to the left of the decimal place. For more see: < To solve your problem, you might try using the `decimal` module, which allows you to configure the precision you need: <
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "python" }
Mac app shrinks when copied to USB I have a Mac app that is 443,245,675 bytes. When I copy it to a flash drive, the copied version is only 443,239,527 bytes and the app package becomes invalid (`spctl -a` fails). This difference (6148 bytes) is the size of a `.DS_Store` file exactly, but none seems to exist in the app package. My hidden files are visible and I've looked using `ls -l` — there's no `.DS_Store` file there. What's going on here and how do I fix it so my app doesn't become invalidated every time it's copied? Note that the app still runs even though `spctl` fails. That said, should I even worry about this?
Your thumb drive is likely formatted as FAT32 (or just FAT if older). Copying the app to something that isn't formatted as Mac OS Extended, probably resulted in the loss of things like file owner, permissions, etc, that may have been needed to run/validate it with the system. Either consider 1. Packaging it as a .dmg, or 2. If this is something you might need often, you could reformat the thumb drive as HFS+ (after backing up anything important on it). Consider copying the app file with the flag to preserve settings: cp -p source_file target_thumb_drive
stackexchange-apple
{ "answer_score": 1, "question_score": 1, "tags": "macos, file transfer, code signing" }
Duplicate displaced plane and have edges line up? I have a displaced plane (shown in image 1,) which I'd like to duplicate and move next to itself to expand it into 2 tiles. However, when I do that, the edges don't line up and I can't get the individual tiles to generate new bumps while also lining up properly with the last. How might I fix this? Thank you! :) ![Image 1](
He he .. @MmmChezBurgerz, you beat me to it! You can put the texture into the space of any object you choose.. here, an Empty called 'Texture Space'. This answer is only for illustration.. ![enter image description here](
stackexchange-blender
{ "answer_score": 2, "question_score": 0, "tags": "displacement" }
I'm copying all httpdocs files from server to server using rsync, what do I use to include hidden / htaccess files Here is the command I'm running rsync -av -e ssh httpdocs user@ipaddress:httpdocs but that misses out hidden files like .htaccess ? Any help appreciated ! Rich :)
With rsync all subdirectories and files will be automaticaly copied. You need not additional keys or options to copy hidden files.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "linux, bash" }
Selecting delimited data in one column of data.table based on positional values in another I have a data table x<-data.table(col1=rep("hello,how,are,you",4),col2=1:4) col1 col2 1: hello,how,are,you 1 2: hello,how,are,you 2 3: hello,how,are,you 3 4: hello,how,are,you 4 now I need to select values from col1 based on the values in col2. How can I do this within j of data.table? Final data should look something like this col1 col2 col3 1: hello,how,are,you 1 hello 2: hello,how,are,you 2 how 3: hello,how,are,you 3 are 4: hello,how,are,you 4 you
I don't know if this is the most efficient (is speed or memory the top concern?) solution: library(data.table) x <- data.table(col1=c(rep("hello,how,are,you",3), "Lirum, Larum, Löffel, Stiel"), col2=1:4) x[, ind := .I] x[, col3 := strsplit(col1, ",", fixed=TRUE)] x[, col4 := col3[[1]][col2], by=ind] # col1 col2 ind col3 col4 # 1: hello,how,are,you 1 1 hello,how,are,you hello # 2: hello,how,are,you 2 2 hello,how,are,you how # 3: hello,how,are,you 3 3 hello,how,are,you are # 4: Lirum, Larum, Löffel, Stiel 4 4 Lirum, Larum, Löffel, Stiel Stiel
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "r, data.table" }
jQuery: How to fire event when all asynchronous calls return? I have a jQuery application that loads data from five asynchronous server calls. I do not want to display any data until all five calls return. (I plan on displaying a Loading message until that happens.) How can I detect when all five calls have returned? I considered having each callback method increment a variable (using jQuery's data() method, perhaps) and then waiting for the value to become 5. (I am not sure yet how I would listen for that event.) I do not think this is a very good solution, however. What would happen if two calls return at the same time? Is there a better way to do this?
If you are already using jQuery for the AJAX calls, you can use `$.ajaxStop()` for this, it fires when **all** current calls come back, you can use it like this: $("#loading").ajaxStop(function() { $(this).fadeOut(); }); This isn't really that different than `.click()` in terms that it's just an event, you can use the `ajaxStop` event yourself if you want, like this: $("#loading").bind('ajaxStop', function() { $(this).fadeOut(); });
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 1, "tags": "javascript, jquery, events, asynchronous" }
Share the dist folder of loopback4 I just build the dist folder of my Loopback 4 API and wish to deploy it on one of my machines. 1. `npm run build && tar -zxvf dist.tar.gz ./dist` (Move the dist.tar.gz file on another machine + untar it) 2. Try to run it: `node ./dist/index.js` 3. Get this error: `tslib package not found`. Is there something I'm missing? There is no packages.json in the dist folder then no way to install the dependencies... Should I add a flag or something? (I didn't find any explanation in the documentation)
In line with other TypeScript projects, LoopBack 4 projects requires `dist`, `package.json`, `package-lock.json` to be published. In production, you can run this command to skip the build process and instead execute the pre-built artifacts: node .
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "node.js, build, loopbackjs, production, loopback4" }
Netbeans screen artifacting I have noticed recently that in net beans sometimes lines are left on the screen and aren't cleaned up. I cant get a screen shot for some reason so an image from my phone will have to do: !Here Is there a setting I need to change, or something? or is it a problem with my monitor?
Nope, just minimalize/resize window to redraw
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, netbeans, lines, artifact" }
Pipe stdout of two programs to each other I have two programs, one of them prints something first, they need to communicate with each other with their standard IO. Is there a way in Bash to pipe stdout of two programs to each other? I know I could do this in C with forks and dups, but is there a way with pure Bash?
Create a named FIFO that will "loop" the pipe: mkfifo myfifo <myfifo program1 | program2 >myfifo rm myfifo Even if none of the programs prints anything first, you can "inject" data into the FIFO, so it's received by `program1`: # from another console echo start >myfifo To observe/store the communication, use `tee` in the right place(s). Examples: <myfifo program1 | program2 | tee myfifo <myfifo program1 | tee /dev/tty ./log1 | program2 | tee ./log2 >myfifo The whole thing will work in `sh`, there's nothing specific to Bash in this solution. Please read this answer about possible scenarios leading to a deadlock.
stackexchange-superuser
{ "answer_score": 2, "question_score": 0, "tags": "linux, bash, redirection, io" }
Corresponding Rational Function I know that all meromorphic functions on $\mathbb{CP}^1$ are rational functions. However, I'm having some troubles understanding how to obtain the corresponding rational function from a meromorphic one. For example, given an invertible matrix $A = \begin{bmatrix}a, b\\\c, d\end{bmatrix} \in GL_2(\mathbb{C})$ we define $F_A : \mathbb{CP}^1 \to \mathbb{CP}^1$ by $$F_A([z:w]):=[az+bw:cz+dw]$$ What is the rational function corresponding to $F_A$? Probably it's a very easy computation but I don't get it.
Note that $$\mathbb{C} = \\{[z:1]\,|\,z\in \mathbb{C}\\}\subseteq \mathbb{CP}^1$$ Hence you can identify $F_A$ with a rational function $f_A$ given by $$f_A(z) = F_A([z:1])$$ Then $$f_A(z) = \frac{az + b}{cz + d}$$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "complex analysis" }
How to change Apache's 'Server:' header without mod_security? How to change Apache's `Server:` header without mod_security? I do not want to use mod_security because I don't have anything else to do with it. And it is a useless overhead for me. Instead, what should I change in the Apache's source? I usually use Apache compiled from source. I am using Apache version 2.4.46.
To change Apache's `Server:` header, change the following in the source code: Change the file `/path/to/httpd-2.4.46/include/ap_release.h`: Go to the line like: ... #define AP_SERVER_BASEPROJECT "Apache HTTP Server" #define AP_SERVER_BASEPRODUCT "Apache" ... And change it to anything, like: ... #define AP_SERVER_BASEPROJECT "Apache Something My Server" #define AP_SERVER_BASEPRODUCT "Apache My Server" ... And then compile apache, and you are good! Also, make sure to follow the license that is provided with it. Questions about license here are off-topic.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "apache, http headers" }
How to dynamically change html content depending on screen resolution I want to replace a section of a html(php) for one of two php files based on the screen resolution. The only way i know to get screen resolution is by javascript, I've searched for ways to get javascript variables in a php script but I can't achieve what i want to do.(I need to change the section content dynamically, replacing one of the two php files any time screen resolution reaches a specific value).
You need to have both HTML code ready, and display the correct one based on the screen resolution. You can use CSS display property for it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "javascript, php, html, responsive" }
Get querystring value I want to make a method in my tools library that request the querystring from the url. I created the following code, but i can't use the HttpContext in a class library. public string RequestString(string requestParam, string Default) { string param = HttpContext.Current.Request.QueryString[requestParam]; if (param != null) { return param; } else { return Default; } } I know it is possible, but i can't remember how...
You need to add a reference to the `System.Web.dll` assembly in your class library project. But of course you will only be able to access the query string when your method is called in the context of a HTTP request. See this MSDN page for more information about the HttpContext class.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, query string, httpcontext" }
how can we receive message from IFTTT to a java code and vise versa how can we receive message from IFTTT to a java code and vise versa it may be restful webservice?
I would recommend using IFTTT's Maker service it can receive and send web requests < it gives you a key code to use and you either use a POST or GET request to trigger maker. The only problem is for receiving with maker it sends a web request to a public URL. I would recommend using something like google drive or drop box to modify a file and create a way to see that ifttt detected whatever you told it to do. hope this helps ps: if you want to see something some people made with maker: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "java, rest, ifttt" }
calculate hex checksum in python I need to write a function to calculate the checksum of its argument and then send the parameter with it's checksum out. When I was calculating the checksum manually i was doing something like this: data = '\x03\x2F\x00\x00\x02\x12\x01\x47' and then s.sendall(data) is there a way to write data as: data = "03 2F 00 00 02 12 01" and let python know that I want what's in data to be seen as Hex? If python views that as hex will my function look like for i in range(len(data)): sum = sum +data[i] or something like that?
To represent as hexadecimal, use `binascii.hexlify`: >>> import binascii >>> binascii.hexlify('\x03\x2F\x00\x00\x02\x12\x01\x47') '032f000002120147' >>> ' '.join(binascii.hexlify(ch) for ch in '\x03\x2F\x00\x00\x02\x12\x01\x47') '03 2f 00 00 02 12 01 47' To calculate checksum, iterate each bytes: data = '\x03\x2F\x00\x00\x02\x12\x01\x47' checksum = 0 for ch in data: checksum += ord(ch) # ord('\x03`) -> 3 or using `sum` and `map`: checksum = sum(map(ord, data))
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "python" }
Use dictionary on Pandas column? I want to do something like the following: df['Day'] = df['Day'].apply(lambda x: x + myDict[df['Month']]), where myDict={2:3,4:1,6:1,9:1,11:1,1:0,3:0,5:0,7:0,8:0,10:0,12:0}. What I'm doing is adding a number of days onto the day of the month if it's a certain month. Ex: If it's February and the day of the month is 28, I add 3 to get 31. But this does not work because I really want to apply myDict to the indexes of df['Month'], not the Month column directly. Can I do iterrows inline for my command? I think this would perform faster through pandas than a big for loop iterating through the whole dataframe.
Try: df.Day += df.Month.map(myDict) Or: because I don't really get what you are doing df.Day += df.index.to_series().map(myDict)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, pandas, dictionary, lambda" }
Move Records to bottom of a spreadsheet if it contains a 0 I would like to move an entire row to the bottom of a spread sheet if the column k contains a 0. The code I have only works on change not on activate or even better yet with a button. How would i modify the code to work outside of on change? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub Dim rw As Long Application.EnableEvents = False If Not Intersect(Target, Range("K:K")) Is Nothing And LCase(Target) = 0 Then rw = Target.Row Target.EntireRow.Cut Cells(Rows.Count, 1).End(xlUp)(2) Rows(rw).Delete End If Application.EnableEvents = True End Sub
Try: Option Explicit Sub test() Dim Lastrow As Long, i As Long With ThisWorkbook.Worksheets("Sheet1") Lastrow = .Cells(.Rows.Count, "K").End(xlUp).Row For i = Lastrow - 1 To 1 Step -1 If .Range("K" & i).Value = 0 Then Lastrow = .Cells(.Rows.Count, "K").End(xlUp).Row .Rows(i).Cut .Rows(Lastrow + 1) .Rows(i).EntireRow.Delete End If Next i End With End Sub
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "excel, vba" }
Using a newer version of Python than what is installed on Linux server I have an account on a Linux server which currently has Python2.4 installed on it so by default running the command `which python` returns `/usr/bin/python` I have installed Python2.7 in my account home directory @ /path/to/myaccount and have set and sourced the path in my .bash_profile file as PYTHONPATH=/path/to/myaccount/bin/python export PATH=$PYTHONPATH:$PATH However I am still getting Python2.4 as my default Python.
`PYTHONPATH` tells Python where to look for modules and packages (`.py` files etc) You need to make sure your _shell_ is looking in the right place for the Python binary export PATH=/path/to/myaccount/bin:$PATH
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, linux, python 2.7, admin" }
Add a line and turn this into a sport Add a straight line to this visual and turn it into a sport. ![enter image description here](
May add a line as > ![Add an L at the start]( which may be read as > lacrosse
stackexchange-puzzling
{ "answer_score": 12, "question_score": 9, "tags": "visual, rebus" }
What is RestorationIdentifier? I am wondering what RestorationIdentifier is, and why would we use it? I saw RestorationIdentifier on MMDrawerController. MMDrawerController using like this : ` [self setRestorationIdentifier:@"MMExampleCenterControllerRestorationKey"];`
Consider that you want to allow your user to close the app and then return to exactly where they were when they open the app again. And you should want to do that. Broadly you have 2 options: 1. Implement it yourself, saving everything into user defaults or similar and reconstructing the view hierarchy yourself 2. Use Apple State Preservation which will automatically rebuild the view hierarchy for you and which you can tie into to save and restore other pertinent information Option 2 is behind the use of the restoration id (so that the view hierarchy can be recorded and rebuilt).
stackexchange-stackoverflow
{ "answer_score": 20, "question_score": 14, "tags": "ios, iphone, objective c, uinavigationcontroller" }
In which module does the Timer class reside in python? Am reading the following online Timer manual for python 2.5, but am wondering where is the actual module where the class Timer resides? Gath
The way to figure this out: on the page you linked to, there's an Up link. It goes to the threading module.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "python, timer" }
Common Table Expression, why semicolon? Usually in `SQL Server` Common Table Expression clause there is semicolon in front of the statement, like this: ;WITH OrderedOrders AS --semicolon here ( SELECT SalesOrderID, OrderDate, ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber' FROM Sales.SalesOrderHeader ) SELECT * FROM OrderedOrders WHERE RowNumber BETWEEN 50 AND 60 Why?
* To avoid ambiguity because WITH can be used elsewhere `..FROM..WITH (NOLOCK)..` `RESTORE..WITH MOVE..` * It's optional to terminate statements with `;` in SQL Server Put together, the previous statement must be terminated before a WITH/CTE. To avoid errors, most folk use `;WITH` because we don't know what is before the CTE So DECLARE @foo int; WITH OrderedOrders AS ( SELECT SalesOrderID, OrderDate, ...; is the same as DECLARE @foo int ;WITH OrderedOrders AS ( SELECT SalesOrderID, OrderDate, ...; The MERGE command has a similar requirement.
stackexchange-stackoverflow
{ "answer_score": 96, "question_score": 67, "tags": "sql, sql server, tsql, sql server 2008, common table expression" }
Save Scope Graphic of Simulink Model I'm using simulink of Matlab R2012b. When I finish generating my model, I want to save the graphics obtained from it that are seen in the scope, but I can't find an easy way to do this. Does exist a way to save the graphics that I'm obtaining from the model that are seen in the scope?
The long way to do this is, before running the model, go to the terminal of matlab, and enter the next lines: >>>shh = get(0,'ShowHiddenHandles'); >>>set(0,'ShowHiddenHandles','On') >>>set(gcf,'PaperPositionMode','auto') >>>set(gcf,'InvertHardcopy','off') >>>saveas(gcf,'mypic.jpg') >>>set(0,'ShowHiddenHandles',shh) And the file will be saved in the current folder where you are working. The other way is doing a screenshot, and then pasting it on a program like paint or inkscape.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "matlab, graphics, simulink" }
Can the iPhone detect the size of a touch? As far as I can tell the iPhone multitouch framework sends the location of each touch but not the size. I want to allow the user to tap a button with the tip of their thumb, or to put the pad of their thumb across multiple buttons (not real UIButtons) and have my touch tracking code realize it needs to press all the buttons the thumb is over.
Since UITouch handles the touch and nothing is said about the size, i'd say no you can't. You better try another approch like a drag..
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 10, "tags": "cocoa touch" }
Why are two diodes used here? I'm following the wiring diagram for a digitech fs3x guitar pedal footswitch. For the third SPST switch, it's wired from the other two switches connected by 2 diodes, both in the same direction. Can anyone explain why a single diode wouldn't work here (with both wires connected to it) !Schematic #1 !Schematic #2
The two diodes are preventing a high potential on EITHER the Ring or Tip from generating a current flow into the Tip or Ring respectively, when none of the momentary switches are depressed. A single diode, say for example the diode between the Tip and the Up button, would not prevent a potential on Tip from generating a non-negligible current flow into the Ring when Ring was at a sufficiently lower potential than Tip. This potential would be approximated by the forward voltage drop of the N14002.
stackexchange-electronics
{ "answer_score": 2, "question_score": 0, "tags": "diodes, guitar pedal" }
Detect type of calculation via vba I have a spreadsheet set to manual calculation for time saving (it takes a long time to calculate). I'd like to offer some way of advising the user whether a calculate needs to be performed or not to get the whole workbook up to date. I've not thought it through fully yet, but in my head I need to be able to distinguish the calculates that a user performs. I.e. I need a worksheet_calculate event to be able to recognise if the user has done a shift-f9 or a ctrl-shift-f9 and to be able to alter it's behaviour according to that. Any help would be gratefully received.
You can try using `onkey` : Sub TrackKeys() Application.OnKey "+{F9}", "Recalculate" End Sub 'in your sub you can call the calculations mode to be changed. Sub Recalculate() Sheet1(1).Range("A2:E5").Calculate End Sub Found the link: Try this for a better explanation :) <
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "vba, excel, excel 2003" }
Find maximum of column for each business quarter pandas Assume that I have the following data set import pandas as pd, numpy, datetime start, end = datetime.datetime(2015, 1, 1), datetime.datetime(2015, 12, 31) date_list = pd.date_range(start, end, freq='B') numdays = len(date_list) value = numpy.random.normal(loc=1e3, scale=50, size=numdays) ids = numpy.repeat([1], numdays) test_df = pd.DataFrame({'Id': ids, 'Date': date_list, 'Value': value}) I would now like to calculate the maximum within each business quarter for `test_df`. One possiblity is to use `resample` using `rule='BQ', how='max'`. However, I'd like to keep the structure of the array and just generate another column with the maximum for each BQ, have you guys got any suggestions on how to do this?
I think the following should work for you, this groups on the quarter and calls `transform` on the 'Value' column and returns the maximum value as a Series with it's index aligned to the original df: In [26]: test_df['max'] = test_df.groupby(test_df['Date'].dt.quarter)['Value'].transform('max') test_df Out[26]: Date Id Value max 0 2015-01-01 1 1005.498555 1100.197059 1 2015-01-02 1 1032.235987 1100.197059 2 2015-01-05 1 986.906171 1100.197059 3 2015-01-06 1 984.473338 1100.197059 ........ 256 2015-12-25 1 997.965285 1145.215837 257 2015-12-28 1 929.652812 1145.215837 258 2015-12-29 1 1086.128017 1145.215837 259 2015-12-30 1 921.663949 1145.215837 260 2015-12-31 1 938.189566 1145.215837 [261 rows x 4 columns]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, pandas" }
CrystalDecisions.Web DLL I've downloaded the Business Objects 3.0 SDK but it didn't contain the CrystalDecisions.Web DLL (version 12). The DLL exists on the Business Objects XI SDK (version 11.5) and on the Business Objects 4.0 SDK (version 13), but not on the BO3 Any thoughts on the matter? Thanks
The 'CrystalDecisions.Web DLLs version 12.0.2000.0' thread on SAP's forum might be useful--it discusses service packs. You may also want to leverage the OpenDocument SDK to do the 'heavy lifting' for displaying a report rather than trying to code it yourself. You might also consider migrating to the WebServices SDK as well.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "crystal reports, business objects, business objects sdk" }
Combining ECC and AES for a Web Chat system I am working on a portable secure chat via desktop or mobile, which adopts OTP plus asymmetric encryption. The idea goes like this: Suppose that Alice and Bob are clients, and the server is run by Steve. Steve generates the server private/public key pair, while Alice and Bob generates their client key pairs`. For each message, the client generates a random AES key for encrypting that specific message, that is then encrypted with the server's public key. The client also signs the message with its private key as well. The server decrypts such message, encrypts it with the public key of every online client, and broadcasts it to them. Is there any problem with CPU load on the server or client, or problem with security breaches happening during message transfer, or is this idea just useless and needs to be scrapped? The ECC keypair would be 521 bits, while the AES key would be 256 bits.
I refer to your own answer. > using TLS is good enough > Is there any problem with ...snip... security breaches happening during message transfer, Well yes, there is a problem. Have you understood the implication of @forest 's cryptic comment? E2E = end to end. À la Signal. With TLS, client/server messaging will be encrypted, but the messages will be plaintext as they pass through the server. That means anyone with physical/judicial access to the server will be able to read all the messages. And initiate Man in the Middle attacks. Read about all the troubles with Blackberry phones. It's all about what you want to achieve, and some of that can be troublesome.
stackexchange-crypto
{ "answer_score": 1, "question_score": 2, "tags": "encryption, elliptic curves, one time pad" }
Github actions CMake: Error Cannot load cache I moved my `CMakeLists.txt` from the root into my `src/` directory and I reconfigured my CMake workflow. The error comes from the build scope. Error loading Cache. **My Configuration:** jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Configure CMake run: cmake ${{github.workspace}}/src -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build run: cmake --build ${{github.workspace}}/src --config ${{env.BUILD_TYPE}} - name: Test working-directory: ${{github.workspace}}/src/build run: ctest -C ${{env.BUILD_TYPE}}
With the command `cmake ${{github.workspace}}/src -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}` you set the location of the CMakeLists.txt, the cmake output directory is still the current working directory `.`. This output directory should be passed to `--build` - name: Build run: cmake --build . --config ${{env.BUILD_TYPE}}
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "github, cmake, github actions" }