pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
39,252,713
0
<p>I think the error is <code>OnUpdate()</code> in <code>WithinSight</code> class. When you do the return it never does this <code>gameObject.tag = "Untagged";</code></p> <p>Change the order of the lines like this.</p> <pre><code>public override TaskStatus OnUpdate() { for (int i = 0; i &lt; possibleTargets.Length; ++i) { if (withinSight(possibleTargets [i], fieldOfViewAngle)) { target.Value = possibleTargets [i]; gameObject.tag = "Untagged"; return TaskStatus.Success; } } return TaskStatus.Failure; } </code></pre> <p>I can't reproduce this scenario, but this code won´t go back to a previuos cube. In case you want that you should save a reference of the last cube the sphere moved towards and do the comparisons in <code>OnUpdate()</code> of <code>WithinSight</code>.</p>
2,129,546
0
best practices in naming session variables <p>I was used to naming my session variables the "normal" way, kinda like when I want to keep track of user details, I name them:</p> <ul> <li><code>$_SESSION['username']</code></li> <li><code>$_SESSION['email']</code> </li> <li><code>$_SESSION['id']</code></li> </ul> <p>I am worried that they may be in conflict with other session data when I am browsing sites in the same browser, or will there not be any conflict at all(once I tried to simultaneously run two of my projects with the same session variables, residing in the same server, and obviously, things got real messy).</p>
37,819,064
0
<p><a href="https://jsfiddle.net/tmf773ab/" rel="nofollow">Is this the one you expecting?</a> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> Scroll me... </p> </p> <pre><code>body { margin: 0; } nav { background: rgba(53, 145, 204, 0); position: fixed; top: 0; width: 100%; } nav ul &gt; li { display: inline-block; } .container { height: 1000px; margin-top: 100px; } $(document).scroll(function() { var dHeight = $(this).height()-$(window).height(); if (dHeight &gt;= $(this).scrollTop()) { $('nav').css('background', 'rgba(53,145,204,' + $(this).scrollTop() + ')'); } }); </code></pre>
36,409,821
0
<p>Since it is not clear what your requirements are, I will assume that what you really want to use is a <a href="https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx" rel="nofollow">BackgroundWorker</a>. The following also have samples.</p> <p><a href="https://msdn.microsoft.com/en-us/library/a3zbdb1t(v=vs.110).aspx" rel="nofollow">BackgroundWorker.ReportProgress Method (Int32, Object) (System.ComponentModel)</a></p> <p><a href="https://msdn.microsoft.com/en-us/library/ywkkz4s1.aspx?cs-save-lang=1" rel="nofollow">Walkthrough: Multithreading with the BackgroundWorker Component (C# and Visual Basic)</a></p> <p><a href="https://msdn.microsoft.com/en-us/library/hybbz6ke(v=vs.110).aspx?cs-save-lang=1" rel="nofollow">How to: Run an Operation in the Background</a></p>
37,072,932
0
<p>Calculating out of basic logic, theoretically 1 GHz can do 1 billion calculations/second. </p> <p>Time for 10 quadrillion calculations would mean, 10 quadrillion/1 billion</p> <p>So calculate it through and you will find that it will take approximetly 115 days to complete</p> <pre><code>10,000,000,000,000,000 / 1,000,000,000 = 10,000,000 seconds 10,000,000 seconds = 166,667 minutes 166,667 minutes = 2778 hours 2778 hours = 115 days </code></pre> <p>But this is all theoretical</p>
26,476,745
0
<p><strong>Steps, Using Apache POI :</strong></p> <ol> <li><p>Open excel file in input mode (inputstream)</p></li> <li><p>Use POI API and read the excel content</p></li> <li><p>Update cell’s value using different setCellValue methods.</p></li> <li><p>Close the excel input file (inputstream)</p></li> <li><p>Open same excel file in output mode (outputstream)</p></li> <li><p>Write content of updated workbook in output file</p></li> <li><p>Close output excel file</p></li> </ol> <p><strong>Sample:</strong></p> <pre><code>try { FileInputStream file = new FileInputStream(new File("C:\\update.xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); Cell cell = null; //Update the value of cell cell = sheet.getRow(1).getCell(2); cell.setCellValue(cell.getNumericCellValue() * 2); cell = sheet.getRow(2).getCell(2); cell.setCellValue(cell.getNumericCellValue() * 2); cell = sheet.getRow(3).getCell(2); cell.setCellValue(cell.getNumericCellValue() * 2); file.close(); FileOutputStream outFile =new FileOutputStream(new File("C:\\update.xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } </code></pre>
14,946,185
0
<p>I think you may have a couple of issues here ...</p> <p>First I think your template call is non syntactically correct:</p> <pre><code>$("#tmplFeatures").tmpl(template1).appendTo("carouseldata"); </code></pre> <p>Should (according to the documentation) look like this:</p> <pre><code>$.tmpl( "tmplFeatures", template1).appendTo("carouseldata"); </code></pre> <p>But I'm not sure that you can pass HTML (template1) as the 'data' parameter for the <code>.tmpl()</code> method:</p> <p><a href="https://github.com/jquery/jquery-tmpl" rel="nofollow">https://github.com/jquery/jquery-tmpl</a></p> <p><strong>UPDATE</strong></p> <p>Looking more closely at your code above, it does not appear that you are passing any data to the <code>.tmpl()</code> call. It's not clear what the following line returns, but this should be the iterable data your template will be used to display.</p> <pre><code>var template1 = $(templates).filter("tmplFeatures").html(); </code></pre> <p>And this looks like (possibly) another representation of the template.</p>
32,345,378
0
Using PHPUnit installed globally with Silex project <p>I have global PHPUnit composer installation in </p> <pre><code>*~/.composer/vendor/phpunit*. </code></pre> <p>I want to use this installation to run tests from Silex application. Test files need to use project's <code>*vendor/autoload.php*</code> to load classes which will be tested at least, while global PHPUnit needs to load it's own <code>*~/.composer/vendor/autoload.php*.</code></p> <p>So in the project's tests I can't use PHPUnit autoloaded classes. So do I need to install PHPUnit to the project? But it looks like overkill while I have global PHPUnit. So, any help?</p>
28,706,129
0
<p>You need to change the jQuery code like this:</p> <pre><code>$(document).ready(function(){ var eventChoice = $('#test'), prodInterest = $('#productInterest'); eventChoice.change(function(){ var str = ""; $('#test option:selected').each(function(){ str += "Channel &amp; TR Event Reg - " + $(this).text(); }); prodInterest.val( str ); }); }); </code></pre> <p>Notice the removal of <code>change()</code> after the binding which caused it to trigger the change right after the binding was done.</p> <p>Code version when selected option is blank:</p> <pre><code>$(document).ready(function(){ var eventChoice = $('#test'), prodInterest = $('#productInterest'); eventChoice.change(function(){ var str = ""; $('#test option:selected').each(function(){ if ($(this).val() != "") { str += "Channel &amp; TR Event Reg - " + $(this).text(); } }); prodInterest.val( str ); }); }); </code></pre>
30,331,922
0
<p>I think your <code>screenHeightInWorld</code> is really a <code>screenTopInWorld</code>, a point can be anywhere in the space.</p> <p>You need the relative <strong>screen height in world</strong> coordinate. Which is actially the <strong>half of the camera frustum size</strong> if you use ortographic projection, as you think of it.</p> <p><code>float screenHeightInWorld = Camera.main.orthographicSize / 2.0f;</code></p> <p>I did not read the rest, but is probably fine, up to you how you implement this. I'd simply create an arrow method, something like <code>bool SpawnArrowAboveIfFits()</code>, which can call itself iteratively on the new instances.</p>
24,469,521
0
<p>Something like this:</p> <pre><code>#!/bin/bash for i in one; do n=$(echo $i | wc -c) echo $n done </code></pre>
22,673,429
0
<p>The <code>LayoutAnchorablePaneControl</code> (or any <code>TabControl</code> for that matter) has a property <code>TabStripPlacement</code> which you can set to <code>Top</code>. See the VS2010 <a href="http://avalondock.codeplex.com/SourceControl/latest#Version2.0/Xceed.Wpf.AvalonDock.Themes.VS2010/Theme.xaml" rel="nofollow">Theme.xaml</a></p>
40,467,503
0
<p>Timelion uses pre-defined time intervals for its time plots. In order to plot the "value" as function of time you can set the granularity to 'Auto' and use this string:</p> <pre><code> .es(metric='max:value') </code></pre> <p>You can also set the granularity to the minimum possible and add <code>.fit(carry)</code> to the above string in order to fill null values, in that case you can replace <code>max</code> with <code>min</code> or <code>avg</code>, it will produce the same plot (<code>sum</code> won't work here).</p>
31,205,776
0
restart broken tcp connection in windows using winsock 2 lib <p>am working on a c program that should log data from a norma 5000, but it seams like the normas tcpconnection randomly closes after an arbitary time (0.2-6h) but i need to log longer than that. </p> <p>when it Closes the Connection i can just restart program and it will continue to log. so i got the idea of just restarting my socket when the tcpconnection breaks. but my restart dosent work every time.. the function i Think you want to look at is shutdownCon, init and main.</p> <p>my question is: what am i doing wrong?</p> <p>winsock errors i get when the tcp Connection stops working 10053 (WSAECONNABORTED) or 10054 (WSAECONNRESET).</p> <p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx</a></p> <pre><code>#pragma comment(lib, "Ws2_32.lib") #define WIN 1 #define debug 1 #include &lt;winsock2.h&gt; #include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;sys/timeb.h&gt; #include &lt;time.h&gt; #define HOST "192.168.0.101" #define PORT 23 #define SOCKET_HANDLE_FMT_PFX "" #define SOCKET_HANDLE_FMT "u" /* "%u" - 'typedef u_int SOCKET' */ typedef SOCKET socket_handle_t; typedef struct { socket_handle_t h; } *socket_t; /**************************************************************************** **/ static void Delay(double seconds) { Sleep((DWORD)(seconds * 1000)); } /**************************************************************************** **/ void wsa_error(char *func,int error) { fprintf(stderr,"%s() failed, error %d\n", func,error == -1 ? WSAGetLastError() : error); int c; /* must be int to hold EOF */ while((c = getchar()) != '\n' &amp;&amp; c != EOF); } /**************************************************************************** **/ int socket_setup(void) { #if WIN WSADATA wsaData; int wsaerrno; /* * Initialize Windows Socket DLL */ if ( (wsaerrno = WSAStartup( MAKEWORD(1,1), /* at least version 1.1 */ &amp;wsaData)) != 0 ) { wsa_error("WSAStartup",wsaerrno); return -1; } #endif /* WIN */ return 0; /* OK */ } /**************************************************************************** **/ int socket_cleanup(void) { #if WIN if ( WSACleanup() == SOCKET_ERROR ) wsa_error("WSACleanup",-1); #endif return 0; /* OK */ } /**************************************************************************** **/ socket_t socket_create(void) { socket_handle_t sh; socket_t s; sh = socket(AF_INET,SOCK_STREAM,0); #if WIN if ( sh == INVALID_SOCKET ) { wsa_error("socket",-1); return NULL; } #endif s = calloc(1,sizeof(*s)); if ( !s ) return NULL; s-&gt;h = sh; return s; /* OK */ } /**************************************************************************** **/ int socket_connect(socket_t s,struct sockaddr *addr,int addrlen) { int ret = 0; /* OK */ #if WIN if ( connect(s-&gt;h,addr,addrlen) == SOCKET_ERROR ) { wsa_error("connect",-1); return -1; } #endif return 0; /* OK */ } /**************************************************************************** **/ int socket_recv(socket_t s,void *buf,int len,int flags) { register int l; #if WIN l = recv(s-&gt;h,buf,len,flags); if ( l == SOCKET_ERROR ) { wsa_error("recv",-1); return -1; } #endif return l; } /**************************************************************************** **/ int socket_send(socket_t s,void *buf,int len,int flags) { register int slen; /* sent length */ #if WIN slen = send(s-&gt;h,buf,len,flags); if ( slen == SOCKET_ERROR ) { wsa_error("send",-1); return -1; } #endif return slen; } /**************************************************************************** **/ int socket_puts(socket_t s,char *str) { char buf[1024]; strcpy(buf,str); strcat(buf,"\n"); if ( socket_send(s,buf,strlen(buf),0) &lt; 0 ) return -1; return 0; } /**************************************************************************** **/ int socket_gets(socket_t s,char *str) { char buf[1024]; char *p; if ( socket_recv(s,buf,sizeof(buf),0) &lt; 0 ) return -1; if ( (p = memchr(buf,'\n',sizeof(buf))) != NULL ) { if ( p &gt; buf &amp;&amp; p[-1] == '\r' ) p--; *p = '\0'; } else buf[sizeof(buf)-1] = '\0'; strcpy(str,buf); return strlen(str); } /**************************************************************************** **/ /*is some thing wrong here?*/ int shutdownCon(socket_t s){ char buff[1024]; if (shutdown(s-&gt;h,2)== SOCKET_ERROR) { wsa_error("shutdownCon",-1); return -1; } while(socket_gets(s,buff)&gt; 1); if(closesocket(s-&gt;h) == SOCKET_ERROR) { wsa_error("shutdownCon",-1); return -1; } socket_cleanup(); return 0; } /*is some thing wrong here?*/ int init(socket_t *s){ struct sockaddr_in saddr; struct sockaddr_in *addr_in = (struct sockaddr_in *)&amp;saddr; /* socket (TCP/IP) API initialization: */ if ( socket_setup() &lt; 0 ) return -1; /* * Connect to the instrument: */ /* set destination IP address and TCP port: */ memset(addr_in,0,sizeof(struct sockaddr_in)); addr_in-&gt;sin_family = AF_INET; addr_in-&gt;sin_port = htons(PORT); addr_in-&gt;sin_addr.s_addr = inet_addr(HOST); /* create socket: */ *s = socket_create(); if ( !*s ) return -1; #if debug fprintf(stderr,"socket_connect() ...\n"); #endif if ( socket_connect(*s,(struct sockaddr *)&amp;saddr,sizeof(saddr)) &lt; 0 ) return 1; #if debug fprintf(stderr,"socket_connect(): done\n"); #endif return 1; } int recon(socket_t *s){ shutdownCon(*s); init(s); return 0; } void printTime(){ struct _timeb timebuffer; char *timeline; _ftime( &amp;timebuffer ); timeline = ctime( &amp; ( timebuffer.time ) ); printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &amp;timeline[20] ); } int main(int argc,char *argv[]) { socket_t s; char buffer[1024]; char oper[1024]; init(&amp;s); #if debug fprintf(stderr,"trying to get id from norma \n"); if ( socket_puts(s,"*IDN?") &lt; 0 ) return 1; if ( socket_gets(s,buffer) &lt; 0 ) return 1; puts(buffer); #endif //##################CONF FROM FLUKE##################### /* Bring the instrument into a default state: */ //socket_puts(s,"*RST"); /* Select three wattmeter configuration: */ //socket_puts(s,"ROUT:SYST \"3W\""); /* SYNC source = voltage phase 1: */ //socket_puts(s,"SYNC:SOUR VOLT1"); /* Set voltage range on voltage channel 1 to 300 V: */ //socket_puts(s,"VOLT1:RANG 300.0"); /* Set current channel 1 to autorange: */ //socket_puts(s,"CURR1:RANG:AUTO ON"); /* Set averaging time to 1 second: */ //socket_puts(s,"APER 1.0"); /* Select U, I, P measurement: */ //socket_puts(s,"FUNC \"VOLT1\",\"CURR1\",\"POW1:ACT\""); /* Run continuous measurements: */ //socket_puts(s,"INIT:CONT ON"); //###################################################### socket_puts(s,"SYST:KLOC REM"); socket_puts(s,"*RST"); socket_puts(s,"ROUT:SYST \"3w\""); socket_puts(s,"APER 0.025"); socket_puts(s,"INP1:COUP DC"); socket_puts(s,"FUNC \"VOLT1\",\"CURR1\",\"POW1\",\"POW1:APP\",\"POW1:ACT\",\"PHASE1\""); socket_puts(s,"INIT:CONT ON"); Delay(5.0); /* Wait 2 seconds */ int opstat = -1; while(1){ //if(opstat != -1) // recon(&amp;s); opstat = 0; while((opstat &amp; 0x400) == 0){ if(socket_puts(s,"STAT:OPER:EVEN?")==-1){ recon(&amp;s); continue; } memset(oper,0,sizeof(oper)); if(socket_gets(s,oper) == -1){ recon(&amp;s); continue; } opstat = atoi(oper); } if(socket_puts(s,"DATA?") == -1){/* Query the measurement */ recon(&amp;s); continue; } memset(buffer,0,sizeof(buffer)); /* Clear buffer */ if(socket_gets(s,buffer) == -1){/* read values */ recon(&amp;s); continue; } puts(buffer); /* Print the value on the screen */ //Delay(1.0); /* Wait 2 seconds */ printTime(); } return 0; } /**************************************************************************** **/ </code></pre> <p>best regards baot</p>
20,522,185
0
<p>You dont need to make properties manually. Just go through the wizard for making a crystal report. It will manage all thing all that need is proper connection with DB and selection of tables.</p> <p><a href="http://www.youtube.com/watch?v=5C9fwFyJQxQ" rel="nofollow">I think video will help full</a></p>
33,109,710
0
<p>There are several ways to achieve what you want as the other answers point out. If you want a bit of safety checking then I'd use <code>TryParse</code>:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main() { var test = "1 2 3 x"; var values = test.Split(new [] {' '}, StringSplitOptions.RemoveEmptyEntries); var results = new List&lt;int&gt;(); foreach(var value in values) { int x; if(Int32.TryParse(value, out x)) { results.Add(x); } else { Console.WriteLine("{0} is not an integer", value); } } } } </code></pre>
20,934,928
0
changing storyboard after UIAlert button pressed <p>I want to change to the main menu after clicking main menu at the game over UIAlert</p> <p>trying this:</p> <pre><code> -(void)gameOver { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Time's up!" message:[NSString stringWithFormat:@"You've scored: %i points!", scoreCounter] delegate:self cancelButtonTitle:nil otherButtonTitles:@"Submit to Leaderboards",@"Play Again",@"Main Menu", nil]; [alert show]; } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { [self toMain]; } if (buttonIndex == 2) { [self toMain]; } if (buttonIndex == 3) { [self toMain]; } } -(void)toMain { mainMenu *main = [[mainMenu alloc] initWithNibName:nil bundle:nil]; [self presentViewController:main animated:YES completion:NULL]; } </code></pre> <p>does nothing at all...</p> <p>EDIT</p> <p>fixed the button index, now facing a black screen after [self toMain]</p>
32,998,118
1
cursor.fetchmany vs DECLARE BINARY CURSOR and FETCH <p>I am not sure which is the most effective or the disadvantages/advantages of each approach or whether they are technically the same thing ?</p> <p>That is </p> <pre><code>cursor.execute("DECLARE super_cursor BINARY CURSOR FOR SELECT names FROM myTable") while True: cursor.execute("FETCH 1000 FROM super_cursor") rows = cursor.fetchall() </code></pre> <p>as expressed in the answer given by alecxe <a href="http://stackoverflow.com/questions/17933344/python-postgres-can-i-ftechall-1-million-rows">python postgres can I ftechall() 1 million rows?</a></p> <p>In comparison to: </p> <pre><code>while True: results = cursor.fetchmany(1000) if not results: break for result in results: yield result </code></pre> <p>Should one use fetchmany as specified in psycopg2 or DECLARE BINARY.</p> <p>I Have assumed that fetchmany and DECLARE BINARY both setup a temporary table on the database server side... The client side is an Apache server.</p> <p>The website I am working with does calculations on user input to that of data in the database... Hence needs to load large amounts of data for pattern matching. </p> <p>Thank you.</p>
31,151,137
0
How to add a click listener to polymer custom element's child? <p>I am trying to add a click listener to one of the buttons inside a custom element in the <strong>"created"</strong> life cycle callback (even tried <strong>"ready"</strong> callback with same result).</p> <p>I am thrown with the error "button element is undefined/null". </p> <hr> <p><strong>Note:</strong></p> <p>a. I cannot add a click listener for the whole custom component like this. </p> <pre><code> listeners: { 'click': '_onClick' }, </code></pre> <p>I just need to add a listener to the button. How to get this simple thing? Sorry I am sounding naive. </p> <p>b. Cannot do inline script because of CSP restriction</p> <pre><code>&lt;paper-button id='saveBtn' on-click="handleClick"&gt; Save &lt;/paper-button&gt; </code></pre> <hr> <p><strong>Error Msg:</strong></p> <blockquote> <p>Uncaught TypeError: Cannot read property 'addEventListener' of null</p> <p>Polymer.created @ elements-imports.csp.js:10596Polymer.Base._addFeature._invokeBehavior @ elements-imports.csp.js:267Polymer.Base._addFeature._doBehavior @ elements-imports.csp.js:262Polymer.Base.createdCallback @ elements-imports.csp.js:97Polymer.Base._addFeature.instanceTemplate @ elements-imports.csp.js:535Polymer.Base._addFeature._stampTemplate @ elements-imports.csp.js:531Polymer.Base._addFeature._initFeatures @ elements-imports.csp.js:4627Polymer.attached @ elements-imports.csp.js:5612Polymer.Base._addFeature._invokeBehavior @ elements-imports.csp.js:267Polymer.Base._addFeature._doBehavior @ elements-imports.csp.js:262Polymer.Base.attachedCallback @ elements-imports.csp.js:102Polymer.Base._addFeature.attachedCallback @ elements-imports.csp.js:603Polymer.Base._addFeature._readySelf @ elements-imports.csp.js:591(anonymous function) @ elements-imports.csp.js:5554Polymer.ImportStatus._importsLoaded @ elements-imports.csp.js:5553(anonymous function) @ elements-imports.csp.js:5564checkDone @ webcomponents-lite.js:968watchImportsLoad @ webcomponents-lite.js:990(anonymous function) @ webcomponents-lite.js:939whenDocumentReady @ webcomponents-lite.js:957checkReady @ webcomponents-lite.js:952</p> </blockquote> <hr> <p><strong>Custom Element:</strong></p> <pre><code>&lt;dom-module id="my-form"&gt; &lt;template&gt; &lt;div&gt; &lt;paper-input id="inputName" label="Name" required error-message="Required Input"&gt; Name &lt;/paper-input&gt; &lt;paper-input id="inputServer" label="Server URL" required error-message="Required Input"&gt; Server &lt;/paper-input&gt; &lt;paper-input id="inputUsername" label="Username" required error-message="Required Input"&gt;Username&lt;/paper-input&gt; &lt;paper-input id="inputPassword" label="Password" type="password" required error-message="Required Input" value=""&gt;Password&lt;/paper-input&gt; &lt;div class="rows layout horizontal right-justified certificate"&gt; &lt;paper-button id='cancelBtn' tabindex="0"&gt;Cancel&lt;/paper-button&gt; &lt;paper-button id='saveBtn' tabindex="0"&gt;Save&lt;/paper-button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; &lt;/dom-module&gt; &lt;script&gt; Polymer({ is: 'my-form', created: function() { var saveBtn = document.querySelector('#saveBtn'); saveBtn.addEventListener('click', function() { document.getElementById('inputName').validate(); document.getElementById('inputServer').validate(); document.getElementById('inputUsername').validate(); document.getElementById('inputPassword').validate(); }); }, }); </code></pre>
32,798,860
0
<p>You set the <code>android:onClick</code> in the xml attribute which will invoke your <code>next</code> method, and you <code>setOnClickListener</code> again in your <code>next</code>, so the first time you click the imageView, the <code>mp.start()</code> will not be invoked.</p> <pre><code>MediaPlayer mp = null; public void next (View view) { if (mp != null) { mp.stop(); mp.release(); } mp = MediaPlayer.create(this, R.raw.dry); mp.start(); } </code></pre>
38,426,100
0
php, regex preg_match a specific word 0 or 1 time <p>I want to match a string with the words of another string, keeping the order:</p> <pre><code>$string_original = "Number three is good, then two and one."; $match_string = "three two one"; $result = magic_function($string_original,$match_string); </code></pre> <p>I want the result to be</p> <pre><code>$result = array(0 =&gt; 'three', 1 =&gt; 'two', 2 =&gt; 'one'); </code></pre> <p>Because all the words in the match string are found in the original ordered. An other example:</p> <pre><code>$string_original = "two is a magic number, one also and three"; $match_string = "three two one"; $result = magic_function($string_original,$match_string); //RESULT WOULD BE $result = array(0 =&gt; 'three'); //LAST EXAMPLE $string_original = "three one, then two!"; $match_string = "three two one"; $result = magic_function($string_original,$match_string); //RESULT WOULD BE $result = array(0 =&gt; 'three', 1 =&gt; 'two'); </code></pre> <p>My magic_function is something like</p> <pre><code>function magic_function($origin,$match){ $exploded = explode(' ',$match); $pattern = '/'; foreach ($exploded as $word){ $pattern .= '';//I NEED SOMETHING TO PUT HERE, BUT MY REGEX IS PRETTY BAD AND I DON'T KNOW } $pattern .= '/'; preg_match($pattern,$origin,$matches); return $matches; } </code></pre> <p>Any help with the regex part? Thank you.</p>
16,813,495
0
Get an element at a specific index from a NavigableSet <p>I have a <code>NavigableSet</code> and I would like to get its median object.</p> <p>Being that it's a <code>NavigableSet</code>, I know it's sorted, and thus I know that the median of it is either the middle element, or the arithmetic middle of the two middle elements.</p> <p>Therefore I would like to access the element at <code>set.size() / 2</code>, but the <code>NavigableSet</code> interface doesn't allow me to.</p> <p>Is there an easy way to get the specific element without having to iterate through the set manually?</p>
11,858,853
0
<p>Set the property <code>IsReadOnly=True</code></p>
3,759,745
0
<blockquote> <p>"The dictionary passed in, is constantly increasing in size"</p> </blockquote> <p>Do you mean that it's being modified while you're executing this code? That's a no-no. I suspect the <code>ToList</code> call is failing due to this. (After <code>ToList()</code> has executed, the list should be effectively separate from the dictionary.)</p> <p>Basically <code>Dictionary&lt;TKey, TValue&gt;</code> doesn't support concurrent reading and writing. You might want to look at <a href="http://msdn.microsoft.com/en-us/library/dd287191.aspx" rel="nofollow noreferrer"><code>ConcurrentDictionary&lt;,&gt;</code></a> which allows you to iterate over it while another thread is writing.</p> <p>One suggestion to improve performance when it's all working: call <code>side.ToString()</code> <em>once</em> at the start of the method, instead of on every single loop iteration.</p>
22,181,920
0
How to call Angular's internal email validation method <p>Is it possible to call Angular's internal email validation method from JavaScript rather than declarative in the markup?</p> <p>Thank you.</p> <p><em>EDIT:</em></p> <p>To answer all, the reason I am looking for this is so that email validation is consistent when using both the normal <code>&lt;input type="email"/&gt;</code> validation as well as when using programmatic validation.</p>
6,514,515
0
<p>This may not work in your scenario, but you can invoke a method from a binding using an ObjectDataProvider. Here's a quick example:</p> <pre><code>&lt;Window.Resources&gt; &lt;local:StringToDoubleConverter x:Key="stringToDouble" /&gt; &lt;local:MyObject x:Key="objInstance" /&gt; &lt;ObjectDataProvider x:Key="odp" ObjectInstance="{StaticResource objInstance}" ObjectMethod="MyMethod" &gt; &lt;ObjectDataProvider.MethodParameters&gt; &lt;sys:Double&gt;0&lt;/sys:Double&gt; &lt;/ObjectDataProvider.MethodParameters&gt; &lt;/ObjectDataProvider&gt; &lt;/Window.Resources&gt; </code></pre> <p>Now, an element in your view, say a TextBox can bind to the method parameter:</p> <pre><code>&lt;TextBox Text={Binding Source={StaticResource odp}, Path=MethodParameters[0], UpdateSourceTrigger=PropertyChanged, Converter={StaticResource stringToDouble}} /&gt; </code></pre> <p>The method return value can then be used in a binding elsewhere:</p> <pre><code>&lt;Label Content="{Binding Source={StaticResource odp}}" ContentStringFormat="Method returned: {0}" /&gt; </code></pre> <p>Again, this may not work in your scenario, but it does illustrate a way to pass a parameter to a method and use the return value entirely in XAML. Here's a resource for more information: <a href="http://bea.stollnitz.com/blog/?p=22" rel="nofollow">http://bea.stollnitz.com/blog/?p=22</a></p>
27,995,808
0
<p>Yes, it is possible to do so.</p> <p><strong>CAUTION:</strong> Proceed at your own risk. Writing block placement strategy is extremely complicated and risky. It's seems a code smell that your apps need to determine how replicas are placed. Think about if you really really need to write block placement strategies. Having warned you, proceed if you want to know how to accomplish this. Typically this feature is used to control how well balanced a cluster is. E.g. one of the strategies that was built by one of the Hadoop vendors is to place blocks on the disk with the lowest percentage disk used.</p> <p>Here's a bunch of resources for you to check out:</p> <ol> <li>SO post with the same problem: <a href="http://stackoverflow.com/questions/14494179/modifying-the-block-placement-strategy-of-hdfs">Modifying the block placement strategy of HDFS</a></li> <li>Another SO: <a href="http://stackoverflow.com/questions/13129599/how-does-hdfs-choose-a-datanode-to-store">how does hdfs choose a datanode to store</a></li> <li>Blog from 2009 when the feature was first released: <a href="http://hadoopblog.blogspot.com/2009/09/hdfs-block-replica-placement-in-your.html" rel="nofollow">http://hadoopblog.blogspot.com/2009/09/hdfs-block-replica-placement-in-your.html</a></li> </ol>
38,981,461
0
<p>I suggest you to create json object from your vars and pass it as argument, something like:</p> <pre><code>&lt;button id="modalBtn" type="button" onclick="ShowProduct(&lt;?php echo json_encode(array($title, $description, $img))?&gt;);"&gt; View Details &lt;/button&gt; </code></pre> <p>Or (for more readable keys)</p> <pre><code>&lt;button id="modalBtn" type="button" onclick="ShowProduct(&lt;?php echo json_encode(array('title' =&gt; $title, 'descr' =&gt; $description, 'img' =&gt; $img))?&gt;);"&gt; View Details &lt;/button&gt; </code></pre> <p>And your <code>ShowProduct</code> function you can define like:</p> <pre><code>function ShowProduct(params) { console.log( params ); // do other stuff } </code></pre> <p><strong>Update:</strong></p> <p>if your vars are already in array you can:</p> <pre><code>// pass this array: ShowProduct(&lt;?php echo json_encode($your_array)?&gt;) // fill new array with required keys only ShowProduct(&lt;?php echo json_encode(array($your_array['title'], $your_array['description'], $your_array['img']))?&gt;) </code></pre>
24,856,520
0
<p>Use explode() and return the second index.</p> <p>Example: </p> <pre><code>$parts = explode(' ', shell_exec('git --version')); return $parts[2]; </code></pre>
11,540,937
0
ActionScript 3 MouseEvent run once <p>What I want to do is to run once my over listener function. The problem is that once I do a mouse over into my movie clip "button", it enters a new loop again and again. How can I make it run <strong>only</strong> once, when the tween event is completed ?</p> <pre><code>import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; function Over (e:MouseEvent):void { trace('Over'); var myTweenUp:Tween = new Tween(button, "y", Back.easeOut, 200, 180, 2, true); } function Out (e:MouseEvent):void { trace('Out'); var myTweenDown:Tween = new Tween(button, "y", Back.easeOut, 180, 200, 2, true); } button.addEventListener(MouseEvent.MOUSE_OVER, Over); button.addEventListener(MouseEvent.MOUSE_OUT, Out); </code></pre>
38,580,497
0
Cocos2d-x 3.1 Following player with scale <p>I'm making an isometric game using cocos2d-x. I use cocos2d::Follow to make the camera follows my player (player is always at the center of screen). <br/> Everything work fine but when I scale my tilemap, the camera does not follow my player like what I want (player is not at the center of screen). The camera behaves like it still follows my player in original scale.<br/> How can I make the camera to follow my player properly?</p> <p>Note:<br/> I'm using TMXTileMap and add player's sprite as a child of map node. My code is as below<br/> </p> <pre><code>tileMap = new TMXTiledMap(); tileMap-&gt;initWithTMXFile("tiles/TileMap.tmx"); tileMap-&gt;setAnchorPoint(Vec2(0.5, 0.5)); tileMap-&gt;setPosition(visibleSize.width / 2, visibleSize.height / 2); int mapWidth = tileMap-&gt;getMapSize().width * tileMap-&gt;getTileSize().width; int mapHeight = tileMap-&gt;getMapSize().height * tileMap-&gt;getTileSize().height; float scale = visibleSize.width * 3 / mapWidth; tileMap-&gt;setScaleX(scale); tileMap-&gt;setScaleY(scale); this-&gt;addChild(tileMap, -1, kTagTileMap); sprite = Sprite::create("player.png"); Vec2 coord = Vec2(tileMap-&gt;getContentSize().width / 2, tileMap-&gt;getContentSize().height / 2); tileMap-&gt;addChild(sprite, (int)tileMap-&gt;getChildren().size()); camera = Follow::createWithOffset(sprite, offX, offY, boundary); tileMap-&gt;runAction(camera); </code></pre>
6,313,489
0
Where to start for a web application? <p>I want to start and learn coding to create a web application. I have experience in Java, C, Lisp, and Perl. I heard node.js is good to learn.<br> Can anyone suggest a good place to start?</p>
4,604,771
0
SQL Server Stored Procedure Compile-time Validation <p>Does anyone know how to get compile time validation of parameters being passed to a stored procedure. Example If Proc1 calls Proc2 but specifies an invalid parameter name for Proc2. Currently I find out at run-time. Is there a way to find out when I'm creating Proc1?</p> <p>Thanks much, Tom</p>
31,448,411
0
<p>So I figure it out! I was creating a new instance of myClass => <code>new MyClass()</code> thus the injection couldn't work! So I injected the MyClass() instead of creating a new instance and bound it in the ApplicationConfig. This worked fine.</p>
40,633,713
0
<p>One can do it exactly like in iOS: </p> <pre><code>let str = String.init(format: NSLocalizedString("TEST", comment:" "), 3) modularLargeTemplate.body1TextProvider = CLKSimpleTextProvider(text: str, shortText: str) </code></pre> <p>where the <code>Localizable.strings</code> file contains an entry </p> <pre><code>"TEST" = "Available: %i"; </code></pre> <p>This works, if <code>Localizable.strings</code> is target of the iOS app, and the watch extension.<br> However, I don’t know how to do the same with <code>CLKSimpleTextProvider.localizableTextProvider(withStringsFileTextKey: „TEST“)</code>.<br> Actually, I cannot imagine why a <code>localizableTextProvider</code> exists at all, if it cannot be used together with run time arguments (apparently), and does not provide any advantage (apparently) compared to the solution above.</p>
13,954,991
0
jQuery Collapsible Panel <p>ASP.Net, 2.0 VS2005, .Net 2.0 jQuery 1.8.3, jQuery UI 1.9.2</p> <p>I have two panels (more will come later on) on my form that can be open or closed at the users request.</p> <p>i am using the jQuery '.slideToggle' method.</p> <p>This is my markup</p> <pre><code>&lt;div class="trigger0"&gt;Collapsible Header 1 - Click to toggle&lt;/div&gt; &lt;div class="panel0"&gt; content 1 &lt;/div&gt; &lt;div class="trigger1"&gt;Collapsible Header 2 - Click to toggle&lt;/div&gt; &lt;div class="panel1"&gt; content 2 &lt;/div&gt; </code></pre> <p>The following works fine</p> <pre><code>$(document).ready(function() { $(".trigger0").click(function(){ $(".panel0").slideToggle("medium"); }); $(".trigger1").click(function() { $('.panel1').slideToggle("medium"); }); }); </code></pre> <p>but this doesn't</p> <pre><code>$(document).ready(function() { for (var vReportSectionCount = 0; vReportSectionCount &lt; 2; vReportSectionCount++) { $(".trigger" + vReportSectionCount).click(function(){ $(".panel" + vReportSectionCount).slideToggle("medium"); }); } }); </code></pre> <p>As i dont yet know how many panels will finally exist i dont want to have to write a new line for every panel. Can someone explain to me why and propose a better solution?</p>
7,021,593
0
Memory leak when using SWFLoader in Adobe AIR <p>I'm trying to load windowed sub-application in another windowed application, The requirement is to replace one loaded application with another on user action. </p> <p>I tried the documented method of <code>unloadAndStop</code>() on the <code>swfLoader</code> in the main windowed application, but somehow during memory profiling I could see the instances of those applications were maintained in the memory even after explicitly running garbage collection.</p> <p>Where as If I make those windowed application as modules, and then try to load them using the Moduleloader things work smoothly and unloaded modules are removed from memory.</p> <p>Any one faced the same issue before ?</p>
39,617,831
0
How to invert drag rotation in A-Frame? <p><em>A simple question. I used 4-6 hours to finding this but not found.</em></p> <p>Example, Im building a <strong>panorama viewer</strong> : <code>&lt;a-sky&gt;</code></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://aframe.io/releases/0.3.0/aframe.min.js"&gt;&lt;/script&gt; &lt;a-scene&gt; &lt;a-sky src="https://aframe.io/aframe/examples/boilerplate/panorama/puydesancy.jpg" rotation="0 -130 0"&gt;&lt;/a-sky&gt; &lt;/a-scene&gt;</code></pre> </div> </div> </p> <p>How to <strong>invert roation by drag mouse</strong> ? <em>(Left to right , right to left - something like this)</em></p>
8,136,517
0
<p>You can keep the uur and minuut values in a variable.Then get it formulated.</p> <pre><code>declare @hr int declare @mint int set @hr = SUM(dbo.kbpres.uur) set @mint = SUM(dbo.kbpres.minuut) SELECT (@hr*60 + @mint) / 60 as hours, (@hr*60 + @mint) % 60 as minutes </code></pre> <p>I think this will solve the prob please check</p>
9,310,680
0
<p>You don't have UINavigationController into your pop-up, so it works normal. Change it to support navigation like this:</p> <pre><code>//build our custom popover view BookSelectionview* popoverContent = [[BookSelectionview alloc] init]; UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:popoverContent] autorelease]; //resize the popover view shown //in the current view to the view's size popoverContent.contentSizeForViewInPopover = CGSizeMake(500, 600); //create a popover controller self.popoverController = [[UIPopoverController alloc] initWithContentViewController:navigationController]; </code></pre>
34,647,535
0
What does force unwrapped mean in an expected argument type? <p>Here is my line of code in Swift, it calls a method:</p> <pre><code>networkManager.postUserProfile(self, onSuccess: {(username: String, userID: NSNumber, recommendedLessons: [AnyObject]) -&gt; Void in ... code block }, onFailure: {(error: NSError) -&gt; Void in ... another code block }) </code></pre> <p>The <code>networkManager</code> class is from Objective-C and is:</p> <pre><code>- (void)postUserProfile:(Profile *)profile onSuccess:(void(^)(NSString *username, NSNumber *userID, NSArray *recommendedLessons))successBlock onFailure:(void(^)(NSError *error))failureBlock; </code></pre> <p>And the error message is:</p> <blockquote> <p>error: cannot convert value of type <code>(String, NSNumber, [AnyObject]) -&gt; Void</code> to expected argument type <code>((String!, NSNumber!, [AnyObject]!) -&gt; Void)!</code></p> </blockquote> <p>When calling a method, I understand that the <code>!</code> operator will force-unwrap an optional. However in this situation, what is the meaning of the <code>!</code> in the expected argument type?</p>
15,913,062
0
<p>The following code snippet illustrate an example of usage and creation of an OWL expression using the OWL API (taken and adapted from <a href="https://code.google.com/p/elk-reasoner/wiki/QueryingComplexClasses" rel="nofollow">there</a>):</p> <pre><code>//OWL Expression we would like to create: //in OWL Functional syntax: ObjectIntersectionOf(A ObjectSomeValuesFrom(R B)) //in Manchester syntax: A and R some B PrefixManager pm = new DefaultPrefixManager("http://example.org/"); OWLClass A = factory.getOWLClass(":A", pm); OWLObjectProperty R = factory.getOWLObjectProperty(":R", pm); OWLClass B = factory.getOWLClass(":B", pm); //The expression OWLClassExpression expression = factory.getOWLObjectIntersectionOf(A, factory.getOWLObjectSomeValuesFrom(R, B)); //Create a class in order to use the expression OWLClass C = factory.getOWLClass(":C", pm); // Declare an equivalentClass axiom //Just there to show how an example on how to use the expression OWLAxiom definition = factory.getOWLEquivalentClassesAxiom(C, expression); manager.addAxiom(ontology, definition); </code></pre>
4,604,794
0
Creating a simple li slider (infinate or with 'rewind'/stop) <p>So far I've got scrolling list items on click using the code below:</p> <pre><code>$('li#news-back').click(function(){ $('li.news-item').animate({ left : '-=960px' }); //$('li.news-item:first').insertAfter('li.news-item:last'); }); $('li#news-forward').click(function(){ $('li.news-item').animate({ left : '+=960px' }); //$('li.news-item:last').inserBefore('li.news-item:first'); }); </code></pre> <p>Each list item is 960px wide , items are floated left and only one item is shown in the container at any given time. Clicking back for forward will animate the li by their width making the next or previous visible..</p> <p>The problem is that for now there are 4 items. So I either need to add the first item to the end or the list or the last to the beginning of the list when clicked as the code I've commented out. </p> <p>Watching this in firebug it seems to be rearranging the content as I hoped but it's not working so within the browser (getting some very odd results - jumping to the 3rd when the second should be visible etc).</p> <p>The other solution perhaps would be to use an if statement to say (was we're manipulating the left property) - when back is click if left = 0 do nothing or alert there are no more in the list - then if forward is click to say if left = 2880 do nothing as you'll be at the end of the list..</p> <p>Any pointers greatly appreciated.</p>
13,206,301
0
<p>Serkan is right.</p> <p>From the first paragraph on <a href="http://codex.wordpress.org/Function_Reference/fetch_feed" rel="nofollow">http://codex.wordpress.org/Function_Reference/fetch_feed</a></p> <blockquote> <p>Retrieves an external feed and parses it. Uses the SimplePie and FeedCache functionality for retrieval and parsing and automatic caching.</p> </blockquote>
23,385,664
0
<p>This happens if the user is not in the current session or if the accesstoken is expired You can try by just using the logout url instead of destroying session before the logouturl.</p> <p>This is for testing : While redirecting make sure that the $facebook->getuser() is not returning 0 and access token exists.</p> <p>This happened for me a 6 months back i have done the same thing(making sure that fb session not destroyed before logging out the user) it worked</p>
5,248,321
0
Have TouchJSON return mutable objects? <p>I am receiving some json from a web service. I parse this using the TouchJSON library. I keep the data around for the user to change certain values and then I want to return it to the web service.</p> <p>The JSON object I get contains NSDictionary Objects within the object, like this:</p> <pre><code>[ { "id": null, "created_at": 12332343, "object": { "name": "Some name", "age" : 30 }, "scope": "it stuff", "kind_id": 1, "valid": true, "refering_statement": { "id": 95 }, "user": { "id": 1 } } ] </code></pre> <p>If I want to change values in this dictionary, I can't because the returned objects from TouchJSON are not mutable. </p> <p><strong>Is there a way to have have TouchJSON return mutable objects?</strong> </p> <p><strong>or is there a way to have Objective C make an NSDictionary and all its children mutable?</strong></p> <p>or do I have to just go through every NSDictionary in NSDictionary and copy all data into a mutable copy and then reinsert everything?</p> <p>Hope someone can help me out on this one:) thanks in advance.</p>
7,798,341
0
<p>The decision of whether to override the method or use the event handler often times comes down to how much control you need to have over what happens during the execution of that method. Overriding the method gives you full control of the method, whereas the event handler only runs after the method has executed. </p> <p>If you need a high level of control over what happens during that method, I would advise overriding the method. If you simply need to run some code after execution of the method, I would use the event handler.</p> <pre><code>protected override void OnDeactivated(EventArgs e) { //run some code before execution (anything that could effect execution) //call the base method and fire the event base.OnDeactivated(e); //run some code after execution } </code></pre>
34,223,386
0
<p><em><a href="http://ss64.com/nt/set.html" rel="nofollow">The <code>CALL SET</code> syntax</a> allows a <a href="http://ss64.com/nt/syntax-substring.html" rel="nofollow">variable substring</a> to be evaluated, the <a href="http://ss64.com/nt/call.html" rel="nofollow">CALL page</a> has more detail on this technique, in most cases a better approach is to use <a href="http://ss64.com/nt/delayedexpansion.html" rel="nofollow"><code>Setlocal EnableDelayedExpansion</code></a></em>. </p> <p>Command line (note that all <code>%</code> percent signs are <a href="http://ss64.com/nt/syntax-esc.html" rel="nofollow">escaped</a> as <code>^%</code> and that <code>&gt;</code> and <code>&amp;</code> characters are escaped within a pair of <code>"</code> double quotes:</p> <pre><code>set "zeroThroughNine=call set /a number=^%Random^% ^% 10&gt;nul &amp; call echo number=^%number^%" %zeroThroughNine% for /L %G in (1, 1, 10) do @%zeroThroughNine% </code></pre> <p>Batch script, <strong><code>CALL</code> method</strong> (note that all <code>%</code> percent signs are escaped as <code>%%</code>):</p> <pre><code>@echo OFF SETLOCAL set "_zeroThroughNine=call set /a _number=%%Random%% %%%% 10 &amp; call echo number=%%_number%%" echo check variables set _ echo output %_zeroThroughNine% for /L %%G in (1,1,10) do %_zeroThroughNine% echo check variables after evaluating set _ ENDLOCAL </code></pre> <p>Batch script, <strong><code>EnableDelayedExpansion</code> only for output</strong>:</p> <pre><code>@echo OFF SETLOCAL EnableExtensions DisableDelayedExpansion set "_zeroThroughNine=set /a _number=!Random! %% 10 &amp; echo Number=!_number!" SETLOCAL EnableDelayedExpansion echo check variables set _ echo output %_zeroThroughNine% for /L %%G in (1,1,10) do %_zeroThroughNine% echo check variables after evaluating set _ ENDLOCAL ENDLOCAL </code></pre> <p>Batch script, <strong><code>EnableDelayedExpansion</code> script wide</strong> (note that <code>!</code> exclamation sign is escaped as <code>^!</code>):</p> <pre><code>@echo OFF SETLOCAL EnableExtensions EnableDelayedExpansion set "_zeroThroughNine=set /a _number=^!Random^! %% 10 &amp; echo NUMBER=^!_number^!" echo check variables set _ echo output %_zeroThroughNine% for /L %%G in (1,1,10) do %_zeroThroughNine% echo check variables after evaluating set _ ENDLOCAL </code></pre>
7,912,440
0
<p>You can use a separate div, and do some tricks using paddings and margins. </p> <p>In the fiddle, the blue div is the 'Mid' div, and the red div is the content div. They still have the same side and position. The green div is a trick, and is lowered 170px. Now, when you give the green div a background instead of mMid, the background should be lowered 170px relative to the content div.</p> <p><div class="snippet" data-lang="js" data-hide="true"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#mMid { width:1001px; border: 1px solid blue; padding-top: 170px; } #mTrick { border: 1px solid green; background:url(/images/mMid.png) top left repeat-y; } #mBot { background:url(/images/mBot.png) bottom left no-repeat; /* width: 1001px; not needed. It will borrow the size from it's parent */ border: 1px solid red; margin-top: -170px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="mMid"&gt; &lt;div id="mTrick"&gt; &lt;div id="mBot"&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; Content&lt;br&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><a href="http://jsfiddle.net/GolezTrol/N3z8S/1/" rel="nofollow">Or view jsFiddle</a></p>
26,142,138
0
<p>In Java world, your use case is called as BPM (Business process management). </p> <p>In .Net world, this is called as Windows Workflow Foundation (WWF).</p> <p>There are many java based open source BPM tools. The one i like is <a href="http://www.jbpm.org/" rel="nofollow noreferrer">jBPM</a>.</p> <p>This is more powerful and can be integrated with rule engines like <a href="http://www.drools.org/" rel="nofollow noreferrer">Drools</a>.</p> <p>Sample jBPM Screenshot: <img src="https://i.stack.imgur.com/3aw9x.png" alt="jBPM Diagram"></p> <p>Also <a href="http://activiti.org/" rel="nofollow noreferrer">Activiti</a> is another good choice.</p> <p>Sample Activiti Screenshot: <img src="https://i.stack.imgur.com/SwngO.png" alt="Activiti Diagram"></p>
29,859,834
0
<p>It seems like your question boils down to "how can I dynamically add a method to an object", the the short answer is don't do it (1). Objects can have attributes which can be functions, and that's fine, but these functions do not become methods and don't behave like methods. For example if <code>foo.attr is sum</code> then <code>foo.attr(x)</code> is the same as <code>sum(x)</code> not <code>sum(foo, x)</code>.</p> <p>Your question has a certain functional "aroma" to it, if you wanted to drop the class/object stuff and go the fully functional route you could do something like this:</p> <pre><code>def identity(x): return x def f(n): return [i for i in range(1, 10) if (n % i == 0)] def s(factors): return (len(factors) == 2) def foo(func, helper=identity): def innerfunc(n): return func(helper(n)) return innerfunc a = foo(f) print a(6) # [1, 2, 3, 6] b = foo(s, a) print b(5) # True </code></pre> <p>If that doesn't appeal to you, I would suggest thinking of the <code>func</code> and <code>parent</code> attributes on your <code>Foo</code> class as data attached to your objects, not as methods, and work out the problem from there. The logic associated with your class should live inside proper methods. These methods can refer to the data as needed. Here's my very simple example:</p> <pre><code>class Foo(object): def __init__(self, func, parent=None): self.func = func self.parent = parent def run(self, n): if self.parent is None: return self.func(n) else: return self.func(self.parent.run(n)) a = Foo(f) print a.run(6) # [1, 2, 3, 6] b = Foo(s, a) print b.run(5) # True </code></pre> <p>(1) Methods belong to a class not an object, so the question should really be how can I attach something to my object that behaves like a method.</p>
22,794,899
0
<p>Horizontal Scroll View is only good if you have just a few items. If you have a lot, you should consider an alternative: a <a href="http://developer.android.com/reference/android/support/v4/view/ViewPager.html" rel="nofollow"><strong>ViewPager</strong></a> (in case you wish to show only a single item at a time), or a third party library like <a href="https://github.com/sephiroth74/HorizontalVariableListView" rel="nofollow"><strong>"Horizontal Variable ListView"</strong></a>. I'm sure there are other alternatives.</p> <p>note that the Gallery view is very inefficient and buggy so you shouldn't even try to use it. </p>
11,835,896
0
<p>The advice here may work for you <a href="http://forums.asp.net/t/1063057.aspx" rel="nofollow">http://forums.asp.net/t/1063057.aspx</a> in short define and add a CssClass to your gridview then use plain old CSS stylesheet to target and decorate the control.</p>
33,919,058
0
Prevent iOS URL scheme hijack <p>I have an app that gets opened from another app via a URL scheme. The URL contains signup tokens. As any app can register the same URL scheme as my app, I am concerned a "fake" app can do a man-in-the-middle attack and capture the signup tokens.</p> <p>My idea is to check that the URL scheme does not open another app when my app is first opened.</p> <p>From a security perspective, if the URL scheme opens my app the first time, will it always open my app in the future?</p>
36,742,550
0
<p>I found the error >> all what i forgot to do is to return data from http get in factory services.js >></p> <pre><code> .factory('stations',['$http',function($http){ var stations = []; return $http.get(base_url+'api/stations/uid/'+uu_id).success(function(response){ stations = response; return stations; }); }]) </code></pre>
14,504,280
0
<p>There is no problem doing what you want, you just need to be carful with the HTML when you have nested columns. Here's a working example with fluid rows <a href="http://jsfiddle.net/panchroma/yYFMT/" rel="nofollow">http://jsfiddle.net/panchroma/yYFMT/</a> </p> <p>When using fluid rows, note that spans of the nested columns add to 12 and the HTML is </p> <pre><code>&lt;div class="row-fluid"&gt; &lt;div class="span8"&gt; &lt;div class="row-fluid"&gt; &lt;div class="span6"&gt;nested col&lt;/div&gt; &lt;div class="span6"&gt;nested col&lt;/div&gt; &lt;/div&gt; &lt;!-- end nested row --&gt; &lt;/div&gt; &lt;!-- end span 8 parent --&gt; &lt;div class="span4"&gt; span 4 &lt;/div&gt; &lt;/div&gt; &lt;!-- end row --&gt; </code></pre> <p>If you don't have fluid rows, the spans of the nested columns add up to the width of the parent, eg</p> <pre><code>&lt;div class="row"&gt; &lt;div class="span8"&gt; &lt;div class="row"&gt; &lt;div class="span4"&gt;nested col&lt;/div&gt; &lt;div class="span4"&gt;nested col&lt;/div&gt; &lt;/div&gt; &lt;!-- end nested row --&gt; &lt;/div&gt; &lt;!-- end span 8 parent --&gt; &lt;div class="span4"&gt; span 4 &lt;/div&gt; &lt;/div&gt; &lt;!-- end row --&gt; </code></pre> <p>Here's a working example of with non-fluid rows: <a href="http://jsfiddle.net/panchroma/MX6GK/" rel="nofollow">http://jsfiddle.net/panchroma/MX6GK/</a></p> <p>Good luck!</p>
7,776,710
0
Detect a hyperlink in a text - jQuery <p>I have a plain text, say, <code>"Hello how are you, please visit 'http://google.com'"</code>. </p> <p>I am displaying this in a div using jQuery (this text is being randomly generated). My question is, is there any way that I can detect that "http://google.com" in the text is a hyperlink and thereby convert that part of the text in to a clickable hyperlink?</p> <p>Thanks. </p>
18,562,867
0
<p>Prestashop doesn't support "delete product animation", the store you mention as example (mangoshoppers.com) is not using prestashop, is not even PHP.</p>
30,473,500
0
Delete row from the page without refreshing the page <p>I use this method to delete a row from the table. I'm able to delete the row from the database and shows the 'status' alert. But i've to refresh the page for removing the row from the page. What should i do?</p> <pre><code>&lt;script type="text/javascript"&gt; function DeleteRow(btnDel) { $.get('../ProtocolSummary/DeleteRowATList?id2=' + btnDel, function(data, status){ alert("Status: " + status); }); $(btnDel).closest("tr").remove(); } &lt;/script&gt; ***Html*** &lt;tbody&gt; &lt;% var ATRowId = 0; foreach (var item in Model.List) {%&gt; &lt;tr style="text-align:center"&gt; &lt;td&gt;&lt;%=Html.TextAreaFor(m =&gt; m.List[RowId].Type, new { value = @Model.List[ATRowId].Type, @style = "width:260px;" })%&gt; &lt;%=Html.HiddenFor(x=&gt;x.List[RowId].AssistiveId,Model.ATList[RowId].AssistiveId) %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=Html.TextAreaFor(m =&gt; m.List[RowId].Schedule, new { value = @Model.List[ATRowId].Schedule, @style = "width:260px;" })%&gt;&lt;/td&gt; &lt;td&gt;&lt;%=Html.TextAreaFor(m =&gt; m.List[RowId].Storage, new { value = @Model.List[ATRowId].Storage, @style = "width:260px;" })%&gt;&lt;/td&gt; &lt;td style="width:50px"&gt;&lt;input type="button" value="delete" class="btnDel" style="float:right;width:20px" onclick="DeleteRow(&lt;%= item.AssistiveId%&gt;)" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% ATRowId++; }%&gt; &lt;/tbody&gt; </code></pre>
3,221,921
0
Change all with command line <p>I'm wondering if there is a way to change a specific word in all of the files within the /www/ directory using command line. Just looking for a faster way to change out a specific word so I don't need to open all the files manually! Thanks!</p>
6,144,517
0
php command line print in object not returning <p>I am trying to run some php from the command line but the php in my class is not being hit.</p> <pre><code>&lt;?php print "1"; try { print ",2"; $a = new myClass(""); } catch (Exception $e) { print $e-&gt;getMessage(); } print ",3"; </code></pre> <p>myClass</p> <pre><code>&lt;?php class myClass{ function __construct($var) { print "My Class"; } } </code></pre> <p>The output I am getting is:</p> <pre><code>1,2 Process finished with exit code 255 </code></pre> <p>Why is the print in the constructor not outputting to the command line?</p>
21,633,057
0
<p>This isn't possible, but your goal <em>may</em> be achievable with <a href="http://msdn.microsoft.com/en-us/library/85w54y0a.aspx" rel="nofollow">conversion operators</a>. It seems that what you're trying to do is make it possible to pass an <code>IView&lt;T&gt;</code> as the <code>T</code> object which it contains. You could write a base class like this:</p> <pre><code>public abstract class ViewBase&lt;T&gt; { public abstract T SomeParam { get; } public static implicit operator T(ViewBase&lt;T&gt; view) { return view.SomeParam; } } </code></pre> <p>Then, if you define a class like:</p> <pre><code>public class SomeView : ViewBase&lt;ISomeView&gt; { } </code></pre> <p>It can be accepted anywhere an <code>ISomeView</code> is expected:</p> <pre><code>ISomeView view = new SomeView(); </code></pre>
23,287,646
0
<p>If you have that textfile, you might just put a <code>rename</code> at the beginning of each line and save it as .<code>bat</code>.</p> <p>(E. g. with Notepad++, Search Mode = Extended, replace <code>\n</code> with <code>\nrename</code>, maybe check first and last lines)</p>
37,651,690
0
<p>I think the change of basis could help you<a href="https://en.wikipedia.org/wiki/Change_of_basis" rel="nofollow" title="Wiki Link">Wiki Link</a>. Its quite easy to implement. </p>
28,595,643
0
How can a Makefile determine the binary format the compiler will create? <p>Is it possible for a Makefile to determine what binary format the compiler is targeting (i.e. PE, ELF, Mach-O, etc.)? Maybe by running the compiler or assembler with certain options?</p> <p>Or can I accurately determine this from the OS (by running <code>uname -s</code> or something of the sort)?</p>
27,024,730
0
How can I make the code segments of this page more readable? <p>Sorry about the specific question - I'm writing up this page for my portfolio <a href="http://ashereinhorn.com/portfolio/2014/hex-tile-world-script-page-unfinished/" rel="nofollow">http://ashereinhorn.com/portfolio/2014/hex-tile-world-script-page-unfinished/</a></p> <p>however the column is so narrow that it results in some undesirable formatting for the dark, code segments. </p> <p>How can I make these section expand further to the right (and left?) so that there is less line wrapping. </p> <p>I'm writing it all in HTML so a solution with just that would be perfect. I'm not against solutions where you have to expand them or they open a floating element that displays the content either. </p> <p>Thank you in advance. </p>
2,277
0
<p>From the <a href="http://www.python.org/doc/faq/general/#why-are-there-separate-tuple-and-list-data-types" rel="nofollow noreferrer">Python FAQ</a>:</p> <blockquote> <p>Lists and tuples, while similar in many respects, are generally used in fundamentally different ways. Tuples can be thought of as being similar to Pascal records or C structs; they're small collections of related data which may be of different types which are operated on as a group. For example, a Cartesian coordinate is appropriately represented as a tuple of two or three numbers.</p> <p>Lists, on the other hand, are more like arrays in other languages. They tend to hold a varying number of objects all of which have the same type and which are operated on one-by-one.</p> </blockquote> <p>Generally by convention you wouldn't choose a list or a tuple just based on its (im)mutability. You would choose a tuple for small collections of completely different pieces of data in which a full-blown class would be too heavyweight, and a list for collections of any reasonable size where you have a homogeneous set of data.</p>
35,588,607
0
<p>If you are simply extending the list already in the Dictionary with key <code>oldKey</code> then <code>mainGraph[oldKey].Add(newValue);</code> will do it.</p>
20,296,784
0
<p>Instead this <code>String.valueOf(tokenizer.nval)</code> use <code>tokenizer.sval</code> and use 'list.add (sval)'.</p>
912,429
0
<p>I agree with most of the others here. I think you should really try to uncomplicate things by using another already build free option like itunes, Winamp or WMP. If you really want to learn something new, do this just for fun after when you won't be under so much pressure to make it work.</p> <p>If, however you REALLY want to go through with this I think <a href="http://code.google.com/p/ffmpeg-sharp/" rel="nofollow noreferrer">http://code.google.com/p/ffmpeg-sharp/</a> should do what you want.</p>
37,591,413
0
<p>Did you already create a podile?</p> <p>With cocoapods installed, take the following steps:</p> <ul> <li>Open a terminal window, and $ cd into your project directory (cd ~/Path/To/Folder/Containing/your/app)</li> <li>Create a Podfile by running $ pod init</li> <li>Open the podfile (open -a Xcode Podfile) and add the podline and save the file, for example:</li> </ul> <blockquote> <p>pod 'AFNetworking', '~> 3.0'</p> </blockquote> <ul> <li>Run $ pod install in your project directory </li> <li>Open App.xcworkspace</li> </ul> <p>Please find a more extended guide <a href="https://www.raywenderlich.com/97014/use-cocoapods-with-swift" rel="nofollow">here</a></p> <p>Hope this helps!</p>
14,925,551
0
What does class << self mean? <p>Regarding:</p> <pre><code>class Test class &lt;&lt; self def hi puts "Hi there" end end </code></pre> <p>I came up with following image in my head:</p> <p>Since everything is an object in Ruby, classes themselves are objects of class <code>Class</code>. By calling <code>class &lt;&lt; self</code> you open up <code>Class</code> definition from the inside of <code>Test</code> and inject few instance methods. Since <code>Test</code> is an instance of <code>Class</code>, you can call those methods same way you call instance methods on your objects: <code>Test.hi</code>. </p> <p>Following is the pseudo code which helps to visualise my previous sentence:</p> <pre><code>class Class def hi puts “Hi there” end end Test = Class.new(class Test end) Test.hi </code></pre> <p>Am I getting this right?</p>
14,477,804
0
<p>The <code>.htaccess</code> method mentioned by Yada is valid. Another approach would be to do this in your PHP script itself. If it's a cronjob running through CLI:</p> <pre><code>if (!empty($_SERVER['REMOTE_ADDR'])) { // If a "remote" address is set, we know that this is not a CLI call header('HTTP/1.1 403 Forbidden'); die('Access denied. Go away, shoo!'); } </code></pre> <p>Or if it's triggered by a browser request from the other PHP script, just verify if the IP is yours/local:</p> <pre><code>if ($_SERVER['REMOTE_ADDR'] != '192.168.1.5') { // Or whatever your local IP is header('HTTP/1.1 403 Forbidden'); die('Get out and stay out!'); } </code></pre>
15,929,012
0
Is it possible to use a parent table Id instead of child table Id, when child table should put it's Id into another table <p>I have this Generalization relation ship between some classes in my class diagram. FirstClass as a base class that has Name attribute, SecondClass as a derived class that the FirstClass is it's base class and has some other attributes and finally ThirdClass that is a derived class from SecondClass and it has some other attributes too. ThirdClass as an association relation ship with Widget class, 1.*.</p> <p><img src="https://i.stack.imgur.com/8ytZp.png" alt="enter image description here"></p> <hr> <p>I used Joined strategy when I wanted to implement a Data Model from the class diagram. so the FirstTable has their Pk in the SecondTable and the SecondTable has its PK in the ThirdTable. As you see Third table should has it's PK in Widget class. And there are some costs whenever I want to Join widget table with third table because I need to fetch Name from First Table.</p> <p>Is it appropriate that I read Id from FirtTable (Actually it's base class) and put it into Widget table? </p> <hr>
31,686,783
0
<p>Use the <code>.figure()</code> function to create a new window, the following code makes two windows:</p> <pre><code>import matplotlib.pyplot as plt plt.plot(range(10)) # Creates the plot. No need to save the current figure. plt.draw() # Draws, but does not block plt.figure() # New window, if needed. No need to save it, as pyplot uses the concept of current figure plt.plot(range(10, 20)) plt.draw() </code></pre> <p>You can repeat this as many times as you want</p>
11,755,163
0
<p>Check the Permissions section at <a href="https://developer.spotify.com/technologies/apps/guidelines/" rel="nofollow">https://developer.spotify.com/technologies/apps/guidelines/</a></p> <p>You will need to add the URLs google web fonts are loaded from to the RequiredPermissions element. </p>
13,190,317
0
<p>Yes, I agree with Ivan. If you use this technique, it will consume high resource on the server and most of shared hosting doesnt permit it as it will make the instability on the server. If you want to try on shared hosting, I believe you need to sign up the highest plan. Or you can deal with the provider and ask their best price. :) For ASP.NET provider, I would recommend you to find it on Microsoft site as they really specialize in this field. If it still doesnt work, you need to use VPS or cloud. good luck.</p>
30,423,788
0
<p>You question is a bit unclear, but I think this will point you in a productive direction. SQL is designed to perform operation on sets of rows, not to loop through processing one row at a time. The following code will correlate your data into one row for each pair of slots at each date/time. You can use a <code>CASE</code> expression, as shown, to add a column that indicates the status of the row, and you can then add a <code>WHERE</code> clause, not shown, to perform any additional filtering.</p> <pre><code>-- Sample data. declare @Samples as Table ( SampleId Int, Slot Int, EventDate Date, StartTime Time(0), EndTime Time(0), Action VarChar(10) ); insert into @Samples ( SampleId, Slot, EventDate, StartTime, EndTime, Action ) values ( 200, 1, '20150501', '00:00:00', '00:30:00', NULL ), ( 201, 2, '20150501', '00:00:00', '00:30:00', NULL ), ( 202, 1, '20150501', '00:30:00', '01:00:00', 'A' ), ( 203, 2, '20150501', '00:30:00', '01:00:00', NULL ), ( 204, 1, '20150501', '01:00:00', '01:30:00', NULL ), ( 205, 2, '20150501', '01:00:00', '01:30:00', 'A' ), ( 206, 1, '20150501', '01:30:00', '02:00:00', 'B' ), ( 207, 2, '20150501', '01:30:00', '02:00:00', 'B' ); select * from @Samples; -- Data correleated for each date/time. select Slot1.EventDate, Slot1.StartTime, Slot1.EndTime, Slot1.Action as Action1, Slot2.Action as Action2, Coalesce( Slot1.Action, Slot2.Action ) as SummaryAction, case when Slot1.Action = Slot2.Action then 'ERROR!' else 'Okay.' end as Status from @Samples as Slot1 inner join @Samples as Slot2 on Slot2.EventDate = Slot1.EventDate and Slot2.StartTime = Slot1.StartTime and Slot1.Slot = 1 and Slot2.Slot = 2; </code></pre>
36,993,416
0
<p>You can use the <code>body-parser</code> middleware:</p> <pre><code>$ npm install body-parser --save </code></pre> <p>Then:</p> <pre><code>const express = require('express') const bodyParser = require('body-parser') const app = express() app.use(bodyParser.urlencoded({ extended: true })) app.use(bodyParser.json()) app.post('/foo', function (req, res) { // req.body is a plain object }) </code></pre>
27,653,861
0
<p>Unicode provides <strong>Directional Formatting Characters</strong>,and Qt supports it well.</p> <p>Thus,for <strong><code>QLabel</code></strong> and <strong><code>QLineEdit</code></strong> etc. we can insert a <strong><code>LRM</code></strong> control character<br/> ,which is define in <strong>Unicode Bidirectional Algorithm</strong>, at the beginning of a <strong>RightToLeft</strong> string to make the string <strong>left-alignment</strong>.For more information about <strong>Unicode Bidirectional Algorithm</strong>,click <a href="http://www.unicode.org/reports/tr9/" rel="nofollow">here</a>.</p> <pre><code>QString(QChar(0x200E))+strText; </code></pre> <p>And for <strong><code>QTextEdit</code></strong> etc. which has a <strong><code>QTextDocument</code></strong> we can make <strong>RightToLeft</strong> string <strong>left-alignment</strong> by setting <strong><code>QTextDocment</code></strong>'s <code>textDirection</code> to <strong><code>Qt::LeftToRight</code></strong>. </p> <p>ps:<br/> <strong><code>QString</code></strong> has a <strong><code>isRightToLeft</code></strong> member function to decide whether the string is <strong>RightToLeft</strong> or not. For example,a string that begins with a notation from <strong>Right-to-left</strong> writting language is <strong>RightToLeft</strong>. </p> <p>I answered <a href="http://stackoverflow.com/questions/27615175/how-to-make-right-to-left-language-eg-arabic-characters-behave-like-left-to-ri/27653970#27653970">another one</a>,which maybe helpful for finding your own solution.</p>
1,762,311
0
In C# , How can i create a System.Drawing.Color object using a hex value? <p>In C# , How can i create a System.Drawing.Color object using a value like this #FFFFF,#FGFG01 etc... </p>
38,892,754
0
How to call SOAP API from the browser <p>I have a localhost SOAP API that I can call using Chrome's extension <a href="https://chrome.google.com/webstore/detail/boomerang-soap-rest-clien/eipdnjedkpcnlmmdfdkgfpljanehloah/reviews" rel="nofollow">Boomerang - SOAP &amp; REST Client</a> it works and I get results with this request:</p> <pre><code>&lt;x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eko="http://localhost:8080/api/myapi.wsdl"&gt; &lt;x:Header/&gt; &lt;x:Body&gt; &lt;eko:getReview&gt; &lt;eko:auth&gt;123abfdbgfdg&lt;/eko:auth&gt; &lt;eko:changed_since&gt;2016-06-07&lt;/eko:changed_since&gt; &lt;eko:rating_id&gt;?&lt;/eko:rating_id&gt; &lt;eko:product_id&gt;?&lt;/eko:product_id&gt; &lt;/eko:getReview&gt; &lt;/x:Body&gt; &lt;/x:Envelope&gt; </code></pre> <p>Now I need to call this API method; getReview, using the browser. So I tried to pass those parameters like this:</p> <pre><code>http://localhost/api/api.php/getReview/123abfdbgfdg/2016-06-07 </code></pre> <p>But seems not working: I just get back the WSDL service help, but not the actual call results.</p> <p>Is it even possible to call SOAP from browser?</p>
4,744,507
0
XML, DTD: how to make the order not important <p>I started off using an XML file and a parser as a convenient way to store my data</p> <p>I want to use DTD to check the structure of the xml files when they arrive.</p> <p>Here is my DTD file </p> <pre><code>&lt; ?xml version="1.0" encoding="UTF-8"?&gt; &lt; !ELEMENT document (level*)&gt; &lt; !ELEMENT level (file,filelName?,fileNumber?)&gt; &lt; !ELEMENT file (#PCDATA)&gt; &lt; !ELEMENT filelName (#PCDATA)&gt; &lt; !ELEMENT fileNumber (#PCDATA)&gt; </code></pre> <p>(note that fileName and fileNumber are actually purely optional)</p> <p>and </p> <pre><code>&lt;document&gt; &lt;level&gt; &lt;file&gt;group1file01&lt;/file&gt; &lt;/level&gt; &lt;level&gt; &lt;file&gt;group1file02&lt;/file&gt; &lt;fileName&gt;file 2&lt;/fileName&gt; &lt;fileNumber&gt;0&lt;/fileNumber&gt; &lt;/level&gt; ... </code></pre> <p>as such all this works fine. (I use eclipse "validate" option to test it for now)</p> <p>however while testing I got what I think is a wierd error</p> <p>if I do </p> <pre><code> &lt;level&gt; &lt;levelName&gt;Level 2&lt;/levelName&gt; &lt;levelNumber&gt;0&lt;/levelNumber&gt; &lt;file&gt;group1level02&lt;/file&gt; &lt;/level&gt; </code></pre> <p>changing the order of the lines, Eclipse refuses to validate it ...</p> <p>I was wondering if this was a problem with Eclipse or if the order is actually important.</p> <p>If the order is important how can I change the DTD to make it work no matter the ordering of he elements?</p> <p>I can't really change the XML because I already have all the XML files and the parser written (I know I did it the wrong way round lol).</p>
17,190,654
0
How to create text file in given directory in iphone and android <p>can you please tell me hoe to create text file in given given directory .I need write on that text file .and read the text from that text file. I am able to create folder using this code .But i need to add text file inside the folder(newDir).</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Local File System Example&lt;/title&gt; &lt;script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" charset="utf-8"&gt; // Wait for Cordova to load document.addEventListener("deviceready", onDeviceReady, false); // Cordova is ready function onDeviceReady() { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail); } function onFileSystemSuccess(fileSystem) { console.log(fileSystem.name); var directoryEntry = fileSystem.root; directoryEntry.getDirectory("newDir", {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail) } function onDirectorySuccess(parent) { console.log(parent); } function onDirectoryFail(error) { alert("Unable to create new directory: " + error.code); } function onFileSystemFail(evt) { console.log(evt.target.error.code); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Example&lt;/h1&gt; &lt;p&gt;Local File System&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
25,194,097
0
image existing on http://website.com but not on www.website.com <p>I uploaded an image earlier today and it works fine so long as i do not type www into the URL in front... We have had this problem multiple times and I have no idea why this keeps happening or what I can do to help the problem...</p> <p>I have tried to access from multiple browsers and computers to see if it's a caching issue but alas, it does not seem to work...</p> <p>I have used both google AND the stack overflow search functions in an attempt to find someone else with the same problem. Maybe I'm not very good at googling, but I wasn't able to find someone else. I did find qiestions that asked between the differences between using www and not using it, but not a single of them had files that could be located on one of them while not on the other.</p>
2,623,763
0
<p><code>SomeStruct.OtherStruct</code> is a property, returning a value - it's not a variable. This line:</p> <pre><code>a.OtherStruct.PublicProperty++; </code></pre> <p>is like calling:</p> <pre><code>a.get_OtherStruct().PublicProperty++; </code></pre> <p>Because the expression <code>a.get_OtherStruct()</code> is a <em>value</em> rather than a <em>variable</em>, it's a bit like doing this:</p> <pre><code>OtherStruct tmp = a.get_OtherStruct(); tmp.PublicProperty++; </code></pre> <p>Changing the value of <code>PublicProperty</code> in the <em>copy</em> of <code>OtherStruct</code> returned by the property isn't going to change the original value at all. That's almost certainly not your intention. The C# designers foresaw this sort of problem, and managed to prohibit it in many situations.</p> <p>Note that if <code>OtherStruct</code> were a reference type (a class) instead, then it would be the <em>reference</em> that was copied, not the values within it... so changing <code>tmp.PublicProperty</code> <em>would</em> make a difference. See my <a href="http://pobox.com/~skeet/csharp/references.html" rel="nofollow noreferrer">article on reference and value types</a> for more information.</p> <p>Btw, mutable structs like this are generally a really bad idea. They cause all kinds of problems, and hard-to-predict code.</p> <p>EDIT: In response to your "answer", the two lines <em>aren't</em> the same: the <code>a.OtherStruct</code> property expression isn't the target of an assignment operator or a compound assignment operator.</p> <p>You can argue that you'd like C# to be defined in a way which would allow this (although I'd still disagree) but the compiler <em>is</em> implementing the specification correctly. See section 10.7.2 of the C# 3.0 spec for more details.</p>
18,494,356
0
<blockquote> <p>Why doesn't C++ provide us with a constructor which takes an array as an argument?</p> </blockquote> <p>Why would it? A <code>std::set</code> is not an array, and it already has a constructor that takes iterators to initialize it, so adding another constructor for an array is unnecessary. <code>std::vector</code> IS an array and even it does not have a constructor that takes an array.</p> <blockquote> <p>Alternatively, is there anything wrong with defining the following function?</p> </blockquote> <p>Yes and no. It is unnecessary as you can just write</p> <pre><code>MyType myArray[mySize]; std::set&lt;MyType&gt; mySet(myArray, myArray + sizeof(myArray) / sizeof(array[0]); // or std::set&lt;MyType&gt; mySet(myArray, myArray + mySize); // or std::set&lt;MyType&gt; mySet(std::begin(myArray), std::end(myArray)); c++11 </code></pre> <p>It isn't really worthy of its own function.</p> <p>If you really want to write a function to help you out, I'd approach it by porting <code>std::begin</code> and <code>std::end</code> to C++03. Those would at least be more usable than a function specifically to create a <code>std::set</code>.</p> <p>It would look exactly like what Konrad posted in his answer.</p>
30,401,906
0
PyQt4: Where can you make menus? <p>I'm using Python 3 and PyQt4</p> <p>I'm trying to make a simple main window with a menubar. It doesn't work if I try to set up the menubar in the MainWindow initialization but does work if I set it up in some external function. That is, the following does NOT work:</p> <pre><code>import sys from PyQt4 import QtGui class MyMainWindow(QtGui.QMainWindow): def __init__(self, parent=None): super().__init__(parent) centralWidget = QtGui.QWidget() menubar = QtGui.QMenuBar() menu = QtGui.QMenu("File") menu.addAction("New") menubar.addMenu(menu) self.setMenuBar(menubar) self.setCentralWidget(centralWidget) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) mainWindow = MyMainWindow() mainWindow.show() sys.exit(app.exec_()) </code></pre> <p>While if I simply move the menu setup down to the main routine:</p> <pre><code>class MyMainWindow(QtGui.QMainWindow): def __init__(self, parent=None): super().__init__(parent) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) mainWindow = MyMainWindow() centralWidget = QtGui.QWidget() menubar = QtGui.QMenuBar() menu = QtGui.QMenu("File") menu.addAction("New") menubar.addMenu(menu) mainWindow.setMenuBar(menubar) mainWindow.setCentralWidget(centralWidget) mainWindow.show() sys.exit(app.exec_()) </code></pre> <p>Then the menu is created (I know I don't have any actions hooked up, this is stripped down to show the oddity). I thought it might have to do with being in <strong>init</strong> but moving it to another class routine, e.g. setup(self), and then calling that after creating the mainWindow doesn't solve the problem. </p> <p>I seem to be continually baffled by what works and what doesn't in PyQt4. If anyone could point me at some good resources I'd also appreciate it (I've read <strong>Rapid GUI Programming</strong> but find I'm still lost).</p> <p>Thanks in advance for your help</p>
25,358,040
0
AngularJS with ui-router: Changing value of a parent dependency of from child's controller <p><strong>Environment</strong>: AngularJS application (using UI Router) that has nested states.</p> <p><strong>Short version:</strong> How do I change the value of a parent-state's dependency from inside a child's controller, such that siblings of the child state, who are also using the dependency will get the new value.</p> <p><strong>Long version</strong>: Take the following configuration:</p> <pre><code>shopApp.config(function($stateProvider) { $stateProvider.state('shop', { url : '/shop', templateUrl : 'shop.html', resolve : { user : function($q) { // callback that ends up returning null // because the user is not logged in } }, controller: function($scope, user) { // user is null at this point $scope.user = user; } }).state('shop.login', { url : '/login', templateUrl : 'login.html', controller : function($scope) { // onLoggedIn is called from some form-processing // logic once the user has successfully logged in $scope.onLoggedIn = function(userObject) { // I want the shop.userDetails state's controller // to get the new $scope.user value $scope.user = userObject; $state.go('^.userDetails'); }; } }).state('shop.userDetails', { url : '/userDetails', templateUrl : 'userDetails.html', controller : function($scope, user) { // Unfortunately user is null here $scope.user = user; } }); }); </code></pre> <p>The <em>shop.login</em> state's controller has a function called <em>onLoggedIn</em> that's called once the user has logged in successfully. An object containing user-information is passed to this function. From this point on I want all resolutions of the <em>user</em> dependency to use this value (i.e <em>userObj</em>). Unfortunately, instead of using the value that I've just assigned to <em>$scope.user</em>, it seems that the value that gets passed to the controller of <em>shop.userDetails</em> is the one that was originally resolved when the <em>shop</em> state's controller was created.</p> <p>Does anyone know how to do this? If I'm doing this all wrong please tell me.</p>
11,507,316
0
<p>In Netbeans 7.2 it is in Tools-Options-Editor-Formatting-Line Wrap (default off). </p>
29,745,437
0
<p>Pretty late on answering this question. Guess I had never worked on this problem then. But not that I have been looking into it for sometime now, I can share some insight. What @greedybuddha is saying is mostly right, but they are tricks and techniques to prevent creating the tree entirely every time step. As usual these techniques with their own overheads (memory footprint etc) and necessary trade-offs need to be made. Also, it may not be possible to apply them in all situations. </p> <ol> <li><p><strong>Allocate enough memory upfront to handle octree of a given depth. Deallocate the memory only when all timessteps have finished.</strong> For example suppose for all n-body input data sets you are going to use, you know that your Octree will never go beyond a depth of say 10. In that case it is easy to figure out how many maximum nodes you octree might have(usually its a geometric progression sum). By doing a bit of bookkeeping(valid child indexes of each node) for every octree node, it is easy to reuse this buffer to fill in octree nodes without needing to allocate/deallocate octree nodes every timestep. Clearly the likely overhead here is that you might be wasting lot of memory but then you gain performance by not doing allocation/deallocation every timestep Usual way of going about bounding the number of octree levels is to allow multiple bodies per leaf node (last level of octree or smallest cell size of octree grid)</p></li> <li><p><strong>Create a new Octree only when needed</strong>: It is possible to think about a situation where octree doesn't change for some series (burst) of timesteps and then it changes and the pattern repeats. This can happen only when bodies positions change insignificantly over a timestep burst such that octree structure remains the same during that burst. And in what situation will bodies move slowly - when the chosen timestep size is pretty small, forces exerted + initial momentum on bodies is small. How to dynamically figure out such bursts is a difficult problem. This is a more tricky technique and I dont know whats the easy way to do this. This requires some insight of timestep granularity, initial velocity/acceleration of the bodies and kind of forces the bodies are dealing with.</p></li> </ol>
8,137,371
0
wxWidgets OnInit <p>This code works fine:</p> <pre><code>#include &lt;wx/wx.h&gt; class MyApp : public wxApp { virtual bool OnInit(); }; IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { wxFrame *frame = new wxFrame(NULL, -1, _("Hello World"), wxPoint(50, 50), wxSize(450, 350)); frame-&gt;Show(true); return true; } </code></pre> <p>But this doesn't:</p> <pre><code>#include &lt;wx/wx.h&gt; class MyApp : public wxApp { virtual bool OnInit(); }; IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { wxFrame frame(NULL, -1, _("Hello World"), wxPoint(50, 50), wxSize(450, 350)); frame.Show(true); return true; } </code></pre> <p>It doesn't give any compilation/link/execution error, just don't show up the window. Why this?</p>
35,362,525
0
Pipe git diff to git checkout <p>If I delete a file, I can revert it in git with:</p> <pre><code>git checkout filename </code></pre> <p>If I want to revert all deleted files, I can list them with:</p> <pre><code>git diff --diff-filter=D --name-only </code></pre> <p>What I then want to do is restore them, but</p> <pre><code>git diff --diff-filter=D --name-only | git checkout </code></pre> <p>Doesn't work, it only repeats the list to stdout, and git checkout seems to receive no input. Ditto for | git checkout HEAD -- and so on.</p> <p>I've tried this in Windows Command Prompt, in Powershell, and in Git Bash, with the same result each time.</p> <p>How do I correctly pipe input to git checkout?</p>
33,065,635
0
Symfony2 use getDoctrine() in AppKernel to dynamically register bundles <p>I have created an application where I can manage multiple websites. There are a lot of "extensions" (bundles) that can be used in the websites if they have the right to use it. The rights (which website can use wich bundles) are managed in my application and are saved in the database (with the namespace of the allowed bundle). </p> <p><strong>EDIT:</strong> <strike>When I call a website the bundles are loaded in the WebsiteKernel (a normal AppKernel that is commonly used by each website).</strike> <em>Each website has its's own app- and web-folder. So there is a separate app-cache for each website. Each website has it's own WebsiteKernel.php (= a normal AppKernel).</em></p> <p>Now I want to register the allowed bundles for the currently called website dynamically in <strike>the</strike> <em>its</em> WebsiteKernel. In the post "<a href="http://stackoverflow.com/questions/6609240/is-it-possible-to-dynamically-register-bundles-in-symfony2">Is it possible to dynamically register bundles in Symfony2?</a>" this was done by looking into the bundle-directories. I would like to do this the same way but I only want to include the bundles that are saved as "allowed for this website" in the database.</p> <p>To do so I need access to a repository to get the allowed bundle-namespaces. I thought I could do something like <code>$this-&gt;getDoctrine()-&gt;getRepository('MyAppBundle:MyObject');</code> but I don't know how to call this function in the WebsiteKernel (= AppKernel). When I try to call <code>$this-&gt;getDoctrine()</code> I have a UndefinedMethodExeption. Of course I try to do this after the doctrine-bundle has been registered.</p> <p><strong>So the question is: How do I have to change the code in the WebsiteKernel (= AppKernel) to use <code>$this-&gt;getDoctrine()</code>?</strong></p> <p>Btw.: This two posts have a similar problem but they hasn't been answered yet.</p> <ul> <li><a href="http://stackoverflow.com/questions/10572966/symfony2-how-to-dynamically-register-a-bundle-and-clear-the-cache-from-other">Symfony2: How to dynamically register a bundle (and clear the cache) from other bundle&#39;s controller</a></li> <li><a href="http://stackoverflow.com/questions/10060282/symfony2-register-bundle-and-its-routes-at-runtime">Symfony2 register bundle and its routes at runtime</a></li> </ul>
27,015,095
0
<p>do you have an inverseattribute above MenuID in other EF entities? would you have a look at a similar example here: <a href="http://stackoverflow.com/a/25496214/3316279">http://stackoverflow.com/a/25496214/3316279</a>. also this one: <a href="http://stackoverflow.com/a/25646025/3316279">http://stackoverflow.com/a/25646025/3316279</a></p>
1,827,221
0
<p>Wireshark won't help you if you have to debug HTTPS requests (unless you can get the encryption keys for both endpoints - see the Wireshark site for details). Firebug and Tamper Data are getting close, but for thorough analysis, I sometimes like to save a recorded session. I'd recommend giving <a href="https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project" rel="nofollow noreferrer">the OWASP Zed Attack Proxy</a> (the successor of <a href="http://www.parosproxy.org/" rel="nofollow noreferrer">Parosproxy</a>, which is no longer actively developed) a try. It is a Java application serving as a http(s) proxy; it provides quite a lot of features and proved to be very helpful to me in the past.</p> <p>ZAP offers an easy autoconfiguration of Firefox. Bear in mind to do that on a separate (meaning: not for other browsing activities) Firefox profile: In order to intercept https, ZAP will install a new SSL certificate.</p>
12,848,567
0
<p>Give your <code>cell</code> class an <code>address</code> attribute, which is a two-tuple, e.g. <code>(0,0)</code>. Give the <code>cell</code> class a <code>__hash__</code> method, which returns <code>hash(self.address)</code>.</p> <pre><code>class cell: def __init__(self,address): self.address = address def __hash__(self): return hash(self.address) def __eq__(self): return hash(self) == hash(other) </code></pre> <p>You can still access cells by their address, but the cells know where they belong.</p> <pre><code>&gt;&gt;&gt; c = cell((0,0)) &gt;&gt;&gt; c &lt;so.cell instance at 0xb74c6a2c&gt; &gt;&gt;&gt; grid = dict() &gt;&gt;&gt; grid[c] = c &gt;&gt;&gt; grid[c] &lt;so.cell instance at 0xb74c6a2c&gt; &gt;&gt;&gt; grid[(0,0)] &lt;so.cell instance at 0xb74c6a2c&gt; </code></pre> <p>I'm not sure what else your <code>cell</code>s need to know and/or do, but if you're just doing numerical stuff here, I'd highly recommend the <a href="http://docs.scipy.org/doc/scipy/reference/sparse.html" rel="nofollow">scipy.sparse</a> module.</p>
5,630,312
0
Simple MySQL/AJAX Search Box question <p>I am making a simple search box on my web site. I followed a tutorial <a href="http://teamtutorials.com/web-development-tutorials/php-tutorials/creating-a-form-that-will-search-a-mysql-database" rel="nofollow">here</a></p> <p>I just need to query id numbers from a certain table in the database and display the EXACT results right beneath the searchbox</p> <p>you can see it here:</p> <p><a href="http://4evergreengroup.com/temp/" rel="nofollow">http://4evergreengroup.com/temp/</a></p> <p>click on "instant verification" and I want the search box that pops up to display its results right beneath and still remain in the fancybox</p>
21,849,147
0
<p>Sure</p> <pre><code>SELECT column1, MIN(column2) FROM your_table GROUP BY column1 </code></pre> <p>Since you don't care which <code>column2</code> value you get, you could also use <code>MAX</code> or many other aggregate functions instead of <code>MIN</code>.</p>
11,653,390
0
<p>Not the best way, and probably not very good if the tree is big, but you can create a recursive function like :</p> <pre><code>public String ToString() { return id + "{" + a.ToString() + ";" + b.ToString() + "}"; } </code></pre> <p>With : <code>id</code> the id of the current node, <code>a</code> and <code>b</code> the two child</p> <p><strong>EDIT</strong></p> <p>You need to be absolutely sure that this is a tree and that it does not contains any cycle.</p>