title
stringlengths
10
150
body
stringlengths
17
64.2k
label
int64
0
3
How to elegantly check if a number is within a range?
<p>How can I do this elegantly with C#?</p> <p>For example, a number can be between 1 and 100.</p> <p>I know a simple <code>if (x &gt;= 1 &amp;&amp; x &lt;= 100)</code> would suffice; but with a lot of syntax sugar and new features constantly added to C#/.Net this question is about more idiomatic (one can all it elegance) ways to write that.</p> <p>Performance is not a concern, but please add performance note to solutions that are not O(1) as people may copy-paste the suggestions.</p>
0
How to fetch and reuse the CSRF token using Postman Rest Client
<p>I am using Postman Rest client for hitting the rest services. I am getting the following error when I try to execute the rest service from Postman client.</p> <pre><code>HTTP Status 403 - Cross-site request forgery verification failed. Request aborted. </code></pre> <p><a href="https://i.stack.imgur.com/ynwWL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ynwWL.png" alt="enter image description here"></a></p> <p>It appears that the rest services are secured by the implementation of CSRF token. Does anybody has any idea about how to fetch the CSRF token and reuse it for future requests?</p>
0
TypeScript set css style for HTMLCollectionOf<Element>, NodeCollection<Element>,google autocomplete forms
<p>how I can set css style for HTMLCollectionOf or NodeCollection</p> <pre><code> let items = document.querySelectorAll('.pac-item') as NodeListOf&lt;HTMLElement&gt;; </code></pre> <p><a href="https://i.stack.imgur.com/oLP5E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oLP5E.png" alt="enter image description here"></a></p> <p>For HTMLElement set style working good <a href="https://i.stack.imgur.com/v0vvp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v0vvp.png" alt="enter image description here"></a></p>
0
"You don't have an extension for debugging 'JSON with Comments'" warning when debugging VS Code theme
<p>I generated the files necessary for creating a color theme in VS Code. I did this with the <a href="https://www.npmjs.com/package/generator-code" rel="noreferrer">generator-code</a> node package.<br></p> <p><a href="https://i.stack.imgur.com/aHL8k.png" rel="noreferrer">My file structure is as follows</a><br></p> <p>When I run VS Code's debugger, I get <a href="https://i.stack.imgur.com/eW47e.png" rel="noreferrer">this warning</a> that prevents the debugger from running.<br></p> <p>Here are the contents of my launch.json file for reference:</p> <pre><code>{ &quot;version&quot;: &quot;0.2.0&quot;, &quot;configurations&quot;: [ { &quot;name&quot;: &quot;Extension&quot;, &quot;type&quot;: &quot;extensionHost&quot;, &quot;request&quot;: &quot;launch&quot;, &quot;runtimeExecutable&quot;: &quot;${execPath}&quot;, &quot;args&quot;: [ &quot;--extensionDevelopmentPath=${workspaceFolder}&quot; ], &quot;outFiles&quot;: [ &quot;${workspaceFolder}/out/**/*.js&quot; ], } ] } </code></pre> <p>In case you're wondering what I'm expecting to happen when I run the debugger, <a href="https://youtu.be/pGzssFNtWXw?t=369" rel="noreferrer">here's the moment</a> in the tutorial I was following where I ran into this problem.<br></p> <p><strong>Edit:</strong> Well, I evaded the problem somehow by deleting the files and starting over. I'm not sure what was causing the problem before.</p>
0
Pandas: for loop through columns
<p>My data looks like: </p> <pre><code>SNP Name ss715583617 ss715592335 ss715591044 ss715598181 4 PI081762 T A A T 5 PI101404A T A A T 6 PI101404B T A A T 7 PI135624 T A A T 8 PI326581 T A A T 9 PI326582A T A A T 10 PI326582B T A A T 11 PI339732 T A A T 12 PI339735A T A A T 13 PI339735B T A A T 14 PI342618A T A A T </code></pre> <p>In reality I have a dataset of 50,000 columns of 479 rows. My objective is to go through each column with characters and convert the data to integers depending on which is the most abundant character.</p> <p>Right now I have the data input, and I have more or less written the function I would like to use to analyze each column separately. However, I can't quite understand how to use a forloop or use the apply function through all of the columns in the dataset. I would prefer not to hardcode the columns because I will have 40,000~50,000 columns to analyze. </p> <p>My code so far is:</p> <pre><code>import pandas as pd df = pd.read_csv("/home/dfreese/Desktop/testSNPtext", delimiter='\t') df.head() # check that the file format fits # ncol df df2 = df.iloc[4:-1] # Select the rows you want to analyze in a subset df print(df2) </code></pre> <p>My function: </p> <pre><code>def countAlleles(N): # N is just suppose to be the column, ideally once I've optimized the function # I need to analyze every column # Will hold the counts of each letter in the column letterCount = [] # This is a parallel array to know the order letterOrder = {'T','A','G','C','H','U'} # Boolean to use which one is the maximum TFlag = None AFlag = None GFlag = None CFlag = None HFlag = None UFlag = None # Loop through the column to determine which one is the maximum for i in range(len(N)): # How do I get index information of the column? if(N[i] == 'T'): # If the element in the column is T letterCount[0] = letterCount[0] + 1 elif(N[i] == 'A'): letterCount[1] = letterCount [1] + 1 elif (N[i] == 'G'): letterCount[2] = letterCount [2] + 1 elif (N[i] == 'C'): lettercount[3] = letterCount[3] + 1 elif(N[i] == 'H'): letterCount[4] = letterCount[4] + 1 else: letterCount[5] = letterCount[5] + 1 max = letterCount[0] # This will hold the value of maximum mIndex = 0 # This holds the index position with the max value # Determine which one is max for i in range(len(letterCount)): if (letterCount[i] &gt; max): max = letterCount[i] mIndex = i </code></pre> <p>So I designed the function to input the column, in hopes to be able to iterate through all the columns of the dataframe. My main question is: </p> <p>1) How would I pass each in each column as a parameter to the for loop through the elements of each column?</p> <p>My major source of confusion is how indexes are being used in pandas. I'm familiar with 2-dimensional array in C++ and Java and that is most of where my knowledge stems from.</p> <p>I'm attempting to use the apply function: </p> <pre><code>df2 = df2.apply(countAlleles('ss715583617'), axis=2) </code></pre> <p>but it doesn't seem that my application is correct.</p>
0
How to solve error: "Invalid type in JSON write (NSConcreteData)"
<p>I'm trying to write some code to validate a subscription on my iOS App. I'm following this tutorial: <a href="http://savvyapps.com/blog/how-setup-test-auto-renewable-subscription-ios-app/" rel="nofollow">http://savvyapps.com/blog/how-setup-test-auto-renewable-subscription-ios-app/</a></p> <p>It's not in Swift 2.0, so I had to convert some of the code, but I'm having trouble with this line:</p> <pre><code>let requestData = try! NSJSONSerialization.dataWithJSONObject(receiptDictionary, options: NSJSONWritingOptions.PrettyPrinted) as NSData! </code></pre> <p>When it hits that line, it prints this error message: </p> <blockquote> <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteData)'</p> </blockquote> <p>Here's the whole function:</p> <pre><code>func validateReceipt() { print("Validating") if let receiptPath = NSBundle.mainBundle().appStoreReceiptURL?.path where NSFileManager.defaultManager().fileExistsAtPath(receiptPath) { print("Loading Validation") let receiptData = NSData(contentsOfURL:NSBundle.mainBundle().appStoreReceiptURL!) print(receiptData) let receiptDictionary = ["receipt-data" : receiptData!.base64EncodedDataWithOptions([]), "password" : "placeholder"] let requestData = try! NSJSONSerialization.dataWithJSONObject(receiptDictionary, options: NSJSONWritingOptions.PrettyPrinted) as NSData! let storeURL = NSURL(string: "https://sandbox.itunes.apple.com/verifyReceipt")! let storeRequest = NSMutableURLRequest(URL: storeURL) storeRequest.HTTPMethod = "POST" storeRequest.HTTPBody = requestData let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration()) session.dataTaskWithRequest(storeRequest, completionHandler: { (data, response, connection) -&gt; Void in if let jsonResponse: NSDictionary = try! NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions.MutableContainers) as? NSDictionary, let expirationDate: NSDate = self.formatExpirationDateFromResponse(jsonResponse) { print(expirationDate) //self.updateIAPExpirationDate(expirationDate) } }) } } </code></pre> <p>I haven't done in-app purchases before, so I'm a bit new to this. Thanks in advance for your help!</p>
0
Include my markdown README into Sphinx
<p>I would like to include my project's <code>README.md</code> into my Sphinx documentation like in <a href="https://stackoverflow.com/questions/10199233/can-sphinx-link-to-documents-that-are-not-located-in-directories-below-the-root">Can sphinx link to documents that are not located in directories below the root document?</a> - which is that in the resulting Sphinx html documentation I click on a link in the table of contents on the welcome page and get to the <code>README.md</code>.</p> <p>For that a document <code>readme_link.rst</code> is created which contains the lines</p> <pre><code>Readme File ----------- .. include:: ../../README.md </code></pre> <p>and I add the line</p> <pre><code>README &lt;readme_link&gt; </code></pre> <p>into the toctree of <code>index.rst</code>. Going with that, my <code>README.md</code> is not parsed as Markdown, but just printed onto the page as-is-text.</p> <p>I thought an alternative idea might be to have a markdown file <code>readme_link.md</code> instead, but there is no way to include files with markdown.</p> <p><strong>How can I have my README.md parsed as markdown?</strong></p> <p>(Of course I don't want to rewrite it as .rst.)</p> <h2>Why <a href="https://github.com/miyakogi/m2r#sphinx-integration" rel="noreferrer">m2r</a> is not working</h2> <p>I tried to follow <a href="https://stackoverflow.com/questions/45967058/render-output-from-markdown-file-inside-rst-file">Render output from markdown file inside .rst file</a>, but this is not working. My <code>README.md</code> has some headings like</p> <pre><code># First heading some text ## Second heading 1 some text ## Second heading 2 some text </code></pre> <p>and I get the error <code>WARNING: ../README.md:48: (SEVERE/4) Title level inconsistent:</code>. I understand from <a href="https://stackoverflow.com/questions/24504301/what-does-title-level-inconsistent-mean">What does &quot;Title level inconsistent&quot; mean?</a> that I need to use other symbols - but reading into them I realized that the answer refers to <code>rst</code> symbols. That would mean that my markdown readme actually wasn't transformed into <code>rst</code>.</p> <p>PS: Someone else who tried something like that is <a href="https://muffinresearch.co.uk/selectively-including-parts-readme-rst-in-your-docs/" rel="noreferrer">https://muffinresearch.co.uk/selectively-including-parts-readme-rst-in-your-docs/</a></p>
0
How to prevent the ip address of hyper-v virtual switch from being changed?
<p>I have a laptop with Windows 10 2004 installed. I configureded Hyper-V and created two VMs: On one VM runs windows 10 to enclose serveral malware IM softwares which I have to use for working contacts. On the other VM runs ubuntu server 20.04 for development.</p> <p>I configured Hyper-V with a virtual switch of type internal network and Hyper-V automatically specified the virtual switch with a static IP. I want to connect to ubuntu with machine name. So I specified ubuntu VM with a static IP and added an item in the hosts file of the host windows 10. Then I can use the remote over SSH feature of VS Code to develop node.js app in windows 10 host. Everything went ok till I had restarted my laptop.</p> <p>After I have restarted the laptop, the IP address of the hyper-v virtual switch was changed. I couldn't reconnect to VM ubuntu any more because the VM ubuntu was configured with a static IP and default gateway based on the old IP of the virtual switch.</p> <p>I checked the IPv4 properties of the virtual switch via UI, It's configured as &quot;using the following IP&quot;, so I thought of the IP shouldn't change. But I was wrong. Each time after my laptop being restarted, the &quot;static IP&quot; of virtual switch always changes. This change breaks the connection to VM ubuntu.</p> <p>So, is there any way to prevent the IP address of the virtual switch from being changed? Or some way to add name resolving mechanism to Hyper-V virtual switch (then I can configure using dynamic IP address in VMs)?</p>
0
Django Query __isnull=True or = None
<p>this is a simple question. I'd like to know if it is the same to write:</p> <pre><code>queryset = Model.objects.filter(field=None) </code></pre> <p>than:</p> <pre><code>queryset = Model.objects.filter(field__isnull=True) </code></pre> <p>I'm using django 1.8</p>
0
How to properly create gcp service-account with roles in terraform
<p>Here is the terraform code I have used to create a service account and bind a role to it: </p> <pre><code>resource "google_service_account" "sa-name" { account_id = "sa-name" display_name = "SA" } resource "google_project_iam_binding" "firestore_owner_binding" { role = "roles/datastore.owner" members = [ "serviceAccount:sa-name@${var.project}.iam.gserviceaccount.com", ] depends_on = [google_service_account.sa-name] } </code></pre> <p>Above code worked great... except it removed the <code>datastore.owner</code> from any other service account in the project that this role was previously assigned to. We have a single project that many teams use and there are service accounts managed by different teams. My terraform code would only have our team's service accounts and we could end up breaking other teams service accounts.</p> <p>Is there another way to do this in terraform?</p> <p>This of course can be done via GCP UI or gcloud cli without any issue or affecting other SAs.</p>
0
Move body to a specific position - Box2D
<p>I have a b2Body which I would like to move at a certain target position. I don't want to use the SetPosition function. How can I achieve this using :</p> <ol> <li>Changing linear velocities.</li> <li>Using mouseJoint. (The target position is fixed. Mouse is NOT involved.)</li> </ol> <p>I'm using Box2DAS3 2.1a. Help in any other language would also be appreciated. </p>
0
Debug jar file in eclipse
<p>I have a jar file which is having some issue and I would like to debug it.</p> <p>I created the application on eclipse. During dev phase I have done debug but with the source code. I wanted to debug jar file to find out the reason of error i.e. it could be source code I have is different from jar file or some jar file issue.</p>
0
Emulating a mobile screen size through an iframe
<p>Just a random thought, What if I wanted to showcase a responsive webdesign not by resizing the browser window, but actually loading the responsive site in an IFRAME having the same dimension as that of a mobile screen. Can this work?</p> <p>assuming that I have an IFRAME </p> <pre><code>&lt;iframe src="something" id="viewPort"/&gt; </code></pre> <p>into which I load the responsive website. and then let the user test by adjusting the iframe width and height in their browser.</p> <p>IF this can work it can be a boon for clients who don't know a thing about browsers.</p>
0
Setting Access-Control-Allow-Origin header on source server
<p>I am using <code>$.get</code> to parse an RSS feed in jQuery with code similar to this:</p> <pre><code>$.get(rssurl, function(data) { var $xml = $(data); $xml.find("item").each(function() { var $this = $(this), item = { title: $this.find("title").text(), link: $this.find("link").text(), description: $this.find("description").text(), pubDate: $this.find("pubDate").text(), author: $this.find("author").text() } //Do something with item here... }); }); </code></pre> <p>However, due to the Single Origin Policy, I'm getting the following error:</p> <blockquote> <p>No 'Access-Control-Allow-Origin' header is present on the requested resource.</p> </blockquote> <p>Fortunately I have access to the source server, as this is my own dynamically created RSS feed.</p> <p>My question is: how do I set the Access-Control-Allow-Origin header on my source server?</p> <p><strong>Edit</strong></p> <p>I'm using PHP and I think my webserver is Apache.</p>
0
&bullet; doesn't work in IE?
<p>Is that not an acceptable HTML code to use when designing pages? It renders correctly in Chrome, Safari, Firefox, Opera, etc... but IE literally outputs <code>&amp; bullet;</code></p> <p>but even when I type the HTML code in this text box it gives me a bullet! &bullet;</p> <p>Is this method deprecated? Should I resort to the ASCII # or something?</p> <p>Many thanks SO</p>
0
Install Redis on Alpine based image in docker
<p>I am trying to install Redis on the <code>golang:1.10.1-alpine3.7</code> image. I tried <code>RUN apk add --no-cache redis</code>, but when I tried to run the <code>redis-cli</code> command, I get an exit status 127, which means the given command in not found. I would like to know how I would be able to run the <code>redis-cli</code> command.</p>
0
Definition of integration point in Abaqus
<p>I need to know the definition of "integration points" in abaqus subroutines. I'm new to abaqus software and I'm waiting for your help</p>
0
Using Team Foundation Server in Xcode
<p>Has anyone integrated Team Foundation Server in XCode? </p> <p>I am migrating from Git to TFS.</p> <p>How can this be done? </p> <p>Are there any useful tutorials or articles on the matter?</p>
0
Get country code from country name in IOS
<p>Im retrieving a country name from a server in english. For example, "Spain"</p> <p>What I want to do is, assuming the country name is going to be written in english, get the country code. </p> <p>What should I do? I´ve found getting the country name from the country code quite easy, but I´ve got no idea of how to do the opposite operation.</p> <p>Thanks a lot.</p>
0
How to remove selected items from a listbox
<p>This is for a VB.NET 4.5 project in VS2015 Community.</p> <p>I am trying to remove certain selected items from a listbox, but only if the selected item meets a condition. I've found plenty of examples on how to remove selected items. But nothing that works with a condition nested in the loop going through the selected items (at least, I can't get the examples to work with what I'm trying to do...)</p> <p>Here's my code:</p> <pre><code> Dim somecondition As Boolean = True Dim folder As String For i As Integer = 0 To lstBoxFoldersBackingUp.SelectedItems.Count - 1 If somecondition = True Then folder = lstBoxFoldersBackingUp.SelectedItems.Item(i) Console.WriteLine("folder: " &amp; folder) lstBoxFoldersBackingUp.SelectedItems.Remove(lstBoxFoldersBackingUp.SelectedItems.Item(i)) End If Next </code></pre> <p>The console output correctly shows the text for the current iteration's item, but I can't get the Remove() to work. As the code is now, I get the console output, but the listbox doesn't change.</p>
0
Jest mock window.scrollTo
<p>My React component calls <code>window.scrollTo</code> and when I run my jest tests, they pass, but there is a console error:</p> <pre><code> console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29 Error: Not implemented: window.scrollTo at Object.&lt;anonymous&gt;.module.exports (/private/var/www/samplesite.com/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17) at Window.scrollTo (/private/var/www/samplesite.com/node_modules/jsdom/lib/jsdom/browser/Window.js:544:7) at scrollTo (/private/var/www/samplesite.com/back-end/utils/library.jsx:180:12) at commitHookEffectList (/private/var/www/samplesite.com/node_modules/react-dom/cjs/react-dom.development.js:17283:26) at commitPassiveHookEffects (/private/var/www/samplesite.com/node_modules/react-dom/cjs/react-dom.development.js:17307:3) at Object.invokeGuardedCallbackImpl (/private/var/www/samplesite.com/node_modules/react-dom/cjs/react-dom.development.js:74:10) at invokeGuardedCallback (/private/var/www/samplesite.com/node_modules/react-dom/cjs/react-dom.development.js:256:31) at commitPassiveEffects (/private/var/www/samplesite.com/node_modules/react-dom/cjs/react-dom.development.js:18774:9) at wrapped (/private/var/www/samplesite.com/node_modules/react-dom/node_modules/scheduler/cjs/scheduler-tracing.development.js:207:34) at flushPassiveEffects (/private/var/www/samplesite.com/node_modules/react-dom/cjs/react-dom.development.js:18822:5) undefined </code></pre> <p>I have tried mocking it in a few ways (both in the test itself and also in a jest <code>setupFiles</code> that gets called before each test) , but the console error will not go away:</p> <p>Attempt 1:</p> <pre><code>let window = {}; window.scrollTo = jest.fn(); </code></pre> <p>Attempt 2:</p> <pre><code>let scrollTo = jest.fn(); Object.defineProperty(window, "scrollTo", scrollTo); </code></pre> <p>Attempt 3:</p> <pre><code>delete global.window.scrollTo; global.window.scrollTo = () =&gt; {}; </code></pre> <p>Attempt 4:</p> <pre><code>global.window = {}; global.window.scrollTo = () =&gt; {}; </code></pre> <p>How can i get rid of this console error? Thanks.</p>
0
iis-express file access permissions
<p>I'm running a wcf service hosted on iis express 7.5. Inside the service, i have a service operation that needs to write a file on the filesystem, but when it tries to do so, i'm getting an exception.</p> <p>i'm writing the file to the exact same folder where the project is hosted, by using: string filePath = HttpContext.Current.Server.MapPath(".");</p> <p>but i keep getting this exception:</p> <p>DirectoryNotFoundException - "Could not find a part of the path C:\websites....</p> <p>It seems like my iis express doesn't have permission to write files. if so, how do i give it permission?</p> <p>thanks!</p>
0
Pymongo: How to check if the update was successful ?
<p>How to check if the update was successful in Pymongo? If the record was updated with the same value it should be considered a successful update. ie, Even if the modified count is zero it is considered a successful update. How to do this. </p> <pre><code>result = _db.testcollection.update_one({"_id": col_id}, {"$set": obj}) return True if result.modified_count &gt; 0 else False </code></pre> <p>This works well if the value is changed. But I want to return true even when technically the record was not changed because the record is same what we are trying to update.</p> <p>How to do this?</p>
0
How to execute SqlQuery with Entity Framework Core 2.1?
<p>In Entity Framework 6, I can execute a raw SQL query on the database using the following command:</p> <pre><code>IEnumerable&lt;string&gt; Contact.Database.SqlQuery&lt;string&gt;("SELECT a.title FROM a JOIN b ON b.Id = a.aId WHERE b.Status = 10"); </code></pre> <p>On a new project, I am trying to use Entity Framework Core 2.1. I have a need to execute raw SQL query. While googling, I can see that the extension <code>SqlQuery</code> was changed to <code>FromSql</code>. However, <code>FromSql</code> only exists on the <code>DbSet&lt;&gt;</code> not on the <code>DbContext.Database</code>.</p> <p>How can I run <code>FromSql</code> outside the <code>DbSet&lt;&gt;</code>? The method <code>FromSql</code> does not exists on the database object <code>DbContext.Database.FromSql&lt;&gt;</code>.</p>
0
Powershell Invoke-WebRequest returns "remote name could not be resolved" but not proxy error
<p>I am trying to download a page using <code>wget</code> (alias for <code>Invoke-WebRequest</code>) in powershell. The page in question is <code>www.privatahyresvärdar.nu</code>.</p> <p>When using Internet Explorer I can navigate to <code>www.privatahyresvärdar.nu</code> but I cannot run wget from powershell nor can i <code>ping</code> the site. Neither command can resolve the hostname.</p> <p>I have followed several advice on SO and other sites commenting on using Proxies as an error source for <code>wget</code> failing, but i am not using any Proxy. </p> <p>Please help me identify the error source!</p>
0
Get the number of days in the current month in Java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/2545110/find-the-number-of-days-in-a-month-in-java">Find the number of days in a month in Java</a> </p> </blockquote> <p>I know these are some ways to do it, but I'm having hard time find information how to do it without passing specified date.</p> <p>I just want to get number of days in a current month, how do I do that?</p>
0
How to load images from a directory on the computer in Python
<p>Hello I am New to python and I wanted to know how i can load images from a directory on the computer into python variable. I have a set of images in a folder on disk and I want to display these images in a loop.</p>
0
How to color sliderbar (sliderInput)?
<p>I tried to make different color for a few sliderInput bar in R shiny. It requires css etc. I looked online and can only find how to make one <code>sliderInput</code>. How can I make create several different color to different bars?</p> <p>Here are my testing code. It will show all bar in same style:</p> <pre><code> ui &lt;- fluidPage( tags$style(type = &quot;text/css&quot;, &quot; .irs-bar {width: 100%; height: 25px; background: black; border-top: 1px solid black; border-bottom: 1px solid black;} .irs-bar-edge {background: black; border: 1px solid black; height: 25px; border-radius: 0px; width: 20px;} .irs-line {border: 1px solid black; height: 25px; border-radius: 0px;} .irs-grid-text {font-family: 'arial'; color: white; bottom: 17px; z-index: 1;} .irs-grid-pol {display: none;} .irs-max {font-family: 'arial'; color: black;} .irs-min {font-family: 'arial'; color: black;} .irs-single {color:black; background:#6666ff;} .irs-slider {width: 30px; height: 30px; top: 22px;} .irs-bar1 {width: 50%; height: 25px; background: red; border-top: 1px solid black; border-bottom: 1px solid black;} .irs-bar-edge1 {background: black; border: 1px solid red; height: 25px; border-radius: 0px; width: 20px;} .irs-line1 {border: 1px solid red; height: 25px; border-radius: 0px;} .irs-grid-text1 {font-family: 'arial'; color: white; bottom: 17px; z-index: 1;} .irs-grid-pol1 {display: none;} .irs-max1 {font-family: 'arial'; color: red;} .irs-min1 {font-family: 'arial'; color: red;} .irs-single1 {color:black; background:#6666ff;} .irs-slider1 {width: 30px; height: 30px; top: 22px;} &quot;), uiOutput(&quot;testSlider&quot;) ) server &lt;- function(input, output, session){ output$testSlider &lt;- renderUI({ fluidRow( column(width=3, box( title = &quot;Preferences&quot;, width = NULL, status = &quot;primary&quot;, sliderInput(inputId=&quot;test&quot;, label=NULL, min=1, max=10, value=5, step = 1, width='100%'), sliderInput(inputId=&quot;test2&quot;, label=NULL, min=1, max=10, value=5, step = 1, width='50%') ) )) }) } shinyApp(ui = ui, server=server) </code></pre>
0
Module AppRegistry is not a registered callable module
<p>I'm starting with React Native development and I encountered an issue in the very beginning. When trying to run my app I get errors:</p> <blockquote> <p>Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)<br> Unhandled JS Exception: Invariant Violation: Native module cannot be null.<br> Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)</p> </blockquote> <p>My App.js:</p> <pre><code>import React, { Component } from 'react'; import { SafeAreaView } from 'react-native'; import DefaultRouter from './src/navigation/DefaultRouter' export default class App extends Component { render() { return ( &lt;SafeAreaView&gt; &lt;DefaultRouter /&gt; &lt;/SafeAreaView&gt; ); } }; </code></pre> <p>index.js:</p> <pre><code>import { AppRegistry } from 'react-native'; import App from './App'; import {name as appName} from './app.json'; AppRegistry.registerComponent(appName, () =&gt; App); </code></pre> <p>DefaultRouter.js:</p> <pre><code>import { createSwitchNavigator, createAppContainer } from 'react-navigation'; import LoginScreen from '../screen/LoginScreen'; import DefaultTabBar from '../navigation/TabBar'; const DefaultRouter = createSwitchNavigator({ LOGIN_SCREEN: { screen: LoginScreen }, TAB_NAVIGATION: { screen: DefaultTabBar } }, { initialRouteName: 'LOGIN_SCREEN', headerMode: 'none' }) export default createAppContainer(DefaultRouter) </code></pre> <p>Other files are simple <code>Component</code> subclasses.</p> <p>The issue manifests regardless if I run the app from Visual Studio Code or from terminal with <code>react-native run-ios</code></p> <p>I looked through existing answers and I didn't find anything that could point me in the right direction:<br> <a href="https://stackoverflow.com/questions/34969858/react-native-module-appregistry-is-not-a-registered-callable-module">React-Native: Module AppRegistry is not a registered callable module</a><br> <a href="https://stackoverflow.com/questions/56397800/react-native-module-appregistry-is-not-a-registered-callable-module-calling-ru">React Native: Module AppRegistry is not a registered callable module (calling runApplication)</a><br> <a href="https://stackoverflow.com/questions/49128692/module-appregistry-is-not-a-registered-callable-module-calling-runapplication">module appregistry is not a registered callable module (calling runApplication)</a> <a href="https://stackoverflow.com/questions/55381142/module-appregistry-is-not-a-registered-callable-module-and-cant-find-variable-c">Module AppRegistry is not a registered callable module and Cant find variable: Constants</a><br> <a href="https://stackoverflow.com/questions/38133086/react-native-module-appregistry-is-not-a-registered-callable-module">React Native Module AppRegistry is not a registered callable module</a><br> <a href="https://stackoverflow.com/questions/48283521/module-appregistry-is-not-a-registered-callable-module-only-in-release-configura">Module AppRegistry is not a registered callable module only in Release configuration</a></p> <p>I'm stuck and I don't know where to go from here</p>
0
Can an "SEO Friendly" url contain a unique ID?
<p>I'd like to start using "SEO Friendly Urls" but the notion of generating and looking up large, unique text "ids" seems to be a significant performance challenge relative to simply looking up by an integer. Now, I know this isn't as "human friendly", but if I switched from</p> <pre><code>http://mysite.com/products/details?id=1000 </code></pre> <p>to</p> <pre><code>http://mysite.com/products/spacelysprokets/sproket/id </code></pre> <p>I could still use the ID alone to quickly lookup the details, but the URL itself contains keywords that will display in that detail. Is that friendly enough for Google? I hope so as it seems a much easier process than generating something at the end that is both unique and meaningful.</p> <p>Thanks!</p> <p>James</p>
0
Unique identifier for an iPhone app
<p>For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I'd like to send some unique phone id. Looked at <pre> [[UIDevice mainDevice] uniqueIdentifier]<br> and [[NSUserDefaults standardDefaults] stringForKey:@"SBFormattedPhoneNumber"] </pre></p> <p>but getting errors in the simulator.</p> <p>Is there an Apple sanctioned way of doing this?</p>
0
What exactly is nullptr?
<p>We now have C++11 with many new features. An interesting and confusing one (at least for me) is the new <code>nullptr</code>.</p> <p>Well, no need anymore for the nasty macro <code>NULL</code>.</p> <pre><code>int* x = nullptr; myclass* obj = nullptr; </code></pre> <p>Still, I am not getting how <code>nullptr</code> works. For example, <a href="http://en.wikipedia.org/wiki/C%2B%2B11#Null_pointer_constant" rel="noreferrer">Wikipedia article</a> says:</p> <blockquote> <p>C++11 corrects this by introducing a new <strong>keyword</strong> to serve as a distinguished null pointer constant: nullptr. It is of <strong>type nullptr_t</strong>, which is implicitly convertible and comparable to any pointer type or pointer-to-member type. It is not implicitly convertible or comparable to integral types, except for bool.</p> </blockquote> <p>How is it a keyword and an instance of a type?</p> <p>Also, do you have another example (beside the Wikipedia one) where <code>nullptr</code> is superior to good old <code>0</code>?</p>
0
How can I color Python logging output?
<p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p> <p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible with Python, but I can’t find out how to do this anywhere. </p> <p>Is there any way to make the Python <code>logging</code> module output in color? </p> <p>What I want (for instance) errors in red, debug messages in blue or yellow, and so on. </p> <p>Of course this would probably require a compatible terminal (most modern terminals are); but I could fallback to the original <code>logging</code> output if color isn't supported.</p> <p>Any ideas how I can get colored output with the logging module?</p>
0
how to alter table Composite primary key
<pre><code>CREATE TABLE [dbo].[INVS_ITEM_LOCATIONS] ([DEPARTMENT_CODE] [varchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [IM_INV_NO] [numeric](10, 0) NOT NULL, [LOCATION_CODE] [varchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [CURR_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__CURR___1352D76D] DEFAULT ((0)), [DO_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__DO_QT__1446FBA6] DEFAULT ((0)), [ALLOC_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__ALLOC__153B1FDF] DEFAULT ((0)), [YOB_QTY] [numeric](10, 0) NOT NULL CONSTRAINT [DF__INVS_ITEM__YOB_Q__162F4418] DEFAULT ((0)), [FOC_QTY] [numeric](10, 0) NULL CONSTRAINT [DF__INVS_ITEM__FOC_Q__17236851] DEFAULT ((0)), [USER_CREATED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [DATE_CREATED] [datetime] NOT NULL, [USER_MODIFIED] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [DATE_MODIFIED] [datetime] NULL, CONSTRAINT [INVS_ITEM_LOCATIONS_PK] PRIMARY KEY CLUSTERED ([DEPARTMENT_CODE] ASC, [IM_INV_NO] ASC, [LOCATION_CODE] ASC) WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] </code></pre> <p>This is my table structure ......how can I remove the composite primary key in table and also I should add foreign key to im_inv_no reference table is invs_location which contain im_inv_no and the department_code should be same primary key .pls help</p>
0
How to start/stop/restart a thread in Java?
<p>I am having a real hard time finding a way to start, stop, and restart a thread in Java.</p> <p>Specifically, I have a class <code>Task</code> (currently implements <code>Runnable</code>) in a file <code>Task.java</code>. My main application needs to be able to START this task on a thread, STOP (kill) the thread when it needs to, and sometimes KILL &amp; RESTART the thread...</p> <p>My first attempt was with <code>ExecutorService</code> but I can't seem to find a way for it restart a task. When I use <code>.shutdownnow()</code> any future call to <code>.execute()</code> fails because the <code>ExecutorService</code> is "shutdown"...</p> <p>So, how could I accomplish this?</p>
0
Setting the titleLabel.font property of a of a UIButton not working
<p>In currently working with iOS 7 and I an attempting to increase the font size of the titleLabel of my UIButton. I am doing it like this,</p> <pre><code>[[_centerButton titleLabel] setFont:[UIFont boldSystemFontOfSize:28.0]]; </code></pre> <p>However this does not do anything. Every time I compile with a different size the font always stays the same. Even when I completely delete that line the font stays the same. Apparently it is sticking to the default size.</p> <p>How can I increase the font size of my UIButton title?</p>
0
Home directory does not exist JBOSS
<p>I'm trying to run jboos as 7.1 and when I run the standalone.bat I get this error. I have configured everything as you can see here:</p> <pre><code>Calling "C:\jboss-as-7.1.1.Final\bin\standalone.conf.bat" =============================================================================== JBoss Bootstrap Environment JBOSS_HOME: C:\jboss-as-7.1.1.Final\ JAVA: C:\Program Files\Java\jdk1.7.0_45\bin\java JAVA_OPTS: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xms64M -Xmx51 2M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.se rver.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.war ning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.c onfig=standalone.xml =============================================================================== 13:21:17,915 Informaci¾n [org.jboss.modules] JBoss Modules version 1.1.1.GA java.lang.IllegalStateException: JBAS015849: Home directory does not exist: C:\j boss-as-7.1.1.Final" at org.jboss.as.server.ServerEnvironment.&lt;init&gt;(ServerEnvironment.java:3 28) at org.jboss.as.server.Main.determineEnvironment(Main.java:242) at org.jboss.as.server.Main.main(Main.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.modules.Module.run(Module.java:260) at org.jboss.modules.Main.main(Main.java:291) Presione una tecla para continuar . . . </code></pre> <p>The bin/standalone.conf.bat is this one:</p> <pre><code>rem ### -*- batch file -*- ###################################################### rem # ## rem # JBoss Bootstrap Script Configuration ## rem # ## rem ############################################################################# rem # $Id: run.conf.bat 88820 2009-05-13 15:25:44Z [email protected] $ rem # rem # This batch file is executed by run.bat to initialize the environment rem # variables that run.bat uses. It is recommended to use this file to rem # configure these variables, rather than modifying run.bat itself. rem # rem Uncomment the following line to disable manipulation of JAVA_OPTS (JVM parameters) rem set PRESERVE_JAVA_OPTS=true if not "x%JAVA_OPTS%" == "x" ( echo "JAVA_OPTS already set in environment; overriding default settings with values: % JAVA_OPTS%" goto JAVA_OPTS_SET ) rem # rem # Specify the JBoss Profiler configuration file to load. rem # rem # Default is to not load a JBoss Profiler configuration file. rem # rem set "PROFILER=%JBOSS_HOME%\bin\jboss-profiler.properties" rem # rem # Specify the location of the Java home directory (it is recommended that rem # this always be set). If set, then "%JAVA_HOME%\bin\java" will be used as rem # the Java VM executable; otherwise, "%JAVA%" will be used (see below). rem # rem set "JAVA_HOME=C:\opt\jdk1.6.0_23" rem # rem # Specify the exact Java VM executable to use - only used if JAVA_HOME is rem # not set. Default is "java". rem # rem set "JAVA=C:\opt\jdk1.6.0_23\bin\java" rem # rem # Specify options to pass to the Java VM. Note, there are some additional rem # options that are always passed by run.bat. rem # rem # JVM memory allocation pool parameters - modify as appropriate. set "JAVA_OPTS=-Xms64M -Xmx512M -XX:MaxPermSize=256M" rem # Reduce the RMI GCs to once per hour for Sun JVMs. set "JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 - Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true" rem # Warn when resolving remote XML DTDs or schemas. set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true" rem # Make Byteman classes visible in all module loaders rem # This is necessary to inject Byteman rules into AS7 deployments set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman" rem # Set the default configuration file to use if -c or --server-config are not used set "JAVA_OPTS=%JAVA_OPTS% -Djboss.server.default.config=standalone.xml" rem # Sample JPDA settings for remote socket debugging rem set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" rem # Sample JPDA settings for shared memory debugging rem set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_shmem,address=jboss,server=y,suspend=n" rem # Use JBoss Modules lockless mode rem set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.lockless=true" :JAVA_OPTS_SET </code></pre> <p>Why?. Thanks so much. Regards</p>
0
Can an oracle SQL query execute a string query selected from a table?
<p>When using oracle SQL is it possible to run a query based on a text_string from a subquery? An example might clarify what I'm trying to do</p> <pre><code> select count(sql_text), sql_text from (select sql_text from query_table) sql_table group by sql_text; </code></pre> <p>The outer query is intended to count the number of results for each query retrieved from the query_table.</p> <p>Is there some way I can execute the sql statements I retrieved from my query_table in the same query?</p> <p>Thanks</p> <p>EDIT: I was able to query sql from a table using the dbms_xmlgen.get_xml() function. I suppose that any command which caused the sql to be parsed and executed would work. That being said, here's the generic code that I was able to accomplish things with:</p> <pre><code> select to_number ( extractvalue( xmltype( dbms_xmlgen.getxml('select count(*) c from '|| table_name)), '/ROWSET/ROW/C'))counter, sql_text from (select '('||sql_text||')' table_name from query_table) sql_table; </code></pre> <p>While perhaps not the most elegant way to do things, it works and is a single sql statement.</p>
0
Change keyboard shortcut in sublime text 2
<p>How do i change the current keys for selecting all with the multiple cursor to CMD + G?</p>
0
Communications link failure due to: java.io.EOFException
<p>My webapp is running on Tomcat 5.5, I declared the datasource in web.xml:</p> <pre><code>&lt;resource-ref&gt; &lt;res-ref-name&gt;jdbc/OrdiniWebDS&lt;/res-ref-name&gt; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt; &lt;res-auth&gt;Container&lt;/res-auth&gt; &lt;res-sharing-scope&gt;Shareable&lt;/res-sharing-scope&gt; &lt;/resource-ref&gt; </code></pre> <p>In context.xml (tomcat conf):</p> <pre><code>&lt;Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/OrdiniWebDS" password="[mypassword]" type="javax.sql.DataSource" url="jdbc:mysql://[myHost:port]/ordiniweb" username="[myusername]" /&gt; </code></pre> <p>The database is a MySql 5.0. Everything works well except that sometimes, after several hours of "unuse", at first access I got this Exception:</p> <pre><code>com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1956) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2368) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2867) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1616) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1708) at com.mysql.jdbc.Connection.execSQL(Connection.java:3255) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1293) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1428) at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at com.blasetti.ordiniweb.dao.OrdiniDAO.caricaOrdine(OrdiniDAO.java:263) ... ** END NESTED EXCEPTION ** Last packet sent to the server was 0 ms ago. com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2579) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2867) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1616) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1708) com.mysql.jdbc.Connection.execSQL(Connection.java:3255) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1293) com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1428) org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) com.blasetti.ordiniweb.dao.OrdiniDAO.caricaOrdine(OrdiniDAO.java:263) ... </code></pre> <p>I need to refresh and it works well again. Any idea? Thanks.</p>
0
Make applications similar to Talking Tom Cat
<p>I want to make an applications similar to Talking Tom Cat, Touch Pets Cats/, Virtual Monkey and the Tap Zoo.</p> <p>I have knowledge of Iphone basic animation.</p> <p>I want to know that can i make these apps without OpenGL ,cocos and other gaming environment... Can i make it by using only basic frameworks...</p>
0
'module' object has no attribute 'basicConfig'
<p>I have the following code, copied from the Python manual:</p> <pre><code>import logging LOG_FILENAME = 'example.log' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('This message should go to the log file') </code></pre> <p>When I try to run the script (via <code>python.exe script.py</code>) I get an error of <code>'module' object has no attribute 'basicConfig'</code>.</p> <p>However when I copy and paste the code in interactive mode (via python.exe then copy and pasting the actual code) I get no error. The code runs fine.</p> <p>I have python 2.6.6.</p> <p>Thank you!</p>
0
How to return an array from a function?
<p>How can I return an array from a method, and how must I declare it?</p> <pre><code>int[] test(void); // ?? </code></pre>
0
The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>
<p>Here is my form:</p> <pre><code>&lt;form action="j_security_check"&gt; &lt;h:panelGrid columns="2" bgcolor="#eff5fa" cellspacing="5" frame="box" styleClass="center"&gt; &lt;h:outputLabel value="User ID:"/&gt; &lt;h:inputText id="j_username" tabindex="1" /&gt; &lt;h:outputLabel value="Password:"/&gt; &lt;h:inputSecret id="j_password"/&gt; &lt;h:outputLabel value=""/&gt; &lt;h:commandButton id="login" value="Login"/&gt; &lt;/h:panelGrid&gt; &lt;/form&gt; </code></pre> <p>It work fine with Glassfish 3.0.1, but since Glassfish 3.1 b2 it shows this warning as a <code>FacesMessage</code> in the JSF page:</p> <blockquote> <p>The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <code>&lt;h:form&gt;</code></p> </blockquote> <p>If I change the <code>&lt;form action="j_security_check"&gt;</code> to <code>&lt;h:form&gt;</code>, it does not fix it, I have to place the <code>&lt;h:form&gt;</code> inside the <code>&lt;h:panelGrid&gt;</code>.</p>
0
How do I format a date with Dart?
<p>I have an instance of <code>DateTime</code> and I would like to format that to a String. How do I do that? I want to turn the date into a string, something like "2013-04-20".</p>
0
CypressError: Timed out retrying: cy.click() failed because this element is detached from the DOM
<p>The dropdown basically takes long to get load itself once the back end response is received. If I put a wait of around 8 seconds, then it works. But, don't want to hard code the wait here. Any idea as what might be going wrong? I couldn't identify the css as well.</p> <pre><code>cy.get('input').last().type(`{selectall}${value}`); cy.get('mat-option &gt; span').then(option =&gt; { if (option.get(0).textContent === 'Loading...') { cy.wait(5000); } }); cy.containsCaseInsensitive(value, 'mat-option').first().scrollIntoView().debug().click(); </code></pre> <p>The error log - </p> <pre><code>CypressError: Timed out retrying: cy.click() failed because this element is detached from the DOM. &lt;mat-option _ngcontent-gcj-c21="" class="mat-option ng-star-inserted" role="option" ng-reflect-value="[object Object]" tabindex="0" id="mat-option-104" aria-disabled="false" style=""&gt;...&lt;/mat-option&gt; Cypress requires elements be attached in the DOM to interact with them. The previous command that ran was: &gt; cy.debug() This DOM element likely became detached somewhere between the previous and current command. Common situations why this happens: - Your JS framework re-rendered asynchronously - Your app code reacted to an event firing and removed the element You typically need to re-query for the element or add 'guards' which delay Cypress from running new commands. https://on.cypress.io/element-has-detached-from-dom </code></pre>
0
What is mean by +srv in mongoDb connection string
<p>I am new to MongoDB and just encountered two types of connection string.</p> <ol> <li><p>mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]</p> </li> <li><p>mongodb+srv://[username:password@]host[/[database][?options]]</p> </li> </ol> <p>I know about the 1st one. But unfamiliar with the (+srv) in the 2nd.</p> <pre><code> let connectionUrl; if (username &amp;&amp; password) connectionUrl = `mongodb://${username}:${password}@${host}:${ port || 27017 }/${databaseName}`; else connectionUrl = `mongodb://${host}:${ port || 27017 }/${databaseName}`; console.log(connectionUrl, &quot;connectionUrlconnectionUrl&quot;); let connection = await mongoose.createConnection(connectionUrl, { useNewUrlParser: true, }); return connection; </code></pre> <p>Now the problem user can enter username, password, hostname, etc...</p> <p>But is there any way to know when to add <em><strong>(+srv)</strong></em> because I was trying with localhost and with MongoDB atlas. Atlas works fine with +srv but in the case of localhost, it's throwing an error.</p>
0
add quotes around variable in ansible variables
<p>I've got problem with one of ansible playbooks (enrise.postgresql).</p> <p>It accepts variable postgresql_listen_addresses (list of values to listen_addresses in /etc/postgresql/9.3/main/postgresql.conf).</p> <p>I want to use value ansible_default_ipv4.address, but ansible provide it without quotes, and postgress wants it with single quotes (like '192.168.0.1').</p> <p>I have variable like this:</p> <pre><code>postgresql_listen_addresses: '{{ [ ansible_default_ipv4.address ] }}' </code></pre> <p>When address is without quotes, postgress complains about unquoted IP address (syntax error).</p> <p>How can I add quotes around value of ansible_default_ipv4.address? </p> <p>Thanks.</p> <p>UPD: </p> <p>I was able to solve it with this ugly code. If someone can better, please help.</p> <pre><code>print_quotes: "'%s'" postgresql_listen_addresses: [ "{{print_quotes|format(ansible_default_ipv4.address) }}" </code></pre>
0
PDOException SQLSTATE[HY000] [1049] Unknown database 'forge' failed
<p>I want to access a Mysql data the first step is to create a new table for "vanvlymen" and I typed mysql> USE vanvlymen; the database changed. and type SHOW tables; showing the available of the tables that the database contains.</p> <pre><code>mysql -u root -p enter password: **** mysql&gt; show databases; -databases- information_schema mysql performance_schema phpmyadmin vanvlymen 5 rows... </code></pre> <p>everything is looking good... I have decide to tell mysql to specify the database I am working on before executing the query as "vanvlymen"</p> <p>app/config/database.php</p> <pre><code> 'mysql' =&gt; array( 'driver' =&gt; 'mysql', 'host' =&gt; 'localhost', 'database' =&gt; 'vanvlymen', 'username' =&gt; 'foobar', 'password' =&gt; 'foobar', 'charset' =&gt; 'utf8', 'collation' =&gt; 'utf8_unicode_ci', 'prefix' =&gt; '', ), </code></pre> <p>save as file go to FileZilla using FTP find a file drag and drop into my live server overwrite the database.php file. </p> <p>I have tried to clear the cache like that </p> <pre><code> php artisan cache:clear php artisan migrate </code></pre> <p>it errors: </p> <pre><code> SQLSTATE[42000] [1049] unknown database 'forge'. </code></pre> <p>Why keeping it said unknown database 'forge' I am excepting to change to vanvlymen database. Should I remove mysql and reinstall? </p> <p>I am using windows 8.1 with laravel 4.2</p> <p>Using phpmyadmin, I know what is the password and username to log in.</p>
0
How to read xlsx file with ExcelJS?
<p>How does the code should look like to get cell A1 value from the file "C:\1.xlsx"? I tried numbers of examples but still didn't managed to get it work.</p> <pre><code>var Excel = require('exceljs'); var workbook = new Excel.Workbook(); workbook.xlsx.readFile("C:\1.xlsx") .then(function() { var worksheet = workbook.getWorksheet('Sheet1'); var cell = worksheet.getCell('A1').value; console.log(cell); }); </code></pre> <p>I see no errors, but it doesn't work.</p>
0
How Can I Fix "TypeError: Cannot mix str and non-str arguments"?
<p>I'm writing some scraping codes and experiencing an error as above. My code is following.</p> <pre><code># -*- coding: utf-8 -*- import scrapy from myproject.items import Headline class NewsSpider(scrapy.Spider): name = 'IC' allowed_domains = ['kosoku.jp'] start_urls = ['http://kosoku.jp/ic.php'] def parse(self, response): """ extract target urls and combine them with the main domain """ for url in response.css('table a::attr("href")'): yield(scrapy.Request(response.urljoin(url), self.parse_topics)) def parse_topics(self, response): """ pick up necessary information """ item=Headline() item["name"]=response.css("h2#page-name ::text").re(r'.*(インターチェンジ)') item["road"]=response.css("div.ic-basic-info-left div:last-of-type ::text").re(r'.*道$') yield item </code></pre> <p>I can get the correct response when I do them individually on a shell script, but once it gets in a programme and run, it doesn't happen.</p> <pre><code> 2017-11-27 18:26:17 [scrapy.core.scraper] ERROR: Spider error processing &lt;GET http://kosoku.jp/ic.php&gt; (referer: None) Traceback (most recent call last): File "/Users/sonogi/envs/scrapy/lib/python3.5/site-packages/scrapy/utils/defer.py", line 102, in iter_errback yield next(it) File "/Users/sonogi/envs/scrapy/lib/python3.5/site-packages/scrapy/spidermiddlewares/offsite.py", line 29, in process_spider_output for x in result: File "/Users/sonogi/envs/scrapy/lib/python3.5/site-packages/scrapy/spidermiddlewares/referer.py", line 339, in &lt;genexpr&gt; return (_set_referer(r) for r in result or ()) File "/Users/sonogi/envs/scrapy/lib/python3.5/site-packages/scrapy/spidermiddlewares/urllength.py", line 37, in &lt;genexpr&gt; return (r for r in result or () if _filter(r)) File "/Users/sonogi/envs/scrapy/lib/python3.5/site-packages/scrapy/spidermiddlewares/depth.py", line 58, in &lt;genexpr&gt; return (r for r in result or () if _filter(r)) File "/Users/sonogi/scraping/myproject/myproject/spiders/IC.py", line 16, in parse yield(scrapy.Request(response.urljoin(url), self.parse_topics)) File "/Users/sonogi/envs/scrapy/lib/python3.5/site-packages/scrapy/http/response/text.py", line 82, in urljoin return urljoin(get_base_url(self), url) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/parse.py", line 424, in urljoin base, url, _coerce_result = _coerce_args(base, url) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/parse.py", line 120, in _coerce_args raise TypeError("Cannot mix str and non-str arguments") TypeError: Cannot mix str and non-str arguments 2017-11-27 18:26:17 [scrapy.core.engine] INFO: Closing spider (finished) </code></pre> <p>I'm so confused and appreciate anyone's help upfront!</p>
0
Implement jQuery confirmation modal in a form submit?
<p>I am using jQuery modal confirmation like this:</p> <pre><code>$(function() { $( "#dialog-confirm" ).dialog({ resizable: false, height:190, width: 330, modal: true, buttons: { "Yes": function() { $( this ).dialog( "close" ); }, No: function() { $( this ).dialog( "close" ); } } }); }); &lt;div id="dialog-confirm" title="Genalytics"&gt; &lt;p&gt;&lt;span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"&gt;&lt;/span&gt;Are you sure want to unshare?&lt;/p&gt; &lt;/div&gt; </code></pre> <p>I have a input button in a form like this:</p> <pre><code>&lt;input type="submit" value="Unshare" name="unshare" /&gt; </code></pre> <p>I want to popup dialog box when user clicks on the button. How can I do that?</p>
0
What is a container manifest?
<p>The only <a href="https://docs.docker.com/registry/spec/manifest-v2-2/" rel="noreferrer">doc</a> on this topic seems to assume I already know what a manifest is, the problem it solves, and how it fits into the docker ecosystem. After reading the doc I'm still not sure how manifests actually work.</p> <p>My private GCR contains manifest files- don't really understand their purpose. Does docker hub also use manifest files? I can see they contain the layers and hashes of each layer, but I'm still unclear on how docker generates/uses them.</p> <p>What is the purpose of a container manifest?</p>
0
Magento: Disable module for any particular store
<p>Suppose, I have 3 stores.</p> <p>I want to disable a module in Store 2. I only want it to be enabled in Store 1 and Store 3.</p> <p>I see that I can do it by:- </p> <ul> <li><p>Going to <strong>System -> Configuration -> Advanced</strong> </p></li> <li><p>Selecting desired store from <strong>Current Configuration Scope</strong> dropdown list.</p></li> </ul> <p>But this does not work fully.</p> <p>And, I also don't want to check store in the module code itself or create system configuration field for the module to check/uncheck store to enable/disable.</p> <p>What I am expecting is by adding some code in <strong>app/etc/modules/MyNamespace_MyModule.xml</strong>. Can we do it this way?</p>
0
How do I use subscript and superscript in Swift?
<p>I want my <code>UILabel</code> to display text in following manner 6.022*10<sup>23</sup>. What functions does Swift have for subscript and superscript?</p>
0
AWS S3: Force File Download using 'response-content-disposition'
<p>Few lines(below) generate signed URL to which browser is redirected to download a file from S3.</p> <p>I am facing well known issue of Chrome not downloading pdf files from S3 when content type is set as Octet Stream.</p> <p>The solution is to force chrome to download file instead of trying to read/open it.</p> <p>I tried adding 'response-content-disposition' to sign as well as URL, but it didn't work.</p> <p>How to use 'response-content-disposition' header when url is to be generated? </p> <pre><code> String codedFilename= EncodingUtil.urlEncode(bucketPath,'UTF-8'); String stringtosign = 'GET\n\n\n'+Lexpires+'\n/'+bucketName+'/'+codedFilename; String signed = make_sig(stringtosign); String codedsigned = EncodingUtil.urlEncode(signed,'UTF-8'); String url = serverURL+'/'+bucketName+'/'+codedFilename+'?AWSAccessKeyId='+awskey+'&amp;Expires='+Lexpires+'&amp;Signature='+codedsigned; </code></pre> <p>Note:- This is salesforce-apex syntax.</p>
0
go tool: no such tool "tour"
<p>I'm trying out Go for the first time. I was following <a href="https://tour.golang.org/welcome/3" rel="noreferrer">these docs</a> and wanted to run the go tour locally, but I haven't figured out how to get it to work. </p> <p>Where is the tool "tour" supposed to be found?<br> I'm on OSX 10.11.3, and I installed Go via Homebrew<br> my Go entries in <code>.zshrc</code></p> <pre><code>export GOPATH=$HOME/code/Go export GOROOT=/usr/local/opt/go/libexec export PATH=$PATH:$GOPATH/bin export PATH=$PATH:$GOROOT/bin </code></pre>
0
C - How do i read all lines of a file
<p>Im unsure how to read all the lines of a file, atm it only reads the first line of the code in the text file. Can someone show me how to make it read all the lines?</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; int main(int argc, char **argv) { FILE *fp; fp = fopen("specification.txt", "r"); char ** listofdetails; listofdetails = malloc(sizeof(char*)*6); listofdetails[0] = malloc(sizeof(char)*100); fgets(listofdetails[0], 100, fp); /*strcpy(listofdetails[0], "cars");*/ printf("%s \n", listofdetails[0]); free(listofdetails[0]); free(listofdetails); fclose(fp); return 0; } </code></pre> <p>MY text file:</p> <pre><code>10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2 10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2 10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2 </code></pre>
0
Python realtime plotting
<p>I acquire some data in two arrays: one for the time, and one for the value. When I reach 1000 points, I trigger a signal and plot these points (x=time, y=value).</p> <p>I need to keep on the same figure the previous plots, but only a reasonable number to avoid slowing down the process. For example, I would like to keep 10,000 points on my graph. The matplotlib interactive plot works fine, but I don't know how to erase the first points and it slows my computer very quickly. I looked into matplotlib.animation, but it only seems to repeat the same plot, and not really actualise it.</p> <p>I'm really looking for a light solution, to avoid any slowing.</p> <p>As I acquire for a very large amount of time, I erase the input data on every loop (the 1001st point is stored in the 1st row and so on).</p> <p>Here is what I have for now, but it keeps all the points on the graph:</p> <pre><code>import matplotlib.pyplot as plt def init_plot(): plt.ion() plt.figure() plt.title("Test d\'acqusition", fontsize=20) plt.xlabel("Temps(s)", fontsize=20) plt.ylabel("Tension (V)", fontsize=20) plt.grid(True) def continuous_plot(x, fx, x2, fx2): plt.plot(x, fx, 'bo', markersize=1) plt.plot(x2, fx2, 'ro', markersize=1) plt.draw() </code></pre> <p>I call the init function once, and the continous_plot is in a process, called every time I have 1000 points in my array.</p>
0
What is the difference between a Local Database in C# and a SQL Server Management Studio created database?
<p>I'm creating an application with MS Visual C# 2010 Express that requires a database.</p> <p>I've learned that there seem to be two ways to create/use a SQL database with this application. </p> <p>The first seems to be where from within C#, I can create a "local database" by right-clicking on my application in the Solution Explorer and clicking "Add"->"New Item"->"Local Database". Then it's shown in the Database Explorer and I can use it. </p> <p>The other way is where I create a database with SQL Server Management Studio and then from within the C# code, I open a connection to it (SQLConnection... yada yada yada) and use it.</p> <p>I'm having a hard time understanding what technical reasons there are between choosing one way or the other way to do this...</p> <p>Can someone describe the differences and what criteria would be used to choose one way vs. the other? (or point to a website reference...)</p> <p>Thanks!</p> <p>-Adeena </p> <p>Additional Info... Right now, this is really a hobby project as I get a few things worked out.</p> <ol> <li>I'm the only developer and working on a single machine </li> <li>The application is intended to be one that runs standalone - not in a browser or over the web in any way. I know that that's not the direction the universe is heading, but as mentioned above, this is a hobby project that I need to complete to work out a few other issues. </li> <li>I don't believe I have any need or intent for multiple applications to work on this database.</li> </ol>
0
css: expand div on hover without displacing other divs
<p>I have the following code :</p> <pre><code>&lt;style&gt; #items {width:300px;} .item {width:100px;border:solid 1px #ccc;float:left;height:20px;overflow:hidden;} .item:hover{height:auto} &lt;/style&gt; &lt;div id="items"&gt; &lt;div class="item"&gt;text 1&lt;br&gt;text 1&lt;br&gt;text 1&lt;/div&gt; &lt;div class="item"&gt;text 2&lt;br&gt;text 2&lt;br&gt;text 2&lt;/div&gt; &lt;div class="item"&gt;text 3&lt;br&gt;text 3&lt;br&gt;text 3&lt;/div&gt; &lt;div class="item"&gt;text 4&lt;br&gt;text 4&lt;br&gt;text 4&lt;/div&gt; &lt;div class="item"&gt;text 5&lt;br&gt;text 5&lt;br&gt;text 5&lt;/div&gt; &lt;div class="item"&gt;text 6&lt;br&gt;text 6&lt;br&gt;text 6&lt;/div&gt; &lt;div class="item"&gt;text 7&lt;br&gt;text 7&lt;br&gt;text 7&lt;/div&gt; &lt;div class="item"&gt;text 8&lt;br&gt;text 8&lt;br&gt;text 8&lt;/div&gt; &lt;div class="item"&gt;text 9&lt;br&gt;text 9&lt;br&gt;text 9&lt;/div&gt; &lt;div class="item"&gt;text 10&lt;br&gt;text 10&lt;br&gt;text 10&lt;/div&gt; &lt;/div&gt; </code></pre> <p>see it in action : <a href="http://jsfiddle.net/6K7t4/" rel="noreferrer">http://jsfiddle.net/6K7t4/</a></p> <p>when a div id hovered, it should expand without displacing other divs as shown at : <a href="http://shopping.kelkoo.co.uk/ss-shirt.html" rel="noreferrer">http://shopping.kelkoo.co.uk/ss-shirt.html</a></p> <p>Also, please suggest how to achieve a cross-browser solution.</p> <p>If it can be done using pure css, I prefer that solution.</p> <p>If not, can it be done using jquery in an easy way without plugins?</p>
0
replace column values in one dataframe by values of another dataframe
<p>I have two dataframes, the first one has 1000 rows and looks like:</p> <pre><code>Date Group Family Bonus 2011-06-09 tri23_1 Laavin 456 2011-07-09 hsgç_T2 Grendy 679 2011-09-10 bbbj-1Y_jn Fantol 431 2011-11-02 hsgç_T2 Gondow 569 </code></pre> <p>The column <code>Group</code> has different values, sometimes repeated, but in general about 50 unique values.</p> <p>The second dataframe contains all these 50 unique values (50 rows) and also the hotels, that are associated to these values:</p> <pre><code>Group Hotel tri23_1 Jamel hsgç_T2 Frank bbbj-1Y_jn Luxy mlkl_781 Grand Hotel vchs_94 Vancouver </code></pre> <p>My goal is to replace the value in the column <code>Group</code> of the first dataframe by the corresponding values of the column <code>Hotel</code> of the second dataframe/or create the column <code>Hotel</code> with the corresponding values. When I try to make it just by assignment like</p> <pre><code>df1.loc[(df1.Group=df2.Group), 'Hotel']=df2.Hotel </code></pre> <p>I have an error that the dataframes are not of equal size, so the comparison is not possible.</p>
0
Joining multiple tables using Entity Framework
<p>i am trying to join 3 tables using EF but it throws an error saying </p> <pre><code>consider swaping conditions on either side of equals </code></pre> <p>can some one pls help</p> <pre><code> var billdata = from billtotal in context.billTotals join billcard in context.billClubcards on billtotal.OrderID equals billcard.OrderID join billtender in context.billTenders on billtender.OrderID equals billtotal.OrderID select billtotal; </code></pre>
0
Javascript TypeError: xxx is not a function
<p>Friends I came to a bit of problem. Everything was working fine before. But I can't rectify why it starts giving me such error.<br> Here is my JavaScript Code:</p> <pre><code>function newSupplier() { $('div#AddSupplier div.msg').html('').hide(); $('div#AddSupplier div.loader').show(); registerSupplier($('div#AddSupplier table.frm :input').serialize()).done(function (a) { if (a.Msg) { $('div#AddSupplier div.msg').html(a.Msg).removeClass('success').addClass('error').fadeIn(); } else if (a.supid) { $('div#AddSupplier div.msg').html('Supplier &lt;span class="l2"&gt;' + a.supid + '&lt;/span&gt; Registered').removeClass('error').addClass('success').fadeIn(); $('div#AddSupplier table.frm :input').val(''); } }).always(function () { $('div#AddSupplier div.loader').hide(); }).fail(function () { $('div#AddSupplier div.msg').html(errMsgNet).removeClass('success').addClass('error').fadeIn(); }); } </code></pre> <p>And here is the code of <code>registerSupplier()</code> function:</p> <pre><code>function registerSupplier(dataToPost) { return $.ajax({ type: "POST", url: jsonpath + 'Json.ashx?method=RegisterSupplier', data: dataToPost }); } </code></pre> <p>And here is the complete JS file: <a href="http://preview.myignou.com/Docs/jScript.js">http://preview.myignou.com/Docs/jScript.js</a></p> <p>Related HTML </p> <pre><code>&lt;div id="ViewOrder"&gt; &lt;h2&gt;View Order Details&lt;/h2&gt; &lt;div class="tab-content"&gt; &lt;table class="frm"&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Enter Order Number&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="orderNumber" onkeyup="$('#ViewOrder&gt;div&gt;div').fadeOut();" /&gt;&lt;input type="button" class="but1 m-side" value="OK" onclick="LoadMaterialOrder();"/&gt;&lt;/td&gt; &lt;td&gt; &lt;div class="process"&gt;&amp;nbsp;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div&gt; &lt;div class="border shadow m-tb"&gt; &lt;h2 class="header"&gt;Order Details&lt;/h2&gt; &lt;div id="orderDetails" class="tab-content"&gt; &lt;table class="frm"&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Supplier&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;select id="newSupplier" name="supplier"&gt;&lt;/select&gt;&lt;/td&gt; &lt;td class="r-align"&gt;&lt;input type="button" value="Load Suppliers" onclick="loadSuppliers('#newSupplier')" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Order Date&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="orderDate" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Delivery Date&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="deliveryDate" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Cancel Date&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="cancelDate" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Payment Due Mark&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input id="payDue2" type="checkbox" name="isPayDue" /&gt;&lt;label for="payDue2"&gt;Yes&lt;/label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Remember Mark&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input id="remark2" type="checkbox" name="isMarked" /&gt;&lt;label for="remark2"&gt;Yes&lt;/label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;table class="footer-buttons"&gt; &lt;tr&gt; &lt;td&gt; &lt;div class="msg"&gt;&lt;/div&gt; &lt;div class="loader" style="display:none;"&gt;&lt;img alt="loader" src="CSS/Images/loader.gif" /&gt;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="button" class="but1 sub-but" value="Save Changes" onclick=""/&gt;&lt;input type="reset" value="Reset" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;br /&gt; &lt;div class="border shadow m-tb"&gt; &lt;h2 class="header"&gt;Payment Records&lt;/h2&gt; &lt;div id="paymentHistory" class="tab-content"&gt; &lt;table class="tab pay-his"&gt; &lt;tr class="th"&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;Trans#&lt;/td&gt; &lt;td&gt;Date&lt;/td&gt; &lt;td&gt;Comment&lt;/td&gt; &lt;td&gt;Type&lt;/td&gt; &lt;td&gt;Credit&lt;/td&gt; &lt;td&gt;Debit&lt;/td&gt; &lt;td&gt;Balance&lt;/td&gt; &lt;td&gt;Associated Agent&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="radio" name="paySelect" /&gt;&lt;/td&gt; &lt;td&gt;101-1&lt;/td&gt; &lt;td&gt;12-12-12&lt;/td&gt; &lt;td&gt;Abclk lask aa&lt;/td&gt; &lt;td&gt;Credit&lt;/td&gt; &lt;td&gt;500&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;500.00&lt;/td&gt; &lt;td&gt;Shashwat Tripathi&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="radio" name="paySelect" /&gt;&lt;/td&gt; &lt;td&gt;101-2&lt;/td&gt; &lt;td&gt;12-12-12&lt;/td&gt; &lt;td&gt;Shashwat Tripathi&lt;/td&gt; &lt;td&gt;Debit&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;500&lt;/td&gt; &lt;td&gt;500.00&lt;/td&gt; &lt;td&gt;Sudhir&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="radio" name="paySelect" /&gt;&lt;/td&gt; &lt;td&gt;101-3&lt;/td&gt; &lt;td&gt;12-12-12&lt;/td&gt; &lt;td&gt;Shashwat Tripathi&lt;/td&gt; &lt;td&gt;Credit&lt;/td&gt; &lt;td&gt;500&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;500.00&lt;/td&gt; &lt;td&gt;Sudhir Gaur&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;input type="button" class="but2" value="Edit" onclick="$('#ViewOrder #payEdit').slideDown(function () { $('html, body').animate({ scrollTop: $('#paymentHistory').offset().top-20 }, 500); });" /&gt;&lt;input type="button" class="but2 m-side" value="Delete" /&gt; &lt;div id="payEdit" class="border m-tb shadow" style="display:none;"&gt; &lt;h2 class="header"&gt;Edit Payment&lt;/h2&gt; &lt;div class="tab-content"&gt; &lt;table class="frm"&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Date&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="date" placeholder="dd-mm-yy"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Type&lt;/label&gt;&lt;/td&gt; &lt;td&gt; &lt;select name="type"&gt; &lt;option&gt;Credit&lt;/option&gt; &lt;option&gt;Debit&lt;/option&gt; &lt;option&gt;Expense&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Amount&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="amount" placeholder="धनराशी..." /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Comment&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name="comment" rows="4" cols="10"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="button" class="but1" value="Save Changes" /&gt;&lt;input type="button" class="but2 m-side" onclick="$('#payEdit').slideUp();" value="Cancel" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;br /&gt; &lt;h2&gt;Register New Payment&lt;/h2&gt; &lt;hr /&gt; &lt;div id="newMatOrderPayment"&gt; &lt;table class="frm"&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Date&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="date" placeholder="dd-mm-yy" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Type&lt;/label&gt;&lt;/td&gt; &lt;td&gt; &lt;select name="type"&gt; &lt;option&gt;Credit&lt;/option&gt; &lt;option&gt;Debit&lt;/option&gt; &lt;option&gt;Expense&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Amount&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="amount" placeholder="धनराशी..." /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Comment&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name="comment" rows="4" cols="10"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;table class="footer-buttons"&gt; &lt;tr&gt; &lt;td&gt; &lt;div class="msg"&gt;&lt;/div&gt; &lt;div class="loader" style="display:none;"&gt;&lt;img alt="loader" src="CSS/Images/loader.gif" /&gt;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="button" class="but1" value="Register Payment" onclick=""/&gt;&lt;input type="button" class="but2" onclick="$('#NewMatOrderPayment :text').val('');" value="Reset" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="AddSupplier"&gt; &lt;h2&gt;Register New Suppiler&lt;/h2&gt; &lt;div class="tab-content"&gt; &lt;table class="frm"&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Supplier ID&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="supId" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Contact Number&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="contact" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Address&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name="address" cols="10" rows="4"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Email address&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="email" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;City&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="city" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;table class="footer-buttons"&gt; &lt;tr&gt; &lt;td&gt; &lt;div class="msg"&gt;&lt;/div&gt; &lt;div class="loader" style="display:none;"&gt;&lt;img alt="loader" src="CSS/Images/loader.gif" /&gt;&lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="button" class="but1 sub-but" value="Register" onclick="newSupplier();"/&gt;&lt;input type="reset" value="रीसेट" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>If I am calling this function directly from FF and Firebug console then It is getting called.<br> <strong>But on button click I am getting error <code>TypeError: newSupplier is not a function</code></strong></p> <p>Please ask me If u need additional code.</p>
0
Eclipse: Open in New Window
<p>In Package Explorer I right-clicked on project and selected "Open in New Window". New Eclipse window was opened with that project. Then I closed old, "main" Eclipse window, so only new "project" window remained.</p> <p>Now each time I launch Eclipse I have this "project" window with project name in window title and Package Explorer drilled down into this project. And I need to press "Up" button in Package Explorer to see all my projects.</p> <p>How can I restore default behaviour and launch Eclipse with workspace scope and not project?</p>
0
converting QdateTime to normal python dateTime?
<p>I have a lot of existing code that just uses the normal <code>dateTime</code> class in python, however in upgrading my program I am using the <code>QtGui.QdateTimeEdit()</code> class, but that class returns a <code>QdateTime</code> object that seems to be incompatible with the normal <code>dateTime</code> object. </p> <p>So, is there a sane way to convert <code>QdateTime</code> to normal python <code>dateTime</code>? Other then breaking it into its parts and recreating a normal <code>dateTime</code> object from that? I am using PyQt4 with Python 3.2. Thanks.</p>
0
Python - access global list in function
<p>I am new to Python, Before this, I was using C.</p> <pre><code>def cmplist(list): #Actually this function calls from another function if (len(list) &gt; len(globlist)): globlist = list[:] #copy all element of list to globlist # main globlist = [1, 2, 3] lst = [1, 2, 3, 4] cmplist(lst) print globlist </code></pre> <p>When I execute this code it shows following error</p> <pre><code> if (len(list) &gt; len(globlist)): NameError: global name 'globlist' is not defined </code></pre> <p>I want to access and modify globlist from a function without passing it as an argument. In this case output should be</p> <pre><code>[1, 2, 3, 4] </code></pre> <p>Can anyone help me to find the solution?</p> <p>Any suggestion and correction are always welcome. Thanks in advance.</p> <p><strong>Edit:</strong> Thanks Martijn Pieters for suggestion. Origional error is </p> <pre><code>UnboundLocalError: local variable 'globlist' referenced before assignment </code></pre>
0
Xcode 6 won't let me develop on my iOS 8 phone
<p>I was developing an application with iOS 7, and I just updated to the beta of iOS 8. I downloaded Xcode 6 beta and now when I plug my phone in, it lists my phone under "Ineligible devices" and won't let me develop on it. Why is this?</p>
0
Why does Request.Cookies return string instead of HttpCookie object in foreach loop?
<p>This morning I accidentally saw the following snippet code, I was fairly surprised because it work very well.</p> <p>Don't look at its logic please, I'm just curious why does the HttpCookieCollection (Request.Cookies in this case) return a string (cookie name) instead of a HttpCookie object in foreach loop. Is it a consistency issue because we normally get HttpCookie object in this collection by index/name?</p> <p>Thanks,</p> <pre><code>foreach (string cookieKey in System.Web.HttpContext.Current.Request.Cookies) { HttpCookie tmpCookie = System.Web.HttpContext.Current.Request.Cookies[cookieKey]; if (tmpCookie != null &amp;&amp; tmpCookie["RecentlyVisited"] != null) { cookie.Add(tmpCookie); } } </code></pre>
0
Can I use JavaScript to create a client side email?
<p>I want to create a client side mail creator web page. I know the problems of using the mailto action in an html form (not standard, no default mail appication set on the client). But the web page isn't very important, and they don't care very much.</p> <p>The mail created by the mailto action has the syntax:</p> <blockquote> <p>subject: undefined subject<br> body:</p> <p>param1=value1<br> param2=value2<br> .<br> .<br> .<br> paramn=valuen </p> </blockquote> <p>Can I use JavaScript to format the mail like this?</p> <blockquote> <p>Subject:XXXXX</p> <p>Body: Value1;Value2;Value3...ValueN</p> </blockquote>
0
preg_match_all JS equivalent?
<p>Is there an equivalent of PHP's preg_match_all in Javascript? If not, what would be the best way to get all matches of a regular expression into an array? I'm willing to use any JS library to make it easier.</p>
0
How to configure git to avoid accidental git push
<p>After git clone, the config in the new repo looks like:</p> <pre><code>remote.origin.url=&lt;some url&gt; remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master </code></pre> <p>Then, I can execute "git pull" and "git push". But I'm interested in only do "git pull", because I want to push into another repo.</p> <p>One thing I can do is:</p> <pre><code>git add remote repo-for-push &lt;some other url&gt; git push repo-for-push master </code></pre> <p>But I would like to configure git to use default and distinct repositories for pull and push, i.e:</p> <pre><code>git pull # pulls from origin git push # pushes into repo-for-push, avoiding accidental push into the origin </code></pre> <p>How can this be configured? Thanks in advance.</p> <p>EDIT:<br> Basically, I want to setup the default push repo to be different from the default fetch/pull repo.</p>
0
DefaultCredentials in Accessing CRM / Sharepoint Web Services
<p>I made an application that access CRM's web service. The problem is, when I deployed the dll into Sharepoint server, it returned error 401 unauthorized. Apparently the System.Net.CredentialCache.DefaultCredentials didn't work (my suspicion). Here's the code.</p> <pre><code>CrmSdk.CrmAuthenticationToken token = new CrmSdk.CrmAuthenticationToken(); token.AuthenticationType = AuthenticationType.AD; token.OrganizationName = ORGANIZATION_NAME; CrmService service = new CrmService(); service.Url = "http://crmserver:5555/mscrmservices/2007/crmservice.asmx"; service.CrmAuthenticationTokenValue = token; service.PreAuthenticate = true; service.Credentials = System.Net.CredentialCache.DefaultCredentials; </code></pre> <p>It goes vice-versa.</p> <p>When I made application that access Sharepoint's webservice (coding the plugin) and deployed it to CRM server. It couldn't access the Sharepoint's web service. Unauthorized error. Here is the code:</p> <pre><code>Lists listService = new Lists(); listService.PreAuthenticate = true; listService.Credentials = System.Net.CredentialCache.DefaultCredentials; listService.Url = "http://sharepointserver/webname/_vti_bin/Lists.asmx"; </code></pre> <p>My CRM server and Sharepoint server are in the same domain.</p> <p>For both code, if I changed the credentials part into something like this then deploy it on server, it can run.</p> <pre><code>service.Credentials = new NetworkCredential("username", "password", "domain"); </code></pre> <p>Still, I don't want to do this because it reveals user's password in the code. May anyone help me?</p> <p>The IIS in both server doesn't allow Anonymous Access and it uses Integrated Windows Authentication. </p> <p>Thank you</p> <hr> <p>From my local computer, I can access the CRM web services or Sharepoint web services. I guess I'm authorized because the DefaultCredentials sent my credentials that its password is saved in the "<strong>Stored Username and Password</strong>" (<em>Control Panel > User Accounts > tab Advanced > Manage Passwords</em>) This way, I don't have to type:</p> <pre><code>service.Credentials = new NetworkCredential("username", "password", "domain"); </code></pre> <p>and my DefaultCredentials from my local comp is authorized to access the web services.</p> <p>I tried to implement this on the Sharepoint server that access CRM web services. and..tadaa..it won't work. hahaha.. </p> <p>can we inject credentials to DefaultCredentials in server?</p> <p>the last thing I want to do is to hardcode the useraccount (like the code above)</p>
0
Python decorators: how to use parent class decorators in a child class
<p><strong>Note</strong>:</p> <p><em>The accepted answer on the other question shows how to use the parent decorater.</em></p> <p><em>The accepted answer on this question shows moving the decorator to the module scope.</em></p> <hr> <p>EDIT: Using the previous example was a bad idea. Hopefully this is more clear:</p> <pre><code>class A: def deco( func ): print repr(func) def wrapper( self, *args ): val = func( *args ) self.do_something() return val return wrapper def do_something( self ): # Do something print 'A: Doing something generic for decoration' @deco def do_some_A_thing ( self ): # Do something print 'A: Doing something generic' class B ( A ): @deco def do_some_B_thing( self ): # Do something print "B: Doing something specific" a = A() b = B() a.do_some_A_thing() b.do_some_B_thing() #Expected Output: #A: Doing something generic #A: Doing something generic for decoration #B: Doing something specific #A: Doing something generic for decoration </code></pre> <p>This code generates a NameError: name 'deco' is not defined inside B. The decorator needs to be inside the class scope because I require access to stored state. </p> <p>Third Edit: On Sven's suggestions, I tried this:</p> <pre><code>class A: def deco( func ): def wrapper( self, *args ): val = func( *args ) self.do_something(*args) return val return wrapper def do_something( self ): # Do something print 'A: Doing something generic for decoration' @deco def do_some_A_thing ( self ): # Do something print 'A: Doing something generic' deco = staticmethod(deco) class B ( A ): @A.deco def do_some_B_thing( self ): # Do something print "B: Doing something specific" a = A() b = B() a.do_some_A_thing() b.do_some_B_thing() #Expected Output: #A: Doing something generic #A: Doing something generic for decoration #B: Doing something specific #A: Doing something generic for decoration </code></pre> <p>I now have have TypeError: do_some_A_thing() takes exactly 1 argument (0 given). Any pointers?</p>
0
New Project: Ruby on Rails or Symfony2 ( or other framework)
<p>I am about to start a new project and I am hung up on which language/framework to use. I've been a PHP programmer professionally, but it wasn't on the scale of this project. I've played around with RoR and i've been very impressed so far. Right now, the two leading candidtates are RoR and Symfony2.</p> <p>My major hang ups with RoR: - i don't know ruby, or i hardly do. i can read it ok, but get stuck writing the code. - i've read complaints about it being slow, and it seems to be slow just at the CLI.</p> <p>My major hang ups with Symfony2: - there's practically no documentation for it. Symfony1.x? sure..but not symfony2 - there's also little support. the BB on their site is like 80% spam. - went to install it on a local dev enviroment haven't been able to even get that running (see my first hang up)</p> <p>this project will be fairly complex and go beyond the basic CRUD operations. it isn't under a super-tight timeline, but there is one. ~3 months for milestone1 which is basically a calendar, some financial organization stuff (not transactions with financial institutions, just personal finance organization type stuff), and a project manager/cms.</p> <p>also, i'm open to using other frameworks, but symfony2 seems to be the best right now. if symfony2 had RoR's support/documentation/tutorials/etc it would be a no brainer.</p> <p>i'm really interested in hearing what the stackoverflowverse has to say on the matter. im constantly impressed with the quality of the answers/replies on this site. </p> <p>some other sub-questions (that are in my head right now): - if you recommend a different php framework, why? - what are you biggest gripes with any of the options mentioned?</p> <p>i know CakePHP is the closest to RoR, but i've been reading that the models are a bit wonky (Many to many relationships and such).</p> <p>right now, i'm leaning towards RoR. Simply put, i really want to learn it and it could do the job. i just don't know ruby and i've ready a lot of good about symfony2.</p> <p>any advice you could offer will be greatly appreciated. thanks!</p>
0
Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'aspNetCore
<p>I have recently published my ASP.NET Core application to my host. I am hitting a HTTP Error 500.19.</p> <p>IIS 8.5 says the issue is:-</p> <p><strong>"Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'aspNetCore'"</strong></p> <p>It also highlights this key add line in my system.webServer config:-</p> <pre><code>&lt;handlers&gt; &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" &lt;/handlers&gt; </code></pre> <p>I'm not really sure what to do on this. It looks as though there is a duplicate instance of this, so I have tried renaming this but it still asks to add this again?</p> <p>Here is my web.config:-</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;!-- Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380 --&gt; &lt;system.webServer&gt; &lt;handlers&gt; &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /&gt; &lt;/handlers&gt; &lt;aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/&gt; &lt;/system.webServer&gt; &lt;system.net&gt; &lt;defaultProxy useDefaultCredentials="true" &gt; &lt;/defaultProxy&gt; &lt;/system.net&gt; &lt;/configuration&gt; </code></pre>
0
How to properly catch a 404 error in .NET
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1949610/c-how-can-i-catch-a-404">How can I catch a 404?</a> </p> </blockquote> <p>I would like to know the proper way to catch a 404 error with c# asp.net here is the code I'm using</p> <pre><code>HttpWebRequest request = (HttpWebRequest) WebRequest.Create(String.Format("http://www.gravatar.com/avatar/{0}?d=404", hashe)); // execute the request try { //TODO: test for good connectivity first //So it will not update the whole database with bad avatars HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Response.Write("has avatar"); } catch (Exception ex) { if (ex.ToString().Contains("404")) { Response.Write("No avatar"); } } </code></pre> <p>This code works but I just would like to know if this is the most efficient.</p>
0
2 different types of custom UITableViewCells in UITableView
<p>in my UITableView i want to set for the first news of an rss feed a custom tableViewCell(Type A lets say) and for the other news second, third etc.. another custom tableViewCell(trype B) the problem is that the custom tableViewCell(trype A) created for the first news is reused, but curiously the number of rows between the first use of the customViewCell(type A) and the second appearance of the same type of customViewCell is not equal..</p> <p>my cellForRowAtIndexPath it looks like this.</p> <pre><code>- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ int feedIndex = [indexPath indexAtPosition:[indexPath length] - 1]; Feed *item = [[[[self selectedButton] category] feedsList] objectAtIndex:feedIndex + 1]; static NSString *CellIdentifier = @"Cell"; if(feedIndex == 0){ MainArticleTableViewCell *cell = (MainArticleTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[MainArticleTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; [[[cell subviews] objectAtIndex:0] setTag:111]; } cell.feed = item; return cell; } else{ NewsTableViewCell *cell = (NewsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[NewsTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier orientation:currentOrientation] autorelease]; [[[cell subviews] objectAtIndex:0] setTag:111]; } cell.feed = item; return cell; } return nil; } </code></pre> <p>the the two types of cells have different heights which is set correctly. could someone point me in the right direction on how to make the type A custom cell to appear only for the first news(not being reused)? thank you</p>
0
Database design for a survey
<p>I need to create a survey where answers are stored in a database. I'm just wondering what would be the best way to implement this in the database, specifically the tables required. The survey contains different types of questions. For example: text fields for comments, multiple choice questions, and possibly questions that could contain more than one answer (i.e. check all that apply).</p> <p>I've come up with two possible solutions:</p> <ol> <li><p>Create a giant table which contains the answers for each survey submission. Each column would correspond to an answer from the survey. i.e. SurveyID, Answer1, Answer2, Answer3</p> <p>I don't think this is the best way since there are a lot of questions in this survey and doesn't seem very flexible if the survey is to change.</p></li> <li><p>The other thing I thought of was creating a Question table and Answer table. The question table would contain all the questions for the survey. The answer table would contain individual answers from the survey, each row linked to a question.</p> <p>A simple example:</p> <p><strong>tblSurvey</strong>: SurveyID</p> <p><strong>tblQuestion</strong>: QuestionID, <em>SurveyID</em>, QuestionType, Question </p> <p><strong>tblAnswer</strong>: AnswerID, <em>UserID</em>, <em>QuestionID</em>, Answer</p> <p><strong>tblUser</strong>: UserID, UserName</p> <p>My problem with this is that there could be tons of answers which would make the Answer table pretty huge. I'm not sure that's so great when it comes to performance.</p></li> </ol> <p>I'd appreciate any ideas and suggestions.</p>
0
Creating a simple black image with opencv using cvcreateimage
<p>Very basic question coming from a newbie in OpenCV. I just want to create an image with every pixel set to <code>0</code> (black). I have used the following code in the main() function:</p> <pre><code>IplImage* imgScribble = cvCreateImage(cvSize(320, 240), 8, 3); </code></pre> <p>And what I get is a solid gray image, instead of the black one.</p> <p>Thanks in advance !</p>
0
Python 3, module 'itertools' has no attribute 'ifilter'
<p>I am new at Python, trying to build an old python file into Python 3. I got several build errors which I solved. But at this point I am getting above error. I have no idea how to fix this. The code section looks like below.</p> <pre><code>return itertools.ifilter(lambda i: i.state == "IS", self.storage) </code></pre>
0
django admin many-to-many intermediary models using through= and filter_horizontal
<p>This is how my models look:</p> <pre><code>class QuestionTagM2M(models.Model): tag = models.ForeignKey('Tag') question = models.ForeignKey('Question') date_added = models.DateTimeField(auto_now_add=True) class Tag(models.Model): description = models.CharField(max_length=100, unique=True) class Question(models.Model): tags = models.ManyToManyField(Tag, through=QuestionTagM2M, related_name='questions') </code></pre> <p>All I really wanted to do was add a timestamp when a given manytomany relationship was created. It makes sense, but it also adds a bit of complexity. Apart from removing the .add() functionality [despite the fact that the only field I'm really adding is auto-created so it technically shouldn't interfere with this anymore]. But I can live with that, as I don't mind doing the extra <code>QuestionTagM2M.objects.create(question=,tag=)</code> instead if it means gaining the additional timestamp functionality. </p> <p>My issue is I really would love to be able to preserve my <code>filter_horizontal</code> javascript widget in the admin. I know the docs say I can use an inline instead, but this is just too unwieldy because there are no additional fields that would actually be in the inline apart from the foreign key to the <code>Tag</code> anyway. </p> <p>Also, in the larger scheme of my database schema, my <code>Question</code> objects are already displayed as an inline on my admin page, and since Django doesn't support nested inlines in the admin [yet], I have no way of selecting tags for a given question. </p> <p>Is there any way to override <code>formfield_for_manytomany(self, db_field, request=None, **kwargs)</code> or something similar to allow for my usage of the nifty <code>filter_horizontal</code> widget and the auto creation of the <code>date_added</code> column to the database? </p> <p>This seems like something that django should be able to do natively as long as you specify that all columns in the intermediate are automatically created (other than the foreign keys) perhaps with <code>auto_created=True</code>? or something of the like</p>
0
How to reset / change password in Node.js with Passport.js?
<p>I use Passport.js in Node.js to create a login system. Everything is ok, but I do not know how to reset user password when they forget their password or they want to change it. </p> <p>User model in MongoDB</p> <pre><code>var UserSchema = new Schema({ email: String, username: String, provider: String, hashed_password: String, salt: String, }); </code></pre>
0
PHPMailer: Using remote SMTP server, works under localhost, Connection refused (111) on remote server
<p>I've got a bizarre problem here. I'm trying to use PHPMailer to send an email, through SMTP. I have a website hosted by GoDaddy and it's that SMTP account that I'm trying to use to send the mail.</p> <ol> <li>It works if I execute my PHP file on my localhost server.</li> <li>It does not work if I execute my PHP file on GoDaddy's server.</li> </ol> <p>The error message I get is:</p> <p><code>SMTP -&gt; ERROR: Failed to connect to server: Connection refused (111)</code></p> <p>I checked <code>phpinfo</code> on both localhost and the remote server. Both have <code>smtp_port</code> listed as <code>25</code>. I'm using WAMP on my machine and the server is some form of Linux (which I know nothing about and have no idea how to administer).</p> <p>Here is the code in question:</p> <p><strong>INDEX.PHP</strong>:</p> <pre><code>&lt;?php date_default_timezone_set('America/Los_Angeles'); include_once("phpmailer/class.phpmailer.php"); $mail = new PHPMailer; $mail-&gt;SMTPDebug = 1; $mail-&gt;Port = 25; $mail-&gt;IsSMTP(); $mail-&gt;Host = 'smtpout.secureserver.net'; $mail-&gt;SMTPAuth = true; $mail-&gt;Username = '[email protected]'; $mail-&gt;Password = 'super_secret_password'; $mail-&gt;SMTPSecure = ''; // tried ssl and tls, with same result $mail-&gt;ClearAddresses(); $mail-&gt;AddAddress('[email protected]', 'Receiver Name'); $mail-&gt;From = "[email protected]"; $mail-&gt;FromName = "Username"; $mail-&gt;Subject = 'Hi there'; $mail-&gt;Body = "This is a message"; if ($mail-&gt;Send()) { echo "Message sent!\n"; } else { echo "Message failed!\n"; print_r($mail-&gt;ErrorInfo); } exit(); ?&gt; </code></pre>
0
Entity Framework Core does not save related data
<p>In continuation of yesterday's <a href="https://stackoverflow.com/questions/40364084/ef-core-cannot-insert-the-value-null-into-column-with-default-value">post</a></p> <p>Two Entities</p> <pre><code>public class Realtor { public Realtor() { Guid = Guid.NewGuid(); Registration = DateTime.Now; } public int Id { get; set; } public Guid Guid { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public DateTime Registration { get; set; } public int SubdivId { get; set; } public Subdiv Subdiv { get; set; } } public class Subdiv { public Subdiv() { Created = DateTime.Now; } public int Id { get; set; } public string Name { get; set; } public DateTime Created { get; set; } public List&lt;Realtor&gt; Realtors { get; set; } } </code></pre> <p>I spend test</p> <ol> <li>I added one Subdiv (TOSTER TM) and received his ID</li> <li><p>Next, I add a Realtor and I push Subdiv property found on the ID, the newly created TOSTER TM Realtor.Subdiv is an object of type Subdiv. OK. <a href="https://i.stack.imgur.com/v52UG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v52UG.jpg" alt="enter image description here"></a></p></li> <li><p>Then I try to select from the base the newly added Realtor. <code>Realtor.Subdiv = null</code> OMG!! <a href="https://i.stack.imgur.com/8c0P0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8c0P0.jpg" alt="enter image description here"></a></p></li> <li><p>We get Subdiv object, which is lacking in Realtor above and see his <code>List&lt;Realtor&gt; = null</code></p></li> </ol> <p><a href="https://i.stack.imgur.com/E41Bc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E41Bc.jpg" alt="enter image description here"></a></p> <p>Please help in solving this problem.</p>
0
Google Analytics doesn't work on new iOS project
<p>I have created a new iOS project and added Google Analytics support following by official instructions. </p> <p>I've added to Frameworks:</p> <pre><code>libGoogleAnalyticsServices.a AdSupport.framework CoreData.framework SystemConfiguration.framework libz.dylib </code></pre> <p>But it doesn't work with the errors:</p> <pre><code>ld: warning: directory not found for option '-L/Users/.../Sources/GoogleAnalytics' Undefined symbols for architecture armv7: "_OBJC_CLASS_$_NSManagedObjectModel", referenced from: objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o) "_OBJC_CLASS_$_NSAttributeDescription", referenced from: objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o) "_OBJC_CLASS_$_NSEntityDescription", referenced from: objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o) objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o) "_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from: objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o) "_OBJC_CLASS_$_NSFetchRequest", referenced from: objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o) "_OBJC_CLASS_$_NSManagedObjectContext", referenced from: objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o) "_NSSQLiteErrorDomain", referenced from: -[GAIDataStore performBlockAndWait:withError:] in libGoogleAnalyticsServices.a(GAIDataStore.o) "_NSSQLiteStoreType", referenced from: -[GAIDataStore coordinatorWithModel:URL:] in libGoogleAnalyticsServices.a(GAIDataStore.o) "_NSOverwriteMergePolicy", referenced from: -[GAIDataStore contextWithModel:URL:] in libGoogleAnalyticsServices.a(GAIDataStore.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) </code></pre> <p>How can I fix it? And does it support <strong>arm64</strong>?</p>
0
Function convert Hex String to BitArray C#
<p>I created the following function which will do as requested (convert HEX string to BitArray). I am not sure about the efficiency of the function, but my main problem now is that the <strong>Convert.ToInt64</strong> function is <em>endian specific</em>. When this is ported over to alternate chipsets we will get different results (or exceptions). So can anyone think of an alternate way to do this conversion???</p> <pre><code>public BitArray convertHexToBitArray(string hexData) { string binary_values = ""; BitArray binary_array; if (hexData.Length &lt;= "FFFFFFFFFFFFFFFF".Length) // Max Int64 { binary_values = Convert.ToString(Convert.ToInt64(hexData, 16), 2); binary_array = new BitArray(binary_values.Length); for (int i = 0; i &lt; binary_array.Length; i++) { if (binary_values[i] == '0') { binary_array[i] = false; } else { binary_array[i] = true; } } } } </code></pre> <p>I removed most of the error / exception handling to keep this to size so plz forgive that. </p>
0
How to initiate array element to 0 in bash?
<pre><code>declare -a MY_ARRAY=() </code></pre> <p>Does the declaration of array in this way in bash will initiate all the array elements to 0?</p> <p>If not, How to initiate array element to 0?</p>
0
How to use RESTEasy client framework to send data in a POST
<p>I am using the RESTEasy client framework to call a RESTful webservice. The call is made via a POST and sends some XML data to the server. How do I accomplish this?</p> <p>What is the magical incantation of annotations to use to make this happen?</p>
0
Failed to build Android app (refer to both ActionBarSherlock & ViewPagerTabs) with Ant
<p>I have one Android app which uses ActionBarSherlock &amp; ViewPagerTabs. I use Eclipse to write and build it, and it just works well until I try to build it with Ant. Here's what I did:</p> <ol> <li>go to ActionBarSherlock folder, run "android update <strong>lib-project</strong> --path ."</li> <li>go to ViewPagerTabs folder, run "android update <strong>lib-project</strong> --path ." too</li> <li>go to app folder, run "android update <strong>project</strong> --path ."</li> <li>run "and debug" under app folder, and I got following errors:</li> </ol> <p>:</p> <pre><code>[javac] C:\Android\TestApp\src\com\test\App\TestActivity.java:46: cannot find symbol [javac] symbol : method getSupportActionBar() [javac] location: class com.test.App.TestActivity [javac] final ActionBar ab = getSupportActionBar(); [javac] ^ </code></pre> <p>So question NO. 1: <strong>I have correct library references in app's project.properties, and ActionBarSherlock &amp; ViewPagerTabs could be built successfully, why do I still get these errors?</strong></p> <p>There's a workaround for this issue -- copy all classes.jar under library's bin folder into app's libs folder, and run "ant debug" again. But I need to delete these .jar files under app's libs folder after all .java files of app could be compiled.</p> <p>Running "ant debug" again after this, I will get following errors:</p> <pre><code>[dx] processing archive C:\Android\ActionBarSherlock\library\bin\classes.jar... [dx] ignored resource META-INF/MANIFEST.MF [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl.class... [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.class... [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.class... [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs.class... [dx] processing android/support/v4/app/ActionBar$LayoutParams.class... [dx] processing android/support/v4/app/ActionBar$OnMenuVisibilityListener.class... [dx] processing android/support/v4/app/ActionBar$OnNavigationListener.class... [dx] processing android/support/v4/app/ActionBar$Tab.class... [dx] processing android/support/v4/app/ActionBar$TabListener.class... [dx] processing android/support/v4/app/ActionBar.class... [dx] processing android/support/v4/app/ActivityCompatHoneycomb.class... [dx] [dx] UNEXPECTED TOP-LEVEL EXCEPTION: [dx] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatHoneycomb; [dx] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123) [dx] at com.android.dx.dex.file.DexFile.add(DexFile.java:163) [dx] at com.android.dx.command.dexer.Main.processClass(Main.java:486) [dx] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455) [dx] at com.android.dx.command.dexer.Main.access$400(Main.java:67) [dx] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394) [dx] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245) [dx] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131) [dx] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109) [dx] at com.android.dx.command.dexer.Main.processOne(Main.java:418) [dx] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329) [dx] at com.android.dx.command.dexer.Main.run(Main.java:206) [dx] at com.android.dx.command.dexer.Main.main(Main.java:174) [dx] at com.android.dx.command.Main.main(Main.java:95) [dx] 1 error; aborting </code></pre> <p>My question NO.2 is: <strong>how can I fix this issue?</strong></p> <p>Thanks!</p>
0
nodejs write 64bit unsigned integer to buffer
<p>I want to store a 64bit (8 byte) big integer to a nodejs buffer object in big endian format.</p> <p>The problem about this task is that nodejs buffer only supports writing 32bit integers as maximum (with buf.write32UInt32BE(value, offset)). So I thought, why can't we just split the 64bit integer?</p> <pre><code>var buf = new Buffer(8); buf.fill(0) // clear all bytes of the buffer console.log(buf); // outputs &lt;Buffer 00 00 00 00 00 00 00 00&gt; var int = 0xffff; // as dezimal: 65535 buf.write32UInt32BE(0xff, 4); // right the first part of the int console.log(buf); // outputs &lt;Buffer 00 00 00 00 00 00 00 ff&gt; buf.write32UInt32BE(0xff, 0); // right the second part of the int console.log(buf); // outputs &lt;Buffer 00 00 00 ff 00 00 00 ff&gt; var bufInt = buf.read32UInt32BE(0) * buf.read32UInt32BE(4); console.log(bufInt); // outputs 65025 </code></pre> <p>As you see this nearly works. The problem is just splitting the 64bit integer and finding the missing 510 at reading it. Would somebody mind showing the solutions for these two issues?</p>
0
List of mso- attributes
<p>I'm searching for a list of Microsoft specific CSS attributes with mso- prefix.</p> <p>Any link to an offical or unofficial source would be awesome.</p>
0
How to share redux store in micro frontend architecture?
<p>I am trying to create a small project to implement micro-frontend architecture following <a href="https://martinfowler.com/articles/micro-frontends.html" rel="noreferrer">Micro Frontends</a> article. I am creating multiple repositories for each MFE(Micro frontend) and also using Redux for the application. I have the following architecture:</p> <ol> <li><code>Frame</code> - A centralised(main) repo that is responsible for rendering the main application part and MFEs based on routing(I am using <code>connected-react-router</code>). It initialises the Redux store and also adds an <code>injectReducer</code> function to dynamically add reducers as explained in <a href="https://redux.js.org/recipes/code-splitting#defining-an-injectreducer-function" rel="noreferrer">code splitting in redux</a> docs. The frame fetches the manifest for particular MFE and renders it. The frame also has some redux data for authentication purpose.</li> <li><code>MFEs</code> - These are the individual feature-wise application and are rendered by frame.</li> </ol> <p>Now I have a problem that I want to use <code>injectReducer</code> function into my MFEs to dynamically add reducers to store. For this, I need access to the same <code>store</code> instance that is created by frame. As mentioned in <a href="https://stackoverflow.com/questions/38460949/what-is-the-best-way-to-access-redux-store-outside-a-react-component">this answer</a>, the ideal way is to export the created store instance and use it but how we can share the same instance of the store across multiple repos?</p>
0
Flutter Navigator.of(context).pop vs Navigator.pop(context) difference
<p>What's the difference between <code>Navigator.of(context).pop</code> and <code>Navigator.pop(context)</code>?</p> <p>To me both seems to do the same work, what is the actual difference. Is one deprecated? </p>
0
Forward HTTPS traffic thru Nginx without SSL certificate
<p>I want to use Nginx to expose my NodeJS server listening on port 443.</p> <p>I don't want to manage the SSL certificate with Nginx. I would rather do that on the NodeJS server using the <code>SNICallback</code> option of <code>https.createServer</code>.</p> <p>How do I setup the <code>nginx.conf</code> to support this?</p>
0
Elixir - Looping through and adding to map
<p>I'm rebuilding something in Elixir from some code I built in C#.</p> <p>It was pretty hacked together, but works perfectly (although not on Linux, hence rebuild).</p> <p>Essentially what it did was check some RSS feeds and see if there was any new content. This is the code:</p> <pre><code>Map historic (URL as key, post title as value). List&lt;string&gt; blogfeeds while true for each blog in blogfeeds List&lt;RssPost&gt; posts = getposts(blog) for each post in posts if post.url is not in historic dothing(post) historic.add(post) </code></pre> <p>I am wondering how I can do Enumeration effectively in Elixir. Also, it seems that my very process of adding things to "historic" is anti-functional programming.</p> <p>Obviously the first step was declaring my list of URLs, but beyond that the enumeration idea is messing with my head. Could someone help me out? Thanks.</p>
0
How can I disable some dates range in a fullcalendar?
<p>I want to disable days before and after dates range, anybody know how can I do that? (sorry for my english). </p> <p>Hernan</p>
0
Handling X-FORWARDED-PROTO header in Java web application
<p>Can any one guide me in working with <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto" rel="nofollow noreferrer">X-FORWARDED-PROTO</a> header in Java web application deployed to Apache Tomcat.</p> <p>The application setup is in such a way that tomcat talks with Apache webserver, which in turn talks with Cisco Load Balancer, finally the balancer publishes the pages to the client (tomcat -> apache2 -> load balancer -> client).</p> <p>The SSL Certificate is installed in Load Balancer and it's handling HTTPS requests. My requirement is to make the application behave in such a way that it uses the <em>X-FORWARDED-PROTO</em> and change the pages as HTTP or HTTPS.</p> <p>Checking on the header files of my webpages I could not find the <em>X-FORWARDED-PROTO</em> header. I don't have access to the Load Balancer configuration either, and the IT has suggested us to use the <em>X-FORWARDED-PROTO</em> to differentiate between HTTP and HTTPS request.</p> <p>Is there any configuration to be done in Tomcat or Apache level so that it will return the <em>X-FORWARDED-PROTO</em> header? Or is it that the configuration should be handled in Load Balancer?</p>
0
How do I compile sql?
<p>I am learning SQL but I have not been able to figure out what is used to compile and run SQL code.</p>
0
Flip ordering of legend without altering ordering in plot
<p>I have found that when adding <code>coord_flip()</code> to certain plots using ggplot2 that the order of values in the legend no longer lines up with the order of values in the plot.</p> <p>For example:</p> <pre><code>dTbl = data.frame(x=c(1,2,3,4,5,6,7,8), y=c('a','a','b','b','a','a','b','b'), z=c('q','q','q','q','r','r','r','r')) print(ggplot(dTbl, aes(x=factor(y),y=x, fill=z)) + geom_bar(position=position_dodge(), stat='identity') + coord_flip() + theme(legend.position='top', legend.direction='vertical')) </code></pre> <p><img src="https://i.stack.imgur.com/bNwCU.png" alt="enter image description here"></p> <p>I would like the 'q' and 'r' in the legend to be reversed without changing the order of 'q' and 'r' in the plot.</p> <p><code>scale.x.reverse()</code> looked promising, but it doesn't seem to work within factors (as is the case for this bar plot).</p>
0