title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
SSRS on a Domain Controller / DNS Server
<p>I have installed SSRS on a server which is also both a domain controller and a DNS server and am having some difficulty setting up permissions.</p> <p>The symptom is the "User does not have required permissions" message, the solution for which is well documented online (e.g. <a href="https://stackoverflow.com/questions/3389040/reporting-services-permissions-on-sql-server-r2-ssrs">Reporting Services permissions on SQL Server R2 SSRS</a>).</p> <p>However this solution is not working for me. I have opened IE as administrator and added my domain user with full privileges under both site settings and folder settings, yet still I can only open Report Manager when I open IE as admin, and furthermore when I do so I can only open it with via localhost and not via the machine name. </p> <p>I suspect the issue may be related to the fact that the server is also a domain controller and a DNS server but really don't know.</p> <p>EDIT: I should expand on what is happening when I enter the machine name: I am being prompted for credentials 3 times and then getting a blank screen.</p>
2
Guard checking of lambdas
<p>I usually perform guard checking like so:</p> <pre><code>public void doStuff(Foo bar, Expression&lt;Func&lt;int, string&gt;&gt; pred) { if (bar == null) throw new ArgumentNullException(); if (pred == null) throw new ArgumentNullException(); // etc... } </code></pre> <p>I've seen this extra check which ensures that the predicate is actually a lambda:</p> <pre><code> if (pred.NodeType != ExpressionType.Lambda) throw new ArgumentException(); </code></pre> <p>The <code>ExpressionType</code> enum has many possibilities, but I don't understand how any of them would apply because I assumed the compiler would only allow a lambda.</p> <p>Q1: <em>Is there benefit to this?</em> We do thorough guard checking of all inputs, so does this add value? </p> <p>Q2: Is there a performance penalty - i.e. does it take longer than a regular type/bounds/null check?</p>
2
Fastest way to count PDF images using PDFBox 2.x
<p>We occasionally encounter some extremely large PDFs filled with full page, high resolution images (the result of document scanning). For example, I have a 1.7GB PDF with 3500+ images. Loading the document takes about 50s but counting the images takes about 15 minutes. </p> <p>I'm sure this is because the image bytes are read as a part of the API calls. Is there way to extract the image count without actually reading the image bytes?</p> <p>PDFBox version: 2.0.2</p> <p>Example Code:</p> <pre><code>@Test public void imageCountIsCorrect() throws Exception { PDDocument pdf = readPdf(); try { assertEquals(3558, countImages(pdf)); // assertEquals(3558, countImagesWithExtractor(pdf)); } finally { if (pdf != null) { pdf.close(); } } } protected PDDocument readPdf() throws IOException { StopWatch stopWatch = new StopWatch(); stopWatch.start(); FileInputStream stream = new FileInputStream("large.pdf"); PDDocument pdf; try { pdf = PDDocument.load(stream, MemoryUsageSetting.setupMixed(1024 * 1024 * 250)); } finally { stream.close(); } stopWatch.stop(); log.info("PDF loaded: time={}s", stopWatch.getTime() / 1000); return pdf; } protected int countImages(PDDocument pdf) throws IOException { StopWatch stopWatch = new StopWatch(); stopWatch.start(); int imageCount = 0; for (PDPage pdPage : pdf.getPages()) { PDResources pdResources = pdPage.getResources(); for (COSName cosName : pdResources.getXObjectNames()) { PDXObject xobject = pdResources.getXObject(cosName); if (xobject instanceof PDImageXObject) { imageCount++; if (imageCount % 100 == 0) { log.info("Found image: #" + imageCount); } } } } stopWatch.stop(); log.info("Images counted: time={}s,imageCount={}", stopWatch.getTime() / 1000, imageCount); return imageCount; } </code></pre> <p>If I change the countImages method to rely on the COSName, the count completes in less than 1s but I'm a little uncertain about relying on the prefix of the name. This appears to be a byproduct of the pdf encoder and not PDFBox (I couldn't find any reference to it in their code):</p> <pre><code>if (cosName.getName().startsWith("QuickPDFIm")) { imageCount++; } </code></pre>
2
Output an IotHub endpoint with Azure Resource Manager template
<p>I am about to script the deployment of our Azure solution. For that reason I create an Azure IoTHub with a Resource Manager Template. This works very well. But the problem is, I need the <strong>Event Hub-compatible endpoint</strong> string for further deployments. </p> <p>See: <a href="https://picload.org/image/rrdopcia/untitled.png" rel="noreferrer">https://picload.org/image/rrdopcia/untitled.png</a></p> <p>I think, the solution would be, to output it in the template, but I cant get it to work.</p> <p>The output-section of my <em>template.json</em> actually looks like this:</p> <pre><code> "outputs": { "clusterProperties": { "value": "[reference(parameters('clusterName'))]", "type": "object" }, "iotHubHostName": { "type": "string", "value": "[reference(variables('iotHubResourceId')).hostName]" }, "iotHubConnectionString": { "type": "string", "value": "[concat('HostName=', reference(variables('iotHubResourceId')).hostName, ';SharedAccessKeyName=', variables('iotHubKeyName'), ';SharedAccessKey=', listkeys(variables('iotHubKeyResource'), variables('iotHubVersion')).primaryKey)]" } } </code></pre> <p>And here are the variables I used:</p> <pre><code> "variables": { "iotHubVersion": "2016-02-03", "iotHubResourceId": "[resourceId('Microsoft.Devices/Iothubs', parameters('iothubname'))]", "iotHubKeyName": "iothubowner", "iotHubKeyResource": "[resourceId('Microsoft.Devices/Iothubs/Iothubkeys', parameters('iothubname'), variables('iotHubKeyName'))]", }, </code></pre>
2
Correct way to get child nodes using HtmlAgilityPack in C#
<p>I'm trying to scrape data with HtmlAgilityPack. However it is not working as I expected. Each web page I'm scraping contains a list of items, and each item contains first name and email.</p> <pre><code>&lt;div class="item"&gt; &lt;div&gt;... &lt;span class="first-name"&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;... &lt;span class="email"&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>My thought was to extract all div nodes from each page, then retrieve first name and email from each node. I thought this would be working:</p> <pre><code>var div = rootDocument.DocumentNode.SelectNodes("//div[@class='item']"); var firstNames = div.SelectNodes("//span[@class='first-name']//text()"); var emails = div.SelectNodes("//span[@class='email-address']//a//text()"); </code></pre> <p>However, firstNames and emails seemed to retrieve all nodes in the page, not the div. I only want to get child nodes belong to one div. What is the correct way to do this?</p>
2
How to install Bootstrap on a chromebook?
<p>Hence the title, how would I install Bootstrap on a chromebook? I researched on the net, but couldn't find a thing. Also on SO there doesn't seem to be a question that covers this topic. I tried using npm, but the commands from <a href="http://getbootstrap.com/" rel="nofollow">getbootstrap.com</a> aren't working. </p> <p>I have already created a website (although it is based on a theme, it is <a href="http://totalnfl.com/" rel="nofollow">totalnfl.com</a>) and am looking to install Bootstrap to make my life easier when completely recoding it all from scratch (or maybe based on the old version, I'm not sure yet). Thanks!</p>
2
touchscreen ft5x06 not responding?
<p>I am using kontron smarc-samx6i board run with nxp imx6q processor. I am currently working with yocto In that I need to interface a touch screen of ft5316 through I2C . For that I edited the device tree as follows:</p> <pre><code>polytouch: edt_ft5x06@39 { compatible = "edt","edt_ft5x06","edt-ft5x06"; reg = &lt;0x39&gt;; pinctrl-names = "default"; pinctrl-0 = &lt;&amp;pinctrl_smx6_i2c_gpio_1&gt;; irq_pin=&lt;&amp;gpio3 1 0&gt;; interrupt-parent = &lt;&amp;gpio3&gt;; interrupts = &lt;0 70 0x04&gt;; }; </code></pre> <p>When I am using <code>i2cdump</code> command the touchscreen responds successfully, but when I am working with module it won't respond.</p> <p>When I am using the below command i am getting following output</p> <pre><code>root@smarc-samx6i:~# cat /proc/bus/input/devices I: Bus=0019 Vendor=0001 Product=0001 Version=0100 N: Name="gpio-keys.27" P: Phys=gpio-keys/input0 S: Sysfs=/devices/soc0/gpio-keys.27/input/input0 U: Uniq= H: Handlers=kbd event0 evbug B: PROP=0 B: EV=23 B: KEY=4000 100000 0 0 0 B: SW=1 </code></pre> <p>My device did not probe and i am not getting any error while instantiating the device using the command:</p> <pre><code>echo edt_ft5x06 0x39&gt; /sys/bus/i2c/devices/i2c-1/new_device Instantiated device edt_ft5x06 at 0x39 device </code></pre> <p>How can i make it work!!</p>
2
Animating font size changes
<p>I am trying to do a little animation which change a label frame along with changing the font size. I have seen that animating directly the font size is not possible. So I have tried to use CGAffineTransform.</p> <p>Here is what I have tried so far :</p> <pre><code> UIView.animateWithDuration(1, animations: { if self.topConstraint.active { self.initialTopConstraint.active = false self.initialLeadingConstraint.active = false self.label.transform = CGAffineTransformMakeScale(0.5, 0.5) self.finalTopConstraint.active = true self.finalLeadingConstraint.active = true } else { self.initialTopConstraint.active = true self.initialLeftConstraint.active = true self.label.transform = CGAffineTransformMakeScale(1.5, 1.5) self.finalTopConstraint.active = false self.finalLeftConstraint.active = false } self.view.layoutIfNeeded() }) </code></pre> <p>In fact, this works, but I am using auto layout, and at the end of the animation, the constraints are not satisfied at all. The final constraints constants are 8, and when I print the label frame at the end of the animation, the label is around 13 points from the left and around 16 points from the top.</p> <p>Initial frame :</p> <p><a href="https://i.stack.imgur.com/L8gcy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L8gcy.png" alt="enter image description here"></a></p> <p>Final frame with constraints respected but no font size changes made :</p> <p><a href="https://i.stack.imgur.com/ndaeL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ndaeL.png" alt="enter image description here"></a></p> <p>Final frame with constraints not respected and font size changes made :</p> <p><a href="https://i.stack.imgur.com/VDa3e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VDa3e.png" alt="enter image description here"></a></p> <p>Is there anyway to combine properly Auto layout and CGAffineTransform ?</p>
2
VBA/IE Check the checkbox with same name and different value
<p>I would like to check the first checkbox, but my code in VBA does not work.</p> <pre><code>&lt;input type="Checkbox" name="report_filters_product" value="2340"&gt; &lt;input type="Checkbox" name="report_filters_product" value="1338"&gt; &lt;input type="Checkbox" name="report_filters_product" value="2998"&gt; &lt;input type="Checkbox" name="report_filters_product" value="8007"&gt; </code></pre> <p>My code to check the first checkbox is:</p> <pre><code>Set Element = objIE.document.getElementsByName("report_filters_product").Value = 2340 Element.Checked = True </code></pre> <p>But this does not work. What might be going wrong?</p>
2
change input value based on <select> PHP/Mysql
<p>Been looking for a few days for the answer and even tho I think this should be simple, I just can't seem to make it work.</p> <p>First I populate a "select" with values from my database with a while loop.</p> <pre><code>&lt;select class="admin-content-select" name="sale"&gt; &lt;?php try { $stmt = $db-&gt;prepare('SELECT saleID, saleKal, saleNr FROM wcms_sale'); $stmt-&gt;execute(array(':saleKal' =&gt; $row['saleKal'])); while($sale = $stmt-&gt;fetch()){ echo '&lt;option value="'.$sale['saleKal'].'"&gt;'.$sale['saleKal'].'&lt;/option&gt;'; } }catch(PDOException $e) { echo $e-&gt;getMessage(); } ?&gt; &lt;/select&gt; </code></pre> <p>then I have an input field which I need to get populated with a value based on what is selected. The values are on the same row in the db so my initial thought was that it would be easy to say: "when X row is selected, echo Y" but since it's a while loop it will simply echo a lot of input fields.</p> <p>Any work arounds or am I totally in the wrong here with the while loop?</p> <p>Hope I explained this right and thanks beforehand for any answer :)</p> <p><strong>Answer:</strong></p> <pre><code>&lt;select id="saleName" class="admin-content-select" onchange="changeFunc()"&gt; &lt;option value="'.$sale['saleNr'].'"&gt;'.$sale['saleKal'].'&lt;/option&gt;'; </code></pre> <p>Then added a function as suggested:</p> <pre><code>function changeFunc(){ var x = document.getElementById("selectID").value; document.getElementById("inputID").value = x; } </code></pre> <p>Thanks for all the answers!</p>
2
ASP.NET Core - What is the best way to persist a model across whole application?
<p>To start, I have an ASP.NET MVC Core application that acts as sort of a wizard where the user logs in, and starts building a "configuration" of data. Essentially, as the user goes through each page, they are configuring/adding different data to this "configuration". As they go through these pages, the configuration is saved along the way. The problem I'm having is coming up with a good solution of saving the progress of the configuration and persisting it across the application. Here is a very simplified version of a couple of my models and what I'm doing (without getting into too much domain detail):</p> <pre><code>public class Configuration { string ConfigName; CustomerInfo CustomerInfo; InputData Input; } public class CustomerInfo { string CustomerName; string Company; string PhoneNumber; } public class InputData { int SomeNumber; int SomeOtherInput; int AnotherNumber; } </code></pre> <p>So, in this case, I essentially have a Create page for CustomerInfo. The user fills out the customer information form, save it, and then is directed to the Create page for InputData, saves it, is redirected to another view, and so on. While this is happening, I need to keep track of the "Profile" that all of these belong to.</p> <p>I've considered using a Session to store this, but I'm aware of some of the drawbacks of that, especially if multiple servers are serving requests - sessions get lost, etc.</p> <p>What would be a better solution/best practice for something like this?</p> <p>Edit: I should note that I am using a database right now to store this data. So for this example, I have a "Configuration" table that contains foreign keys to a CustomerInfo table and a InputData table respectively. </p>
2
Simple AJax call is not working - Other page get loaded
<p>I have started learning AJAX today. I wrote a simple ajax call, but instead of getting response asynchronously, it just load the PHP script page. Just like normal form submission.</p> <p><strong>html</strong></p> <pre><code>&lt;form id="form" method="POST" action="name.php"&gt; &lt;input type="text" name="Name"&gt; &lt;input type="submit" value="Submit" /&gt; </code></pre> <p></p> <p><strong>JS</strong></p> <pre><code>$("#form").submit(function(e) { e.preventDefault(); var url = "name.php"; $.ajax({ type: "POST", url: url, data: $("#form").serialize(), success: function(data) { alert(data); } }); }); </code></pre> <p><strong>PHP</strong></p> <pre><code>&lt;?php $data= $_POST['Name']; echo $data; ?&gt; </code></pre> <p>Instead of getting Alert on the same page, I am being redirected to <code>name.php</code> with the value I have submited.</p>
2
code too large and too many constants errors (Android Studio)
<p>I've got a problem that I cannot resolve; I searched in web, but I didn't find a precise solution, or at least I didn't understand very well, I don't know.</p> <p>Anyway, I've got Android Studio v. 2.1, and here's what I'm trying to do:</p> <p>At first I created an SQLite Database overriding the <code>onCreate</code> method, than, in another override of the same method, I wrote a method that checks if the database is empty; if true, it'll add around 300000 words. Here's this part:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Database db = new Database(getApplicationContext()); db.open(); if (db.queryTutteParole().getCount() == 0) { db.inserisciParole("pane", "no"); db.inserisciParole("latte", "no"); db.inserisciParole("uovo", "no"); db.inserisciParole("farina", "no"); db.inserisciParole("sale", "no"); //and all the remaining words } db.close(); } </code></pre> <p>To clarify: <code>queryTutteParole()</code> is a method that returns a cursor of all that's in the database, and <code>inserisciParole()</code> puts the words with their value in the database.</p> <p>Well, no errors with the code (I tested with only 5 words put), but if I put all the 300000+ words and I try to run it on my device, I have these errors:</p> <p><a href="http://i.stack.imgur.com/ZWFcu.png" rel="nofollow">Here's the image with the errors</a></p> <p>What I should do? </p> <p>Thanks :)</p>
2
thisArg of array.forEach does not reference as expected
<p>Given following code:</p> <pre><code>const theArray = ['Audi','Volvo','Mercedes']; const myObj = {a: 7}; theArray.forEach((value, index, array) =&gt; { console.log(index + ' : ' + value); console.log(array === theArray); console.log(this.a); }, myObj); </code></pre> <p>I get following output:</p> <pre><code>0 : Audi true undefined 1 : Volvo true undefined 2 : Mercedes true undefined </code></pre> <p>Where I don't understand why <code>this</code> does not reference myObj and returns undefined instead of 7. While <code>this typeof Object</code> returns true, I don't know which Object it references. I just know that <code>this</code> returns an empty Object(i.e. {})</p> <p>Node.js interpreter version is v6.2.1</p> <p>V8-Engine version is 5.0.71.52</p>
2
Building fortran with llvm
<p>I've seen, that there is an considerable performance increase using llvm. Is there a way to compile a fortran code using llvm (or clang)?</p>
2
Delete user in Google Apps Script - Fix "Resource Not Found userKey" error
<p>I am creating a google apps script add-on that will allow us to add and delete users to our google apps domain. Certain information is entered into a google sheet (First name, last name, employee number, etc. etc.). Then, the person entering the users can select all the rows of users they would like to add. </p> <p>Google apps script then creates a username and password based on their first and last name and enters them to our Google Apps domain among other things. This part works perfectly.</p> <p>I am trying to write another function that will allow the person managing users to select the rows of users they would like to remove from our domain for whatever reason and click a "Delete Users" button. This will delete the users based on their email address in our system. </p> <p>Here is my code:</p> <pre><code>function delUsers() { var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getActiveRange(); var i = range.getRow(); var stop = range.getLastRow(); while (i != stop + 1) { var email = sheet.getRange("C" + i).getValue(); var user = String(email); AdminDirectory.Users.remove(user); } }; </code></pre> <p>You will see that the function loops through each row selected and gets the email address. It is in the format "[email protected]".</p> <p>The problem is I keep getting the error "Resource Not Found userKey". Per suggestion from AbrahamB below, I made sure my userKey was a string as found in the GAS documentation. I used javascript's <code>typeof</code> to make sure of this.</p> <p>The weird thing is upon further investigation, the user <em>is</em> actually being deleted, but the "Resource Not Found userKey" error is still being thrown.</p> <p>Any help in explaining why this error is happening and how to fix it would be appreciated.</p>
2
Incorrect syntax near the keyword 'SCHEMA'. ERROR With creating it
<p>I am trying to create a view schema, but fell into some problem. </p> <p>Can you please explain. I#m new to schemas.</p> <pre><code>CREATE VIEW schema.[TEMP1_V]( LOCATION, OBJECTID, CTID, numb, COUNTALL, COUNTALL_DEBIT ) AS SELECT LOCATION, OBJECTID, CTID, numb, COUNTALL, COUNTALL_DEBIT COUNT (location) OVER (PARTITION BY location) AS COUNTALL, COUNT (location) OVER (PARTITION BY location, IS_DEBIT) AS COUNTALL_DEBIT FROM ALLOCAMT_V </code></pre> <p>I am getting an error when trying to create it. 'Incorrect syntax near the keyword 'SCHEMA'.'</p>
2
GOLANG Static library linking
<p>OS->Ubuntu 16.04 LTS | Go Vesrion-> 1.6.2 64 bit </p> <p>I am using this github.com/xeodou/go-sqlcipher PKG</p> <p>This Pkg need ->libcrypto library</p> <p>This is the Link of program what i am compiling from _example folder from above pkg <a href="https://play.golang.org/p/drJGhsWiEi" rel="nofollow">https://play.golang.org/p/drJGhsWiEi</a></p> <p>when i am using-> go build encryption.go (encryption binary genrated)</p> <p>command-> file ./encryption</p> <p>encryption: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=91d49d6db997f83dfc722b820e5cab4cc16854cf, not stripped</p> <p>command-> ldd ./encrption</p> <pre><code> linux-vdso.so.1 =&gt; (0x00007ffca8fba000) libcrypto.so.1.0.0 =&gt; /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fa93c071000) libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa93be6d000) libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa93bc4f000) libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa93b886000) /lib64/ld-linux-x86-64.so.2 (0x000055f1aa574000) </code></pre> <p>command-> ./encryption</p> <p>Output i am getting - {"name":"xeodou", "password": "123456"} </p> <p>when i am using ->go build --ldflags '-extldflags "-static"' encryption.go</p> <p>command-> file ./encryption</p> <p>encryption: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=71fa3d0c30cc5c52dd4f8bea432f8e0468225f9a, not stripped</p> <p>command-> ldd ./encryption</p> <pre><code> not a dynamic executable </code></pre> <p>command-> ./encryption</p> <p>Output i am getting - Segmentation fault (core dumped)</p> <p>The thing i am not getting is when same binary run in other device some it worked some not.</p> <p>Please guide me </p>
2
How to convert images of gif picture to NSData for iOS?
<p>In my iOS Application, I want to show a Gif image in my <code>tableViewCell</code>. Download this Gif image by <code>SDWebImage</code>, and use <code>FLAnimatedImageView</code> to show this image.</p> <p>But now I have a problem, <code>SDWebImage</code> return a images ,but the <code>FLAnimatedImageView</code> want a <code>NSData</code>. </p> <p>How to convert images of <code>gif</code> to <code>NSData</code>?</p> <p>Forgive my poor English.</p> <pre><code>[[SDWebImageManager sharedManager] downloadImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if (image.images.count &gt; 0)//gif { // how to get the data FLAnimatedImage *animatedImage = [FLAnimatedImage animatedImageWithGIFData:data]; _chatGIFImage.animatedImage = animatedImage1; } }]; </code></pre>
2
Android automatic keyboard language depending on the person you are writing to
<p>I often find myself writing to different people in different languages. Every time I have to switch to the correct language to avoid false auto-correction.</p> <p><strong>The language only depends on the person I am talking to</strong>, that is I will always talk in italian to <code>a</code>, <code>b</code> and <code>c</code>; in english to <code>l</code> and <code>m</code>; in french with <code>x</code>. </p> <p>Is there a keyboard that keeps track of that, or a way to have it automatically configured when switching contacts?</p>
2
How can I switch perspective programmatically after starting an E4 application?
<h2>Scenario</h2> <p>I have a pure E4 application in which I want to select the initial perspective for the user depending on the user's roles. I therefore have a perspective to start with which contains one part only. In that part, I use the @PostConstruct-Method to check the user's roles and afterwards trigger the command for switching perspective:</p> <hr> <p>Initial View</p> <pre class="lang-java prettyprint-override"><code>@Inject private IEclipseContext eclipseContext; @PostConstruct public void initialize() { // checking credentials and retrieving roles come here which is pretty long // that's why switching perspective is a seperate method // and EclipseContext is injected to instance instead of method this.switchPerspective(_usersInitialPerspectiveId) } private void switchPerspective(String pTargetPerspectiveId) { final ECommandService _commandService = this.eclipseContext.get(ECommandService.class); final EHandlerService _handlerService = this.eclipseContext.get(EHandlerService.class); final Map&lt;String, Object&gt; _commandParameter = new HashMap&lt;&gt;(); _commandParameter.put(PluginIdConstants.ID_OF_PARAMETER_FOR_SWITCH_PERSPEKTIVE, pZielPerspektiveId); final ParameterizedCommand _switchPerspectiveCommand = _commandService.createCommand(COMMAND_ID_FOR_SWITCH_PERSPECTIVE, _commandParameter); _handlerService.executeHandler(_switchPerspectiveCommand); } </code></pre> <hr> <p>For switching perspective from here, I use the exact same handler as from menu items configured in <code>Application.e4xmi</code>, which looks like this:</p> <hr> <p>Perspective Switch Handler</p> <pre class="lang-java prettyprint-override"><code>@Execute public void execute(final MWindow pWindow, final EPartService pPartService, final EModelService pModelService, @Named(PluginIdConstants.ID_OF_PARAMETER_FOR_SWITCH_PERSPEKTIVE) final String pPerspectiveId) { final List&lt;MPerspective&gt; _perspectives = pModelService.findElements(pWindow, pPerspectiveId, MPerspective.class, null); if (!(_perspectives.isEmpty())) { // Show perspective for looked up id pPartService.switchPerspective(_perspectives.get(0)); } } </code></pre> <hr> <h2>The Problem</h2> <p>The problem is pretty simple: When using the above handler triggered by a menu item, it works as intended and switches perspective. But using the same handler by my initial view (triggering it programmatically) does not switch perspective. I debugged the code to check if the handler gets identical information in both cases and it does.</p> <p>Maybe my application has not finished starting and that's why the handler has no effect, but if this is the problem, how can I check this?</p> <p>Any ideas on what I maybe missed are welcome!</p>
2
SignatureDoesNotMatch in aws s3 c# while getting presigned url
<p>Hi I have mvc application in which I want to get url of uploaded image in amazon s3 but after getting url its not able to get open in browser code to get Url is</p> <pre><code> var expiryUrlRequest = new GetPreSignedUrlRequest(); expiryUrlRequest.BucketName = BUCKET_NAME; expiryUrlRequest.Key = "uploads/participantid_" + v1+ "/taskid_" + v2 + "/" + 0 + ".mp4"; expiryUrlRequest.ContentType = "Video/mp4"; expiryUrlRequest.Expires = DateTime.Now.AddYears(10); string url = client.GetPreSignedURL(expiryUrlRequest); </code></pre> <p>I also get url but after pestling it into browser it show signature does not match.</p>
2
Javascript Animation with multiple images
<p>I'll thy to explain the situation.<br> I am working on a csgo gambling website.<br></p> <p><a href="https://i.stack.imgur.com/0z4RC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0z4RC.png" alt="enter image description here"></a> <br> I have a roulette animation based on a picture with 30 slots.<br> {1 on the Image}<br> <br> And I browsed trough some sites and then I came across this page with something similar, but the difference was that they used single images which repeats themself <em>I think</em>.<br> This is what ive found:<br> {2 on the Image}<br> <br> This is what I mean , they use just images and kinda repeat them: {3 on the Image}</p> <p>I'm not sure if they generate a random pattern or if this is a custom pattern.<br> But it would be nice if someone could give a feedback<br> {4 on the Image}</p> <p>All I want is just to know is what this exactly is so I can do a resarch or even better if someone could explain me how this works or how to do it.</p> <p>Thanks alot</p> <p><strong><em>Im sorry that the image looks bad, its because i'm not allowed to post multiple screenshots</em></strong></p> <p>What I mean is not an spinning image, it mean this.<br> Please check this gif then you know what i mean.<br> Once the timer hits 0 it starts spinning<br> <a href="https://i.stack.imgur.com/pXE0s.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pXE0s.gif" alt="https://i.gyazo.com/4264f9f4c356bc7a5e2ab10efaa90f12.gif"></a></p>
2
AutoExport Run Results from UFT Function
<p>I am running an automated test script using UFT 12.52. I am wondering if there is a way to export results from within a function in the UFT Script. The idea is to call the function and export the run results. </p> <p>I can do it externally by creating a .vbs file which launches the script in uft and runs and exports the result, but i cannot figure out how to do it from within a UFT Script as function. </p> <p>Below is my code for exporting results externally. </p> <p>Thanks</p> <pre><code>Dim qtApp Dim qtTest Dim qtResultsOpt Dim qtAutoExportResultsOpts Set qtApp = CreateObject("QuickTest.Application") qtApp.Launch qtApp.Visible = True qtApp.Options.Run.ImageCaptureForTestResults = "OnError" qtApp.Options.Run.RunMode = "Fast" qtApp.Options.Run.ViewResults = False qtApp.Open "Z:\D:\paperlessEnhancements\", True Set qtTest = qtApp.Test qtTest.Settings.Run.IterationMode = "rngIterations" qtTest.Settings.Run.StartIteration = 1 qtTest.Settings.Run.EndIteration = 1 qtTest.Settings.Run.OnError = "NextStep" Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" n Set qtAutoExportResultsOpts = qtApp.Options.Run.AutoExportReportConfig qtAutoExportResultsOpts.AutoExportResults = True qtAutoExportResultsOpts.StepDetailsReport = True qtAutoExportResultsOpts.DataTableReport = True qtAutoExportResultsOpts.LogTrackingReport = True qtAutoExportResultsOpts.ScreenRecorderReport = True qtAutoExportResultsOpts.SystemMonitorReport = False qtAutoExportResultsOpts.ExportLocation = "C:\Documents and Settings\All Users\Desktop" qtAutoExportResultsOpts.UserDefinedXSL = "C:\Documents and Settings\All Users\Desktop\MyCustXSL.xsl" qtAutoExportResultsOpts.StepDetailsReportFormat = "UserDefined" qtAutoExportResultsOpts.ExportForFailedRunsOnly = True qtTest.Run qtResultsOpt MsgBox qtTest.LastRunResults.Status qtTest.Close Set qtResultsOpt = Nothing Set qtTest = Nothing Set qtApp = Nothing Set qtAutoExportSettings = Nothing </code></pre> <p>I also tried this : </p> <pre><code>Dim qtResultsOpt Dim qtAutoExportResultsOpts Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") qtResultsOpt.ResultsLocation = "C:\Temp\Notepad1" Set qtResultsOpt = Nothing </code></pre>
2
Template template parameters without specifying inner type
<p>I want to know if it is at all possible to have code that has the following behaviour:</p> <pre><code>int main() { func&lt;vector&gt;(/*some arguments*/); } </code></pre> <p>That is, I want the user to be able to specify the container without specifying the type that it operates on.</p> <p>For example, some (meta) code (which does not work with the above) that might define <code>func</code> would be as follows:</p> <pre><code>template&lt;typename ContainerType&gt; int func(/*some parameters*/) { ContainerType&lt;int&gt; some_container; /* operate on some_container here */ return find_value(some_container); } </code></pre>
2
Uploading a file via Jaxax REST Client interface, with third party server
<p>I need to invoke a remote REST interface handler and submit it a file in request body. Please note that <strong>I don't control the server</strong>. I cannot change the request to be multipart, the client has to work in accordance to external specification.</p> <p>So far I managed to make it work like this (omitting headers etc. for brevity):</p> <pre><code>byte[] data = readFileCompletely (); client.target (url).request ().post (Entity.entity (data, "file/mimetype")); </code></pre> <p>This works, but will fail with huge files that don't fit into memory. And since I have no restriction on filesize, this is a concern.</p> <p><strong>Question:</strong> is it somehow possible to use streams or something similar to avoid reading the whole file into memory?</p> <p>If possible, I'd prefer to avoid implementation-specific extensions. If not, a solution that works with RESTEasy (on Wildfly) is also acceptable.</p>
2
How to extract all numbers from a string using regex?
<p>I have a table <strong>table1</strong> with a field <strong>phone</strong>. This is a string field that is full of other characters besides the number. I want to extract all the numbers from the string.</p> <p><a href="https://i.stack.imgur.com/q2atp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q2atp.jpg" alt="enter image description here"></a></p> <p>I tried "[0-9]+" but I only get the first group of numbers in each row. I tried searching online but the regexes I tried were incompatible with access. Please explain the regex as well. Thanks.</p> <p>This is the VBA regex function I'm using:</p> <pre><code>Function myRegex(ByRef myString As String, ByVal pattern As String) As String Dim rgx As New RegExp Dim colMatches As MatchCollection With rgx .pattern = pattern .ignoreCase = True .Global = False .Multiline = False Set colMatches = .Execute(myString) End With If colMatches.Count &gt; 0 Then myRegex = colMatches(0).Value Else myRegex = "" End If End Function </code></pre>
2
Mysqli_real_escape_string with Single Quotes - Is it Safe?
<p>So I know that using prepared statements with placeholders is pretty much the only way to protect yourself from SQL injection due to poor formatting of your queries. However, I also see many people suggesting that, although mysqli_real_escape_string is NOT safe, using it with single quotes around the variable <em>is</em>. For example (note the single quotes in the query):</p> <pre><code>$value1 = mysqli_real_escape_string($value1); $value2 = mysqli_real_escape_string($value2); $value3 = mysqli_real_escape_string($value3); mysqli_query("INSERT INTO table (column1, column2, column3) VALUES ('" . $value1 . "', '" . $value2 . "', '" . $value3 . "')"; </code></pre> <p>So: <strong>when <em>only dealing with integers and strings</em>, would the above example be just as safe as if you were to use mysqli prepared statements and placeholders?</strong></p>
2
Why delete pointer to stack is error?
<p>I have read topic <a href="https://stackoverflow.com/questions/441831/calling-delete-on-variable-allocated-on-the-stack">Calling delete on variable allocated on the stack</a> And i know when use operator delete in stack, see error. But i want to know more and deep information . Why error ?</p>
2
libsodium-64.dll not found in production Azure Service Fabric cluster
<p>Using libsodium-net for all of its security goodness in an Azure Service Fabric Reliable Service, on my local dev cluster everything is working fine (although I did have to set the libsodium-64.dll to copy to the output directory).</p> <p>Unfortunately, when deployed to a real cluster in Azure it throws the following error:</p> <p><code>Unable to load DLL 'libsodium-64.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)</code></p> <p>I've checked by Remote Desktop-ing into one of the nodes and the DLL is copied across into the same directory as the service, exactly as it is in my dev cluster. Can't work out why it can't be found in production.</p> <p>I've tried setting the PATH environment variable as suggested in <a href="https://stackoverflow.com/questions/28275944/how-to-include-libsodium-net-on-asp-net">this answer</a>, and verified that it does actually get set - unfortunately that doesn't help.</p> <p>Is there anything special I need to do to get ASF to pick up the DLL?</p> <p>Edit: also tried adding the DLL to System32 on all the nodes, didn't solve it either.</p>
2
unable to call web api using custom methods
<p>I followed some answers but getting the following error on postman</p> <p><code>{ "Message": "The requested resource does not support http method 'GET'." }</code> </p> <p>these were the links i followed</p> <p><a href="https://stackoverflow.com/questions/18661946/web-api-route-to-action-name">Web API route to action name</a></p> <p><a href="https://stackoverflow.com/questions/24843264/how-to-add-custom-methods-to-asp-net-webapi-controller">How to add custom methods to ASP.NET WebAPI controller?</a></p> <p>currently setup is like the one as sky-dev has described</p> <p><a href="https://stackoverflow.com/questions/9569270/custom-method-names-in-asp-net-web-api">Custom method names in ASP.NET Web API</a></p> <p><strong>Updated with code</strong></p> <p>webapiconfig.cs</p> <pre><code>public static void Register(HttpConfiguration config) { // Web API configuration and services // Configure Web API to use only bearer token authentication. //config.SuppressDefaultHostAuthentication(); //config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); //// Web API routes //config.MapHttpAttributeRoutes(); //config.Routes.MapHttpRoute( // name: "DefaultApi", // routeTemplate: "api/{controller}/{id}", // defaults: new { id = RouteParameter.Optional } //); config.Routes.MapHttpRoute("DefaultApiWithId", "api/{controller}/{id}", new { id = RouteParameter.Optional }, new { id = @"\d+" }); config.Routes.MapHttpRoute("DefaultApiWithAction", "api/{controller}/{action}"); config.Routes.MapHttpRoute(name: "ApiWithActionName",routeTemplate: "api/{controller}/{action}/{id}",defaults: new { id = RouteParameter.Optional }); config.Routes.MapHttpRoute("DefaultApiGet", "api/{controller}", new { action = "Get" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) }); config.Routes.MapHttpRoute("DefaultApiPost", "api/{controller}", new { action = "Post" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) }); } </code></pre> <p>defaultcontroller.cs</p> <pre><code>public class DefaultController : ApiController { DBEntities db = new DBEntities(); public IEnumerable&lt;CategoryDTO&gt; Category() { IEnumerable&lt;CategoryDTO&gt; List = from tr in db.Categories where tr.IsActive == "Y" orderby tr.DisplayOrder ascending select new CategoryDTO() { Id = tr.Id, Name = tr.Name }; return List; } // GET: api/Default public IEnumerable&lt;string&gt; Get() { return new string[] { "value1", "value2" }; } // GET: api/Default/5 public string Get(int id) { return "value"; } // POST: api/Default public void Post([FromBody]string value) { } // PUT: api/Default/5 public void Put(int id, [FromBody]string value) { } // DELETE: api/Default/5 public void Delete(int id) { } } </code></pre>
2
add percentage of value to a result
<p>i want to calculate the percentage from a entered field.The first field will have a static value in the second field the user should enter a percentage value and this code should get the first value(static) calculate the percentage entered by the user according to the first static value and add that final value to the final result that is total.Here is some of the code i done but this is just basically adding two numbers whereas i want to add the percentage of second field entered by the user to the first one and display it in the final total title</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Page Title&lt;/title&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input style="max-width: 100px; type="number" min="0" type="text" id="quantity1" value="100" /&gt; &lt;input style="max-width: 100px; type="number" min="0" type="text" id="quantity2" /&gt; &lt;h5 class="total" id="total" value="$123"&gt;&lt;/h5&gt; &lt;/body&gt; &lt;script&gt; $('#quantity2').on('keyup',function(){ var val=$('#quantity1').val(); alert(val); //alert(val); var tot = +$(this).val()+ +$('#quantity1').val() ; alert(tot); $('.total').html("$"+tot); }); &lt;/script&gt; &lt;/html&gt; </code></pre>
2
Kill a Process in the Kernel
<p>I'm working on a research project, which tries to find some unusual/malicious states/inputs in the kernel, and stops the kernel thread from further execution immediately.</p> <p>For example, a process issues a system call with malicious arguments, and its kernel thread executes it. In the middle of function <code>Foo()</code>, we use a probe to find that the argument is malicious. And the function has no return value (<code>void</code>). Now we need to kill this process and its corresponding kernel part, and free the resources it uses (locks, etc.).</p> <p>How to implement it in Linux/Android kernel?</p> <p>My current idea is to suspend (call <code>schedule()</code> to make it sleep) the thread forever, and try to kill the process. However, the "kill" signal can only take effect when the process is in user-space, which is too late.</p>
2
Performing background task every minute
<p>I'm looking to perform network tests every minute for an hour to check whether or not the user has a connection -</p> <p>Ideally I'd like to get their location every minute (but not 100% necessary) and ping a server. Is this possible by either the user pressing a UIButton "start test" and then if they close the app it still runs?</p> <p>Or, activate a function when the user is in a location range at a given time? (Looking to perform tests at events)</p> <p>Or, possibly using a push notification to activate the function? This seems very impractical though.</p> <p>My research has shown this is typically only available for VOIP or Audio apps, and background fetch based are either restricted in duration or scheduled by the device itself based on the user's behaviour, which I don't want.</p> <p>Note: The app doesn't necessarily have to be released on the app store, this is just a small project so running it on a few devices will suffice.</p>
2
Yii2 validate username
<p>In my Yii2 application i'm trying to validate a field that i use for the username input using a custom validation method that check if this field have blank spaces.</p> <pre><code>class SomeModel extends Model { public $username; public $email; public $password; public function rules() { return [ // Other rules [ [ 'username', 'password', ], function ($attribute, $params) { if (preg_replace('/\s+/', '', $this-&gt;attribute)) { $this-&gt;addError($attribute, 'No white spaces allowed!'); } }, ], ], } </code></pre> <p>The problem that is not working. Records are saving with some blank spaces.</p> <p>In the view this is the field:</p> <pre><code> &lt;?= $form-&gt;field($model, 'username')-&gt;textInput(['class' =&gt; 'form-control', 'autocomplete' =&gt; 'off', 'placeholder' =&gt; 'Username'])-&gt;label(FALSE); ?&gt; </code></pre>
2
How assign a method reference value to Runnable
<p>I hava a problem about Java 8 <code>Runnable</code>.</p> <pre><code> public static void main(String[] args) { Runnable r1 = Test::t1; Runnable r2 = Test::t2; Runnable r3 = Test::t3; } public static void t1() { } public static String t2() { return "abc"; } public static String t3(String t) { return t; } </code></pre> <p>As the code show, I understand <code>r1</code> is right and <code>r3</code> is wrong, but I don't understand why <code>r2</code> is also right. Can anybody help me understand it?</p>
2
How to get XML text as an Inputstream
<p>I have the following client I am using to call a Jersey REST service.</p> <pre><code>public class JerseyClient { public static void main(String[] args) { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(getBaseURI()); String response = service.accept(MediaType.TEXT_XML) .header("Content-Type", "text/xml; charset=UTF-8") .entity(new File("E:/postx.xml")) .post(String.class); System.out.println(response); } private static URI getBaseURI() { return UriBuilder.fromUri("http://localhost:8080/MyService/rest/xmlServices/doSomething").build(); } } </code></pre> <p>Currently on the server side I have the following:</p> <pre><code>@POST @Path("/doSomething") @Consumes(MediaType.TEXT_XML) @Produces(MediaType.TEXT_XML) public Response consumeXMLtoCreate(ProcessJAXBObject jaxbObject) { </code></pre> <p>How do I change the above server side code so I can use stAX and stream one particular element to disk instead of converting all into objects into memory. My goal is to stream this element containing binary encoding data to disk.</p> <p>The payload I receive is like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ProcessRequest&gt; &lt;DeliveryDate&gt;2015-12-13&lt;/DeliveryDate&gt; &lt;AttachmentBinary&gt;iVBORw0KGgoAAAANSUhEUgAAAFoA&lt;/AttachmentBinary&gt; &lt;AttachmentBinary&gt;iVBORw0KGgoAAAANSUhEUgAAAFoA&lt;/AttachmentBinary&gt; &lt;/ProcessRequest&gt; </code></pre> <p>Following advice from @vtd-xml-author</p> <p>I now have the following:</p> <p>Server side:</p> <pre><code> @POST @Produces(MediaType.TEXT_XML) @Path("/doSomething") @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response consumeXMLtoCreate(@Context HttpServletRequest a_request, @PathParam("fileId") long a_fileId, InputStream a_fileInputStream) throws IOException { InputStream is; byte[] bytes = IOUtils.toByteArray(a_fileInputStream); VTDGen vg = new VTDGen(); vg.setDoc(bytes); try { vg.parse(false); } catch (EncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (EOFException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (EntityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); }// VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); try { ap.selectXPath("/ProcessRequest/BinaryAttachment/text()"); } catch (XPathParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } int i=0; try { while((i=ap.evalXPath())!=-1){ //i points to text node of String s = vn.toRawString(i); System.out.println("HAHAHAHA:" + s); // you need to decode them } } catch (XPathEvalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NavException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>and client side I have this:</p> <pre><code>File file = new File("E:/postx.xml"); FileInputStream fileInStream = null; fileInStream = new FileInputStream(file); ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(getBaseURI()); String tempImage = myfile.jpg; String sContentDisposition = "attachment; filename=\"" + tempImage+"\""; ClientResponse response = service.type(MediaType.APPLICATION_OCTET_STREAM) .header("Content-Disposition", sContentDisposition) .post(ClientResponse.class, fileInStream); </code></pre> <p>I have questions that arise from this solution, firstly how exactly am I avoiding the same memory issues if I end up with a String object in heap that I need to decode ?</p> <p>Secondly can I reconstitute an object or inputStream using vtd-xml once I've removed the image elements as I'd then like to process this using JAXB ?</p> <p>I believe XMLModifier's remove() method should allow me to have some sort of XML represent minus the element I have now written to disk.</p>
2
With openpyxl how can I find out how many cells are merged in .xlsx
<p>I have sheet where the "heading" are in merged cells and the value is in the cells under the "heading", see example.</p> <p>How can I count how many cells the heading spans? I need this to know where to start and stop reading the cells that belong to the "heading".</p> <pre><code>+-----------+-----------+ | Heading1 | Heading2 | +-----------+-----------+ | 1 | 2 | 3 | 3 | 3 | 4 | +---+---+---+---+---+---+ | 4 | 5 | 6 | 3 | 3 | 3 | +---+---+---+---+---+---+ </code></pre>
2
Execute shell command line by line from a file
<p>I have a .txt file which has sed replace commands on each line and has 1000+ entries. The file is on my server. Can any one please help me how to run the commands in file line by line and execute till the end of file.</p> <p>My txt file looks like </p> <pre><code>sed -i 's|http://www.myoldsite/url/category/another/blah|http://www.mynewsite.com|g' ./db.sql sed -i 's|http://www.myoldsite/url/category/blah/blah|http://www.mynewsite.com|g' ./db.sql sed -i 's|http://www.myoldsite/url/category/blah|http://www.mynewsite.com|g' ./db.sql </code></pre>
2
Python - breaking while loop with function (Raspberry Pi)
<p>I have a project that involves a raspberry pi, the dothat 16x2 lcd display and some python code. I am essentially trying to make a dynamic while loop that displays information on the lcd. I am also trying to add a function that cancels the while loop by pressing one of the touch buttons (reference: <a href="https://github.com/pimoroni/dot3k/blob/master/python/REFERENCE.md" rel="nofollow">https://github.com/pimoroni/dot3k/blob/master/python/REFERENCE.md</a>)</p> <p>This is what I got so far:</p> <pre><code>import dothat.lcd as l import dothat.backlight as b import dothat.touch as t from time import sleep import signal import os def main(): i=0 k=0 while True: l.clear() # Clear LCD screen b.hue(1.5) # Set background color l.set_cursor_position(0, 1) # Set cursor position on LCD l.write("%s" % k) # Write variable "k" to LCD @t.on(t.CANCEL) # When CANCEL button is pressed then go to function def cancel(ch, evt): i=1 # Set variable "i" as 1 return if i == 1: break k=k+1 sleep(1) l.clear() # Clear LCD screen b.off() # Turn the LCD Backlight off cmd='pkill python' # os(cmd) # Kill all python processes signal.pause() main() </code></pre> <p>The while loop is running but it won't break when the button is pressed. Ideas?</p>
2
bash compare the contents of two files and based on the results do two different actions
<p>Cannot use <strong>diff</strong> and cannot use <strong>cmp</strong>.</p> <p>We are able to use <strong>comm</strong> with success, but I am not getting the correct results when used with a conditional in script.</p> <pre><code>#!/bin/bash # http://stackoverflow.com/a/14500821/175063 comm -23 &lt;(sort /home/folder/old.txt) &lt;(sort /home/folder/new.txt) if [ $? -eq 0 ];then echo "There are no changes in the files" else echo "New files were found. Return code was $?" fi </code></pre> <p>It always returns:</p> <blockquote> <p>There are no changes in the files</p> </blockquote> <p>as the comm command, runs successfully but the contents of the files are different.</p> <p>I am very limited as to what can be added to this server as it is a corporate LINUX box.</p>
2
How to create a middleware that set a session variable on login in Django?
<p>As the question says, I'd like to set some variable to user session when the user get logged and remove this variable on logout or browser close.</p> <p>Initially I thought to write my custom login view to achieve this, but probably a middleware is a better solution.</p>
2
how to set a JSON object equal to another JSON object within the parent's declaration
<p>I'm new to javascript and json and messing around with some code. </p> <p>This is the format of my JSON object </p> <pre><code>messageData = { "attachment": { "type": "template", "payload": { "template_type": "generic", elements: [{ title: "titleOne", subtitle: "subtitleOne" }, { title: "titleTwo", subtitle: "subtitleTwo" }] } } } </code></pre> <p>Instead of going in an individually adding each title and subtitle object to elements I want to do this with a loop and just set one object equal to an array that contains many more numbers of title and subtitle objects. So lets say I have the object titles: </p> <pre><code>titles = {} //100 objects with different titles and subtitles. </code></pre> <p>Is there a way to implement this logic shown below? </p> <pre><code> messageData = { "attachment": { "type": "template", "payload": { "template_type": "generic", elements = titles } } } </code></pre> <p>Correctly formatting everything? Thanks for the help!</p>
2
String builder underline text
<p>How can I underline text in a string builder ?</p> <pre><code>strBody.Append("be a minimum of 8 characters") </code></pre> <p>I can't use HTML tags </p> <pre><code>be a minimum of &lt;u&gt;8 characters&lt;/u&gt; </code></pre>
2
shiny loading bar for htmlwidgets
<p>In R/Shiny, I am making some quite detailed htmlwidgets to go into a shiny app through a variety of packages, and can often take a long time to render.</p> <p>I would like to create a loading bar or use a loading gif to let the user know that it is loading...and to be patient while it loads.</p> <p>Below is an example of using the <code>dygraphs</code> package that takes quite a while to load once you start including more and more data, i.e. shift the slider higher and higher...and loading times take longer and longer...</p> <p>I am unsure how to incorporate the progress indicator (<a href="http://shiny.rstudio.com/articles/progress.html" rel="nofollow noreferrer">http://shiny.rstudio.com/articles/progress.html</a>) into this...but am open to other suggestions on demonstrating the loading indicator...</p> <pre><code># load libraries require(dygraphs) require(shiny) require(xts) # create a simple app runApp(list( ui = bootstrapPage( sliderInput('n', '10 to the power x', min=2,max=7,value=2), dygraphOutput('plot1') ), server = function(input, output) { output$plot1 &lt;- renderDygraph({ v &lt;- 10^(input$n) out &lt;- dygraph(xts(rnorm(v),Sys.time()+seq(v))) %&gt;% dyRangeSelector() return(out) }) } )) </code></pre> <p><strong>* EDIT *</strong></p> <p>I attempted the below based on suggestions from @Carl in his comments....but it didn't seem to work...please see the below...</p> <pre><code># load libraries require(dygraphs) require(shiny) require(shinydashboard) require(xts) # create a simple app ui &lt;- dashboardPage(title='Loading graphs', dashboardHeader( title = 'Loading Graphs' ), dashboardSidebar( sliderInput('n', '10 to the power x', min=2,max=7,value=2) ), dashboardBody( tags$head(tags$style(type="text/css", " #loadmessage { position: fixed; top: 0px; left: 0px; width: 100%; padding: 5px 0px 5px 0px; text-align: center; font-weight: bold; font-size: 100%; color: #000000; background-color: #CCFF66; z-index: 105; } ")), dygraphOutput('plot1'), conditionalPanel(condition="$('html').hasClass('shiny-busy')", tags$div("Loading...",id="loadmessage")) ) ) server &lt;- function(input, output) { output$plot1 &lt;- renderDygraph({ v &lt;- 10^(input$n) out &lt;- dygraph(xts(rnorm(v),Sys.time()+seq(v))) %&gt;% dyRangeSelector() return(out) }) } shinyApp(ui=ui,server=server) </code></pre> <p>Neither did the following:</p> <pre><code># load libraries require(dygraphs) require(shiny) require(shinydashboard) require(xts) # create a simple app ui &lt;- dashboardPage(title='Loading graphs', dashboardHeader( title = 'Loading Graphs' ), dashboardSidebar( sliderInput('n', '10 to the power x', min=2,max=7,value=2) ), dashboardBody( tags$head(tags$style(HTML(" .progress-striped .bar { background-color: #149bdf; background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.6)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.6)), color-stop(0.75, rgba(255, 255, 255, 0.6)), color-stop(0.75, transparent), to(transparent)); background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent); background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent); -webkit-background-size: 40px 40px; -moz-background-size: 40px 40px; -o-background-size: 40px 40px; background-size: 40px 40px; }"))), dygraphOutput('plot1') ) ) server &lt;- function(input, output) { output$plot1 &lt;- renderDygraph({ v &lt;- 10^(input$n) withProgress(message = 'Making plot', value = 1, { out &lt;- dygraph(xts(rnorm(v),Sys.time()+seq(v))) %&gt;% dyRangeSelector() }) return(out) }) } shinyApp(ui=ui,server=server) </code></pre> <p><strong>* EDIT2 *</strong></p> <p>could something like the solution to this question be used?</p> <p><a href="https://stackoverflow.com/questions/7505318/how-to-display-busy-image-when-actual-image-is-loading-in-client-machine">How to display busy image when actual image is loading in client machine</a></p>
2
fatal error: unexpectedly found nil while unwrapping an Optional value on performing segue
<p>I am logging in using facebook SDK and everything is properly setup. When I authorize my app for first time, the segue gets performed to my next view controller. But when I logout and try to login again, the segue gives an error</p> <p><strong>fatal error: unexpectedly found nil while unwrapping an Optional value</strong></p> <p>This is my code in my appDelegate file</p> <pre><code>func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -&gt; Bool{ let result = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) if result { let token = FBSDKAccessToken.currentAccessToken() let fieldsMapping = [ "id" : "facebookId", "name" : "name", "email": "email" ] backendless.userService.loginWithFacebookSDK( token, fieldsMapping: fieldsMapping, response: { (user: BackendlessUser!) -&gt; Void in print("user: \(user)") self.backendless.userService.setStayLoggedIn(true) loadUser() // Access the storyboard and fetch an instance of the view controller let storyboard = UIStoryboard(name: "Main", bundle: nil) let viewController: MainScreenViewController = storyboard.instantiateViewControllerWithIdentifier("loginViewController") as! MainScreenViewController let rootViewController = self.window!.rootViewController! as UIViewController print(rootViewController) rootViewController.presentViewController(viewController, animated: true, completion: nil) }, error: { (fault: Fault!) -&gt; Void in print("Server reported an error: \(fault)") }) } return result } </code></pre> <p>the error occurs at rootViewController.presentViewController(viewController, animated: true, completion: nil)</p> <p>I have tried performing segue in my viewController in viewDidAppear(), and also tried performSegueWithIdentifier() but the error persists. If I kill my application and try again, the segue works fine. Please suggest me where is the problem. Thanks in advance.</p>
2
Symfony 3 Doctrine MySQL - generate entities with @ORM annotations
<p>according to Symfony 3 docs after running 3 commands:</p> <pre><code>php bin/console doctrine:mapping:import --force AcmeBlogBundle xml php bin/console doctrine:mapping:convert annotation ./src php bin/console doctrine:generate:entities AcmeBlogBundle </code></pre> <p>I should get the result of something like:</p> <pre><code>// src/Acme/BlogBundle/Entity/BlogComment.php namespace Acme\BlogBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Acme\BlogBundle\Entity\BlogComment * * @ORM\Table(name="blog_comment") * @ORM\Entity */ class BlogComment { /** * @var integer $id * * @ORM\Column(name="id", type="bigint") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string $author * * @ORM\Column(name="author", type="string", length=100, nullable=false) */ private $author; ..... </code></pre> <p>unfortunately instead of I get roughly mapped class with getters and setters looking like so:</p> <pre><code>&lt;?php namespace Clashers\PanelBundle\Entity; /** * Users */ class Users { /** * @var string */ private $username; /** * Set username * * @param string $username * * @return Users */ public function setUsername($username) { $this-&gt;username = $username; return $this; } /** * Get username * * @return string */ public function getUsername() { return $this-&gt;username; } </code></pre> <p>Does any of you have faced such an issue and have solved it with no need to manually assign every property to DB type, column? Is there any Doctrine setting(s) I've missed to generate those entities properly?</p>
2
Optional INT parameter in Web API Attribute Routing
<p>I'm trying to create an API method in an ASP.NET Core app that may or may not receive an integer input parameter. I have the following code but getting an error with this. What am I doing wrong?</p> <pre><code>// GET: api/mycontroller/{id} [HttpGet("id:int?")] public IActionResult Get(int id = 0) { // Some logic here... } </code></pre> <p>Here's the error I'm getting: <a href="https://i.stack.imgur.com/RtQnF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RtQnF.png" alt="enter image description here"></a></p>
2
Generate SQL script to create or alter table / stored procedures
<p>I am creating a SQL script that will check weather the object is there or not and then do create or alter based on that.</p> <pre><code>if not exists (select * from sysobjects where name='MyTableName' and xtype='U') create table MyTableName( Id int not null, Name varchar(150) not null ) Else --Alter </code></pre> <p>Now having to do this for a bigger database which has more than 150 table.</p> <p>Is there any way I can generate this automatically for tables and stored procedures?</p>
2
Connect an even number of nodes without intersection
<p>I have two sets of n nodes. Now I want to connect each node from one set with another node from the other set. The resulting graph should have no intersections.</p> <p>I know of several sweep line algorithms (<a href="https://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm" rel="noreferrer">Bentley-Ottmann-Algorithm</a> to check where intersections occur, but I couldn't find an algorithm to solve those intersections, except for a brute-force approach.</p> <p>Each node from one set can be connected to any other node within the other set.</p> <p>Any pointers to (an efficient) algorithm that solves this problem? No implementation needed.</p> <p><strong>EDIT1</strong>:</p> <p>Here is one solution to the problem for <code>n=7</code>:</p> <p><a href="https://i.stack.imgur.com/wNPh1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wNPh1.png" alt="Intersection problem"></a></p> <p>The black dots are a set of nodes and the red dotes are a set. Each black node has to be connected to one red node so that the lines connecting them are not crossing.</p> <p><strong>EDIT2:</strong></p> <p>To further clarify: The positions of all the nodes are fixed and the resulting graph will have n edges. I also don't have any proof that a solution exists, but I couldn't create an example where there was no solution. I'm sure there is a proof out there somewhere that creating such a planar graph is always possible. Also, only <strong>one</strong> solution is needed, not all possible solutions.</p>
2
Unable to create call adapter rx.Observable<POJO>
<p>I'm trying to make a very basic Retrofit/RxJava setup. So I'm trying to consume this API: <a href="http://jsonplaceholder.typicode.com/posts" rel="nofollow">http://jsonplaceholder.typicode.com/posts</a></p> <p>My basic setup is as follows;</p> <p>My retrofit service:</p> <pre><code>public interface SimpleTestService { String endpoint = "jsonplaceholder.typicode.com"; @GET("/posts") Observable&lt;Post&gt; getPosts(); } </code></pre> <p>Creating the service:</p> <pre><code>public class TestAdapter { public static SimpleTestService createService() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://wwww.jsonplaceholder.typicode.com") .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build(); SimpleTestService service = retrofit.create(SimpleTestService.class); return service; } } </code></pre> <p>Making my call:</p> <pre><code>SimpleTestService testService = TestAdapter.createService(); testService.getPosts() .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber&lt;Post&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(Post post) { String text = testText.getText().toString(); text += post.getBody(); testText.setText(text); } }); </code></pre> <p>When I try to do this, I get the exception:</p> <pre><code>java.lang.IllegalArgumentException: Unable to create call adapter for rx.Observable&lt;Post&gt; </code></pre> <p>This is weird to me since I do explicitly add the RX call adapter. I also include all of these things in my build.gradle</p> <p>any tips?</p> <p>Thanks!</p>
2
Linux Kernel Decompressing Linux message not getting printed on UART
<p>I am working on an embedded Project with Minnowboard Max and customized Linux kernel with u-boot.</p> <p>The Kernel command line parameters: </p> <pre><code>initcall_debug=1 video=HDMI-A-1:1920x1200MR@60D console=ttyS0,115200 console=tty0 </code></pre> <p>I am seeing that none of the debug_pustr messages defined in the misc.c file is getting printed in the serial port.</p> <pre><code>debug_putstr("\nDecompressing Linux... "); </code></pre> <p>I have also enabled <code>CONFIG_X86_VERBOSE_BOOTUP =y</code> in the kernel menuconfig. </p> <p>Is there any way to see these messages in the serial port?</p>
2
Comma-Separated List of Media Queries Not Working
<p>I am coding a site with AngularJS and SCSS. I am in the mobile-phase of development and I quickly discovered (for this project) that I needed a way to target multiple breakpoints using a <code>@media</code> query. So I found via <a href="https://stackoverflow.com/questions/7668301/is-it-possible-to-nest-media-queries-within-media-queries">this SO answer</a> and <a href="https://css-tricks.com/logic-in-media-queries/" rel="nofollow noreferrer">this CSS Tricks Post</a> as well as multiple other answers on SO. Then I implemented the solutions I found into a test-case, see snippet below for the test.</p> <pre class="lang-css prettyprint-override"><code>main { background-color: grey; height: 100%; min-height: 1000px; @media (max-width: 992px) { background-color: red } @media (max-width: 768px) { background-color: lightcoral } @media (max-width: 992px), (max-width: 992px) and (orientation: landscape) { background-color: lightgreen; } @media (max-width: 768px), (max-width: 768px) and (orientation: landscape) { background-color: lightblue; // Reset the min-height here, because we no longer have the sticky search bar. min-height: 450px; } } </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;main&gt; &lt;h1&gt;Page Title&lt;/h1&gt; &lt;h2&gt;Some Descriptive information&lt;/h2&gt; &lt;div&gt;Content&lt;/div&gt; &lt;/main&gt; </code></pre> <p>But I haven't been able to get it to work. What I am trying to do, ultimately, is have styles that are applied when the user is in landscape on a tablet, or phone. However, I don't know if I am doing it right, or using the <code>or</code> operator correctly.</p> <p>It plain doesn't work, well, the first statement (for example: <code>(max-width: 992px)</code>) works, but the second one doesn't evaluate to true. According to Mozilla:</p> <blockquote> <p>Comma-separated lists behave like the logical operator or when used in media queries. When using a comma-separated list of media queries, if any of the media queries returns true, the styles or style sheets get applied. Each media query in a comma-separated list is treated as an individual query, and any operator applied to one media query does not affect the others. --- <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#Logical_operators" rel="nofollow noreferrer">Mozilla Documentation</a></p> </blockquote> <p>Even if I break the code into two separate media queries:</p> <pre class="lang-css prettyprint-override"><code>@media (max-width: 992px) { background-color: lightgreen; } @media (max-width: 992px) and (orientation: landscape) { background-color: lightgreen; } </code></pre> <p>It still doesn't work. So I don't know if I am targeting the wrong width (when in landscape) or what I am doing wrong. Can any other Front-End developers out there tell me why my comma seperated media queries aren't working?</p> <p><strong>EDIT:</strong> Here is the native SCSS code:</p> <pre class="lang-css prettyprint-override"><code>main { background-color: $mono-90; height: 100%; min-height: 1000px; @media screen and (max-width: map_get($grid-breakpoints, 'md')) { // Reset the min-height here, because we no longer have the sticky search bar. min-height: 450px; } @media (max-width: map_get($grid-breakpoints, 'lg')), (max-width: map_get($grid-breakpoints, 'lg')) and (orientation: landscape){ background-color: lightgreen; } @media (max-width: map_get($grid-breakpoints, 'md')), (max-width: map_get($grid-breakpoints, 'md')) and (orientation: landscape){ background-color: lightblue; } @media (max-width: map_get($grid-breakpoints, 'sm')), (max-width: map_get($grid-breakpoints, 'sm')) and (orientation: landscape){ background-color: lightcoral; } } </code></pre> <p><strong>EDIT:</strong> Per the recommendation of @Godwin, I simplified my <code>@media</code> queries to this:</p> <pre class="lang-css prettyprint-override"><code>main { background-color: $mono-90; height: 100%; min-height: 1000px; @media screen and (max-width: map_get($grid-breakpoints, 'md')) { // Reset the min-height here, because we no longer have the sticky search bar. min-height: 450px; } @media screen and (max-width: map_get($grid-breakpoints, 'lg')) { background-color: lightgreen; } @media screen and (max-width: map_get($grid-breakpoints, 'md')) { background-color: lightblue; } @media screen and (max-width: map_get($grid-breakpoints, 'sm')) { background-color: lightcoral; } } </code></pre> <p>However, it doesn't work on iPad Landscape (1024x768). I <em>don't</em> want it to show on Laptops, but <em>do</em> want it to show on iPads in Landscape position.</p>
2
Unity- Standalone build run out of memory
<p>So I already asked this question on the unity forums but that didn't help me a lot :/. Today I decided to give my game a try with friends so basically I created a server so other clients/friends could connect to it. After about 20 minutes of playing my game crashed and I quickly checked task manager and my game was using about 3.5 GB of RAM! <a href="http://i.stack.imgur.com/2F0KM.png" rel="nofollow">PHOTO HERE</a> When I looked at the log it said something like this:</p> <pre><code>Unity Player [version: Unity 4.6.1f1_d1db7a1b5196] mono.dll caused an Access Violation (0xc0000005) in module mono.dll at 0023:101071a1. Error occurred at 2016-07-04_163050. C:\Users\Cooler Master\Desktop\TL\TL.exe, run by Cooler Master. 77% memory in use. 0 MB physical memory [1814 MB free]. 0 MB paging file [1039 MB free]. 0 MB user address space [68 MB free]. Write to location 00000000 caused an access violation. </code></pre> <p>So in my game there is something that keeps eating my RAM. It takes about 3MB per second of ram when the game is running. I found some information on internet about Resources.UnloadUnusedAssets but I don't know how to write a script like that! I knew how to write in c# but only the easy scripts like GUI,Newtorkinf,Physics etc.. Also I downloaded unity pro from kickasstorrent only to see profiler window but that didn't help me at all</p> <p>Thank very much for any reply ! Also if you want to check out the game and see what's happening : <a href="http://gamejolt.com/games/thuglifealpha/61660" rel="nofollow">http://gamejolt.com/games/thuglifealpha/61660</a></p> <p>Thanks again! :)</p>
2
Get device tilt in degrees on each axis in Unity?
<p>I'm currently pulling my hair with this issue while developing a game where you can decide on which axis you're going to control.</p> <p>I have read and studied so much about quanternions, gyros, accelerometers, Kalman and complementary filters... But still I'm lost with this issue:</p> <p>Axis here are from my enumeration, not gyro axis. </p> <p>The following code gives the best results so far. The problem here is that either Y (up/down tilting) or Z axis (lengthwise tilting) aren't working and are somehow mixed, depending a run in device. </p> <p>X-axis (like steering wheel) is working as expected.</p> <pre><code> private float GetCurrentTiltByAxis() { float ret = 0; if (AccelerometerAxis == Axis.X) { ret = Input.gyro.attitude.eulerAngles.z; } else if (AccelerometerAxis == Axis.Y) { #if UNITY_ANDROID ret = Input.gyro.attitude.eulerAngles.x; #else ret = Input.gyro.attitude.eulerAngles.y; #endif } else if (AccelerometerAxis == Axis.Z) { #if UNITY_ANDROID ret = Input.gyro.attitude.eulerAngles.y; #else ret = Input.gyro.attitude.eulerAngles.x; #endif } return ret; } </code></pre> <p>I'm using the latest stable unity and looking to build for iOS and Android. Orientation is fixed to Landscape left.</p> <p>All I would need is a function that returns angle of current tilt in specified axis?</p> <p>Any help would be appreciated</p>
2
Why it happens - RelatedObjectDoesNotExist error caused by Model.clean()?
<p>I have a clean method that gives me RelatedObjectDoesNotExist error in my model file </p> <pre><code>@with_author class BOMVersion(models.Model): version = IntegerVersionField( ) name = models.CharField(max_length=200,null=True, blank=True) description = models.TextField(null=True, blank=True) material = models.ForeignKey(Material) creation_time = models.DateTimeField(auto_now_add=True, blank=True) abovequantity = models.DecimalField(max_digits=19, decimal_places=10) belowquantity = models.DecimalField(max_digits=19, decimal_places=10) valid_from = models.DateTimeField(null=True, blank=True) valid_to = models.DateTimeField(null=True, blank=True) is_default = models.BooleanField(default=False) def clean(self): model = self.__class__ if model.objects.filter(material=self.material, is_default=True).count() &gt; 1: raise ValidationError('Material {} has a defaul value already'.format(self.material)) </code></pre> <p>UPDATE: Traceback </p> <pre><code>&gt; Traceback: File &gt; "C:\Users\I812624\dev\mrp\lib\site-packages\django\core\handlers\base.py" &gt; in get_response &gt; 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\I812624\dev\mrp\lib\site-packages\django\contrib\auth\decorators.py" &gt; in _wrapped_view &gt; 22. return view_func(request, *args, **kwargs) File "C:\Users\I812624\dev\mrp\src\item\views\viewsbomversion.py" in &gt; bomversion_new &gt; 68. if form.is_valid(): File "C:\Users\I812624\dev\mrp\lib\site-packages\django\forms\forms.py" in &gt; is_valid &gt; 184. return self.is_bound and not self.errors File "C:\Users\I812624\dev\mrp\lib\site-packages\django\forms\forms.py" in &gt; errors &gt; 176. self.full_clean() File "C:\Users\I812624\dev\mrp\lib\site-packages\django\forms\forms.py" in &gt; full_clean &gt; 394. self._post_clean() File "C:\Users\I812624\dev\mrp\lib\site-packages\django\forms\models.py" in &gt; _post_clean &gt; 430. self.instance.full_clean(exclude=exclude, validate_unique=False) File &gt; "C:\Users\I812624\dev\mrp\lib\site-packages\django\db\models\base.py" &gt; in full_clean &gt; 1132. self.clean() File "C:\Users\I812624\dev\mrp\src\item\models.py" in clean &gt; 673. if model.objects.filter(material=self.material, is_default=True).count() &gt; 1: File &gt; "C:\Users\I812624\dev\mrp\lib\site-packages\django\db\models\fields\related.py" &gt; in __get__ &gt; 608. "%s has no %s." % (self.field.model.__name__, self.field.name) &gt; &gt; Exception Type: RelatedObjectDoesNotExist at &gt; /item/bomversion/new/1/http://127.0.0.1:8000/item/material/material_bomversion_details/1/ &gt; Exception Value: BOMVersion has no material. </code></pre> <p>It looks like material is not visible from within clean method. It is ok if I remove the material from the validation and leave only is_default field.</p> <p>I am clueless why.....</p> <p>UPDATE:</p> <p>the problem is probably that material value is not coming from the form but gets populated in the view</p> <pre><code> if form.is_valid(): bomversion= form.save(commit=False) bomversion.creation_time = timezone.now() bomversion.material = material bomversion.save() </code></pre>
2
Efficient way to extract data within double quotes
<p>I need to extract the data within double quotes from a string.</p> <p>Input:</p> <pre><code>&lt;a href="Networking-denial-of-service.aspx"&gt;Next Page →&lt;/a&gt; </code></pre> <p>Output:</p> <pre><code>Networking-denial-of-service.aspx </code></pre> <p>Currently, I am using following method to do this and it is running fine.</p> <pre><code>atag = '&lt;a href="Networking-denial-of-service.aspx"&gt;Next Page →&lt;/a&gt;' start = 0 end = 0 for i in range(len(atag)): if atag[i] == '"' and start==0: start = i elif atag[i] == '"' and end==0: end = i nxtlink = atag[start+1:end] </code></pre> <p>So, my question is that is there any other efficient way to do this task.</p> <p>Thankyou.</p>
2
Nginx PHP-FPM and curl hangs subsequent browser to server requests
<p>I have php-fpm &amp; nginx stack installed on my server. </p> <p>I'm running a JS app which fires an AJAX request that internally connects to a third party service using curl. This service takes a long time to respond say approximately 150s. </p> <p>Now, When i connect to the same page on another browser tab, it doesn't even return the javascript code on the page which triggers the ajax requests. Basically all subsequent requests keep loading until either the curl returns response or it timeouts.</p> <p>Here, i have proxy_read_timeout set to 300 seconds. </p> <p>I want to know why nginx is holding the resource and not serving other clients.</p>
2
notification localization for data-only firebase push
<p>I have overrided <code>public void onMessageReceived(RemoteMessage remoteMessage)</code> in <code>FirebaseMessagingService</code>.</p> <p>Then i send data-only push. </p> <p>When screen of device is on <code>onMessageReceived</code> is called successfully. Some little time after device locking (screen is off) <code>onMessageReceived</code> is called successfully too (for another sended push of course).</p> <p>But if device is in <strong>deep sleep</strong> mode then <code>onMessageReceived</code> is not called until i press lock/power button.</p> <p>Are there any idea, how to popup notification in deep sleep as soon as push sended?</p> <p>PS: if i use notification-payload in firebase push - i can't localize it in android app (if you have any idea about it - it's superb too).</p>
2
Node.js multiparty upload is not working
<p>The <code>multiparty.Form()</code> is not working. I'm trying to print. (e.g. 2,3,4)</p> <p>Here is my image upload code:</p> <pre><code>app.post('/gallery/add',function(req, res,next) { var input = JSON.parse(JSON.stringify(req.body)); var multipart = require('connect-multiparty'); var multiparty = require('multiparty'); var format = require('util').format; var fs = require("fs"); var path = require('path'); var tempPath =req.files.image.path; var filename2 =req.files.image.originalFilename; req.getConnection(function (err, connection) { console.log('1'); var form = new multiparty.Form(); var image; var title; form.on('error', next); form.on('close', function(err, fields, files){ console.log('2'); if(err) { next(err); console.log(err); } else { console.log('3'); ins = fs.createReadStream(tempPath); ous = fs.createWriteStream(__dirname + '/uploads/' + image.filename); util.pump(ins, ous, function(err) { if(err) { next(err); } else { res.redirect('/#gallery/add'); res.end(); } }); //console.log('\nUploaded %s to %s', files.photo.filename, files.photo.path); //res.send('Uploaded ' + files.photo.filename + ' to ' + files.photo.path); } res.send(format('\nuploaded %s (%d Kb) as %s' , image.filename , image.size / 1024 | 0 , title)); }); // listen on field event for title form.on('field', function(name, val){ console.log('4'); if (name !== 'title') return; title = val; }); // listen on part event for image file form.on('part', function(part){ console.log('5'); if (!part.filename) return; if (part.name !== 'image') return part.resume(); image = {}; image.filename = part.filename; image.size = 0; part.on('data', function(buf){ image.size += buf.length; }); }); // parse the form form.parse(req); }); }); </code></pre> <p>It seems like the <code>form.on</code> method is not working.</p> <p>Where am I going wrong?</p>
2
How to optimize speed for multiple CURL get requests in PHP?
<p>I'm connecting to an API with PHP through a CURL GET and I receive a json with almost 5000 orders. For every order I make another CURL GET and receive the order details (basically 2 foreach). After that I make some inserts and updates in the database (basic stuff) with LARAVEL.</p> <p>The big problem is that for those 5000 orders I have a loading time of almost one hour. I need to this with a cron every night (and for more than 5000).</p> <p>I have a cloud solution with 2GB Memory and 2 CoreProcessor.</p> <p>I tried also Zebra Curl but cannot use that with curl in curl request.</p>
2
Firebase Analytic Search_Term Param value not showing
<p>I want to log user search event to Firebase but the Search_Term param value in the Search event doesn't show up in the dashboard. Here my code:</p> <pre><code>Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.SEARCH_TERM, searchText); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SEARCH, bundle); </code></pre> <p>I have tried to log different event with other param and the param value show up in dashboard correctly! </p> <p>How can I fix this? Thank you</p>
2
CakePHP 3 - How to order find result by associated model
<p>I am building a comment, with replies system using CakePHP and Backbone. But I am having some issues with my CakePHP query, that does not order in the way it needs to be.</p> <p>So this is database system I have right now,</p> <pre><code>Posts ID (Auto, PK) MainPost (Long Text) Timestamp User_id Comments ID (Auto, PK) SubComment (Long Text) Timestamp User_id Post_id (FK, linking to the Posts table) </code></pre> <p>Now I think my model is ok (if needed I can post that code). I can save and update the posts and comments. But what I need to when a new comment is added to the system. That whole post is moved to the top. </p> <p>This is the query I have done on my <code>Posts</code> Table,</p> <pre><code> $Table-&gt;find('all') -&gt;contain(['Comments', 'Comments.Users', ]) // -&gt;order(['Posts.Comments.timestamp' =&gt; 'DESC']) // -&gt;matching('Comments', function ($q) { // return $q-&gt;where(['Comments.timestamp' =&gt; 'DESC']); // }) -&gt;toArray(); </code></pre> <p>So I want to do a sort, like my order looks above, I basically want to order my Posts Table based on the timestamp of my Comments Table. </p> <p>When I run this query, with order enabled, it just says that "Unknown column" but I don't know why? I have a <code>LeftJoin</code> in my model linking the Comments to my Posts table. </p> <p>I have tried doing <code>sorts</code> and <code>orders</code> within the <code>contain</code> call of the query, however these just sort/order the comments and not the posts!</p> <p>So what am I doing wrong? </p>
2
How to set dynamic label size in UITableViewCell
<p>I have TableViewCell and load data by web service (JSON), Data stored in different-different array and data load in tableview. I want to array data size some time large and some time small. so how will manage label size. I tried may examples but do not make dynamic label. please help, Thank You. </p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [title count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //NSLog(@"tableview cell"); TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"event"]; if (cell==nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Cell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString: [img objectAtIndex:indexPath.row]]]; UIImage* image = [[UIImage alloc] initWithData:imageData]; cell.img.image =image; cell.lbl_1.text=[NSString stringWithFormat:@"%@",[title objectAtIndex:indexPath.row]]; cell.lbl_2.text=[NSString stringWithFormat:@"%@",[des objectAtIndex:indexPath.row]]; cell.lbl_3.text=[NSString stringWithFormat:@"%@",[evnt_ary objectAtIndex:indexPath.row]]; return cell; } </code></pre>
2
Path in PartialView method ( to share them between applications)
<p>I want to share some Partial View between some applications. I tried different solutions which are suggested in internet, but none of them not work! But I hope by using absolute or relation path in <code>PartialView</code> method it works but I don't know is it possible or no.</p> <p>So there are 2 questions here:</p> <ol> <li>If I create a common project in my solution as a sub domain, can I use a <strong>URL</strong> of it in other project's <code>PartialView</code> method?</li> <li>If I create common folder in my solution, I use a path something like <code>"~/../Common/myView.cshtml"</code>. In this case Visual Studio not take error to me on editor by on runtime I got an error ("Cannot use a leading .. to exit above the top directory"). So is any solution to use a path of a common folder outside the root?</li> </ol> <p>I know that it'was better that I separate these question into 2 ones, but as there was no solution to share partial views I gather them here.</p> <p>As you can see there is a Common folder in my solution which contains <code>_MainMenu.cshtml</code> and also I have this file in Shared Folder in Website project too. </p> <p>How should I write PartialView in Admin controller to path to each of them?</p> <p>I want some code like these:</p> <p>For Common folder:</p> <p><code>return PartialView("~/../Common/_MainMenu.cshtml");</code></p> <p>For shared folder:</p> <p><code>return PartialView("http://localhost:16287/Module/Menu/_MainMenu");</code></p> <p><a href="https://i.stack.imgur.com/pBvLq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pBvLq.png" alt="enter image description here"></a></p>
2
How to execute sql query on a table whose name taken from another table
<p>I have a table that store the name of other tables. Like</p> <pre><code>COL_TAB -------------- TABLE_NAME -------------- TAB1 TAB2 TAB3 </code></pre> <p>What i want to do is that, i want to run a sql query on table like this,</p> <pre><code>SELECT * FROM (SELECT TABLE_NAME from COL_TAB WHERE TABLE_NAME = 'TAB1') </code></pre> <p>Thanks</p>
2
C++ - Cannot 'new' an array on unknown size in spite of Braced-List initialization?
<p><strong>Preface:</strong> </p> <p>I've found nothing around about this issue. The only thing I've found is people dynamically allocating an array without providing any information about the size of said array, like this <code>int* p = new int[];</code></p> <p>My issue is different:</p> <pre><code>float arr[]{ 1,2,3 }; float* p = new float[]{1, 2, 3}; </code></pre> <p>The first line compiles fine, the second one doesn't:</p> <blockquote> <p><strong>Error C3078</strong> Array size must be specified in new expressions</p> </blockquote> <p>I wonder: why didn't the compiler evaluate the array size from the list-initialization like it did in the first case?</p>
2
Creating a CSS file to change emphasized text in an html file
<p>Sorry if this is an extremely basic/noob question, but I just dipped into html/css and seem to have run into a little problem. Below is the code I have tried for my css file</p> <pre><code>h3{ font-family: Times, Times New Roman, serif; font-size: 1.3em; text-transform: uppercase; text-align: right; color: maroon; } p{ text-emphasis: green; } body { background-color: #e6e6fa; font-family: Arial, sans-serif; font-size: 1.2em; text-emphasis: green; } </code></pre> <p>Ignore the header and body stuff, that is just other (working) parts of the css. I tried sticking "text-emphasis" into other sections (header and body) but <em>nothing</em> seems to change the emphasized text to green (I also need to make it bold, which I'm not sure which command can do that)</p> <p>Again, sorry for the very nooby and vague question. Basically what I need to do is make emphasized text (that appears in 2 paragraphs in my html file) green and bold, instead of it just being italicized. I know this is very spoon-feedy but i've tried different attempts to no avail. thank you all!</p>
2
How to set label width to width of another label
<p>I'm in the process of writing a GUI for my program (see <a href="http://sonrad-ai.tk" rel="nofollow">here</a> for the CLI version) and one of the tasks it does is download an information file from dropbox and displays it to the user. The information it downloads is displayed in a label, and then text input from the user, and output from the program, is displayed in a second label below this. Because I can change the information that it downloads, the width of the top label is variable, and I would like the bottom label to change to be the same width as the top label. </p> <p>I've used the following codes to try and achieve the result, but nothing seems to work, as the bottom label ends up being either too long or too short:</p> <p><code>conv.configure(width=inf.winfo_width())</code> returns 950</p> <p><code>conv.configure(width=inf.cget('width'))</code> returns 0</p> <p><code>conv.configure(width=inf['width'])</code> returns 0</p> <p><code>conv.configure(width=len(max(open('information.txt'), key=len)))</code> returns 178 (the length of the longest line)</p> <p>Here is the GUI layout that I have written:</p> <pre><code>from tkinter import * import urllib root=Tk() root.title("ARTIST AI") inf=Label(root, relief="raised", text="INFORMATION", anchor=N, justify=LEFT) inf.grid(row=0, column=0, columnspan=2) conv=Label(root, height=10, relief="raised", anchor=N, justify=LEFT) conv.grid(row=1, column=0, columnspan=2) ent=Text(root, width=40, height=2) ent.grid(row=2, column=0) sub=Button(root, text="Submit", width=10, height=2, relief="raised", command=getinput) sub.grid(row=2, column=1) try: #Downloads the inforrmation from the Info.txt file in my dropbox account to be displayed to the user. info=urllib.request.urlopen("https://www.dropbox.com/s/h6v538utdp8xrmg/Info.txt?dl=1").read().decode('utf-8') f=open("information.txt", "w") f.write(info) f.close() except urllib.error.URLError: try: info=open("information.txt", "r").read() info=info.replace("\n\n", "\n") info="No internet connection available: using last available information"+"\n\n"+info except FileNotFoundError: info="No information available. Will download information on next valid connection." inf.configure(text=info) conv.configure(width=length_of_inf_label) mainloop() </code></pre> <p>If anyone knows how to do this, any help is greatly appreciated.</p> <p>Thanks in advance.</p>
2
Exception:unable to resolve method using strict-mode: com.realtech.flight.FlightStatus.speed() in kie-server container
<p>I am a new in drools, I am trying to execute a simple CEP rule on Drools kie server 6.4.0.Final running on Tomcat7, but I am getting following error when i try to start the kie container.</p> <pre><code>[localhost-startStop-1] DEBUG KieModule Lookup. ReleaseId com.realtech:stdout:1.0-SNAPSHOT was not in cache, checking classpath [localhost-startStop-1] DEBUG KieModule Lookup. ReleaseId com.realtech:stdout:1.0-SNAPSHOT was not in cache, checking maven repository [localhost-startStop-1] ERROR Unable to build KieBaseModel:kbase1 Unable to Analyse Expression speed == 200: [Error: unable to resolve method using strict-mode: com.realtech.flight.FlightStatus.speed()] [Near : {... speed == 200 ....}] ^ [Line: 15, Column: 4] : [Rule name='flight print'] </code></pre> <p>My code is like:</p> <p>FlightStatus.drl</p> <pre><code>package com.realtech.flight; //import com.realtech.flight.FlightStatus; declare FlightStatus @role(event) end rule "flight print" no-loop true when $flight : FlightStatus( speed == 200 ) // over window:time(1m) then System.out.println("test"); end </code></pre> <p>FlightStatus.java</p> <pre><code>package com.realtech.flight; /** * This class was automatically generated by the data modeler tool. */ public class FlightStatus implements java.io.Serializable { static final long serialVersionUID = 1L; public java.lang.Float speed; public FlightStatus() { } public java.lang.Float getSpeed() { return this.speed; } public void setSpeed(java.lang.Float speed) { this.speed = speed; } public FlightStatus(java.lang.Float speed) { this.speed = speed; } } </code></pre> <p>knowledge base settings in kie-workbench: <a href="http://i.stack.imgur.com/BMOVx.png" rel="nofollow">enter image description here</a></p> <p>and then I got the exception when start containter in kie-server.</p> <p>But it's successful when I delete the declare:</p> <pre><code>declare FlightStatus @role(event) end </code></pre> <p>or delete <code>speed == 200</code>.</p> <p>sorry for my bad english.</p>
2
Using a variable in XAML binding expression
<p>I'm building a control that can edit POCOs. There is a descriptor collection for the fields within the POCO that need to be edited and I'm binding a <code>ListBox</code>'s <code>ItemsSource</code> to this collection. Amongst other things, the descriptor gives me the ability to select a suitable <code>DataTemplate</code> and the variable name in the POCO that this <code>ListBox</code> item should edit.</p> <p>My ListBox is built like this:</p> <pre><code>&lt;ListBox ItemsSource="{Binding ColumnCollection, ElementName=root}"&gt; &lt;ListBox.Resources&gt; &lt;DataTemplate x:Key="TextTemplate"&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding DisplayName}" /&gt; &lt;!-- !!! Question about following line !!! --&gt; &lt;TextBox Text="{Binding ElementName=vm.CurentEditing, Path=PathName}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;!-- Details omitted for brevity --&gt; &lt;DataTemplate x:Key="PickListTemplate" /&gt; &lt;DataTemplate x:Key="BooleanTemplate" /&gt; &lt;/ListBox.Resources&gt; &lt;ListBox.ItemTemplateSelector&gt; &lt;local:DataTypeSelector TextTemplate="{StaticResource TextTemplate}" PickListTemplate="{StaticResource PickListTemplate}" BooleanTemplate="{StaticResource BooleanTemplate}" /&gt; &lt;/ListBox.ItemTemplateSelector&gt; &lt;/ListBox&gt; </code></pre> <p>It is the <code>TextBox</code> binding expression in the "TextTemplate" that I am having problems with. The problem is that "PathName" should not be taken as a literal string, but is the name of a string property in the <code>ColumnDescription</code> class (the collection type of <code>ColumnCollection</code> used for <code>ListBox.ItemsSource</code>), which gives the name of the POCO property I want to bind to (the POCO is "vm.CurrentEditing").</p> <p>Is there some way to use the value of a property in XAML as input to a binding expression, or will I have to resort to code behind?</p> <p>(Incidentally, specifying the <code>ElementName</code> as "x.y" as I have done above also seems to be invalid. I assume the "y" part should be in <code>Path</code> but that's currently taken up with my property name...!)</p>
2
Google Analytics: Are custom metrics "integers only" when sent in through the measurement protocol?
<p>We need to send a decimal value to google analytics, and had decided to do this using a custom metric of the type "Currency". In the Tracking documentation it says that this should be allowed:</p> <blockquote> <p>If the custom metric is configured to have a currency type, you can send decimal values. </p> </blockquote> <p><a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets#sending_data" rel="nofollow">https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets#sending_data</a></p> <p>However, we are sending in raw data using the measurement protocol, and in <em>that</em> documentation it says that only integers are allowed for custom metrics: <a href="https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cm_" rel="nofollow">https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cm_</a></p> <p>I have noticed that the decimal values we send in do not show up in the UI. Could this be the reason? </p>
2
Unity Cloud Build: Error: Unrecognized Project
<p>This is my first time using Unity Cloud Build. I'm using BitBucket with SourceTree, I've also tried it with GitHub, but I keep getting the same error:</p> <blockquote> <p>Error: unrecognized project! Please check your app configuration - if this is a Unity application, We expect your "Project Subdirectory" to be set to the path which directly contains the ProjectSettings and Assets directories. For a native app, this should be set to the path which directly contains the project file (.xcodeproj, project.properties, etc).</p> </blockquote> <p>The project itself is simple, just one 3d character model and a basic walk animation just to make sure things were at a minimum. If anyone could help that would be great!</p> <p>Here is the full log.</p> <pre><code>1: Running Prebuild steps 2: Removing bvr 3: Successfully uninstalled bvr-1.2.11 4: 1 gem installed 5: done. 6: bvr 1.2.12 7: bvr-api 0.2.4 8: Cloning the remote Git repository 9: Cloning repository ssh://[email protected]/jsmccloud/gm_animation_test.git 10: Fetching upstream changes from ssh://[email protected]/jsmccloud/gm_animation_test.git 11: Fetching upstream changes from ssh://[email protected]/jsmccloud/gm_animation_test.git 12: Checking out Revision d84217f8e82b1bedcd64256ae88a38b9226beb9b (refs/remotes/origin/master) 13: First time build. Skipping changelog. 14: Calculated Workspace Size: 308.73 MiB 15: PATH | SIZE 16: /GM_Animation_Test | 308.73 MiB 17: postcheckoutstatus finished successfully. 18: Error: unrecognized project! Please check your app configuration - if this is a Unity application, We expect your "Project Subdirectory" to be set to the path which directly contains the ProjectSettings and Assets directories. For a native app, this should be set to the path which directly contains the project file (.xcodeproj, project.properties, etc). 19: Build step 'Execute shell' marked build as failure 20: postbuildstatus finished successfully. 21: Finished: FAILURE </code></pre>
2
Regular expression matching liquid code
<p>I'm building a website using Jekyll I would like to automatically remove liquid code (and <strong>only</strong> liquid code) from a given HTML file. I'm doing it in Python using regular expressions, and so far I have this one:</p> <pre class="lang-regex prettyprint-override"><code>\{.*?\}|\{\{.*?\}\} </code></pre> <p>As I am not too familiar with liquid (and .html), could someone confirm that this will suffice for my goal?</p> <p>Here is an example of the kind of file I will be working with:</p> <pre class="lang-html prettyprint-override"><code>&lt;div class="post-preview"&gt; &lt;div class="post-title"&gt; &lt;div class="post-name"&gt; &lt;a href="{{ post.url }}"&gt;{{ post.title }}&lt;/a&gt; &lt;/div&gt; &lt;div class="post-date"&gt; {% include time.html %} &lt;/div&gt; &lt;/div&gt; &lt;div class="post-snippet"&gt; {% if post.content contains '&lt;!--break--&gt;' %} {{ post.content | split:'&lt;!--break--&gt;' | first }} &lt;div class="post-readmore"&gt; &lt;a href="{{ post.url }}"&gt;read more-&gt;&lt;/a&gt; &lt;/div&gt; {% endif %} &lt;/div&gt; {% include post-meta.html %} &lt;/div&gt; </code></pre> <p>In this case my regex works, but I wanted to make sure I'm not missing something for the future. I could go for a hackish way and surround all liquid code with comments like</p> <pre class="lang-c prettyprint-override"><code>/* start_liquid */ {blalala} /* end_liquid */ </code></pre> <p>but I'm looking for a more elegant way to do it.</p>
2
Vis.js not showing graph when many nodes are added
<p>I am making a web app to show relationships between items using <code>Vis.js</code>, everything works perfectly fine until I get to the point where I need to display ~260 nodes with ~1200 edges between them.</p> <p>Once I get to that amount of nodes, the graph just shows a blank space and a blue line, nothing else. As soon as I try to zoom it, the line disappears and it's all white.</p> <p>When I look at the position of the nodes I can see that many of them are in negative or very big <code>x, y</code> positions (generally -300 for x and around 478759527705558300000 for y).</p> <p>I have tried, to no avail, to disable physics. The graph is in hierarchichal mode, with levels manually set in the code, but the levels are correct.</p> <p>Network options (the <code>improvedLayout</code> option was just a possibility I found on the internet; it works just the same if I remove it):</p> <pre><code> var options = { layout: { improvedLayout: false, hierarchical: { direction: direction, sortMethod: "directed" } } } </code></pre> <p>Screenshot: <a href="https://i.stack.imgur.com/i18bz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i18bz.png" alt="Screenshot"></a></p>
2
Execute shell, get and display result realtime using PHP
<p>I need to do some long process using Python which will be called using PHP(my main language) and display the result real time.</p> <p>Lets say this is my Python script(<code>a.py</code>).</p> <pre><code>import time for x in range(10): print "S;adasdasd;",x time.sleep(0.5) </code></pre> <p>I have try so many example from internet but always get same result. PHP always wait until script is done then displaying it.</p> <p>Here is one of so many code i have tried.</p> <pre><code> header( 'Content-type: text/html; charset=utf-8' ); $handle = popen('python folder\\a.py', 'r'); while (!feof($handle)) { echo fgets($handle); flush(); ob_flush(); } pclose($handle); </code></pre> <p>Did I miss something?</p>
2
Inserting formula via VBA with reference to another sheet not working. Need workaround
<p>I have created a script which compares columns in two different sheets to sse if the same values are found in both documents. </p> <p>I do this by inserting a formula via VBA into one of the two documents. </p> <p>The formula: <code>=IF(ISNA(MATCH(A1;'[Filename]SheetName'!$B:$B;0));"NO MATCH","MATCH")</code></p> <p>The problem is that if <code>SheetName</code> is anything else than <code>Sheet(insert number here)</code> the script doesn't run. I don't know why it won't recognise the sheet, but I need a workaround for this.</p> <p>VBA Script:</p> <pre><code>Formula1 = "=IF(ISNA(MATCH(" &amp; Chr(col1 + 64) &amp; MyCell1 &amp; ",'[" &amp; fi2 &amp; "]" &amp; SheetName &amp; "'!$" &amp; Chr(col3 + 64) &amp; ":$" &amp; Chr(col3 + 64) &amp; ",0)),""NO MATCH"",""MATCH"")" Formula2 = "=IF(" &amp; Chr(col1 + 65) &amp; MyCell1 &amp; "=""NO MATCH"",""-"",IF(INDEX('[" &amp; fi2 &amp; "]" &amp; SheetName &amp; "'!$" &amp; Chr(col4 + 64) &amp; ":$" &amp; Chr(col4 + 64) &amp; ",MATCH(" &amp; Chr(col1 + 64) &amp; MyCell1 &amp; ",'[" &amp; fi2 &amp; "]" &amp; SheetName &amp; "'!$" &amp; Chr(col3 + 64) &amp; ":$" &amp; Chr(col3 + 64) &amp; ",0))=" &amp; Chr(col21 + 63) &amp; MyCell1 &amp; ",""MATCH"",""NO MATCH""))" With Range(myRange1) .NumberFormat = "General" .Value = Formula1 .Value = .Value .HorizontalAlignment = xlCenter .ColumnWidth = 27 End With With Range(myRange2) .NumberFormat = "General" .Value = Formula2 .Value = .Value .HorizontalAlignment = xlCenter .ColumnWidth = 27 End With </code></pre>
2
svg not displayed in local
<p>I am currently using an svg on an html page which is running on my local machine, and not on a server. The image not display : </p> <pre><code>&lt;svg aria-hidden="true" class="slds-icon slds-icon-standard-lead slds-icon--small"&gt; &lt;use xlink:href="SLDS202/assets/icons/standard-sprite/svg/symbols.svg#lead"&gt;&lt;/use&gt; &lt;/svg&gt; </code></pre> <p>The path are right. On local machine i have the impression that we can't run the use part. Is that right? I didn't see any limitations by being on a server and been on a local machine.</p> <p>This code run well on local : </p> <pre><code> &lt;svg version="1.1" baseProfile="full" width="300" height="200" xmlns="http://www.w3.org/2000/svg"&gt; &lt;rect width="100%" height="100%" fill="red" /&gt; &lt;circle cx="150" cy="100" r="80" fill="green" /&gt; &lt;text x="150" y="125" font-size="60" text-anchor="middle" fill="white"&gt;SVG&lt;/text&gt; &lt;/svg&gt; </code></pre> <p>When inspecting the console, i am getting this error : </p> <pre><code> Unsafe attempt to load URL file:///C:/work/References/SLDS/SLDS202/assets/icons/utility-sprite/svg/symbols.svg#filterList from frame with URL file:///C:/work/References/SLDS/axa-hk-gi-demo.html. 'file:' URLs are treated as unique security origins. </code></pre>
2
Numbers Not on Same Line
<p>I'm new to SVG and have been putting numbers in text tags for a week or two with no issues. It seemed straightforward. Now, strangely, I'm having an issue in which, no matter what numbers I put in, there is a dip in the second number. </p> <p>Here is a pic to show you what is happening. The number "63" is supposed to be all on the same plane with itself, though a bit below the "This Week" designation. Instead, the '3' is dipping down lower. <a href="http://i.imgur.com/76xlGM2.png" rel="nofollow">Pic of my problem</a>.</p> <p>My code:</p> <pre><code> &lt;div class = "chartbox"&gt; &lt;div class = "svgcontainer" &gt; &lt;svg class = "chart" width="590" height="440" role="img"&gt; &lt;g class = "bigbox"&gt; &lt;text x="346" y = "35" class = "blurbhed"&gt;This Week &lt;/text&gt; &lt;text x ="491" y ="44" class = "blurbdeck"&gt;&lt;?php echo round($kms_for_table[0]);?&gt;&lt;/text&gt;&lt;text x ="540" y ="48" class = "blurbkm"&gt;&lt;?php echo "km";?&gt;&lt;/text&gt; &lt;/g&gt; &lt;/svg&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The CSS:</p> <pre><code>body { background-color: #1C1816; font-family: Raleway, Gotham-Rounded, Arial , sans-serif;} .blurbhed { font-size: 1.5em; font-weight: 600; fill: #650a5d; letter-spacing: .3px; } .blurbdeck { font-size: 2.7em; font-weight: 600; fill: #08292e; letter-spacing: .4px; } .blurbkm { font-size: 1.3em; font-weight: 600; fill: #08292e; letter-spacing: .4px; } .svgcontainer { display: block; position: relative; border: 10px solid purple; background-color: lightyellow; margin-left: 10px; height: 453px; width: 630px; margin-top: 0px; margin-bottom: 20px; text-align: center; margin-right: 50px; } .chartbox { display: block; margin-left: auto; margin-right: auto; height: auto; width: 800px; margin-bottom: 10px; padding-top: 20px; } </code></pre> <p>The same problem happens wherever I move the text around the svg element. It occurs with a variety of fonts, and with different numbers. It happens whether I just have it echo the number or have it generated by the code from my model. I also tried making a completely new text element in a different spot, and the same weird dip in the second number occurs.</p> <p>I'm sure this is really simple, but I've been fiddling with it far too long and am hoping someone can help me out. Thank you!</p>
2
ggtern contour plot in R
<p>I have this <a href="https://www.dropbox.com/s/xk8zyu9f0rw77eu/N90_p_0.350_eta_90_W12.dat?dl=0" rel="nofollow noreferrer">data file</a> that has enough data points for me to plot a "heatmap" in ternary plot. (It is not really heat map, just a scatter plot with enough data points)</p> <pre><code>library(ggtern) library(reshape2) N=90 trans.prob = as.matrix(read.table("./N90_p_0.350_eta_90_W12.dat",fill=TRUE)) colnames(trans.prob) = NULL # flatten trans.prob for ternary plot flattened.tb = melt(trans.prob,varnames = c("x","y"),value.name = "W12") # delete rows with NA flattened.tb = flattened.tb[complete.cases(flattened.tb),] flattened.tb$x = (flattened.tb$x-1)/N flattened.tb$y = (flattened.tb$y-1)/N flattened.tb$z = 1 - flattened.tb$x - flattened.tb$y ggtern(data = flattened.tb, aes(x=x,y=y,z=z)) + geom_point(size=1, aes(color=W12)) + theme_bw() + scale_color_gradient2(low = "green", mid = "yellow", high = "red") </code></pre> <p>Here is what I got: </p> <p><a href="https://i.stack.imgur.com/GAxlB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GAxlB.png" alt="enter image description here"></a></p> <p>I want to get something like the following using <code>ggtern</code>:</p> <p><a href="https://i.stack.imgur.com/ZSbrF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZSbrF.png" alt="enter image description here"></a></p> <p><strong>My question</strong> is: How can I get something like the second figure using <code>ggtern</code>?</p> <p><strong>Edit 1</strong>: Sorry for the typo in the file name. I fixed the filename. The data file contains too much data points for me to directly paste them here.</p> <p>The 2nd figure was produced by a 3rd-party Matlab package <code>ternplot</code>. I want a ternary contour plot that has discrete lines rather than the heatmap in my first figure. To be more specific, I want to specify a list of contour lines such as <code>W12=0.05,0.1,0.15,...</code>. I have played with <code>geom_density_tern</code> and <code>geom_interpolate_tern</code> for hours but still have no clue how to get what I want.</p> <p>The MATLAB code is:</p> <pre><code>[HCl, Hha, cax] = terncontour(X,Y,1-X-Y,data,[0.01,0.1,0.2,0.3,0.4,0.5]); </code></pre> <p>where <code>X,Y,1-X-Y</code> specify the coordinate on the plot, <code>data</code> stores the values and the vector specifies the values of the contours.</p>
2
Timeout has no limit? - HttpsURLConnection
<p>In my Java client app I'm connecting to my server using HttpsURLConnection. This works all fine, except on certain moments it does not timeout at all. I set the timeout parameters of the connection as such (to 5000 ms):</p> <pre><code>HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); // timeouts con.setConnectTimeout(5000); con.setReadTimeout(5000); con.setRequestMethod("put"); con.setDoInput(true); con.setDoOutput(true); con.setRequestProperty("Content-length", String.valueOf(output.length())); OutputStreamWriter os = new OutputStreamWriter(con.getOutputStream(), "UTF-8"); BufferedWriter writer = new BufferedWriter(os); writer.write(output); writer.close(); os.close(); con.connect(); int respCode = con.getResponseCode(); if(respCode == 200) { InputStreamReader is = new InputStreamReader(con.getInputStream()); BufferedReader br = new BufferedReader(is); String input; String respBody = ""; while ((input = br.readLine()) != null){ respBody += input; } br.close(); is.close(); this.result = respBody; } </code></pre> <p>I'm catching all exceptions, but none is registered, so the problem cannot be an uncaught exception. The connection simply does not timeout. I waited for 3 minutes and had no response. I could reproduce the bug a few times while switching network during the execution of a request.</p> <p>Also, sometimes there was a response after about a minute. Which is longer than the timeouts.</p> <p>I already tried interrupting the thread on which the request is made after a timeout, disconnecting the HttpsURLConnection. But there must be a neater solution than that. I would like to know where this indefinite timeout comes from.</p> <p>Any ideas? </p> <p>Thanks a lot!</p>
2
Padding not working for SELECT OPTION in IE11
<p>~I have created listbox control and trying to add padding between options, It is working with chrome but not working with IE11, Anyone can suggest what I am doing wrong.I need to place items in the listbox with line spacing. Below code contains style sheet I am using and HTML code which has select options tag, Tried styles with padding, margin, line space etc but no luck. </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;change demo&lt;/title&gt; &lt;style&gt; div { color: red; } &lt;/style&gt; &lt;style type="text/css"&gt; select::-ms-expand { /* for IE 11 */ display: none; } .ListBox { background-color: transparent; font-family: verdana; font-size: 8pt; font-weight: bold; color: black; vertical-align:middle; } .ListBox option { padding:30px 30px 30px 30px; -webkit-appearance: none; -moz-appearance: none; -ms-appearance: none; -o-appearance: none; appearance: none; } } } &lt;/style&gt; &lt;script src="https://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;select name="sweets" multiple="multiple" class="ListBox"&gt; &lt;option&gt;Chocolate&lt;/option&gt; &lt;option selected="selected"&gt;Candy&lt;/option&gt; &lt;option&gt;Taffy&lt;/option&gt; &lt;option selected="selected"&gt;Caramel&lt;/option&gt; &lt;option&gt;Fudge&lt;/option&gt; &lt;option&gt;Cookie&lt;/option&gt; &lt;/select&gt; &lt;div&gt;&lt;/div&gt; &lt;script&gt; $( "select" ) .change(function () { var str = ""; $( "select option:selected" ).each(function() { str += $( this ).text() + " "; }); $( "div" ).text( str ); }) .change(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
2
Table TD are not aligning correctly
<p>The issue I am having is for some reason, the order of a particular td skips order: The following image will show you what I mean:</p> <p>As you can see below, the TEMP section should not be in the end but rather next to full time.</p> <p><a href="https://i.stack.imgur.com/cKxnX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cKxnX.png" alt="enter image description here" /></a></p> <p>Below is the html and css code.</p> <p>HTML:</p> <pre><code>&lt;div id=&quot;mainPhoto2&quot;&gt; &lt;div style=&quot;display: inline-block; text-align: center; margin-left: 260px&quot;&gt; &lt;h1&gt; JOB &lt;br /&gt; &lt;span class=&quot;green&quot;&gt;AUTHORIZATION&lt;/span&gt;&lt;span class=&quot;gray&quot;&gt; NOTICE (JAN)&lt;/span&gt; &lt;/h1&gt; &lt;/div&gt; &lt;div style=&quot;float: right; margin-top: 10px; margin-right: 30px&quot;&gt; &lt;cfoutput&gt; Date Completed:&lt;br /&gt; #DateFormat(now(), &quot;mm/dd/yyyy&quot;)# &lt;/cfoutput&gt; &lt;/div&gt; &lt;form name=&quot;SubmitVisit&quot; method=&quot;POST&quot; class=&quot;j&quot;&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td colspan=&quot;4&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;SECTION A - CHECK CATERGORY(S) THAT APPLY AND COMPLETE APPROPRIATE SECTIONS&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot;&gt;&lt;input type=&quot;checkbox&quot; /&gt; Replacement&lt;/td&gt; &lt;td class=&quot;mm&quot;&gt;&lt;input type=&quot;checkbox&quot; /&gt; Additional Position&lt;/td&gt; &lt;td class=&quot;mm&quot;&gt;&lt;input type=&quot;checkbox&quot; /&gt; New Title/Position&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=&quot;4&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;SECTION B - CURRENT INFORMATION REQUIRED&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;Department Name&lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Location&lt;/td&gt; &lt;td colspan=&quot;2&quot; class=&quot;mm&quot; style=&quot;text-align: center&quot;&gt;&lt;select class=&quot;selectmenu2&quot;&gt; &lt;option selected disabled class=&quot;hideoption&quot;&gt;Company (please check one)&lt;/option&gt; &lt;option class=&quot;mm&quot;&gt;RMG&lt;/option&gt; &lt;option class=&quot;mm&quot;&gt;LMG&lt;/option&gt; &lt;option class=&quot;mm&quot;&gt;CSC&lt;/option&gt; &lt;!---&lt;option&gt;Option 4&lt;/option&gt; &lt;option&gt;Option 5&lt;/option&gt;---&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=&quot;2&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;Position Title&lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td rowspan=&quot;3&quot; style=&quot;text-align: center&quot; class=&quot;mm&quot;&gt;&lt;select class=&quot;selectmenu&quot;&gt; &lt;option selected disabled class=&quot;hideoption&quot; style=&quot;width: 10%&quot;&gt;Check one&lt;/option&gt; &lt;option class=&quot;mm&quot;&gt;RMG&lt;/option&gt; &lt;option class=&quot;mm&quot;&gt;LMG&lt;/option&gt; &lt;option class=&quot;mm&quot;&gt;CSC&lt;/option&gt; &lt;!---&lt;option&gt;Option 4&lt;/option&gt; &lt;option&gt;Option 5&lt;/option&gt;---&gt; &lt;/select&gt;&lt;/td&gt; &lt;td rowspan=&quot;3&quot; class=&quot;mm&quot; style=&quot;text-align: center; width: 20%; margin-top: -20px; vertical-align: top&quot;&gt; ADOC&lt;br /&gt; &lt;input id=&quot;checkbox&quot; type=&quot;checkbox&quot; /&gt; &lt;span class=&quot;text2&quot;&gt;If ADOC-does&lt;br /&gt; position support UCMG?&lt;br /&gt; &lt;input type=&quot;checkbox&quot; /&gt; YES&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type=&quot;checkbox&quot; /&gt; NO &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot; style=&quot;vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Reporting to&lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;td rowspan=&quot;1&quot; class=&quot;mm&quot; style=&quot;text-align: center; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Full Time&lt;br /&gt; &lt;input style=&quot;&quot; type=&quot;checkbox&quot; /&gt; &lt;/td&gt; &lt;td rowspan=&quot;1&quot; class=&quot;mm&quot; style=&quot;text-align: center&quot;&gt;TEMP&lt;br /&gt; &lt;input type=&quot;checkbox&quot; /&gt;&lt;br /&gt; Duration of assignment &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 20%&quot;&gt;&lt;b&gt;UltiPro Supervisor (timekeeping)&lt;/b&gt;&lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=&quot;4&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;SECTION C - REASON FOR VACANCY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=&quot;2&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;Last Incumbent Name&lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td colspan=&quot;2&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;Date Position Vacated&lt;br /&gt; &lt;br /&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=&quot;4&quot; class=&quot;mm&quot;&gt;&amp;nbsp;&amp;nbsp;SECTION D - AUTHORIZATIONS (MUST HAVE SIGNATURES)&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 5%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Date&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 15%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Hiring Manager (signature required)&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 5%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Date&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 30%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Vice President Human Resources (signature required)&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 5%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Date&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 25%&quot;&gt;&amp;nbsp;&amp;nbsp;VP or Medical Director or Dep (signature required)&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 5%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;Date&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;td class=&quot;mm&quot; style=&quot;width: 30%; vertical-align: top&quot;&gt;&amp;nbsp;&amp;nbsp;COO/CFO&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot; colspan=&quot;4&quot;&gt;SECTION E - POSITION JUSTIFICATION (must be completed for ALL positions)&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class=&quot;mm&quot; style=&quot;font-style: italic; background-color: white&quot;&gt;To facilitate the approval of this JAN please provide specific business criteria as to why this position needs to be added or replaced.&lt;br /&gt; &lt;div style=&quot;height: 180px&quot;&gt;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;br /&gt; </code></pre> <p>Below is the CSS:</p> <pre><code> /* top elements */ * { padding: 0; margin: 0; } body { margin: 0; padding: 0; font: .70em/1.5em Verdana, Tahoma, Helvetica, sans-serif; color: #666666; background: #A9BAC3 url(bg.gif) repeat-x; text-align: center; } /* links */ a { color: #4284B0; background-color: inherit; text-decoration: none; } a:hover { color: #9EC068; background-color: inherit; } /* headers */ h1, h2, h3 { font: bold 1em 'Trebuchet MS', Arial, Sans-serif; color: #333; } h1 { font-size: 1.5em; color: #6297BC; } h2 { font-size: 1.4em; text-transform:uppercase;} h3 { font-size: 1.3em; } h4 { font-size: 1.1em; color: #6297BC; } h5 { font-size: 1.2em; color: red; font-weight:bold } h6 { font-size: 1.1em; font-weight:bold } p.data { padding:0 0 0 0 } p, h1, h2, h3, h4, h5, h6 { margin: 10px 15px; } border-left: 4px solid #4284B0; } acronym { cursor: help; border-bottom: 1px solid #777; } /* form elements */ form { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: #FAFAFA; } form.a { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: white; } form.b { margin:10px; padding: 0; border: 1px solid #f2f2f2; border-color:#333333; background-color:#CCCCCC; } form.c { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border:inherit; border:groove; border-color:#000000; } form.d { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border-color:#000000; width:500px; } form.e { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border-color:#000000; width:800px; } form.f { margin:10px; padding: 0; border: 0px ; background-color: white; border-color:#000000; width:500px; } form.g { margin:10px; padding: 0; background-color: white; border-color:#f2f2f2; width:600px; } form.h { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border-color:#000000; width:700px; } form.i { margin:5px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border-color:#000000; width:780px; } form.j { margin:0px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border-color:#000000; width:800px; } label { display:block; font-weight:bold; margin:5px 0; } input { padding: 2px; border:1px solid #D7D7D7; font: normal 1em Verdana, sans-serif; color:#000; } input.a { padding: 4px; border:1px solid #D7D7D7; font: normal 1em Verdana, sans-serif; color:#000; } input.b { padding: 4px; font: normal 1em Verdana, sans-serif; color:#000; display: none !important; } input.border { padding: 2px; border:1px solid #999999; font: normal 1em Verdana, sans-serif; color:#777; } input.borderB { padding: 6px; border:1px solid #000000; font: normal 1em Verdana, sans-serif; color:black; } input.borderC { padding: 6px; border:1px solid #000000; font: normal 1em Verdana, sans-serif; color:black; font-size:12px } input.borderD { padding: 2px; border:1px solid #000000; font: normal 1em Verdana, sans-serif; color:black; font-size:14px } input.borderE { padding: 4px; border:1px solid #000000; font: normal 1em Verdana, sans-serif; color:black; font-size:11px } input.textbox{ padding: 2px; border:1px solid #999999; font: normal 1em Verdana, sans-serif; color:#777; } textarea { width:300px; padding:2px; font: normal 1em Verdana, sans-serif; border:1px solid #eee; height:100px; display:block; color:#777; } textarea.a { border:none; background-color:transparent; width:300px; padding:1px; font: normal 1em Verdana, sans-serif; height:50px; overflow: auto; border: none; } textarea.b{ background-color:#f2f2f2; width:250px; padding:1px; font: normal 1em; color:#000000; font-family:Calibri; font-size:12px; height:75px; overflow: auto; border:inherit; border:groove; border-color:#000000; } /* search form */ form.searchform { background: transparent; border: none; margin: 0; padding: 0; } form.searchform input.textbox { margin: 0; width: 120px; border: 1px solid #9EC630; background: #FFF; color: #333; height: 14px; vertical-align: top; } form.searchform input.button { margin: 0; padding: 2px 3px; font: bold 12px Arial, Sans-serif; background: #FAFAFA; border: 1px solid #f2f2f2; color: #777; width: 60px; vertical-align: top; } form.searchform input.textboxa { margin: 0; width: 120px; border: 1px solid #9EC630; background: #FFF; color: #333; background-image:url(googlesm.gif); background-position:center; background-repeat:no-repeat; height: 14px; vertical-align: top; } /*********************** LAYOUT ************************/ #wrap { background: #FFF; width: 820px; height: 100%; margin: 0 auto; text-align: left; } #wrapnew { background: #FFF; width: 1000px; height: 100%; margin: 0 auto; text-align: left; } #content-wrap { clear: both; margin: 0; padding: 0; background: #FFF; } /* header */ #header { position: relative; height: 85px; background: #000 url(headerbg.gif) repeat-x 0% 100%; } #header h1#logo { position: absolute; margin: 0; padding: 0; font: bolder 2.8em 'Trebuchet MS', Arial, Sans-serif; letter-spacing: -2px; text-transform: lowercase; top: 0; left: 5px; } #header h2#slogan { position: absolute; top:37px; left: 45px; color: #666666; text-indent: 0px; font: bold 11px Tahoma, 'trebuchet MS', Sans-serif; text-transform: none; } #header form.searchform { position: absolute; top: 0; right: -12px; } /* main */ #main { float: left; margin-left: 15px; padding: 0; width: 50%; } #mainland { float: left; margin-left: 15px; padding: 0; width: 95%; } #mainPhoto2 { margin-left: 15px; padding: 0; width: 100%; } * html body #sidebar ul.sidemenu a { height: 18px; } /* menu tabs */ #header ul { z-index: 999999; position: absolute; margin:0; padding: 0; list-style:none; right: 0; bottom: 6px !important; bottom: 5px; font: bold 13px Arial, 'Trebuchet MS', Tahoma, verdana, sans-serif; } #header li { display:inline; margin:0; padding:0; } #header a { float:left; background: url(tableft.gif) no-repeat left top; margin:0; padding:0 0 0 4px; text-decoration:none; } #header a span { float:left; display:block; background: url(tabright.gif) no-repeat right top; padding:6px 15px 3px 8px; color: #FFF; } /* Commented Backslash Hack hides rule from IE5-Mac \*/ #header a span {float:none;} /* End IE5-Mac hack */ #header a:hover span { color:#FFF; } #header a:hover { background-position:0% -42px; } #header a:hover span { background-position:100% -42px; } #header #current a { background-position:0% -42px; color: #FFF; } #header #current a span { background-position:100% -42px; color: #FFF; } /* end menu tabs */ /* alignment classes */ .float-left { float: left; border: none; } .float-right { float: right; } .align-left { text-align: left; } .align-right { text-align: right; } /* additional classes */ .clear { clear: both; } .green { color: #9EC630; } .gray { color: #BFBFBF; } .black { color: black; } .red { color: red; } #about { position: absolute; left: 369px; top: 15px; height: 296px; width: 287px; padding: 10px 10px 10px; } /* For Vision */ #contCol .regalList li { background:url(../../images/regal_bullet.GIF) 0 12px no-repeat; padding:8px 0 0 20px; } /* the Default theme */ *::-moz-any-link br,*:-moz-any-link br { /*a workarround for mozilla*/ display:none; } div#menuold * { border-collapse: collapse; /*removes the cell-borders*/ cursor: pointer; /*because IE displays the text cursor if the link is inactive*/ } div#menuold { /*background: #efebde;*/ height: 15px; white-space: nowrap; width: 10%; } div#menuold .a { /* background: #F5F5DC; border: 1px solid #F5F5DC;*/ color: #000000; text-decoration: none; } div#menuold .a table { display: block; font: 10px Verdana, sans-serif; white-space: nowrap; } div#menuold table, div#menuold table a { display: none; } div#menuold .a:hover { color:black; background: #7DA6EE; border: 1px solid #000080; color: #0000FF; margin-right:-1px; /*resolves a problem with Opera not displaying the right border*/ } div#menuold .a:hover table#niv1 { background: #FFFFFF; border: 1px solid #708090; display: block; white-space: nowrap; position:absolute; } div#menuold .a:hover table#niv1 a { border-left: 10px solid #708090; border-right: 1px solid white; /*resolves a jump problem*/ color: black; display: block; padding: 1px 12px; text-decoration: none; white-space: nowrap; z-index: 1000; } div#menuold .a:hover table#niv2{ display:none } div#menuold .a:hover table#niv1 a:hover { background: #7DA6EE; border: 1px solid #000000; border-left: 10px solid #000000; color: #000000; display: block; padding: 0px 12px; text-decoration: none; z-index: 1000; } div#menuold .a:hover table#niv1 a:hover table#niv2{ background: #FFFFFF; border: 1px solid #708090; display: block; white-space: nowrap; position:absolute; } tr, td, table {font-size:10px;font-family:arial, sans-serif, tahoma;color: #000; text-align: left;} select { margin: 0; padding: 0; border: 1px solid #eee; color: #000000; background: #d8d8d8; font-size:10px;} select.a { margin: 0; padding: 0; border: 1px solid #eee; color: #000000; background: #d8d8d8; font-size:11px;} select.b{margin: 0;border-width: 1px; padding: 1px;font-weight: normal;font-size: 11px;font-family: Verdana, Arial, Helvetica, sans-serif;background-color: #F8F8F8;color: #000;} select.c{margin: 0;border-width: 1px; padding: 1px;font-weight: normal;font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;background-color: #F8F8F8;color: #000;} select.bb{margin: 0;border-width: 1px; padding: 2px;font-weight: normal;font-size: 13px;font-family: Verdana, Arial, Helvetica, sans-serif;background-color: #fee4ac;color: #000;} select.bc{margin: 0;border-width: 1px; padding: 2px;font-weight: normal;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;;background-color: #F8F8F8;color: #000;} select.c{margin: 0;border-width: 1px; padding: 1px;font-weight: normal;font-family: Verdana, Arial, Helvetica, sans-serif;background-color: #F8F8F8;color: #000; width: 150px;font-size: 10px;border:1px solid #69A3D3;height: 100px;padding-right:0px} .rdate { margin: 0; padding: 0; width: 85px; border: 1px solid #eee; color: #000000; background: #d8d8d8;font-size:11px; } TH {font-family:arial, sans-serif, tahoma; font-size:11px;color: #808080; text-align: center;font-weight: bold;} TH.a {font-family:arial, sans-serif, tahoma; font-size:11px;color: #808080; text-align: left;font-weight: bold;} TH.b {font-family:arial, sans-serif, tahoma; font-size:12px;color: #808080; text-align: center;font-weight: bold;} TH.c {font-family:arial, sans-serif, tahoma; font-size:13px;color: #808080; text-align: center;font-weight: bold;} Td.a {font-family:arial, sans-serif, tahoma; font-size:10px;color: #808080; text-align: center;} Td.b {font-family:arial, sans-serif, tahoma; font-size:11px;color: #808080; text-align: center;font-weight: bold;} Td.c {font-family:arial, sans-serif, tahoma; font-size:11px;color: #000; text-align: left;} Td.d {font-family:arial, sans-serif, tahoma; font-size:11px;color: #000; text-align: center;} Td.e {font-family:arial, sans-serif, tahoma; font-size:11px;color: #333333; text-align: left;font-weight: bold;} Td.f {font: bold 1em 'Trebuchet MS', Arial, Sans-serif; color: #333;font-size: 1.1em; font-weight:bold } Td.g {font-family:arial, sans-serif, tahoma; font-size:11px;color: #000; text-align: left;} Td.h {font-family:arial, sans-serif, tahoma; font-size:11px;color: #000; text-align: center;} Td.i {font-family:arial, sans-serif, tahoma; font-size: 1.2em;color: #000; text-align: left;font-weight:bold} Td.j {font-family:arial, sans-serif, tahoma; font-size:11px;color: #000; text-align: left; word-break: break-all;word-break: break-word;} Td.jj {font-family:arial, sans-serif, tahoma; font-size:12px;color: #000; text-align: left; word-break: break-all;word-break: break-word; vertical-align:top} Td.k {font-family:arial, sans-serif, tahoma; font-size:9px;color: #000; text-align: left; font-style:italic} Td.l {font-family:Trebuchet MS, Arial, Sans-serif; font-size:14px;color: #333333; text-align: left;font-weight: bold;} Td.m {font-family:arial, sans-serif, tahoma; font-size: 1.2em;color: #000; text-align: left;font-weight:bold;} Td.mm {font-family:arial, sans-serif, tahoma; font-size: 1.2em;color: #000; text-align: left;font-weight:bold; padding:2px} Td.n {font-family:arial, sans-serif, tahoma; font-size:11px;color: #000; text-align: left;vertical-align:top} Td.o {font-family:arial, sans-serif, tahoma; font-size: 1.2em;color: #000; text-align: center;font-weight:bold} Td.p {font-family:arial, sans-serif, tahoma;, sans-serif; font-size: 1.2em;color: #666; text-align: left;} Td.r {font-family:arial, sans-serif, tahoma; font-size:14px;color: #000; text-align: left; height:25px } Td.s {font-family:arial, sans-serif, tahoma; font-size:14px;color: #000; text-align: left; height:25px;font-weight: bold;} .checkbox, .radio { width: 19px; height: 25px; padding: 0 5px 0 0; background: url(checkbox.gif) no-repeat; display: block; clear: left; float: left; } table.b { margin:10px; padding: 0; border: 1px solid #f2f2f2; background-color: white; border:inherit; border:groove; border-color:#000000; } .box { background-color: #eee; border: 1px; border-style: solid; border-color: #CC9999; padding: 5px; margin: 5px; width: 400px; height: 290px; } .vertical-line { display: inline; background-color: #000; width: 1px; height: 100%; } .negs { padding:0; margin: 0; border:#000000 solid 1px; border-collapse:collapse; } .negs tr th{ border:#000000 solid 1px; border-collapse:collapse; background-color:#CCCCCC; color:#000000; padding:5px; margin:0; } .negs .odd td{ padding:5px; margin:0; background-color:#E4EDF3; border:#000000 solid 1px; border-collapse:collapse; } .negs .even td{ padding:5px; margin:0; background-color:#FFF; border:#000000 solid 1px; border-collapse:collapse; } .negs .fixed td{ padding:5px; margin:0; color:#ACA899; background-color:#ECE9D8; border:#000000 solid 1px; border-collapse:collapse; } /* tables */ table.tablesorter { font-family:arial; background-color: #CDCDCD; margin:10px 0pt 15px; font-size: 8pt; width: 100%; text-align: left; } table.tablesorter thead tr th, table.tablesorter tfoot tr th { background-color: #e6EEEE; border: 1px solid #FFF; font-size: 8pt; padding: 4px; } table.tablesorter thead tr .header { background-image: url(bgsort.gif); background-repeat: no-repeat; background-position: center right; cursor: pointer; } table.tablesorter tbody td { color: #3D3D3D; padding: 4px; background-color: #FFF; vertical-align: top; } table.tablesorter tbody tr.odd td { background-color:#F0F0F6; } table.tablesorter thead tr .headerSortUp { background-image: url(asc.gif); } table.tablesorter thead tr .headerSortDown { background-image: url(desc.gif); } table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { background-color: #8dbdd8; } /* New Small Table */ table.tablesortersm { font-family:arial; background-color: #CDCDCD; margin:10px 0pt 15px; font-size: 8pt; width: 95%; text-align: left; } table.tablesortersm thead tr th, table.tablesortersm tfoot tr th { background-color: #e6EEEE; border: 1px solid #FFF; font-size: 8pt; padding: 4px; } table.tablesortersm thead tr .header { background-image: url(bgsort.gif); background-repeat: no-repeat; background-position: center right; cursor: pointer; } table.tablesortersm tbody td { color: #3D3D3D; padding: 4px; background-color: #FFF; vertical-align: top; } table.tablesortersm tbody tr.odd td { background-color:#F0F0F6; } table.tablesortersm thead tr .headerSortUp { background-image: url(asc.gif); } table.tablesortersm thead tr .headerSortDown { background-image: url(desc.gif); } table.tablesortersm thead tr .headerSortDown, table.tablesortersm thead tr .headerSortUp { background-color: #8dbdd8; } /* CSS Document */ .ac_results { padding: 0px; border: 1px solid WindowFrame; background-color: Window; overflow: hidden; } .ac_results ul { width: 100%; list-style-position: outside; list-style: none; padding: 0; margin: 0; } .ac_results iframe { display:none;/*sorry for IE5*/ display/**/:block;/*sorry for IE5*/ position:absolute; top:0; left:0; z-index:-1; filter:mask(); width:3000px; height:3000px; } .btn-style{ border : solid 1px #638a00; border-radius : 3px; moz-border-radius : 3px; -webkit-box-shadow : 0px 2px 2px rgba(0,0,0,0.4); -moz-box-shadow : 0px 2px 2px rgba(0,0,0,0.4); box-shadow : 0px 2px 2px rgba(0,0,0,0.4); font-size : 14px; color : #ffffff; padding : 1px 10px; background : #96c300; background : -webkit-gradient(linear, left top, left bottom, color-stop(0%,#96c300), color-stop(100%,#648c00)); background : -moz-linear-gradient(top, #96c300 0%, #648c00 100%); background : -webkit-linear-gradient(top, #96c300 0%, #648c00 100%); background : -o-linear-gradient(top, #96c300 0%, #648c00 100%); background : -ms-linear-gradient(top, #96c300 0%, #648c00 100%); background : linear-gradient(top, #96c300 0%, #648c00 100%); filter : progid:DXImageTransform.Microsoft.gradient( startColorstr='#96c300', endColorstr='#648c00',GradientType=0 ); } table.z { width: 100%; border-collapse: collapse; } /* Zebra striping */ tr:nth-of-type(odd) { background: #eee; } th.z { background: #333; color: white; font-weight: bold; } td.z, th.z { padding: 6px; border: 1px solid #ccc; text-align: left; } /*07/01/2016 JAN STYLING*/ /*.dateCorner{ border:1px solid black; height:40px; width:140px; float:right; font-weight:bold; padding: 0 0 0 5px; margin-left:2em; margin-right:1em; } a{ text-decoration:none; color:black; } </code></pre> <p>Any help would be appreciate, thanks</p>
2
How to verify control's databinding match the bindingsource?
<p>I have complex forms where controls are on various tabs and panels. These forms use a bindingsource to bind their controls to the data source.</p> <p>There might be situations during development where the data source's members have been renamed but not the forms' controls.</p> <p>As no exception is thrown on loading the form, is there a way to loop through the bindingsource's datasource members and compare them with the controls' databinding values?</p> <p>Particular attention must be made to hidden controls, as explained in this <a href="https://stackoverflow.com/questions/33307160/winforms-respond-to-bindingsource-being-applied/33309549#33309549">SO answer</a>.</p> <p>Where should this check take place? In the constructor or <code>OnLoad</code>? (It should at least happen after <code>InitializeComponent</code> because the bindingsource's datasource, ie. typeof(myObject) is set in this method).</p>
2
Linux Cross compile Library
<p>I try to use Linaro to cross compile "nano-2.5.3" program for my ARM board. my build platform is linux ubuntu 12.04. I use these commands</p> <pre><code>export PATH=$PATH:/project/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin export CROSS_COMPILE=arm-linux-gnueabihf- export ARCH=arm ./configure --host=arm-linux-gnueabihf --prefix=/project/nano </code></pre> <p>every thing went well then I try to use make</p> <pre><code>make </code></pre> <p>after that there is a error :</p> <pre><code>/usr/include/ncursesw/curses.h:60:34: fatal error: ncursesw/ncurses_dll.h: No such file or directory </code></pre> <p>so i compile a ncurses library with my cross compiler in path "/project/ncurses" and add the include with:</p> <pre><code>export CPPFLAGS=-I/project/ncurses/include/ncurses </code></pre> <p>and do over again. but no luck I tried everything but the cross compiler keep checking the original path here are the full error text:</p> <pre><code>make all-recursive make[1]: Entering directory `/project/nano-2.5.3' Making all in doc make[2]: Entering directory `/project/nano-2.5.3/doc' Making all in man make[3]: Entering directory `/project/nano-2.5.3/doc/man' make all-recursive make[4]: Entering directory `/project/nano-2.5.3/doc/man' Making all in fr make[5]: Entering directory `/project/nano-2.5.3/doc/man/fr' make all-am make[6]: Entering directory `/project/nano-2.5.3/doc/man/fr' make[6]: Nothing to be done for `all-am'. make[6]: Leaving directory `/project/nano-2.5.3/doc/man/fr' make[5]: Leaving directory `/project/nano-2.5.3/doc/man/fr' make[5]: Entering directory `/project/nano-2.5.3/doc/man' make[5]: Nothing to be done for `all-am'. make[5]: Leaving directory `/project/nano-2.5.3/doc/man' make[4]: Leaving directory `/project/nano-2.5.3/doc/man' make[3]: Leaving directory `/project/nano-2.5.3/doc/man' Making all in texinfo make[3]: Entering directory `/project/nano-2.5.3/doc/texinfo' make all-am make[4]: Entering directory `/project/nano-2.5.3/doc/texinfo' make[4]: Nothing to be done for `all-am'. make[4]: Leaving directory `/project/nano-2.5.3/doc/texinfo' make[3]: Leaving directory `/project/nano-2.5.3/doc/texinfo' Making all in syntax make[3]: Entering directory `/project/nano-2.5.3/doc/syntax' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/project/nano-2.5.3/doc/syntax' make[3]: Entering directory `/project/nano-2.5.3/doc' make[3]: Nothing to be done for `all-am'. make[3]: Leaving directory `/project/nano-2.5.3/doc' make[2]: Leaving directory `/project/nano-2.5.3/doc' Making all in m4 make[2]: Entering directory `/project/nano-2.5.3/m4' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/project/nano-2.5.3/m4' Making all in po make[2]: Entering directory `/project/nano-2.5.3/po' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/project/nano-2.5.3/po' Making all in src make[2]: Entering directory `/project/nano-2.5.3/src' arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I.. -DLOCALEDIR=\"/project/nano/share/locale\" -DSYSCONFDIR=\"/project/nano/etc\" -I/usr/include/ncursesw -I/project/ncurses/include/ncurses -g -O2 -Wall -MT browser.o -MD -MP -MF .deps/browser.Tpo -c -o browser.o browser.c In file included from nano.h:93:0, from proto.h:27, from browser.c:25: /usr/include/ncursesw/curses.h:60:34: fatal error: ncursesw/ncurses_dll.h: No such file or directory compilation terminated. make[2]: *** [browser.o] Error 1 make[2]: Leaving directory `/project/nano-2.5.3/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/project/nano-2.5.3' make: *** [all] Error 2 </code></pre>
2
implement game of life with only 2 array
<p>I want to memory-efficient <a href="https://github.com/shiffman/The-Nature-of-Code-Examples/tree/master/chp07_CA/NOC_7_02_GameOfLifeSimple" rel="nofollow">this</a> (the game of life code of shiffman in the nature of code book). how can change the below code to have only two arrays and constantly swap them, writing the next set of states into whichever one isn’t the current array?</p> <pre><code>class GOL { int w = 8; int columns, rows; int[][] board; GOL() { // Initialize rows, columns and set-up arrays columns = width / w; rows = height / w; board = new int[columns][rows]; //next = new int[columns][rows]; // Call function to fill array with random values 0 or 1 init(); } void init() { for (int i = 1; i &lt; columns - 1; i++) { for (int j = 1; j &lt; rows - 1; j++) { board[i][j] = (int) random(2); } } } // The process of creating the new generation void generate() { int[][] next = new int[columns][rows]; // Loop through every spot in our 2D array and check spots neighbors for (int x = 1; x &lt; columns - 1; x++) { for (int y = 1; y &lt; rows - 1; y++) { // Add up all the states in a 3x3 surrounding grid int neighbors = 0; for (int i = -1; i &lt;= 1; i++) { for (int j = -1; j &lt;= 1; j++) { neighbors += board[x + i][y + j]; } } // A little trick to subtract the current cell's state since // we added it in the above loop neighbors -= board[x][y]; // Rules of Life if ((board[x][y] == 1) &amp;&amp; (neighbors &lt; 2)) next[x][y] = 0; else if ((board[x][y] == 1) &amp;&amp; (neighbors &gt; 3)) next[x][y] = 0; else if ((board[x][y] == 0) &amp;&amp; (neighbors == 3)) next[x][y] = 1; else next[x][y] = board[x][y]; } } // Next is now our board board = next; } // This is the easy part, just draw the cells, fill 255 for '1', fill 0 for '0' void display() { for (int i = 0; i &lt; columns; i++) { for (int j = 0; j &lt; rows; j++) { if ((board[i][j] == 1)) fill(0); else fill(255); stroke(0); rect(i * w, j * w, w, w); } } } } </code></pre>
2
Return a Reference to a Class with Static Methods and Static Fields Without Instantiation
<p>I want to create a wrapper class that calls static methods and member fields from a class that is provided by a library I am unable to view the code.</p> <p>This is to avoid boilerplate setting code of the global member fields when I need to use a static method in a specific context.</p> <p>I want to try to avoid creating wrapper methods for each static method.</p> <p>My question:</p> <p>Is it possible to return a class with static methods from a method to access just the static methods without instantiating it?</p> <p>Code is below with comments in-line.</p> <p>The code is used to demonstrate a change in a static value when the method <code>getMath()</code> is invoked.</p> <p>I want to avoid the setting of the value before calling the static method.</p> <pre><code>StaticMath.setFirstNumber(1); StaticMath.calc(1); StaticMath.setFirstNumber(2); StaticMath.calc(1); </code></pre> <p>I am using the Eclipse IDE and it comes up with Warnings, which I understand, but want to avoid.</p> <p>I tried searching for something on this subject, so if anyone can provide a link I can close this.</p> <pre><code>public class Demo { // Static Methods in a class library I don't have access to. static class StaticMath { private static int firstNum; private StaticMath() { } public static int calc(int secondNum) { return firstNum + secondNum; } public static void setFirstNumber(int firstNum) { StaticMath.firstNum = firstNum; } } // Concrete Class static class MathBook { private int firstNum; public MathBook(int firstNum) { this.firstNum = firstNum; } // Non-static method that gets the class with the static methods. public StaticMath getMath() { StaticMath.setFirstNumber(firstNum); // I don't want to instantiate the class. return new StaticMath(); } } public static void main(String... args) { MathBook m1 = new MathBook(1); MathBook m2 = new MathBook(2); // I want to avoid the "static-access" warning. // Answer is 2 System.out.println(String.valueOf(m1.getMath().calc(1))); // Answer is 3 System.out.println(String.valueOf(m2.getMath().calc(1))); } } </code></pre>
2
How to get rid of grey lock with an orange triangle Firefox self signed certificate
<p>I have a self signed certificate which I trusted in Firefox through 'Add exception', but when I request my localhost site (certificate's Common Name is <code>localhost</code>), I see a grey lock with orange triangle:</p> <p><a href="https://i.stack.imgur.com/QdFgq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QdFgq.png" alt="enter image description here"></a></p> <p>While in Chrome:</p> <p><a href="https://i.stack.imgur.com/bMZQe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bMZQe.png" alt="enter image description here"></a></p> <p>I read about it at the Mozilla website (<a href="https://support.mozilla.org/en-US/kb/mixed-content-blocking-firefox" rel="nofollow noreferrer">https://support.mozilla.org/en-US/kb/mixed-content-blocking-firefox</a>):</p> <p><a href="https://i.stack.imgur.com/w2qDk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w2qDk.png" alt="enter image description here"></a></p> <p>But I do not have insecure passive content at <code>https://localhost</code>, I just output a blank page, nothing more.</p> <p>How can I see a green lock in Firefox too?</p> <p>Thanks for the attention.</p> <p>EDIT: Here is what Firefox says when I click the lock:</p> <p><a href="https://i.stack.imgur.com/MC43v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MC43v.png" alt="enter image description here"></a></p> <p><code>Connessione non sicura</code> means <code>Connection not secure</code>.</p> <p>Firefox's console:</p> <p><a href="https://i.stack.imgur.com/7uE8I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7uE8I.png" alt="enter image description here"></a></p>
2
Running a Exchange 2013 script through PowerShell
<p>I am trying to setup a script to run with scheduled task each night for Exchange 2013. I have created a .ps1 that runs the exchange cmdlet and then the script that I want ran follows. The issues that I am having it that the script is not running after PowerShell access Exchange.</p> <p>Here is the script:</p> <p>powershell.exe -NonInteractive -noexit -command ". 'E:\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto -ClientApplication:ManagementShell"</p> <p>Set-CalendarProcessing -Identity "Room" -BookingWindowInDays (New-timespan -Start (GET-Date) -End 12/1/16).days</p> <p>If I copy the script and paste it into PowerShell it works but if I right click on the .ps1 file and select "Run in PowerShell" it connects to Exchange but does not run the rest.</p> <p>Any help is greatly appreciated. Thank you.</p>
2
Wordpress + SQL + Polylang function
<p>I'm trying to make table from <code>custom_post_type</code> named <code>company</code>. I have there company name, desc and meta tags for each record. This website is multilanguage, but i don't want to make double posts for each company so i've made extra fields <code>acf</code> for other lang etc.</p> <p>When I'm on English version of page, everything is working great. The problems is on Polish version.</p> <p>Here is a sql of getting all post by custom meta_key. </p> <pre><code>$all_posts = $wpdb-&gt;get_results( " SELECT *, meta_value as meta_value_pl FROM $posts LEFT JOIN $postmeta ON ( $posts.ID = $postmeta.post_id ) WHERE post_type = 'company' AND post_status = 'publish' AND $postmeta.meta_key = '$name' ORDER BY meta_value DESC LIMIT $start, $per_page"); </code></pre> <p>I want to make a virtual column of translation the meta_value and order by it. But i can't translate the meta_value by pll_() function because i can't place it there.</p> <p>Ex:</p> <pre><code>$all_posts = $wpdb-&gt;get_results( " SELECT *, pll__(meta_value) as meta_value_pl FROM $posts LEFT JOIN $postmeta ON ( $posts.ID = $postmeta.post_id ) WHERE post_type = 'company' AND post_status = 'publish' AND $postmeta.meta_key = '$name' $where_search ORDER BY meta_value DESC LIMIT $start, $per_page"); </code></pre> <p>But i get this text 'pll__(meta_value)' in column, not the translation.</p> <p>I don't know I'm explaining it very clear, but maybe someone will understand that :)</p>
2
Array elements Comparison Java
<p>As a beginner I am doing online problems to understand arrays, this is not homework but practice. Any advice helps!</p> <p><strong>The code should take user input</strong>.</p> <p><strong>Problem:</strong> </p> <p>Print two space-separated integers denoting the respective comparison scores earned by A and B.</p> <ul> <li>Sample Input</li> </ul> <p>5 6 7 3 6 10</p> <ul> <li>Sample Output</li> </ul> <p>1 1 </p> <p><strong>Explanation</strong></p> <p>In this example: A = (a0, a1, a2) where the values are (5,6,7)</p> <p>B = (b0,b1,b2) where the values are (3,6,10)</p> <p>Compare each individual score:</p> <p>a0 > b0 ==> so A receives 1 point.</p> <p>a0 = b0 ==> nobody receives a point.</p> <p>b0 > a0 ==> so B receives 1 point.</p> <p>A's comparison score is 1 and B's comparison score is 1. Thus, we print 1 1 on a single line.</p> <p><strong>Approach 1:</strong> </p> <p>First I though of implementing this as a 2d array but I only got this far as I am not sure where to implement the comparison:</p> <pre><code>public class CompareElem2DArray{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int array2d [][]= new int[3][3]; System.out.println("Please enter 3 marks for A and 3 marks for B: "); for(int a = 0; a&lt;3; a++) //row { for(int b=0; b&lt;3; b++)//column { int array2d[a][b] = in.nextInt(); } } for (int column = 0; column&lt;3; column++) { for(int row=0; row&lt;3; row++) { System.out.println( array2d[column][row]+" "); } } System.out.println(); } } </code></pre> <p><strong>Approach 2:</strong></p> <p>This is my second attempt without using 2D arrays.</p> <pre><code>public class Comparison { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a0 = in.nextInt(); int a1 = in.nextInt(); int a2 = in.nextInt(); int b0 = in.nextInt(); int b1 = in.nextInt(); int b2 = in.nextInt(); int a[] = new int[3]; int b[] = new int[3]; int firstAns = 0; int secondAns = 0; for(int i = 0; i&lt;3; i++) { int a[i] = in.nextInt(); System.out.println(a[i]); } for(int j = 0; j&lt;3; j++) { int b[j] = in.nextInt(); System.out.println(b[j]); } for(int z = 0; z&lt;3; z++) { if(a[z]&gt;b[z]) { firstAns++; } else if(a[z]&lt;b[z]) { secondAns++; } else { return; } } System.out.println(firstAns); System.out.println(secondAns); } } </code></pre>
2
Multi step form - ajax response on the following step
<p>is it possible in case of multisteps form (php -ajax - jquery) to get the response from step1 on step 2. For the moment, I get the response but it's block the process form and it's noted on phase1 form. Precision : I'm beginner whith ajax and jquery.</p> <pre><code>success : function(data){ if (data != 'passed') { jQuery('#messages-errors').html(data); } if (data == 'passed') { $(".frm").hide("fast"); $("#step2").show("slow"); $(".open1").css("display","none"); $(".open2").css("display","inline-block"); $("#check-ok").html(data); } }, error : function(){ alert('no working.'); } }); } }); </code></pre>
2
Can I use throw without any message?
<p>Here is my code:</p> <pre><code>try { if ( condition 1 ) { throw; } else { // do something } // some code here if ( condition 2 ){ throw; } } catch (Exception $e) { echo "something is wrong"; } </code></pre> <p>As you see, my <code>catch</code> block has its own error message, And that message is a constant. So really I don't need to pass a message when I use <code>throw</code> like this:</p> <pre><code>throw new Exception('error message'); </code></pre> <p>Well can I use <code>throw</code> without anything? I just need to jump into <code>catch</code> block.</p> <p>Honestly writing an <strong>useless</strong> error message is annoying for me.</p> <hr> <p>As you know my current code has a syntax error: <em>(it referring to <code>throw;</code>)</em></p> <blockquote> <p><strong>Parse error:</strong> syntax error, unexpected ';' in {path}</p> </blockquote>
2
exporting feature importance to csv from random forest
<p>Hi I would like to create a .csv with 2 columns: the feature importance of a random forest model and the name of that feature. And to be sure that the match between numeric value and variable name is correct</p> <p>Here it's an example but I cannot export to .csv correclty</p> <pre><code>test_features = test[["area","product", etc.]].values # Create the target target = test["churn"].values pred_forest = my_forest.predict(test_features) # Print the score of the fitted random forest print(my_forest.score(test_features, target)) importance = my_forest.feature_importances_ pd.DataFrame({"IMP": importance, "features":test_features }).to_csv('forest_0407.csv',index=False) </code></pre>
2
Intro.js doesn't skip over hidden element
<p>I been working with <code>Intro.js</code> for a week now and found out that it doesn't skip over hidden elements:</p> <pre><code>for (var i = 0, elmsLength = allIntroSteps.length; i &lt; elmsLength; i++) { var currentElement = allIntroSteps[i]; //alert(( jQuery(currentElement).is(':visible') )); // skip hidden elements /*if (jQuery(currentElement).is(':visible') == true) { continue; }*/ if (currentElement.style.display == 'none') { continue; } var step = parseInt(currentElement.getAttribute('data-step'), 10); if (step &gt; 0) { introItems[step - 1] = { element: currentElement, intro: currentElement.getAttribute('data-intro'), step: parseInt(currentElement.getAttribute('data-step'), 10), tooltipClass: currentElement.getAttribute('data-tooltipClass'), highlightClass: currentElement.getAttribute('data-highlightClass'), position: currentElement.getAttribute('data-position') || this._options.tooltipPosition }; } } </code></pre> <p>it still doesn't work.</p> <p>anyone know what is the real issue ? please help</p>
2
Mocking a generic class with an abstract version of said class
<p>I'm attempting to mock an abstract class, but from what I've seen, I don't think it's possible. We have some classes that use generics, that must extends a specific abstract class. There's a whole group of them and they have been mocked successfully. The abstract class has one method that deals with returning the generic and looks like this:</p> <pre><code>public abstract class ChildPresenter &lt;T extends ChildView&gt; { private T view; public abstract T getView(); } </code></pre> <p>The class we are testing has the following in it:</p> <pre><code>public class ParentPresenter { private ConcreteChildPresenter1 childPresenter1; private ConcreteChildPresenter2 childPresenter2; private ConcreteChildPresenter3 childPresenter3; private ConcreteChildPresenter4 childPresenter4; List&lt;ChildPresenter&gt; childPresenters; } </code></pre> <p>In the constructor, these classes are injected in, using Google Guice, set to the variables, and added to the list of child presenters.</p> <p>The method under test is one that iterates over all of the <code>childPresenters</code> objects and runs the method <code>getView()</code>.</p> <p>I attempted it this way in my test class:</p> <pre><code>public class ParentPresenterTest { private ConcreteChildPresenter1 childPresenter1; private ConcreteChildPresenter2 childPresenter2; private ConcreteChildPresenter3 childPresenter3; private ConcreteChildPresenter4 childPresenter4; private List&lt;ChildPresenter&gt; childPresenters; //This is an abstract class private ChildView childView; @BeforeTest public void createInjector() { Guice.createInjector(...//Creates a fake module and does binding for the variables mentioned earlier //e.g. childPresenter1 = mock(ConcreteChildPresenter1.class); binder.bind(ConcreteChildPresenter1.class).toInstance(childPresenter1); //e.t.c for other variables //Same for child view childView = mock(ChildView.class); binder.bind(ChildView.class).toInstance(childView); } childPresenters = new ArrayList&lt;ChildPresenter&gt;(); childPresenters.add(childPresenter1); //Add all child presenters for(ChildPresenter childPresenter : childPresenters) { when(childPresenter.getView()).thenReturn(childView); } } } </code></pre> <p>The problem happens at the line <code>when(childPresenter.getView()).thenReturn(childView);</code> as Mockito complains with the following message:</p> <blockquote> <p>org.mockito.exceptions.misusing.WrongTypeOfReturnValue:</p> <p>ChildView$$EnhancerByMockitoWithCGLIB$$2f6a4bd5</p> <p>cannot be returned by getView() getView() should return ConcreteChildView1</p> <p>*** If you're unsure why you're getting above error read on. Due to the nature of the syntax above problem might occur because:</p> <ol> <li><p>This exception <em>might</em> occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing.</p> </li> <li><p>A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.</p> </li> </ol> </blockquote> <p>Which I can understand, but it seems a waste to mock each individual concrete <code>ChildView</code> when all I want to do is confirm the mocked <code>ChildView</code> called a single method using the following:</p> <pre><code>verify(childView, atLeast(childPresenters.size())).getView(); </code></pre> <p>Is there another way to do this? Can I somehow use mocked abstract classes in place of the concrete ones?</p> <p><strong>EDIT</strong> Here is a concrete version of how the <code>getView()</code> method is implemented:</p> <pre><code>public ConcreteChildPresenter1&lt;ConreteChildView1&gt; { @Override public ConreteChildView1 getView() { view.buildView(); return view; } } </code></pre> <p>And the abstract <code>ChildView</code> class that all child views extend:</p> <pre><code>public abstract ChildView { public abstract void buildView(); } </code></pre>
2
Caching a link to another page with service worker
<p>I am looking to cache the contents of a dynamic linked page. I have a simple index.html with a service worker registered, and want to set it up where when you reach this page it dynamically caches the contents that the link is pointing to (the idea is that this second page will not be included in the static install event). </p> <p>Basically I am designing a page that will have a link to a recommended/related page which I want to be stored in the cache. When the user clicks the link to the recommended related page I want it to load from the cache.</p> <p>index.html: </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;script src="script.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hello Plunker!&lt;/h1&gt; &lt;h3&gt;I want to cache&lt;/h3&gt; &lt;a href="page2.html"&gt;this link to my second page!&lt;/a&gt; &lt;script&gt; if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').then(function(reg) { // registration worked console.log('Registration succeeded. Scope is ' + reg.scope); }).catch(function(error) { // registration failed console.log('Registration failed with ' + error); }); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>page2.html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;script src="script2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;This is my second page!&lt;/h1&gt; &lt;h3&gt;I want everything from this page to be stored in the cache.&lt;/h3&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is the plunkr: <a href="https://plnkr.co/edit/YIAacgkuboyRBkv10hfl?p=catalogue" rel="noreferrer">https://plnkr.co/edit/YIAacgkuboyRBkv10hfl?p=catalogue</a></p> <p>How can I set up my fetch event to dynamically cache the contents of the second page without explicitly putting page2.html in my static install event? </p>
2
Force JavaScript to load additional resources over https
<p>I am using the <a href="https://developers.google.com/virtual-keyboard/v1/getting_started" rel="nofollow">Virtual Keyboard (Deprecated)</a> from Google in my current project. Unfortunately it loads some additionale js-resources from an insecure source. Is there a way to force the script to use https instead of http?</p> <p>The problem is the language file which is used to display the correct letters. The stylesheet e.g. is loaded over https.</p> <p>Here is my script:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Virtual Keyboard | Google APIs&lt;/title&gt; &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input id="language"&gt; &lt;script&gt; google.load("elements", "1", { packages: "keyboard" }); function onLoad() { var kbd1 = new google.elements.keyboard.Keyboard( [google.elements.keyboard.LayoutCode.SWEDISH], ['language']); } google.setOnLoadCallback(onLoad); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Update:</p> <p>The only resource, which is loaded over normal http is <a href="http://www.google.com/uds/modules/elements/keyboard/sv.js" rel="nofollow">the language-file</a>, in this case the swedish version. The language-file is loaded in the function <code>onLoad</code> during the <code>var kb1 = new google....</code>.</p>
2
VB Script Integer division vs Float Division Rounding up
<p>Hi Fellow stackoverflowers,</p> <p>I'm having a problem converting a formula from <code>classic asp</code> <code>VBscript</code> to <code>C# .net</code> I need <code>c#</code> to behave similar to the result of the <code>VBScript</code></p> <p>The formula goes like this</p> <pre><code>Dim dTravelHours, result dTravelHours = 22.7359890666919 result = (CDbl(dTravelHours)*2 + 2)\8 </code></pre> <p>Mathematically the result is 5.9331475 however since I used an integer division instead of Decimal division "/" The result is 5 , I can get this result properly in c# by simply type casting the result to int</p> <p>however if I used a differently value:</p> <pre><code>Dim dTravelHours, result dTravelHours = 22.7359890666919 result = (CDbl(dTravelHours)*2 + 2.5)\8 </code></pre> <p>the mathematical result is 5.9956475 and vbScript result is 6</p> <p>the same with 5.9456475 the <code>vbscript</code> result is 6</p> <p>How do I replicate the same behavior in <code>C#</code> ? I already tried using <code>Math.Floor,</code> <code>Math.Ceiling</code>, <code>Math.Round</code> but still no Good.</p> <p>Thanks in advance for your answers and suggestions </p>
2
How to get data in chunks from very large table which has primary key column data type as varchar
<p>I want to retrieve data from table with 28 million rows. I want to retrieve 1 million rows at a time. </p> <p>I have checked answers from following links <a href="https://stackoverflow.com/questions/23952899/get-data-from-large-table-in-chunks">Get data from large table in chunks</a> <a href="https://stackoverflow.com/questions/8439645/how-can-i-get-a-specific-chunk-of-results">How can I get a specific chunk of results?</a> The solution suggests a query which has int ID column. In my case I have primary key column with varchar(15) as data type</p> <p>I want to use something like this which is faster - Select top 2000 * from t where ID >= @start_index order by ID</p> <p>But since the ID column is varchar, I can not use integer index. </p> <p>How can I efficiently get data in chunks from a table with primary key having varchar data type?</p>
2