pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
3,342,725
0
<p><code>DataTable</code> derives from <code>Object</code>, so can be assigned to any <code>Object</code> variable.</p> <p>From MSDN (<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx" rel="nofollow noreferrer">DataSource</a>):</p> <blockquote> <p>The DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:</p> <ul> <li>The IList interface, including one-dimensional arrays.</li> <li>The IListSource interface, such as the DataTable and DataSet classes.</li> <li>The IBindingList interface, such as the BindingList class.</li> <li>The IBindingListView interface, such as the BindingSource class.</li> </ul> </blockquote>
22,861,331
0
<p>The "traditional" ways of using <code>AssemblyName.GetAssemblyName(string)</code> or <code>FileVersionInfo</code> won't work as they aren't supported on .NET CF. To do this without using <code>Assembly.LoadFrom</code>, you will need to use P/Invoke to natively get the file version information. You can try this code (<em><strong>untested</strong></em>):</p> <pre><code>[DllImport("coredll", EntryPoint = "GetFileVersionInfo", SetLastError = true)] private static extern bool GetFileVersionInfo(string filename, int handle, int len, IntPtr buffer); [DllImport("coredll", EntryPoint = "GetFileVersionInfoSize", SetLastError = true)] private static extern int GetFileVersionInfoSize(string filename, ref int handle); [DllImport("coredll", EntryPoint = "VerQueryValue", SetLastError = true)] private static extern bool VerQueryValue(IntPtr buffer, string subblock, ref IntPtr blockbuffer, ref int len); public static Version GetFileVersionCe(string fileName) { int handle = 0; int length = GetFileVersionInfoSize(fileName, ref handle); Version v = null; if (length &gt; 0) { IntPtr buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(length); if (GetFileVersionInfo(fileName, handle, length, buffer)) { IntPtr fixedbuffer = IntPtr.Zero; int fixedlen = 0; if (VerQueryValue(buffer, "\\", ref fixedbuffer, ref fixedlen)) { byte[] fixedversioninfo = new byte[fixedlen]; System.Runtime.InteropServices.Marshal.Copy(fixedbuffer, fixedversioninfo, 0, fixedlen); v = new Version( BitConverter.ToInt16(fixedversioninfo, 10), BitConverter.ToInt16(fixedversioninfo, 8), BitConverter.ToInt16(fixedversioninfo, 14), BitConverter.ToInt16(fixedversioninfo, 12)); } } Marshal.FreeHGlobal(buffer); } return v; } </code></pre>
18,687,333
0
<p><code>QString</code> offers the <code>arg</code> function:</p> <pre><code>QString("~Untitled %1").arg(armaTab-&gt;currentIndex() + 1) </code></pre>
13,398,017
0
<p>Since this </p> <p><code>$("#offerd_desc li").css('opacity', '0');</code></p> <p>Sets the opacity INSTANT to 0, you would use the animation();</p> <pre><code>$("#offerd_desc li").mouseover({ $(this).stop().animate({opacity:0.5},500); }); $("#offerd_desc li").mouseout({ $(this).stop().animate({opacity:0.5},500); }); </code></pre> <p>Use stop() before you do animation, else it will cause flickering when you hover it fast. and i strongly recommend to use speeds such as 200 - 500 ms, cause else animation will take to long time.</p>
687,383
0
<p>First get the Type object using <code>Type.GetType(stringContainingTheGenericTypeArgument)</code></p> <p>Then use <code>typeof(Repository&lt;&gt;).MakeGenericType(theTypeObject)</code> to get a generic type.</p> <p>And finally use <code>Activator.CreateInstance</code></p>
13,352,986
0
<p>There is no way to do this. Must be done manually.</p>
5,021,275
0
Accessing NI-VISA from Qt C++ 4.7 <p>I am developing a Windows (7) application using Qt (4.7.0) to call some methods in a DLL (NI visa32.dll) to communicate with instruments through the GPIB port. The manufacturer's header file is also available (visa.h).</p> <p>In the project file, I tried adding the path and library reference to the original places where the files are located at as:</p> <pre><code>INCLUDEPATH += "C:/Program Files/National Instruments/Shared/CVI/Include" LIBS += "C:/Windows/System32/visa32.dll" </code></pre> <p>but, I get the compilation error:</p> <pre><code>collect2: ld returned 1 exit status </code></pre> <p>Following the instructions in <a href="http://stackoverflow.com/questions/2590299/importing-dll-into-qt">Importing a DLL into Qt</a>, I created a "visa.a" from the "visa32.dll", and copied them to a subfolder "visa/lib", and added the path and library to the project file:</p> <pre><code>INCLUDEPATH += visa/include LIBS += -Lvisa/lib LIBS += -lvisa.a </code></pre> <p>I tried also with <code>-lvisa</code> or <code>-lvisa.dll</code>, but in all the cases I get also another compilation error saying that the <code>-lvisa</code>, <code>-lvisa.a</code> or <code>-lvisa.dll</code> is not found. I edited the original header file "visa.h", and prefixed with Q_DECL_IMPORT every object in the file, and also made sure that the extern "C" statement be present.</p> <p>I include the reference to the header file in the application as:</p> <pre><code>#include "visa.h" </code></pre> <p>and note that the compiler does recognize the referenced objects belonging to the visa.h file.</p> <p>Any help to solve this compilation error will be greatly appreciated.</p> <hr> <p>I also tried with Visual C++ (2010) following the instructions of <a href="http://stackoverflow.com/questions/809948/dll-references-in-visual-c">DLL References in Visual C++</a>. In this case, I do not get any compilation error, but linking errors. For example: </p> <pre><code>AgiE364X.obj: error LNK2019: unresolved external symbol "extern "C" long __stdcall viClose(unsigned long)" </code></pre> <p>being viClose a called method in NI-VISA. </p> <p>I would prefer to use Qt C++ instead of Visual C++, though. </p> <p>Thanks in advance.</p>
27,345,140
0
<p>Try putting in a break.</p> <pre><code>// As a side note: you can check at the very beginning to see that // the ID isn't being compromised by something by checking if // is_numeric. Also, you can save your 'fail' message until the very // end when checking that your $leadsource isset. These extra points // are not essential, but they will throw a fail at all points of the // code (if that is valuable at all to you) $sourcetracking = (isset($_GET['id']) &amp;&amp; is_numeric($_GET['id']))? $_GET['id']:false; if($sourcetracking !== false) { $LegacyIDLookupArray = array( '2612' =&gt; 'ADV-ShowProg', '2462' =&gt; 'ADV-ShowProg-3.5x7', '2422' =&gt; 'ADV-Mag-book' ); foreach ($LegacyIDLookupArray as $LegacyID =&gt; $Oldleadsource) { if($sourcetracking == $LegacyID) { $leadsource = &amp;$Oldleadsource; // This is where the break goes to stop your loop // when condition is met break; } } } // Your $leadsource OR fail is echoed here. echo (isset($leadsource))? $leadsource : "fail"; </code></pre>
3,696,383
0
Grails: Is there a debug flag I can check? <p>I have a few log.debugs() that I don't want to process (since they are heavy) unless the app is currently in debug mode (not production). </p> <p>Is there a way to check if the grails app is currently in debug mode/development mode?</p>
34,854,415
0
<p>Do not use functions in templates when you can avoid this.</p> <pre><code>&lt;select ng-model="template"&gt; &lt;option value="test.html"&gt;first&lt;/option&gt; &lt;option value="test2.html"&gt;second&lt;/option&gt; &lt;/select&gt; &lt;div ng-include="template"&gt;&lt;/div&gt; </code></pre> <p><a href="http://plnkr.co/edit/osB9UiSzvF4IoqkizcOP?p=preview" rel="nofollow">http://plnkr.co/edit/osB9UiSzvF4IoqkizcOP?p=preview</a></p>
6,897,996
0
<pre><code>- (IBAction)own { if (thing.hidden == NO) { int rNumber = rand() % 4; NSString *myText = @""; // switch (rNumber) { case 0: myText = @"A"; break; case 1: myText = @"B"; break; case 2: myText = @"C"; break; case 3: myText = @"D"; break; default: break; } result.text = myText; } if (thing.hidden == YES) { int rNumber = rand() % 3; </code></pre>
32,512,845
0
<p>The two standard patterns for High Availability NAT are:</p> <ul> <li><a href="https://aws.amazon.com/articles/2781451301784570" rel="nofollow">High Availability for Amazon VPC NAT Instances: An Example</a></li> <li><a href="https://aws.amazon.com/articles/5995712515781075" rel="nofollow">Using Squid Proxy Instances for Web Service Access in Amazon VPC: An Example</a> (Uses proxies instead of route tables, I think)</li> </ul> <p>If you are using the NAT for traffic to Amazon S3, you can also take advantage of <a href="https://aws.amazon.com/blogs/aws/new-vpc-endpoint-for-amazon-s3/" rel="nofollow">VPC Endpoint for S3</a> to reduce the reliance on having a HA NAT.</p>
18,557,551
0
<p>Because the connection <em>is</em> established. Calling accept() isn't a pre-requisite for that. The system accepts incoming connections and enqueues them to the backlog queue. Calling accept() just removes an item from the queue, blocking while it is empty.</p>
3,491,746
0
<p>Edit: Actually I can get this error message by using a scalar function as if it was a table valued function. </p> <p><strong>Don't use</strong></p> <pre><code>SELECT * from [dbo].[calculatecptcodeprice] (...) </code></pre> <p><strong>Use</strong></p> <pre><code>SELECT [dbo].[calculatecptcodeprice] (...) </code></pre> <p><strong>Other things to check</strong></p> <ol> <li>Permissions</li> <li>You are prefixing the function with the schema name when you use it.</li> <li>You are trying to use it from within the same database as you created it.</li> </ol>
32,850,431
0
<p>Constructors are used to generate the "default" values in an object.<br> Once created, however, "getters" and "setters" are simply methods that allow you to access private members of that object. They're named as such because one name their methods <code>getValue()</code> to get a private variable named value from an object or <code>setValue(int)</code> to set it.</p> <p>It is often also convenient to do error-checking in these methods, and to call a selection of "setters" in the constructor to save on code or easily create multiple constructors.</p> <p>Here is an example:</p> <pre><code>class MyClass { private: int value; public: MyClass(int); void setValue(int); int getValue(); }; MyClass::MyClass(int _value) { setValue(_value); // pass to "setter" } void MyClass::setValue(int _value) { if (_value &gt; 0) // error-checking here value = _value; else value = 0; } int MyClass::getValue() { return value; } </code></pre>
30,651,349
0
Calculating cumulative hypergeometric distribution <p>Suppose I have 100 marbles, and 8 of them are red. I draw 30 marbles, and I want to know what's the probability that at least five of the marbles are red. I am currently using <a href="http://stattrek.com/online-calculator/hypergeometric.aspx" rel="nofollow">http://stattrek.com/online-calculator/hypergeometric.aspx</a> and I entered 100, 8, 30, and 5 for population size, number of success, sample size, and number of success in sample, respectively. So the probability I'm interested in is Cumulative Probability: $P(X \geq 5)$ which = 0.050 in this case. My question is, how do I calculate this in R?</p> <p>I tried</p> <pre><code>&gt; 1-phyper(5, 8, 92, 30, lower.tail = TRUE) [1] 0.008503108 </code></pre> <p>But this is very different from the previous answer.</p>
19,196,481
0
<p><code>DateTime</code> is a value type object which mean that you cannot set it's value to <code>null</code>.</p> <p>Use the <code>DBNull.Value</code> to assign the data. </p> <hr> <p><a href="http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx" rel="nofollow">Value Types</a></p>
19,934,433
0
<p>I have found that the issue lies with the references to icon files and an older version of the jquery library being used. I'm still not sure why it wasn't an issue for IE, but was for chrome. </p> <p>My theory on why the incorrect reference to the icon file was causing a problem was that when no icons were rendered on the Dynatree object, Chrome did not insert any "pixel address" on which to click. I realize that is not the correct term, but it is my theory. In IE, it did not seem to be a problem.</p> <p>When I rendered the page after correcting the reference to the icon file, all worked as expected.</p>
40,625,227
0
Multithreading in windows service <p>I am designing a solution for a client where in data has to be polled from SQL table and a request is to be sent to a WCF service with a request formed from that data. The response of the WCF service will contain additional data that has to be updated in the SQL table again.</p> <p>For e.g. in TableA there are 6 columns namely primaryKeyColumn,columnA, columnB, columnC, columnD and columnE.</p> <p>The WCF request will contain data from columns A,B and C. The service response will contain data for all 5 columns. The data of columns D and E needs to be updated for that row in the tableA.</p> <p>I have thought of implementing this using Windows service. To increase the performance I am thinking to implementing multi threading in this solution.</p> <p>Can some one guide me in this ? I have never used multi threading in windows service before. What are the risks ?</p>
37,526,756
0
<p>Use Google Place api will help you to know about particular place <a href="https://developers.google.com/maps/documentation/android-api/infowindows#custom_info_windows" rel="nofollow">link</a></p>
2,406,931
0
how to solve ran time error NSString, sqlite3_column_text NULL problem? <p>I am new in iphone application developer i am using sqlite3 database and in app delegate i am wright following code and run properly we also find value from database to in my aplication, </p> <p>but immediately the application is going to crass why this is occurs i am not understand. </p> <p>code is given bellow</p> <pre><code> -(void)Data { databaseName = @"dataa.sqlite"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; databasePath =[documentsDir stringByAppendingPathComponent:databaseName]; [self checkAndCreateDatabase]; list1 = [[NSMutableArray alloc] init]; sqlite3 *database; if (sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK) { if(detailStmt == nil) { const char *sql = "Select * from Dataa"; if(sqlite3_prepare_v2(database, sql, -1, &amp;detailStmt, NULL) == SQLITE_OK) { //NSLog(@"Hiiiiiii"); //sqlite3_bind_text(detailStmt, 1, [t1 UTF8String], -1, SQLITE_TRANSIENT); //sqlite3_bind_text(detailStmt, 2, [t2 UTF8String], -2, SQLITE_TRANSIENT); //sqlite3_bind_int(detailStmt, 3, t3); while(sqlite3_step(detailStmt) == SQLITE_ROW) { //NSLog(@"Helllloooooo"); NSString *item= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 0)]; //NSString *fame= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 1)]; //NSString *cinemax = [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 2)]; //NSString *big= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 3)]; //pvr1 = pvr; item1=item; //NSLog(@"%@",item1); data = [[NSMutableArray alloc] init]; list *animal=[[list alloc] initWithName:item1]; // Add the animal object to the animals Array [list1 addObject:animal]; //[list1 addObject:item]; } sqlite3_reset(detailStmt); } sqlite3_finalize(detailStmt); // sqlite3_clear_bindings(detailStmt); } } detailStmt = nil; sqlite3_close(database); </code></pre> <p>}</p> <p>when we see console they show the following error giving bellow </p> <pre><code> 2010-03-09 10:02:40.262 SanjeevKapoor[430:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString' </code></pre> <p>when we see debugger they show error in following line</p> <pre><code> NSString *item= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 0)]; </code></pre> <p>I am not able to solve that problum plz help me.</p>
30,193,970
0
Animate when the first image is loaded <p>I want to animate an element only when this element is loaded ( with the background ). I tryed this but doesn't work:</p> <p>CSS:</p> <pre><code>#topimg{ background: rgba(0, 0, 0, 0) url(../img/bg.jpg) 0 0 no-repeat fixed; background-size: cover; } </code></pre> <p>HTML:</p> <pre><code>&lt;div id="topimg"&gt; &lt;/div&gt; </code></pre> <p>JAVASCRIPT:</p> <pre><code>$('#topimg').load(function() { $('#topimg').css({opacity: 0}).animate({opacity: 1}, {duration: 1500}); }); </code></pre>
39,439,488
0
Include LaTeX code from R objects into markdown <p>I am writing up a report where the output gets pushed to a <code>xlsx</code> document via <code>library(xlsx)</code>. This data then feeds into a table especially formatted with LaTeX code that formats the output:</p> <pre><code>```{r import_results, echo = F} if(!file.exists("Analysis/results.xlsx")){ wb &lt;- xlsx::createWorkbook(type = "xlsx") sheets &lt;- xlsx::createSheet(wb, "data") }else{ wb &lt;- loadWorkbook("Analysis/results.xlsx") sheets &lt;- removeSheet(wb, "data") sheets &lt;- xlsx::createSheet(wb, "data") } getSheets(wb) addDataFrame(sheet = sheets, x = Results1) addDataFrame(sheet = sheets, x = Results2, startRow = nrow(Results1)+2) addDataFrame(sheet = sheets, x = Results3, startRow = nrow(Results1)+ nrow(Results2) + 4) xlsx::saveWorkbook(wb, "Analysis/results.xlsx") } </code></pre> <p><a href="https://i.stack.imgur.com/C57f1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C57f1.jpg" alt="Excel view"></a> After writing to sheet that table data is linked to, I read it back into R, now with all the LaTeX in the cells and in essence I want to <code>cat</code> results so they are LaTeX code, but it prints the <code>data.frame</code> as a long string when I <code>knit</code>:</p> <pre><code>```{r, echo = F, results='asis'} wb &lt;- read.xlsx("Analysis/results.xlsx", sheetName = "import", header=F) row.names(wb) &lt;-NULL wb ``` </code></pre> <p><a href="https://i.stack.imgur.com/Fwk7K.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fwk7K.jpg" alt="Output"></a></p> <p>What is the appropriate way to automate this cross platform integration?</p>
38,330,493
1
How can I acquire data from live experimentation and do a live 2D plot using threads? <p>I need to take data from an instrument and live 2D plot them. I can do it without threads, but it is slow ... How could I proceed without having errors like "QObject::setParent: Cannot set parent, new parent is in a different thread", "QApplication: Object event filter cannot be in a different thread" and "QPixmap: It is not safe to use pixmaps outside the GUI thread". I used this code as a test:</p> <pre><code> import threading import time import numpy as np import matplotlib.pyplot as plt class myThread (threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter s=(6,6) self.x=np.zeros(s) def run(self): print "Starting " + self.name threadLock.acquire() if self.threadID==1: acquire_data(self.x) count_to_three(self.name,1) plot_it(self.x) count_to_three(self.name,1) print "Exiting "+ self.name if self.threadID==2: count_to_three(self.name,1) print "Exiting "+ self.name threadLock.release() def print_time(threadName, delay, counter): while counter: time.sleep(delay) print "%s: %s" % (threadName, time.ctime(time.time())) counter -= 1 def count_to_three(threadName,delay): i=0 while i&lt;4: time.sleep(delay) print"%s: %s" % (threadName,i) i+=1 def acquire_data(x): return def plot_it(x): sidex = np.linspace(0,6,6) sidey = np.linspace(0,6,6) X,Y = np.meshgrid(sidex,sidey) plt.subplot(111) plt.pcolormesh(X,Y,x) return # Create new threads plt.figure() threadLock=threading.Lock() while True: threads=[] thread1 = myThread(1, "Thread-1", 3) thread2 = myThread(2, "Thread-2", 2) # Start new Threads thread1.start() thread2.start() # Add threads to thread list threads.append(thread1) threads.append(thread2) for t in threads: plt.show() t.join() </code></pre>
16,248,115
0
<pre><code>"select * from products where 1".cleanstring($stringval); function cleanstring($var) { $color_list = array('GOLD','RED','GREEN','WHITE'); $sql_where=''; foreach( $color_list AS $v){ if(strpos($var, $v)!==false){ $sql_where .=" AND color LIKE '%{$v}%'"; } } return $sql_where; } //select * from products where 1 OR color LIKE '%GOLD%' OR color LIKE '%RED%' </code></pre> <p>REMARK:</p> <p>input: GOLDRED ,</p> <p>match: GOLD RED,GOLD-RED,GOLD/RED..... GOLD/RED/ABC,RED_GOLDGREEN, </p> <p>may be after get all data , then make func ranking by match % ,like search engine </p>
36,224,422
1
Python Turtle Positional Errors <p>I've been trying to scale a Turtle drawing by a single axis and after some testing, I managed the following function:</p> <pre><code>def DrawSquare(length=50.0, Yscale=2): setheading(0) for n in range(0,4): oldYcor = int(ycor()) oldPos = pos() penup() forward(length) newYcor = int(ycor()) print 'OldYcor = ', int(oldYcor) print 'NewYcor = ', int(newYcor) print '------' setpos(oldPos) pendown() if (oldYcor == newYcor): print 'dont scale' forward(length) elif (oldYcor != newYcor): print 'scale' forward(length*Yscale) left(90) penup() speed('slowest') goto(0,0) #TESTS DrawSquare(50.0, 2) DrawSquare(50.0, 2) DrawSquare(50.0, 2) DrawSquare(50.0, 2) </code></pre> <p>The output of these tests should just be four overlapping squares scaled on the y axis, but for some very strange reason Python is randomly changing my Y values before and after a movement by 1 unit, when they should be the same. (for instance, a line being drawn horizontally has an oldYcor of 99, but a newYcor of 100), which completely breaks my code and produces the squares out of place.</p> <p>Another strange thing i noticed is that without converting the turtle's ycor() to an int, the print statements display some bizarre values that dont make any sense to me...</p> <p>I appreciate any help!!</p>
3,499,987
0
<p>You need the GLOBAL <code>g</code> switch.</p> <p>s/^#(.+)/$1/g</p>
5,411,757
1
Problem writing unicode UTF-16 data to file in python <p>I'm working on Windows with Python 2.6.1.</p> <p>I have a Unicode UTF-16 text file containing the single string Hello, if I look at it in a binary editor I see:</p> <pre><code>FF FE 48 00 65 00 6C 00 6C 00 6F 00 0D 00 0A 00 BOM H e l l o CR LF </code></pre> <p>What I want to do is read in this file, run it through Google Translate API, and write both it and the result to a new Unicode UTF-16 text file.</p> <p>I wrote the following Python script (actually I wrote something more complex than this with more error checking, but this is stripped down as a minimal test case):</p> <pre><code>#!/usr/bin/python import urllib import urllib2 import sys import codecs def translate(key, line, lang): ret = "" print "translating " + line.strip() + " into " + lang url = "https://www.googleapis.com/language/translate/v2?key=" + key + "&amp;source=en&amp;target=" + lang + "&amp;q=" + urllib.quote(line.strip()) f = urllib2.urlopen(url) for l in f.readlines(): if l.find("translatedText") &gt; 0 and l.find('""') == -1: a,b = l.split(":") ret = unicode(b.strip('"'), encoding='utf-16', errors='ignore') break return ret rd_file_name = sys.argv[1] rd_file = codecs.open(rd_file_name, encoding='utf-16', mode="r") rd_file_new = codecs.open(rd_file_name+".new", encoding='utf-16', mode="w") key_file = open("api.key","r") key = key_file.readline().strip() for line in rd_file.readlines(): new_line = translate(key, line, "ja") rd_file_new.write(unicode(line) + "\n") rd_file_new.write(new_line) rd_file_new.write("\n") </code></pre> <p>This gives me an almost-Unicode file with some extra bytes in it:</p> <pre><code>FF FE 48 00 65 00 6C 00 6C 00 6F 00 0D 00 0A 00 0A 00 20 22 E3 81 93 E3 82 93 E3 81 AB E3 81 A1 E3 81 AF 22 0A 00 </code></pre> <p>I can see that 20 is a space, 22 is a quote, I assume that "E3" is an escape character that urllib2 is using to indicate that the next character is UTF-16 encoded??</p> <p>If I run the same script but with "cs" (Czech) instead of "ja" (Japanese) as the target language, the response is all ASCII and I get the Unicode file with my "Hello" first as UTF-16 chars and then "Ahoj" as single byte ASCII chars.</p> <p>I'm sure I'm missing something obvious but I can't see what. I tried urllib.unquote() on the result from the query but that didn't help. I also tried printing the string as it comes back in f.readlines() and it all looks pretty plausible, but it's hard to tell because my terminal window doesn't support Unicode properly.</p> <p>Any other suggestions for things to try? I've looked at the suggested dupes but none of them seem to quite match my scenario.</p>
22,641,032
0
<p>Do you have the SVN Ant tasks defined? In our build we have this line at the top:</p> <pre><code>&lt;typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpath="svnant.jar"/&gt; </code></pre> <p>and then we can reference the task just fine.</p>
30,965,893
0
Swift Error: Consecutive declarations on a line must be separated by ';' <p>This is my code:</p> <pre><code>import UIKit class PlaylistMasterViewController: UIViewController { @IBOutlet weak var abutton: UIButton! override func viewDidLoad() { super.viewDidLoad() abutton.setTitle("Press me!", forState: .Normal) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "showPlaylistDetailSegue" { let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController playlistDetailController.segueLabelText = "Yay!You Pressed" } } </code></pre> <p>I am getting error on the last line! my xCode version is 6.3.2 .. and I can't overcomer this because the app is always failing. I am getting here two errors: 1- Consecutive declarations on a line must be separated by ';' 2- Expected Declaration</p> <p>Thanks in advance</p>
25,363,871
0
NA/NaN/Inf error when fitting HMM using depmixS4 in R <p>I'm trying to fit simple hidden markov models in R using depmix. But I sometimes get obscure errors (Na/NaN/Inf in foreign function call). For instance</p> <pre><code> require(depmixS4) t = data.frame(v=c(0.0622031327669583,-0.12564002739468,-0.117354660120178,0.0115062213361335,0.122992418345013,-0.0177816909620965,0.0164821157439354,0.161981367176501,-0.174367935386872,0.00429417498601576,0.00870091566593177,-0.00324734222267713,-0.0609817740148078,0.0840679943325736,-0.0722982123741866,0.00309386232501072,0.0136237132601905,-0.0569072400881981,0.102323872007477,-0.0390675463642003,0.0373248728294635,-0.0839484669503484,0.0514620475651086,-0.0306598076180909,-0.0664992242224042,0.826857872461293,-0.172970803143762,-0.071091459861684,-0.0128631184461384,-0.0439382422065227,-0.0552809574423446,0.0596321725192134,-0.06043926984848,0.0398700063815422)) mod = depmix(response=v~1, data=t, nstates=2) fit(mod) ... NA/NaN/Inf in foreign function call (arg 10) </code></pre> <p>And I can have input of almost identical size and complexity work fine...Is there a preferred tool to depmixS4 here?</p>
32,758,318
0
<p>You can use <code>godep save</code> in your local pc where you complete your program. godep save collect all the dependency files for you. When you move to other pc, just copy the Godep folder with your code and it will solve your problems.</p>
911,612
0
<p>Project Euler isn't fond of discussing problems on public forums like StackOverflow. All tasks are made to be done solo, if you encounter problems you may ask help for a specific mathematical or programming concept, but you can't just decide to ask how to solve the problem at hand - takes away the point of project Euler.</p> <p>Point is to learn and come up with solutions yourself, and learn new concepts.</p>
40,908,974
0
Extjs 5 - Date picker year only <p>I would like date picker without day or month, just with year.</p> <p>I would like this </p> <p><a href="http://stackoverflow.com/questions/28167452/extjs-5-date-picker-year-and-month-only">EXTJS 5 - Date picker year and month only</a> </p> <p>but without month, just year.</p> <p>Thanks</p>
21,593,785
0
<p>You need to add <code>- (IBAction)filebrowserbutton:(id)sender;</code> to your header file and connect it to your button's <code>touchDown</code> method.</p>
17,814,498
0
<p>Add</p> <pre><code>gem 'therubyracer' </code></pre> <p>to your <code>Gemfile</code>. Then run</p> <pre><code>bundle </code></pre> <p>The error occurs because you don't have JavaScript runtime environment, which is needed by <code>Asset Pipeline</code>. </p>
31,248,792
0
Mysql ssl connection with real connect giving error <p>I am getting this error while trying to connect mysql on SSL.</p> <blockquote> <p>Warning: mysqli_real_connect() [function.mysqli-real-connect]: SSL operation failed with code 1. OpenSSL Error messages: error:14082174:SSL routines:SSL3_CHECK_CERT_AND_ALGORITHM:dh key too small in /usr/www/test/testing.php on line 13</p> </blockquote> <p>This works fine on my local wamp or xampp but not on the hosting web server</p> <p>What can be done to solve this ? Any help will be appreciated.</p> <p><strong>After Notes -</strong></p> <p>I was originally using </p> <pre><code>$db-&gt;ssl_set('client-key.pem', 'client-cert.pem', 'ca-cert.pem', NULL, 'NULL'); </code></pre> <p>and it used to work fine for years but only after we upgraded to different SSL certs it stopped working. </p> <p>It should be what Mel_T just answered.. </p>
11,749,138
0
Automatic dependencies in TeamCity (or other continuous build)? <p>I'm thinking of implementing a really large continuous build at work (hundreds of Visual Studio solutions, thousands of projects). It includes .NET, C++, and VB6 code. We have some solutions building on TeamCity, but dependencies aren't set up right. Keeping the dependencies in sync between source code and TeamCity (or another tool) sounds totally unrealistic at this scale. <strong>Does anyone know if there is a tool/plugin to detect solution dependencies automatically in TeamCity? How about with other continuous integration tools?</strong> Even if it only works on .NET projects, that would still be a big help.</p> <p>I found a small, command line tool (<a href="http://gittup.org/tup" rel="nofollow">gittup.org/tup</a>) that says it infers dependencies by monitoring file access. It seems possible to apply this technique to a larger scale build tool, but I don't know if it's been done. Or maybe there is a whole other solution out there.</p>
19,165,257
0
C++ template issue to Pull Up the Builder pattern into a configuration? <p>I have an algorithm that requires a large number of parameters (i.e. configuration) as part of its constructor and also requires some clearly defined creational steps. Therefore I have created a <a href="http://en.wikipedia.org/wiki/Builder_pattern" rel="nofollow">Builder Pattern</a> implementation that allows to set the needed parameters and create the intermediate and final instance e.g.</p> <pre><code>// somewhere class SomeAlgo { public: SomeAlgo(double a, double b, double c, double d, double e /* etc */); ; </code></pre> <p>Now I define the Builder to be e.g.</p> <pre><code>class SomeAlgoBuilder { public: SomeAlgo&amp; createResult() { /* TODO: */ } virtual SomeAlgoBuilder&amp; creationStep1() = 0; virtual SomeAlgoBuilder&amp; creationStep2() = 0; virtual SomeAlgoBuilder&amp; creationStep3() = 0; // example setter note the builder returns *this SomeAlgoBuilder&amp; setA(double a) { a_ = a; return *this; } SomeAlgoBuilder&amp; setB(double b) { b_ = b; return *this; } // etc }; </code></pre> <p>At this point everything looks ok but now I would like to <code>Pull Up</code> the setters of the builder into a <code>SomeAlgoConfig</code> class so that I can also cover the use-case of passing around a simple configuration instead of a convoluted long list of parameters. This simple configuration is what in Java is known as a Value Object or Bean. The new Builder would be like this:</p> <pre><code>// not "is a" config but need the implementation inheritance // &gt;&gt;&gt;&gt;&gt;&gt; note the need to pass SomeAlgoBuilder as template class SomeAlgoBuilder : private SomeAlgoConfig&lt;SomeAlgoBuilder&gt; { public: SomeAlgo&amp; createResult() { /* TODO: */ } virtual SomeAlgoBuilder&amp; creationStep1() = 0; virtual SomeAlgoBuilder&amp; creationStep2() = 0; virtual SomeAlgoBuilder&amp; creationStep3() = 0; }; </code></pre> <p>Now the <code>SomeAlgoConfig</code> implementation:</p> <pre><code>template&lt;T&gt; class SomeAlgoConfig { T&amp; setA(double a) { a_ = a; return *static_cast&lt;T*&gt;(this); } T&amp; setB(double b) { b_ = b; return *static_cast&lt;T*&gt;(this); } // etc } </code></pre> <p>and the intent is to be used like this:</p> <pre><code>SomeAlgoConfig config; // &lt;&lt;&lt; here it won't compile because it misses the T parameter config.setA(a).setB(b).setC(c); </code></pre> <p>This will do the trick I guess. However, whenever I'd like to use <code>SomeAlgoConfig</code> on its own (outside the context of a Builder) e.g. to pass it as parameter I need to declare it with a template parameter which would be itself <code>SomeAlgoConfig&lt;SomeAlgoConfig&gt;</code>. How can I define it in a way that it defaults to itself as template type? e.g. doing this doesn't work: <code>template&lt;typename T = SomeAlgoConfig&gt; class SomeAlgoConfig</code> because the <code>SomeAlgoConfig</code> is not yet known at that point. </p>
30,985,073
0
WAMP crashed after computer shutted down <p>Wamp doesn't work since my computer suddenly shutted down (having run Wamp), yet before that it was working fine. The system is Win7 64-bit.</p> <p>I'd installed again Wamp x64, problem hadn't been solved. I did the same with Wamp x32 but problem still was current.</p> <p>When I select <code>Apache-&gt;Service-&gt;Test Port 80</code>, I get <code>Your port 80 is not actually used</code>. When it is <code>Apache-&gt;Service-&gt;Install service</code>, I get <code>Your port 80 is available, Install will proceed</code>. After restart nothing gets turn to the better.</p> <p>Moreover, when I get in <code>Apache-&gt;Modules</code>, there is exclamation mark in red triangle next to 4 Apache modules: <code>auth_form_module</code>, <code>cache_socache_module</code>, <code>macro_module</code>, <code>proxy_wstunnel_module</code>. In the past, about 1 installation back, I couldn't connect to MySQL.</p> <p><strong>Port 80 is NOT used</strong> by Skype, IIS or whatever else - I've checked it by various methods. No firewall or antivirus hits the spot - before it was running with no problem.</p> <p>Doings in <code>httpd.conf</code>, including changing port number to 8080 or 81, brings no progression.</p> <p>I walked through half of internet but no solution solves the problem. Wamp icon is still red, when i hit <code>localhost</code>, <em>NOT FOUND</em> is printed.</p>
13,393,751
0
Change values in <td>'s with jquery <p>I have a table of values. Is it possible with JQuery by clicking on currency link to change value in cells with exchange rates? This static example table</p> <pre><code>&lt;table border="1"&gt; &lt;tr&gt; &lt;td class="currency"&gt;100&lt;/td&gt; &lt;td class="currency"&gt;200&lt;/td&gt; &lt;td class="current"&gt;now in USD&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="currency"&gt;150&lt;/td&gt; &lt;td class="currency"&gt;230&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="currency"&gt;400&lt;/td&gt; &lt;td class="currency"&gt;200&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="currency"&gt;550&lt;/td&gt; &lt;td class="currency"&gt;2920&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;a href="#" class="USD"&gt;USD&lt;/a&gt; &lt;a href="#" class="EUR"&gt;EUR&lt;/a&gt; </code></pre> <p>Pls look <a href="http://jsfiddle.net/halofourteen/PjPYV/2/" rel="nofollow">jsfiddle</a>. In other words by clicking on currency values must recalculate them according to rates. In my example on jsfiddle I want to understand how simply change value(for example <code>usd=1</code> <code>eur=1.3</code>) Thanks!</p>
10,631,885
0
<p>Simply dropping in the files and refreshing is sufficient. Eclipse will automatically ammend the package declaration in the Java sources.</p> <p>That all being said, you should be looking at using a version control system such as CVS or subversion for example.</p>
19,730,743
0
<p>My solution using a <a href="http://developer.android.com/reference/android/app/ListFragment.html" rel="nofollow"><code>ListFragment</code></a>, based on the solutions by @Jakobud and @greg7gkb.</p> <pre><code>ListView listView = getListView(); listView.setDivider(null); listView.setDividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)); listView.setHeaderDividersEnabled(true); listView.setFooterDividersEnabled(true); View padding = new View(getActivity()); listView.addHeaderView(padding); listView.addFooterView(padding); </code></pre>
34,632,493
0
<p><strong>There is no standard way to get the battery level for an iBeacon.</strong> Some manufacturers like Kontakt store the battery level in an extra byte at the end of the broadcast, which is true for the post you reference. However, this will not work for all manufacturers.</p> <p>Another common way to get the info is with a proprietary connectable Bluetooth LE service. It is unclear whether the beacons you are using have this capability. Even if they do, you need to be able to get a public API from the manufacturer to figure out how to do it. If the manufacturer does not publish this, then you are out of luck unless you can reverse engineer it yourself.</p> <p>Again, every manufacturer is different, so you must find a different solution for each beacon type. </p>
6,574,683
0
<p>You need to handle the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkbox.checkedchanged.aspx" rel="nofollow">Checkbox changed event</a> after this you can determine if it is your collection or not and add or remove it accordingly</p>
9,330,386
0
<p>Have you read the <a href="http://www.cc.gatech.edu/~bader/COURSES/GATECH/CSE6140-Fall2007/papers/LC87.pdf" rel="nofollow">original paper</a>? It's very nicely explained.</p>
20,963,409
0
<p>SBAR stands for Subordinate Clause (see <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.9.8216&amp;rep=rep1&amp;type=pdf">here</a>). In your case the subordinate clause starts with the subordinate conjunction <em>After</em></p>
16,213,950
0
<p>You could try something like this: <a href="http://jsfiddle.net/MQrd6/3/" rel="nofollow">http://jsfiddle.net/MQrd6/3/</a></p> <p>The trick is to set the width of <code>border-image</code> same as <code>border-width</code>:</p> <pre><code>#leaf { width: 760px; vertical-align: middle; border-width: 22px; border-image: url(http://img703.imageshack.us/img703/4976/leafy.png) 22 22 round; } </code></pre> <p>No versions of IE supports border-image. To give support in IE you could try <a href="http://css3pie.com/" rel="nofollow">CSS3pie</a>, a simple library that allows you to use several CSS3 features in IE6 or higher.</p>
29,268,120
0
<p>Your <code>outfile2</code> is a <code>PrintWriter</code>. Somewhat surprisingly, <a href="http://docs.oracle.com/javase/8/docs/api/java/io/PrintWriter.html" rel="nofollow"><code>PrintWriter</code> methods don't throw exceptions</a>.</p> <blockquote> <p>Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError().</p> </blockquote> <p>That explains why your first code doesn't throw <code>IOException</code>.</p> <p>In your second code, you add a call to <code>readLine()</code>, probably from a <code>BufferedReader</code>, that does throw <code>IOException</code>.</p>
29,831,363
0
<p>You set the api endpoint like this:</p> <pre><code>cf api https://api.ng.bluemix.net </code></pre> <p>and then you login with <code>cf login</code>.</p> <p>Alternatively you can use the European endpoint:</p> <pre><code>cf api https://api.eu-gb.bluemix.net </code></pre> <p>EDIT:</p> <p>Alternatively, as you were implying, you can pass the API endpoint to <code>cf login</code> directly via the <code>-a</code> option:</p> <pre><code>cf login -a https://api.ng.bluemix.net -u &lt;ibm.com id&gt; </code></pre>
7,357,749
0
wp7 sms sending recieving and sms interceptors <p>Is there any way to send and recieve sms in wp7?</p> <p>And is there any way smsinterceptors if not</p> <p>is there any alternative way to do it?</p> <p>Any third party tool like that?</p>
9,874,489
0
<p>The new animation should take the current transform (translation) into account:</p> <pre><code> CATransform3D leftTransform = CATransform3DMakeRotation(wobbleAngle, 0.0f, 0.0f, 1.0f); leftTransform = CATransform3DConcat(layer.transform, leftTransform); CATransform3D rightTransform = CATransform3DMakeRotation(-wobbleAngle, 0.0f, 0.0f, 1.0f); rightTransform = CATransform3DConcat(layer.transform, rightTransform); NSValue* valLeft = [NSValue valueWithCATransform3D:leftTransform]; NSValue* valRight = [NSValue valueWithCATransform3D:rightTransform]; </code></pre> <p>Where <code>layer</code> is the layer that will be animated.</p>
39,989,023
0
<p>The best way to deal with this is by indexing into the rows using a Boolean series as you would in R.</p> <p>Using your df as an example,</p> <pre><code>In [5]: df.Col1 == "what" Out[5]: 0 True 1 False 2 False 3 False 4 False 5 False 6 False Name: Col1, dtype: bool In [6]: df[df.Col1 == "what"] Out[6]: Col1 Col2 Col3 Col4 0 what the 0 0 </code></pre> <p>Now we combine this with the pandas isin function.</p> <pre><code>In [8]: df[df.Col1.isin(["men","rocks","mountains"])] Out[8]: Col1 Col2 Col3 Col4 2 men of 2 16 4 rocks lips 4 32 6 mountains history. 6 48 </code></pre> <p>To filter on multiple columns we can chain them together with &amp; and | operators like so.</p> <pre><code>In [10]: df[df.Col1.isin(["men","rocks","mountains"]) | df.Col2.isin(["lips","your"])] Out[10]: Col1 Col2 Col3 Col4 2 men of 2 16 3 to your 3 24 4 rocks lips 4 32 6 mountains history. 6 48 In [11]: df[df.Col1.isin(["men","rocks","mountains"]) &amp; df.Col2.isin(["lips","your"])] Out[11]: Col1 Col2 Col3 Col4 4 rocks lips 4 32 </code></pre>
9,642,721
0
<p>Use <a href="http://api.jquery.com/val/" rel="nofollow"><code>.val()</code></a>, not <a href="http://api.jquery.com/attr/" rel="nofollow"><code>.attr()</code></a>, to set an element's value.</p> <p><a href="http://jsfiddle.net/mattball/jjjSf/" rel="nofollow">http://jsfiddle.net/mattball/jjjSf/</a></p> <hr> <p>As a side note, that's not remotely how <code>.attr()</code> — or JavaScript as a language — works. You cannot use a function call on the left-hand side of an assignment statement. It is meaningless.</p>
19,378,842
0
<p>On further analysis, I found that the error boils up to an IOException in the Persistence class. The class <code>ErrorNode</code> must implement <code>Serializable</code> and that should do the trick</p> <blockquote> <p><strong>EDIT:</strong> If you are a jbpm developer, you may want to look at the above error trace that does not give an indication that it is in fact a serialization error on the programmers side that resulted in this error. The actual exception does not propagate to the output.</p> </blockquote>
10,020,444
0
<p><a href="http://jsfiddle.net/yUgYW/3/" rel="nofollow">http://jsfiddle.net/yUgYW/3/</a></p> <p>this is what I get this far.. could be a start for you</p> <p><strong>HTML</strong></p> <pre><code>&lt;div id="container"&gt; &lt;ul&gt; &lt;li class="fisrt"&gt;1&lt;/li&gt; &lt;/ul&gt; &lt;ul class="center"&gt; &lt;li&gt;2&lt;/li&gt; &lt;li&gt;3&lt;/li&gt; &lt;li&gt;4&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li class="last"&gt;5&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;​ </code></pre> <p><strong>CSS</strong></p> <pre><code>#container { } li {float:left; border:1px solid red; width:120px;} .fisrt { float:left; } .last { float:right; } .center { width:400px; margin:auto; }​ </code></pre>
39,976,421
0
Degenerate a single SQL table into multiple domaines tables <p><strong>In short:</strong> I have a client who wish to be able to add domain tables, without adding SQL tables.</p> <p>I am working with an application in wich data are organized and made available with a postgresql <em>catalogue</em>. What I mean by <em>catalogue</em> is that the database hold the path to the actual data file(s) as well as some metadata.</p> <p>Adding a new table means that the (Java class of the) client application has to be updated. This is a costly process for the client, who want us to find a way to let him add new kind of data in the catalogue, without having to change the schema.</p> <p>I don't have many more specificities about the db itself and it's configuration as I'm usualy mostly a client of the said db.</p> <p><strong>My idea:</strong> to solve this was to have a generic table with the most often used columns (like date, comment etc.) and a column containing a <em>domain key</em>. The <em>domain key</em> would be used by the client application to request the kind of generic data is needed (and would have no meaning whatsoever to the db provider). Adding metadata could be done with a companion file within the catalogue and further filtering would have to be done on the client side.</p> <p><strong>Question:</strong> as I am by no mean an SQL expert, I would like to know if it is an acceptable solution, and what limitation I could be facing ? I'm thinking of performance, data volume etc. Or maybe a different approach, is advisable ?</p> <p>Regarding expected volume, for a single domain data type, it could be arround 30 new entry per day.</p>
5,351,492
0
<p>try this</p> <pre><code>preg_replace('@(?&lt;!http:)//.*@','',$test); </code></pre> <p>also read more about PCRE assertions <a href="http://cz.php.net/manual/en/regexp.reference.assertions.php" rel="nofollow">http://cz.php.net/manual/en/regexp.reference.assertions.php</a></p>
30,023,822
0
<p>I think by calling <code>AsyncTask</code> in <code>for</code> loop, it might start another task while the previous one still in <code>doInbackground()</code> that will result in multiple progress running because of this:</p> <p><code>pDialog = new ProgressDialog(getActivity());</code></p> <p>You will have a reference on the last started progress, so <strong>calling dismiss will only hide last one, while the other X progress(es) will remain active</strong>.</p> <p>So, either:</p> <ol> <li>Start the progress one time, before starting the <code>for loop</code> and stop it at <code>onPostExecute()</code> of last asyncTask</li> </ol> <p>Or </p> <ol start="2"> <li>Move the for loop inside <code>doInBackground()</code> as @StackOverflowUser stated</li> </ol>
20,637,122
1
python IDLE shell appears not to handle some escapes correctly <p>For example \b backspace prints as quad (shown as [] in example below). But \n newline is Ok.</p> <pre><code>&gt;&gt;&gt; print 'abc\bd' abc[]d &gt;&gt;&gt; print 'abc\nd' abc d </code></pre> <p>Im running under Vista (pro), python 2.7</p> <p>Ive tried googling this issue generally and in SO and cant find anything relevant, which seems odd and makes me wonder if theres some setting or other may be wrong in my setup. Not sure what to look for. </p>
24,600,172
0
<p>Looks like no impacts from the AD perspectives. From a DNS perspective, Azure assigned IP addresses to the machines in the order that they were restarted, so to avoid confusing DNS, I restarted the VMs in order of increasing IP address.</p> <p>Needed to make sure SQL Server data volumes were attached before starting the machine, otherwise the database would show as being in a pending recovery state.</p> <p>Also, apps that depend on MAC address (such as some license servers) did require new license files, as the MAC address changed.</p>
15,315,792
0
<p><code>voltage</code>- int, current battery voltage in millivolts</p> <p><code>temperature</code> - int, current battery temperature in tenths of a degree Centigrade</p> <p><a href="http://hi-android.info/src/com/android/server/BatteryService.java.html">Here is the source file </a></p>
21,391,166
0
<p>You could use the WITH clause to achieve the same effect:</p> <pre><code>WITH DISTINCT_TALENTS(PERSONID, TALENT) AS (SELECT DISTINCT PERSONID, TALENT FROM TALENTS) SELECT DISTINCT PERSONID, TALENT FROM (SELECT A.PERSONID, CASE WHEN TALENT_COUNT = 2 THEN 'BOTH' ELSE A.TALENT END FROM DISTINCT_TALENTS A INNER JOIN (SELECT PERSONID, COUNT(TALENT) TALENT_COUNT FROM DISTINCT_TALENTS GROUP BY PERSONID) B ON A.PERSONID = B.PERSONID) </code></pre> <p>First you create a virtual DISTINCT_TABLES table:</p> <pre><code>+------------------+ | personid talent | +------------------+ | 1 play | | 1 swim | | 2 play | | 3 swim | +------------------+ </code></pre> <p>next you create a subquery b with the following</p> <pre><code>+------------------------+ | personid talent_count | +------------------------+ | 1 2 | | 2 1 | | 3 1 | +------------------------+ </code></pre> <p>you join with original DISTINCT_TALENTS to obtain</p> <pre><code>+----------+--------+--------------+ | personid | talent | talent_count | +----------+--------+--------------+ | 1 | both | 2 | | 1 | both | 2 | | 2 | play | 1 | | 3 | swim | 1 | +----------+--------+--------------+ </code></pre> <p>you take the distinct personid, talent to obtain the final result.</p> <p>A solution similar to using exists is:</p> <pre><code>SELECT DISTINCT PERSONID, TALENT FROM ( SELECT B.PERSONID, CASE WHEN A.TALENT IS NULL THEN 'swim' WHEN B.TALENT IS NULL THE 'play' ELSE 'both' END TALENT FROM TALENTS A FULL OUTER JOIN TALENTS B ON A.PERSONID = B.PERSONID AND A.TALENT='play' AND B.TALENT='swim' ) </code></pre> <p>And finally, also with the <code>EXISTS</code> function used like a lookup function:</p> <pre><code>SELECT DISTINCT PERSONID, TALENT FROM ( SELECT A.PERSONID, CASE WHEN A.TALENT = 'play' AND EXISTS (SELECT 1 FROM TALENTS B WHERE A.PERSONID = B.PERSONID AND B.TALENT = 'swim') THEN 'both' WHEN A.TALENT = 'swim' AND EXISTS (SELECT 1 FROM TALENTS B WHERE A.PERSONID = B.PERSONID AND B.TALENT = 'play') THEN 'both' ELSE A.TALENT END TALENT FROM TALENTS A) </code></pre>
1,535,014
0
<p>I thought Professional SQL Server 2005 Performance Tuning by WROX was pretty excellent.</p>
411,996
0
<p>There are four main open-source relational database management systems of note that might be appropriate to this sort of application: Postgresql, MySQL, Firebird and Ingres. There are other systems such as <a href="http://www.sqlite.org/" rel="nofollow noreferrer">SQLite,</a> but they do not have this type of architecture and are not really designed for this type of workload. Some other open-source database management systems of this type do exist, but do not appear to be strongly viable for some reason, such as a lack of apparent vendor commitment. An example of a system that has this type of issue is <a href="http://en.wikipedia.org/wiki/MaxDB" rel="nofollow noreferrer">SAP-DB.</a></p> <p><a href="http://www.postgresql.org/" rel="nofollow noreferrer">Postgresql</a> has the best feature set of any of the open-source databases, and support for XA transactions, which you will probably want if your application is a three-tier system and supports transactions of non-trivial complexity. In particular you will want this if you want to do transactions spanning more than one call to the database.</p> <p>Several commercial variants of PostgreSQL have been built over the years, such as <a href="http://en.wikipedia.org/wiki/Illustra" rel="nofollow noreferrer">Illustra,</a> <a href="http://www.greenplum.com/" rel="nofollow noreferrer">Greenplum</a> and <a href="http://www.enterprisedb.com/" rel="nofollow noreferrer">EnterpriseDB.</a> Illustra was a commercial release of PostgreSQL which was subsequently bought by Informix. Greenplum is a mofified version designed for data warehousing applications. EnterpriseDB is a company that provides supported commercial versions of PostgreSQL with some value-added software.</p> <p><a href="http://www.mysql.com/" rel="nofollow noreferrer">MySQL</a> 5.x has a feature set that supports a reasonable cross section of capabilities, but it is not as feature-rich as PostgreSQL. It has more widespread mainstream acceptance and would be the easiest of the open-source database management systems to recruit skilled developers for. Although older versions did not have robust transaction support, transactional storage engines such as <a href="http://www.innodb.com/" rel="nofollow noreferrer">InnoDB</a> have been available for some time. The <a href="http://www.oracle.com/corporate/press/2005_oct/inno.html" rel="nofollow noreferrer">current</a> <a href="http://www.oracle.com/corporate/press/2006_feb/sleepycat.html" rel="nofollow noreferrer">politics</a> <a href="http://www.mysql.com/news-and-events/sun-to-acquire-mysql.html" rel="nofollow noreferrer">surrounding</a> the acquisition by Sun have generated <a href="http://news.oreilly.com/2008/07/mysql-forks-could-drizzle-be-t.html" rel="nofollow noreferrer">code forks</a> and the MySQL landscape is <a href="http://ronaldbradford.com/blog/understanding-the-various-mysql-products-variants-2009-03-13/" rel="nofollow noreferrer">somewhat messy,</a> with controversy about <a href="http://monty-says.blogspot.com/2008/11/oops-we-did-it-again-mysql-51-released.html" rel="nofollow noreferrer">quality issues in the 5.1 release.</a> However, MySQL is by far the most popular and best known of the open-source database management systems and is the only one with significant brand recognition outside of open-source circles.</p> <p><a href="http://www.firebirdsql.org/" rel="nofollow noreferrer">Firebird</a> is an open-source version of Interbase. Last I looked, it did not have XA support but would be fine if your application was set up as a two-tier client-server system. <strong>Update:</strong> I can't find a definitive specification on this, but the documentation does indicate that it has support for two-phase commit, but what I could find was not specific on whether it supported the XA protocol. The documentation implies that the JDBC driver does have support for two-phase commits. </p> <p>An interesting variant on this system is <a href="http://www.janus-software.com/fb_fyracle.html" rel="nofollow noreferrer">Fyracle</a>, which is designed to offer a degree of compatibility with Oracle. This was originally developed for use as a back-end to <a href="http://www.compiere.com/" rel="nofollow noreferrer">Compiere</a>, which was built against Oracle and quite tightly coupled to it.</p> <p><a href="http://www.ingres.com/" rel="nofollow noreferrer">Ingres</a> is now available with an open-source license, but has been greeted with a bit of a collective yawn by the open-source community. However It is quite feature-rich and very mature - I know people who were doing INGRES apps in 1990, and it dates back to the 1980s. </p>
25,848,195
0
Android - Thread safety while updating arraylist <p>My Activity consists of a BroadcastReceiver and an AsyncTask, both of them update an ArrayList (very often). I understand that an AsyncTask runs in the background, and there may be a possibility where the BroadcastReceiver and the AsyncTask threads may update the ArrayList at the same time. How can I make them thread-safe ?</p> <p>EDIT: As alexander mentioned, a BroadcastReceiver is run on the main thread unless you explicitly implement it otherwise.</p>
33,939,920
0
Preventing startx after login on my Raspberry pi <p>I'm trying to set up my pi to operate through SSH in anticipation of a robot project. I've successfully set up a SSH client on my laptop (PuTTY) and enabled SSH using raspi-config. I can login to the pi via SSH but the screen, having displayed the login progress becomes unresponsive, whatever I type in is ignored. There is only a 'block' cursor and no raspverrypi 'prompt' visible.</p> <p>On conncting the pi to a screen I see that LXDE has started. I assume this is my uderlying problem. How do I prevent startx from running automatically on login? </p>
39,202,772
0
Delphi 10.1 Berlin android 5.0.1 app crash on TEdit focus <p>I have a minimal firemonkey test app with one button and one TEdit control on form.</p> <p>If I run this app on Acer Tablet B1-770 on Andoid 5.0.1 happen following:</p> <p>If I click (or touch) in the edit control the app crashes. I have no problems with other android versions.</p> <p>Tried this solution but with no success (but this was for seattle version)</p> <p><a href="https://stackoverflow.com/questions/34595492/delphi-android-application-is-raising-issue-in-lennova-a5000-mobile%20%20Thanks%20in%20advance%20for%20help">https://stackoverflow.com/questions/34595492/delphi-android-application-is-raising-issue-in-lennova-a5000-mobile</a></p> <p>Some suggestions? Thanks</p>
16,194,335
0
<p><code>INSERT INTO beneficiaries (quoteid, uid, name, percent) SELECT quoteid, uid, name, percent FROM children WHERE quoteid = '$quoteid'</code>;</p> <p>Adjust column names as needed.</p>
14,278,955
0
Assembly procedure calling from C (Intel 8086) <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/14278373/intel-8086-assembly-procedure-calling-from-c">Intel 8086 Assembly procedure calling from C</a> </p> </blockquote> <p>I need to prepare a procedure in Assembly for Intel 8086 able to be called from a C (pass a string and return an integer value (16bit)). My assembly procedure works perfectly fine "stand-alone". I need help with connecting them together.</p> <p>Program is supposed to run on Intel 8086. I need to use MASM or emu8086 as assembler/simulator. Kindly recommend a C compiler and also a way to make the simple C program that is able to call the assembly procedure and get the returned value.</p> <p><em>How can I connect the ASM file and the C file? (How will the compiler know where is the definition/code for this procedure?)</em></p> <p><em>How can I receive the string sent from C in Assembly language, also how to return the integer to C from Assembly?</em></p>
16,930,358
0
OpenGL does not draw as expected <p>I am currently working my way through the current OpenGL Programming Guide, Version 4.3. I implemented the code of the first example, that should display two triangles. Basically pretty simple. </p> <p>But nothing is displayed when I run that code (just the black window).</p> <p>This is the init function where the triangles are created:</p> <pre><code>GLuint vertexArrayObjects[1]; GLuint buffers[1]; const GLuint vertexCount = 6; void init() { // glClearColor(0,0,0,0); glGenVertexArrays(1, vertexArrayObjects); glBindVertexArray(vertexArrayObjects[0]); GLfloat vertices[vertexCount][1] { {-90.0, -90.0}, { 85.0, -90.0}, {-90.0, 85.0}, { 90.0, -85.0}, { 90.0, 90.0}, {-85.0, 90.0} }; glGenBuffers(1, buffers); glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); ShaderInfo shaders[] { {GL_VERTEX_SHADER, "one.vsh"}, {GL_FRAGMENT_SHADER, "one.fsh"}, {GL_NONE, nullptr} }; GLuint program = LoadShaders(shaders); glUseProgram(program); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, ((char *)NULL + (0))); glEnableVertexAttribArray(0); } </code></pre> <p>And the very simple draw:</p> <pre><code>void display() { glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(vertexArrayObjects[0]); glDrawArrays(GL_TRIANGLES, 0, vertexCount); glFlush(); } </code></pre> <p>But as said, nothing is drawn. Is there an error in my implementation?</p> <p><em>The full code is <a href="http://pastebin.com/4XpC2xZQ" rel="nofollow">here</a> and LoadShaders (straight from the books website, so this should be out of interest) is <a href="http://pastebin.com/ZQHdRhG4" rel="nofollow">here</a>. The shaders are <a href="http://pastebin.com/Ydf4PMSA" rel="nofollow">here</a>.</em></p>
16,475,412
0
<p>Please try to search first your question on google if you not found your solution on google in that case you should post your question. See your answer on below link</p> <ol> <li><p><a href="http://stackoverflow.com/questions/2746478/how-can-i-loop-through-all-subviews-of-a-uiview-and-their-subviews-and-their-su">How can I loop through all subviews of a UIView, and their subviews and their subviews</a></p></li> <li><p><a href="http://stackoverflow.com/questions/7243888/how-to-list-out-all-the-subviews-in-a-uiviewcontroller-in-ios">How to list out all the subviews in a uiviewcontroller in iOS?</a></p></li> <li><p><a href="http://iphonedevsdk.com/forum/iphone-sdk-development/5599-removing-all-subviews-from-a-view.html" rel="nofollow">http://iphonedevsdk.com/forum/iphone-sdk-development/5599-removing-all-subviews-from-a-view.html</a></p></li> </ol>
30,930,751
0
<p>Let's suppose the following two arrays and their "sum":</p> <pre><code>Array 1: 1 2 3 4 5 6 7 8 9 [length = 9] Array 2: 2 4 6 8 2 4 6 [length = 7] Sum : 3 6 9 12 7 10 13 8 9 [length = 9] </code></pre> <p>Pay attention to the last two items. The sum is equal to the value of the first array because the second array doesn't contain such number of values.</p> <pre><code>Array 1: 1 2 3 4 5 6 7 8 9 Array 2: 2 4 6 8 2 4 6 ? ? </code></pre> <p>That's exactly what algorithm does:</p> <p>1) While both arrays have numbers at <code>i</code> index - sum up.</p> <pre><code>ctr : ! ! ! ! ! ! ! \|/ [ ctr = 7 (remember: 0-based indexes)] Array 1: 1 2 3 4 5 6 7 8 9 [length = 9] Array 2: 2 4 6 8 2 4 6 [length = 7] Sum : 3 6 9 12 7 10 13 </code></pre> <p>Here <code>while (ctr &lt; array1.length &amp;&amp; ctr &lt; array2.length)</code> conditions breaks at <code>ctr &lt; array2.length</code>.</p> <p>Further, the check <code>ctr == array2.length</code> returns true meaning that the Array 2 is over and we need to continue iterating through the <code>array1</code>.</p> <pre><code>for (x = ctr; x &lt; array1.length; i++) { result.push(array1[x]); } </code></pre> <p>2) While the remaining array is not over - add values from it.</p> <pre><code>x : ! ! \|/ [ x = 10] Array 1: 1 2 3 4 5 6 7 8 9 [length = 9 ] Array 2: 2 4 6 8 2 4 6 [length = 7 ] Sum : 3 6 9 12 7 10 13 8 9 </code></pre>
4,359,372
0
Red5 changing the default location of storing media files <p>I've just started playing with Red5 and am developing an app using which users can record video messages. Now by default the video files are being saved in </p> <p>C:\Program Files\Red5\webapps\webcam_recorder\streams</p> <p>I am trying to figure out how I can change the default location and say be able to save it in c:\streams instead</p> <p>Secondly once I deploy to prod, my idea is to save these video files on Amazon S3 and have red5 stream from there. Is that possible. If so where in the config will I specify this change.</p> <p>Thanks a lot for your responses.</p>
12,674,575
0
Ribbon button not firing event set by onAction when clicked <p>I've designed an add-in to Outlook 2010 where I'm trying to fire (or, rather, catch) an event fired when a button is clicked as shown <a href="http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/a3fa9ea5-6710-48c4-adb7-1f11afe34f81/">in this article</a>. I've targeted the right XML (since the changes to it are seen on the ribbon). However, The event I'm trying to catch is either not fired at all or (more likely) fired an other way than what my listened is looking (listening?).</p> <p>I also tried to go by the reference on MSDN <a href="http://msdn.microsoft.com/en-us/library/documentformat.openxml.office2010.customui.button.onaction.aspx">here</a>, <a href="http://msdn.microsoft.com/en-us/library/aa942866%28v=vs.100%29.aspx">here</a> and mostly <a href="http://msdn.microsoft.com/en-us/library/aa722523.aspx">here</a>. To no avail, though... I wonder if it's got to do with the "repurpose" information.</p> <p>Here's the markup.</p> <pre><code>&lt;tab idMso="TabMail"&gt; &lt;group id="group1" label="CRMK"&gt; &lt;button id="MyId" onAction="Button_Click" label="Do me!" size="large" /&gt; &lt;/group&gt; &lt;group id="group2" label="group2"&gt; &lt;button id="button1" label="button1" showImage="false" /&gt; &lt;/group&gt; &lt;/tab&gt; </code></pre> <p>And the code behind looks like this.</p> <pre><code>private void Button_Click(Object sender, RibbonControlEventArgs eventArgs) { MessageBox.Show("Button clicked..."); } </code></pre> <p>What am I missing? How can I debug such a thing?</p>
24,375,315
0
<p>This works:</p> <pre><code>data={} with open(fn) as f: reader=csv.reader(f, delimiter='\t', quoting=csv.QUOTE_NONE) header=next(reader) for row in reader: data.setdefault(row[1], []).append(int(row[2])) print 'key\tmin\tmax' for k in data.keys(): print '{}\t{}\t{}'.format(k, min(data[k]), max(data[k])) </code></pre> <p>With your example data, prints:</p> <pre><code>key min max bye 2 7 hi 1 5 </code></pre>
35,229,671
0
If statements based on another column within a dataframe: in R <p>For a simple dataframe:</p> <pre><code>df &lt;- structure(list(id = 1:9, sex = structure(c(2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L), .Label = c("f", "m"), class = "factor"), score = c(55L, 60L, 62L, 47L, 45L, 52L, 41L, 46L, 57L)), .Names = c("id", "sex", "score"), class = "data.frame", row.names = c(NA, -9L)) </code></pre> <p>I want to write some if statements based on score for males and females. The basic if function would go like this:</p> <pre><code>df$score3&lt;-ifelse(df$score &lt;45,"low", ifelse(df$score&gt;=45 &amp; df$score&lt;55,"normal", ifelse(df$score &gt;=55,"high", NA))) </code></pre> <p>How would I change this expression for males only (separate cut offs will be used for females (say low = &lt;50, normal = >=50 &amp; &lt;58, high = >=58)).</p> <p>If any advice could be given on using if statements based on another column within a dataframe, I would be most grateful.</p>
30,900,662
0
<p>You can use images to fully customize your GUI. In our case, it's the buttons.</p> <h1>[Class] ImageButton</h1> <p>Image Buttons for AHK GUIs.</p> <p>Source: <a href="https://github.com/AHK-just-me/Class_ImageButton" rel="nofollow">https://github.com/AHK-just-me/Class_ImageButton</a><br> Forum topic: <a href="http://ahkscript.org/boards/viewtopic.php?t=1103" rel="nofollow">http://ahkscript.org/boards/viewtopic.php?t=1103</a><br> An example is provided here: <a href="https://github.com/AHK-just-me/Class_ImageButton/blob/master/Sources/Sample.ahk" rel="nofollow">https://github.com/AHK-just-me/Class_ImageButton/blob/master/Sources/Sample.ahk</a></p> <hr> <h2>Shortened example</h2> <pre><code>#NoEnv SetBatchLines, -1 #Include Class_ImageButton.ahk ; ---------------------------------------------------------------------------------------------------------------------- Gui, DummyGUI:Add, Pic, hwndHPIC, PIC1.jpg SendMessage, 0x0173, 0, 0, , ahk_id %HPIC% ; STM_GETIMAGE HPIC1 := ErrorLevel GuiColor := "Blue" Gui, Margin, 50, 20 Gui, Font, s10 Gui, Color, %GuiColor% ImageButton.SetGuiColor(GuiColor) Gui, Add, Button, vBT1 w200 hwndHBT1, Button 1`nLine 2 Opt1 := [0, 0x80CF0000, , "White", "H", , "Red", 4] ; normal flat background &amp; text color Opt2 := [ , "Red"] ; hot flat background color Opt5 := [ , , ,"Gray"] ; defaulted text color -&gt; animation If !ImageButton.Create(HBT1, Opt1, Opt2, , , Opt5) MsgBox, 0, ImageButton Error Btn1, % ImageButton.LastError Gui, Show, , Image Buttons Return ; ---------------------------------------------------------------------------------------------------------------------- GuiClose: GuiEscape: ExitApp </code></pre>
19,712,836
0
<p>What's happening is that the "event dispatch thread", where all the Swing events happen, is having to wait for your code. Don't do long-running stuff on the event dispatch thread. This is a famous anti-pattern. </p> <p>You should read the lesson from the Java tutorials, that starts at <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html</a>, which describes this. </p> <p>Two small points that are unrelated to your problem:</p> <ol> <li>Your code will be much more manageable if you use an array of <code>ImageIcon</code> variables, instead of six separate variables. </li> <li>You could use the <code>sleep</code> method of the <code>Thread</code> class instead of the "busy sleep" that you're using.</li> </ol>
16,241,005
0
<ol> <li><p>How do you know that the request is not valid?</p></li> <li><p>Do you work for GoDaddy or have permission from those who own, manage or control the servers you are developing against to test their servers? (see license agreement for LoadRunner)</p></li> </ol>
8,802,675
0
<p>i'd really wish this wouldn't be possible, but sadly it is (or was). i don't know for sure if this still works on Win7 and with current browser-versions, but in the past you could do this...</p> <p><strong>Firefox</strong></p> <pre><code>function getUsr() { return Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get('USERNAME'); } </code></pre> <p><strong>Internet Explorer</strong></p> <pre><code>function getUsr() { var wshell = new ActiveXObject("WScript.Shell"); return wshell.ExpandEnvironmentStrings("%USERNAME%"); } </code></pre>
17,208,214
0
<p>You probably want to install .NET Framework 4.5, which is an in-place, backwards-compatible version of the .NET 4.0 framework. You can find the installer here: <a href="http://www.microsoft.com/en-us/download/details.aspx?id=30653" rel="nofollow">http://www.microsoft.com/en-us/download/details.aspx?id=30653</a></p>
13,418,860
0
<p>I had run into a similar challenge with a proxy class. For reasons that I won't go into, I needed to serialize the class manually using the XmlSerializer on web server and deserialize on client. I was not able to find an elegant solution online, so I just avoided the issue by removing the XmlTypeAttribute from the proxy class manually after I auto-generated it in Visual Studio.</p> <p>I kept coming back to see if there was a way to get the namespace to workout. Here is how I got it working without the need to modify the auto-generated classes. I ended up using an XmlTextReader to return the desired namespace on nodes matching a property name. There is room for improvement, but i hope it helps someone.</p> <pre><code>class Program { static void Main(string[] args) { //create list to serialize Person personA = new Person() { Name = "Bob", Age = 10, StartDate = DateTime.Parse("1/1/1960"), Money = 123456m }; List&lt;Person&gt; listA = new List&lt;Person&gt;(); for (int i = 0; i &lt; 10; i++) { listA.Add(personA); } //serialize list to file XmlSerializer serializer = new XmlSerializer(typeof(List&lt;Person&gt;)); XmlTextWriter writer = new XmlTextWriter("Test.xml", Encoding.UTF8); serializer.Serialize(writer, listA); writer.Close(); //deserialize list from file serializer = new XmlSerializer(typeof(List&lt;ProxysNamespace.Person&gt;)); List&lt;ProxysNamespace.Person&gt; listB; using (FileStream file = new FileStream("Test.xml", FileMode.Open)) { //configure proxy reader XmlSoapProxyReader reader = new XmlSoapProxyReader(file); reader.ProxyNamespace = "http://myappns.com/"; //the namespace of the XmlTypeAttribute reader.ProxyType = typeof(ProxysNamespace.Person); //the type with the XmlTypeAttribute //deserialize listB = (List&lt;ProxysNamespace.Person&gt;)serializer.Deserialize(reader); } //display list foreach (ProxysNamespace.Person p in listB) { Console.WriteLine(p.ToString()); } Console.ReadLine(); } } public class Person { public string Name { get; set; } public int Age { get; set; } public DateTime StartDate { get; set; } public decimal Money { get; set; } } namespace ProxysNamespace { [XmlTypeAttribute(Namespace = "http://myappns.com/")] public class Person { public string Name { get; set; } public int Age { get; set; } public DateTime Birthday { get; set; } public decimal Money { get; set; } public override string ToString() { return string.Format("{0}:{1},{2:d}:{3:c2}", Name, Age, Birthday, Money); } } } public class XmlSoapProxyReader : XmlTextReader { List&lt;object&gt; propNames; public XmlSoapProxyReader(Stream input) : base(input) { propNames = new List&lt;object&gt;(); } public string ProxyNamespace { get; set; } private Type proxyType; public Type ProxyType { get { return proxyType; } set { proxyType = value; PropertyInfo[] properties = proxyType.GetProperties(); foreach (PropertyInfo p in properties) { propNames.Add(p.Name); } } } public override string NamespaceURI { get { object localname = LocalName; if (propNames.Contains(localname)) return ProxyNamespace; else return string.Empty; } } } </code></pre>
39,757,418
1
Using Tweepy Stream, How do I search for retweets? <p>I am currently using Tweepy's stream in order to fetch tweets. For some reason, it does not seem to show that I am fetching any sort of retweets. The <code>retweet_count</code> field is always 0 and the <code>retweeted</code> field is always false. Normal tweets are showing up however...</p> <p>Am I looking at the wrong field to retrieve retweets? Or are there really not enough retweets in the US?</p> <p>Here is the code that I am working with:</p> <pre><code>access_token = xxxx access_token_secret = xxxx consumer_key =xxxx consumer_secret = xxxx class StdOutListener(StreamListener): def on_data(self, data): if 'retweet_count' in json.loads(data) and 'retweeted' in json.loads(data): if json.loads(data)['retweet_count']&gt;0 or json.loads(data)['retweeted']=True: print(json.loads(data)) return True def on_error(self, status): print(status) if __name__ == '__main__': l = StdOutListener() auth = OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) stream = Stream(auth, l) print("Use CTRL + C to exit at any time.\n") #stream.filter(track=['trump','hilary']) stream.filter(locations=[-124.848974, 24.396308, -66.885444, 49.384358]) </code></pre>
17,410,310
0
<p>you can try</p> <pre><code>if(spinnerCarbs == null) return; </code></pre> <p>Then the rest of you code </p>
28,030,308
0
<p>You do not need to use <code>?</code>. Generics are not used like that except in rare (and usually strange) circumstances.</p> <pre><code>class MyClass { } class MyExtendedClass extends MyClass { } public void test() { Map&lt;Integer, MyClass&gt; myMap = new HashMap&lt;Integer, MyClass&gt;(); myMap.put(1, new MyClass()); myMap.put(2, new MyExtendedClass()); } </code></pre>
11,180,828
0
<p>If your branch consists of many small commits adding up to one large change, you might be able to effect this by pushing the commits up in stages. Perhaps create a new branch starting at the point at which your code diverges from that on the company server, then pull ranges of commits from your branch in stages and push after each range is pulled.</p> <p>But pushing separate folders/files - I'm pretty certain that's not possible: it rather goes against git's requirement that a commit be an atomic entity.</p>
28,113,333
0
NullPointerException when reading manifest signed webstart jar behind authentication layer <p>I have a java webstart application running in a tomcat web server. The single jar referenced by the JNLP has been signed. The entire web-application is behind a basic authentication layer.<br> Web.xml extract:</p> <pre class="lang-xml prettyprint-override"><code> &lt;security-constraint&gt; &lt;display-name&gt; Client (SSL)&lt;/display-name&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;Client (SSL)&lt;/web-resource-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;http-method&gt;GET&lt;/http-method&gt; &lt;http-method&gt;POST&lt;/http-method&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;role-name&gt;clientuser&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;user-data-constraint&gt; &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt; &lt;/user-data-constraint&gt; &lt;/security-constraint&gt; &lt;login-config&gt; &lt;auth-method&gt;BASIC&lt;/auth-method&gt; &lt;realm-name&gt;Client Webstart&lt;/realm-name&gt; &lt;/login-config&gt; </code></pre> <p>When I run the JNLP, webstart correctly asks me to fill in the username and password, but then crashes with the following null pointer exception: <br></p> <pre><code>java.lang.NullPointerException at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source) at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source) at com.sun.javaws.security.AppPolicy.addPermissions(Unknown Source) at com.sun.jnlp.JNLPClassLoader.getTrustedCodeSources(Unknown Source) at com.sun.deploy.security.CPCallbackHandler$ParentCallback.strategy(Unknown Source) at com.sun.deploy.security.CPCallbackHandler$ParentCallback.openClassPathElement(Unknown Source) at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(Unknown Source) at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$800(Unknown Source) at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(Unknown Source) at com.sun.deploy.security.DeployURLClassPath$JarLoader.&lt;init&gt;(Unknown Source) at com.sun.deploy.security.DeployURLClassPath$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source) at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source) at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at com.sun.javaws.Launcher.doLaunchApp(Unknown Source) at com.sun.javaws.Launcher.run(Unknown Source) at java.lang.Thread.run(Unknown Source) </code></pre>
13,424,558
0
<p>Lua cannot magically give the original arguments new values. They might not even be on the stack anymore, depending on optimizations. Furthermore, there's no indication where the code was when it yielded, so it may not be able to see those arguments anymore. For example, if the coroutine called a function, that new function can't see the arguments passed into the old one.</p> <p><code>coroutine.yield()</code> returns the arguments passed to the <code>resume</code> call that continues the coroutine, so that the site of the yield call can handle parameters as it so desires. It allows the code doing the resuming to communicate with the specific code doing the yielding. <code>yield()</code> passes its arguments as return values from <code>resume</code>, and <code>resume</code> passes its arguments as return values to <code>yield</code>. This sets up a pathway of communication.</p> <p>You can't do that in any other way. Certainly not by modifying arguments that may not be visible from the <code>yield</code> site. It's simple, elegant, and makes sense.</p> <p>Also, it's considered exceedingly rude to go poking at someone's values. Especially a function already in operation. Remember: arguments are just local variables filled with values. The user shouldn't expect the contents of those variables to change unless it changes them itself. They're <code>local</code> variables, after all. They can only be changed locally; hence the name.</p>
37,724,737
0
<p>I do expect that you are using the correct host on your side.</p> <p>But you are missing Username and Password.</p> <pre><code>transport = session.getTransport("smtp"); transport.connect(hostName, port, user, password); transport.sendMessage(message, message.getAllRecipients()); </code></pre> <p>or you can use the Authenticator:</p> <pre><code>Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); </code></pre>
21,932,897
0
<p><code>quiver</code> plot may be too much for plotting only one vector in 3-D. You can achieve a similar plot by using a simple <code>plot3</code> such as the one plotted below.</p> <p>In this plot, the origin of the vector is the blue dot, and the direction is given by the red line.</p> <p><img src="https://i.stack.imgur.com/dlmTs.png" alt="enter image description here"> </p> <p>The code</p> <pre><code>%v is the direction of the vector (3 cartesian coordinates) v = sort(randn(100,3)); v = bsxfun(@rdivide,v,sqrt(sum(v.^2,2))); %xyz the origin of the vector ind = linspace(-pi,pi,100); x = cos(ind); y = sin(ind); z = ind; %the plotting function figure for ii = 1:numel(ind) plot3(x(ii),y(ii),z(ii),'bo'); %origin in blue set(gca,'XLim', [-3 3], 'YLim', [-3 3], 'ZLim', [-3 3]); hold on; hl = plot3( linspace(x(ii), x(ii)+v(ii,1),10), ... linspace(y(ii), y(ii)+v(ii,2),10), ... linspace(z(ii), z(ii)+v(ii,3),10), ... 'r'); %direction in red view(80,10); pause(0.1); %clf end </code></pre>
8,683,766
0
AIR from HTML: Controlling Size of New Window <p>I'm using Dreamweaver to convert a web site into an AIR desktop app. The app searches and browses through PDF files and provides links for opening them. I am foremost a web developer, so HTML and JavaScript/jQuery is what I understand, the links are simple <code>&lt;a&gt;</code> tags with target set to _blank. Adding any scripting to control the size of the new AIR windows in which the PDFs open causes the links to cease working at all. All tutorials I've found on how to control the size of a new AIR window show how to do it in MXML, but Dreamweaver works with a regular XML formatted application manifest.</p> <p>So, what's the trick?</p>
2,228,533
0
Estimate the size of outputted dll/exe upfront? <p>currently I'm fixing some issues regarding to small outputted dll (I'm using Ribosome build system on Windows) so I'm wondering this:</p> <p>suppose project (C++) include source files whose total size is i.e. 100 KB and project also depends on i.e. 3 libraries, each about 100KB, what binary size should I expect after compiling and linking? Can I estimate this up front? </p> <p>p.s. assuming that this is release build with turned off any kind of optimization and source files contain pure code without any comments or similar</p> <p>Thanks</p>
35,278,942
0
Scraping with a multithreaded queue + urllib3 suffers a drastic slowdown <p>I am trying to scrape a huge number of URLs (approximately 3 millions) that contains JSON-formatted data in the shortest time possible. To achieve this, I have a Python code (python 3) that uses Queue, Multithreading and Urllib3. Everything works fine during the first 3 min, then the code begins to slow down, then it appears to be totally stuck. I have read everything I could find on this issue but unfortunately the solution seems to requires a knowledge which lies far beyond me.</p> <p>I tried to limit the number of threads : it did not fix anything. I also tried to limit the maxsize of my queue and to change the socket timeout but it did no help either. The distant server is not blocking me nor blacklisting me, as I am able to re-launch my script any time I want with good results in the beggining (the code starts to slow down at pretty random time). Besides, sometimes my internet connection seems to be cut - as I cannot surf on any website - but this specific issue does not appear every time.</p> <p>Here is my code (easy on me please, I'm a begginer):</p> <pre><code>#!/usr/bin/env python import urllib3,json,csv from queue import Queue from threading import Thread csvFile = open("X.csv", 'wt',newline="") writer = csv.writer(csvFile,delimiter=";") writer.writerow(('A','B','C','D')) def do_stuff(q): http = urllib3.connectionpool.connection_from_url('http://www.XXYX.com/',maxsize=30,timeout=20,block=True) while True: try: url = q.get() url1 = http.request('GET',url) doc = json.loads(url1.data.decode('utf8')) writer.writerow((doc['A'],doc['B'], doc['C'],doc['D'])) except: print(url) finally: q.task_done() q = Queue(maxsize=200) num_threads = 15 for i in range(num_threads): worker = Thread(target=do_stuff, args=(q,)) worker.setDaemon(True) worker.start() for x in range(1,3000000): if x &lt; 10: url = "http://www.XXYX.com/?i=" + str(x) + "&amp;plot=short&amp;r=json" elif x &lt; 100: url = "http://www.XXYX.com/?i=tt00000" + str(x) + "&amp;plot=short&amp;r=json" elif x &lt; 1000: url = "http://www.XXYX.com/?i=0" + str(x) + "&amp;plot=short&amp;r=json" elif x &lt; 10000: url = "http://www.XXYX.com/?i=00" + str(x) + "&amp;plot=short&amp;r=json" elif x &lt; 100000: url = "http://www.XXYX.com/?i=000" + str(x) + "&amp;plot=short&amp;r=json" elif x &lt; 1000000: url = "http://www.XXYX.com/?i=0000" + str(x) + "&amp;plot=short&amp;r=json" else: url = "http://www.XXYX.com/?i=00000" + str(x) + "&amp;plot=short&amp;r=json" q.put(url) q.join() csvFile.close() print("done") </code></pre>
17,980,724
0
<p>Echo the HTML form and ensure your file uses the .php extension (.php)</p>
28,107,625
0
<p>You can use which.</p> <pre><code>desireDf &lt;- df[ which( df$CATEGORY=="over 10 mio" &amp; (df$COUNTRY=="Germany" | df$COUNTRY=="Sweden" )), ] </code></pre> <p>Also it works without which:</p> <pre><code>desireDf &lt;- df[ (df$CATEGORY=="over 10 mio" &amp; (df$COUNTRY=="Germany" | df$COUNTRY=="Sweden")), ] </code></pre>
27,100,213
0
Android webview pageStarted not detected, facebook unable to cancel share <p>I am sharing a link using my webview.</p> <p>"<a href="http://m.facebook.com/sharer.php?u=" rel="nofollow noreferrer">http://m.facebook.com/sharer.php?u=</a>" + urltoshare;</p> <p>My code is:</p> <pre><code>WebView myWebView = (WebView) findViewById(R.id.wvForFB); WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); myWebView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!loadingFinished) { redirect = true; } loadingFinished = false; view.loadUrl(url); return true; } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if(!redirect){ loadingFinished = true; } if(loadingFinished &amp;&amp; !redirect){ //HIDE LOADING IT HAS FINISHED myrelativebar.setVisibility(View.GONE); myprogressbar.setVisibility(View.GONE); } else{ redirect = false; } } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, null); loadingFinished = false; myrelativebar.setVisibility(View.VISIBLE); myprogressbar.setVisibility(View.VISIBLE); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast.makeText(getApplicationContext(), "" + description, Toast.LENGTH_SHORT).show(); } }); myWebView.loadUrl(attrurl); </code></pre> <p>I need to detect the cancel event on this view. But event on clicking <strong>cancel or Post</strong> <strong>DOES NOT call onpageStarted</strong>, not internally or via debugging for pagestarted.I want to detect cancel event and hide the webview. Do suggest any workaround.</p> <p><img src="https://i.stack.imgur.com/RRCCj.png" alt="Share page opened using this link"></p>
11,063,655
0
<pre><code>$sql=array(); foreach ($f_list as $list) { //This assumes, your values are already safely quoted $sql[]="'".$list['id']."','".$list['name']."'"; } $sql=implode('),(',$sql); $sql="INSERT INTO tablename VALUES($sql)"; // now run the query </code></pre>
11,691,849
0
<p>The application identifier of an app "looks something like an Internet domain name in reverse, such as 'com.apple.textedit'."<a href="http://macscripter.net/viewtopic.php?pid=96491" rel="nofollow"> &rarr; reference</a></p> <p>If you used Xcode to create your Applescript application you can set the Application Bundle Identifier as part of the application setup wizard or in the Application Target properties. If you used the Applescript Editor to write your script and save it as an application your bundle won't have an identifier but you can add one.</p> <p>CTRL-Click on your application bundle and click Show Package Contents. Click on the Contents folder and then open the Info.plist file. This file specifies properties of your application in XML format. If you have Xcode installed it will open the file in the Plist editor making it a little more friendly to edit. What you want to do is add the CFBundleIdentifier key and your Application Identifier as the value. For example:</p> <pre><code>&lt;key&gt;CFBundleIdentifier&lt;/key&gt; &lt;string&gt;com.depot6.showworkingdrive&lt;/string&gt; </code></pre> <p>Add it near the CFBundleName key/value pair under the element. Saving the modified Info.plist will allow you to target that application in your Dashcode widget.</p>
16,253,580
0
<p>It looks like there is not a perfect solution</p> <p>I ended up having a ProgressBar instance in the Activity, another instance in each fragment exactly overlapping the Activity one and then I just fade them in and out.</p> <p>The "stuck" effect is now negligible</p>