pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
7,320,133 | 0 | Add alias for jquery support in Eclipse Aptana Plugin <p>I've managed to enable jQuery support using this tutorial <a href="http://stackoverflow.com/questions/4721124/how-to-enable-jquery-support-in-aptana-studio-3">How to enable jQuery support in Aptana Studio 3</a> and using code completion with:</p> <pre><code>$. or $("p").add( ... </code></pre> <p>works. But in my projects I need to use the nonconflict Version. So I added this:</p> <pre><code><aliases> <alias name="$" type="jQuery"/> <alias name="jQuery" type="jQuery"/> </aliases> </code></pre> <p>but this doesn't seem to work. </p> <p>This tutorial <a href="http://wiki.appcelerator.org/display/tis/Using+JavaScript+Libraries" rel="nofollow">http://wiki.appcelerator.org/display/tis/Using+JavaScript+Libraries</a> says</p> <blockquote> <p>Save it to your disk, and then drag it into your project. It does not matter where in the project it sits, so you can create a new folder for files like this if you like.</p> </blockquote> <p>so I added a folder /source/support to fit my structure and add .sdocml files there.... but nothing seems to happen. So I'm not really sure if adding the file actually does something. Tried adding it a couple of times, but this doesn't seem to trigger anything.</p> <p>Any clues? </p> |
37,523,724 | 0 | <p>You can't do it with jQuery's <code>.slideUp()</code> and <code>.slideDown()</code> function because it animates <code>height</code> of the element. However you can add <code>class</code> on <code>click</code> and use css <code>transform</code> for styling them.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$("#slide").click(function() { $("#top, #bottom").toggleClass('hidden'); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.slide { position: relative; height: 100px; background-color: yellow; overflow: hidden; } .slide .innerTop, .slide .innerBottom { transition: transform 0.25s linear; transform: translateY(0); } .slide .innerTop { position: absolute; top: 0px; } .slide .innerTop.hidden { transform: translateY(-100%); } .slide .innerBottom { position: absolute; bottom: 0px; } .slide .innerBottom.hidden { transform: translateY(100%); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <button id="slide">slide it</button> <div id="slidebottom" class="slide"> <div class="innerTop" id="top">Slide from top</div> <div class="innerBottom" id="bottom">Slide from bottom</div> </div></code></pre> </div> </div> </p> |
2,268,402 | 0 | <pre><code>$("ul#topElement:first") </code></pre> |
2,945,481 | 0 | <p>You might find this <a href="http://www.devdaily.com/FunctionPoints/" rel="nofollow noreferrer">tutorial</a> on FPA of interest. Personally, I don't put much stock in this estimation method. From my perspective it attempts to provide a precise estimate in for things that have been shown repeatedly to not be precisely measurable. I much prefer <a href="http://www.mountaingoatsoftware.com/topics/planning-poker" rel="nofollow noreferrer">planning poker</a> or something similar that tries to group things within a similar order of magnitude and provide an estimate based on your previous estimations for similarly sized stories.</p> <p>If you're doing this for a class, simply follow the rules given in the text book and crank out the answer. If you're really intending to try this as a software development estimation method, my advice is to simplify the process rather than make it more complex. I would imagine that members of the International Function Point User Group (yes, there is one), will disagree.</p> |
33,896,523 | 0 | <p>Since every <code>id</code> in a page must be unique, and the <code><s:radio></code> tag is generating multiple HTML tags, it is generating multiple <code>id</code>s; </p> <p>the real mistake however is that you are looping through radio buttons like if they would be checkboxes, while they're not. </p> <p><strong>Radio buttons allows only one choice</strong>. </p> <p>Take the element by name and read the value, to get the selected one, or empty if none is selected.</p> <p>Normally you could use <strong>dot notation</strong> (<code>.</code>)</p> <pre><code>document.forms[0].bean.gender.value </code></pre> <p>but since your name has a dot in it, you must use the other syntax (<code>[""]</code>):</p> <pre><code>document.forms[0]["bean.gender"].value </code></pre> |
24,690,196 | 0 | <p>I have been able to solve the problem.</p> <p>Seemingly, the index for the foreign key must have the same column order that the constraint, which is something that I didn't find specified. </p> <p>Changing the constraint to <code>`fk_id_checklist` , `fk_id_user` , `fk_id_user_company` , `fk_sent_date`</code> solves this error.</p> |
12,159,424 | 0 | <p>In javascript you can set breakpoints using the <code>debugger;</code> statement. However, they will only pause node if a debugger is actually attached.</p> <p>So launch your node script using</p> <pre><code>./node.js --debug-brk myfile.js </code></pre> <p>then launch node-inspector and press the play button to continue to the next breakpoint and it will hit your <code>debugger;</code> breakpoint (at least that works for me ATM)</p> <p>you still need one extra click after restarting, but at least your breakpoints are saved.</p> <p>if your breakpoint is not hit automatically, but only after some user action you don't need the <code>--debug-brk</code> of course.</p> |
26,022,922 | 0 | <p>No different at all but on some shells # is used for the user with root privilege .</p> |
26,243,565 | 0 | <p>Try this (wishing it would help, although take backup of your sheet before!):</p> <pre><code>Sub FastestBlankRowTerminator() ActiveSheet.UsedRange.Columns(6).SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub </code></pre> |
625,154 | 0 | <p>I think they did that on purpose - views should be independent from controllers. Think of it like this: you should be able to put controllers into a totally different assembly and still have your application work. Your controllers should also be able to work with totally different set of views.</p> <p>The framework is also setup to go to the views folder to fetch appropriate files. You would have to change that behavior yourself if you decide to move the views. Might not be worth the hassle.</p> <p>And finally, if you really want to do it, you should probably look at your project file. There is a DependsUpon element that you can use to make a file go underneath another:</p> <pre><code><Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> </Compile> </code></pre> |
9,644,704 | 0 | How to get Specific Contact Number by using Contact Id <p>Here my Contact names are Displayed on List View . By clicking the List I get <code>ContactName</code> and <code>Contact Id</code>. From that I want to fetch<code>Phone number</code> by Using either <code>Contact ID</code> or <code>Contact name</code>,Please Help me.</p> <p>Here is My Code</p> <pre><code>void ReadContacts(String sort) { final Uri uri = ContactsContract.Contacts.CONTENT_URI; final String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; //boolean mShowInvisible = false; String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'"; String[] selectionArgs = null; final String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; m_curContacts = managedQuery(uri, projection, selection, selectionArgs, sortOrder); String[] fields = new String[] {ContactsContract.Data.DISPLAY_NAME}; m_slvAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, m_curContacts, fields, new int[] {android.R.id.text1}); m_slvAdapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { Log.d(LOG_TAG, "runQuery constraint:"+constraint); String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'" + " AND "+ ContactsContract.Contacts.DISPLAY_NAME + " LIKE '%"+constraint+"%'"; String[] selectionArgs = null;//new String[]{"'1'"};//, }; Cursor cur = managedQuery(uri, projection, selection, selectionArgs, sortOrder); return cur; } }); m_lvContacts.setAdapter(m_slvAdapter); // cur.close(); } public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { ContentResolver cr; Cursor cursor = (Cursor) m_lvContacts.getItemAtPosition(position); String szDisplayName = cursor.getString(cursor.getColumnIndexOrThrow( ContactsContract.Contacts.DISPLAY_NAME)); String szId = cursor.getString(cursor.getColumnIndexOrThrow( ContactsContract.Contacts._ID)); int nId = cursor.getInt(cursor.getColumnIndexOrThrow( ContactsContract.Contacts._ID)); Log.d(LOG_TAG, "Item click:"+position+" szId:"+szId+" nId:"+nId+" Data:"+szDisplayName); Toast.makeText(getBaseContext(), "Item click:"+phoneNumber+" szId:"+szId+" nId:"+nId+" Data:"+szDisplayName, Toast.LENGTH_SHORT).show(); } </code></pre> |
38,029,444 | 0 | Ajax POST multiple forms with multiple PHP destinations <p>I have a page with two forms and each form uses a different PHP page for its post. I can only find examples / documentation on using multiple forms with the same PHP post script. I am struggling to get this to work, can any help ? </p> <p>This is the JQUERY, that works if i use one form, I've tried to add an ID tag but it didn't seem to work:</p> <pre><code> $(function () { $('form').on('submit', function (e) { var form = $(this); e.preventDefault(); $.ajax({ type: 'post', url: form.attr('action'), data: form.serialize(), success: function () { alert('Suppiler Amended!'); } }); }); }); </script> </head> <body> <?php echo "<div class='table1'>"; echo "<div class='datagrid'>"; echo "<table id='tblData2'><thead><tr><th>Notes</th><th>Updated By</th><th></th></thead></tr>"; while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) { ?> <tbody><tr> <td><FONT COLOR='#000'><b><?php echo "".$row["notes"].""?></td> <td><FONT COLOR='#000'><b><?php echo "".$row["enteredby"].""?></td> <td><FONT COLOR='#000'><b><a href="edit.php"> <form name="edit" action="script1.php" method="post"> <input type="hidden" name="notes" value="<?php echo"".$row["notes"]."";?>"> <input type="hidden" name="noteid" value="<?php echo"".$row["noteid"]."";?>"> <input type="submit" value="EDIT"> </form> </a></td> </tr></tbody> <?php $companyid = "".$row['id'].""; } ?> </table> </div> <br> <form name="notes" action="add-note.php" method="post"> ADD NEW NOTE:<br> <input type="text" name="newnote" style="height:120px;width:200px;"><br> <input type="hidden" name="companyid" value="<?php echo"".$companyid."";?>"> <input type="hidden" name="user" value="<?php echo"".$user."";?>"> <br> <input type="submit" value="ADD NOTE"> </form> </code></pre> |
5,463,544 | 0 | How to format an HTTP PUT request? <p>I am using the Yahoo Placemaker API and would like to send a request but I am getting confused as to how to send the request. The request is composed of a URL and a document and inside the document, there are a bunch of parameters. Please see below.</p> <pre><code>http://wherein.yahooapis.com/v1/document documentContent=Sunnyvale+CA documentType=text/plain appid=my_appid </code></pre> <p>How do I format the URL into a request is it like so?</p> <pre><code>http://wherein.yahooapis.com/v1/documentContent=Sunnyvale+CA?documentType=text/plain?appid=my_appid </code></pre> <p>I would like to use this the Placemaker service for a Mac app written in objective-c.</p> <p>Any suggestions would be great. Thanks.</p> |
9,484,097 | 0 | <p>Your trick would work, if you would tell <code>tr</code>, what slash should be translated into:</p> <pre><code>for w in $(echo "what/the/heck" | tr "/" " ") ; do echo $w; done what the heck </code></pre> |
23,831,156 | 0 | <blockquote> <p>Why does the outer function return a function</p> </blockquote> <p>Because:</p> <p>(a) It has a return statement in front of a function expression</p> <p>and</p> <p>(b) The returned function is used as an argument to a function that expects that argument be a function</p> <blockquote> <p>where does the event-variable come from</p> </blockquote> <p>From the native browser code that implements the event listener routines (according to <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener" rel="nofollow">the specification</a> for <code>addEventListener</code>)</p> |
24,480,553 | 0 | <p>Since you have <code>border-spacing:10px;</code> there will be space remaining on the right and left side to separate the <code>td</code>. However, you could put a <code>div</code> around the table and change it's <code>margin-left</code> and <code>margin-right</code>.</p> <p>Try this:</p> <pre><code>body { background-color: gray; overflow: hidden; } .grid { margin-left: -20px; margin-right: -20px; } </code></pre> <p>You cell 4's text is overflowing but it is because you have a lot of <code>.</code> or dots without a space so when you enter text it should be fine.</p> <p><strong><a href="http://jsfiddle.net/8sw9v/1" rel="nofollow">DEMO</a></strong></p> |
36,011,253 | 0 | How to open multiple files in visual basic for applications (ms outlook) <p>I use this code to open just one file when I click on a button. How can I select multiple files using a part of this code and open the folder at a specific directory?</p> <pre><code> Function BrowseForFile() Dim shell: Set shell = CreateObject("WScript.Shell") Dim fso: Set fso = CreateObject("Scripting.FileSystemObject") Dim tempFolder: Set tempFolder = fso.GetSpecialFolder(2) Dim tempName: tempName = fso.GetTempName() Dim tempFile: Set tempFile = tempFolder.CreateTextFile(tempName & ".hta") tempFile.Write _ "<html>" & _ " <head>" & _ " <title>Browse</title>" & _ " </head>" & _ " <body>" & _ " <input type='file' id='f' >" & _ " <script type='text/javascript'>" & _ " var f = document.getElementById('f');" & _ " f.click();" & _ " var shell = new ActiveXObject('WScript.Shell');" & _ " shell.RegWrite('HKEY_CURRENT_USER\\Volatile Environment\\MsgResp" & tempName & _ "', f.value);" & _ " window.close();" & _ " </script>" & _ " </body>" & _ "</html>" tempFile.Close shell.Run tempFolder & "\" & tempName & ".hta", 0, True BrowseForFile = shell.RegRead("HKEY_CURRENT_USER\Volatile Environment\MsgResp" & tempName) shell.RegDelete "HKEY_CURRENT_USER\Volatile Environment\MsgResp" & tempName fso.DeleteFile (tempFolder & "\" & tempName & ".hta") End Function Public Sub CommandButton1_Click() If ListBox1.ListIndex = -1 Then MsgBox "Message", vbExclamation, "Warning" End If With ListBox1 .AddItem BrowseForFile End With End Sub </code></pre> <p>Thanks in advance,</p> |
34,027,821 | 0 | Content of Element Declaration Must Match and Other Validation Errors <p>I am very new to XML and Schema and am having a really hard time trying to validate my document. I keep getting the error that Content of Element Declaration Must Match at line 13 column 58. I have tried everything I can possibly think of and read every article and other question and can't figure it out. Please help!</p> <p>Here is my XML:</p> <pre><code><?xml version="1.0" encoding="UTF-8" ?> <CustomerAccount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" LastUpdated="2011-12-01" xsi:noNamespaceSchemaLocation="me.xsd"> <UpdatedBy kind="SalesPerson">Lisa Moroz</UpdatedBy> <ShipTo country="Canada"> <name>Maya Wells</name> <street>44 Gamble Avenue</street> <city>Toronto</city> <province>ON</province> <zip>L1M3G1</zip> </ShipTo> <ShipTo country="Canada"> <name>Maya Wells</name> <street>62 Elm Street</street> <city>Montreal</city> <province>QC</province> <zip>K2J3H4</zip> </ShipTo> <BillTo> <country>Canada</country> <name>Maya Wells</name> <street>78 Audley Street</street> <city>Oakville</city> <province>ON</province> <zip>O3R1M5</zip> </BillTo> </CustomerAccount> </code></pre> <p>And here is my Schema:</p> <pre><code><?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="CustomerAccount"> <xs:complexType> <xs:sequence> <xs:simpleType> <xs:element name="UpdatedBy" type="xs:string" /> </xs:simpleType> <xs:sequence> <xs:element name="ShipTo" type="ShipToType" minOccurs="1" maxOccurs="unbounded"/> <xs:element name="BillTo" type="BillToType" /> </xs:sequence> <xs:attribute name ="kind" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="ShipToType"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="street" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="province" type="xs:string"/> <xs:element name="zip" type="xs:string"/> </xs:sequence> <xs:attribute name="country" type="xs:string"/> </xs:complexType> <xs:complexType name="BillToType"> <xs:sequence> <xs:element name="country" type="xs:string" /> <xs:element name="name" type="xs:string"/> <xs:element name="street" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="province" type="xs:string"/> <xs:element name="zip" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> </code></pre> <p>Thanks for your help!</p> |
8,936,890 | 0 | RandomMove Method Tic Tac Toe Not Functional <p>I am working on creating a tic tac toe game that allows the user to play against a computer. When the user selects a button on the board, the AI will detect if there is a possible three combo. If there is no threat detected, than the computer will pick a spot randomly on the board to move.</p> <p>However, my problem is when I make a certain move, the computer sometimes places a move and sometimes get skipped. I was wondering how to fix this, my <code>randomMove()</code> method is displayed below.</p> <p>Would this situation call for a recursive method (my teacher briefly told me this might be necessary) or otherwise? If it is recursive, can you explain it? Thanks for any help!</p> <pre><code>public void RandomMove() { Random x = new Random(); int y = 1 + x.nextInt(9); if (buttons[y].getText().equals("O") || buttons[y].getText().equals("X")) { RandomMove(); } else { buttons[y].setText("O"); buttons[y].setEnabled(false); } } </code></pre> <p>More specifically I get this error sometimes:</p> <blockquote> <p>Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError</p> </blockquote> |
38,755,365 | 0 | <p>Running gradle with the --info flag to determine the command being run:</p> <pre><code>gradlew :app:compileHello-jniArm64- v8aDebugAllSharedLibraryHello-jniMainC --info </code></pre> <p>In the output you should see a command containing <code>aarch64-linux-android-gcc -dM -E -</code> with a full path. Check that you do actually have this binary at the path shown (it should have been included in the android ndk).</p> <p>Assuming you do, try running the command yourself. It will read from stdin and print a bunch of constants to stdout (gradle is trying to parse the version from this), but you want to see stderr:</p> <pre><code>echo '' | ./aarch64-linux-android-gcc -dM -E - 1>/dev/null </code></pre> <p>If the command fails, an error should be shown which can hint at the problem. In my case it was trying to include a folder <code>4.9.x</code> but I had a folder named <code>4.9</code>. Most likely there will be a different problem with your setup.</p> |
6,235,391 | 0 | Set a HTML elements width attribute right away using javascript <p>Is it possible to set an elements width like this:</p> <pre><code><img id="backgroundImg" src="images/background.png" alt="" width="javascript:getScreenSize()['width']+px" height="1100px"/> </code></pre> <p>Where getScreenSize() is a javascript function.</p> <pre><code> function getScreenSize() { var res = {"width": 630, "height": 460}; if (document.body) { if (document.body.offsetWidth) res["width"] = document.body.offsetWidth; if (document.body.offsetHeight) res["height"] = document.body.offsetHeight; } if (window.innerWidth) res["width"] = window.innerWidth; if (window.innerHeight) res["height"] = window.innerHeight; alert( res['width'] ); return res; } </code></pre> <p>Or do I have to change the img's width inside a javascript function?</p> <pre><code>function changeImgWidth( img ) { img.offsetRight = getScreenWidth()['width'] + "px"; } </code></pre> |
8,931,834 | 0 | <p>The ISO C++ Standard specifies that all virtual methods of a class that are not pure-virtual must be defined. </p> <p>Simply put the rule is:<br> If your derived class overiddes the Base class virtual method then it should provide a definition as well, If not then the Base class should provide the definition of that method. </p> <p>As per the above rule in your code example, <code>virtual void bar();</code> needs a definition in the Base class.</p> <p>Reference:</p> <p><strong>C++03 Standard: 10.3 Virtual functions [class.virtual]</strong> </p> <blockquote> <p>A virtual function declared in a class shall be defined, or declared pure (10.4) in that class, or both; but no diagnostic is required (3.2).</p> </blockquote> <p>So either you should make the function pure virtual or provide a definition for it. </p> <p>The <strong><a href="http://gcc.gnu.org/faq.html#vtables" rel="nofollow">gcc faq</a></strong> doccuments it as well: </p> <blockquote> <p>The ISO C++ Standard specifies that all virtual methods of a class that are not pure-virtual must be defined, but does not require any diagnostic for violations of this rule <code>[class.virtual]/8</code>. Based on this assumption, GCC will only emit the implicitly defined constructors, the assignment operator, the destructor and the virtual table of a class in the translation unit that defines its first such non-inline method.</p> <p>Therefore, if you fail to define this particular method, the linker may complain about the lack of definitions for apparently unrelated symbols. Unfortunately, in order to improve this error message, it might be necessary to change the linker, and this can't always be done.</p> <p>The solution is to ensure that all virtual methods that are not pure are defined. Note that a destructor must be defined even if it is declared pure-virtual <code>[class.dtor]/7</code>.</p> </blockquote> |
24,981,233 | 0 | <p>9,999,999,999 is more then <code>int32</code> max value (that is 2,147,483,647. <a href="http://msdn.microsoft.com/en-us/library/system.int32.maxvalue(v=vs.110).aspx" rel="nofollow">link</a>)</p> <p>use <code>int64</code> instead (int64 max value is: 9,223,372,036,854,775,807. <a href="http://msdn.microsoft.com/en-us/library/system.int64.maxvalue(v=vs.110).aspx" rel="nofollow">link</a>)</p> |
27,275,397 | 0 | specific stripchart with ggplot2 <p>I've got this dataframe</p> <pre><code>df <- structure(list(rang = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25.5, 25.5, 27.5, 27.5, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42.5, 42.5, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54.5, 54.5, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88 ), dr = c(164, 176, 260, 297, 308, 313, 327, 333, 339, 365, 396, 403, 404, 410, 413, 414, 422, 424, 440, 442, 443, 451, 477, 496, 530, 530, 546, 546, 548, 565, 567, 574, 576, 587, 590, 603, 619, 626, 629, 630, 642, 653, 653, 660, 667, 670, 677, 682, 689, 711, 716, 737, 763, 772, 772, 776, 778, 792, 794, 820, 835, 838, 842, 855, 861, 888, 890, 899, 906, 908, 969, 1011, 1046, 1058, 1069, 1072, 1074, 1100, 1153, 1348, 1368, 1432, 1468, 1516, 1612, 1712, 1714, 1731), signe = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L), .Label = c("negatif", "positif"), class = "factor")), .Names = c("rang", "dr", "signe"), row.names = c(NA, -88L), class = "data.frame") </code></pre> <p>and this chart when I use the <code>stripchart</code> function in base R </p> <pre><code>stripchart(df[,1]~df[,3], method="stack", vertical=FALSE, ylim=c(0.5,2.5), group.names=levels(df[,3]), xlab="Rang des différences dr", pch=18, cex=1.2) </code></pre> <p>Can I have the same plot with the library <code>ggplot2</code>? I used <code>geom_dotplot</code> but I didn't the same plot. This an example </p> <pre><code>ggplot(data = df, aes(y=df[,1], x=factor(df[,3]))) + geom_dotplot(binaxis = "y", dotsize = 0.5) + coord_cartesian(ylim=c(0, 88)) + scale_y_continuous(breaks=seq(0, 88, 1)) </code></pre> <p>Help me, please!</p> |
32,257,363 | 0 | <p>You can do it on <code>change</code> event. You can use <strong><a href="http://api.jquery.com/on/" rel="nofollow"><code>on()</code></a></strong> function for binding events.</p> <pre><code>$('yourInputSelector').on('input',function(){ if( $(this).val() == 0 ) $('yourDiv').show(); else $('yourDiv').show(); }); </code></pre> |
7,215,491 | 0 | <p>As dnndeveloper says, your answer is <code>ObjectContext.CreateObject<T>.</code></p> <p>So you're gonna want - </p> <pre><code> Dim ci = _db.CreateObject(Of CalenderItem)() ci.OrderDetail = _orderDetail ci.Image = c.image ci.YearMonth = c.YearMonth _orderDetail.CalenderItems.Add(ci) </code></pre> <p>or something along those lines. I've run into this issue a couple of times and this has worked so far.</p> <p>HTH</p> |
38,789,234 | 0 | <p>You can have a List for data and pass the data to viewpager adapter in constructor and in view pager you can pass the data to fragment in getItem() function.</p> |
35,514,929 | 0 | Rounding in R Returning Wrong Value <p>Consider the following code using a modified rounding function:</p> <pre><code>round2 = function(x, n) { posneg = sign(x) z = abs(x)*10^n z = z + 0.5 z = trunc(z) z = z/10^n z*posneg } n<-387.9 d<-400 round2(n/d,4) </code></pre> <p>The function should return 0.9698, but it returns 0.9697. This seems to occur during the trunc function when 9698 gets truncated to 9697. Is there another rounding function I can use (besides the default round function) to make this value correct?</p> |
12,848,334 | 0 | <pre><code>$("input").click(function() { var dataAttr = $(this).attr("data-logic"); if (dataAttr == "yes") { var value = $(this).attr("value"); alert('Has logic ' + value); } }); </code></pre> <p><a href="http://jsfiddle.net/wCRLE/1/" rel="nofollow">http://jsfiddle.net/wCRLE/1/</a></p> |
39,493,460 | 0 | <p>Hopefully you can find your answer in this:</p> <p><a href="https://jsfiddle.net/ekekp8rh/1/" rel="nofollow">https://jsfiddle.net/ekekp8rh/1/</a></p> <p>Not sure what you were hoping to get but at least this displays a chart.</p> <pre><code>var data = { projects: [{ name: 'Project X', jobs_running: [ [1459814400000, 121], [1459900800000, 205], [1459987200000, 155], [1460073600000, 458] ], jobs_pending: [ [1459814400000, 146], [1459900800000, 149], [1459987200000, 158], [1460073600000, 184] ] }, { name: 'Project Y', jobs_running: [ [1459814400000, 221], [1459900800000, 295], [1459987200000, 255], [1460073600000, 258] ], jobs_pending: [ [1459814400000, 246], [1459900800000, 249], [1459987200000, 258], [1460073600000, 284] ] }] }; nueva(data); function nueva(current_data) { var seriesOptions = [], type = ['jobs_running', 'jobs_pending']; for (var j = 0; j < current_data['projects'].length; j++) { var project = current_data['projects'][j]; for (var i = 0; i < type.length; i++) { seriesOptions.push({ name: project.name + ' ' + type[i], data: project[type[i]] }); } } $('#containerChart').highcharts('StockChart', { series: seriesOptions }); } </code></pre> |
27,861,200 | 0 | <p>What you are now doing is getting the <code>context.getAttribute()</code> from the ServletContext itself not from the HttpServletRequest. So it should be something like this: <code>String value = (String) req.getAttribute(token)</code>. Also keep in mind .getAttribute() method returns null if no attribute of the given name exists.</p> |
25,207,200 | 0 | How to set current spinner text without changing associated selection list items <p>I have a Spinner with some values</p> <pre><code>| Monday | | Thuesday | | Wednesday | | Thursday | | Friday | | Saturday | | USER DEFINED | </code></pre> <p>When the user choose <code>USER DEFINED</code> he can input a custom value in a dialog, assuming that I get this value as <code>String userDef="Your choice"</code>.</p> <p>I need to set this String as current item, without change the spinner selection list, that must appear the same described above, also when the user clicks again on the spinner, something like in Google Analytics Android App, see the image.</p> <p><em>unclicked spinner</em> <img src="https://i.stack.imgur.com/Fyswk.jpg" alt="Unclicked spinner Google Analytics"> <em>clicked spinner</em> <img src="https://i.stack.imgur.com/amAxE.jpg" alt="clicked spinner Google Analytics"></p> <p>How could I do this?</p> |
22,060,105 | 0 | <p>You are using <code>System.out.println("X");</code> This automatically appends a newline character to the end of the string.</p> <p>Instead use <code>System.out.print("X");</code> to print the X's next to each other.</p> |
21,583,536 | 0 | <p>Use Python's classes for this.</p> <p>A simple example. Let's first define a Point data structure that will hold information about a point in cartesian coordinates:</p> <pre><code>class Point(object): """ Define a point at X, Y """ def __init__(self, x=0, y=0): self.x=x self.y=y </code></pre> <p>Now let's define a circle:</p> <pre><code>class Circle(object): def __init__(self, x=0, y=0, radius=1): """ Define a circle centered at X, Y with radius """ self.x=x self.y=y self.radius=radius </code></pre> <p>Now you can declare an instance of each and test if the point is inside the circle:</p> <pre><code>>>> c1=Circle() # default of x=0, y=0, radius=1 >>> p1=Point(5,6) # a point at x=5, y=6 </code></pre> <p>Is that point inside the circle? You can test it:</p> <pre><code>>>> ((p1.x-c1.x)**2 + (p1.y - c1.y)**2)**0.5<c1.radius False </code></pre> <p>That would be a whole lot easier if we did not have to remember the pythagorian theorem for the circle's center and the point. Let's add that basic functionality to the Circle object:</p> <pre><code>class Circle(object): def __init__(self, x=0, y=0, radius=1): self.x=x self.y=y self.radius=radius def point_in(self, p): return ((p.x-self.x)**2 + (p.y - self.y)**2)**0.5<self.radius </code></pre> <p>Now you can use a more logical method:</p> <pre><code>>>> c1.point_in(Point(5,5)) False >>> c1.point_in(Point(.5,.5)) True </code></pre> <p>So what about 'above' or 'below'? I suppose 'above' would mean if a point is outside the circle and <code>Point.y > Circle.y</code>. Add this to the Circle class:</p> <pre><code>def above(self, p): return ((p.x-self.x)**2 + (p.y - self.y)**2)**0.5 > self.radius and p.y>self.y </code></pre> <p>Test it:</p> <pre><code>>>> c1.above(Point(5,5)) True </code></pre> <p>You can extend this concept so that you can test if a circle overlaps another circle or an area of a polygon defined by Points. You can also extend it so that each shape will use the appropriate formula for itself and the other shape. (How do you know if polygons intersect? Now we are talking more complexity! Start <a href="http://stackoverflow.com/a/218081/298607">HERE</a>. If you have OpenGL, you can draw the two polygons offscreen with two additive colors and test for added pixel colors...)</p> <p>Then extend that to what you mean by 'above' and 'below' for triangles squares, rectangles, circles. Your basic definition of shapes other than a circle will require a rotation or just be defined as polygons by their vertices. </p> |
14,984,488 | 0 | <p>That is right: no such class exists in the QtGui module of Qt5. And yes, you have to resort to plain OpenGL calls to handle your textures if you don't want to pull in the widget library.</p> <p>That being said, the current (let's say somewhat non-optimal and inconsistent) situation is recognized and actively being discussed by the Qt developers. See Sean Harmer's <a href="http://lists.qt-project.org/pipermail/development/2012-December/008765.html" rel="nofollow">OpenGL in Qt 5.1 and onwards</a> mail, specifically point 7. But following that thread and having a look at the current dev tree, I doubt it is going to land in 5.1.</p> <hr> <p>Edit: Looking at the other answers and the recent comments I'd like to add regarding options you have with standard Qt 5.0:</p> <p>Is your main goal to:</p> <ol> <li>get some pointer you can pass to <code>glTexImage2D(..., GL_UNSIGNED_BYTE, GL_RGBA, pointer)</code> from your potentially 'weird' formatted QImage? or</li> <li>use some helper class that spares you dealing with <code>glTex*()</code> related functions?</li> </ol> <p>If it is the first and linking the (old) OpenGL module (which is part of Qt 5.0) is an option (and apart from 'esthetically' reasons, I don't see why it would not be), you could use the static <code>QGLWidget::convertToGLFormat(QImage)</code> that Victor was hinting at. If not, then doing something like that function does 'by hand' (along the lines of what Xīcò suggested) should work: basically first calling <code>QImage::convertToFormat(QImage::Format_ARGB32)</code> and then add some platform dependent byte swizzeling and mirroring (see <em>convertToGLFormatHelper(...)</em> in <a href="http://qt.gitorious.org/qt/qt/blobs/4.8/src/opengl/qgl.cpp" rel="nofollow">the source</a>). Although, if you happen to use your own shaders, then doing that on the GPU is way faster.</p> <p>If you want to have both <em>and</em> linking the mentioned OpenGL Qt 5.0 add-on module is an option you might be able to actually use a <code>QGLWidget::bindTexture(...)</code> equivalent even in your QQuickView class:</p> <pre><code>GLuint texID = QGLContext::fromOpenGLContext( this->openglContext())->bindTexture(...) </code></pre> <p>Where <code>this</code> would be a QQuickView*. See the <a href="http://qt-project.org/doc/qt-5.0/qtopengl/qglcontext.html" rel="nofollow">QGLContext help</a>. (Disclaimer: I have not tried that myself.)</p> |
20,175,868 | 0 | Extracting sub-matrices from a matrix <p>I was wondering: I have a 100x100 matrix. I would like to split it in several 10x10 sub-matrices the first including columns and rows 1-10, then second including columns 11-20 and rows 1-10 and son on until eventually I have a set of 10x10 matrices.</p> <p>Is there any way of doing this without needing to build an extremely complex array of for loops?</p> <p>Thanks :)</p> |
12,485,187 | 0 | Google Docs Folder Not Found <p>We are using Document List API version 3. We use two-legged OAuth and get access using permission obtained through Google Apps Marketplace. We retrieve a list of folders contained in a folder as follows: https://docs.google.com/feeds/default/private/full/folder:[folder doc id]/contents/-/folder?xoauth_requestor_id=[user name]</p> <p>We get 9 results. We retain the document ids of these folders. Later on we retrieve each folder using their document id as follows where [user name] is the same as what we used previously: https://docs.google.com/feeds/default/private/full/[folder doc id]?xoauth_requestor_id=[user name]</p> <p>We are able to get the document (folder) for 8 of the 9 but for one of them we get ResourceNotFoundException no matter when we try and no matter if we retry. We know that the folder still exists and the specified user has access to it.</p> <p>This is similar in nature to the issue that someone else reported recently in: <a href="http://stackoverflow.com/questions/12448323/document-not-found">Document not found</a></p> <p>Is this likely to be a google bug? Any suggestions of how to resolve it other than moving to Google Drive API?</p> <p>Regards, LT</p> |
6,315,543 | 0 | Build cpp application <p>I have a list of files (cpp, h, and also child-folders inside with cpp/h too).</p> <p>I'm not sure how to build it correctly because it doesn't have any makefile or smth like that (pure c++-files). So I decided to "catch" the right <code>gcc</code> arguments to build it.</p> <pre><code>g++ *.cpp `wx-config --libs` `wx-config --cxxflags` -lGL -lglut -lfkr-skeletal2d </code></pre> <p>Now I have that line. Here is the list of files:</p> <pre><code>$ ls -p AnimationEditor/ Core-Code/ GLRender.cpp GLSprite.cpp Icons/ LGPLv3.txt MainWindow.h PlayBar.h PopUp.h TimeLine.h BoneEditor/ daten/ GLRender.h GLSprite.h LGPLv3_de.txt MainWindow.cpp PlayBar.cpp PopUp.cpp TimeLine.cpp wxWidgets_Addons/ </code></pre> <p>There is files in directory <code>Core-Code</code>:</p> <pre><code>AnimationManager.cpp AnimationManager.h SkeletalManager.cpp SkeletalManager.h TextureManager.cpp TextureManager.h </code></pre> <p>When I use that gcc-line I get a lot of linker errors:</p> <pre><code>undefined reference to `CSkeletalManager::*** undefined reference to `CAnimationManager::*** </code></pre> <p>Maybe, I have to specify somehow the files from <code>Core-Code</code>. I can't understand the problem.</p> |
12,066,738 | 0 | SpreadsheetEntry.getKey() returns a key preceded by 'spreadsheet%3A' <p>I use Google Spreadsheet API to copy a document from one account to another and then I want to return the key for the newly created spreadsheet.</p> <p>The copying is done by retrieving the template spreadsheet, creating a new one with <code>SpreadsheetEntry newDoc = new SpreadsheetEntry();</code> then setting the <code>id</code> of the new one to the template spreadsheet <code>newDoc.setId(template.getId());</code>. Then I insert the new spreadsheet</p> <p><code>newDoc = service.insert(new URL("https://docs.google.com/feeds/default/private/full"), newDoc);</code></p> <p>I want to return to the caller two things: link to the newly created spreadsheet and its key. I get the first through <code>newDoc.getSpreadsheetLink().getHref();</code> and it returns <code>https://docs.google.com/a/bridgeworks.nl/spreadsheet/ccc?key=0Asl_Vu_YG4J-dDc5NHpwTFVRZFNiVENnRUxOb21XLVE</code></p> <p>Then I call <code>newDoc.getKey();</code> and it returns <code>spreadsheet%3A0Asl_Vu_YG4J-dDc5NHpwTFVRZFNiVENnRUxOb21XLVE</code></p> <p>The key seems to be preceded by <code>spreadsheet%3A</code>. But why? Can I safely remove it and return just the key?</p> <p>If I use</p> <p><code>URL worksheetUrl = urlFactory.getWorksheetFeedUrl("0Asl_Vu_YG4J-dDc5NHpwTFVRZFNiVENnRUxOb21XLVE", "private", "full");</code></p> <p>it succeeds but</p> <p><code>URL worksheetUrl = urlFactory.getWorksheetFeedUrl("spreadsheet%3A0Asl_Vu_YG4J-dDc5NHpwTFVRZFNiVENnRUxOb21XLVE", "private", "full");</code></p> <p>fails</p> |
3,288,407 | 0 | <p>I've had some situations where a client had a very stubborn proxy server on their network that refused to give you a newer version of the file. We ended up having to rename the css and js files for every release :(</p> |
29,284,415 | 0 | <p>You should handle this in the global.asax (HttpApplication class file) - specifically like so:</p> <p>c#</p> <pre><code>void Application_OnAuthenticateRequest(Object Source, EventArgs Details) { // Authentication code goes here. //if fail, Response.Redirect('NotAuthenticated.htm'); //or like so. } </code></pre> <p>VB</p> <pre><code> Sub Application_OnAuthenticateRequest(Source As Object, Details as EventArgs) 'Authentication code goes here. End Sub </code></pre> |
2,889,797 | 0 | Trouble getting started with Spring Roo and GWT <p>I am trying to get started with SpringRoo and GWT after seeing the keynote... unfortunately I am stuck at this issue. I successfully created the project using Roo and added the persistence, the entities and when I perform the command "perform package" I get this error:</p> <pre> 23/5/10 12:10:13 AM AST: [ERROR] ApplicationEntityTypesProcessor cannot be resolved 23/5/10 12:10:13 AM AST: [ERROR] ApplicationEntityTypesProcessor cannot be resolved to a type 23/5/10 12:10:13 AM AST: [WARN] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch] 23/5/10 12:10:13 AM AST: [WARN] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch] 23/5/10 12:10:13 AM AST: Build errors for helloroo; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (default) on project helloroo: Compiler errors : error at import tp.gwt.request.ApplicationEntityTypesProcessor; </pre> <p>I see this in the Maven console and can't complete the build... I know there is some jar missing but how and why? Because I downloaded all the latest version including GWT milestone release. Any idea why this error is occurring? How do I resolve this issue?</p> |
19,647,288 | 0 | <p>Assuming that <code>tbl_b.col_ba</code> is a primary key (or just unique field) simple <code>JOIN</code> should help. Try this SQL:</p> <pre><code>SELECT col_aa, col_ab FROM tbl_a JOIN ( SELECT col_ba FROM tbl_b WHERE col_bb IN ( SELECT col_ca FROM tbl_c WHERE col_cb = 1 ) ) T2 ON (col_ac = T2.col_ba AND col_ad = T2.col_ba) </code></pre> <p>Hope it will help</p> |
33,960,649 | 0 | <p>Looks like you need conversion from JSON to hash. (See <a href="http://apidock.com/rails/Hash/to_json" rel="nofollow">DOCS</a>). But, when you do <code>to_s</code> the output is not in pure JSON format. So, you may see I'm using <code>gsub</code> to replace <code>=></code> with <code>:</code></p> <pre><code>require 'json' hash = {"description" => "test"} => {"description"=>"test"} str = hash.to_s.gsub("=>", ":") => "{\"description\":\"test\"}" JSON.parse(str) => {"description"=>"test"} </code></pre> |
32,076,909 | 0 | Random lines in map (bug?) with ggmap - how to get rid of them? <p>I use ggmap (2.4) in R (RStudio 0.98) and I have a map of Myanmar with political borders in which I am plotting some linguistic information. Unfortunately the borders are displayed along with a few random lines in the same color that should not be there. One is straight in the north part, two others are further down in the south and extend into the ocean. I marked them with 2 red arrows.</p> <p>Here's my source code:</p> <pre><code>library(ggmap) burma <- get_map(location=c(lon=96, lat=20), maptype='satellite', color='color', zoom=5) burma.map <- ggmap(burma, darken=c(.33, 'white')) + coord_map(xlim=c(92,102), ylim=c(29,10)) + borders(database="world", colour="yellow") burma.map </code></pre> <p>The outcome is this: <a href="http://imgur.com/MgHG76g" rel="nofollow" title="Sorry, I don't have enough credits to post the picture directly.">Myanmar map with borderline syndrom</a></p> <p>Looks like a bug in the vectors for the country borders.</p> |
11,083,650 | 0 | <p>Convert the file into <a href="http://json.org/example.html" rel="nofollow">JSON data</a> for easy access -- the data shouldn't change very often, so this shouldn't be a problem. You can then load this via <a href="http://api.jquery.com/jQuery.getJSON/" rel="nofollow">AJAX</a>:</p> <pre><code>$.getJSON('ajax/cities.json', function(data) { var $opt = $("<option>") .attr("value",data.city) .text(data.state); $('#state').append($opt); }); </code></pre> <p>...or something like that.</p> |
18,668,977 | 0 | Ruby Geocoder [Rails] - How to Traverse this Result <p>I just installed <a href="http://www.rubygeocoder.com" rel="nofollow" title="Ruby Geocoder">Ruby Geocoder</a> and I am trying to traverse the <code>Geocoder::Result</code>, but keep coming up short. I am in rails console, and have used the following:</p> <p><code>s = Geocoder.search("90210")</code></p> <p>Which returns the following:</p> <p><code>[#<Geocoder::Result::Google:0x007ff295579ad8 @data={"address_components"=>[{"long_name"=>"90210", "short_name"=>"90210", "types"=>["postal_code"]}, {"long_name"=>"Beverly Hills", "short_name"=>"Beverly Hills", "types"=>["locality", "political"]}, {"long_name"=>"Los Angeles", "short_name"=>"Los Angeles", "types"=>["administrative_area_level_2", "political"]}, {"long_name"=>"California", "short_name"=>"CA", "types"=>["administrative_area_level_1", "political"]}, {"long_name"=>"United States", "short_name"=>"US", "types"=>["country", "political"]}], "formatted_address"=>"Beverly Hills, CA 90210, USA", "geometry"=>{"bounds"=>{"northeast"=>{"lat"=>34.1354771, "lng"=>-118.3867129}, "southwest"=>{"lat"=>34.065094, "lng"=>-118.4423781}}, "location"=>{"lat"=>34.1030032, "lng"=>-118.4104684}, "location_type"=>"APPROXIMATE", "viewport"=>{"northeast"=>{"lat"=>34.1354771, "lng"=>-118.3867129}, "southwest"=>{"lat"=>34.065094, "lng"=>-118.4423781}}}, "types"=>["postal_code"]}, @cache_hit=nil>]</code></p> <p>How can I access a specific part of the Result? I have tried the following:</p> <p><code>s.result.city</code>, <code>result.city</code>, <code>s.data</code>?? But none of these work. Any ideas would be great.</p> <p>Thanks!</p> |
40,348,553 | 0 | <p>Another option, that might be more flexible for future needs, is to use <code>dplyr</code>. This requires the data to be in a data.frame, but it sounds like that is what you have anyway.</p> <pre><code>df <- data.frame(g, mat) df %>% group_by(g) %>% summarise_all(mean) </code></pre> <p>It groups by the <code>g</code> column, then takes a mean of all of the remaining columns. It returns:</p> <pre><code> g X1 X2 X3 1 a 1.5 7.5 13.5 2 b 3.5 9.5 15.5 3 c 5.5 11.5 17.5 </code></pre> <p>Which I believe is your desired outcome. If combined with <code>tidyr</code>, it may also make it easier to use/access those means by putting them in a long format</p> <pre><code>df %>% gather(Measurement, Value, -g) %>% group_by(g, Measurement) %>% summarise(mean = mean(Value)) </code></pre> <p>returning:</p> <pre><code> g Measurement mean 1 a X1 1.5 2 a X2 7.5 3 a X3 13.5 4 b X1 3.5 5 b X2 9.5 6 b X3 15.5 7 c X1 5.5 8 c X2 11.5 9 c X3 17.5 </code></pre> |
17,886,213 | 0 | Capturing Enter key on Android's onKeyDown <p>I'm making a remote app that requires a keyboard. I'm not using an EditText, I am forcing it to invoke pragmatically.</p> <p>In the activity, I have a semi intelligent <code>onKeyDown</code> code that translates the android keycode into the ascii code processable by my server and sends it:</p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { int asciiKey = -1; if (keyCode >= KeyEvent.KEYCODE_A && keyCode <= KeyEvent.KEYCODE_Z) { asciiKey = keyCode - KeyEvent.KEYCODE_A + 'A'; } else if (keyCode==KeyEvent.KEYCODE_DEL) { asciiKey = 8; } else if (keyCode==KeyEvent.KEYCODE_ENTER) { asciiKey = 13; } else { asciiKey = event.getUnicodeChar(event.getMetaState()); } out.println("k "+asciiKey); return super.onKeyDown(keyCode, event); } </code></pre> <p>But when I press the <kbd>Enter</kbd> key, it's not sending (I've tried the Jelly Bean Default and Hacker's Keyboard). Not even a "-1". The method isn't even being called. It works for most other keys (Numbers, Letters, Backspace, Some Symbols) so it's not the app itself.</p> <p>The code that invokes the keyboard and hides it later:</p> <pre><code>InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); </code></pre> <p>Is there something I'm missing? Also, is there a better way to translate Android keycodes into Ascii keys (specifically replicatable by <code>java.awt.Robot</code>).</p> <p>Thanks for any help in advance.</p> |
18,952,554 | 0 | <p>Download SMTP server, run the server before you click submit.</p> |
3,466,348 | 0 | <p>If you want to catch memory allocation errors (which you probably should) then you'll have to make the call to new in the body of the constructor.</p> |
39,862,896 | 0 | <p>It seems you want the behavior of</p> <pre class="lang-css prettyprint-override"><code>word-break: break-word; </code></pre> <p>It is a non-standard property supported by Chrome which behaves almost like <code>word-wrap: break-word</code>. However, when <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=492202" rel="nofollow">they tried to remove it</a>, they noticed</p> <blockquote> <p>In some cases (tables and <code>display: table;</code> layouts) the <code>word-break: break-word</code> behavior is different from <code>word-wrap: break-word;</code> and the former works as expected.</p> </blockquote> <p>The CSS WG <a href="https://lists.w3.org/Archives/Public/www-style/2016Mar/0352.html" rel="nofollow">resolved</a> to</p> <blockquote> <p>Add <code>word-break: break-word</code> to spec if Edge/Firefox find it critical enough to Web compat to implement it.</p> </blockquote> <p>So it may become standard.</p> <hr> <p>But currently, if you want to prevent table cells from being at least as wide as the longest word, and still avoid breaking inside words when it's not necessary, you can use</p> <pre class="lang-css prettyprint-override"><code>table-layout: fixed; </code></pre> <p>Note this will get rid of some special table behaviors, e.g. all columns will be equally wide even if their contents could fit better in other arrangements.</p> |
10,214,852 | 0 | What is the most correct way to add a UIViewController to a subview and remove it? <p>I'm trying to add a UIViewController subview, and then upon clicking a button close it. My current code does the job, I'm just not sure if it will leak or cause any problems.</p> <p>So first I add the subview</p> <pre><code>-(IBAction)openNewView:(id)sender{ // start animation [UIView beginAnimations:@"CurlUp" context:nil]; [UIView setAnimationDuration:.3]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; // add the view newViewController* newVC = [[newViewController alloc] initWithNibName:@"newViewController" bundle:[NSBundle mainBundle]]; [self.view addSubview:newVC.view]; [UIView commitAnimations]; } </code></pre> <p>Then in newViewController.m I have the function to remove it</p> <pre><code>-(IBAction)closeNewView:(id)sender{ // start animation [UIView beginAnimations:@"curldown" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:.3]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES]; // close dialog [self.view removeFromSuperview]; [UIView commitAnimations]; [self.view release]; } </code></pre> <p>Like I said this works, however when I Analyze the code, it tells me:</p> <p>Potential leak of an object allocated on line X and stored into 'newViewController' for:</p> <pre><code>newViewController* newVC = [[newViewController alloc] initWithNibName:@"newViewController" bundle:[NSBundle mainBundle]]; </code></pre> <p>and</p> <p>Incorrect decrement of the reference count of an object that is not owned at this point by the caller for <code>[self.view release];</code></p> <p>If I <code>autorelease</code> the viewController instead of <code>[self.view release]</code> it crashes upon removing (also if I release the view after adding it) with: -[FirstViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0xd21c7e0</p> <p>If I call <code>[newVC release]</code> in either viewControllers <code>dealloc</code> it fails to build.</p> <p>Hopefully I'm not asking a fairly obvious question, but what is the correct way to add and remove viewControllers?</p> |
7,507,794 | 0 | <p>You could set Firebug to <em>persist</em> the console so you can see errors on reload.</p> <p><img src="https://i.stack.imgur.com/OyFg0.png" alt="Firebug"></p> |
31,909,576 | 0 | <p>You will have to <code>ksort()</code> your params before you pass them here:</p> <pre><code>foreach(array_keys($params) as $key) { $url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key])); } </code></pre> <p>e.g.</p> <pre><code>$params = array( 'AWSAccessKeyId' => "MY_AWS_KEY", 'Action' => "SubmitFeed", 'SellerId' => "MY_SELLER_ID", 'FeedType' => "_POST_PRODUCT_DATA_", 'SignatureMethod' => "HmacSHA256", 'SignatureVersion' => "2", 'Timestamp'=> $timestamp, 'Version'=> "2009-01-01", 'MarketplaceIdList.Id.1' => "MY_MARKETPLACE_ID", 'PurgeAndReplace'=>'false' ); $secret = 'MY_SECRET_KEY'; $url_parts = array(); ksort($params); foreach(array_keys($params) as $key) { $url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key])); } </code></pre> <p>I'm not entirely sure about the string you are signing, you should try it with this (adding /Feeds/2009-01-01 to it):</p> <pre><code>"POST\nmws-eu.amazonservices.com\n/Feeds/2009-01-01\n" . $url_string </code></pre> <p>Also, Amazon expects a <code>SellerId</code> for the <code>_POST_PRODUCT_DATA_</code> operation, not <code>Merchant</code>.</p> <p>I suggest you to use mws-eu-amazonservices.com instead of the co.uk one, you can use this for all the european marketplaces and don't need to change it for each. As a sidenote:</p> <p>Amazon doesn't really report the correct error. The error you are getting can also occur if only SellerId is Merchant like above, or anything different that has nothing to do with what you are trying to do. </p> |
30,035,009 | 0 | <p>I was searching for that same problem and i find this on github</p> <p><a href="https://github.com/DWorkS/AStickyHeader/issues/12" rel="nofollow">https://github.com/DWorkS/AStickyHeader/issues/12</a></p> <p>And this solved my problem.</p> <p>All this says is to rename the package name on the <code>AndroidManifast.xml</code> file. And its done.</p> |
19,636,219 | 0 | <p>There is a fairly easy solution to the System.exit problem. Where you had: </p> <pre><code> System.out.println("the size of Hashmap is: " + jobCountMap.size()); System.exit(job.waitForCompletion(true) ? 0 : 1); </code></pre> <p>Instead place the following: </p> <pre><code>System.out.println("the size of Hashmap is: " + jobCountMap.size()); boolean completionStatus = job.waitForCompletion(true); //your code here if(completionStatus==true){ System.exit(0) }else{ System.exit(1) } </code></pre> <p>This should allow you to run any processing you want within your main function, including starting a second job if you want.</p> |
1,899,843 | 0 | Is there a nosql store that also allows for relationships between stored entities? <p>I am looking for nosql key value stores that also provide for storing/maintaining relationships between stored entities. I know Google App Engine's datastore allows for owned and unowned relationships between entities. Does any of the popular nosql store's provide something similar? </p> <p>Even though most of them are schema less, are there methods to appropriate relationships onto a key value store? </p> |
14,618,937 | 0 | How do I join multiple result sets from a WHILE loop in a mySQL query? <p>This is the problem that I currently have. </p> <p>I have 7 tables of trip data. What I am currently doing is selecting at random, a Card_ID from the third table, then searching through all 7 tables with that Card_ID and selecting all record made by that particular Card_ID.</p> <p>The problem is that many result sets are generated, and this presents problems since I will have to manually export them one by one. Is there anyway to 'automate' this process by combining about like 2000 WHILE loops of records into one result set?</p> <p>Thanks in advance.</p> <pre><code>BEGIN DECLARE counter INT; DECLARE random INT; DECLARE cardid VARCHAR(20); SET counter = 1; WHILE counter < 801 DO SET random = FLOOR(1 + (RAND() * 5451696)); SET cardid = (SELECT CARD_ID FROM trips13042011 WHERE TripID = random); SELECT * FROM trips11042011 WHERE CARD_ID=cardid UNION ALL SELECT * FROM trips12042011 WHERE CARD_ID=cardid UNION ALL SELECT * FROM trips13042011 WHERE CARD_ID=cardid UNION ALL SELECT * FROM trips14042011 WHERE CARD_ID=cardid UNION ALL SELECT * FROM trips15042011 WHERE CARD_ID=cardid UNION ALL SELECT * FROM trips16042011 WHERE CARD_ID=cardid UNION ALL SELECT * FROM trips17042011 WHERE CARD_ID=cardid ORDER BY Ride_Start_Date, Ride_Start_Time ASC; SET counter = counter + 1; end WHILE; END </code></pre> |
36,111,823 | 0 | <pre><code>func ReadFile(filename string) ([]byte, error) </code></pre> <p>My answer was from another import called <a href="https://golang.org/pkg/io/ioutil/#ReadFile" rel="nofollow">"io/ioutil"</a>.</p> <p>This will return the file's contents in bytes and I was able to use the function string(file) to convert the bytes into text.</p> |
2,815,311 | 0 | <p><a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow noreferrer">PEP 8</a> is pretty much "the root" of all common style guides.</p> <p>Google's <a href="http://google-styleguide.googlecode.com/svn/trunk/pyguide.html" rel="nofollow noreferrer">Python style guide</a> has some parts that are quite well thought of, but others are idiosyncratic (the two-space indents instead of the popular four-space ones, and the CamelCase style for functions and methods instead of the camel_case style, are pretty major idiosyncrasies).</p> <p>On to your specific questions:</p> <blockquote> <p>1.- What is the most widely used column width? (the eternal question) I'm currently sticking to 80 columns (and it's a pain!)</p> </blockquote> <p>80 columns is most popular</p> <blockquote> <p>2.- What quotes to use? (I've seen everything and PEP 8 does not mention anything clear) I'm using single quotes for everything but docstrings, which use triple double quotes.</p> </blockquote> <p>I prefer the style you're using, but even Google was not able to reach a consensus about this:-(</p> <blockquote> <p>3.- Where do I put my imports? I'm putting them at file header in this order.</p> <p>import sys import -rest of python modules needed-</p> <p>import whatever import -rest of application modules-</p> <p></p> </blockquote> <p>Yes, excellent choice, and popular too.</p> <blockquote> <p>4.- Can I use "import whatever.function as blah"? I saw some documents that disregard doing this.</p> </blockquote> <p>I strongly recommend you always import modules -- not specific names from inside a module. This is not just style -- there are strong advantages e.g. in testability in doing that. The <code>as</code> clause is fine, to shorten a module's name or avoid clashes.</p> <blockquote> <p>5.- Tabs or spaces for indenting? Currently using 4 spaces tabs.</p> </blockquote> <p>Overwhelmingly most popular.</p> <blockquote> <p>6.- Variable naming style? I'm using lowercase for everything but classes, which I put in camelCase.</p> </blockquote> <p>Almost everybody names classes with uppercase initial and constants with all-uppercase.</p> |
36,197,111 | 0 | invalid foreach() expecting to show no data if null in Codeigniter <p>I was expecting view to show message 'no data found' when my query is returning null value but im getting error message: Invalid argument supplied for foreach() <p>Here's the controller code:</p> <pre><code>public function index() { $ctki = $this->ctki_model->get_all_ctki_data(); if ( !empty($ctki) ) { $this->data['ctkiData'] = $ctki; } else { $this->data['ctkiData'] = 'Tidak ada data CTKI.'; } $this->load->view($this->layout, $this->data); } </code></pre> <p><p>Here's the view code:</p> <pre><code><table class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr> <th>No</th> <th>Nama Lengkap</th> <th>Jenis Kelamin</th> <th>No KTP</th> <th>No Passport</th> <th>Kota</th> <th>No Telepon</th> <th>No HP</th> <th>Aksi</th> </tr> </thead> <tbody> <?php foreach($ctkiData as $row): ?> <?php // Link edit, hapus, cetak $link_edit = anchor('program/administrasi/edit/'.$row->ID_CTKI, '<span class="glyphicon glyphicon-edit"></span>', array('title' => 'Edit')); $link_hapus = anchor('program/administrasi/hapus/'.$row->ID_CTKI,'<span class="glyphicon glyphicon-trash"></span>', array('title' => 'Hapus', 'data-confirm' => 'Anda yakin akan menghapus data ini?')); ?> <tr> <td><?php echo ++$no ?></td> <td><?php echo $row->Username ?></td> <td><?php echo $row->Nama_Lengkap_User ?></td> <td><?php echo $row->No_Telepon ?></td> <td><?php echo $row->No_HP ?></td> <td><?php echo $row->Level ?></td> <td><?php echo format_is_blokir($row->Status_Blokir) ?></td> <td><?php echo $link_edit.'&nbsp;&nbsp;&nbsp;&nbsp;'.$link_hapus ?></td> </tr> <?php endforeach ?> </tbody> </table> </code></pre> |
3,314,207 | 0 | <p>I'd suggest caching the patterns and having a method that uses the cache.</p> <p>Patterns are expensive to compile so at least you will only compile them once and there is code reuse in using the same method for each instance. Shame about the lack of closures though as that would make things a lot cleaner.</p> <pre><code> private static Map<String, Pattern> patterns = new HashMap<String, Pattern>(); static Pattern findPattern(String patStr) { if (! patterns.containsKey(patStr)) patterns.put(patStr, Pattern.compile(patStr)); return patterns.get(patStr); } public interface MatchProcessor { public void process(String field); } public static void processMatches(String text, String pat, MatchProcessor processor) { Matcher m = findPattern(pat).matcher(text); int startInd = 0; while (m.find(startInd)) { processor.process(m.group()); startInd = m.end(); } } </code></pre> |
21,168,987 | 0 | <p>This should work in all browsers:</p> <pre><code>$(document).ready(function () { if (document.addEventListener) { document.addEventListener("mousewheel", MouseWheelHandler, false); //IE9, Chrome, Safari, Oper document.addEventListener("DOMMouseScroll", MouseWheelHandler, false); //Firefox } else { document.attachEvent("onmousewheel", MouseWheelHandler); //IE 6/7/8 } function MouseWheelHandler(){ // cross-browser wheel delta e = window.event || e; var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); //scrolling up? if (delta >= 0) { $('body').scrollTop(0); } } }); </code></pre> |
5,868,669 | 0 | <p>You should just change the "upload_path" value in your configuration Array.</p> <p>Here is some kind of code you could use :</p> <pre><code> $config['upload_path'] = './uploads/'; $this->load->library('upload', $config); </code></pre> <p>Referring to the <strong>User Guide</strong> : <a href="http://codeigniter.com/user_guide/libraries/file_uploading.html" rel="nofollow">http://codeigniter.com/user_guide/libraries/file_uploading.html</a></p> |
35,014,027 | 0 | <p>The iAd network will soon be discontinued and new apps are no longer accepted. You might want to reconsider. <a href="https://developer.apple.com/news/?id=01152016a" rel="nofollow">https://developer.apple.com/news/?id=01152016a</a></p> |
2,364,248 | 0 | <p>This is little more than a matter of opinion. So, here's mine.</p> <ol> <li>Don't sweat the small stuff</li> <li>Check out <a href="http://rads.stackoverflow.com/amzn/click/0321113586" rel="nofollow noreferrer">other</a> people's opinions on the matter (which you're doing)</li> <li>It matters less which convention you choose, and much much more that you apply it consistantly</li> <li><p>Here's some of my convention:</p> <blockquote> <pre><code>class MyGizmo { public: int DoIt(); private: string myString_; }; typedef vector<MyGizmo> MyGizmos; namespace somewhere { MyGizmos gizmos; }; int MyGizmo::DoIt() { int retVal = 0; string strCopy = myString; retVal = strCopy.length(); return retVal; } </code></pre> </blockquote></li> </ol> |
16,952,750 | 0 | if statement inside mysql query to determine table to select <p>I would like to perform a <strong>if statment</strong> in the middle of a query, I need to find out if oc.product_type == 'clothing' or 'other' If it is clothing, then i need to select the <strong>specific_clothing</strong> table instead of the <strong>non_clothing</strong> table? I really lost with this one </p> <pre><code>SELECT o.total, o.shipping, o.order_date ,oc.product_type, oc.product_id, oc.quantity, oc.price_per ,cu.first_name, cu.last_name, CONCAT(cu.address1, cu.address2) AS address, </code></pre> <p><strong>//here is where im trying to use if</strong> </p> <pre><code> if(oc.product_type = 'clothing' SELECT style FROM specific_clothing where oc.product_id = specific_clothing_id) as item FROM order_contents AS oc INNER JOIN `orders` as o ON oc.order_id = o.id INNER JOIN `customers` AS cu ON o.customer_id=cu.id WHERE o.customer_id = '214'; </code></pre> |
9,248,418 | 0 | <p>ID item of item to be edited is passed to edit form in the query string like this: editform.aspx?ID=ItemId. So, first, check if ID is in the url and correct.</p> |
11,744,173 | 0 | <p>The problem to be solved is that you have an input and a series of functions, and you want to apply the functions to the input in order.</p> <p>If the functions are purely state-changing functions, <code>s -> s</code> on an input of type <code>s</code>, then you don't <em>need</em> <code>State</code> to use them. Haskell is very good at chaining together functions like these, e.g. with the standard composition operator <code>.</code>, or something like <code>foldr (.) id</code>, or <code>foldr id</code>.</p> <p>However, if the functions both mutate a state <em>and</em> report some result of doing so, so that you could give them the type <code>s -> (s,a)</code>, then gluing them all together is a bit of a nuisance. You have to unpack the result tuple and pass the new state value to the next function, use the reported value somewhere else, and then unpack <em>that</em> result, and so on. It's easy to pass the wrong state to an input function because you have to name each result and input explicitly to do the unpacking. You end up with something like this:</p> <pre><code>let (res1, s1) = fun1 s0 (res2, s2) = fun2 s1 (res3, s3) = fun3 res1 res2 s1 ... in resN </code></pre> <p>There, I accidentally passed <code>s1</code> instead of <code>s2</code>, maybe because I added the second line in later and didn't realise the third line needed changing. When composing the <code>s -> s</code> functions, this problem can't possibly arise because there are no names to get right:</p> <pre><code>let resN = fun1 . fun2 . fun3 . -- etc. </code></pre> <p>So we invented <code>State</code> to do the same trick. <code>State</code> is essentially just a way of gluing functions like <code>s -> (s,a)</code> together in such a way that the right state always gets passed to the right function.</p> <p>So it's not so much that people went "we want to use <code>State</code>, let's use <code>s -> (s,a)</code>" but rather "we're writing functions like <code>s -> (s,a)</code>, let's invent <code>State</code> to make that easy". With functions <code>s -> s</code>, it's already easy and we don't have to invent anything.</p> <p>As an example of how <code>s -> (s,a)</code> arises naturally, consider parsing: a parser will be given some input, consume some of the input and return a value. In Haskell, this is naturally modelled as taking an input list, and returning a pair of the value and the remaining input - i.e. <code>[Input] -> ([Input], a)</code>, or <code>State [Input]</code>.</p> |
34,394,168 | 0 | <p>You need to change this line</p> <pre><code>$("myTable tr td") </code></pre> <p>to</p> <pre><code>$("#myTable tbody tr td") //missing pound sign & your tds are inside tbody </code></pre> |
22,819,161 | 0 | <p>Try <code>-notmatch "\[.*\]"</code> instead of <code>-ne</code></p> |
13,729,327 | 0 | <p>1) use a timer with 15 seconds interval;</p> <p>2) save the current mouse location on screen: <a href="http://stackoverflow.com/questions/1316681/getting-mouse-position-in-c-sharp">Getting mouse position in c#</a></p> <p>3) when timer reached 15 seconds, check mouse location again. if it is changed, update current mouse location. if it is unchanged, draw something on screen at the mouse location (and you need clean it too): <a href="http://stackoverflow.com/questions/7897307/how-do-i-draw-graphics-in-c-sharp-without-a-form">How do I draw graphics in C# without a form</a></p> <p>It is not the best choice, but if the mouse is moved during the 15 seconds, it is unlikely it will back to its original location in 15 seconds.</p> |
10,496,661 | 0 | <p>I fixed the problem by changing the frameDuration of the videoComposition.</p> |
17,160,775 | 0 | I want to hide the iOS nav bar on particular view <p>Now I'm pretty sure there is a way to do this as i saw this post earlier <a href="http://stackoverflow.com/questions/7699455/uinavigationabar-not-hiding">UINavigationabar not hiding</a> but I just want confirmation so i can prove to my developer there is a way to hide the footer nav buttons on a particular view.</p> <p>I want to hide the buttons on the home view and use big custom buttons instead - he tells me it isn't possible. Seeking a second opinion here.</p> <p>THanks!</p> |
35,106,414 | 0 | <p>I propose this solution, which doesn't deviate much from yours:</p> <pre><code>import pandas as pd from datetime import datetime data = pd.read_csv('Meteorite_Landings.csv') for i, val in enumerate(data["year"]): try: b = datetime.strptime(val, '%m/%d/%Y %H:%M:%S %p').year print b except TypeError: pass </code></pre> <p>This prints the years. The reason for the try-except thing is that <a href="https://data.nasa.gov/Space-Science/Meteorite-Landings/gh4g-9sfh" rel="nofollow">the dataset you're probably using</a> is not complete and contains some NANs (?).</p> |
37,066,361 | 0 | <p>public <strong><em>List< RestaurantDetails></em></strong> restaurant; return Array</p> <p>public <strong><em>RestaurantDetails</em></strong> restaurant; return Object</p> <p>Your API return Object. Not return Array</p> <p>Try this!!</p> <pre><code>public class RestaurantsZomato { public NearbyRestaurants nearby_restaurants; public static class NearbyRestaurants { public RestaurantDetails restaurant; }} </code></pre> <p><strong><em>Update</em></strong></p> <p>Your Json String return JsonObject. You must use JsonObject </p> <pre><code>Ion.with(context) .load("https://developers.zomato.com/api/v2.1/geocode?lat=25.12819&lon=55.22724") .asJsonObject() .setCallback(new FutureCallback<JsonObject>() { @Override public void onCompleted(Exception e, JsonObject result) { // do stuff with the result or error } }); </code></pre> |
2,687,532 | 0 | <p>This <strong>is</strong> possible.</p> <pre><code>class Object class << self Kernel.send :define_method, :foo do #Object.send to be more restrictive @foo = 'bar' end end end </code></pre> <p>.</p> <pre><code>irb(main):023:0> class Object irb(main):024:1> class << self irb(main):025:2> Kernel.send :define_method, :foo do irb(main):026:3* @foo = 'bar' irb(main):027:3> end irb(main):028:2> end irb(main):029:1> end => #<Proc:0x00007f5ac89db168@(irb):25> irb(main):030:0> x = Object.new => #<Object:0x7f5ac89d6348> irb(main):031:0> x.foo => "bar" irb(main):032:0> [].foo => "bar" irb(main):033:0> //.foo => "bar" </code></pre> <p>It's important to understand eigenclasses. Every class is implemented mysteriously by the Ruby interpreter as a hidden class type:</p> <pre><code>irb(main):001:0> class Object irb(main):002:1> def eigenclass irb(main):003:2> class << self; self; end irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> x = Object.new => #<Object:0x7fb6f285cd10> irb(main):007:0> x.eigenclass => #<Class:#<Object:0x7fb6f285cd10>> irb(main):008:0> Object.eigenclass => #<Class:Object> irb(main):009:0> Object.class => Class </code></pre> <p>So, in your example, when you're trying to call foo on your objects, it's operating on the class <code>#<Object:0x7fb6f285cd10></code>. However, what you want it to operate on is the secret class <code>#<Class:#<Object:0x7fb6f285cd10>></code></p> <p>I hope this helps!</p> |
25,817,682 | 0 | <p>If I understood correctly you are trying to access a parent controller from a child controller. Here are some proposals ordered from noob to expert ;)</p> <ol> <li><p>The simplest approach would be to just use a global variable to provide reference to the controller you need - not recommended.</p></li> <li><p>Give your parent view an id and call a method on it's controller like this:</p> <p>sap.ui.getCore().byId("parentViewId").getController().method();</p></li> <li><p>You can directly call a controllers method like this:</p> <p>sap.ui.controller("namespace.Controllername").method();</p></li> <li><p>I would highly recommend a more decoupled way of communication between controllers (or application components in general) using the <a href="https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.core.EventBus.html" rel="nofollow">sap.ui.core.EventBus</a>. It implements a pattern known as Event or Message Bus and imho really rocks ;)</p></li> </ol> <p>GL Chris</p> |
35,395,268 | 0 | <p>You need to specify the encoding in the HTML file of the Polymer element.</p> <pre><code><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </code></pre> <p>See also <a href="http://stackoverflow.com/questions/22790895/i-have-greek-text-on-a-string-in-dart-using-polymer-why-is-it-displayed-wrongly">I have greek text on a String in Dart using Polymer, why is it displayed wrongly on the browser?</a></p> |
24,151,423 | 0 | <p>Probably the most secure so far is <a href="http://www.scala-js-fiddle.com/">http://www.scala-js-fiddle.com/</a> (<a href="https://github.com/lihaoyi/scala-js-fiddle">code on GitHub</a>) simply because it does not even run the code on the server, but on the client!</p> <p>The gotcha is: it's not truly Scala code, it is <a href="http://www.scala-js.org/">Scala.js</a>, which is a dialect of Scala, is still experimental, etc. But it <em>might</em> be enough for your use case.</p> |
38,957,244 | 0 | <p>Move the <code>app:layout_scrollFlags="scroll|enterAlways"</code> from the toolbar to the Framelayout. Sorry for being late.</p> |
32,571,066 | 0 | <p>You are forgetting the <code>if(i%2==0)</code> which is crucial. This line basically skips every second character. Then, the line you have identified can be split in 2 parts:</p> <pre><code>string[j]=string[i]; // Overwrite the character at position j j++; // Now increase j </code></pre> <p>The variable <code>i</code> keeps track of the position of the string you have reached while reading it; <code>j</code> is used for writing. In the end, you write 0 at position <code>j</code> to terminate the string.</p> |
28,810,808 | 0 | Drupal URL Redirection <p>The homepage of our website - <a href="http://urn1350.net/" rel="nofollow">http://urn1350.net/</a>, we would like to change to <a href="http://urn1350.net/elections" rel="nofollow">http://urn1350.net/elections</a> to be the homepage. What options do I have for URL redirection in the backend on a drupal and apache server</p> |
37,136,495 | 0 | Daemon that monitors a 'queue' and runs commands, asynchronously <p>I know this has been asked before, but I can't figure out a particular piece of the puzzle and would really like any help on this!</p> <p><strong>Program Flow :</strong> </p> <p><em>INITIAL REQUEST :</em> Browser -> Apache -> to PHP -> PHP sends taskinfo about a time consuming command, to 'something', and returns instantly.</p> <p>There could be multiple requests being sent at the same time to the server, by multiple browsers.</p> <p><em>SERVER:</em> The 'something' runs a specific command with the taskinfo as params PARALLELY in the BACKGROUND > saves output to DB</p> <p><em>AJAX:</em> -> Apache -> PHP -> Checks DB -> Returns info to user.</p> <p>I have explored solutions such as rabbitmq / gearman etc, but am unable to figure them out. </p> <p>The <strong>precise problem</strong> is that I can't figure out the part where the 'something' (a daemon), automatically runs the specified command, whenever a task in added to a 'queue/list'. The way I see it, a command needs to run seperate from the daemon, and I don't understand where or how this command should run.</p> <p>So in short: A non-blocking daemon that monitors a queue and runs a specific command! </p> <p>But How ?</p> <p>Been stuck at this for a few days now. I know there are simpler alternatives like curl and exec(), but they are not suitable for my use case.</p> <p>Thanks</p> |
18,659,648 | 0 | boost::stable_vector insertion is orders of magnitude slower than std::vector. why? <p>I'm noticing a large performance difference between std::vector and boost::stable_vector. Below is example where I construct and insert 100,000 ints into both a vector and a stable vector.</p> <p>test.cpp:</p> <pre><code>#include <iostream> #include <vector> #include <boost/container/stable_vector.hpp> #include <boost/timer/timer.hpp> int main(int argc, char** argv) { int size = 1e5; boost::timer::cpu_timer timer; timer.start(); std::vector<int> vec(size); timer.stop(); std::cout << timer.format(); timer.start(); boost::container::stable_vector<int> svec(size); timer.stop(); std::cout << timer.format(); } </code></pre> <p>compile:</p> <pre><code>g++ -O3 test.cpp -o test -lboost_system-mt -lboost_timer-mt </code></pre> <p>output:</p> <pre><code> 0.000209s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) 5.697013s wall, 5.690000s user + 0.000000s system = 5.690000s CPU (99.9%) </code></pre> <p>What is the reason for this huge discrepancy? My understanding is that both types should have similar insertion performance.</p> <p>UPDATE: boost version: 1.54</p> <pre><code>dev/stable_vector_test: g++ --version i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. </code></pre> <p>I added std::list to the code and tried passing -DNDEBUG in addition to -O3.</p> <pre><code>dev/stable_vector_test: make g++ -g test.cpp -o test -lboost_system-mt -lboost_timer-mt dev/stable_vector_test: ./test size: 10000 vector: 0.000047s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) list: 0.001168s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) stable_vector: 0.963679s wall, 0.960000s user + 0.000000s system = 0.960000s CPU (99.6%) dev/stable_vector_test: make opt g++ -O3 -DNDEBUG test.cpp -o test -lboost_system-mt -lboost_timer-mt dev/stable_vector_test: ./test size: 10000 vector: 0.000038s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) list: 0.000659s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) stable_vector: 0.000752s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%) </code></pre> <p>So with -O3 and -DNDEBUG I get comparable performance to std::list</p> |
10,157,129 | 0 | Java - Structuring the flow of data in GUI from input to output <p>I'm putting together a GUI with a couple of panels. In one panel there are components for the user to input various parameters. In another panel, there are buttons and a place to output a plot based on data generated using the user inputs.</p> <p>I have all of the various pieces working independently now I'd just like them to talk to each other!! </p> <p>When i hit one button, I would like to take all of user inputs and combine them to generate a data set and plot it. Another button then to write this same data to a file.</p> <p>I have code to implement all the components individually, code to write data to a file and code to generate a plot from data. All of which works fine.</p> <p>I thought that I could use the Action/ChangeEvents to take the parameters and assign them to an ArrayList. Then use this arraylist to generate the data.<br> I'm finding it difficult to plan an approach to tackling this. </p> <p>Currently I'm using get set methods in the event handlers to set parameter levels for a particular instance of the array list, I would like to pass this instance into another class to generate the data but don't know how to make it accessible.</p> <p>I hope I have provided enought information here. If anyone has any thoughts on this they would be much appreciated.</p> |
19,079,643 | 0 | <p>The <a href="http://www.fabricationgem.org/#!defining-fabricators" rel="nofollow">Fabrication gem documentation</a> for defining fabricators seems to indicate that this will work for both directions in a <code>belongs_to</code>/<code>has_many</code> relationship, and you can pass <code>count: n</code> to get n objects:</p> <pre><code>Fabricator(:person) do open_source_projects(count: 5) children(count: 3) { |attrs, i| Fabricate(:person, name: "Kid #{i}") } end </code></pre> <p>The documentation is pretty good; I would recommend checking it out and then experimenting :)</p> |
15,551,903 | 0 | <p>B could create and send a <a href="http://git-scm.com/2010/03/10/bundles.html" rel="nofollow">bundle</a> rather than a patch. This allows sending commits when none of the transports available for push or fetch will work.</p> |
33,898,232 | 0 | <p>You are trying to use a Python console to update your conda distribution when you have to update it from your local console.</p> <p>I guess you're using Windows, just open the command prompt (cmd.exe), and from there update the conda distribution with the commands you already know:</p> <pre><code>conda update conda conda update anaconda conda install <package> </code></pre> <p><strong>Update:</strong></p> <p>Conda commands have to be used directly in the command prompt:</p> <p><a href="https://i.stack.imgur.com/wYH4a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wYH4a.png" alt="enter image description here"></a></p> |
40,182,610 | 0 | <p>You should call the <a href="https://developer.apple.com/reference/foundation/timer/1415405-invalidate" rel="nofollow">invalidate()</a> method:</p> <blockquote> <p>This method is the only way to remove a timer from an RunLoop object. The RunLoop object removes its strong reference to the timer, either just before the invalidate() method returns or at some later point.</p> <p>If it was configured with target and user info objects, the receiver removes its strong references to those objects as well.</p> </blockquote> <p>Somewhere in your code, you should implement:</p> <pre><code>timer.invalidate() </code></pre> <p>Hope this helped.</p> |
7,738,588 | 0 | BufferedImage turns all black after scaling via canvas <p>I have a method which purpose is to receive an image and return it scaled down. The reason I'm using canvas is that I believe that it will scale the image automatically for me.</p> <p>After the conversion the outputimage is completely black. Anyone have any clue on how to fix this?</p> <pre><code>try { InputStream in = new ByteArrayInputStream(f.getBytes()); BufferedImage image = ImageIO.read(in); File beforescale = new File("beforescale.jpg"); ImageIO.write(image, "jpg", beforescale); //works Canvas canvas = new Canvas(); canvas.setSize(100, 100); canvas.paint(image.getGraphics()); image = canvasToImage(canvas); File outputfile = new File("testing.jpg"); ImageIO.write(image, "jpg", outputfile); //all black response.getWriter().print(canvas); } catch (Exception ex) { ex.printStackTrace(); } } private BufferedImage canvasToImage(Canvas cnvs) { int w = cnvs.getWidth(); int h = cnvs.getHeight(); int type = BufferedImage.TYPE_INT_RGB; BufferedImage image = new BufferedImage(w,h,type); Graphics2D g2 = image.createGraphics(); cnvs.paint(g2); g2.dispose(); return image; } </code></pre> |
36,682,139 | 0 | <p>One way of doing this is to perform a rolling upgrade. This will ensure that your deployed application incurs no downtime (new pods are started before old pods are stopped). One caveat is that you must be using a replication controller or replication set to do so. Most rolling deployments will simply involve just updating the container's image for the new version of software.</p> <p>You can do this through Java via <a href="http://fabric8.io" rel="nofollow">fabric8</a>'s <a href="https://github.com/fabric8io/kubernetes-client" rel="nofollow">Kubernetes Java client</a>. <a href="https://github.com/fabric8io/kubernetes-client/blob/a47d2e288599559069481895c8b6fc7cf3fbab3d/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/FullExample.java#L147" rel="nofollow">Here</a>'s an example:</p> <pre><code>client.replicationControllers() .inNamespace("thisisatest") .withName("nginx-controller") .rolling().updateImage("nginx"); </code></pre> <p>You can change any configuration of the replication controller (replicas, environment variables, etc). The call will return when your pods running the new version are <code>Ready</code> & the old replication & pods have been stopped & deleted.</p> |
10,770,681 | 0 | <p>A couple of useful things:</p> <ol> <li><p>If you're running your app out of Xcode, add an exception breakpoint. In the breakpoint navigator (command-6) hit the '+' at the very bottom left to add. This will pause execution on the line that throws the exception and allow you to inspect the current scope, stack, etc.</p></li> <li><p>If you're using gdb, use <code>bt</code> to print the backtrace</p></li> <li><p>If you're using lldb, use <code>thread backtrace</code> instead</p></li> </ol> |
17,817,348 | 0 | Total pages in PDF using html2pdf <p>I have some HTML using which I am printing a PDF, I would like to get the count of total pages the PDF will produce in a PHP Variable.</p> <pre><code>$html2pdf = new HTML2PDF('P', 'A4'); $html2pdf->writeHTML($html, false); $html2pdf->Output('myfile.pdf'); </code></pre> <p>I would like to do something like..</p> <pre><code>$totalpages = $html2pdf->getTotalPageCount(); //should return total pages the myfile.pdf would produce. </code></pre> |
32,573,685 | 0 | D3 Labels text amount slightly off <p>I'm having a problem with my D3 bar chart not displaying the correct amount for the label text. It seems like it's slightly off, and I'm not sure why.</p> <p>I'm trying to get the text labels to display whatever the newNumber is within the dataset.</p> <p>Here's the code I'm using:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> var w = 800; var h = 600; var padding = 5; var maxNumber = 100; //Generate random numbers var dataset = []; for (var i = 0; i < 21; i++) { var newNumber = Math.random() * maxNumber; dataset.push(newNumber); } var xScale = d3.scale.ordinal() .domain(d3.range(dataset.length)) .rangeRoundBands([padding, w - padding], 0.05); var yScale = d3.scale.linear() .domain([d3.max(dataset), 0]) .range([padding, h - padding]); var xAxis = d3.svg.axis() .scale(xScale) .orient("bottom"); var yAxis = d3.svg.axis() .scale(yScale) .orient("left"); var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); svg.selectAll("rect") .data(dataset) .enter() .append("rect") .attr("x", function(d, i) { return xScale(i) + padding; }) .attr("y", function(d) { return h - yScale(d) - padding - 15; }) .attr("width", xScale.rangeBand()) .attr("fill", "rgba(95, 159, 229, 0.3"); svg.selectAll("rect") .data(dataset) .transition().delay(function(d, i) { return i / dataset.length * 800; }) .duration(1500) .ease("linear") .attr("y", function(d) { return h - yScale(d) - padding - 15; }) .attr("height", function(d) { return yScale(d); }); svg.selectAll("text") .data(dataset) .enter() .append("text") .text(function(d) { return Math.floor(d3.max(dataset) - d); }) .attr("text-anchor", "middle") .attr("x", function(d, i) { return xScale(i) + padding + 15; }) .attr("y", function(d) { return h - yScale(d) - padding - 20; }) .attr("font-family", "sans-serif") .attr("font-size", "11px") svg.append("g") .attr("class", "xAxis") .attr("transform", "translate(0," + (h - padding - 15) + ")") .call(xAxis); svg.append("g") .attr("class", "yAxis") .attr("transform", "translate(" + (padding + 15) + ",0)") .call(yAxis);</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>D3: BDAS Bar Chart Test</title> <style> svg { padding-left: 15px; padding-top: 30px; } rect { transition: 0.1s; } rect:hover { fill: rgba(95, 159, 229, 1); } .xAxis path, .yAxis path { fill: #aaa; height: 0.5px; } .xAxis .tick text, .yAxis .tick text { font-family: sans-serif; fill: #aaa; font-size: 15px; } </style> </head> <body> </body> </html></code></pre> </div> </div> </p> |
21,634,630 | 0 | Dynamic LINQ aggregates on IQueryable as a single query <p>I'm building a datagrid library that works on generic IQueryable data sources. At the bottom selected columns will have aggregates: sum, average, count etc.</p> <p>I can compute the sum/average/count individually using the code from this article <a href="http://stackoverflow.com/questions/17490080/how-to-do-a-sum-using-dynamic-linq">How to do a Sum using Dynamic LINQ</a> </p> <p>I don't want to run them individually for a datasource, as this would cause multiple queries on the database, I would rather create a single expression tree an execute this as a single query.</p> <p>In static LINQ you'd do all the .Sum, .Average and .Count methods and return a new anonymous type with the values. I don't need an anonymous type (unless this is the only way): a list or array of the aggregates would be fine.</p> <p>I assume from the other article I would need to string together a series of MethodCallExpression objects somehow. Can anyone help?</p> |
6,179,839 | 0 | <p>Have a solution for you. First check if browser is IE, next use encodeURI to encode all the file path and name, you have to do that first in order to correctly capture the unescaped chars like "\". Then just replace, its working for me:</p> <pre><code>var browserName=navigator.appName; if (browserName=="Microsoft Internet Explorer") { var soloNombre = encodeURI(soloNombre); soloNombre = soloNombre.replace("C:%5Cfakepath%5C",""); var soloNombre = decodeURI(soloNombre); alert(soloNombre); } </code></pre> <p>Works like a charm.</p> |
7,012,542 | 0 | <p>So for now solution seems to be to list <code>/dev/shm</code> e.g.</p> <pre><code>$ ls -al /dev/shm/sem.*|more -rw------- 1 auniyal auniyal 16 2011-08-09 15:59 /dev/shm/sem.mysem -rw------- 1 auniyal auniyal 16 2011-08-09 16:29 /dev/shm/sem.mysem1 -rw------- 1 auniyal auniyal 16 2011-08-09 16:37 /dev/shm/sem.mysem2 -rw------- 1 auniyal auniyal 16 2011-08-09 16:37 /dev/shm/sem.mysem3 -rw------- 1 auniyal auniyal 16 2011-08-09 16:39 /dev/shm/sem.mysem4 ... </code></pre> |
41,081,983 | 0 | <p><a href="https://i.stack.imgur.com/GMJnn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GMJnn.png" alt="Pull down to refresh works if I pull from the region starting from red line"></a></p> <p>Figured this out when I tested the app on my phone instead of emulator. The List View is always present even though the datasource is empty. In my case, the listview began where the Text view finished at the red line.</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.