pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
39,417,462
0
Developing two android app that can send/trigger notification to each other <p>I've been studying android development for about 2 months, and still trying to learn new things and stuffs in mobile dev. And I've been wondering how can two android application send notification to each other. I saw a tutorial about <code>notificationCompat</code> wherein a notification pop-up when an action(<code>onClick</code>) is performed inside the application. And I thought that maybe it is also possible to trigger that notification from another application. And my question is now, How can I trigger a notification in the 1st application using the 2nd application? And also addtional info will be that the two application is on the same local network(Ad hoc).</p>
6,783,050
0
<p>Here is the solution: Simply, <strong>RESTART THE MACHINE</strong> !</p>
3,093,313
0
<p>I personnaly use the second one, here is how I view this :</p> <p>You must think of that with the semantics, you would say </p> <p>"When &lt;a> of class &lt;class> trigger the event &lt;hover> I want &lt;that> to happen."</p> <p>not this :</p> <p>"When &lt;a> trigger event &lt;hover> check if it is of class &lt;class> then do &lt;that>."</p>
36,556,045
0
<p>Use:</p> <pre><code>a = np.array([23, 50, 100, 120]) np.median(a[a &gt; 50]) </code></pre>
18,587,784
0
<p>In TeamCity 7.1.3 you are unable to achieve what you are asking. The only way you can do this is to add permissions whenever projects are added. However, if you update to TeamCity 8.x there is now the concept of project hierarchies. You can grant permissions at any level and the permissions are inherited to the sub projects. For example:</p> <ul> <li>Project A <ul> <li>Sub project 1</li> <li>Sub project 2</li> </ul></li> <li>Project B</li> </ul> <p>If you give a developer permissions to project A and then add a new sub project:</p> <ul> <li>Project A <ul> <li>Sub project 1</li> <li>Sub project 2</li> <li>Sub project 3</li> </ul></li> <li>Project B</li> </ul> <p>There will have permission to all 3 sub-projects in project A without having to change the permissions model. This should achieve exactly what you are after.</p>
20,914,439
0
Get reference dll into another dll which is exposed to COM <p>I'm want to find the answers for this problem:</p> <p>I'm developing a .NET 4.0 DLL wich has reference to another third party Dll FTP. This DLL that i'm developing is loaded through reflection by another DLL called LoaderDLLs.</p> <p>LoaderDLLs is exposed for COM, the problem is when the COM use DLL to invoke .NET DLL 4.0 everything is fine but when .NET DLL 4.0 internally call third party DLL FTP occurs next error:</p> <p><strong>Exception has been thrown by the target of an invocation.Could not load file or assembly 'Jscape.Ssh, Version=2.7.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.</strong> </p> <p>I have attemped install third party DLL FTP into GAC through gacutil, but a think this is not working, How can i get reference to that DLL?</p>
22,048,536
0
<p>Let's break down this recursive call:</p> <p>With <code>m(3)</code>, <code>p</code> isn't <code>0</code>, so we return <code>3*3 + m(2);</code>.</p> <pre><code>3*3 + (m(2)) </code></pre> <p>With <code>m(2)</code>, <code>p</code> isn't <code>0</code>, so we return <code>3*2 + m(1);</code>.</p> <pre><code>3*3 + (3*2 + m(1)) </code></pre> <p>With <code>m(1)</code>, <code>p</code> isn't <code>0</code>, so we return <code>3*1 + m(0);</code>.</p> <pre><code>3*3 + (3*2 + (3*1 + m(0)) </code></pre> <p>With <code>m(0)</code>, <code>p</code> is <code>0</code>, so we return <code>0</code>. Then the recursive call stack unwinds.</p> <pre><code>3*3 + (3*2 + (3*1 + (0)) = 9 + (6 + (3 + 0)) = 9 + (6 + 3) = 9 + 9 = 18 </code></pre>
19,442,399
0
<p>I guess the problem is because you have not defined actions MOVE, UP and DOWN for the touch. Try writing your code in <strong>MotionEvent.ACTION_DOWN</strong>, If this works for you. </p> <pre><code> case R.id.layout_button_subscriptions:{ switch (event.getAction()) { case MotionEvent.ACTION_MOVE: { break; } case MotionEvent.ACTION_DOWN: { startActivity(new Intent(AppActivity.this,Subs.class)); break; } } </code></pre>
19,416,347
0
<p>Error 10501 can occur if using DoDirectPayment API but you do not have PayPal Payments Pro on your account. </p> <p>If you have Payments Pro on your account but still getting this error, it could be an account setup issue; in that case contact customer support to further investigate.</p>
6,815,934
0
Ideas about web browser in Qt using GSM/GPRS modem <p>I have successfully interfacted Telit GL 865 GSM/GPRS modem to my Atmel microprocessor. My POC board is running embedded linux and I have also cross compiled Qt libraries(including Webkit) and transferred it to the board.</p> <p>I can also read and write AT commands from Qt application by opening an FD(File descriptor) and then executing commands.</p> <p>I'm also able to connect to the GPRS, also getting HTTP response. Currently I'm setting the HTML that I get from AT commands, through the QWebView's setHTML() function. But by this the images doesn't load(obviously) and also I cannot navigate through the links as the browser doesn't have a direct access to the Internet. So what is the proper implementation by which my Qt Webkit browser can directly communicate over GPRS using my modem ?</p>
19,720,515
0
<p>Forgot a <code>^</code></p> <pre><code>RewriteRule ^(.*)\.html$ $1.php [L,R=301] </code></pre>
27,268,099
0
Efficient R Conditional Function for Each Value in a Data Frame Column <p>I needed to make a function (wpcm) to manipulate every value in a data frame column a certain way. It takes a very long time. Is there a way to do this more efficiently?</p> <p>Edit:</p> <p>my previous question had an example function, which had the contents of Powerm removed. The heart of my question is: is there a better way to do this than using the for loop in wpcm?</p> <pre><code> Powerm &lt;- function(v,turbnum) # This function inputs wind speed (m/s) and a specified turbine, # then outputs the turbine's rated power # v is wind speed # turbnuum is turbine analyzed # { # turnine 1 is 10 kW bergy if (turbnum ==1) { powerCurve &lt;- c(-12,-12,-11,0,39,102,229,399,596,848,1151,1510,1938,2403,2949,3602,4306,5071,5960,6856,7849,8863,9928,10885,11619,12019,12276,12395,12449,12495,12508,12546,12555,12503,12528,12442,12396,12208,11878,11989,11495) x=seq(0.5,20.5,0.5) indexx= 2*v # curve is binned by 0.5 m/s } # Turbine 2 is Aeolos-H 50 kW if (turbnum == 2) { powerCurve &lt;- c(0.54,0.9,1.92,3.75,5.99,8.71,11.96,16.03,20.53,25.88,32.18,38.59,45.81,50.03,50,50,50,50) x=seq(3,11.5,0.5) # which power curve value are we closest to? # binned by .5 m/s, so multiply v by 2 # starts at 3 m/a so subtract 2 indexx= 2*(v-2) - 1 # curve is binned by 0.5 m/s } # turnine 3 is 50 kW Endurance #-3120 # http://www.smallwindcertification.org/wp-content/new-uploads/2013/11/SPP-13-07-Summary-Report.pdf if (turbnum ==3) { powerCurve &lt;- c(-0.14,-.33,-.24,-0.09,1.03,2.48,4.71,8.21,11.82,16.19,20.17,25.04,29.26,35.07,36.69,43.96,46.67,51.52,54.73,56.84,58.92,60.25,61.25,62.1,62.67,63.38,63.62,65.02,65.47,65.67,66.57) x=seq(1.5,16.5,0.5) indexx= 2*v-1 # curve is binned by 0.5 m/s } # Turbine 4 is Northern 100 kW if (turbnum == 4) { powerCurve &lt;- c(-.5,-.5,1.2,7.2,14.5,24.7,37.9,58.7,74.8,85.1,90.2,94.7,95.3,95.1,94.2,92.9,91.2,88.9,87.1,84.1,81.3,78.6,76.1,74.3,71.1) x=seq(1,25,1) indexx=v } # surr is the number of surrounding # points in polynomial approximation. surr=2 # return NA if NA if (is.na(v))return(NA) #Low speeds dismissed if (v &lt; 3)return(0) # speeds beyond curve correspond to 50 if (v&gt;tail(x,1))return(tail(powerCurve,1)) # determine appropriate extrapolation region. # If wind speed is at the end of the power curve, # don't fit to the right of it. if (indexx&gt;=length(powerCurve)-surr) { rang &lt;- (indexx-surr):length(powerCurve) } # same logic but for low wind speeds else if (indexx&lt;=surr) { rang &lt;-1:(indexx+surr) } # everythin's fine, no special case else { rang &lt;- (indexx-surr):(indexx+surr) } # make polynomial fit with surrounding curve points powwa &lt;- data.frame('speed'=x[rang]) pows &lt;- data.frame('speed'=v) pred &lt;- lm(powerCurve[rang] ~ poly(speed,degree=length(unique(powwa$speed))-1),data=powwa) pows$power &lt;- predict(pred,newdata=pows) if (pows$power[1]&lt;0) return(0) return(pows$power) } wpcm &lt;- function(dats,turbnum) { s &lt;- data.frame('s'=c(1:length(dats))) for (i in 1:length(dats)) { s$s[i] &lt;- Powerm(dats[i],turbnum) } return(s$s) } </code></pre> <p>Here is an example of my usage:</p> <pre><code>s &lt;- data.frame('windSpeed'=seq(0,100,0.001)) # (The true data is not so organized) mean(wpcm(s$colm,2)) </code></pre> <p>I expect an output of average power production corresponding to the set of input wind speed. My problem is that it takes a long time to evaluate big data sets.</p>
24,590,480
0
<p>You are trying to access an array that is not initialized. There is no initialization of >everything&lt; in your code, thus resulting in a NullPointerException.</p>
6,548,914
0
<p>You'd use the <a href="http://msdn.microsoft.com/en-us/library/ms187331.aspx">WAITFOR DELAY</a> statement</p>
34,230,932
0
<p>I know I'm way late to this party but, I think I understand this request to mean that you just want to pass in some properties and generate your query based on those dynamic properties.</p> <p>with the code below I can use any Type and then just populate and pass in an object of that Type with a few values set (I call this my query object), and the query will be generated to go find objects that match the values that you set in your query object.</p> <p>*be careful of bools and things that have default values. </p> <p><strong>Dynamic Query Example</strong></p> <pre><code> public IEnumerable&lt;T&gt; Query&lt;T&gt;(T templateobject) { var sql = "SELECT * From " + typeof(T).Name + " Where "; var list = templateobject.GetType().GetProperties() .Where(p =&gt; p.GetValue(templateobject) != null) .ToList(); int i = 0; Dictionary&lt;string, object&gt; dbArgs = new Dictionary&lt;string, object&gt;(); list.ForEach(x =&gt; { sql += x.Name + " = @" + x.Name; dbArgs.Add(x.Name, x.GetValue(templateobject)); if (list.Count &gt; 1 &amp;&amp; i &lt; list.Count - 1) { sql += " AND "; i++; } }); Debug.WriteLine(sql); return _con.Query&lt;T&gt;(sql, dbArgs).ToList(); } </code></pre> <p><strong>Usage</strong></p> <p>*repo is the class that contains the above function</p> <pre><code>var blah = repo.Query&lt;Domain&gt;(new Domain() { Id = 1, IsActive=true }); </code></pre> <p><strong>Output</strong></p> <pre><code>SELECT * From Domain Where Id = @Id AND IsActive = @IsActive </code></pre> <p>then it spits out any "Domains" that match the above query.</p>
34,734,691
0
<h1>Step 1: Open QtCreator</h1> <p>I assume you already have sucessfully installed QtCreator. Start it up :-)</p> <h1>Step 2: Open the examples</h1> <p>In QtCreator you have a lot of examples that come with the software and is immediately available to test out! All you have to do is open the examples screen and find the example you want. Each example is accompanied with a lot of well written documentation.</p> <p><a href="https://i.stack.imgur.com/kKdfl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kKdfl.png" alt="QtCreator Examples"></a></p> <h1>Step 3: Search for "network"</h1> <p>In your case you want examples related to network programming. Simply type network in the search field (or anything else you want).</p> <p><a href="https://i.stack.imgur.com/iFwnC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iFwnC.png" alt="enter image description here"></a></p> <h1>Step 4: Select the example you want</h1> <p>Actually since you wanted to make a client and a server you will want to look at two separate examples called <strong>blocking fortune client</strong> and <strong>fortune server</strong>.</p> <p><a href="https://i.stack.imgur.com/CjURo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CjURo.png" alt="Blocking fortune example"></a> <a href="https://i.stack.imgur.com/lFg91.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lFg91.png" alt="Fortune server example"></a></p> <h1>Step 5: Configure the examples</h1> <p>When you click the example, QtCreator will ask you to configure the example. This simply means you have to choose which "kit" to compile the project with. This is a side-effect of the awesome fact that Qt supports a lot of platforms and a lot of versions. In your case there should probably be only one or two options. The screen looks like this:</p> <p><a href="https://i.stack.imgur.com/ef5Iy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ef5Iy.png" alt="Configuring a project in QtCreator"></a></p> <h1>Step 6: Build and run the project</h1> <p>I would start the server first and then start the client. They should be able to communicate over network. Please consult the excellent documentation that pops up for each example to find out how it is bestto test them.</p> <p>In general, to run a project, simply select the correct <strong>project/kit/build/run</strong> from the selector (see screenshot) and then press the big green play symbol. This should take some time to build and then start your example.</p> <p><a href="https://i.stack.imgur.com/wKjx1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wKjx1.png" alt="Build and run project in QtCreator"></a></p> <p>There, I hope this got you going on a journey in the world of the really amazing Qt &amp; QtCreator tools!</p>
21,546,695
0
Split php mysql data into 20 rows per column <p>I want to split the data from php mysql into 20 rows per column. Below is my code:</p> <pre><code>while($row = mysql_fetch_assoc($result)) { $id[] = $row['id']; } for($i = 0; $i &lt; 20; $i++) { echo '&lt;table&gt;&lt;tr&gt;'; for ($j = 0; $j &lt; (count($id)-1)/20; $j++) { echo '&lt;td&gt;'.$id[$i + $j * 20].'&lt;/td&gt;'; } echo '&lt;/tr&gt;&lt;tr&gt;'; } echo '&lt;/tr&gt;&lt;/table&gt;'; </code></pre> <p>Let's say I have 21 rows, and the code only output 20 rows, and the 21th row is missing.</p> <p>And if there are 22 rows (as long as the remainder after divided by 20 is more than or less than by 1), there is <code>undefined offset 22, undefined offset 23.....</code> errors.</p> <p>There is something wrong with the inner <code>for</code> loop, but I cannot fix it. How can I fix this error?</p>
5,587,261
0
Getting my Unit of Work to... well, work! <p>I am implementing Unit of Work. This is part of my interface:</p> <pre><code>public interface IUnitOfWork { void Add(object entity); void Update(object entity); void Delete(object entity); void Commit(); } </code></pre> <p>It looks like from examples I've found online or in books, the Unit of Work is forced to work with type "object", as we can be adding any "type" of entity to the uow.</p> <p>Not a big deal until it comes time to Commit(). When I commit, given an entity type, I need to look-up the repository based on the entity type, and then call the appropriate action.</p> <p>For example, I have an entity type named Expert</p> <pre><code>public class Expert { public object ID { get; set; } public string Name { get; set; } } </code></pre> <p>Expert has a repository named ExpertRepository. All Repositories in my application implement IRepository:</p> <pre><code>public interface IRepository&lt;T&gt; { void Create(T item); void Update(T item); void Delete(T item); } public class ExpertRepository : IRepository&lt;Expert&gt; { public void Create(Expert item) { //TSQL to insert } public void Update(Expert item) { //TSQL to update } public void Delete(Expert item) { //TSQL to delete } } </code></pre> <p>I want to clarify that it is not the responsibility of my Repositories to add, update, or delete an entity from my uow, rather, I'll have the consuming code (maybe in a Service Layer) new up the uow, and then add directly to it... when my app is ready, it will call Commit().</p> <p>This does two things. It allows my consuming code to decide how it wants the entity to be persisted. Either the consuming code can call .Create() directly on the Repository to persist the entity with no uow, or the consuming code can start a uow, call .Add() on the uow, and then when .Commit() is called, the uow will go through all entities, and by action type (add, update delete), new up the appropriate repository, and the TSQL code will execute.</p> <p>Now, the problem I'm running into is when I'm looping through the Add, Update, and Delete collections in my uow. Here is a code snippet:</p> <pre><code>public void Commit() { using (TransactionScope tx = new TransactionScope()) { try { foreach (object item in addedItems) { if (item.GetType() == typeof(Expert)) { IRepository&lt;Expert&gt; repository = new ExpertRepository(); repository.Create((Expert)item); } } } } } </code></pre> <p>I have to resolve entity type of what's in the object collection via the item variable. Then I need to new up that entity's Repository (also providing the correct type to the IRepository interface), and then call .Create().</p> <p>That's all well and good, but I don't want to have these conditional checks for every possible entity, for the entity's interface, and the entity's repository sitting in my uow. That's very very bad.</p> <p>I know that an IoC container could help here (such as Unity), but is there any IoC container that can resolve generic types at runtime? I ask, b/c IRepository will need to be typed correctly to be a var that holds the instance of a given entity's repository.</p> <p>I've made some design decisions here such as putting the strong typing with the Repositories, not the UOW. For instance, I don't want a .Create() method sitting on a Repository that takes type object, esp. since my Repositories have a one-to-one relationship with my entities (Expert, ExpertRepository).</p> <p>I've also decided that since most of the repository calls are the same, I don't want an interface for each repository (aka, ExpertRepository implements IExpertRepository). That doesn't make sense, I think using generics here is the answer.</p> <p>But it all comes down to the problem in my uow. How do I get what I need to implement it correctly.</p> <p>Any suggestions or pointers in the right direction would be appreciated.</p> <p>Thanks!</p>
34,588,954
0
How to convert no of days array into json format <p>I have created an array of no of days using the <strong>for loop</strong> </p> <pre><code>$noOfDays=array(); for($i=1;$i&lt;=31;$i++){ if ($i == '1') { $noOfDays[$i]['Number']=$i; $noOfDays[$i]['Days']=$i.' Day'; }else{ $noOfDays[$i]['Number']=$i; $noOfDays[$i]['Days']=$i.' Days'; } } </code></pre> <p>and than converted this array into json </p> <pre><code>echo $noOfDaysjson= json_encode($noOfDays); </code></pre> <p>the $noOfDaysjson returns json as below :-</p> <pre><code>{**"1"**:{"Number":1,"Days":"1 Day"},**"2"**:{"Number":2,"Days":"2 Days"},**"3"**:{"Number":3,"Days":"3 Days"},**"4"**:{"Number":4,"Days":"4 Days"},"5":{"Number":5,"Days":"5 Days"},"6":{"Number":6,"Days":"6 Days"},"7":{"Number":7,"Days":"7 Days"},"8":{"Number":8,"Days":"8 Days"},"9":{"Number":9,"Days":"9 Days"},"10":{"Number":10,"Days":"10 Days"},"11":{"Number":11,"Days":"11 Days"},"12":{"Number":12,"Days":"12 Days"},"13":{"Number":13,"Days":"13 Days"},"14":{"Number":14,"Days":"14 Days"},"15":{"Number":15,"Days":"15 Days"},"16":{"Number":16,"Days":"16 Days"},"17":{"Number":17,"Days":"17 Days"},"18":{"Number":18,"Days":"18 Days"},"19":{"Number":19,"Days":"19 Days"},"20":{"Number":20,"Days":"20 Days"},"21":{"Number":21,"Days":"21 Days"},"22":{"Number":22,"Days":"22 Days"},"23":{"Number":23,"Days":"23 Days"},"24":{"Number":24,"Days":"24 Days"},"25":{"Number":25,"Days":"25 Days"},"26":{"Number":26,"Days":"26 Days"},"27":{"Number":27,"Days":"27 Days"},"28":{"Number":28,"Days":"28 Days"},"29":{"Number":29,"Days":"29 Days"},"30":{"Number":30,"Days":"30 Days"},"31":{"Number":31,"Days":"31 Days"}} </code></pre> <p>but i donot want the no. shown like 1, 2 in bold in json format</p> <p>how can i get json like:-</p> <pre><code>'[{"Number":"1","Days":"1 Day"},{"Number":"2","Days":"2 Days"},{"Number":"3","Days":"3 Days"},{"Number":"4","Days":"4 Days"},....so on]'; </code></pre>
21,918,230
1
Why does IPython notebook only output one DIV from this code? <p>In an IPython notebook I input this code in a cell:</p> <pre><code>from IPython.display import HTML HTML("""&lt;div&gt;One&lt;/div&gt;""") HTML("""&lt;div&gt;Two&lt;/div&gt;""") </code></pre> <p>How come the output cell only contains the second div?</p> <p>EDIT. @Dunno has shown how I can put all the html into one <code>HTML()</code> and both elements are rendered, but I still don't understand what's going on. Here's a more general case:</p> <p>When I enter this in an input cell:</p> <pre><code>1 2 3 </code></pre> <p>The output is </p> <pre><code>3 </code></pre> <p>But if I enter the following:</p> <pre><code>print 1 print 2 print 3 </code></pre> <p>Then I get this output:</p> <pre><code>1 2 3 </code></pre> <p>What's the difference? Is IPython notebook only evaluating the last statement when I don't use <code>print</code> statements? Or is each subsequent evaluation overwriting the previous one?</p>
8,014,404
0
<p>I spent a considerable amount of time looking into this. EventMachine needs to run as a thread in your rails install (unless you are using Thin,) and there are some special considerations for Passenger. I wrote our implementation up here: <a href="http://www.hiringthing.com/2011/11/04/eventmachine-with-rails.html">http://www.hiringthing.com/2011/11/04/eventmachine-with-rails.html</a></p>
30,368,236
0
I receive error message when run JNI android app A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 17729 <p>I got an error when i run android app that I use JNI functions and c++ code in it. When it run, I got below message:</p> <blockquote> <p>Fatal signal 11 (SIGSEGV) at 0xe480001d (code=1), thread 5465</p> </blockquote> <p>And finally here is my codes:</p> <pre><code>JNIEXPORT jstring JNICALL Java_ir_bassir_ndktest4_MainActivity_getName (JNIEnv *env, jobject obj){ jclass cls = (*env)-&gt;GetObjectClass(env, obj); jmethodID mid = (*env)-&gt;GetStaticMethodID(env, cls, "testJava", "([Ljava/lang/String)[Ljava/lang/String"); jstring plainText = (*env)-&gt;NewStringUTF(env, "Hello from JNI ! Compiled with ABI 2222 "); jstring result = (*env)-&gt;CallStaticObjectMethod(env, cls, mid, plainText); return (*env)-&gt;NewStringUTF(env, plainText); } </code></pre> <p>And on the Java side:</p> <pre><code>public class MainActivity extends ActionBarActivity { public native String getName(); public static String testJava(String txt){ Log.d("BP","call back to java method"); String result = txt + "its added in JAVA"; return result; } static{ System.loadLibrary("HelloJNI"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String name = getName(); Log.d("BP",name); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } </code></pre>
10,918,644
0
<p>i use LinearLayout to show webview and setGravity.</p> <pre><code> LinearLayout linearLayout = new LinearLayout(this); linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); linearLayout.setGravity(Gravity.CENTER); WebView view = new WebView(this); linearLayout.addView(view); setContentView(linearLayout); </code></pre> <p>it help you.</p>
24,509,737
1
Dynamically adding a property to a class <p>This has been previously asked on Stack Overflow, but none of the answers seem to address exactly what I need to do. In my case, I want these dynamically-added properties to be a shortcut to store and read values from a database, so unfortunately it's not as easy <a href="https://stackoverflow.com/a/1355444/184363">as in this answer</a> (where a <code>lambda</code> function was used) or <a href="https://stackoverflow.com/q/10967551/184363">this one</a> (where values where stored in a dictionary): I must call other methods of the class.</p> <p>This is my attempt:</p> <pre><code>import operator class Foo(object): def get_value(self, name): # read and return value from database return -1 def set_value(self, name, value): # store value in database pass def add_metadata_property(name): getter = operator.methodcaller('get_value', name) setter = operator.methodcaller('set_value', name) # gets value at runtime setattr(Foo, name, property(getter, setter)) add_metadata_property('spam') f = Foo() f.spam # works! f.spam = 2 </code></pre> <p>The last line, however, raises:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 27, in &lt;module&gt; TypeError: methodcaller expected 1 arguments, got 2 </code></pre> <p>Any ideas on how to achieve this?</p>
40,125,386
0
How to Store a key and value in a cell using ExcelPackage C# <p>Am creating an Excel sheet with dropdown for each cell using ExcelPackage.Now i pass a value to list as 20-APSECE (i.e) StudentId-StudentName so that i can render both id and name while rendering the excel using c#.</p> <p>Is there any other way, that only StudentName should be visible in list of dropdown and should get both StudentId and StudentName while rendering?</p> <p>I tried Formatting the cell but it didn't work.</p>
19,681,548
0
<p>You can override the default form panel to add this functionality. Add the following to your code:</p> <pre><code> Ext.override(Ext.form.Panel, { clearForm:function(){ Ext.each(this.getForm().getFields().items, function(field){ field.setValue(''); }); } }); </code></pre> <p>You can then clear a form using:</p> <p>myForm.clearForm()</p> <p>Where myForm is your form panel.</p> <p>The <code>reset()</code> method just resets the form back to the last record loaded.</p>
1,955,204
0
<p>this is probably the simplest way to do it, <em>using a loop</em>:</p> <pre><code>//counting backwards is easier when you are doing removals from a list for( int i = lst.Count -1; i&gt;= 0; i--) { if(condition1 || condition2) { RemoveFromDB(lst[i]); lst.RemoveAt(i); } } </code></pre> <p>you can refactor that to use the functional methods provided by the framework:</p> <pre><code>var toRemove = lst.FindAll( item =&gt; !PricingOptionIsValid(item) || !item.ItemIsOnSite() ); toRemove.ForEach( item =&gt; { RemoveFromDB(item.ID); lst.Remove(item); }); </code></pre> <p>and you could write this without the toRemove variable, by chaining the ForEach onto the FindAll</p>
13,186,434
0
<p>Again, <strong>without subquery</strong>:</p> <p>Key element is to add <a href="http://www.postgresql.org/docs/current/interactive/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS" rel="nofollow"><strong><code>PARTITION BY</code></strong></a> to the window function(s):</p> <pre><code>SELECT DISTINCT t.section -- ,sum(count(*)) OVER (PARTITION BY t.section) AS tickets_count ,sum(min(a.revenue)) OVER (PARTITION BY t.section) AS atendees_revenue FROM tickets t LEFT JOIN attendees a ON a.id = t.attendee_id GROUP BY t.attendee_id, t.section ORDER BY t.section; </code></pre> <p><a href="http://sqlfiddle.com/#!12/6e522/1" rel="nofollow"><strong>-> sqlfiddle</strong></a></p> <p>Here, you <code>GROUP BY t.attendee_id, t.section</code>, before you run the result through the window function. And use <code>PARTITION BY t.section</code> in the window function as you want results partitioned by section this time.</p> <p>Uncomment the second line if you want to get a count of tickets, too.</p> <p>Otherwise, it works similar to <a href="http://stackoverflow.com/a/13169627/939860">my answer to your previous question</a>. I.e., the rest of the explanation applies.</p>
6,907,640
0
<p>You also could specify a URL (which should return a JSON array of models) on your collection and then do window.Contents.fetch(). Backbone will auto-populate the model (Content) specified in your collection and automatically add them to your collection.</p>
18,842,362
0
<p>when you use <code>Convert.ToInt16</code> you will get this exception if <em>value does not consist of an optional sign followed by a sequence of digits (0 through 9)</em></p> <p>Do a validation for inputs before proceed like below. </p> <pre><code>int orderNo; if (int.TryParse(txtOrderNo.Text, out orderNo)) { DisplayOrder(orderNo); DisplayOrderDetails(orderNo); } </code></pre> <p>Side Note :</p> <p>don't share the <code>SqlConnection</code> create new instant when you need it and wrap it with using block like below </p> <pre><code>using (SqlConnection con = new SqlConnection(connectionString)) { } </code></pre> <p>Use SQL Parameters </p> <pre><code>cmdSelect.CommandText = "SELECT * FROM Orders WHERE OrderNo = @OrderNo"; cmdSelect.Parameters.AddWithValue("@OrderNo", nOrderNo); </code></pre>
27,035,692
0
<p>This line: <code>[self.view removeConstraints:self.view.constraints];</code> removes more on iOS 8 than on iOS 7. The easies way to fix this it to add an array holding the constraints you add to the view and remove only those constraints.</p> <p>Maybe you even can remove this line completely but this depends on your application.</p>
33,475,653
0
<p>Just to close the question.</p> <p>Answer : The update method was getting a wrong argument from its calling method. Hence the output was not as expected. Thanks for pointing out that there might not be any matches for the update statement.</p>
5,358,195
0
<p>Check out <a href="http://www.orchardproject.net/docs/Managing-widgets.ashx" rel="nofollow">this link</a> to understand the concept of layers and zones.</p> <p>Basically, you can customize the zone (a place to put a widget or a place where content goes) layout of a particular page by matching it to a layer (using a rule defined in by the layer). The layer structure allows for inheritance.</p>
17,850,453
0
<p>There is no option for jdbc that looks like Hibernate; I think you have to get a look to specif RDBMS vendor driver options when preparing connection string.</p> <p>About your code you have to use</p> <p><code>BatchPreparedStatementSetter.getBatchSize()</code> </p> <p>or</p> <p><code>JdbcTemplate.batchUpdate(String sql, final Collection&lt;T&gt; batchArgs, final int batchSize, final ParameterizedPreparedStatementSetter&lt;T&gt; pss)</code></p>
11,484,531
0
Using file upload jquery plugin in jsp page with strut action class <p>I know there are many jquery plugins available for file upload.But it just shows how can we added it in the jsp page.But i want to know that how we can deal with the files that are selected using these plugins in the backend.For example am using spring with struts2.So i want to send these files in my action class from my jsp and to store it in the server location.Any body know how can i do it.</p>
30,517,644
0
<p>I don't see you clearing the interrupt. Some UART peripherals require you to clear the interrupt or the interrupt will continue to cycle. Some will clear the interrupt automatically when the data register is read, though, so refer to the peripheral documentation. In my experience an uncleared interrupt is often the cause of a perpetually cycling interrupt.</p> <p>Also, I'm unconvinced it's your problem but, you shouldn't need the</p> <pre><code>MOVS R0, #1 ; MASK all interrupts MSR PRIMASK, R0 </code></pre> <p>and </p> <pre><code>MOVS R0, #0 ; ENABLE all interrupts MSR PRIMASK, R0 </code></pre> <p>sections of code. You shouldn't have to mask any interrupts while in an interrupt. If you're executing from an interrupt context, having properly configured interrupt priorities will stop other interrupts from triggering. </p> <p>Like others say, based on how you're using it, you shouldn't need the assembly code at all, just name your C function "UART_Handler".</p>
28,241,550
0
<p>You need to define a <code>default</code> cursor value for the last cell with CSS:</p> <pre><code>.hover-table-tow:last-child { cursor:default; } </code></pre>
9,563,670
0
How to read Text from pdf file in c#.net web application <p>I am working on one project where there is a functionality need to implement with PDF</p> <p>I want to read the text of PDF file in my c#.net project.</p> <p>Can anyone know what is the way to do so?</p>
15,621,933
0
<p>My guess is that <code>LocalOffer.Category</code> is a single <code>Category</code> (based on the name). Try this instead:</p> <pre><code>return (from o in Table&lt;LocalOffer&gt;() where categories.Contains(o.CategoryId) select o) .Count(); </code></pre> <p>However, if <code>LocalOffer.Category</code> is an <code>IEnumerable&lt;Category&gt;</code>, this is probably what you need:</p> <pre><code>return (from o in Table&lt;LocalOffer&gt;() where o.Any(c =&gt; categories.Contains(c.CategoryId)) select o) .Count(); </code></pre>
21,790,295
0
Move an image with the arrow keys using JavaScript <p>I want to be able to move an image around the screen with JavaScript. The code I have below will put the image on the screen but will not let me move it around.</p> <p>Question: Want to be able to move the image around the screen with the arrow keys?</p> <p>I am certain there has to be a game loop that somehow is running all the time when the page is active. How this is done I am not certain either but I think that it might be int he load function.</p> <p><strong>JavaScript Code:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;Test Move Object&lt;/title&gt; &lt;script type="text/javascript"&gt; &lt;script type="text/javascript"&gt; function leftArrowPressed() { var element = document.getElementById("image1"); element.style.left = parseInt(element.style.left) - 5 + 'px'; } function rightArrowPressed() { var element = document.getElementById("image1"); element.style.left = parseInt(element.style.left) + 5 + 'px'; } function upArrowPressed() { var element = document.getElementById("image1"); element.style.top = parseInt(element.style.top) - 5 + 'px'; } function downArrowPressed() { var element = document.getElementById("image1"); element.style.top = parseInt(element.style.top) + 5 + 'px'; } function moveSelection() { evt = evt || window.event; switch (evt.keyCode) { case 37: leftArrowPressed(); break; case 39: rightArrowPressed(); break; case 38: upArrowPressed(); break; case 40: downArrowPressed(); break; } }; function gameLoop() { // change position based on speed moveSelection(); setTimeout("gameLoop()",10); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="gameLoop()" onkeydown="" onkeyup="" bgcolor='yellow'&gt; Test &lt;img id="image1" src="C:\Users\itpr13266\Desktop\mp.jpg" style="position:absolute;" height="15" width="15"&gt; &lt;/body&gt; end html &lt;/html&gt; </code></pre>
34,916,907
0
How to serialize Out of the box bean <p>We are developing web application using ADF. In this application we are using some classes which are available in third party jars.</p> <p>We are using Weblogic 11g cluster environment for deploying this application. While running the application we are getting error log like "<strong>object can not be serialized</strong>". We are getting this error wherever we are trying to use the classes available in third party JAR.</p> <p>Now my concern is how to serialize these classes? or is there any other way/ setting using which we can avoid this error?</p>
4,683,591
0
<p>For the record, 1.0E-4 = 0.0001.</p>
39,383,051
0
<p>To skip searching for pre-compiled binaries, and force a build from source, use</p> <pre><code>npm install --build-from-source </code></pre>
23,410,158
0
<p><strong>For your <code>ImagePanel</code> class</strong></p> <ol> <li><code>super.paint[Component]</code> <em>before</em> all the other stuff. </li> <li>Don't override <code>paint</code> but instead <code>paintComponent</code></li> <li>Don't set properties in <code>paintComponent</code> method ie <code>setOpaque()</code>. Beside, <code>JPanel</code> is opaque by default</li> <li>Override <code>getPreferredSize()</code> for painting on panels </li> </ol> <p><strong>For loadng images</strong></p> <p>Make a habit of not reading images from the file system, unless the application is specific to <em>only</em> your machine.</p> <p>Instead read from the class path and make the image a resource by packaging it into the class path</p> <ol> <li><p>Change your file structure</p> <pre><code>ProjectRoot src images 3D.jpg </code></pre></li> <li><p>Read from class path. Use <code>ImageIO</code> to make sure your path is correct. If it's invalid, an exception will be thrown</p> <pre><code>URL url = getClass().getResource("/images/3D.jpg"); Image image = ImageIO.read(url); </code></pre></li> </ol> <p><strong>For Netbeans GUI Builder</strong></p> <p>You can set the label icon using the design tool</p> <ol> <li>Select your label from the navigator or the design view. </li> <li>Go to the properties window in the right and find the property <code>icon</code></li> <li>click the ellipses button to the right of the property and a dialog will appear.</li> <li>Find your image and select OK (make sure your image is in a package in the src)</li> </ol> <hr> <p>See <a href="http://stackoverflow.com/a/22146266/2587435">related</a> and <a href="http://stackoverflow.com/a/22214485/2587435">maybe related</a></p>
11,775,572
0
<p>I normally use a try catch for this.</p> <pre><code>try: session.commit() catch: str(sys.exc_info()[0]) + " \nDESCRIPTION: "+ str(sys.exc_info()[1]) + "\n" + str(sys.exc_info()[2]) </code></pre> <p>When I encounter an integrity error, I get the following message and I skip that particular transcation and continue with the rest of them</p> <pre><code>DESCRIPTION: (IntegrityError) duplicate key value violates unique constraint "test_code" DETAIL: Key (test_code)=(5342) already exists. 'INSERT INTO test_table (pk, test_code, test_name) VALUES (%(pk)s, %(test_code)s, %(test_name)s)' { 'pk': '1', 'test_code': '5342', 'test_name': 'test' } </code></pre>
10,423,728
0
<p>Another approach is to use something like the following query, perhaps as a view. It will give you the most recent StatusID for each Person.</p> <pre><code>SELECT PersonID, StatusID FROM ( SELECT PersonID, StatusID, rank() OVER(PARTITION BY PersonID ORDER BY PersonStatusDate DESC) as rnk FROM tPersonStatusHistory ) A WHERE rnk = 1 </code></pre> <p>I'm not sure that this satisfies your requirement for performance, but it's something you could look into.</p>
4,304,034
0
Design using composition and interfaces in Java <p>I designed the following for a problem:</p> <pre><code>class Animal { // ... } class Guppy extends Animal { ... } class Pigeon extends Animal { ... } class TailedAnimal extends Animal { // ... } class Dog extends TailedAnimal { ... } class Cat extends TailedAnimal { ... } class HornedAnimal extends Animal { // ... } class Ram extends HornedAnimal { ... } public static void main(String[] args) { Animal a = getSomeAnimal(); a.doSomething(); if (a instanceof TailedAnimal) { // do something } if (a instanceof HornedAnimal) { // do something else } } </code></pre> <p>Animal, HornedAnimal and TailedAnimal are used mainly as data models.</p> <p>Since Java does not support multiple inheritance, I have trouble creating Rhinoceros which is a Horned and Tailed animal. After asking around, someone recommended using composition and interfaces. I came up with the following:</p> <pre><code>class Animal { // ... } class Guppy extends Animal { ... } class Pigeon extends Animal { ... } class Ram extends Animal implements IHorned { ... } class Cat extends Animal implements ITailed { ... } class Dog extends Animal implements ITailed { BasicTail t = new BasicTail(); public Object getTail() { return t.getTail(); } public void setTail(Object in) { t.setTail(in); } } interface ITailed { public Object getTail(); public void setTail(Object in); //... } class BasicTail implements ITailed { Object myTail; public Object getTail() { return myTail; } public void setTail(Object t) { myTail = t; } } interface IHorned { // getters and setters } public static void main(String[] args) { Animal a = getSomeAnimal(); a.doSomething(); // how do I check if a is horned or tailed? } </code></pre> <p>My questions are:</p> <ol> <li>Is this the correct way of using composition/interfaces?</li> <li>My interface has getters and setters. Is that supposed to be correct? Is there any way to avoid this? Assuming that there is currently no way to abstract the behaviour of Tails and Horns, and they're are being used mainly as data holders.</li> <li>How do I determine if my Animal is Horned or Tailed?</li> </ol>
25,580,979
0
<p>Not sure what you thought was going on in the <code>handleLists</code> part of your script. You just need to wrap the other segment in an iterator (<code>forEach</code>) after finding the elements corresponding to the IDs.</p> <pre><code>var idList= ["MeatList", "Seats", "Lastname"].map(function(id){return document.getElementById(id)}); idList.forEach(function(select){ [].slice.call(select.options) .map(function(a){ if(this[a.value]){ select.removeChild(a); } else { this[a.value]=1; } },{}); }); </code></pre> <p>Of course, this is bad. You should make de-duplicating a function of it's own, eg.:</p> <pre><code>function deDuplicate(select){ [].slice.call(select.options) .map(function(a){ if(this[a.value]){ select.removeChild(a); } else { this[a.value]=1; } },{}); } </code></pre> <p>and then:</p> <pre><code>var idList= ["MeatList", "Seats", "Lastname"].map(function(id){return document.getElementById(id)}); idList.forEach(function(select){ deDuplicate(select); }); </code></pre> <p>Personally I recommend learning/using CoffeeScript as it <em>uncrufts</em> Javascript a great deal, the de-dupe looks like this:</p> <pre><code>deDuplicate = (select)-&gt; [].slice.call(select.options).map (a)-&gt; if @[a.value] select.removeChild a else @[a.value] = 1 , {} </code></pre> <p>and then wrapped you can do:</p> <pre><code>deDuplicate select for select in ["MeatList", "Seats", "Lastname"].map (id)-&gt; document.getElementById id </code></pre> <p>Which reads more plainly as english, at least to me it does. As always YMMV.</p>
30,952,827
0
Proximity of polylines in time <p>Given two paths in 2D, each described as a polyline (sequence of points where each two consecutive points are connected by a straight line), I would like to find the parts of the paths that are closer than a given distance d; i.e. areas of proximity within certain bound d.</p> <p>Is there a JAVA/Scala API that provides this functionality? If not, any ideas for efficient algorithm that would do the job?</p>
32,877,091
0
<p>Depending on exactly what you are doing, it might be easier to make a real parser.</p> <pre><code>{-# LANGUAGE FlexibleContexts #-} import Text.Parsec import Text.Parsec.Char singleQuotedStrings = many (char '\'' *&gt; many letter &lt;* char '\'') main = print $ parse singleQuotedStrings [] "'all''your''base''belong'" </code></pre>
20,329,363
0
<p>this trick may help you on getting the scrollbar width for any browser, you can use it as a function:</p> <p><a href="http://stackoverflow.com/questions/986937/how-can-i-get-the-browsers-scrollbar-sizes">How can I get the browser&#39;s scrollbar sizes?</a></p> <p>and if you're woried about leaving the white space if the scrollbar isn't showing, you can force it with css:</p> <pre><code>body { overflow-y: scroll; } </code></pre>
3,350,103
0
<p>Here is my solution: <a href="http://jsbin.com/oteze/8" rel="nofollow noreferrer">http://jsbin.com/oteze/9</a> I tested it on Firefox 3.6.8. ADD: Now it works in IE7 too.</p> <p>You can nest any number of submenus anywhere. Just like that:</p> <pre><code>&lt;li&gt;&lt;a href="#"&gt;Child 1.2&lt;/a&gt; &lt;ul class="child"&gt; &lt;li&gt;&lt;a href="#"&gt;Child 1.2.1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Child 1.2.2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; </code></pre> <p>I modified your code a little, so there is difference between first level submenu and other levels. I also moved all show/hide logic to JS.</p> <pre><code> $(document).ready(function() { $("#Programming ul.child-first-level").hide(); $("#Programming ul.child").hide(); $("#Programming ul.child").each(function(index) { $(this).css("margin-left", $(this).parent().css("width")); }); $("#Programming li ul.child-first-level").parent().hover( function() { $(this).children("ul").fadeIn(); }, function() { $(this).children("ul").stop(true, true).css("display", "none"); } ); $("#Programming li ul.child").parent().hover( function() { var offset = $(this).children("ul").offset(); offset.top = 0; $(this).children("ul").offset(offset); $(this).children("ul").css("margin-left", $(this).parent().css("width")); $(this).children("ul").fadeIn(); }, function() { $(this).children("ul").stop(true, true).css("display", "none"); } ); }); </code></pre>
31,839,696
0
<p>Basically, to run function in x seconds, use <code>setTimeout</code></p> <pre><code>setInterval( function () { //do magic here every 2seconds }, 2000); </code></pre> <p>And for updating chart.js data refer to this <a href="http://stackoverflow.com/a/20100851/2308005">answer</a></p>
36,746,229
0
React Redux routing - is there something simple that just works and isn't going to change in 12 hours? <p>Without hopefully having to go into all the options and issues, does anyone have or know of a solid routing solution that is simple and just works for a React Redux combination? If so can you please provide a complete working reference including history, transitions, params, and so on?</p> <p>Not sure how we ended up with 10 or more solutions to something that should be a core need for any real application, but the sheer number and constant flux (no pun intended) of the solutions out there make it seems like a nearly impossible task to zero in on anything in any timely manner. They seem to be growing in complexity as well and almost battling against each other in some cases.</p> <p>If Dan or anyone else is going to link to the Redux real world example, please comment on the plan to address <a href="https://github.com/reactjs/redux/issues/637" rel="nofollow">this</a> issue/discussion. For simple router (or whatever we're calling it this week), or any of the other like Tiny, or the plethora of others, please clarify where history should come from (history lib router, your lib...) and why as well as how to handle params and such.</p> <p>TIA</p>
39,202,257
0
What is Android's google app theme? <p>I am building an Android app and need to make it look like Android's stock google app (the one with the "G" icon) or google maps app. What theme are these google apps using? </p> <p>The TripAdvisor app, for instance, has a very similar look and feel as the default google app. Is it possible to achieve the same look and feel like the stock google apps?</p> <p>Would someone please let me know? Thanks!</p>
580,020
0
<p>I'd hybrid this. <strong>Design it for the ability to use separate databases, but don't separate until there is a clear performance benefit.</strong></p> <p>Design your application so that multiple clients can exist in the same database. (i.e. build a layer of separation between client data). Then plan for it all to be in one database.</p> <p>That way, you don't overarchitect your solution to start out with, but it gives you the flexibility to spin off very high-usage clients to a dedicated database. If your database exists with only one client in it, so what? This will also save on server costs so that you can be sure that you're using the hardware investment in a reasonable way already before adding more capacity.</p>
7,640,695
0
<p>Just because people have written the code and made the source available doesn't mean that it's always going to be good code.</p> <p>The principles you're used to (small classes that do their one thing well) is a good one. But not every developer follows those principles.</p> <p>In the PHP world, a lot of people have worked their way up through it from the early days, when everything was in a single procedural monolithic block of code -- and I've seen some horrendous examples of that still in everyday use. Converting one's mindset from that to an OOP structure at all can be a big leap for some people, and even for people who haven't come from that background, a lot of the code examples they would be learning from are, so it's not a surprise to see monster classes.</p> <p>The short answer is to write code the way you're comfortable with and the way you've been taught. It sounds like you've got better coding practices ingrained into you than most PHP developers out there, so don't feel you have to change just because other people are doing things differently.</p>
26,880,519
1
How does tastypie handle comlex url? <p>Tastypie can automatically generate urlpattern for simple resource urls.</p> <p>For example, <code>/user/1/</code> , <code>/group/2/</code>, I only need to define UserResource and GroupResource</p> <p>But what if I have API url like <code>/group/2/user/</code>, saying I want to retrieve all users in group 2.</p> <p>Does tastypie have any solution to handle this?</p>
22,820,729
0
<p>Well, I am not sure what you really want on this.</p> <p>But this is not the way to go.</p> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects" rel="nofollow" title="Working with objects">Here</a> you have an tutorial so you can have a better idea in how to use Objects in JScript, I am a bit rusty in JScripts so I read that tutorial last week, and it helped me a lot.</p> <p>This code you posted is a bit difficult to understand the goal, if you could clear this, I can help you better.</p>
24,036,058
0
How to embed a link in email message for file attached in email using JavaMail API? <p>I want to embed a link in email for file already attached in email message using JavaMail API.</p> <p>For example, I am sending an email with some attachments. Now I want to embed link for all files which are available in email message.</p> <p>Could you please help me on this?</p> <p>I am using below code to attach a file in email message:</p> <pre><code>MimeBodyPart messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(attachFile); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(attachFileName); </code></pre>
14,799,164
0
<p>Something like this perhaps?</p> <pre><code>use strict; use warnings; use autodie; my @data; for my $file (qw/ file1.txt file2.txt /) { open my $fh, '&lt;', $file; local $/; my $data = &lt;$fh&gt;; my $i = 0; push @{$data[$i++]}, $_ for $data =~ /[0-9.]+/g; } my $divisor = pop @data; for (@data) { my $val = $_-&gt;[0] / $divisor-&gt;[0] - $_-&gt;[1] / $divisor-&gt;[1]; printf "%.10f\n", $val * $val; } </code></pre> <p><strong>output</strong></p> <pre><code>0.0000000000 0.0000004258 0.4258414140 0.0000004929 1.3263326558 0.0227301083 0.0000000248 0.0504327886 0.0000000591 0.2468596095 0.4159147013 0.0000004497 0.4545017058 0.0000005315 1.2770423982 0.0947597910 0.0000001021 0.0140095243 0.0000000159 0.4442444469 </code></pre>
31,579,316
0
Rewriting sql query <p>I have where clause in my rails app that looks like this:</p> <pre><code>Report.where("lower(coalesce(#{organization_tables_with_name.join(',')})) LIKE lower(?)","%#{organization_name}%") </code></pre> <p>it works as expected but this code is vulnerable to sql injection. I rewrite this to something like that:</p> <pre><code>Report.where("lower(coalesce(?)) LIKE lower(?)", organization_tables_with_name,"%#{organization_name}%") </code></pre> <p>but this not works. The problem is that after sending to coalesce paremeter it makes quotes around it:</p> <pre><code>WHERE(lower(coalesce('k12_seas.name,k12_leas.name,k12_schools.name,k12_sections.name')) </code></pre> <p>but it should be:</p> <pre><code>WHERE (lower(coalesce(k12_seas.name,k12_leas.name,k12_schools.name,k12_sections.name)) </code></pre> <p>how can I solve this problem?</p>
21,642,178
0
<p>Abstract classes are used to provide common functionality to child classes and force child to have own implementation of abstract members. it cannot be initialized, so individually it is not an object, but takes part in behaviour of child class</p> <pre><code> public abstract void Import(Oasis OasisSource); </code></pre> <p>If you want all children of this abstract class to implement there own <code>Import</code> functionality, otherwise implement the functionality in the base abstract class, mark it as virtual so the children can override if necessary.</p>
29,224,315
0
<p>You can use the <code>mapvalues</code> function from the <code>plyr</code> package. Try this code snippet, which assumes that you have a factor column in a data frame called <code>df$column</code>:</p> <pre><code>library(plyr) vals_to_replace &lt;- c("diet", "diet contr", "IDDM") mapvalues(df$column, from = vals_to_replace, to = rep("No", length(vals_to_replace))) </code></pre> <p>You can add as many factor names to <code>vals_to_replace</code> as you like.</p>
23,059,760
0
Cannot iterate over ExecutionResult <p>I have written a test, copying the official cypher query example from <a href="http://docs.neo4j.org/chunked/stable/tutorials-cypher-java.html" rel="nofollow">here</a> and adding a needed cast. Then it fails with: <code>java.lang.ClassCastException: scala.collection.Iterator$$anon$11 cannot be cast to java.util.Iterator ...</code>. This is the code:</p> <pre class="lang-java prettyprint-override"><code>@Test public void testCreateWithCypher() { ExecutionEngine engine = new ExecutionEngine(db, StringLogger.SYSTEM); try (Transaction transaction = db.beginTx()) { String cypher = "CREATE (x:Person {name: 'John'})" + "RETURN x"; ExecutionResult result = engine.execute(cypher); Iterator&lt;Node&gt; n_column = (Iterator&lt;Node&gt;) result.columnAs("x"); for (Node node : IteratorUtil.asIterable(n_column)) { String nodeResult = node + ": " + node.getProperty("name"); } transaction.success(); } } </code></pre> <p>Without the cast, it will not compile, since <code>columnAs</code> returns <code>Iterator&lt;Object&gt;</code>. What is this <code>scala.collection.Iterator$$anon$11</code> doing the by the way? I thought it <a href="http://api.neo4j.org/2.1.0-M01/org/neo4j/graphdb/ResourceIterator.html" rel="nofollow">extended</a> <code>java.lang.Iterator</code>? </p> <p>I just want an <code>Iterator&lt;Node&gt;</code> so that I can get stuff from the <code>ExecutionResult</code>. How can do that without the cast? My project uses these dependencies for <code>${neo4.version}</code> = 2.0.1:</p> <pre class="lang-xml prettyprint-override"><code> &lt;dependency&gt; &lt;groupId&gt;org.neo4j&lt;/groupId&gt; &lt;artifactId&gt;neo4j&lt;/artifactId&gt; &lt;version&gt;${neo4j.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.neo4j&lt;/groupId&gt; &lt;artifactId&gt;neo4j-cypher&lt;/artifactId&gt; &lt;version&gt;${neo4j.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.neo4j&lt;/groupId&gt; &lt;artifactId&gt;neo4j-kernel&lt;/artifactId&gt; &lt;version&gt;${neo4j.version}&lt;/version&gt; &lt;type&gt;test-jar&lt;/type&gt; &lt;/dependency&gt; </code></pre>
38,679,082
0
Breadth-first search with set instead of queue <p>I'm using BFS to find connected components. I've decided to implement it using a set to track visited nodes. The problem with that approach is that one vertex may be added to queue twice. So I just changed queue to set. I don't care about visit order, all nodes are visited once and the algorithm works fine. Of course, this is not classical BFS anymore: the order is broken. </p> <p>Pseudocode:</p> <pre><code>Set visited; Set to_visit; visited.insert(start) to_visit.insert(start) while (to_visit is not empty){ current = to_visit.first to_visit.delete(current) for each neighbour of current { isNew = visited.insert(neighbour) if (isNew) { to_visit.insert(neighbour) } } } </code></pre> <p>I'm pretty sure I'm not the first one who "invented" it. I wonder: how does this I-dont-care-first search is called? </p>
5,178,310
0
<pre><code>String a[]=null; </code></pre> <p><code>null</code> assigned before processing, so <code>NullPointerException</code>!</p> <p>try</p> <pre><code>String[] a=new String[100]; </code></pre> <p>or something;</p>
20,195,839
0
<p>There is none, you can starting in-app preferences though.. But linking to the Apple preferences app has been deleted.</p>
23,284,022
0
mongoose/mongodb querying for records without a related record <p>I have two mongoose models. Let's call one model foo and the second model bar. Bar records have a related foo record and an email address. I want my api to be passed an email address and return a list of foo records that do not have a bar record created with that email address. How would I go about doing this with mongoose?</p> <p>I know I could write this query with SQL but ive been trying to learn a no sql db, hence mongo.</p> <p>Here is an example. I have 2 foo records and 2 bar records:</p> <p>foos:</p> <pre><code>{name:"first foo"} {name:"second foo"} </code></pre> <p>and my bar records:</p> <pre><code>{ email:"[email protected], foo_id:first_foo._id } { email:"[email protected], foo_id:second_foo._id } </code></pre> <p>The request to my api would come in with email: [email protected]. In this case, I would want to return the second foo (and any other foo records) because first foo has a bar record with the email in the request. </p>
10,751,185
0
smarty : assign var and scope root <p>I have a template in smarty like this :</p> <ul> <li>Template folder <ul> <li>home.tpl</li> <li>article.tpl</li> <li>category.tpl</li> <li>var.tpl</li> </ul></li> </ul> <p>In each template file (except var.tpl), i include the file var.tpl. home.tpl have a structure in 1 column article.tpl have a structure in 2 columns</p> <p>My template files are like this (home example) :</p> <pre><code>{include file="$tpl_dir./var.tpl"} &lt;div class="span{$center_column}" id="center_column"&gt; &lt;/div&gt; </code></pre> <p>In order to change quickly the apparence of my website, i wrote the following lines in var.tpl :</p> <pre><code>{assign var=center_column_g value=['home'=&gt;'12','article'=&gt;'10'] scope="root"} {assign var=center_column_default value='10' scope="root"} {if $center_column_g[$page_name]} {assign var=center_column value=$center_column_g[$page_name] scope="root"} {else} {assign var=center_column value=$center_column_default scope="root"} {/if} </code></pre> <p>ps : $page_name is a global variable with the name of each template page.</p> <p>So with var.tpl, if i can easy change the class of my div #center_column</p> <p>I have a doubt with this code :</p> <pre><code>{if $center_column_g[$page_name]} {assign var=center_column value=$center_column_g[$page_name] scope="root"} {else} {assign var=center_column value=$center_column_default scope="root"} {/if} </code></pre> <p>Is it right to assign var center_column in the root scope ?</p>
17,160,882
0
<p>This error happens because you are persisting a new object attached to an object that already exist. Invoke the <code>crear</code> method in the <code>ocurrence</code> object before adding <code>personas</code> to the list. </p>
39,035,762
0
<pre><code>img{ display: block; margin-right: auto; margin-left: auto; } </code></pre>
15,939,159
0
Mixed Content Warning for Forum Design <p>I'm currently designing a social network on my local host, that also has a forum aspect involved. There are three things that a user can do on the site that is causing me some concern. </p> <ol> <li>Log in to their profile via the header from any page on the site.</li> <li>Post things on their wall that include links to external sites.</li> <li>Post in the forum a variety of different things including links to external sites, and images on external sites.</li> </ol> <p>Because of #1 I made the entire site https. So no matter where a user was on the site, they could log in and their entire session would be encrypted. This functionality is working great but I am afraid of <code>Mixed Content Warnings</code>.</p> <p>Right now I'm thinking twice about making the full site secure b/c if I keep it this way will mixed content warnings appear for every page that has a link to an external site, or an image from an external site? Unfortunately I have never seen this warning b/c none of the browsers I use seem to show it to me. And I searched for some kind of list of browsers that show this warning but there is no finite list that I can find. So this is awkward b/c I'm worrying and trying to avoid a thing that I've never seen. But I have thought of one solution.</p> <p>My current idea on how to fix the image problem is to take images from users when they post a forum and write them to my disk, and provide the new image link. I am pretty sure this is exactly how google images stays https while showing millions of images from http sites. I think they write them all to their own server. Example: </p> <p><a href="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTj_52I-TSX79mQFJRLTDNGahtGbsh_BpYDp0H3hbzJDWK2qxPZ" rel="nofollow">https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTj_52I-TSX79mQFJRLTDNGahtGbsh_BpYDp0H3hbzJDWK2qxPZ</a></p> <p>So I think I have found a solution to the image problem but what about external links? Because when a user posts a link on their wall to <a href="http://stackoverflow.com/">http://stackoverflow.com/</a> for example I read the post and surround it with an anchor tag so technically to a browser wouldn't that be none secure content? Wouldn't that throw a warning? </p> <p>How could I fix this and not annoy my users? And do you have a better solution to my image problem? Thank you all for reading through my confusion.</p>
11,567,147
0
Why did RVM break my MANPATH on mac osx? <p>Ever since installing RVM, my manpages are broken. Current versions of man don't use the MANPATH variable, so why is it being set to .rvm/man and why isn't there a full catalog of manpages inside that folder?</p>
25,300,724
0
show item number total only in the minicart <p>I want to show item number total only in the minicart that is in the header.(OpenCart v1.5.6.4)</p> <p><strong>I get this currently</strong> (according to OpenCart functionality)</p> <pre><code>==For O item== Shopping Cart 0 item(s) - $0.00 ==For 1 item== Shopping Cart 1 item(s) - $100 </code></pre> <p><br> <strong>But what I'm hoping to get is</strong></p> <pre><code>==For O item== Shopping Cart 0 ==For 1 item== Shopping Cart 1 </code></pre> <p>Any help would be greatly appreciated. Thanks</p>
29,226,973
0
How to disable the jquery validator 1.13.1 to create new html for error message and use the existing one <p>I am working with jQuery Validator 1.13.1 and I have recently upgraded from JQuery Validator 1.9.0. Now the issue is I was using predefined html for displaying my error messages instead of making jquery validator to create a new html for error message for example:</p> <p>Using jQuery Validator 1.9.0</p> <pre><code>&lt;span for='first_name' class='error' generated='true'&gt;&lt;/span&gt; jQuery(".form-cls").validate({ errorElement: "span", errorClass: "error", , </code></pre> <p>and it was working fine.</p> <p>and now in jQuery Validator 1.13.0</p> <pre><code>&lt;span id="first_name-error" class="error"&gt;&lt;/span&gt; jQuery(".form-cls").validate({ errorElement: "span", errorClass: "error", errorPlacement: function(error, element) { if(element[0]) { jQuery('#'+element[0].id+'-error').replaceWith(error); } </code></pre> <p>Now the jquery validator is using the existing error to display error as well as it creates a new one. Kindly suggest me how can I disable jquery validator to create a new for error message and use the existing one. I dont want to use errorPlacement thing :( },</p>
9,178,071
0
<p>You still need to use <code>IList&lt;T&gt;</code> instead of <code>List&lt;T&gt;</code>, because NH needs its own collection implementation.</p> <p>Consider:</p> <ul> <li>You won't get very far in a complex model without lazy loading, except your database fits into RAM or you don't mind to cut you OO model into pieces which destroys both maintainability and performance.</li> <li>You can have entities without virtual members when you use interfaces to create proxies from. However, you should only use these interfaces to reference to entities, because they could always be proxies.</li> </ul>
20,237,959
0
<p>Firstly, the cast to <code>int</code> is counter productive. You have <code>float</code> values and don't want to loose precision by casting to <code>int</code>, which will always be one of <code>{0, 1 ... 4 * radius^2}</code>.</p> <p>Furthermore, the comparison to <code>== 0</code> needs some luck to be hit. If you want to fill the circle, use <code>&lt;= 0</code> or if you want to draw a line try something like <code>abs(...) &lt;= epsilon</code> where epsilon is some small number that describes the line's thickness.</p> <p>Be aware that you just set the r-component of the returned color of 1. This does not need to result in a red circle (e.g. if you already have a white texture).</p> <p>I would do something like the following:</p> <pre><code>float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 { float dx = coords.x - 0.5f; float dy = coords.y - 0.5f; if(dx * dx + dy * dy &lt;= 0.25f) return float4(1.0f, 0.0f, 0.0f, 1.0f); else return float4(0.0f, 0.0f, 0.0f, 0.0f); } </code></pre> <p>Notice that you don't need an explicit radius or center because the texture coordinates are normalized.</p>
38,383,183
0
<p>No params, just the 'Authorization' header.</p> <p>Use the "OAuth Signature Generator" on the link you included to generate a test request and confirm yourself.</p> <p>You just need to properly sign the request. This provides the context including the user, since it implicitly includes details about your request, the client secret, the user token etc.</p> <pre><code>$ oksocial https://api.twitter.com/1.1/account/verify_credentials.json { "id": 999999, "id_str": "999999", "name": "Bobby Bonson", "screen_name": "xxxx", "location": "CA", "description": "...", "url": null, "entities": { "description": { "urls": [] } }, "protected": false, "followers_count": 699, "friends_count": 631, "listed_count": 34, </code></pre>
20,494,976
0
Image path for displaying on a user profile <p>I have managed to find the code I needed but just have some questions that need answering so that I understand as I am a little confused. I understand that the below code allows me to upload an image but what I cant get my head around is how i would display the image for a profile picture, by this I mean what path would I use to locate the image for the individual user. I just need this explaining to me so that I understand it</p> <p>Many Thanks the code I am using for uploading the image is below</p> <pre><code>&lt;!--- set the full path to the images folder ---&gt; &lt;cfset mediapath = expandpath('./images')&gt; &lt;!--- set the desired image height ----&gt; &lt;cfset thumbsize = 75&gt; &lt;!--- set the desired image width ---&gt; &lt;cfset imagesize = 320&gt; &lt;cfif structKeyExists(form,"fileUpload") and len(form.fileUpload)&gt; &lt;cffile action="upload" filefield="FileUpload" destination="#MediaPath#" nameconflict="makeunique"&gt; &lt;!--- read the image ----&gt; &lt;cfimage name="uploadedImage" source="#MediaPath#/#file.serverFile#" &gt; &lt;!--- figure out which way to scale the image ---&gt; &lt;cfif uploadedImage.width gt uploadedImage.height&gt; &lt;cfset thmb_percentage = (thumbsize / uploadedImage.width)&gt; &lt;cfset percentage = (imagesize / uploadedImage.width)&gt; &lt;cfelse&gt; &lt;cfset thmb_percentage = (thumbsize / uploadedImage.height)&gt; &lt;cfset percentage = (imagesize / uploadedImage.height)&gt; &lt;/cfif&gt; &lt;!--- calculate the new thumbnail and image height/width ---&gt; &lt;cfset thumbWidth = round(uploadedImage.width * thmb_percentage)&gt; &lt;cfset thumbHeight = round(uploadedImage.height * thmb_percentage)&gt; &lt;cfset newWidth = round(uploadedImage.width * percentage)&gt; &lt;cfset newHeight = round(uploadedImage.height * percentage)&gt; &lt;!--- see if we need to resize the image, maybe it is already smaller than our desired size ---&gt; &lt;cfif uploadedImage.width gt imagesize&gt; &lt;cfimage action="resize" height="#newHeight#" width="#newWidth#" source="#uploadedImage#" destination="#MediaPath#/#file.serverFile#" overwrite="true"/&gt; &lt;/cfif&gt; &lt;!--- create a thumbnail for the image ---&gt; &lt;cfimage action="resize" height="#thumbHeight#" width="#thumbWidth#" source="#uploadedImage#" destination="#MediaPath#/thumbs/#file.serverFile#" overwrite="true"/&gt; &lt;cfoutput&gt; &lt;img src="images/thumbs/#file.serverFile#" height="#thumbHeight#" width="#thumbWidth#" align="left" hspace="10"&gt;&lt;br&gt; Original Image: #uploadedImage.width#x#uploadedImage.height#&lt;br&gt; Resized Image: #newWidth#x#newHeight#&lt;br&gt; Thumbnail: #thumbWidth#x#thumbHeight#&lt;br&gt;&lt;br&gt; &lt;a href="images/#file.serverFile#"&gt;See Image&lt;/a&gt;&lt;br&gt; &lt;/cfoutput&gt; &lt;/cfif&gt; &lt;form action="" method="post" enctype="multipart/form-data"&gt; &lt;label for="fileUpload"&gt;Choose Image: &lt;/label&gt; &lt;input type="file" name="fileUpload"&gt; &lt;input type="submit" value="Upload Image"&gt; &lt;/form&gt; </code></pre>
35,360,950
0
iReport : expression with BigDecimal not correct <p>I have a textfield with this expression : </p> <pre><code>($V{caBrut3}.add($V{remiseRistourne3}).add($V{frais3}).subtract($V{montantAchat1})).divide($V{caBrut3}.add($V{remiseRistourne3}).add($V{frais3})) </code></pre> <p>iReport tells me that this expression is not valid (closing bracket before divide seems to be the problem). I don't see why. </p> <p>I want to divide the first part (before divide) with the second part. </p> <p>How can I do that with BigDecimal values?</p>
12,268,882
0
<p>This is saying, essentially, "For each line in the file, split the line on the tab character into an array of strings, then create an array of those arrays (such that each element in the returned array is an array)"</p> <p>The <code>Select</code> function takes an Enumerable of something and applies a function to each item, producing 1 output value for each input value. In other programming languages this is called a Map or a Projection.</p> <p>The => indicates a lambda expression which is compiled into a delegate function. It takes an argument called "line", whose type is inferred by the usage (because <code>ReadLines</code> returns an IEnumerable of Strings, <code>line</code> is of type String).</p> <p>The lambda's body has an implied return type of the value resulting from the last call (the call to <code>Split</code>). Thus, the line says "run this lambda on each line".</p> <p>Finally, the call to <code>.ToArray</code> at the end (outside of the lambda) converts the <code>IEnumerable&lt;String[]&gt;</code> returned by <code>Select</code> into an array of arrays (<code>String[][]</code>).</p>
18,733,273
0
<p>I have found link which can help you to talking api</p> <p><a href="https://github.com/xively/xively-rb/wiki/Talking-to-the-REST-API" rel="nofollow">https://github.com/xively/xively-rb/wiki/Talking-to-the-REST-API</a></p> <p>you can use</p> <pre><code>client = Xively::Client.new(YOUR_API_KEY) response = client.post('/v2/feeds.json', :body =&gt; feed.to_json) puts response.headers['location'] # Will give us the location of the Xively feed including the ID =&gt; "http://api.xively.com/v2/feeds/SOMEID" </code></pre> <p>Create a Datapoint</p> <p>The datapoint creation endpoint takes an array of datapoints</p> <pre><code> datapoint = Xively::Datapoint.new(:at =&gt; Time.now, :value =&gt; "25") client.post('/v2/feeds/504/datastreams/temperature/datapoints', :body =&gt; {:datapoints =&gt; [datapoint]}.to_json) </code></pre>
7,235,693
0
<p>I had the same problem recently. Try adding <code>display: none;</code> to the container div. That will prevent it from showing that split-second flash. You can change <code>none;</code> to <code>block;</code> through jQuery after loading completes with: </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#whateverSelector').show(); }); &lt;/script&gt; </code></pre> <p>You can either put this at the end of the document before the <code>&lt;/body&gt;</code> or (better yet) before the <code>&lt;/head&gt;</code>.</p> <p>Perhaps the <code>none;</code> is being over-written somewhere in the CSS. Try adding the style inline to see if you can sort-of "force" it to work. This this in the HTML: <code>&lt;div class="orbit-wrapper" style="display:none;"&gt;...</code> I hope that helps.</p>
3,856,100
0
iPhone app crash on iOS 4.0 <p>All crash reports submitted for our application on iOS 4.0 are giving the below information:</p> <pre><code>Application Specific Information: &lt;my app name&gt;[3532] was suspended with locked system files: /private/var/mobile/Library/AddressBook/AddressBook.sqlitedb </code></pre> <p>Any idea what this indicates and what could be the possible cause of crash. Our application is not interacting with AddressBook.sqlitedb at all.</p> <p>The complete crash log:</p> <pre><code>Exception Type: 00000020 Exception Codes: 0xdead10cc Highlighted Thread: 0 Application Specific Information: app name[3532] was suspended with locked system files: /private/var/mobile/Library/AddressBook/AddressBook.sqlitedb Thread 0: 0 libobjc.A.dylib 0x3302e4ac object_dispose 1 CoreFoundation 0x31372cfe -[NSObject(NSObject) dealloc] 2 QuartzCore 0x33e45264 -[CALayer dealloc] 3 QuartzCore 0x33eb5e60 -[CALayer _dealloc] 4 QuartzCore 0x33e3c752 CALayerRelease 5 QuartzCore 0x33e3cd20 CA::release_root_if_unused(_CALayer*, _CALayer*, void*) 6 QuartzCore 0x33e3ccbc x_hash_table_remove_if 7 QuartzCore 0x33e3cb26 CA::Transaction::commit() 8 QuartzCore 0x33e42406 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) 9 CoreFoundation 0x313caa42 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 10 CoreFoundation 0x313cc46e __CFRunLoopDoObservers 11 CoreFoundation 0x313cd774 __CFRunLoopRun 12 CoreFoundation 0x313768e4 CFRunLoopRunSpecific 13 CoreFoundation 0x313767ec CFRunLoopRunInMode 14 GraphicsServices 0x329f36e8 GSEventRunModal 15 GraphicsServices 0x329f3794 GSEventRun 16 UIKit 0x316692a0 -[UIApplication _run] 17 UIKit 0x31667e10 UIApplicationMain 18 app name 0x00002a64 main + 36 19 app name 0x00002a34 start + 32 Thread 1: 0 libSystem.B.dylib 0x35228c4c kevent + 24 1 libSystem.B.dylib 0x352d1e44 _dispatch_mgr_invoke 2 libSystem.B.dylib 0x352d1894 _dispatch_queue_invoke 3 libSystem.B.dylib 0x352d1a34 _dispatch_worker_thread2 4 libSystem.B.dylib 0x35275d82 _pthread_wqthread 5 libSystem.B.dylib 0x3526efcc start_wqthread + 0 Thread 2: 0 libSystem.B.dylib 0x351fc6b4 semaphore_wait_signal_trap + 8 1 libSystem.B.dylib 0x35229d92 semaphore_wait_signal 2 libSystem.B.dylib 0x351fe4a4 pthread_mutex_lock 3 WebCore 0x30138194 _WebTryThreadLock(bool) 4 WebCore 0x301380da WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) 5 CoreFoundation 0x313caa42 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 6 CoreFoundation 0x313cc46e __CFRunLoopDoObservers 7 CoreFoundation 0x313cd780 __CFRunLoopRun 8 CoreFoundation 0x313768e4 CFRunLoopRunSpecific 9 CoreFoundation 0x313767ec CFRunLoopRunInMode 10 WebCore 0x30138056 RunWebThread(void*) 11 libSystem.B.dylib 0x35275986 _pthread_start 12 libSystem.B.dylib 0x3526b0e4 thread_start + 0 Thread 3: 0 libSystem.B.dylib 0x351fc658 mach_msg_trap + 20 1 libSystem.B.dylib 0x351fe724 mach_msg 2 CoreFoundation 0x313cb2c8 __CFRunLoopServiceMachPort 3 CoreFoundation 0x313cd582 __CFRunLoopRun 4 CoreFoundation 0x313768e4 CFRunLoopRunSpecific 5 CoreFoundation 0x313767ec CFRunLoopRunInMode 6 Foundation 0x3329571e +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] 7 Foundation 0x33265c96 -[NSThread main] 8 Foundation 0x332ea9da __NSThread__main__ 9 libSystem.B.dylib 0x35275986 _pthread_start 10 libSystem.B.dylib 0x3526b0e4 thread_start + 0 Thread 4: 0 libSystem.B.dylib 0x35220a20 select$DARWIN_EXTSN + 20 1 CoreFoundation 0x313d0e70 __CFSocketManager 2 libSystem.B.dylib 0x35275986 _pthread_start 3 libSystem.B.dylib 0x3526b0e4 thread_start + 0 Thread 5: 0 libSystem.B.dylib 0x3527685c __workq_kernreturn + 8 1 libSystem.B.dylib 0x35275e98 _pthread_wqthread 2 libSystem.B.dylib 0x3526efcc start_wqthread + 0 Thread 6: 0 libSystem.B.dylib 0x3527685c __workq_kernreturn + 8 1 libSystem.B.dylib 0x35275e98 _pthread_wqthread 2 libSystem.B.dylib 0x3526efcc start_wqthread + 0 Thread 7: 0 libSystem.B.dylib 0x35205974 access + 8 1 libsqlite3.dylib 0x3282f5a6 unixAccess 2 libsqlite3.dylib 0x32826e5a sqlite3OsAccess 3 libsqlite3.dylib 0x32835bf0 sqlite3BtreeBeginTrans 4 libsqlite3.dylib 0x3284f038 sqlite3Step 5 libsqlite3.dylib 0x3282639c sqlite3_step 6 AppSupport 0x31475634 CPSqliteStatementCopyStringResult 7 AppSupport 0x3147626e CPSqliteConnectionCopyValueForProperty 8 AppSupport 0x314773a2 CPSqliteDatabaseCopyValueForProperty 9 AppSupport 0x314773ba CPSqliteDatabaseCopyUniqueIdentifier 10 AddressBook 0x34dd7c3a ABCCreateAddressBookWithDatabaseDirectoryAndForceInProcessMigrationAndResetSortKeys 11 AddressBook 0x34dd7eba ABCCreateAddressBookWithDatabaseDirectoryAndForceInProcessMigration 12 AddressBook 0x34dd7ec8 ABCCreateAddressBookWithDatabaseDirectory 13 AddressBook 0x34de3e78 ABAddressBookCreate 14 TextInput 0x34973fb8 KB::matchable_strings_from_address_book() 15 TextInput 0x34978686 KB::DynamicDictionaryImpl::background_load_address_book(KB::StaticDictionary const&amp;) 16 TextInput 0x34979d36 KB::BackgroundLoad(void*) 17 libSystem.B.dylib 0x35275986 _pthread_start 18 libSystem.B.dylib 0x3526b0e4 thread_start + 0 Unknown thread crashed with unknown flavor: 5, state_count: 1 Binary Images: 0x1000 - 0x41fff +CVCrDVR armv6 &lt;4ca92ed88199f56c60997ff21ed9963e&gt; /var/mobile/Applications/6EF0091E-FE47-43B7-8515-08688A530869/CVCrDVR.app/CVCrDVR 0xeb000 - 0xecfff dns.so armv7 &lt;240b8d3f07b4fcb234de598f8e67de1a&gt; /usr/lib/info/dns.so 0xf0000 - 0xf4fff AccessibilitySettingsLoader armv7 &lt;9e7d0552cedc18ba0b26cd182c47df8d&gt; /System/Library/AccessibilityBundles/AccessibilitySettingsLoader.bundle/AccessibilitySettingsLoader 0x2fe00000 - 0x2fe26fff dyld armv7 &lt;193570c1391880df7da870149117e49e&gt; /usr/lib/dyld 0x30135000 - 0x30686fff WebCore armv7 &lt;859bdd351085819fb4da07d12b41543f&gt; /System/Library/PrivateFrameworks/WebCore.framework/WebCore 0x30ac5000 - 0x30adafff libresolv.9.dylib armv7 &lt;1ed920d5a995cd94e71c41631d7c551e&gt; /usr/lib/libresolv.9.dylib 0x30adc000 - 0x30bc4fff libGLProgrammability.dylib armv7 &lt;9bcf5fe3e7abc344425e581ff2896579&gt; /System/Library/Frameworks/OpenGLES.framework/libGLProgrammability.dylib 0x30ca5000 - 0x30d4bfff WebKit armv7 &lt;a1d04572b3214188f60f2d1961ac1fe8&gt; /System/Library/PrivateFrameworks/WebKit.framework/WebKit 0x30eb4000 - 0x30f76fff CFNetwork armv7 &lt;9fdd61632fd1b48d65daba561528946f&gt; /System/Library/Frameworks/CFNetwork.framework/CFNetwork 0x31297000 - 0x3129cfff MobileKeyBag armv7 &lt;d33678689445fcf1898314262fd1ebd3&gt; /System/Library/PrivateFrameworks/MobileKeyBag.framework/MobileKeyBag 0x3129f000 - 0x312e7fff libBLAS.dylib armv7 &lt;3b4a2849c10d100a178a3c2d9f6af523&gt; /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libBLAS.dylib 0x312ea000 - 0x31358fff ProofReader armv7 &lt;479bd40ac65cb7e6c3000d79d649571f&gt; /System/Library/PrivateFrameworks/ProofReader.framework/ProofReader 0x31359000 - 0x3142bfff CoreFoundation armv7 &lt;17c9c36ae8824496b507446869cd4d9d&gt; /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 0x31472000 - 0x314a0fff AppSupport armv7 &lt;2a64271b39599b2180d0dfd3141027ee&gt; /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport 0x31663000 - 0x3280dfff UIKit armv7 &lt;6c767127e477e6ac7b7f083857ca8064&gt; /System/Library/Frameworks/UIKit.framework/UIKit 0x32824000 - 0x32868fff libsqlite3.dylib armv7 &lt;36b9bc7d02e29c8d321dd0d7bf7e115e&gt; /usr/lib/libsqlite3.dylib 0x3286b000 - 0x3286dfff IOMobileFramebuffer armv7 &lt;1fdf9182a63464743901526caf39240a&gt; /System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer 0x329b6000 - 0x329ccfff RawCamera armv7 &lt;78168f60a21e67ce307c5ce30054dba6&gt; /System/Library/CoreServices/RawCamera.bundle/RawCamera 0x329dc000 - 0x329e2fff liblockdown.dylib armv7 &lt;df3c6cea5e6848109a6e033e1d883320&gt; /usr/lib/liblockdown.dylib 0x329e3000 - 0x329ebfff libgcc_s.1.dylib armv7 &lt;b8fc1381e87a55740d9ac66195039a63&gt; /usr/lib/libgcc_s.1.dylib 0x329f0000 - 0x329fbfff GraphicsServices armv7 &lt;7194df9e594ae0fd9d9c600ccf456a08&gt; /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices 0x329fc000 - 0x32a46fff libstdc++.6.dylib armv7 &lt;baab09769f92decea73680bc15aa8618&gt; /usr/lib/libstdc++.6.dylib 0x32ad3000 - 0x32ad5fff libAccessibility.dylib armv7 &lt;06dd6032c40b1feb094d63eeb2002d6d&gt; /usr/lib/libAccessibility.dylib 0x32b17000 - 0x32b59fff CoreTelephony armv7 &lt;bc8796c8e011fea9923170d3c948a694&gt; /System/Library/Frameworks/CoreTelephony.framework/CoreTelephony 0x32b98000 - 0x32b9bfff IOSurface armv7 &lt;e67242f81fd1c0fa5e84b3fae5d310ae&gt; /System/Library/PrivateFrameworks/IOSurface.framework/IOSurface 0x32bb6000 - 0x32bb6fff vecLib armv7 &lt;85f89752df7814c1b243c26f59388523&gt; /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/vecLib 0x32bd1000 - 0x32bdbfff ExternalAccessory armv7 &lt;56a0856978d36be40c42834de8ab966d&gt; /System/Library/Frameworks/ExternalAccessory.framework/ExternalAccessory 0x32de8000 - 0x32f06fff CoreGraphics armv7 &lt;4022bbf12f11dd1f6b75662c764e7f7c&gt; /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics 0x32f20000 - 0x32f2dfff DataDetectorsUI armv7 &lt;8f6e03c382591e1f30f06e97b4b31570&gt; /System/Library/PrivateFrameworks/DataDetectorsUI.framework/DataDetectorsUI 0x3302b000 - 0x330cbfff libobjc.A.dylib armv7 &lt;89553a61e05078fd178ac0ea2081ae40&gt; /usr/lib/libobjc.A.dylib 0x3325a000 - 0x33379fff Foundation armv7 &lt;c985a61696030b4d1bdc8fe010f4e43b&gt; /System/Library/Frameworks/Foundation.framework/Foundation 0x3337c000 - 0x3338efff VoiceServices armv7 &lt;f5b5b032e4c0b79c42e0fde5a59a6eb3&gt; /System/Library/PrivateFrameworks/VoiceServices.framework/VoiceServices 0x3344f000 - 0x33489fff IOKit armv7 &lt;5e0169de165c2fd25a2ddac1f3e19d06&gt; /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit 0x33641000 - 0x33680fff libGLImage.dylib armv7 &lt;b96f5e231a3e39677b5e3621d61d2f11&gt; /System/Library/Frameworks/OpenGLES.framework/libGLImage.dylib 0x33681000 - 0x33683fff MobileInstallation armv7 &lt;74e2bd725da63513053b4fa41d8cd89c&gt; /System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation 0x3368e000 - 0x3371bfff ImageIO armv7 &lt;abf07fc0430aaf2a2823753c78061aac&gt; /System/Library/Frameworks/ImageIO.framework/ImageIO 0x33850000 - 0x33969fff libicucore.A.dylib armv7 &lt;c4f4fd74dfa672fb4d84914585bbada5&gt; /usr/lib/libicucore.A.dylib 0x33c6f000 - 0x33c87fff libRIP.A.dylib armv7 &lt;436e3b257ba088ca6f773961ce619892&gt; /System/Library/Frameworks/CoreGraphics.framework/Resources/libRIP.A.dylib 0x33c88000 - 0x33c8bfff libGFXShared.dylib armv7 &lt;12f82e44ff36b29f8d0661878be83554&gt; /System/Library/Frameworks/OpenGLES.framework/libGFXShared.dylib 0x33c90000 - 0x33c9cfff DataDetectorsCore armv7 &lt;bc6bff5b67aae8b97a8cdd43ed7b0bb1&gt; /System/Library/PrivateFrameworks/DataDetectorsCore.framework/DataDetectorsCore 0x33e36000 - 0x33edefff QuartzCore armv7 &lt;109b4f6a3d2ee5aa1bb5775ab5a489bc&gt; /System/Library/Frameworks/QuartzCore.framework/QuartzCore 0x33ee2000 - 0x33f8bfff libxml2.2.dylib armv7 &lt;1d74fa3a5cec309857503a51cb2df667&gt; /usr/lib/libxml2.2.dylib 0x34035000 - 0x342cffff libLAPACK.dylib armv7 &lt;fbc3f7ad1260a159d75be53218fa9e0c&gt; /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libLAPACK.dylib 0x343a8000 - 0x343b1fff CoreVideo armv7 &lt;58180e899ec56cd8bca00221dea2bc32&gt; /System/Library/Frameworks/CoreVideo.framework/CoreVideo 0x343ee000 - 0x3442cfff libvDSP.dylib armv7 &lt;cc8d6be7a5021266e26ebd05e9579852&gt; /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib 0x3442d000 - 0x34435fff libkxld.dylib armv7 &lt;4ec35c4d1e1e73416aea84537829ce91&gt; /usr/lib/system/libkxld.dylib 0x34438000 - 0x34445fff OpenGLES armv7 &lt;e397de408a0a789f816bc1803ae58faf&gt; /System/Library/Frameworks/OpenGLES.framework/OpenGLES 0x344e8000 - 0x34521fff MobileCoreServices armv7 &lt;d38c937ae3548777da263d2657536189&gt; /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices 0x3456c000 - 0x3459bfff CoreText armv7 &lt;76eb1b63d684c3d21dba9e8129666d2f&gt; /System/Library/Frameworks/CoreText.framework/CoreText 0x3459c000 - 0x345d2fff Security armv7 &lt;7cea1027f1a381b8d6c5ffae4dae0d22&gt; /System/Library/Frameworks/Security.framework/Security 0x3473c000 - 0x347dbfff JavaScriptCore armv7 &lt;894df23ebbc4df713d9519141a61dd19&gt; /System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore 0x347dc000 - 0x347ddfff CoreSurface armv7 &lt;042e433142b7faa4c96b23e555faaf13&gt; /System/Library/PrivateFrameworks/CoreSurface.framework/CoreSurface 0x34844000 - 0x3484bfff libbz2.1.0.dylib armv7 &lt;5d079712f5a39708647292bccbd4c4e0&gt; /usr/lib/libbz2.1.0.dylib 0x3487c000 - 0x348aafff SystemConfiguration armv7 &lt;2b44ac2fc47fc45c4006d08019688dbb&gt; /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration 0x348ac000 - 0x348b7fff libz.1.dylib armv7 &lt;19a78978d5908bedc6496470fe542936&gt; /usr/lib/libz.1.dylib 0x348e9000 - 0x34929fff CoreAudio armv7 &lt;1723726845b73efbeca75b33d75f335a&gt; /System/Library/Frameworks/CoreAudio.framework/CoreAudio 0x3493e000 - 0x3496cfff libCGFreetype.A.dylib armv7 &lt;475259824770c6ff1b63f30238b3ea81&gt; /System/Library/Frameworks/CoreGraphics.framework/Resources/libCGFreetype.A.dylib 0x3496d000 - 0x349a3fff TextInput armv7 &lt;949f29588014140b606042685de1dee6&gt; /System/Library/PrivateFrameworks/TextInput.framework/TextInput 0x349a4000 - 0x349c3fff Bom armv7 &lt;c73b68b11b2801cefbfbdb6328a7fcfb&gt; /System/Library/PrivateFrameworks/Bom.framework/Bom 0x34dd5000 - 0x34e07fff AddressBook armv7 &lt;3dde743216bbf016019b59f821dda6e3&gt; /System/Library/Frameworks/AddressBook.framework/AddressBook 0x34f43000 - 0x34f4ffff SpringBoardServices armv7 &lt;7624f0a9e197261f2df43edb86ba0256&gt; /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices 0x34f50000 - 0x34f5dfff libbsm.0.dylib armv7 &lt;27ad6b3a74ce1068586eabd6a553183f&gt; /usr/lib/libbsm.0.dylib 0x34f5e000 - 0x34f64fff IAP armv7 &lt;42a87fc47e059f5a73dcff2227b9e0be&gt; /System/Library/PrivateFrameworks/IAP.framework/IAP 0x3502d000 - 0x35151fff AudioToolbox armv7 &lt;802e4d5c449b69d9552809e5230baa84&gt; /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox 0x35156000 - 0x35156fff Accelerate armv7 &lt;f4c04cdfdb64d209828315cdd5b60bf9&gt; /System/Library/Frameworks/Accelerate.framework/Accelerate 0x351fb000 - 0x35308fff libSystem.B.dylib armv7 &lt;3fcf32f3ad8ef745480b5b36efc41953&gt; /usr/lib/libSystem.B.dylib </code></pre> <p>We tried symbolicatecrash too, but it doesn't point to anywhere.</p> <p>Thanks and Regards, Hetal</p>
2,907,939
0
Hex characters in varchar() is actually ascii. Need to decode it <p>This is such an edge-case of a question, I'd be surprised if there is an easy way to do this.</p> <p>I have a MS SQL DB with a field of type varchar(255). It contains a hex string which is actually a Guid when you decode it using an ascii decoder. I know that sounds REALLY weird but here's an example:</p> <p>The contents of the field: "38353334373838622D393030302D343732392D383436622D383161336634396339663931"</p> <p>What it actually represents: "8534788b-9000-4729-846b-81a3f49c9f91"</p> <p>I need a way to decode this, and just change the contents of the field to the actual guid it represents. I need to do this in T-SQL, I cannot use .Net (which if I could, that is remarkably simple).</p> <p><strong>UPDATE</strong>: Some people have responded with ways that may work in one-off statements, I need a way to put this into an UPDATE statement.</p> <p>For example: UPDATE MyTable SET MyField = MyFunction(MyField)</p> <p>Where MyFunction is the correct answer to this question.</p>
4,010,440
0
<h1>Update</h1> <p>First off I'd suggest you drop the use of setInterval, they're particularly problematic. Instead use the <code>Timer</code> class, which is far more straightforward to manage and use.</p> <p>The <code>setInterval</code> inside the <code>sRes.onLoad</code> function is probably your issue though. The interval should be in milliseconds, so your 0.1 should probably be 100 (for 1/10th second), and the <code>clearInterval</code> calls in <code>fadeIn</code> and <code>unLoad</code> might have <code>myInterval</code> out of scope, check these with a <code>trace</code> to make sure they are clearing as expected.</p> <h2>Code</h2> <p>Ok, I've re-ordered the code to make it a bit more readable... However, it is still in very bad shape. I'm marking things out that I'd need to discuss with you further... (see below additional comments in the code.)</p> <pre><code>stop(); // Moved import to the top. import JSON; // Grouping var declarations. var myself = scrollContent; myself._alpha = 0; var values = Array("3"); var myTimer = null; var sRes:LoadVars = new LoadVars(); var server_send:LoadVars = new LoadVars(); var vars = Array("id"); // why are we looping through an array of one value? for(var i=0; i&lt;vars.length; i++) { server_send[vars[i]] = escape(values[i]); } server_send.load('void.txt'); // what is this for? server_send.sendAndLoad(_global.server, sRes, "POST"); // where do we define _global.server this.onUnload = function () { clearInterval(myTimer); // is myTimer in scope here? server_send = new LoadVars(); trace("stopping gewerbe"); }; function fadeIn(which){ which._alpha += 3; if(which._alpha &gt;= 100){ clearInterval(myTimer); // is myTimer in scope here? } } sRes.onLoad = function(success:Boolean) { if (success) { var o:Object = JSON.parse(sRes.res); var s:String = JSON.stringify(o); var y = 0; for(item in o) { actCol = 0; myself.attachMovie("row", "entry" + item, myself.getNextHighestDepth(), {_x: 0, _y:y}); var tr = myself["entry" + item]; tr.cTitle = o[item]["title"]; tr.cBild = o[item]["image"]; tr.cText = o[item]["text"]; y += 65; } myTimer = setInterval(fadeIn, 0.1, myself); // setInterval uses milliseconds 0.1 is almost certainly the problem. // if you want 1/10th of a second, specify 100 as the interval. _root.myIntervals.push(myTimer); // We never see _root.myIntervals again, what's this for? // The fadeIn and unLoad methods could use this to // guarantee that they clear the right interval. } else { trace("no connection..."); } } </code></pre>
18,077,702
0
<p>I think that your problem is IIS Security Permission. Did you try that?</p> <p>You must grant access to <code>IIS_IUSRS</code> user for read, write and modify files on Template and Output folders. You can read more about this <a href="http://support.microsoft.com/kb/313075" rel="nofollow">Here</a>.</p>
38,812,660
0
Android Studio Messages View doesn't show every time <p>Im Running Android studio in Debian 8 and when I build apk errors are shown in Message view. I set it to popup, But half of the time It seams to fail and I can't view the message view at all.</p> <p>Is this a known bug or what? </p>
37,561,793
0
<p>Since you crosspost, I crossanswer :P IMHO crossposting is bad and you should delete one of the questions.</p> <hr> <p>This question is also being answered here (since you already found my github bug report):</p> <p><a href="https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23529" rel="nofollow">https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23529</a></p> <p>For the moment, and likely it will be this way until the emacs build system changes, the only valid solutions are:</p> <ul> <li><p>Don't build with a Dockerfile and build in a running container that has a seccomp profile that allows the personality syscall. For example:</p> <p><code>docker run --rm -it --security-opt seccomp=unconfined emacs-builder-image</code></p></li> <li><p>Disable /proc/sys/kernel/randomize_va_space before building:</p> <p><code>echo 0 &gt; /proc/sys/kernel/randomize_va_space; docker build .</code></p></li> </ul>
35,912,423
0
How to add css class on validation error to list item <p>In my application I have ListView with textField which is validating when user submit button. When there is error it will show error message. Problem is there is a lot of rows so user can not recognize bad row easily. So is there some way how to add css class to this bad row after submitting button ?</p> <pre><code> private void addListView() { add(new PropertyListView&lt;MyClass&gt;("view") { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem&lt;MyClass&gt; listItem) { listItem.add(new TextField&lt;String&gt;("result") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public final &lt;String&gt; IConverter&lt;MyClass&gt; getConverter(Class&lt;MyClass&gt; type) { return (IConverter&lt;MyClass&gt;) StringConverter.getInstance(); } }); }); } </code></pre>
28,410,390
0
Deserializing a Spark Dstream <p>I am trying to apply Drools Engine (Drools Fusion) over streaming data using Spark Streaming.</p> <p>But I am unable to deserialize a variable of type JavaDStreamto fire rules over it.</p> <p>It is showing comparision error between JavaDstream and Interger. Please suggest how to resolve this. Below is the Code</p> <p>Main class</p> <pre><code>SparkConf conf = new SparkConf().setMaster("local[2]").setAppName("Spark Streaming"); JavaStreamingContext jssc = new JavaStreamingContext(conf, new Duration(10000)); JavaReceiverInputDStream&lt;String&gt; lines = jssc.socketTextStream("localhost", 8089); class splitFunc implements Function&lt;String, Long&gt; { public Long call(String x) { return Long.parseLong(x); } } JavaDStream&lt;Long&gt; in_amount = lines.map(new splitFunc()); insertEvent(entryPointStoreOne,new Sale(),in_amount); </code></pre> <p>Sale.java - FACTS</p> <pre><code>import org.apache.spark.streaming.api.java.JavaDStream; public class Sale { private JavaDStream&lt;Long&gt; amount; public Sale (){ } public void setAmount(JavaDStream&lt;Long&gt; amount) { this.amount=amount; } public JavaDStream&lt;Long&gt; getAmount() { return amount; } </code></pre> <p>}</p> <p>Drools Rules File</p> <pre><code>declare Sale @role(event) end rule "Store One - Has Passed its Sales Record" when $amount : Sale( amount &gt; 1000 ) - FAILING HERE from entry-point StoreOne then System.out.println("Store One has passed its Sales Records"); end </code></pre>
4,260,127
0
Something confusing about digital certificates <p>A digital certificate is a digital document that certifies that a certain public key is owned by a particular user. Thus if you trust the CA that signed the certificate <code>C</code>, then you can trust that specific public/private key pair is owned by the owner of certificate <code>C</code>.</p> <p>a) Assume client <code>A</code> wants to establish a connection with server <code>B</code> located at url www.some_domain.com. When establishing a connection with <code>B</code>, <code>A</code> may receive from the other end a X.509 certificate <code>C</code> and a public key, belonging to the owner of certificate <code>C</code>. </p> <p>But how can client know that owner of <code>C</code> is really a server <code>B</code> and not some other entity that hijacked ( if that is the correct term ) the connection and sent its own certificate and public key to <code>A</code>? </p> <p>Only way I can think of for client to know whether owner of <code>C</code> is really <code>B</code>, is if <code>C's Subject</code> field also specifies the domain for which this certificate is valid or if it specifies the organization to which this certificate belongs ( but that only helps if client knows to which organization www.some_domain.com belongs )?! </p> <p>thank you</p>
13,643,092
0
<p>Let us consider the pros and cons of doing this Server side </p> <p>PROs:</p> <ul> <li>You can do other processing on the data using the power of the server </li> <li>You are not subject to cross domain limitations like you would be in ajax </li> <li>Generally you do not have to worry about your server being able to access the resource, whereas on client you are at the mercy of users net restrictions, firewalls etc </li> <li>More control over your http response\request lifecycle</li> </ul> <p>CONS:</p> <ul> <li>You will have to consume more bandwidth sending the resulting data down to the client.</li> <li>You may have to do more work to leverage good caching practices</li> <li>Dependant on having certain server side libraries\framework elements</li> </ul> <p>Now although we have a much bigger list of Pros than cons... in the majority of cases you will still want to do this on the client... because the issue of double handling the data is actually a very big one, and will cost you both time and money.</p> <p>The only reason you should actually do it server side is if you need to do extensive processing on the data, or you cannot circumvent CORS (cross domain) restrictions.</p> <p>If you are just doing something simple like displaying the information on a webpage, then client side is preferable.</p>
30,050,589
0
<p>The problem is that you're producing this JavaScript inside the <code>onclick</code>:</p> <pre><code>alert_box(10,hello,134) </code></pre> <p>As you can see, you're trying to use a <em>variable</em> called <code>hello</code> there, you aren't using the string <code>'hello'</code>.</p> <p>To do so, you must put it in quotes. To do it reliably, you need to ensure that <code>"</code> and <code>&amp;</code> in them are replaced with HTML entities (<code>&amp;quot;</code>, <code>&amp;amp</code>), and ensure that if they have <code>'</code> in them, they're escaped with backslashes. You'll probably also want to convert line breaks in teh string (if there are any) into <code>\\n</code> sequences and so on. It's a real pain, basically. (This advice assumes you'll continue to use <code>"</code> as the quote around the attribute and that you'll use <code>'</code> as the quote around the JavaScript string.)</p> <p>So:</p> <pre><code>var value_1 = 10; var value_2 = 'hello'; var value_3 = 134; $('#Blocks' + IJ).append( '&lt;span onclick="alert_box(' + value_1 + ',\'' + value_2.replace(/&amp;/g, "&amp;amp;").replace(/"/g, "&amp;quot;").replace(/'/g, "\\'").replace(/[\r\n]+/g, '\\n') + '\',' + value_3 + ')"&gt;&lt;/span&gt;' ); function alert_box(a, b, c) { alert(c); } </code></pre> <p><strong>Live Example:</strong></p> <p><div class="snippet" data-lang="js" data-hide="true"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var value_1 = 10; var value_2 = 'hello'; var value_3 = 134; var IJ = 1; $('#Blocks' + IJ).append( '&lt;span onclick="alert_box(' + value_1 + ',\'' + value_2.replace(/&amp;/g, "&amp;amp;").replace(/"/g, "&amp;quot;").replace(/'/g, "\\'").replace(/[\r\n]+/g, '\\n') + '\',' + value_3 + ')"&gt;click me&lt;/span&gt;' ); function alert_box(a, b, c) { alert("a = " + a + ", b = " + b + ", c = " + c); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="Blocks1"&gt;&lt;/div&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p> <hr> <p><strong><em>But</em></strong>, it would be <strong>much</strong> better not to use <code>onclick</code> at all, which bypasses all of those hassles:</p> <pre><code>var value_1 = 10; var value_2 = 'hello'; var value_3 = 134; $("&lt;span&gt;") .on("click", function() { alert_box(value_1, value_2, value_3); }) .appendTo('#Blocks' + IJ); function alert_box(a, b, c) { alert(c); } </code></pre> <p><strong>Live Example</strong>:</p> <p><div class="snippet" data-lang="js" data-hide="true"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var value_1 = 10; var value_2 = 'hello'; var value_3 = 134; var IJ = 1; $("&lt;span&gt;") .text("click me") .on("click", function() { alert_box(value_1, value_2, value_3); }) .appendTo('#Blocks' + IJ); function alert_box(a, b, c) { alert("a = " + a + ", b = " + b + ", c = " + c); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="Blocks1"&gt;&lt;/div&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p> <hr> <p>The above assumes that the values of <code>value_1</code>, <code>value_2</code>, and <code>value_3</code> don't change after you've hooked up the handler. If they may, we can use a builder function to ensure we use the version as of when we hooked up the handler rather than the version as of when the click event happens:</p> <pre><code>var value_1 = 10; var value_2 = 'hello'; var value_3 = 134; $("&lt;span&gt;") .on("click", buildHandler(value_1, value_2, value_3)) .appendTo('#Blocks' + IJ); function alert_box(a, b, c) { alert(c); } function buildHandler(v1, v2, v3) { return function() { alert_box.call(this, v1, v2, v3); }; } </code></pre> <p><strong>Live Example:</strong></p> <p><div class="snippet" data-lang="js" data-hide="true"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var value_1 = 10; var value_2 = 'hello'; var value_3 = 134; var IJ = 1; $("&lt;span&gt;") .text("click me") .on("click", buildHandler(value_1, value_2, value_3)) .appendTo('#Blocks' + IJ); value_1 = value_2 = value_3 = "changed"; // Just to prove we don't use them function alert_box(a, b, c) { alert("a = " + a + ", b = " + b + ", c = " + c); } function buildHandler(v1, v2, v3) { return function() { alert_box.call(this, v1, v2, v3); }; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="Blocks1"&gt;&lt;/div&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>
3,446,755
0
Qt localization: loading the localizable string probelm <p>I want to load the localized string in a Qt application. For this, I am following a few steps. Correct me if I am wrong.</p> <p>Note: it works fine for <code>QString</code> but not for <code>const char*</code></p> <ol> <li><p>Update the pro file with translation language</p></li> <li><p>Generate <code>.ts</code> &amp; edit using Qt linguist. Generate <code>.qm</code> file using lupdate and lrelease.</p></li> <li><p>Load the .qm file from a particular location.</p></li> </ol> <p>Here is how my <code>const char*</code> looks:</p> <pre><code>const char* sayHello = QT_TRANSLATE_NOOP("FriendlyConversation","hello"); LocalizationWithQT::LocalizationWithQT(QWidget *parent) : QMainWindow(parent) { //ui.setupUi(this); QString str = tr("say hello"); QPushButton *pushbutton = new QPushButton(tr(sayHello)); setCentralWidget(pushbutton) } </code></pre> <p>And here's how I am loading the .qm file:</p> <pre><code>QApplication a(argc, argv); QTranslator translator; bool val = translator.load("c:\\Data\\test\\hellotr_la"); a.installTranslator(&amp;translator); LocalizationWithQT w; w.showMaximized(); return a.exec(); </code></pre> <p>The problem is, if I provide any alternate Latin string to "sayhello", it's not loading at all. </p> <p>I have no idea where the mistake is.</p>
21,770,953
0
<p>The simplest way I know is to use <code>location.href</code> property in <code>OnClientClick</code> event of button.</p> <p><strong>See following example:</strong></p> <pre><code>&lt;asp:Button ID="btnEdit" runat="server" Text="Edit" OnClientClick="window.location.href='your edit URL here'" /&gt; </code></pre>
23,653,424
0
<p>Another solution is to use <a href="http://jrsoftware.org/ishelp/topic_isxfunc_createoutputprogresspage.htm" rel="nofollow"><code>CreateOutputProgressPage</code></a> to display a progress page over the top of the Preparing to Install page. See the <code>CodeDlg.iss</code> example script included with Inno for an example of the usage; it's fairly straightforward.</p>
3,917,947
0
View XML data as a table <p>Is there a way I can use Visual Studio to view my XML data in a tabular structure by applying the appropriate XSD to it?</p> <p>Are there any other tools I can easily use for this purpose? PS: I need this for a one time use.</p>
15,670,911
0
<p>You are trying to call it as a c function but it is declared as a class method.</p> <p>In Objective C you need to write </p> <pre><code>[self setAsPrevious:current]; </code></pre>