pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
18,380,923 | 0 | <p>I'm quite new on that and I don't know if I am understanding your question, but why you don't use "backticks" instead of "system"? It would let you store the output in a variable and then you can do with this variable whatever you want.</p> <p>About backticks: <a href="http://stackoverflow.com/questions/799968/whats-the-difference-between-perls-backticks-system-and-exec">What's the difference between Perl's backticks, system, and exec?</a></p> |
35,835,296 | 0 | Automatically restore last saved document on application launch <p>I have a Core Data Document Based application written in swift and using storyboards. Whenever I build and launch the app, instead of automatically opening the last opened document(s), it will create a new document. What I want to be able to do is have the application automatically restore whatever documents were last opened on application launch, if they are available. How can I do this?</p> |
23,089,080 | 0 | Number of submatricies containing all zeros <p>Is there a way to find a number of rectangular submatrices containing all zeros with a complexity smaller than O(n^3), where n is the dimension of given matrix?</p> |
34,678,213 | 0 | <p>It can also be caused by <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=475368" rel="nofollow">this</a> bug, if you're having Eclipse 4.5/4.6, an Eclipse Xtext plugin version older than v2.9.0, and a particular workspace configuration.</p> <p>The workaround would be to create a new workspace and import the existing projects.</p> |
18,486,496 | 0 | <p>If you ultimately decide to move the cache outside your main webserver process, then you could also take a look at <a href="http://en.wikipedia.org/wiki/Consistent_hashing" rel="nofollow">consistent hashing</a>. This would be a alternative to a replicated cache.</p> <p>The problem with replicated caches, is they scale inversely proportional to the number of nodes participating in the cache. i.e. their performance degrades as you add additional nodes. They work fine when there is a small number of nodes. If data is to be replicated between N nodes (or you need to send eviction messages to N nodes), then every write requires 1 write to the cache on the originating node, and N-1 writes to the other nodes.</p> <p>In consistent hashing, you instead define a hashing function, which takes the key of the data you want to store or retrieve as input, and it returns the id of the server in the cluster which is responsible for caching the data for that key. So each caching server is responsible for a fraction of the overall keys, the client can determine which server will contain the sought data without any lookup, and data and eviction messages do not need to be replicated between caching servers.</p> <p>The "consistent" part of consistent hashing, refers to how your hashing function handles new servers being added to or removed from the cluster: some re-distribution of keys between servers is required, but the function is designed to minimize the amount of such disruption.</p> <p>In practice, you do not actually need a dedicated caching cluster, as your caches could run in-process in your web servers; each web server being able to determine the other webserver which should store cache data for a key.</p> <p>Consistent hashing is used at large scale. It might be overkill for you at this stage. But just be aware of the scalability bottleneck inherent in O(N) messaging architectures. A replicated cache is possibly a good idea to <em>start with</em>.</p> <p>EDIT: Take a look at <a href="http://infinispan.org/docs/5.3.x/faqs/faqs.html" rel="nofollow">Infinispan</a>, a distributed cache which indeed uses consistent hashing out of box.</p> |
26,633,743 | 0 | Fragments won't show up in activity extending ActionBarActivity <p>I have a main activity extending ActionBarActivity. In my activity i create a fragment which isn't showing up. I modified the main activity to extend FragmentActivity and in this case the fragment is showing up. Why isn't the fragment showing up when my activity extends ActionBarActivity? I know that ActionBarActivity extends FragmentActivity so in theory ActionBarActivity should support fragments.</p> <p><strong>Edit: I resolved it. I wouldn't set any content view on my activity. Now that i set it it works when i extend ActionBarActivity. Still is weird that even if i don't set it, when i extend FragmentActivity it works.</strong></p> <p>This is my main activity code:</p> <pre><code>package com.example.yamba; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; //import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; public class StatusActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(savedInstanceState == null) { StatusFragment fragment = new StatusFragment(); FragmentTransaction fr = getSupportFragmentManager().beginTransaction(); fr.add(android.R.id.content, fragment); fr.commit(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.status, 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(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } </code></pre> <p>This is my fragment code:</p> <pre><code>package com.example.yamba; import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.EditText; import android.widget.Toast; import android.os.AsyncTask; import android.text.TextWatcher; import android.text.Editable; import android.view.LayoutInflater; import android.view.ViewGroup; import android.support.v4.app.Fragment; import com.marakana.android.yamba.clientlib.YambaClient; import com.marakana.android.yamba.clientlib.YambaClientException; public class StatusFragment extends Fragment implements OnClickListener { private static final String TAG = "StatusFragment"; private EditText editStatus; private Button buttonTweet; private TextView textCount; private int defaultColor; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); View view = inflater.inflate(R.layout.activity_fragment, container, false); editStatus = (EditText) view.findViewById (R.id.editStatus); buttonTweet = (Button) view.findViewById (R.id.buttonTweet); textCount = (TextView) view.findViewById (R.id.textCount); buttonTweet.setOnClickListener(this); defaultColor = textCount.getTextColors().getDefaultColor(); editStatus.addTextChangedListener(new TextWatcher() { public void afterTextChanged (Editable s) { int count = 140 - editStatus.length(); textCount.setText(Integer.toString(count)); textCount.setTextColor(Color.GREEN); if(count<20 && count >= 10) textCount.setTextColor(Color.YELLOW); else if (count<10) textCount.setTextColor(Color.RED); else textCount.setTextColor(defaultColor); } public void beforeTextChanged(CharSequence s, int start, int count, int after){} public void onTextChanged (CharSequence s, int start, int b, int c){} }); return view; } public void onClick(View view) { String status = editStatus.getText().toString(); Log.d(TAG, "onClicked with status: " + status); new PostTask().execute(status); editStatus.getText().clear(); } private final class PostTask extends AsyncTask<String, Void, String> { protected String doInBackground(String... params) { YambaClient yambaCloud = new YambaClient("student", "password"); try { yambaCloud.postStatus(params[0]); return "Succesfuly posted!"; } catch (YambaClientException e) { e.printStackTrace(); return "Failed to post to yamba sevice!"; } } @Override protected void onPostExecute (String result) { super.onPostExecute(result); Toast.makeText(StatusFragment.this.getActivity(), result, Toast.LENGTH_LONG).show(); } } } </code></pre> |
4,975,957 | 0 | <blockquote> <p>where someone recommended the BackgroundWorker class this MSDN article mentions it is a bad idea to use this when if it manipulates objects in the UI, which mine does for purposes of displaying status counts</p> </blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow">BackgroundWorker</a> is actually ideal for this, as it was designed for this type of scenario. The warning is that you shouldn't change UI elements inside of <code>DoWork</code>, but rather via <code>ReportProgress</code> and the <code>ProgressChanged</code> event.</p> <p>The reason the warning exists is "DoWork" is executed on a background thread. If you set a UI element value from there, you'll get a cross threading exception. However, ReportProgress/ProgressChanged automatically marshals the call back into the proper <code>SynchronizationContext</code> for you.</p> |
17,259,286 | 0 | jquery blinking text and div reload <p>I have a div that refreshes every 30 seconds and I also have text that blinks if it's new content (checked by a cookie).</p> <pre><code>setInterval(function() { $('#reload').load('/page.php #reload'), function() {} }, 30000); // check if atis cookie exits var Key = $("#key").data('key'); if ($.cookie('check_'+Key) == null) { $('.blink_'+Key).each(function() { var elem = $(this); setInterval(function() { if (elem.css('visibility') == 'hidden') { elem.css('visibility', 'visible'); } else { elem.css('visibility', 'hidden'); } }, 500); }); } </code></pre> <p>The blinking works perfectly...until the div refreshes. Once the div refreshes, the blinking stops. I've tried adding the blinking code inside the refresh function, but no avail.</p> <p>Any ideas?</p> |
40,638,928 | 0 | <p>Try to play with this:</p> <pre><code>object OptIdx { def main(args: Array[String]) { println(get_deltas(tests)) } var tests = List( List(Some(313.062468), Some(27.847252)), List(Some(301.873641), Some(42.884065)), List(Some(332.373186), Some(53.509768))) def findDifference(oldPrice: Option[Double], newPrice: Option[Double]): Option[Double] = { Some((newPrice.get - oldPrice.get) / oldPrice.get) } def get_deltas(data: List[List[Option[Double]]]): List[List[Option[Double]]] = { (for { index <- 0 to 1 } yield { (for { i <- 0 to data.length - 2 } yield { findDifference(data(i)(index), data(i + 1)(index)) }).toList }).toList } } </code></pre> <p>It prints the numbers you want, but two of them are swapped. I'm sure you can figure it out, though.</p> |
16,165,095 | 0 | Wordpress, magic fields and post types in menu's <p>I used magic fields a while back and I don't remember having any issues getting my post types to display in my menus.</p> <p>From what I remember and have been able to research online all I need to do is the following:</p> <ol> <li>Create a new Post type in Magic fields</li> <li>In the advanced Options make sure "Show in nav menus" is selected</li> <li>Add a new custom post</li> <li>Browse to Appearence > Menu's</li> <li>Select my main navigation menu</li> <li>On the left hand side select the Post type</li> </ol> <p>However When I get to #5 it's not displaying on the left as I remember.</p> <p>I created a new dev site on my local machine, installed Wordpress 3.4 and Magic field 2.2.1, Then I tried to make a post type and add it to the menu but this again did not display for me anywhere in the menu options.</p> <p>I just can't seem to find it. </p> <p>I've even been through the database entry for the new post type just to check the JSON (At least I'm pretty damn sure it's JSON) and It seems to be setting the show in navs option correctly.</p> |
21,189,838 | 0 | <p>You will find a nice tutorial here: <a href="http://www.jusuchyne.com/codingforme/2012/12/jira-migrating-certain-projects-from-instance/" rel="nofollow">http://www.jusuchyne.com/codingforme/2012/12/jira-migrating-certain-projects-from-instance/</a></p> <p>As described <a href="https://answers.atlassian.com/questions/24187/is-there-a-tool-or-method-to-export-a-project-from-one-instance-of-jira-test-and-import-the-project-into-another-jira-instance-production" rel="nofollow" title="here">here</a>, there is a Plugin in the Atlassian Marketplace, that lets you copy the configuration: <a href="https://marketplace.atlassian.com/plugins/com.awnaba.projectconfigurator.projectconfigurator" rel="nofollow">https://marketplace.atlassian.com/plugins/com.awnaba.projectconfigurator.projectconfigurator</a></p> |
13,442,034 | 0 | Handlebars Bindings with Variable <p>i'm trying to create a Binding in Handlebars/Ember to an Object with a dynamic Key like this:</p> <pre><code>{{view Ember.TextArea valueBinding="foo.[view.content.someid]"}} </code></pre> <p>when im trying this with a static Key, everything is working fine</p> <pre><code>{{view Ember.TextArea valueBinding="foo.[bar]"}} </code></pre> <p>i guess that the "view.content.someid" in my Example is treated as a String. Has anybody a hint how I could solve this, or could tell me why this isn't working??</p> |
10,145,469 | 0 | decltype for member functions <p>How can I get the return type of a member function in the following example?</p> <pre><code>template <typename Getter> class MyClass { typedef decltype(mygetter.get()) gotten_t; ... }; </code></pre> <p>The problem, of course, is that I don't have a "mygetter" object while defining MyClass.</p> <p>What I'm trying to do is: I'm creating a cache that can use, as it's key, whatever is returned by the getter.</p> |
36,569,227 | 0 | Select two columns from same table with different WHERE conditions <p>I have two select statements and I want to generate two columns, one from each statement side by side using these two select statements inside a single select statement</p> <p><strong>Query 1</strong></p> <pre><code> SELECT DISTINCT CASE_ID from t1 WHERE MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-56 AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-49 </code></pre> <pre> CASE_ID 12 13 14 15 17 </pre> <p><strong>Query 2</strong></p> <pre><code>SELECT DISTINCT CASE_ID from t1 WHERE MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-49 AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-42 </code></pre> <pre> CASE_ID 45 98 67 90 76 82 61 </pre> <p>Final Output should be something like:</p> <pre> C1 C2 12 45 13 98 14 67 15 90 17 76 82 61 </pre> <p>Could anyone tell me how to do to so?</p> <p>Thank You. </p> <hr> <p><strong>Update</strong></p> <p>One of the query I tried from the answers :</p> <pre><code>SELECT DISTINCT case when MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 56 AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 49 then CASE_ID end as c1, DISTINCT case when MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-49 AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-42 then CASE_ID end as c2 from t1 WHERE MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 56 AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 42 </code></pre> <p>And I am getting ORA-00936: missing expression. Could anyone tell me the problem?</p> <p>Thanks.</p> |
23,940,154 | 0 | <p>Besides configuring an EC2-instance you can also use the PaaS-solution of AWS, namely Elastic Beanstalk. They have also support for Node.js and it's super easy to deploy your apps using this service.</p> |
24,743,758 | 1 | Pygame Large Surfaces <p>I'm drawing a map of a real world floor with dimensions roughly 100,000mm x 200,000mm.</p> <p>My initial code contained a function that converted any millimeter based position to screen positioning using the window size of my pygame map, but after digging through some of the pygame functions, I realized that the pygame transformation functions are quite powerful.</p> <p>Instead, I'd like to create a surface that is 1:1 scale of real world and then scale it right before i blit it to the screen. </p> <p>Is this the right way to be doing this? I get an error that says Width or Height too large. Is this a limit of pygame?</p> |
23,148,367 | 0 | <p>Your problem is that <code>animal</code> is a <strong>private</strong> base class of <code>human</code> and therefore passing (and storing) <code>this</code> (which is of type <code>lady*</code>) can not be used to call the method from <code>animal</code>. You could fix it making it a public base or by adding a method to <code>human</code>:</p> <pre><code>animal* animal_ptr() { return this; } </code></pre> <p>and later bind:</p> <pre><code>std::bind(&base_type::eat, animal_ptr(), std::placeholders::_1) </code></pre> <p><a href="http://coliru.stacked-crooked.com/a/86aa3493784bdb9a" rel="nofollow"><strong>Live example</strong></a></p> |
12,991,777 | 0 | including a directory in classpath of android ant build script <p>I am new to ant stuff and </p> <p>I have an android project which has a set of dependency jar files , like this</p> <ul> <li>C:\soundlibs\lib-sound1.jar</li> <li>C:\soundlibs\lib-sound2.jar</li> <li>C:\graphicslibs\lib-graphics.jar</li> </ul> <p>When building the android project using ant I have to copy all the jars to android project's libs folder, otherwise it will fail to build</p> <p>Is there a way to include the directories C:\soundlibs and C:\graphicslibs as part of the classpath so that when android script runs javac target it should find the relevant jars automatically , so that I do not have to copy them ??</p> <p>Thanks ,</p> |
36,543,115 | 0 | <pre><code>//Your example json results = [{"type":"fruit", "name":"orange"},{"type":"flower","name":"rose"},{"type":"fruit", "name":"apple"}] </code></pre> <p>First you need to turn your json into an array of dictionaries to get the above object you think it will be:</p> <pre><code>if let results = try NSJSONSerialization.JSONObjectWithData(data,options: NSJSONReadingOptions.MutableContainers) as? [[String : AnyObject]] { //parse into form you want.} // Your example desired result of dictionary with key:array of dictionaries updatedResult[String:[AnyObject]]() = {"fruit":[{"name":"orange"},{"name":"apple"}],"flower":[{"name":"rose"}]} </code></pre> <p>Then you want to loop through the json result and grab out the values into the above format you want:</p> <pre><code>// Swift representation of your provided example let results = [["type":"fruit", "name":"orange"],["type":"flower","name":"rose"],["type":"fruit", "name":"apple"]] // Desired dictionary of key:array of dictionaries var updatedResult = [String:[[String:String]]]() for item in results { if let name = item["name"], type = item["type"] { if updatedResult.keys.contains(type) { updatedResult[type]!.append(["name":name]) } else { updatedResult[type] = [["name":name]] } } } </code></pre> |
585,538 | 0 | <p>Multiple inheritance can be used if the language allows it. I don't know much about it however.</p> <p>Otherwise, you can build a <code>StockItemNode : GraphicNode</code> from a <code>StockItem</code>: </p> <pre><code>class ItemNodeFactory { ... StockItemNode create(StockItem); ... } </code></pre> <p>You can transfer properties from <code>StockItem</code> into an instance of <code>StockItemNode</code> (set-get) which would completely decouple the two types. Or you can have <code>StockItemNode</code> wrap an instance of <code>StockItem</code> (composition).</p> <p>Doing it the other way around (having <code>NodeStockItem : StockItem</code> and/or wrapping a <code>GraphicNode</code> in a <code>StockItem</code>) would result in a particular bad design because you don't want to hardwire a coupling to a specific presentation (<code>GraphicNode</code>) inside a domain/business/data entity (<code>StockItem</code>).</p> |
20,155,961 | 0 | How do I reduce repetitive code when inserting the same metadata into identical columns over multiple tables? <p><strong>My goals:</strong></p> <ul> <li>Follow database-normalization.</li> <li>Ability to track changes in my tables.</li> <li>Ability to restore the state of my database from a given point in time, e.g. last month.</li> <li>Separate the code that is processing the data so that the input can come either from a HTML-form or a script in another language (Ruby/perl).</li> </ul> <p>To accomplish this, I've opted for a database design like the one described in this answer:</p> <p><a href="http://stackoverflow.com/questions/12563706/is-there-a-mysql-option-feature-to-track-history-of-changes-to-records">StackOverflow: Is there a MySQL option/feature to track history of changes to records?</a></p> <p>However, when a user updates several fields, the same metadata has to be inserted into multiple tables that contain identical columns, and my code becomes repetitive. </p> <p><strong>Example:</strong></p> <p>A user submits data through a HTML-form. PHP processes the data like below, with the help of Propel ORM.</p> <pre><code>function insertEvent($name, $venueId, $user, $date, $id = 0) { //validation and formatting.. //if id == 0, new event, //else, this is an update, archive the old database row on successful processing and maintain a common id as a parent //... $event = new Event(); $event->setName($name); $event->setVenueId($venueId); $event->setUser($user); //1 $event->setValidFrom($date); //1 $event->setValidUntil(null); //1 $event->save(); // ... } function insertEventPhonenumber($phonenumber, $pid, $user, $date, $id = 0) { //... $event_phonenumber = new EventPhonenumber(); $event_phonenumber->setPid($pid); //2 $event_phonenumber->setPhonenumber($phonenumber); $event_phonenumber->setUser($user); //2 $event_phonenumber->setValidFrom($date); //2 $event_phonenumber->setValidUntil(null); //2 $event_phonenumber->save(); // ... } function insertEventArtistId($artistId, $pid, $user, $date, $id = 0) { //... $event_artistId = new EventArtistId(); $event_artistId->setPid($pid); //3 $event_artistId->setArtistId($artistId); $event_artistId->setUser($user); //3 $event_artistId->setValidFrom($date); //3 $event_artistId->setValidUntil(null); //3 $event_artistId->save(); // ... } </code></pre> <p><strong>My problem:</strong></p> <p>In my full code there are more tables affected than the three in the example.</p> <p>Marked with //1, //2 and //3, you see data input that is often going to be identical.</p> <p>In my stomach, I don't like this. I've been trying search engines with queries like 'common columns in SQL insert queries over multiple tables' and variations of the wording, without finding anything directly related to my problem.</p> <p>Is this bad practice like it feels to me?</p> <p>How can I minimize the repetition in my code?</p> |
19,118,230 | 0 | <p>You can always use "firebug" to track the elements of a website. It comes a plugin for firefox.</p> |
9,732,383 | 0 | month array not displaying proper value <p>i have month array like</p> <pre><code>$month = array( 01 => "January", 02 => "February", 03 => "March", 04 => "April", 05 => "May", 06 => "June", 07 => "July", 08 => "August", 09 => "September", 10 => "October", 11 => "Novemeber", 12 => "December" ); </code></pre> <p>but when i print_r this it display like this<br><br></p> <pre><code>Array ( [1] => January [2] => February [3] => March [4] => April [5] => May [6] => June [7] => July [0] => September [10] => October [11] => Novemeber [12] => December ) </code></pre> <p>it displaying sept as 0 and the month of august is not dispalying.<br></p> <p>can any one please tell me what is the problem with this. <br> Thanks</p> |
11,872,269 | 0 | stuck building a 'cart management' system <p>I'm trying to build a database for video spots. The main page is a list of spots and you can check them and modify them. What i want to do is build a cart system, where the checked spots' id's are automatically added to the cart and stored as a cookie. That way the use can browse multiple pages while still having everything stay checked.</p> <p>So far, I have a checkbox on every spot that when checked calls a function that adds the id of the checkbox to an array and stores it as a cookie. </p> <p>I'm able to retrieve the cookie through jquery. What I need to do is while looping through the spots and printing them, is to check if that spot id is in the cookie, so I can set it as checked or not through php. Is this possible? Is there a better way to accomplish this?</p> <p>Here is what i have so far.</p> <pre><code>$(document).ready(function(){ var checkedItems = []; $('.spotCheck').click(function(){ var currentID = this.id; checkedItems.push(currentID); updateCookie(); }); function updateCookie(){ $.cookie('itemList',checkedItems); } $('#mainContainer').click(function(){ $('#textInCenter').html($.cookie('itemList') ); }); }); </code></pre> <p>Clicking the checkbox adds the ID to the array checkedItems, and click the mainContainer makes it visible so I can see which items are currently in the array. I can browse through pages and the cookies stay in the array (there's no way to remove them now but I'm not worried about that right now).</p> <p>So how can I check the array to see if an id is in there when I print the list of spots?</p> |
23,520,464 | 0 | <p>The <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy" rel="nofollow">Same Origin Policy</a> prevents you from manipulating the content of an Iframe from an different domain. This was put in place to prevent Iframed content from hijacking your privacy.</p> <p>What you want cannot be done.</p> |
22,225,288 | 0 | Performance of $rootScope.$new vs. $scope.$new <p>My current Controllers <code>$scope</code> is kind of thick with: <code>$watch</code> and event handlers. </p> <p>On one point I need to create a new scope for a modal, which does not have its own controller, because its quite simple. Still it needs a property of the current <code>$scope</code>. I was wondering which of the following solutions is better, and why?</p> <p>a)</p> <pre><code>var modalScope = $rootScope.$new(); modalScope.neededValue = $scope.neededValue; </code></pre> <p>b)</p> <pre><code>var modalScope = $scope.$new(); // modalScope.neededValue already there </code></pre> <p>Should I be worried that the created <code>modalScope</code> will watch also those expressions and events? Any other aspects I should be aware of?</p> |
3,575,186 | 0 | I want to Display news and events in a html page such that automatically they are rotating but on mouseover they stop? <p>I want to Display news and events in a html page such that automatically they are rotating but on mouseover they stop? Please give me any article link related this?</p> |
8,349,264 | 0 | <p>Remove the line that says:</p> <pre><code>android:inputType="text" </code></pre> <p>Then you should get ellipses.</p> |
32,009,553 | 0 | <p>The button is using the default styling. By setting the border to solid will override the default styles.</p> <p>You can combine the border declaration of width, style and colour into one line like so:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.btnstyle2{ height: 28px; text-align: center; background-color: #F8F8F8; border-radius: 3px; border: 2px solid #E8E8E8; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><button type="button" class="btnstyle2">Dismiss</button></code></pre> </div> </div> </p> |
34,951,325 | 0 | Handle GZip compression on Apache 2.4.18 using mod_jk <p>I use Apache 2.4.18 as a reverse proxy to a Java web application.</p> <p>I need to configure gzip-compression on Html and Javascript files.</p> <p>I have deflate, headers and filter modules activated (and mod_jk, for sure).</p> <p>My apache2.conf file is a the default configuration file where I've added:</p> <pre><code>Include sites-enabled/ JKWorkersFile /etc/apache2/workers.properties ServerName localhost </code></pre> <p>My sites-enabled/example.com is reverse proxying to my application like this:</p> <pre><code><VirtualHost *:443> ServerName gzip.example.com SSLEngine on JKMount /application* 172_10_0_1;use_server_errors=400,500 ErrorLog /var/log/apache2/gzip.example.com-error.log LogLevel warn CustomLog /var/log/apache2/gzip.example.com-access.log combined SSLCertificateFile /etc/ssl/private/*.example.com.pem SSLCertificateChainFile /etc/ssl/private/chain_example.com.crt </VirtualHost> </code></pre> <p>And I'm using, in the mods-enabled/deflate.conf:</p> <pre><code><IfModule mod_deflate.c> <IfModule mod_filter.c> # these are known to be safe with MSIE 6 AddOutputFilterByType DEFLATE text/html text/plain text/xml # everything else may cause problems with MSIE 6 AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/xml </IfModule> </IfModule> </code></pre> <p>My browser says, on a js file (also check with Google Pagespeed):</p> <pre><code>Response Headers Accept-Ranges:bytes Cache-Control:max-age=0, no-cache, must-revalidate Connection:Keep-Alive Content-Length:15292 Content-Type:text/javascript Date:Fri, 22 Jan 2016 16:21:05 GMT ETag:W/"15292-1440752026000" Expires:Thu, 01 Jan 1970 00:00:00 GMT Keep-Alive:timeout=5, max=99 Last-Modified:Fri, 28 Aug 2015 08:53:46 GMT Pragma:No-cache Server:Apache/2.4.18 (Ubuntu) mod_jk/1.2.37 OpenSSL/1.0.2e Strict-Transport-Security:max-age=31536000 ; includeSubDomains X-Frame-Options:SAMEORIGIN </code></pre> <p>Is there a configuration that I missed?</p> |
33,320,061 | 0 | PHP Facebook SDK - check if user liked a fanpage <p>I'm trying to check if user liked a fanpage.</p> <p>Here is my code:</p> <pre><code> $facebook = new Facebook(array( 'appId' => APP_ID, 'secret' => APP_SECRET, 'cookie' => true, )); $user = $facebook->getUser(); if (!$user) { $loginUrl = $facebook->getLoginUrl(array( 'scope' => 'user_likes' )); } else { try { $likes = $facebook->api("/me/likes/".$fanpage_id); </code></pre> <p>And my problem - Facebook doesn't give me in a response facebook pages id. I don't know why. When I try to accept a permissions (as user), I can accept only publish informations about me. I can't accept permission "user_likes" because I can't see this permission in text information while I'm accepting a permissions.</p> <p>Anyone can't help me?</p> |
30,838,260 | 0 | <pre><code>sed 's/$/ /;/[[:space:]]\(0\.\)\{0,1\}0[[:space:]]/!b o s/\([^[:space:]]*\).*/\1 0.0 0/ :o s/ $//' YourFile </code></pre> <p>with formating column</p> <pre><code>sed 's/$/ /;/[[:space:]]\(0\.\)\{0,1\}0[[:space:]]/!b o h;s/[[:space:]].*//;x;s/[^[:space:]]*//;s/[1-9]/0/g;H;x;s/\n// :o s/ $//' YourFile </code></pre> |
38,931,351 | 0 | <p>Build your query something like.</p> <pre><code>$query="select * from table where source in(".$_SESSION.")"; $result = mysqli_query($con,$query); </code></pre> |
34,147,784 | 0 | Errors with require_once in php <p>I don't know why when i add a require_once function in my code, it can not run, always show that failed to open stream.</p> <pre><code><?php require_once("../../../../cadpro_vs2/include/admin/ad_nav.php") ?> </code></pre> <p>Any mistake on syntax or something, please help!</p> <p>Can anyone help me?</p> |
14,176,576 | 0 | MS Access query sum up the values when certain columns match <p>I have an Access database holding shoot days for commercials and line items tied to each shoot day. </p> <p>So I'll have something like...</p> <pre><code>Shoot Day ...... Total Travel 400 Travel 150 Travel 200 1 350 1 275 2 850 2 500 ... ... </code></pre> <p>This goes on for a while. I want a query to return something like</p> <pre><code>Shoot Day ....... Total Travel 750 1 625 2 1350 ... ... </code></pre> <p>So I'd like it to add up the total column whenever there is a match in the Shoot Day column.</p> <p>I'd love some help! </p> |
24,153,610 | 0 | Category Hierarchy in Jekyll <p>I've been trying to use Jekyll categories in a hierarchical fashion, i.e.</p> <pre><code>A: ['class', 'topic', 'foo'] AA: ['class', 'topic', 'foo', 'bar'] AB: ['class', 'topic', 'foo', 'baz'] AAA: ['class', 'topic', 'foo', 'bar', 'qux'] </code></pre> <p>I'm trying to create a listing of all immediate subdirectories programmatically. That is, on a page with categories (A), I wish to be able to list the posts with categories (AA) and (AB), but not (AAA). Is this possible with Jekyll's vanilla structure, or should I consider using a plugin?</p> |
3,461,218 | 0 | Best Practice: iPhone app communicating to php script hosted on server <p>My iPhone app communicates with a php script hosted on a server. Hard coded into the app is the domainname.com/phpscript.php?=data</p> <p>If something happens to my domain name, the app won't work. Is there a best practice for handling this. Do you suggest a DNS or something? I'm just looking for ways to avoid a complete resubmission to apple, which takes a good 5 days.</p> |
9,332,963 | 0 | <p>Try this:</p> <pre><code>-webkit-border-radius: 7px !important;-moz-border-radius: 7px !important; </code></pre> <p>I have used your code and !important fixed the issue.</p> |
38,711,033 | 0 | How to group items in array by summary each item <pre><code><?php $quantity = array(1,2,3,4,5,6,7,8,9,10,11,12,1,14,2,16); // Create a new array $output_array = array(); $sum_quantity = 0; $i = 0; foreach ($quantity as $value) { if($sum_quantity >= 35) { $output_array[$i][] = $value; } $sum_quantity = $sum_quantity + $value; } print_r($output_array); </code></pre> <p>When summmary each item >= 35 will auto create child array</p> <pre><code>array( [0] => array(1, 2, 3, 4, 5, 6, 7), [1] => array(8, 9, 10), [2] => array(11, 12, 1), [3] => array(14, 2, 16) ) </code></pre> |
10,054,422 | 0 | <p>Do you have any specific reason for using two different pcs? Assuming if you have two application, you can deploy them in one PC and have DB in the same PC.</p> <p>The design of the application should be like this. 1) Develop a REST/SOAP based Webservice application which talk to DB. 2) Deploy this application in Application server. 2) In your android application user REST/SOAP based webservice client to talk to the webservice hosted in step 2.</p> |
24,641,573 | 0 | How to Install SSL certificate in Linux Servers <p>I am trying to access https wcf web service from my application using monodevelop in Linux. The web service call is throwing the following exception</p> <blockquote> <p>SendFailure (Error writing headers) at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00043] in /home/abuild/rpmbuild/BUILD/mono-3.4.0/mcs/class/System/System.Net/HttpWebRequest.cs:845 at System.ServiceModel.Channels.HttpRequestChannel+c__AnonStorey1.<>m__0 (IAsyncResult r) [0x0001d] in /home/abuild/rpmbuild/BUILD/mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:219.</p> </blockquote> <p>when I try to load the web service url using https, the Firefox browser is giving a warning:</p> <blockquote> <p>"This connection is Untrusted"</p> </blockquote> <p>The certificate(.cer) is generated using Visual Studio 2008 makecert utility.I tried to install certificate using the below commands </p> <ol> <li>certmgr -add -c -m My MyCert.cer</li> <li>certmgr -ssl <a href="https://myserver.com:1200/Monik/TestSvc" rel="nofollow">https://myserver.com:1200/Monik/TestSvc</a></li> </ol> <p>But it looks like the certificates are not configured properly. In some of the forums it saying that move the certificate to <strong>/etc/httpd/conf</strong> . But there is no such folder in my system</p> <p>Please let me know what I am missing?</p> |
26,389,122 | 1 | BeautifoulSoup not working on malformed utf-8 HTML <p>I'm starting to play with <code>BeautifulSoup</code> but its not working. Just tried to obtain all links with <code>find_all('a')</code> and the reponse is always <code>[]</code> or <code>null</code>. Issues could be caused by iso/utf-8 encoding or malformed html, right?</p> <p>I've found that if I only take code between <code><body></body></code> tags it will work ok, so we can prob discard encoding. </p> <p>So what to do? Is there a soup built-in function to fix malformed html? Maybe use RE to just take <code><body></code> contents? Any clues? Its probably a common issue...</p> <p>By the way, i'm dealing with Portuguese (pt_BR) language, Win64, Python27 and example not-working page is <a href="http://www.tudogostoso.com.br/" rel="nofollow">http://www.tudogostoso.com.br/</a></p> <p>EDIT: What i've done so far</p> <pre><code>#im using mechanize br = mechanize.Browser() site = 'http://www.tudogostoso.com.br/' r = br.open(site) #returned html IS OK. outputed and tested a lot html = r.read() soup = BeautifulSoup(html) for a in soup.find_all('a', href=True): print "Found the URL:", a['href'] #nothing happens #but if html = <body>...</body> (cropped manually) its works and prints all the links </code></pre> |
40,705,641 | 0 | <p>I was going through a similar issue and none of the above answers helped. My issue was:</p> <p>-> media message added (worked fine) -> text message added just after media message (app crashed)</p> <p>I found that my problem lied in this piece of code in my cell for item at indexPath</p> <pre><code> let message = messages[(indexPath as NSIndexPath).item] if message.senderId == senderId { cell.textView!.textColor = UIColor.white } else { cell.textView!.textColor = UIColor.black } </code></pre> <p>I just commented out this code and everything works fine now.</p> |
16,274,260 | 0 | Read a complex file to pair <string,pair<map<string,string> string> > C++ <p>So we basically want to read a text file consisting of some different segments to our program:</p> <p>the structure in the program is a cache with: pair data> ></p> <p>the structure in the file is (were key is used as both a key and a delimiter between segments) </p> <pre><code>key headerKey : headerValue headerKey : headerValue ...................... headerKey : headerValue key data data ... data key </code></pre> <p>We have been trying to read this using the following, but it doesnt read the date format (RFC1123). we only get the dates in headerValues as "08 Gmt" or similar "XX gmt". What is wrong in our reading algorithm, below is that <strong>we are using : as a delimiter</strong> but it appears in the date format in different meaning, i.e. segmenting the time:</p> <pre><code> try{ // Create stream ifstream ifs(this->cacheFile.c_str(), ios::binary); // Read file to cache if stream is good if(ifs.good()){ while (! ifs.eof() ){ map<string,string> headerPairs; string tmp; string key; string data; getline(ifs, tmp); while(tmp.empty()){ getline(ifs, tmp); cout << "Empty line..." << "\n"; if(ifs.eof()){ cout << "End of File.."<< "\n"; break; } } //After empty lines get "Key" key = tmp; getline(ifs, tmp); //Get segment of header pairs while(tmp != key){ StringTokenizer headerPair(tmp, ":", StringTokenizer::TOK_TRIM); //StringTokenizer::Iterator it = headerPair.begin(); std::cout << *(headerPair.begin()) <<": " << *(headerPair.end()-1)<< std::endl; string headerKey = *(headerPair.begin()); string headerValue = *(headerPair.end()-1); headerPairs.insert(make_pair(headerKey, headerValue)); getline(ifs, tmp); } cout << "Added " << headerPairs.size() << " header pairs from cache" << "\n"; //tmp equals Key while(tmp!=key){ getline(ifs, tmp); cout << "Searching for header->data delimiter" << "\n"; } cout << "Found header->data delimiter" << "\n"; //Get segment of data! getline(ifs, tmp); while(tmp != key){ data+=tmp; getline(ifs, tmp); } cout << "DATA: " << data << "\n"; cout << "Ending delimiter:" << tmp << "\n"; this->add(key,make_pair(headerPairs, data)); cout << "Added: " << key << " to memory-cache" << endl; } ifs.close(); } } catch (Exception &ex){ cerr << ex.displayText() << endl; } </code></pre> <p>Please suggest a better way of getting the date string:</p> <pre><code> DateTime now : Mon, 29 Apr 2013 08:15:57 GMT DateRetrieved from file: 57 GMT </code></pre> <p>In short: The problem is that we are using a : as a delimiter for the headers, i would like suggestions for another delimiter sign that is failsafe, i.e. it wont be found in the HTTP 1.0 or 1.1 Headers.</p> |
33,622,908 | 0 | <p>You'll need to use an array:</p> <pre><code>function f() { local args=("$@") # values in parentheses for arg in "${args[@]}"; do # array expansion syntax echo "$arg" done } </code></pre> |
20,834,720 | 0 | how to make an overlay of google maps stand on top of the zoom bar <p>So here is how I create an overlay (the standart way). Problem is, when I drag the map around, the overlay gets behind the zoom bar and other controls. I want those controls to go behind the overlay. I tried changing the z-index of the overlay but that doesn't work because parents of the overlay have low z-index. If I change z-index of the parents, the controls get hidden by the whole map. So the reason that changing z-index doesn't work is because overlay and zoom bar for example are in 2 different divs which themselves have z-index.</p> <pre><code><html> <head> <style type="text/css"> #map { width: 600px; height: 500px; } </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map; TestOverlay.prototype = new google.maps.OverlayView(); /** @constructor */ function TestOverlay(map) { this.setMap(map); } /** * onAdd is called when the map's panes are ready and the overlay has been * added to the map. */ TestOverlay.prototype.onAdd = function() { var div = document.createElement('div'); div.innerHTML = "I want the zoombar to go behind me."; div.style.backgroundColor = "white"; div.style.position = "relative"; div.style.fontSize = "20px"; // Add the element to the "overlayLayer" pane. var panes = this.getPanes(); panes.overlayLayer.appendChild(div); }; TestOverlay.prototype.draw = function() { }; // The onRemove() method will be called automatically from the API if // we ever set the overlay's map property to 'null'. TestOverlay.prototype.onRemove = function() { }; function init() { var mapCenter = new google.maps.LatLng(-35.397, 150.644); map = new google.maps.Map(document.getElementById('map'), { zoom: 8, center: mapCenter }); new TestOverlay(map); } google.maps.event.addDomListener(window, 'load', init); </script> </head> <body> <div id="map"></div> </body> </code></pre> <p></p> <p>As you can see. There is an overlay and thats about it, the rest comes from google maps api. Thanks in advance.</p> <p>So, in the end, very hacky and ugly but here's how I've done it:</p> <pre><code><html> <head> <style type="text/css"> #map { width: 600px; height: 500px; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var map; var ol; TestOverlay.prototype = new google.maps.OverlayView(); /** @constructor */ function TestOverlay(map) { this.setMap(map); } /** * onAdd is called when the map's panes are ready and the overlay has been * added to the map. */ TestOverlay.prototype.onAdd = function() { var div = document.createElement('div'); div.id = "dummy"; // Add the element to the "overlayLayer" pane. var panes = this.getPanes(); panes.overlayMouseTarget.appendChild(div); }; TestOverlay.prototype.draw = function() { }; // The onRemove() method will be called automatically from the API if // we ever set the overlay's map property to 'null'. TestOverlay.prototype.onRemove = function() { }; function init() { var mapCenter = new google.maps.LatLng(-35.397, 150.644); map = new google.maps.Map(document.getElementById('map'), { zoom: 8, center: mapCenter }); google.maps.event.addListenerOnce(map, 'idle', function() { var div = document.createElement('div'); div.id = "overlay"; div.className = "gmnoprint"; div.innerHTML = "Yes, the controls go behind me ;)"; div.style = "background-color:white;z-index:100000000000;position:absolute"; $(".gm-style").append(div); }); google.maps.event.addListener(map, 'drag', function() { $("#overlay").css("left", $("#dummy").parent().parent().parent().css("left")) $("#overlay").css("top", $("#dummy").parent().parent().parent().css("top")) }); ol = new TestOverlay(map); } google.maps.event.addDomListener(window, 'load', init); </script> </head> <body> <div id="map"></div> </body> </html> </code></pre> <p>Idea is that the overlay is on same level as the controls and there is a dummy overlay where the overlays are supposed to be. When drag event is fired, I get the coordinates of the dummy div, and put it in my overlay div. Thats about it :) .</p> |
32,980,329 | 0 | Avoiding cPickle in Ipython's parallel <p>I have some code that I have paralleled successfully in the sense that it gets an answer, but it is still kind of slow. Using cProfile.run(), I found that 121 seconds (57% of total time) were spent in cPickle.dumps despite a per call time of .003. I don't use this function anywhere else, so it must be occurring due to ipython's parallel.</p> <p>The way my code works is it does some serial stuff, then runs many simulations in parallel. Then some serial stuff, then a simulation in parallel. It has to repeat this many, many times. Each simulation requires a very large dictionary that I pull in from a module I wrote. I believe this is what is getting pickled many times and slowing the program down.</p> <p>Is there a way to push a large dictionary to the engines in such a way that it stays there permanently? I think it's getting physically pushed every time I call the parallel function.</p> |
22,260,913 | 0 | Is a real-time system sdhedulable? <p>There is a question in my operating systems book about scheduling a system. </p> <p>The question is: A real-time system needs to handle two voice calls that each run every 5 msec and consumes 1 msec of CPU time per burst, plus one video at 25 frames/sec, with each frame requiring 20 msec of CPU time. Is the system schedulable?</p> <p>The solution manual has this answer: Each voice call runs 200 times/second and uses up 1 msec per burst, so each voice call needs 200 msec per second or 400 msec for the two of them. The video runs 25 times a second and uses up 20 msec each time, for a total of 500 msec per second. Together they consume 900</p> <p>The book does not explain how to come to this conclusion, or gives an algorithm. So I was hoping someone could explain how this answer is worked out? </p> <p>Thank you.</p> |
10,160,305 | 0 | <p>For a project I did once, we used a ruby script to generate an AS file containing references to all classes in a certain package (ensuring that they were included in the compilation). It's really easy considering that flash only allows classes with the same name as the file it's in, so no parsing of actual code needed.</p> <p>It would be trivial to also make that add an entry to a dictionary (or something similar), for a factory class to use later.</p> <p>I believe it's possible to have a program execute before compilation (at least in flashdevelop), so it would not add any manual work.</p> <p>Edit: I added a basic FlashDevelop project to demonstrate. It requires that you have ruby installed. <a href="http://dl.dropbox.com/u/340238/share/AutoGen.zip" rel="nofollow">http://dl.dropbox.com/u/340238/share/AutoGen.zip</a></p> |
6,699,569 | 0 | <p>If you can get it to run in a browser then something as simple as this would work</p> <pre><code>var webRequest = WebRequest.Create(@"http://webservi.se/year/getCurrentYear"); using (var response = webRequest.GetResponse()) { using (var rd = new StreamReader(response.GetResponseStream())) { var soapResult = rd.ReadToEnd(); } } </code></pre> |
28,655,478 | 0 | Passing the lat, lng information to the google map script <p>I've have an index.html file that includes a gogglemap.js file to display a map of users location. Currently I am attempting to add the proper code to the index.html to pass the lat, lng info to the js file.</p> <p>Here is filler content for the index file to show what I am attempting to do:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code><h3><display user city></h3> <---- this needs to display users city and has filler text to show what I am trying to accomplish. <div id="map"></div> <script>var lat=12.356;var lng=-19.31;var country="User Country";var city="User City";</script> <----- seems like it is getting the lat/lng somehow before the index page loads and inserting this script into the index file?</code></pre> </div> </div> </p> <p>Here is the js file code:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var styles = [{yourcustomstyle}] var myLatlng = { lat: lat, lng: lng }; function initialize() { var mapOptions = { zoom: 12, center: myLatlng, styles: styles, panControl: false, zoomControl: false, mapTypeControl: false, scaleControl: false, streetViewControl: false, overviewMapControl: false }; var map = new google.maps.Map( document.getElementById('map'), mapOptions ); for (var a = 0; a < 6; a++) { c = Math.random(); c = c * (0 == 1E6 * c % 2 ? 1 : -1); d = Math.random() d = d * (0 == 1E6 * d % 2 ? 1 : -1); c = new google.maps.LatLng( lat + 0.08 * c + 0.052, lng + 0.2 * d + 0.08), marker = new google.maps.Marker({ map: map, position: c, icon: 'marker.png' }); } } function loadScript() { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&amp;callback=initialize'; document.body.appendChild( script ); } window.onload = loadScript;</code></pre> </div> </div> </p> |
34,300,055 | 0 | <p>You should not use fixed values for Width and Height. Take a look at the following links: <a href="http://www.informit.com/articles/article.aspx?p=2220312&seqNum=2" rel="nofollow">Arranging UI Elements</a> and <a href="https://msdn.microsoft.com/en-us/library/bb514707(v=vs.90).aspx" rel="nofollow">Layout with Absolute and Dynamic Positioning</a> to have an idea of how positioning works in XAML.</p> <p>I think you created the UI using the designer, that's why you got those values.</p> <p>Following is a simple example where the web view is filling all the space from the page:</p> <p>XAML</p> <pre><code><Page x:Class="Stack1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <WebView x:Name="WebView" LoadCompleted="WebView_LoadCompleted" Source="https://www.google.com"/> <ProgressRing x:Name="ProgressRing" Foreground="BlueViolet" IsActive="True" Width="100" Height="100" > </ProgressRing> </Grid> </code></pre> <p></p> <p>C# code behind</p> <pre><code>public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } private void WebView_LoadCompleted(object sender, NavigationEventArgs e) { ProgressRing.Visibility = Visibility.Collapsed; } } </code></pre> <p>The ProgressRing will be visible until the web-view content will be loaded (use of LoadCompleted event)</p> <p>Related to Adaptive UI you can take a look at this <a href="https://channel9.msdn.com/Events/Windows/Developers-Guide-to-Windows-10-RTM/Adaptive-UI" rel="nofollow">video</a>.</p> |
12,748,760 | 0 | <p>To get <strong>just</strong> those records that ARE in Encounter and NOT in EnctrAPR, then just use <code>left outer join</code> instead of <code>full outer join</code>, and add a clause excluding null values for EnctrAPR.EncounterNumber.</p> <p>i.e.</p> <pre><code>SELECT Encounter.EncounterNumber, substring(Encounter.EncounterNumber,4,9) as Acct, ... EnctrAPR.APRDRG, Age18, Age18To64, Age65 from Encounter left outer join EnctrAPR on substring(Encounter.EncounterNumber,4,9) = EnctrAPR.EncounterNumber where EnctrAPR.EncounterNumber is null and HSP# = 1 and InOutCode = 'I' and ActualTotalCharge >0 and AdmitSubService <> 'SIG' and [DischargeDate - CCYYMMDD] between @StartDate and @EndDate and Encounter.Age >= 18 </code></pre> <p>Note though that the value for <code>EnctrAPR.APRDRG</code> will always be null, as EnctrAPR doesn't have a matching row.</p> |
26,769,974 | 1 | vectorize for-loop to fill Pandas DataFrame <p>For a financial application, I'm trying to create a DataFrame where each row is a session date value for a particular equity. To get the data, I'm using <a href="http://pandas.pydata.org/pandas-docs/stable/remote_data.html" rel="nofollow">Pandas Remote Data</a>. So, for example, the features I'm trying to create might be the adjusted closes for the preceding 32 sessions.</p> <p>This is easy to do in a for-loop, but it takes quite a long time for large features sets (like going back to 1960 on "ge" and making each row contain the preceding 256 session values). Does anyone see a good way to vectorize this code?</p> <pre><code>import pandas as pd def featurize(equity_data, n_sessions, col_label='Adj Close'): """ Generate a raw (unnormalized) feature set from the input data. The value at col_label on the given date is taken as a feature, and each row contains values for n_sessions """ features = pd.DataFrame(index=equity_data.index[(n_sessions - 1):], columns=range((-n_sessions + 1), 1)) for i in range(len(features.index)): features.iloc[i, :] = equity_data[i:(n_sessions + i)][col_label].values return features </code></pre> <p>I could alternatively just multi-thread this easily, but I'm guessing that pandas does that automatically if I can vectorize it. I mention that mainly because my primary concern is performance. So, if multi-threading is likely to outperform vectorization in any significant way, then I'd prefer that.</p> <p>Short example of input and output:</p> <p><code>>>> eq_data Open High Low Close Volume Adj Close Date<br> 2014-01-02 15.42 15.45 15.28 15.44 31528500 14.96 2014-01-03 15.52 15.64 15.30 15.51 46122300 15.02 2014-01-06 15.72 15.76 15.52 15.58 42657600 15.09 2014-01-07 15.73 15.74 15.35 15.38 54476300 14.90 2014-01-08 15.60 15.71 15.51 15.54 48448300 15.05 2014-01-09 15.83 16.02 15.77 15.84 67836500 15.34 2014-01-10 16.01 16.11 15.94 16.07 44984000 15.57 2014-01-13 16.37 16.53 16.08 16.11 57566400 15.61 2014-01-14 16.31 16.43 16.17 16.40 44039200 15.89 2014-01-15 16.37 16.73 16.35 16.70 64118200 16.18 2014-01-16 16.67 16.76 16.56 16.73 38410800 16.21 2014-01-17 16.78 16.78 16.45 16.52 37152100 16.00 2014-01-21 16.64 16.68 16.36 16.41 35597200 15.90 2014-01-22 16.44 16.62 16.37 16.55 28741900 16.03 2014-01-23 16.49 16.53 16.31 16.43 37860800 15.92 2014-01-24 16.19 16.21 15.78 15.83 66023500 15.33 2014-01-27 15.90 15.91 15.52 15.71 51218700 15.22 2014-01-28 15.97 16.01 15.51 15.72 57677500 15.23 2014-01-29 15.48 15.53 15.20 15.26 52241500 14.90 2014-01-30 15.43 15.45 15.18 15.25 32654100 14.89 2014-01-31 15.09 15.10 14.90 14.96 64132600 14.61 >>> features = data.featurize(eq_data, 3) >>> features -2 -1 0 Date<br> 2014-01-06 14.96 15.02 15.09 2014-01-07 15.02 15.09 14.9 2014-01-08 15.09 14.9 15.05 2014-01-09 14.9 15.05 15.34 2014-01-10 15.05 15.34 15.57 2014-01-13 15.34 15.57 15.61 2014-01-14 15.57 15.61 15.89 2014-01-15 15.61 15.89 16.18 2014-01-16 15.89 16.18 16.21 2014-01-17 16.18 16.21 16 2014-01-21 16.21 16 15.9 2014-01-22 16 15.9 16.03 2014-01-23 15.9 16.03 15.92 2014-01-24 16.03 15.92 15.33 2014-01-27 15.92 15.33 15.22 2014-01-28 15.33 15.22 15.23 2014-01-29 15.22 15.23 14.9 2014-01-30 15.23 14.9 14.89 2014-01-31 14.9 14.89 14.61 </code></p> <p>So each row of features is a series of 3 (<code>n_sessions</code>) successive values from the 'Adj Close' column of the <code>features</code> DataFrame.</p> <p>====================</p> <p>Improved version based on Primer's answer below:</p> <p><code>def featurize(equity_data, n_sessions, column='Adj Close'): """ Generate a raw (unnormalized) feature set from the input data. The value at <code>column</code> on the given date is taken as a feature, and each row contains values for n_sessions >>> timeit.timeit('data.featurize(data.get("ge", dt.date(1960, 1, 1), dt.date(2014, 12, 31)), 256)', setup=s, number=1) 1.6771750450134277 """ features = pd.DataFrame(index=equity_data.index[(n_sessions - 1):], columns=map(str, range((-n_sessions + 1), 1)), dtype='float64') values = equity_data[column].values for i in range(n_sessions - 1): features.iloc[:, i] = values[i:(-n_sessions + i + 1)] features.iloc[:, n_sessions - 1] = values[(n_sessions - 1):] return features </code></p> |
20,183,039 | 0 | <p>The ability to take the product of a scalar and an array is a feature of numpy arrays (see <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html" rel="nofollow">broadcasting</a>) but clearly not of Cython's memoryviews. The way this can be done is by looping over the chunk of memory and multiplying each entry with the desired value. Alternatively, just stick with numpy arrays.</p> <p>Example code: </p> <pre><code>cdef double[:, :] c = np.empty((1, 3)) cdef int i for i in range(3): c[0, i] = a[0, i] * a[0, i] * 0.5 </code></pre> |
39,006,550 | 0 | Google Spreadsheet API update overwrite unspecified value <p>In the Google Spreadsheet API <a href="https://developers.google.com/sheets/reference/rest/v4/spreadsheets.values/update." rel="nofollow">https://developers.google.com/sheets/reference/rest/v4/spreadsheets.values/update.</a>,</p> <p>We can specify a valueRange<a href="https://developers.google.com/sheets/reference/rest/v4/spreadsheets.values/update." rel="nofollow">https://developers.google.com/sheets/reference/rest/v4/spreadsheets.values/update.</a> as the data we want to update</p> <p>Is there a way to overwrite all unspecified cells to empty? For example, if the original first row before updating is: ['1','2','3','4'] . Is there a way to make a request containing ['3'] and update the entire row to: ['3']. In other words, I want to provide absolute overwrite so that I don't need to do a read before update to know which cells I should update to empty</p> |
20,435,152 | 0 | Issue comparing doubles <p>This simple if-comparison is not working, and i'm not sure why.</p> <p>Code:</p> <pre><code>public abstract class Button extends Drawable_object { ... @Override public void update() { super.update(); mouseOver_last = mouseOver; double mx = Game_logic.get_mouse_x(); double my = Game_logic.get_mouse_y(); //the not working statement check: if ((mx <= x + ((double)width / 2))&& (mx >= x - ((double)width / 2))&& (my >= y - ((double)height / 2))&& (my <= y + ((double)height / 2))) { mouseOver = true;} else mouseOver = false; .... } </code></pre> <p>Whilst Game_logic.get_mouse_x() and y are static methods:</p> <pre><code>public class Game_logic { ... public static double get_mouse_x() { return mouse_x; } public static double get_mouse_y() { return mouse_y; } } </code></pre> <p>And those are set by Mouse adapaer in my main run class:</p> <pre><code> public Board() throws IOException, URISyntaxException { ... private class MAdapter2 extends MouseAdapter { @Override public void mouseMoved(MouseEvent e) { Game_logic.set_mouse_x(e.getX()); Game_logic.set_mouse_y(e.getY()); } } </code></pre> <p>The thing is, when I draw on screen x - width / 2, mx and x + width / 2 (same with y), holding mouse at my desired position looks like statement must be true, but <code>mouseOver</code> is still false. How do i fix that?</p> |
37,552,538 | 0 | Android - Sending file over bluetooth <p>I'm developing an Android application sending files from one device to another. Establishing the connection between both devices works perfectly, but there is something going wrong while transferring the file. On the receiving device, the file gets created but unfortunately it's empty.</p> <p>This is my code for handling the incoming file:</p> <pre><code>try { byte[] buffer = new byte[1024]; int bytes = 0; boolean eof = false; File file = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), "test.jpg"); OutputStream os = null; try { os = new BufferedOutputStream(new FileOutputStream(file)); } catch (FileNotFoundException e) { e.printStackTrace(); } while (!eof) { bytes = mmInStream.read(buffer); int offset = bytes - 11; byte[] eofByte = new byte[11]; eofByte = Arrays.copyOfRange(buffer, offset, bytes); String message = new String(eofByte, 0, 11); if(message.equals("end of file")) { os.flush(); os.close(); eof = true; } else { os.write (buffer); } } } catch (IOException e) { e.printStackTrace(); } </code></pre> |
17,340,758 | 0 | WSDL soap response validation <p>I have a wsdl that defines a schema with:</p> <pre><code><xsd:schema elementFormDefault="unqualified" targetNamespace="http://www.xpto.com/xpto"> </code></pre> <p>and the element:</p> <pre><code><xsd:element name="insertResponse"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="1" name="sys_id" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="1" name="table" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="1" name="display_name" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="1" name="display_value" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="1" name="status" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="0" name="status_message" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="0" name="error_message" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </code></pre> <p>but when i execute the operation and get the response, SoapUI says its invalid:</p> <pre><code><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <insertResponse xmlns="http://www.xpto.com/xpto"> <sys_id>something</sys_id> <table>something</table> <display_name>number</display_name> <display_value>something</display_value> <status>something</status> </insertResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> </code></pre> <p>The SoapUI message (with lines wrapped for legibility):</p> <pre><code>line 4: Expected element 'sys_id' instead of 'sys_id@http://www.xpto.com/xpto' here in element insertResponse@http://www.xpto.com/xpto </code></pre> <p>If i change the WSDL to include <code>elementFormDefault="qualified"</code>, in the schema, the same response is valid.</p> <p>Why is this response invalid without <code>elementFormDefault="qualified"</code> and what is the correct way to do it?</p> <p>Also the code generated against this WSDL doesn't like the response either, failing with:</p> <pre><code>Unmarshalling Error: unexpected element (uri:\\"http://www.xpto.com/xpto\\", local:\\"sys_id\\"). Expected elements are <{}table>,<{}display_value>,<{}display_name>, <{}error_message>,<{}sys_id>,<{}status_message>,<{}status> </code></pre> <p>(Again, lines wrapped for legibility.)</p> <p>Using apache-cxf.</p> |
21,701,309 | 0 | <p>Improve your question , but see below answer for your question</p> <pre><code> NSString *string = @"This is the main stringsss which needs to be searched for some text the texts can be any big. let us see"; if ([string rangeOfString:@"."].location == NSNotFound) { NSLog(@"string does not contains"); } else { NSLog(@"string contains !"); } </code></pre> |
12,747,208 | 0 | <p>Got a workaround from nboire from play2-elasticsearch project:</p> <p>Download the project from github. Go to project </p> <pre><code>cd module play compile play publish-local </code></pre> <p>Then your other projects will download from your local instead of <a href="http://cleverage.github.com" rel="nofollow">http://cleverage.github.com</a></p> |
19,396,021 | 0 | How to get number FDs occupied by a processes without using losf? <p>I am trying to get number of FDs occupied by my processes , i tried with lsof , unfortunately it is taking too much of time . If there any other way to get this number , i also tried looking at /proc//fd , but didn't find what i am looking for.</p> |
15,320,471 | 0 | <p>From your stack trace there is a <code>System.InvalidCastException</code></p> <p>It means value of some attribute has incorrect type. Since you are changing only 'tax' attribute, then its type is incorrect. Most probably "tax" is a Money field, so I guess you should assign variable of type <code>decimal</code> to it, not <code>double</code>. Try something like this:</p> <pre><code>decimal Tax = (decimal)((QuoteProduct.BaseAmount - QuoteProduct.ManualDiscountAmount.GetValueOrDefault() - QuoteProduct.VolumeDiscountAmount.GetValueOrDefault()) / 20); </code></pre> |
23,551,264 | 0 | Foreach Object with one element PHP <p>I have an object called <code>$people</code>. It is filled by my database. This object looks like this:</p> <pre><code>Array ( [0] => stdClass Object ( [id] => 21 [fname] => Billy [lname] => Boemba [email] => [email protected] [country] => The Netherlands ) [1] => stdClass Object ( [id] => 22 [fname] => Jill [lname] => Jimba [email] => [email protected] [country] => Austria ) </code></pre> <p>And my foreach like this:</p> <pre><code>foreach($people as $person){ // echo some stuff about the person } </code></pre> <p>All this works, but when I have one record in my database, so <code>$people</code> has only one element, I got a error when I try to use <code>foreach()</code>:<br/> <code>Notice: Trying to get property of non-object</code></p> <p>So how can I use the <code>foreach()</code> function with one element in my object?</p> |
13,148,670 | 0 | <p>Sorry to answer my own question but almost as soon as I posted, I was able to figure it out. So in case anyone else has a question like mine:</p> <pre><code>ini_set('auto_detect_line_endings', true); // Allows Mage require_once('../../app/Mage.php'); //Initializes Mage Mage::app('default'); deleteCoupon(); function deleteCoupon() { $collection = Mage::getModel('salesrule/rule')->getCollection()->load(); foreach($collection as $model) { // Delete all new newsletter sub coupons if ($model->getName() == 'New newsletter subscriber discount') { //Delete all coupons expiring today // if($model->getToDate() == date('Y-m-d')){ $model->delete(); echo "Deleted <br />"; } else { echo "No coupons found! <br />"; } } } </code></pre> |
13,156,208 | 0 | jqGrid multiplesearch - How do I add and/or column for each row? <p>I have a jqGrid multiple search dialog as below:</p> <p>(Note the first empty td in each row).</p> <p><img src="https://i.stack.imgur.com/tK6a1.jpg" alt="jqGrid now"></p> <p>What I want is a search grid like this (below), where:</p> <ol> <li>The first td is filled in with "and/or" accordingly.</li> <li>The corresponding search filters are also built that way.</li> </ol> <p><img src="https://i.stack.imgur.com/aHHqo.jpg" alt="jqGrid want"></p> <p>The empty td is there by default, so I assume that this is a standard jqGrid feature that I can turn on, but I can't seem to find it in the docs.</p> <p>My code looks like this:</p> <pre><code><script type="text/javascript"> $(document).ready(function () { var lastSel; var pageSize = 10; // the initial pageSize $("#grid").jqGrid({ url: '/Ajax/GetJqGridActivities', editurl: '/Ajax/UpdateJqGridActivities', datatype: "json", colNames: [ 'Id', 'Description', 'Progress', 'Actual Start', 'Actual End', 'Status', 'Scheduled Start', 'Scheduled End' ], colModel: [ { name: 'Id', index: 'Id', searchoptions: { sopt: ['eq', 'ne']} }, { name: 'Description', index: 'Description', searchoptions: { sopt: ['eq', 'ne']} }, { name: 'Progress', index: 'Progress', editable: true, searchoptions: { sopt: ['eq', 'ne', "gt", "ge", "lt", "le"]} }, { name: 'ActualStart', index: 'ActualStart', editable: true, searchoptions: { sopt: ['eq', 'ne', "gt", "ge", "lt", "le"]} }, { name: 'ActualEnd', index: 'ActualEnd', editable: true, searchoptions: { sopt: ['eq', 'ne', "gt", "ge", "lt", "le"]} }, { name: 'Status', index: 'Status.Name', editable: true, searchoptions: { sopt: ['eq', 'ne']} }, { name: 'ScheduledStart', index: 'ScheduledStart', searchoptions: { sopt: ['eq', 'ne', "gt", "ge", "lt", "le"]} }, { name: 'ScheduledEnd', index: 'ScheduledEnd', searchoptions: { sopt: ['eq', 'ne', "gt", "ge", "lt", "le"]} } ], jsonReader: { root: 'rows', id: 'Id', repeatitems: false }, rowNum: pageSize, // this is the pageSize rowList: [pageSize, 50, 100], pager: '#pager', sortname: 'Id', autowidth: true, shrinkToFit: false, viewrecords: true, sortorder: "desc", caption: "JSON Example", onSelectRow: function (id) { if (id && id !== lastSel) { $('#grid').jqGrid('restoreRow', lastSel); $('#grid').jqGrid('editRow', id, true); lastSel = id; } } }); // change the options (called via searchoptions) var updateGroupOpText = function ($form) { $('select.opsel option[value="AND"]', $form[0]).text('and'); $('select.opsel option[value="OR"]', $form[0]).text('or'); $('select.opsel', $form[0]).trigger('change'); }; // $(window).bind('resize', function() { // ("#grid").setGridWidth($(window).width()); //}).trigger('resize'); // paging bar settings (inc. buttons) // and advanced search $("#grid").jqGrid('navGrid', '#pager', { edit: true, add: false, del: false }, // buttons {}, // edit option - these are ordered params! {}, // add options {}, // del options {closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, onInitializeSearch: updateGroupOpText, afterRedraw: updateGroupOpText}, // search options {} ); // TODO: work out how to use global $.ajaxSetup instead $('#grid').ajaxError(function (e, jqxhr, settings, exception) { var str = "Ajax Error!\n\n"; if (jqxhr.status === 0) { str += 'Not connect.\n Verify Network.'; } else if (jqxhr.status == 404) { str += 'Requested page not found. [404]'; } else if (jqxhr.status == 500) { str += 'Internal Server Error [500].'; } else if (exception === 'parsererror') { str += 'Requested JSON parse failed.'; } else if (exception === 'timeout') { str += 'Time out error.'; } else if (exception === 'abort') { str += 'Ajax request aborted.'; } else { str += 'Uncaught Error.\n' + jqxhr.responseText; } alert(str); }); $("#grid").jqGrid('bindKeys'); $("#grid").jqGrid('inlineNav', "#grid"); }); </script> <table id="grid"/> <div id="pager"/> </code></pre> |
7,840,894 | 0 | <p>Q_MONKEY_EXPORT is most likely a #define somewhere. Defines like that are sometimes required, for example when the class is in a library and needs to be exported when the header file is included from somewhere else. In that case, the define resolves to something like <code>__declspec(dllexport)</code> (the exact syntax will depend on the tools you are using).</p> |
31,015,598 | 0 | <p>It seems better to use HashMap's boolean containsKey(Object key) method instead of the direct invocation of equalsIgnore..() in main(). If necessary, you may create your own class implement interface Map, and make it a delegator of its HashMap-typed field for customized management of key comparisons.(You may override equals() and hashCode() for keys. Item 8 and Item 9 in Effective Java 2nd ed. by Josh Bloch will give you detailed guide.)</p> |
8,998,607 | 0 | <p>Check that the file <code>RuleGradient.scala</code> starts with the line:</p> <pre><code>package org.dynamics </code></pre> |
19,527,990 | 0 | <p>Try this. I am sure you can do this via a couple JOINs (or at least part of it) but you did not request what your return columns should be</p> <pre><code>SELECT v.visitID FROM Visits AS v WHERE EXISTS(SELECT * FROM VisitDocs AS d WHERE d.VisitID = v.VisitID AND d.docType = 3) AND NOT EXISTS(SELECT * FROM VisitDocs AS d WHERE d.VisitID = v.VisitID AND d.docType Not IN (1,2)) </code></pre> |
34,602,213 | 0 | iOS Facebook Authentication PhoneGap on TestFlight <p>I'm currently testing my app on my iPhone that I built using Phonegap's Adobe Build with Apple's TestFlight application. My app contains Facebook authentication and when I click the authentication button I am presented with the following error:</p> <blockquote> <p>Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.</p> </blockquote> <p>I did a bit of research online and I added the iOS Platform along with my Bundle ID in the respective field on facebook's developer panel but that did not appear to fix things.</p> |
24,205,035 | 0 | <p>As suggested by all above, you can use <code>InetAddress.getByName("hostName")</code> but this can give you a cached IP, Read the java documentation for the same. If you want to get a IP from DNS you can use:</p> <pre><code>InetAddress[] ipAddress = DNSNameService.lookupAllHostAddr("hostName"); </code></pre> |
37,499,538 | 0 | How to write date_query for today, tomorow and next 7 days? <p>So i have a problem with writing <code>data_query</code> to gets post for today, tomorow, and for next 7 days. Any suggestion ?</p> <pre><code>'date_query'=>array('column'=>'post_date','after'=>'Today','before'=>'2 days'); </code></pre> |
31,712,185 | 0 | How to get correct summaries with analytics? <p>I want to get summary numbers from the <code>cust_detail</code> table if a specific <code>invoice_code</code> appears in <code>invoice_detail</code>. </p> <p>In this example, I'd like to report cust_detail summaries only for batches <code>10</code> and <code>20</code> because they are the ones with <code>invoice_code='9999'</code>. But the duplication in the <code>invoice_detail</code> table is skewing my numbers.</p> <pre><code>with invoice_detail as ( select '10' as invoice_batch, '9999' as invoice_code from dual union all select '10' as invoice_batch, '9999' as invoice_code from dual union all select '20' as invoice_batch, '1111' as invoice_code from dual union all select '30' as invoice_batch, '9999' as invoice_code from dual ), cust_detail as ( select '1' as cust_id, '10' as invoice_batch, 40 as points_paid, 30 as points_earned, 30 as points_delivered from dual union all select '1' as cust_id, '20' as invoice_batch, 10 as points_paid, 10 as points_earned, 10 as points_delivered from dual union all select '1' as cust_id, '30' as invoice_batch, 20 as points_paid, 15 as points_earned, 5 as points_delivered from dual ) select cust_id, sum(points_paid) over (partition by c.invoice_batch order by cust_id) batch_total from cust_detail c inner join invoice_detail i on c.invoice_batch=i.invoice_batch where i.invoice_code = '9999'; </code></pre> <p>Desired results:</p> <pre><code> CUST_ID PAID EARNED DELIVERED TOT_PAID TOT_EARNED TOT_DELIVERED --------- ------ -------- ----------- ---------- ------------ --------------- 1 40 30 30 60 45 40 1 20 15 5 60 45 40 </code></pre> |
20,995,086 | 0 | <p>I've finally found a workaround.</p> <p>In netbeans, I've set the background property of the button to some value (different from the one I want, but different from the default 240,240,240 too).</p> <p>When I run the applet, now I always get what I expect, that is the color set in the code with Nimbus.</p> |
37,928,854 | 0 | <blockquote> <p>Couldnt we have avoided the former and done the latter instead?</p> </blockquote> <p>Absolutely. In TypeScript, initializers are not a coding preference, they're a way to ensure that your object fulfills the specification defined by the interface. Crucially, if you add a new non-optional property to your square, the <code>let s: Square = {...</code> variant will <a href="http://www.typescriptlang.org/play/#src=interface%20Square%20%7B%0D%0A%20%20%20%20color%3A%20string%3B%0D%0A%20%20%20%20sideLength%3A%20number%3B%0D%0A%09newProperty%3A%20number%3B%20%2F%2F%20%3C--------%0D%0A%7D%0D%0A%0D%0Alet%20square%20%3D%20%3CSquare%3E%7B%7D%3B%0D%0Asquare.color%20%3D%20%22blue%22%3B%0D%0Asquare.sideLength%20%3D%2010%3B%0D%0A%0D%0Alet%20s%3A%20Square%20%3D%20%7B%20sideLength%3A%2023%2C%20color%3A%20'red'%7D%3B" rel="nofollow">blow up as expected</a>, while the other variant (cast and assign) will be silent. (And of course, someone might accidentally remove or forget to add one of the property assignments, which would again introduce an error of the sort that TypeScript is designed to avoid.)</p> <p>Avoid casting whenever possible. Assuming your dependencies aren't circular (seldom the case), you can always re-write code like this to use initializers. If you want to create an object where some properties may be missing, define those properties as optional in the interface by adding a <code>?</code>:</p> <pre><code>interface Triangle { nonOptional: number; optional?: number; } const t: Triangle = {nonOptional: 1}; // no error </code></pre> |
26,538,148 | 1 | How to extend the django-comments model <p>(Sorry for my bad english, i'm a shabby French)</p> <p>I try to extend the django comment framework to add a like/dislike system. After read <a href="https://docs.djangoproject.com/en/1.7/ref/contrib/comments/custom/#an-example-custom-comments-app" rel="nofollow">the documentation</a>, i have added this to my <strong>model.py</strong> :</p> <pre><code>from django.contrib.comments.models import Comment class Commentslikes(Comment): positif = models.IntegerField(default=0) negatif = models.IntegerField(default=0) </code></pre> <p>After launch the command <code>python manage.py syncdb</code>, django have created the <strong>commentslikes</strong> mysql table with 3 cols : <em>comment_ptr_id</em>, <em>positif</em>, <em>negatif</em> . It's ok.</p> <p>In my <strong>view.py</strong> file, i have override the comment post view with this : </p> <pre><code> def custom_comment_post(request, next=None, using=None): #Post the comment and get the response response = contrib_comments.post_comment(request, next, using) if type(response) == HttpResponseRedirect: redirect_path, comment_id = response.get('Location').split( '?c=' ) if comment_id: comment = Comment.objects.get( id=comment_id ) if comment: #For test, i try to add 20 positif likes, 10 dislikes and edit the comment with 'foo' comment.positif = 20 comment.negatif = 10 comment.comment = 'foo' comment.save() return HttpResponseRedirect( redirect_path + "#c" + comment_id) return response </code></pre> <p>Then I posted a test comment. Comment has been modified with 'foo' but no rows have been added in the <strong>commentslikes</strong> table with the id of comment, positif at 20 and negatif at 10. Not row for the comment has added in <strong>commentslikes</strong></p> <p>I have forgotten or done something ?</p> <p>Thanks, Thomas</p> |
5,079,540 | 0 | VB.Net - Cannot create field "password" in Access <pre><code>'Create field in table Public Sub createField(ByVal tableName As String, ByVal fieldName As String, ByVal fieldType As String) If Not isConnected() Then XGUI.consolePrint("XAccessDatabase.createField() Warning - Database not connected. Create field canceled") Exit Function End If Dim myOleDbCommand As OleDbCommand myOleDbCommand = New OleDbCommand("ALTER TABLE " & tableName & " ADD COLUMN " & fieldName & " " & fieldType, connection) myOleDbCommand.ExecuteNonQuery() End Function createField("users", "password", "TEXT(60)") 'Password </code></pre> <p>I get: Syntax error in field definition, when I try to create "password" field. In all other cases (other field names) it works fine.</p> <p>When trying to create it manually with MS-Access, I have no problem either. What is going on???</p> |
5,255,570 | 0 | Help Needed!! Compiling C++ program - errors <p>This is a routine that I believe is for C. I copied it (legally) out a book and am trying to get it to compile and run in visual studio 2008. I would like to keep it as a C++ program. Lots of programming experience in IBM mainframe assembler but none in C++. Your help is greatly appreciated. I think just a couple of simple changes but I have read tutorials and beat on this for hours - getting nowhere. Getting a lot (4) of error C2440 '=' : cannot convert form 'void*' to to 'int*' errors in statements past the reedsolomon function: Thanks so much! Program follows:</p> <pre><code>#include <iostream> using namespace std; int wd[50] = {131,153,175,231,5,184,89,239,149,29,181,153,175,191,153,175,191,159,231,3,127,44,12,164,59,209,104,254,150,45}; int nd = 30, nc=20, i, j, k, *log, *alog, *c, gf=256, pp=301; /* The following is routine which calculates the error correction codewords for a given data codeword string of length "nd", stored as an integer array wd[]. The function ReedSolomon()first generates log and antilog tables for the Galois Field of size "gf" (in the case of ECC 200, 28) with prime modulus "pp" (in the case of ECC 200, 301), then uses them in the function prod(), first to calculate coefficients of the generator polynomial of order "nc" and then to calculate "nc" additional check codewords which are appended to the data in wd[].*/ /* "prod(x,y,log,alog,gf)" returns the product "x" times "y" */ int prod(int x, int y, int *log, int *alog, int gf) {if (!x || !y) return 0; else return alog[(log[x] + log[y]) % (gf-1)]; } /* "ReedSolomon(wd,nd,nc,gf.pp)" takes "nd" data codeword values in wd[] */ /* and adds on "nc" check codewords, all within GF(gf) where "gf" is a */ /* power of 2 and "pp" is the value of its prime modulus polynomial */ void ReedSolomon(int *wd, int nd, int nc, int gf, int pp) {int i, j, k, *log,*alog,*c; /* allocate, then generate the log & antilog arrays: */ log = malloc(sizeof(int) * gf); alog = malloc(sizeof(int) * gf); log[0] = 1-gf; alog[0] = 1; for (i = 1; i < gf; i++) {alog[i] = alog[i-1] * 2; if (alog[i] >= gf) alog[i] ^= pp; log[alog[i]] = i; } /* allocate, then generate the generator polynomial coefficients: */ c = malloc(sizeof(int) * (nc+1)); for (i=1; i<=nc; i++) c[i] = 0; c[0] = 1; for (i=1; i<=nc; i++) {c[i] = c[i-1]; for (j=i-1; j>=1; j--) {c[j] = c[j-1] ^ prod(c[j],alog[i],log,alog,gf); } c[0] = prod(c[0],alog[i],log,alog,gf); } /* clear, then generate "nc" checkwords in the array wd[] : */ for (i=nd; i<=(nd+nc); i++) wd[i] = 0; for (i=0; i<nd; i++) {k = wd[nd] ^ wd[i] ; for (j=0; j<nc; j++) {wd[nd+j] = wd[nd+j+1] ^ prod(k,c[nc-j-1],log, alog,gf); } } free(c); free(alog); free(log); return (); } int main () {reedsolomon (50,30,20,256,301); for (i = 1; i < 51; i++) {cout<< i; "="; wd[i];} cout<<"HEY, you, I'm alive! Oh, and Hello World!\n"; cin.get(); return 1; } </code></pre> |
39,298,707 | 0 | <p>I have written a code according to my logic. It gives correct output for all the possible inputs came in my mind so have a look at it.</p> <pre><code>import java.util.Scanner; class Combination { public static void main(String args[]) { Scanner sc =new Scanner(System.in); System.out.println("Enter total number of fruit1:"); int fruit_1=sc.nextInt(); System.out.println("Enter total number of fruit2:"); int fruit_2=sc.nextInt(); System.out.println("Enter total number of fruits you want in combination:"); int total=sc.nextInt(); int max=0; int min=0; if(fruit_1>fruit_2) { max=fruit_1; min=fruit_2; } else { max=fruit_2; min=fruit_1; } int ans=0; if(max>total && min>total) ans=total+1; else if(max>total && min<total) ans=min+1; else ans=fruit_1+fruit_2-total+1; if(ans<0) //if A+B<N but u didn't consider in the question System.out.println("Possible Combinations:0"); else System.out.println("Possible Combinations:"+ans); } } </code></pre> <p><strong>EDIT</strong>: Actually I tried to make algorithm and I have made an easier algorithm which will give <code>O(1)</code> Complexity.</p> <pre><code>Take Input A,B from user. Take Input N. Min=Minimum(A,B) Max=Maximum(A,B) If Max>N && Min>N OP=N+1; else If Max>N && Min<N OP=Min+1; else //Max<N && Min<N OR Any other cases OP=A+B+1-N; </code></pre> |
33,938,511 | 0 | <blockquote> <p>I want my data starting with particular ID to be at a predefined node because I know data will be accessed from that node heavily.</p> </blockquote> <p>Looks like that you talk about data locality problem, which is really important in bigdata-like computations (Spark, Hadoop, etc.). But the general approach for that isn't to pin data to specific node, but just to move your whole computation to the data itself.</p> <p>Pinning data to specific node may cause problems like:</p> <ul> <li>what should you do if your node goes down?</li> <li>how evenly will the data be distributed among the cluster? Will be there any hotspots/bottlenecks because of node over(under)-utilization?</li> <li>how can you scale your cluster in future?</li> </ul> <p>Moving computation to data has no issues with these questions, but the approach you going to choose - has.</p> |
15,189,447 | 0 | jInterface to create External Erlang Term <p>How can I format the the following erlang term:</p> <pre><code>{ atom, "message" } </code></pre> <p>In jInterface to an external format that I may call in an erlang shell</p> <pre><code>erlang:binary_to_term( Binary ) </code></pre> <p>Example: Note that since the tuple will be sent over the net, I finish by converting to byte[].</p> <pre><code>OtpErlangObject[] msg = new OtpErlangObject[2]; msg[0] = new OtpErlangAtom( "atom" ); msg[1] = new OtpErlangString( "message" ); OtpErlangTuple reply = new OtpErlangTuple(msg); OtpOutputStream stream = new OtpOutputStream(reply); stream.toByteArray() // byte[] which I send over net </code></pre> <p>The binary received by Erlang is:</p> <pre><code>B = <<104,2,100,0,4,97,116,111,109,107,0,7,109,101,115,115,97,103,101>> </code></pre> <p>Then in an erlang shell converting the received term to binary gives a badarg.</p> <pre><code> binary_to_term( B ). ** exception error: bad argument in function binary_to_term/1 called as binary_to_term(<<104,2,107,0,4,97,116,111,109,107,0,7,109, 101,115,115,97,103,101>>) </code></pre> |
10,211,644 | 0 | <p><code>NSURLConnection</code> will automatically use the system settings for the proxy. You don't have to do anything to enable that.</p> |
15,215,355 | 0 | Consistently subset matrix to a vector and avoid colnames? <p>I would like to know if there is R syntax to extract a column from a matrix and <em>always</em> have no name attribute on the returned vector (I wish to rely on this behaviour).</p> <p>My problem is the following inconsistency:</p> <ul> <li>when a matrix has more than one row and I do <code>myMatrix[, 1]</code> I will get the first column of <code>myMatrix</code> with no name attribute. This is what I want.</li> <li>when a matrix has <strong>exactly one row</strong> and I do <code>myMatrix[, 1]</code>, I will get the first column of <code>myMatrix</code> <strong>but it has the first colname as its name</strong>.</li> </ul> <p>I would like to be able to do <code>myMatrix[, 1]</code> and <em>consistently</em> get something with <strong>no name</strong>.</p> <p>An example to demonstrate this:</p> <pre><code># make a matrix with more than one row, x <- matrix(1:2, nrow=2) colnames(x) <- 'foo' # foo # [1,] 1 # [2,] 2 # extract first column. Note no 'foo' name is attached. x[, 1] # [1] 1 2 # now suppose x has just one row (and is a matrix) x <- x[1, , drop=F] # extract first column x[, 1] # foo # <-- we keep the name!! # 1 </code></pre> <p>Now, the documentation for <code>[</code> (<code>?'['</code>) mentions this behaviour, so it's not a bug or anything (although, why?! why this inconsistency?!):</p> <blockquote> <p>A vector obtained by matrix indexing will be unnamed <strong>unless ‘x’ is one-dimensional</strong> when the row names (if any) will be indexed to provide names for the result.</p> </blockquote> <p><strong>My question is</strong>, is there a way to do <code>x[, 1]</code> such that the result is <em>always</em> unnamed, where <code>x</code> is a matrix?</p> <p>Is my only hope <code>unname(x[, 1])</code> or is there something analogous to <code>[</code>'s <code>drop</code> argument? Or is there an option I can set to say "always unname"? Some trick I can use (somehow override <code>[</code>'s behaviour when the extracted result is a vector?)</p> |
10,186,059 | 0 | C++ Out of Subscript Range <p>I'm running a C++ Program that is supposed to convert string to hexadecimals. It compiles but errors out of me at runtime saying:</p> <blockquote> <p>Debug Assertion Failed! (Oh no!)</p> <p>Visual Studio2010\include\xstring</p> <p>Line 1440</p> <p>Expression: string subscript out of range</p> </blockquote> <p>And I have no choice to abort... It seems like it converts it though up to the point of error so I'm not sure what's going on. My code is simple:</p> <pre><code>#include <iostream> #include <iomanip> #include <string> using namespace std; int main() { string hello = "Hello World"; int i = 0; while(hello.length()) { cout << setfill('0') << setw(2) << hex << (unsigned int)hello[i]; i++; } return 0; } </code></pre> <p>What this program should do is convert each letter to hexadecimal - char by char. </p> |
11,360,945 | 0 | <p>There are a number of ways to archive this. One easy way is to submit all data to the server, where the whole form gets rebuild. Doing this on javascript-side could be done with templating (I assume you use jquery).</p> <p>The serverside-solution (as the final submitting) requires, that your input-names are formed wisly.</p> <p>Example:</p> <pre><code>data[members][{$memberId}][name] </code></pre> <p>If you want to determine, if the form was submitted in its final form, or just to add a member, you can form the submit-buttons like this:</p> <pre><code><input type="submit" name="btn[submit]" value="submit booking" /> <input type="submit" name="btn[add]" value="submit booking" /> </code></pre> <p>On php-side this could be determined by:</p> <pre><code>$btnType = isset($_REQUEST['btn']) && is_array($_REQUEST['btn']) ? array_shift(array_keys($_REQUEST['btn'])) : 'submit'; </code></pre> <p>There are still improvements to apply!</p> |
31,565,847 | 0 | Multiplying one matrix with a set of scalars <p>I have an R script that systematically perform changes to a 3x3 matrix by scalar multiplication as follows</p> <pre><code>R <- matrix(rexp(9, rate=.1), ncol=3); for (i in 1:360) { K = i*R; ... } </code></pre> <p>and use the modified matrix for further calculations within the loop. However, the loop itself is nested inside two other for loops, making the script very slow. So my question is, how can I vectorize this innermost loop such that the result instead is a three-dimensional array A of size 3x3x360 where</p> <pre><code>A[,,i] = i*R; </code></pre> <p>for all i ranging from 1 to 360?</p> |
25,223,049 | 0 | Hibernate: Refrain update on Many-to-Many insert <h2>Problem</h2> <p>I use hibernate to store data in an MySQL database. I now want to store a Company and one of its Branches.</p> <p>The company:</p> <pre><code>@Entity @Table(name="company") public class Company { @Id @GeneratedValue @Column(name="id") private int id; @Column(name="name") private String name; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name="company_branch_join", joinColumns={@JoinColumn(name="company_id")}, inverseJoinColumns={@JoinColumn(name="branch_id")}) private Set<CompanyBranch> branches; // Getters and setters... } </code></pre> <p>And the branch:</p> <pre><code>@Entity @Table(name="company_branch") public class CompanyBranch { @Id @GeneratedValue @Column(name="id") private int id; @Column(name="branch") private String branch; @ManyToMany(mappedBy="branches", cascade = CascadeType.ALL) private Set<Company> companies; // Getters and setters... } </code></pre> <h2>Question</h2> <p>The code works and i can insert the data in the join table. The problem is the override policy regarding the branches. My branch table in the database is already filled with branches and its IDs so i don't want to modify the data. However on an company-insert the branches associated with the company get stored again and override the data with the same ID in the database. How can I prevent this behavior?</p> <pre><code>CompanyBranch cb1 = new CompanyBranch(); cb1.setId(1); cb1.setBranch("Manufacturing"); CompanyBranch cb2 = new CompanyBranch(); cb2.setId(2); cb2.setBranch("DONT-INSERT"); Company c = new Company(); c.setName("[Random-Company-Name]"); c.addBranch(cb1); c.addBranch(cb2); CompanyManager cm = new CompanyManagerImpl(); cm.saveCompany(c); </code></pre> <p>The branch table before execution looks like this:</p> <pre><code>| id | branch | +----+----------------+ | 1 | Manufacturing | | 2 | IT | |... | ... | </code></pre> <p>The table should not change. But after execution it looks like this:</p> <pre><code>| id | branch | +----+----------------+ | 1 | Manufacturing | | 2 | DONT-INSERT | |... | ... | </code></pre> |
35,581,815 | 0 | Select rows from data frame which have at least three negative values? <p>How to filter rows which have atleast 3 negative values?</p> <pre><code>df1 <- Name flex flex2 flex3 flex4 Set1 -1.19045139 -1.25005615 -1.053900875 -1.15142391 Set2 -2.22129212 1.54901305 0.003462145 1.06170243 Set3 -2.08952248 -1.95241584 -1.206060696 -1.65450460 Set4 -1.20091116 0.50700470 -0.098793884 1.50406054 Set5 -1.11771409 0.01175919 -3.056481406 -1.09328262 Set7 -9.01648659 0.07707638 0.198978232 1.18125182 </code></pre> <p>expected output</p> <pre><code>df2 <- Name flex flex2 flex3 flex4 Set1 -1.19045139 -1.25005615 -1.053900875 -1.15142391 Set3 -2.08952248 -1.95241584 -1.206060696 -1.65450460 Set5 -1.11771409 0.01175919 -3.056481406 -1.09328262 </code></pre> <p>i tried the code given below, but it doesn't work</p> <pre><code>Index= as.vector(which(apply(df1,1,function(x){sum(x < -1)/length(x)})>=0.75)) df1[Index,] </code></pre> |
23,523,665 | 1 | Twisted: How to properly check that a request is finished <p>I'm creating an extremely simple Python script to serve one file to one person. However, I cannot seem to figure out how to fire a callback when the request is finished or broken. I was looking into <a href="https://twistedmatrix.com/documents/13.0.0/web/howto/web-in-60/interrupted.html" rel="nofollow">using deferreds</a> but I'm having a hard time wrapping my head around how they work.</p> <p>As far as I can tell my server runs everything synchronously, so I would expect this to be enough:</p> <pre><code>class FileResource(resource.Resource): isLeaf = True def __init__(self, filepath): self.filepath = filepath self.filename = os.path.basename(filepath) def render_GET(self, request): print '%s: request opened (%s)' % (get_time(), request.getClientIP()) request.setHeader('content-type', 'application/octet-stream') request.setHeader('content-disposition', 'attachment; filename="%s"' % self.filename) request.setHeader('content-length', os.path.getsize(self.filepath)) with open(self.filepath, 'rb') as f: request.write(f.read()) request.finish() print '%s: request closed (%s)' % (get_time(), request.getClientIP()) return server.NOT_DONE_YET </code></pre> <p>But the second print fires immediately. If anyone could point me in the right direct that would be appreciated.</p> |
40,849,009 | 0 | Not serializable class with strings only <p>I have a class called Libro which contains strings only:</p> <pre><code>public class Libro { private String titolo; private String autore; private String editore; private String sottotitolo; private String genere; private String dpubb; private String lpubb; private String soggetto; private String isbn; private String note; private String prezzo; private String npag; //getters, setters, constructors... } </code></pre> <p>Then I created an object called <code>a</code> belonging to the <code>Libro</code> class, and I tried to write it to a <code>coso.dat</code> file</p> <pre><code>try{ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("C:\\Users\\Workbench\\Documents\\NetBeansProjects\\coso.dat")); out.writeObject(a); out.close(); }catch(Exception e) {System.out.println("Damn");} </code></pre> <p>Then I opened the file with NotePad and it seems that I tried to serialize an unserializable class: </p> <pre><code>¬í {sr java.io.NotSerializableException(Vx ç†5 xr java.io.ObjectStreamExceptiondÃäk9ûß xr java.io.IOExceptionl€sde%ð« xr java.lang.ExceptionÐý>;Ä xr java.lang.ThrowableÕÆ5'9w¸Ë L causet Ljava/lang/Throwable;L detailMessaget Ljava/lang/String;[ stackTracet [Ljava/lang/StackTraceElement;L suppressedExceptionst Ljava/util/List;xpq ~ t ginobook.classi.Librour [Ljava.lang.StackTraceElement;F*<<ý"9 xp )sr java.lang.StackTraceElementa Åš&6Ý… I lineNumberL declaringClassq ~ L fileNameq ~ L methodNameq ~ xp t java.io.ObjectOutputStreamt ObjectOutputStream.javat writeObject0sq ~ \q ~ q ~ t writeObjectsq ~ ôt ginobook.forms.FormNuovot FormNuovo.javat btnCreaActionPerformedsq ~ q ~ q ~ t access$1500sq ~ Œt ginobook.forms.FormNuovo$15q ~ t actionPerformedsq ~ æt javax.swing.AbstractButtont AbstractButton.javat fireActionPerformedsq ~ ,t "javax.swing.AbstractButton$Handlerq ~ q ~ sq ~ ’t javax.swing.DefaultButtonModelt DefaultButtonModel.javaq ~ sq ~ q ~ $q ~ %t setPressedsq ~ üt *javax.swing.plaf.basic.BasicButtonListenert BasicButtonListener.javat mouseReleasedsq ~ …t java.awt.Componentt Component.javat processMouseEventsq ~ üt javax.swing.JComponentt JComponent.javaq ~ /sq ~ šq ~ -q ~ .t processEventsq ~ ¼t java.awt.Containert Container.javaq ~ 4sq ~ q ~ -q ~ .t dispatchEventImplsq ~ öq ~ 6q ~ 7q ~ 9sq ~ gq ~ -q ~ .t dispatchEventsq ~ t java.awt.LightweightDispatcherq ~ 7t retargetMouseEventsq ~ q ~ >q ~ 7q ~ /sq ~ rq ~ >q ~ 7q ~ <sq ~ èq ~ 6q ~ 7q ~ 9sq ~ ºt java.awt.Windowt Window.javaq ~ 9sq ~ gq ~ -q ~ .q ~ <sq ~ öt java.awt.EventQueuet EventQueue.javaq ~ 9sq ~ aq ~ Hq ~ It access$500sq ~ Åt java.awt.EventQueue$3q ~ It runsq ~ ¿q ~ Mq ~ Iq ~ Nsq ~ ÿÿÿþt java.security.AccessControllert AccessController.javat doPrivilegedsq ~ Lt 5java.security.ProtectionDomain$JavaSecurityAccessImplt ProtectionDomain.javat doIntersectionPrivilegesq ~ Vq ~ Uq ~ Vq ~ Wsq ~ Ût java.awt.EventQueue$4q ~ Iq ~ Nsq ~ Ùq ~ Zq ~ Iq ~ Nsq ~ ÿÿÿþq ~ Qq ~ Rq ~ Ssq ~ Lq ~ Uq ~ Vq ~ Wsq ~ Øq ~ Hq ~ Iq ~ <sq ~ Ét java.awt.EventDispatchThreadt EventDispatchThread.javat pumpOneEventForFilterssq ~ tq ~ `q ~ at pumpEventsForFiltersq ~ iq ~ `q ~ at pumpEventsForHierarchysq ~ eq ~ `q ~ at pumpEventssq ~ ]q ~ `q ~ aq ~ hsq ~ Rq ~ `q ~ aq ~ Nsr &java.util.Collections$UnmodifiableListü%1µìŽ L listq ~ xr ,java.util.Collections$UnmodifiableCollectionB €Ë^÷ L ct Ljava/util/Collection;xpsr java.util.ArrayListxÒ™Ça I sizexp w xq ~ px </code></pre> <p>What did I do wrong..? I'm sorry if the question may seem stupid, but I just couldn't find any answer to it</p> |
25,083,700 | 0 | JQuery DatePicker conflict in Joomla 3 website <p>Sorry, I'm not a programmer and really can't find how to handle this...</p> <p>On a Joomla 3.3.0 website (<a href="http://lantanaweb.com/savoy-sofia/sofia/" rel="nofollow">http://lantanaweb.com/savoy-sofia/sofia/</a>) I added a custom HTML code module (it means adding JS and scripts to Joomla modules) to show a datepicker in a booking form. But the date picker do not show up as it should.</p> <p>Moreover, after adding this module, the full page JQuery slideshow module stopped working.</p> <p>Then I installed the JQuery Easy Plugin to solve JQuery related conflicts, and the slideshow was actually fixed.</p> <p>But I can't still make the datepicker show as it is supposed to do. My joomla custom HTML module code is:</p> <pre><code><script type="text/javascript" src="js/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script> <link type="text/css" href="css/overcast/jquery-ui-1.8.16.custom.css" rel="stylesheet" /> <form action="https://reservations.verticalbooking.com/reservation_hotel.htm" method="post" name="myform" id="myform" target="_blank" style="margin:0px; padding:0px;" onsubmit="invia_form();_gaq.push(['_linkByPost', this]);" > <!-- ###################### --> <!-- PARAMETERS TO CUSTOMIZE --> <input name="gg" id="gg" value="" type="hidden"> <input name="mm" id="mm" value="" type="hidden"> <input name="aa" id="aa" value="" type="hidden"> <input name="id_albergo" value="312" type="hidden"> <input name="lingua_int" value="ita" type="hidden"> <input name="dc" value="710" type="hidden"> <input name="id_stile" value="9456" type="hidden"> <input name="headvar" value="ok" type="hidden"> <input name="graph_be" value="4" type="hidden"> <div id="arrival_date" class="blocco"> <div class="label">Data di Arrivo</div> <div class="tendina"> <input id="datepicker" type="text" value="" > </div> </div> <div id="nights" class="blocco"> <div class="label">Notti</div> <div class="tendina"> <select class="select" name="notti_1" > <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> </select> </div> </div> <div id="rooms" class="blocco"> <div class="label">Camere</div> <div class="tendina"> <select class="select" name="tot_camere"> <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </div> </div> <div id="adults" class="blocco"> <div class="label">Adulti</div> <div class="tendina"> <select class="select" name="tot_adulti"> <option value="1">1</option> <option value="2" selected="selected">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </div> </div> <div id="children" class="blocco"> <div class="label">Bambini</div> <div class="tendina"> <select class="select" name="tot_bambini" > <option value="0" selected >0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </div> </div> <div id="search" class="blocco"> <input id="button" type="submit" value="cerca" /> </input> </div> <div id="cancella"><a href="https://reservations.verticalbooking.com/reservation_hotel.htm?id_albergo=312&dc=710&lingua_int=ita&headvar=ok&id_stile=9456&graph_be=4&cancel=pren">Annulla/Modifica Prenotazione</a></div> </form> <script type="text/javascript"> $(document).ready( function() { var now = new Date(); var today = now.getDate() + '/' + (now.getMonth() + 1) + '/' + now.getFullYear(); $('#datepicker').val(today); }); </script> <script type="text/javascript"> $(function() { $( "#datepicker" ).datepicker({ minDate: "0", showOtherMonths: true, selectOtherMonths: true, altField: "#gg", altFormat: "dd" }); }); function invia_form() { var data = $( "#datepicker" ).attr('value'); //alert(data); data = data.split('/'); $('#gg').attr({value:data[0]}); $('#mm').attr({value:data[1]}); $('#aa').attr({value:data[2]}); //alert($('#gg').attr('value')+' - '+$('#mm').attr('value')+' - '+$('#aa').attr('value')); //$('#myform').submit(); } </script> </code></pre> <p>Although I read a few posts related on the forum, I really don't know where to start from... Any help would be highly appreciated... Thanks!</p> <p>Edit 1: The error is: </p> <pre><code>$(...).datepicker is not a function related code (line 435) is: $( "#datepicker" ).datepicker({ minDate: "0", showOtherMonths: true, selectOtherMonths: true, altField: "#gg", altFormat: "dd" }); </code></pre> |
10,372,132 | 0 | <p>You've said: <code>MainScreen2 *testJudith;</code> which sets testJudith to nil.</p> <p>You then created an array:</p> <pre><code>NSMutableArray *testJudithArray = [[NSMutableArray alloc]init]; </code></pre> <p>You then RESET testJudithArray to a mutable copy of testJudith's Judith array:</p> <pre><code>testJudithArray = [testJudith.Judith mutableCopy]; </code></pre> <p>But testJudith is nil. You haven't set it as anything. Which means the property of nil will always be/return nil. You then try to make a mutableCopy of nil. Thus, testJudithArray becomes nil.</p> <p>You have not created a testJudith to begin with, so you then never create the array you are asking to make a mutable copy of. The mutableCopy method thus returns nil (as any message sent to nil returns nil).</p> <p>Does this explain enough where your error is?</p> |
15,909,718 | 0 | <pre><code>String a = x[0]; String b = x[1]; </code></pre> <p>or</p> <pre><code>for (String z : x) { String valor = z; } </code></pre> <p>I wait help you!</p> |
21,189,182 | 0 | <p>you can use fprintf, which prints formatted text:</p> <pre><code>frintf("%x %x %d\n",_member[0],_member[0],_records); </code></pre> <p>Hope this helps</p> |
1,136,062 | 0 | <p>The <code>Aggregate</code> function would come in handy here.</p> <pre><code>var sum = list.Aggregate((acc, cur) => acc + cur); var average = list.Aggregate((acc, cur) => acc + cur) / list.Count; </code></pre> <p>Just insure that you have the <code>/</code> operator defined for types <code>PointD</code> and <code>int</code>, and this should do the job.</p> <p>Note: I'm not quite sure whether you want the sum or average here (your question is somewhat ambiguous about this), but I've included examples for both.</p> |
17,917,761 | 0 | <p>Set the field not only to <code>hidden</code> as also to <code>disabled</code>, that will solve this. Or as mentioned in the comment if you just use a custom validation return true.</p> |
7,009,621 | 0 | <p>If you remove</p> <pre><code>length="3" </code></pre> <p>it should be trowing an exception</p> |
4,281,650 | 0 | Ajax request saving files with Rails <p>I'm fairly new to ruby on rails and I'm trying to implment a drag and drop file feature with dnduploader.js. I'm getting the file to post to the controller, but I'm unsure how to save the file in the controller to the local file system. Here is snippets of my code if anyone can help. Thank you.</p> <p>Here is the link I'm using to help me: <a href="http://onehub.com/blog/posts/designing-an-html5-drag-drop-file-uploader-using-sinatra-and-jquery-part-1/" rel="nofollow">http://onehub.com/blog/posts/designing-an-html5-drag-drop-file-uploader-using-sinatra-and-jquery-part-1/</a></p> <pre><code>$("#drop_target").dndUploader({ url : "/upload", method : "PUT" }); if (dataTransfer.files.length > 0) { $.each(dataTransfer.files, function ( i, file ) { var xhr = new XMLHttpRequest(); var upload = xhr.upload; xhr.open($this.data('method') || 'POST', $this.data('url'), true); xhr.setRequestHeader('X-Filename', file.fileName); xhr.send(file); }); }; </code></pre> <p>This is where I don't know what to do? I see the upload request happening inside chrome, but I'm unsure how to get the file saved to the filesystem. </p> <pre><code>def upload render :text => "uploaded #{env['HTTP_X_FILENAME']} - #{request.body.read.size} bytes -- #{params[:upload].to_yaml}" end </code></pre> |
5,563,858 | 0 | <p>I always liked evdns</p> <p><a href="http://linux.die.net/man/3/evdns" rel="nofollow">http://linux.die.net/man/3/evdns</a></p> <p>There appears to be a python binding called pyevent</p> <p><a href="http://code.google.com/p/pyevent/source/browse/trunk/evdns.pxi?r=44" rel="nofollow">http://code.google.com/p/pyevent/source/browse/trunk/evdns.pxi?r=44</a></p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.