pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
18,122,185 | 0 | Capistrano: How to disable "try_sudo" from a task <p>I'm currently using capistrano for deploy scripts. I'm working in a constrained environment where sudo does not have certain permissions, namely to create symlinks. The capistrano task create_symlink calls try_sudo by default. Is there a way I can add a condition to the task so that try_sudo is ignored?</p> |
5,416,030 | 0 | How can I get return value when using awk in perl script? <p>I am trying submit to $process the result of this <strong>system call</strong> </p> <pre><code>my $process= system "adb shell ps | egrep adb | awk '{print $1}' "; </code></pre> <p>but when <code>print " $process \n";</code> I have got zero</p> <p>Any suggestions</p> |
20,648,266 | 0 | <p>Your "less than" symbol in your for loop is backwards. As such, your loop is exiting without running the code inside.</p> |
3,031,818 | 0 | <p>You'll have to do quite a bit of drawing by yourself. This MSDN section deals with <a href="http://msdn.microsoft.com/en-us/library/kxys6ytf%28v=VS.100%29.aspx" rel="nofollow noreferrer">Custom Control Painting and Rendering</a> and the documentation for <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.region.aspx" rel="nofollow noreferrer">Control.Region</a> has a sample for making round buttons that you might be able to adapt.</p> <p>I'd suggest having a look at the <a href="http://www.codeproject.com/" rel="nofollow noreferrer">codeproject</a> site as well, a lot of people have written articles there about customizing various controls</p> |
33,543,346 | 0 | Can I simplify WebRTC signalling for computers on the same private network? <p>WebRTC signalling is driving me crazy. My use-case is quite simple: a bidirectional audio intercom between a kiosk and to a control room webapp. Both computers are on the same network. Neither has internet access, all machines have known static IPs.</p> <p>Everything I read wants me to use STUN/TURN/ICE servers. The acronyms for this is endless, contributing to my migraine but if this were a standard application, I'd just open a port, tell the other client about it (I can do this via the webapp if I need to) and have the other connect.</p> <p>Can I do this with WebRTC? Without running a dozen signalling servers?</p> <p>For the sake of examples, how would you connect a browser running on 192.168.0.101 to one running on 192.168.0.102?</p> |
39,453,787 | 0 | SQL Server 2008 R2: trigger after update <p>This is my first post so please bear with me. Here are the tables I'm working with and I'm only showing the relevant columns:</p> <p><strong>Movement</strong>:</p> <pre><code> id cnt_tare_weight chassis_tare_weight </code></pre> <p><strong>Stop</strong>:</p> <pre><code> movement_id order_id </code></pre> <p>For each movement record, there are 2 or more stop records. The way this works, is that we create an order and create the stops. The stops are grouped into movements. </p> <p>Here's some example data:</p> <p><strong>Movement</strong>:</p> <pre><code>id cnt_tare_weight chassis_tare_weight ------------------------------------------------- 1545257 4525.2 3652.2 1545258 null null </code></pre> <p><strong>Stop</strong>:</p> <pre><code>order_id movement_id ------------------------ 0933774 1545257 0933774 1545257 0933774 1545258 0933774 1545258 </code></pre> <p>Here's what I am trying to accomplish:</p> <p>When the <code>cnt_tare_weight</code> and/or <code>chassis_tare_weight</code> are updated in the <code>movement</code> record, I need to copy this data to all other movement records for that order. I want to use a trigger after update to do this. </p> <p>Here is what I've come up with but and I'm not sure it will work. I would like to see if what I'm wanting do is correct or if I'm missing something. </p> <p>Here's my SQL:</p> <pre><code>CREATE TRIGGER set_tare_weights ON movement AFTER UPDATE AS BEGIN SET NOCOUNT ON; DECLARE @movement_id AS INT; DECLARE @cnt_tare_weight AS DECIMAL(8,1); DECLARE @chz_tare_weight AS DECIMAL(8,1); DECLARE @order_id AS int; SELECT @movement_id = inserted.id FROM INSERTED IF update(cnt_tare_weight) BEGIN SET @cnt_tare_weight = 'Updated cnt_tare_weight' END IF update(chz_tare_weight) BEGIN SET @chz_tare_weight = 'Updated chz_tare_weight' END SELECT @order_id = order_id FROM stop WHERE movement_id = @movement_id UPDATE movement SET cnt_tare_weight = @cnt_tare_weight, chz_tare_weight = @chz_tare_weight WHERE @movement_id IN (SELECT DISTINCT movement_id FROM stop WHERE order_id = @order_id) AND id <> @movement_id END </code></pre> <p>I have never created a SQL Server trigger before. I'm not sure if this will work or if I need to do something more. Do I need to create a trigger that calls a stored procedure? Or will the above work? </p> <p>Thanks for any help!</p> |
15,646,109 | 0 | Running gearman on a Heroku Worker <p>I have a PHP app running on heroku (cedar stack). I'm at the point where I need to start passing jobs off to workers. </p> <p>I've looked a both RabbitMQ and gearman. It seems like the best / simplest solution for my app would to use gearman. </p> <p>So I'm guessing the gearman server would run on the main webapp dyno and then the gearman workerapi would run on separate heroku workers, along with the php code that should do the work. </p> <p>How can I go about doing this with Heroku? </p> <p>Thanks</p> |
18,035,156 | 0 | Use transient keyword in not Serializable class <p>Would it make sense to use the <code>transient</code> keyword in a class that does not implement <code>Serializable</code>? </p> <p>Because classes that do not implement <code>Serializable</code> could still be serialized by the <code>ObjectOutputStream</code>.</p> |
8,175,367 | 0 | iphone UIview animation resize in like disappear in water and comes back floating <p>I don't want to fade in and fade out like most common solution for the uiview animation. I would like to have the uiview resize to small until it disappear and comes back the same way. Another way to say it is having a camera pointing closely at the table with all the object in it (UIView) and camera backs up and the more it backs up the smaller the table gets. Which is why i titled which is mainly my app the whole uiview sinks into the water and floats back up. Hopefully i'll find a tutorial or someone's suggestion for the solution. everything resize/shrinks in the middle/center of the screen.</p> <p>UPDATE*** i would like it to shrink in random position of the screen and appear from random position of the screen also. Also my subview from other class is viewdidload in mainView (View = [[View alloc] initWithFrame:CGRectMake(0, 40, 300, 300)];)</p> |
15,071,133 | 0 | <p>As far as I know the content isn't loaded when the div's display style is set to none.</p> <p>Try setting something like this</p> <pre><code><div style="width: 1px; height: 1px; position: absolute; top: -9999px; left: -9999px;"> <div id="player"></div> </div> </code></pre> |
4,076,169 | 0 | How remove "installed twice" errors in RCP Product <p>I have an RCP product based on 2 features: my product feature and the org.eclipse.rcp feature. It worked perfectly at export time and at run time.</p> <p>Last week I decided to add the error log view to my product. I simply added the view to my "persective" and the logview plugin as plugin dependency in my main plugin. Just work fine !!!</p> <p>After exporting my product (through headless build) I noticed that when launching my product I have a lot of errors in the error log view (not acceptable for customers even if all is working fine). These errors are related to the RCP feature plugins and say:</p> <p>the plugin org.eclipse.xxx (one error for each plugin of the RCP feature) has already been installed from /plugins/org.eclipse.xxx </p> <p>Any idea on the way to avoid these errors ? I guess this means I have something wrong in my product configuration.</p> |
33,088,122 | 0 | <p>my suggestion is: just keep codding the way it is, until a problem rises or an extremely need for the change appears.</p> |
21,736,951 | 0 | Saving a CSV into a blob <p>I would like to save CSV files that users upload to a blob. I would than like to retrieve the CSV file out of the blob in a format that I can use with the ruby CSV library. Any ideas on how I can accomplish that? </p> |
32,955,638 | 0 | How to rewrite this on jQuery <p>I have ul with 5 li inside, need to select one of them with index [curSlide-1], I writed it on JS, but can't do that on jQuery:</p> <pre><code>var $bullets = $("ul").find(".bullet"); var curSlide = 5; document.getElementsByClassName("bullet")[curSlide-1].className = "bullet active-bullet"; </code></pre> <p>I've tried to write it on jQuery, but it doesn't work:</p> <pre><code>$bullets[curSlide-1].addClass("active-bullet"); </code></pre> <p>Can somebody tell how to rewrite it correctly?</p> |
18,277,818 | 0 | Is it possible to change the min-height of Google+ comment on Blogger? <p>I just created a new <strong>Blogger blog</strong> and successfully incorporated the <strong>Google+ comment</strong> using the Blogger built-in feature. But I noticed that a <code>div id="widget_bounds"</code> is consuming too much of empty spaces with the <code>min-height=600px</code> CSS property. I suspect that the code was generated on the fly and I couldn't find the <code>div</code> in my Blogger template code. I wonder if it is possible to change its <code>min-height</code> to something like <code>250px</code> and let it auto-expands as the comment grows?</p> <p>You can refer my website with this URL: <a href="http://blog.malaysiatraining.net/2013/08/official-blog-announcement.html" rel="nofollow">http://blog.malaysiatraining.net/2013/08/official-blog-announcement.html</a></p> <p>Any advice would be appreciated. Thank you.</p> |
1,937,038 | 0 | Set mouse cursor as hand on textInput without losing text selection <p>I want to have the mouse cursor to be changed to hand when used for <em>entering</em> the <code><mx:textInput></code>. When the field is already on focus, text selection should be available.</p> <p>I tried any combination of <code>useHandCursor="true"</code>, <code>buttonMode="true"</code> and <code>mouseChildren="false"</code>, and the closest result is when using all three of them. Then the hand cursor does appear, but the text field loses its selection 'abilities' (text cannot be selected using the mouse). This is logical, since <code>mouseChildren="false"</code> disables this. But how do I acheive the desired result?</p> <p>P.S. using Flex 3.1.</p> |
11,333,623 | 0 | Rails app using stripe for payments: can't transmit plan_id from app to stripe website <p>I'm trying to integrate stripe into my app. I'm following a Railscast (#288) but I'm getting the impression there a are few things that Ryan isn't mentioning explicitly.</p> <p>My problem is that the plan_id on my app doesn't get transmitted over to Stripe. Once I generate a test transaction in my app and I log on to Stripe, it will show that a new customer with a valid card was created, but the plan_id isn't transmitted. I do have plans setup on stripe. But since no plan_id is submitted, the credit card never gets charged. So I've got customers, but no payments.</p> <p>Here's my subscription/new.html.haml. I'm wondering if I need to assign a value to the hidden field "plan_id."</p> <pre><code>%p = @plan.name = @plan.price = form_for @subscription do |f| - if @subscription.errors.any? .error_messages %h2 = pluralize(@subscription.errors.count, "error") prohibited this subscription from being saved: %ul - @subscription.errors.full_messages.each do |msg| %li= msg = f.hidden_field :plan_id = f.hidden_field :stripe_card_token .field = f.label :email = f.text_field :email - if @subscription.stripe_card_token Credit card has been provided - else .field = label_tag :card_number, "Credit Card Number " = text_field_tag :card_number, nil, name: nil .field = label_tag :card_code, "Security Code on Card (CVV)" = text_field_tag :card_code, nil, name: nil .field = label_tag :card_month, "Card Expiration" = select_month nil, {add_month_numbers_true: true}, {name: nil, id: "card_month"} = select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year"} .stripe_error %noscript JavaScript is not enabled and is required for this form. First enable it in your web browser settings. .actions= f.submit "Subscribe" </code></pre> <p>Here's my subscription controller. The params(:plan_id) is passed using a string query.</p> <pre><code> def new @subscription = Subscription.new @plan = Plan.find_by_id(params[:plan_id]) end def create @subscription = Subscription.new(params[:subscription]) if @subscription.save_with_payment flash[:success] = "Thank you for subscribing!" redirect_to @subscription else render 'new' end end </code></pre> <p>Here's my model for subscription.rb</p> <pre><code>class Subscription < ActiveRecord::Base has_many :users belongs_to :plan #validates_presence_of :plan_id, :email attr_accessible :stripe_card_token, :plan_id, :email attr_accessor :stripe_card_token def save_with_payment if valid? customer = Stripe::Customer.create(description:email, plan: plan_id, card: stripe_card_token) self.stripe_customer_token = customer.id save! end rescue Stripe::InvalidRequestError => e logger.error "Stripe error while creating customer: #{e.message}" errors.add :base, "There was a problem with your credit card." end end </code></pre> |
24,914,838 | 0 | <p>Test this version, updated using C++11 features. Tested in GCC 4.9.0 with <code>-std=c++11</code>. Tested on Celeron 1.6 GHz, 512 MB RAM.</p> <p>Times in my PC:<br> Original: <strong>Duration (milliseconds): 12658</strong><br> First Version: <strong>Duration (milliseconds): 3616</strong><br> Optimized Version: <strong>Duration (milliseconds): 1745</strong><br></p> <p>Changes are:</p> <ul> <li>Using <code>vector</code> instead of <code>list</code> <a href="http://blog.davidecoppola.com/2014/05/20/cpp-benchmarks-vector-vs-list-vs-deque/">Benchmark</a>, and <a href="https://isocpp.org/blog/2014/06/stroustrup-lists">Words from Stroustrup</a>.</li> <li>Using const whatever we can, the compiler is able to optimize much more if it known that the value don't change.</li> <li>Using std::pair instead of Point.</li> <li>Using new for-loop with constant iterators.</li> </ul> <p>Source:</p> <pre><code>#include <iostream> #include <vector> #include <chrono> #include <iomanip> using namespace std; typedef std::pair<int, int> Point; #define LARGEUR_GRILLE 22 vector<Point> positions; bool verifierNonPrise(const Point& emplacement) { bool nonPrise = true; for (const auto& p : positions) { if (p.first != emplacement.first) { if (p.second == emplacement.second) { nonPrise = false; } if (abs(p.second - emplacement.second) == abs(p.first - emplacement.first)) { nonPrise = false; } } } return nonPrise; } bool placerDame(int i) { bool bonnePosition = false; for (int j = 1; j <= LARGEUR_GRILLE && !bonnePosition; j++) { Point emplacement(i, j); positions.emplace_back(emplacement); if (verifierNonPrise(emplacement) && (i == LARGEUR_GRILLE || placerDame(i + 1))) { bonnePosition = true; } else { positions.pop_back(); } } return bonnePosition; } int main(int argc, char* argv[]) { std::chrono::system_clock::time_point begin_time = std::chrono::system_clock::now(); positions.reserve(LARGEUR_GRILLE); placerDame(1); for (const auto& p : positions) { cout << "(" << p.first << "; " << p.second << ")" << endl; } std::chrono::system_clock::time_point end_time = std::chrono::system_clock::now(); long long elapsed_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>( end_time - begin_time).count(); std::cout << "Duration (milliseconds): " << elapsed_milliseconds << std::endl; return 0; } </code></pre> <p>Some more deep changes.</p> <p>Changes include:</p> <ul> <li>Returning as early as possible. As soon as the queen can not be placed.</li> <li>Returning to a simpler Point class.</li> <li>Using find_if algorithm for searching queen placement.</li> </ul> <p>Source (some recommendation updated):</p> <pre><code>#include <algorithm> #include <iostream> #include <vector> #include <chrono> #include <iomanip> using namespace std; struct Point { int x, y; }; #define LARGEUR_GRILLE 22 vector<Point> positions; bool verifierNonPrise(const Point& emplacement) { return find_if(positions.cbegin(), positions.cend(), [&emplacement](const Point& p) { return (p.x != emplacement.x && (p.y == emplacement.y || abs(p.y - emplacement.y) == abs(p.x - emplacement.x))); }) == positions.cend(); } bool placerDame(int i) { for (int j = 1; j <= LARGEUR_GRILLE; j++) { Point emplacement{i, j}; positions.push_back(emplacement); if (verifierNonPrise(emplacement) && (i == LARGEUR_GRILLE || placerDame(i + 1))) { return true; } else { positions.pop_back(); } } return false; } int main(int argc, char* argv[]) { std::chrono::system_clock::time_point begin_time = std::chrono::system_clock::now(); positions.reserve(LARGEUR_GRILLE); placerDame(1); for (const auto& p : positions) { cout << "(" << p.x << "; " << p.y << ")" << endl; } std::chrono::system_clock::time_point end_time = std::chrono::system_clock::now(); long long elapsed_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>( end_time - begin_time).count(); std::cout << "Duration (milliseconds): " << elapsed_milliseconds << std::endl; return 0; } </code></pre> |
3,228,075 | 0 | HashSet of Strings taking up too much memory, suggestions...? <p>I am currently storing a list of words (around 120,000) in a HashSet, for the purpose of using as a list to check enetered words against to see if they are spelt correctly, and just returning yes or no.</p> <p>I was wondering if there is a way to do this which takes up less memory. Currently 120,000 words is around 12meg, the actual file the words are read from is around 900kb.</p> <p>Any suggestions?</p> <p>Thanks in advance</p> |
2,988,920 | 0 | Getting list of states/events from a model that AASM <p>I successfully integrated the most recent AASM gem into an application, using it for the creation of a wizard. In my case I have a model order</p> <pre><code>class Order < ActiveRecord::Base belongs_to :user has_one :billing_plan, :dependent => :destroy named_scope :with_user, ..... <snip> include AASM aasm_column :aasm_state aasm_initial_state :unauthenticated_user aasm_state :unauthenticated_user, :after_exit => [:set_state_completed] aasm_state : <snip> <and following the event definitions> end </code></pre> <p>Now I would like to give an administrator the possibility to create his own graphs through the AASM states. Therefore I created two additional models called OrderFlow and Transition where there order_flow has many transitions and order belongs_to order_flow. </p> <p>No problem so far. Now I would like to give my admin the possibility to dynamically add existing transitions / events to an order_flow graph. </p> <p>The problem now is, that I do not find any possibility to get a list of all events / transitions out of my order model. aasm_states_for_select seems to be the correct candidate, but I cannot call it on my order model. </p> <p>Can anyone help?</p> <p>Thx in advance. J. </p> |
5,522,604 | 0 | Are there any tutorials on coding a parser for SVG files to be used by box2D? <p>I am trying to create an iPhone game with fairly large levels. Hard coding the platforms and physics objects is very time consuming. I have seen some people have made their own parsers for svg files to use in box2D, and Riq is selling levelSVG but it is a little pricey for me at the moment, and I only need basic features. Is there a tutorial on how to code a parser available online?</p> |
18,210,830 | 0 | <p>You have to print the <code>$value</code> bacause <code>$value</code> have original array value not index. And you are getting array in <code>$stdlist</code> from exploding this post variable <code>$_POST['stdlist']</code>.</p> <pre><code>foreach($stdlist as $value) { echo "<br>"; echo $value; } </code></pre> <p>Now you will get your required result.</p> |
39,772,900 | 0 | <p>I figured out my problem, I set margin to my <code>AppCompatSpinner</code> and set top gravity to it with specific hight.</p> <pre><code><LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="bottom" android:orientation="horizontal"> <android.support.v7.widget.AppCompatSpinner android:id="@+id/spinner_countries" style="@style/Widget.AppCompat.Spinner.Underlined" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginBottom="26dp" android:layout_weight="30" android:spinnerMode="dialog" /> <android.support.design.widget.TextInputLayout android:id="@+id/input_layout_mobile" style="@style/TextInputLayoutTheme" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="70" app:errorEnabled="true"> <com.cashu.app.ui.widgets.CustomEditText android:id="@+id/et_mobile" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start" android:ems="12" android:gravity="center_vertical" android:hint="@string/mobile_hint" android:inputType="number" android:textSize="@dimen/font_size_normal" /> </android.support.design.widget.TextInputLayout> </LinearLayout> </code></pre> <p><strong>[EDIT]</strong></p> <p>When my <code>TextInputLayout</code> has an error, I remove it by adding the following lines:</p> <pre><code>myTextInputLayout.setErrorEnabled(false); myTextInputLayout.setErrorEnabled(true); myTextInputLayout.setError(" "); </code></pre> <p>Why?</p> <ul> <li><p>This line: <code>myTextInputLayout.setErrorEnabled(false);</code> will clear the error from the <code>TextInputLayout</code></p></li> <li><p>This line: <code>myTextInputLayout.setErrorEnabled(true);</code> will enable error for the <code>TextInputLayout</code> again</p></li> <li><p>This line: <code>myTextInputLayout.setError(" ");</code> will prevent layout alignment disruption.</p></li> </ul> <p>Problem now is solved.</p> |
19,799,914 | 0 | <p>I was able to solve this by setting the id of the layout that is inflated within each fragment to its position.</p> <p>What you would have to do is simply change the method onCreateView in you ContainerFragment class to:</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_container, container, false); v.setId(CONTAINER_TYPE) return v; </code></pre> <p>This works because of the way the FragmentPagerAdapter implementation handles fragment tags.</p> |
1,117,281 | 0 | <p>Give a look to the <a href="https://developer.mozilla.org/En/Window.setInterval" rel="nofollow noreferrer">setInterval</a> core function and to the jQuery's <a href="http://docs.jquery.com/Effects/toggle" rel="nofollow noreferrer">Effects/toggle</a> function:</p> <pre><code>setInterval(function(){$('#myDiv').toggle();}, 60000); </code></pre> |
33,463,619 | 0 | <p>The problem may be here: </p> <p>/** MySQL hostname */ define('DB_HOST', 'www.abc.com'); //before 'localhost'</p> <p>Databases are almost always hosted at 'localhost' not at you domain.</p> <p>Try reverting to:</p> <p>/** MySQL hostname */ define('DB_HOST', 'localhost');</p> <p>MORE DETAILED ANSWER</p> <ol> <li><p>I suggest you create a default installation of WP -- including a stock database -- at NetworkSolutions. That will take care of configuring everything: site url, site home, database user, dbase pw, etc. </p></li> <li><p>Download your theme from your local install, and upload it to the new site. </p></li> <li><p>Then in your existing local WP install, go to Admin > Tools > Export and select everything you want to export to the new site. </p></li> <li><p>Go to the new site, Admin > Tools > Import, and import what you exported. Using the WP import/export should eliminate overwriting anything in the new database that should not be overwritten by your local install (site url, home url, users, etc.)</p></li> </ol> |
40,290,896 | 0 | <p>I believe your call is matching the wrong overload of the helper method.</p> <p>As written, it will match this signature:</p> <pre><code>public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes) </code></pre> <p>Notice there is no controller in there.</p> <p>Try this instead:</p> <pre><code>@Html.ActionLink("View Staff", "Index", "Staff" , new { id = item.UnitCode }, null) </code></pre> <p>Which should match the right signature with controller:</p> <pre><code>public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes) </code></pre> |
33,207,359 | 0 | <p>I would like to mention two things </p> <ol> <li><p>AngularJs is not about DOM Manipulation.</p></li> <li><p>working concept of directive ,it must be purely independent from the controller and all, must be working in all place.</p></li> </ol> <p>In my view the directive triggering must be on the basis of data.</p> <p>So there won't be a problem in using multiple directive in a single view if they are triggered according to data</p> |
39,956,718 | 0 | <p>Here is a sample in JS to match your require, another language should the same.</p> <pre><code>/^gs:\/\/(.+?)\/(.+)$/ </code></pre> <p>Check result <a href="http://scriptular.com/#%5Egs%3A%5C%2F%5C%2F(.%2B%3F)%5C%2F(.%2B)%24%7C%7C%7C%7C%7C%7C%7C%7C%5B%22gs%3A%2F%2Fbucket%2Ffolder1%2Ffolder2%2Ftest.csv%22%5D" rel="nofollow">here</a> </p> |
10,959,181 | 0 | <p>I would definitely avoid putting binaries in source control. You'd be far better off creating your own nuget repository containing your preferred versions of packages and either using nuget restore or some other way of "rehydrating" your dependencies for building. I use a simple batch file called nuget-update.bat which just looks at all packages.config files and gets any dependencies it finds.</p> |
33,061,971 | 0 | Selecting MediaRoute on behalf of user works but MediaRoute button is in disconnected state <p>I'm building an app that will launch a chromecast receiver application automatically without the user clicking the mediaroute button and selecting a route. The user has already selected their desired route, and my app attempts to connect to it for a short period of time until it succeeds (hopefully).</p> <p>When it does succeed, the app is launched onto the correct route, however the mediarouter menu item (the one used to select routes traditionally) is not updated, it still remains in the disconnected state. Once the user clicks on it (while the app is already connected to the receiver) it presents him with possible routes, and once he selects the route (the one that is already connected to and displaying the app) the media router menu item updates itself showing that it is connected and allowing the user to disconnect on the next click. </p> <p>I would like it to be updated once successfully connected to the receiver (route). This way the user will be able to disconnect with only a couple clicks (once on the menu item, and once on the 'Stop Casting' button).</p> <p>I am using the CastCompanionLibrary, though I do not think that it matters in this case.</p> <p>I am able to launch the receiver without user action by calling the MediaRouter.Callback directly like so:</p> <p><code>mCastManager.onRouteSelected(mMediaRouter, theRoute);</code></p> <p>Where <code>mMediaRouter</code> is the <code>MediaRouter</code> instance and <code>theRoute</code> is the <code>MediaRouter.RouteInfo</code> instance holding the pre-selected receiver route.</p> <p>Also, I am open to suggestions of better implementing automatic launch of the receiver application from a service/activity.</p> |
31,962,848 | 0 | how to do real time notification in my (own)app? <p>i am new to android. i need develop notification to my application. i have seen gcm (android hive) example and simple example of notification. </p> <p>i was confused with that example. please guide me how to do real time notication?</p> <pre><code> mn = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nb = new NotificationCompat.Builder(this); nb.setSmallIcon(R.drawable.ic_action_mail_add); nb.setTicker("hi"); nb.setContentTitle("mail"); BitmapDrawable bd = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_action_mail); Bitmap b= bd.getBitmap(); nb.setLargeIcon(b); nb.setContentText("haii.."); nb.setContentInfo("3 unread"); nb.setAutoCancel(true); Intent in = new Intent(this,NotificationActivity.class); PendingIntent pi = PendingIntent.getActivity(this, 0, in, PendingIntent.FLAG_UPDATE_CURRENT); nb.setContentIntent(pi); </code></pre> |
19,385,963 | 0 | <p>Try this : <code>(?<=\bHOUSE\s)(?:\d+-\w|\d+\s\w|\d+)\b</code></p> <p>NB. the order on a conditional statement is important, and the first successful match is taken, so if you have <code>\d+|\d+-\w</code> it will only match <strong>4</strong> in <strong>4-C</strong> but <code>\d+-\w|\d+</code> will match <strong>4-C</strong></p> <p><a href="http://regex101.com/r/gS0aO6" rel="nofollow">http://regex101.com/r/gS0aO6</a></p> |
25,785,778 | 0 | <p>You aren't injecting it. There is no autowiring for the <code>RememberMeConfigurer</code>. Also why are you configuring so many beans?</p> <p>The <code>RememberMeAuthenticationProvider</code> is already created for you, if you want to use a different key specify it using <code>key("KEY")</code>. This in turn will be used to create the <code>RememberMeServices</code>.</p> <pre><code>@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired UserDetailsService userDetailsService; @Autowired DatabasePersistentTokeRepositoryImpl databasePersistentTokeRepositoryImpl; @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); } @Override protected void configure(HttpSecurity http) throws Exception { http .rememberMe() .key("KEY") .tokenRepository(databasePersistentTokeRepositoryImpl) .tokenValiditySeconds((int) TimeUnit.SECONDS.convert(7, TimeUnit.DAYS)) .and() .csrf().disable(); } } </code></pre> <p>If you really need to set the <code>alwaysRemember</code> property to true you could use an <code>ObjectPostProcessor</code> to post process the filter and configure the <code>RememberMeServices</code> from there. </p> <p>You would also have injected the wrong type of <code>RememberMeServices</code> as the one configured doesn't use the <code>PersistentTokeRepository</code>.</p> |
36,156,051 | 0 | Scheduled mapreduce job on Google Cloud Platform <p>I'm developing a node.js application that basically <strong>stores user event logs in a database and shows insights about user action</strong>s. For achieving this event logs must be analyzed by using a <strong>Mapreduce</strong> job which would run <strong>once a day automatically</strong> (every night).</p> <p>I've found lots of tutorials about mapreduce on google cloud web site but I'm totally lost because there are several technologies and can't find a way to do it without using the command line and also there is no information about scheduling (<strong>I want that the whole analysis process to be entirely automated</strong>)</p> <p>Please, could you provide me advice about what google technologies should I use or where I can find a good tutorial?</p> <p>Thank you</p> |
29,027,373 | 0 | <p>Solved it by using the following steps:</p> <ul> <li>Open an InputStream to the image as normal</li> <li>Write the stream to a ByteArrayOutputStream</li> <li>Compare the length of the ByteArrayOutputStream to the Content-Length header from the HttpURLConnection</li> <li>If mismatch then you've lost data in transit</li> <li>Otherwise you can convert your ByteArrayOutputStream to a ByteArrayInputStream and use with the BitmapFactory as you see fit</li> </ul> |
3,906,270 | 0 | <p>You have to start <code>wait</code> by acquiring synchronization on the wait variable, e.g.</p> <pre><code>synchronized( this ) { this.wait( ); } </code></pre> <p>Please read the javadoc for <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#wait%28%29" rel="nofollow">wait</a> carefully and follow it to the letter, otherwise you'll be up to nasty surprises.</p> |
21,489,225 | 0 | <p>Convert your month and year columns to strings concatenated with '-'s and add '-01' to the end. Then convert to a date.</p> <pre><code>UPDATE t SET t.[Date] = convert(date, convert(varchar(4), t.[Year]) + '-' + convert(varchar(2), t.[Month]) + '-01') FROM Table t </code></pre> <p>This will create a date for all records in your table.</p> |
13,222,409 | 0 | C# How to handle TCP packets/segments <p>A couple of questions about TCP. </p> <p>I know that the packet will be "split" or fragmented if it hits a network device with lower MTU etc. But the problems I have is understanding how I "rebuild" my payload in the application. (I've been trying for 2-3 hours now, but can't seem to get it right)</p> <p>First things first. When sending the packet, what are the pros/cons of the two following options;</p> <pre><code>NetworkStream ns = client.GetStream(); ns.Write(BitConverter.GetBytes(100)); ns.Write(BitConverter.GetBytes("Test")); </code></pre> <p>or</p> <pre><code>NetworkStream ns = client.GetStream(); byte[] payload = BitConverter.GetBytes(100).Concat(BitConverter.GetBytes("Test")); ns.Write(payload); //, 0, payload.Length); </code></pre> <p>And how do I rebuild the payload at the recv. part if it has been split? I would love a spoon-feeding on this one as I seem to miss some very important, but not so obvious, part in my current application.</p> |
526,231 | 0 | <p>If you just want to see how it can be achieved...</p> <p><a href="http://www.codeproject.com/KB/dotnet/Call_ironpython__in_C_.aspx" rel="nofollow noreferrer">Here's</a> one example to do that.</p> |
15,671,833 | 0 | Show/hide div when clicked on marker <p>I'm new to javascript and no idea where to start digging information how to implement my idea. I want to open a div like a pop-up over the map when a marker is clicked. I have around 15 markers and every marker has different content and images. The pop-up layout will stay the same. I believe making a div is easier than making a infobox, true?</p> <p>this is my photoshop sketch: <a href="http://cl.ly/image/0s3u2A1g2H2r" rel="nofollow">Sketch</a></p> <p>And this is what I have so far: <a href="http://shonderdos.nl/demo/" rel="nofollow">Demo</a></p> <p>What should I try, read and investigate? </p> |
20,303,123 | 0 | Verdana font issue <p>I must implement a website css from psd file. In psd some text is in Verdana, but when I use Verdana in css it appears thicker in a browser than Verdana in the psd file. Does anyone know the reason?</p> |
2,269,515 | 0 | <p>Although it is not object-oriented, <a href="http://www.haskell.org/" rel="nofollow noreferrer"><strong>Haskell</strong></a> offers a significant number of the features that interest you:</p> <ul> <li><p>Syntax support for list comprehensions, plus <code>do</code> notation for a wide variety of sequencing/binding constructs. (Syntax support for dictionaries is limited to lists of pairs, e.g, </p> <pre><code>dict = ofElements [("Sputnik", 1957), ("Apollo", 1969), ("Challenger", 1988)] </code></pre></li> <li><p>Functions support full closures and multiple return values using tuple types. Keyword arguments are not supported but a powerful feature of "implicit arguments" can sometimes substitute.</p></li> <li><p>No runtime modification of classes, types or objects.</p></li> <li><p>Avoidance of specificying classes/types everywhere through <em>type inference</em>.</p></li> <li><p>Metaprogramming using Template Haskell.</p></li> </ul> <p>Also, just so you will feel at home, Haskell has significant indentation!</p> <p>I actually think Haskell has quite a different feel from Python overall, but that is primarily because of the extremely powerful static type system. If you are interested in trying a statically typed language, Haskell is one of the most ambitious ones out there right now.</p> |
1,915,934 | 0 | <p>Yes, NUnit tests are supposed to be isolated and it is <strong>your</strong> responsibility to make sure they are isolated. The solution would be to reset ObjectFactory in the TearDown method of your test fixture. You can use ObjectFactory.EjectAllInstancesOf() for example.</p> |
8,286,918 | 0 | <p>try adding the following to your .htaccess file in the root of your domain</p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/[^/]{2}/product/ [NC] RewriteCond %{REQUEST_URI} ^/([^/]{2})/([0-9]+.*)$ [NC] RewriteRule . /%1/product/%2 [L,R=301] </code></pre> |
9,026,192 | 0 | <p>I don't think there is an out-of-the-box solution to have 2 background colors.</p> <p>The best solution would be to use <strong><a href="http://www.graphviz.org/content/attrs#kcolorList" rel="nofollow noreferrer">gradient</a></strong> fills (<code>fillcolor="orange:yellow"</code>) - but though this is in the documentation, I wasn't able to make it work on my box.</p> <p>You could use <strong><a href="http://www.graphviz.org/content/node-shapes#html" rel="nofollow noreferrer">HTML-like labels</a></strong> as a workaround. You may need to split the label to have it centered, depending on your needs:</p> <pre><code>a[shape="none", label=< <table cellpadding="0" cellborder="0" cellspacing="0" border="0"> <tr> <td bgcolor="orange">abc</td> <td bgcolor="yellow">def</td> </tr> </table> >] </code></pre> <p><img src="https://i.stack.imgur.com/5ReVy.png" alt="2 colors"></p> |
9,760,596 | 0 | How to use scala 2.10 trunk with sbt 0.11.0? (Unresolved dependencies) <p>What's the right way to use sbt with 2.10 trunk? I tried the obvious:</p> <pre><code>james@James-Moores-iMac:~/workspace/Deleteme3$ cat build.sbt scalaVersion := "2.10.0-SNAPSHOT" </code></pre> <p>But that gives:</p> <pre><code>james@James-Moores-iMac:~/workspace/Deleteme3$ sbt compile [info] Loading global plugins from /Users/james/.sbt/plugins [info] Set current project to default-ee38f7 (in build file:/Users/james/workspace/Deleteme3/) [info] Updating {file:/Users/james/workspace/Deleteme3/}default-ee38f7... [info] Resolving org.scala-lang#scala-library;2.10.0-SNAPSHOT ... [warn] module not found: org.scala-lang#scala-library;2.10.0-SNAPSHOT [warn] ==== local: tried [warn] /Users/james/.ivy2/local/org.scala-lang/scala-library/2.10.0-SNAPSHOT/ivys/ivy.xml [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.0-SNAPSHOT/scala-library-2.10.0-SNAPSHOT.pom [warn] ==== Scala-Tools Maven2 Repository: tried [warn] http://scala-tools.org/repo-releases/org/scala-lang/scala-library/2.10.0-SNAPSHOT/scala-library-2.10.0-SNAPSHOT.pom [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: org.scala-lang#scala-library;2.10.0-SNAPSHOT: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [error] {file:/Users/james/workspace/Deleteme3/}default-ee38f7/*:update: sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.0-SNAPSHOT: not found [error] Total time: 1 s, completed Mar 18, 2012 10:39:29 AM james@James-Moores-iMac:~/workspace/Deleteme3$ </code></pre> <p>Trying the suggestion of the new sbt launcher with -sbt-snapshot fails too:</p> <pre><code>james@James-Moores-iMac:/tmp/sfasdf$ sbt -sbt-snapshot compile Detected sbt version 0.12.0-SNAPSHOT Using /Users/james/.sbt/0.12.0-SNAPSHOT as sbt dir, -sbt-dir to override. Getting net.java.dev.jna jna 3.2.3 ... :: retrieving :: org.scala-sbt#boot-jna confs: [default] 1 artifacts copied, 0 already retrieved (838kB/13ms) Getting org.scala-sbt sbt 0.12.0-20120319-052150 ... :: retrieving :: org.scala-sbt#boot-app confs: [default] 38 artifacts copied, 0 already retrieved (7712kB/159ms) Getting Scala 2.9.1 (for sbt)... :: retrieving :: org.scala-sbt#boot-scala confs: [default] 4 artifacts copied, 0 already retrieved (19939kB/426ms) [info] Set current project to wand (in build file:/private/tmp/sfasdf/) Getting Scala 2.10.0-SNAPSHOT ... downloading http://scala-tools.org/repo-snapshots/org/scala-lang/scala-compiler/2.10.0-SNAPSHOT/scala-compiler-2.10.0-20120319.161232-290.jar ... [SUCCESSFUL ] org.scala-lang#scala-compiler;2.10.0-SNAPSHOT!scala-compiler.jar (28525ms) downloading http://scala-tools.org/repo-snapshots/org/scala-lang/scala-library/2.10.0-SNAPSHOT/scala-library-2.10.0-20120319.161232-293.jar ... [SUCCESSFUL ] org.scala-lang#scala-library;2.10.0-SNAPSHOT!scala-library.jar (16869ms) downloading http://scala-tools.org/repo-snapshots/org/scala-lang/jline/2.10.0-SNAPSHOT/jline-2.10.0-20120319.161232-290.jar ... [SUCCESSFUL ] org.scala-lang#jline;2.10.0-SNAPSHOT!jline.jar (1674ms) :: retrieving :: org.scala-sbt#boot-scala confs: [default] 4 artifacts copied, 0 already retrieved (21204kB/91ms) [info] Updating {file:/private/tmp/sfasdf/}default-59a990... [info] Resolving org.scala-lang#scala-library;2.10.0-SNAPSHOT ... [warn] module not found: org.scala-lang#scala-library;2.10.0-SNAPSHOT [warn] ==== local: tried [warn] /Users/james/.ivy2/local/org.scala-lang/scala-library/2.10.0-SNAPSHOT/ivys/ivy.xml [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.0-SNAPSHOT/scala-library-2.10.0-SNAPSHOT.pom [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: org.scala-lang#scala-library;2.10.0-SNAPSHOT: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [error] {file:/private/tmp/sfasdf/}default-59a990/*:update: sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.0-SNAPSHOT: not found [error] Total time: 54 s, completed Mar 20, 2012 7:37:55 AM </code></pre> |
20,915,957 | 0 | <p>Thanks to all. The additional AND condition worked. I had actually tried that earlier but it didn't work when I was testing, in my haste I had not yet added the "completed" column to the table yet. Thanks again. </p> |
20,678,586 | 0 | Spring REST MultipartFile file is always null when do upload file <pre><code>@RequestMapping(value = "{fileName:.+}", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE}) public ResponseEntity<ResponseEnvelope<String>> uploadFile( @RequestParam("ownerId") Long ownerId, @PathVariable("fileName") String fileName, @RequestBody MultipartFile file) throws Exception { ResponseEnvelope<String> env; if(null == certFileContent) { env = new ResponseEnvelope<String>("fail"); return new ResponseEntity<ResponseEnvelope<String>>(env, HttpStatus.OK); } service.uploadCertificate(ownerId, fileName, certFileContent.getBytes()); env = new ResponseEnvelope<String>("success"); return new ResponseEntity<ResponseEnvelope<String>>(env, HttpStatus.OK); } </code></pre> <p>Why I always get the file value is null, I've configure the multipart support,see below,</p> <p> </p> |
2,085,942 | 0 | How to display attached properties in Property Browser of blend for silverlight? <p>I created couple of custom controls and their childresn correctly shows the attached properties in Property Browser for WPF, but in silverlight none of the attached properties appear in Property Brower.</p> <p>How to add design time support for attached properties in silverlight?</p> |
27,783,083 | 0 | <p>Just import them as usual. When running the tests, Maven will create a classpath which will make everything in <code>src/main/java</code> visible to the test classes.</p> |
10,946,490 | 0 | <p>For those having troubles like these accessing the soap web services and using a https protocol, we managed to solve the issue by configuring the RTM CRM 2011 deployment with Claims based authentication and IFD access thanks to <a href="http://www.youtube.com/watch?v=ZD5qaa-G99E" rel="nofollow">this tutorial</a>.</p> <p>Hope it will help some of you !</p> |
40,803,902 | 0 | <p>You need samsung certificate. Application with Certificate that created in Tizen Studio can be run only Emulator. Use Samsung Certificate if you want to run application on real device.</p> <p>Refer <a href="http://stackoverflow.com/questions/40742515/how-to-install-app-on-gear-s2-via-tizen-studio/40755444#40755444">this my answer</a>.</p> |
21,324,210 | 0 | <p>Try this:</p> <pre><code>jQuery(function ($) { if (typeof (window.localStorage) != "undefined") { // will get value of specific id from the browser localStorage and set to the input $("input[type=text]").val(function () { return localStorage.getItem(this.id); }); // will set values in browser localStorage for further reference $("input[type=text]").on("change", function () { localStorage.setItem(this.id, $(this).val()); }); } }); </code></pre> <p>Here is a working <a href="http://jsfiddle.net/sf3ZU/1/" rel="nofollow">Demo</a>.</p> <p><strong>Details:</strong></p> <p>Using local storage in modern browsers is ridiculously easy. All you have to do is modify the <code>localStorage object</code> in JavaScript. You can do that directly or (and this is probably cleaner) use the <code>setItem()</code> and <code>getItem()</code> method:</p> <pre><code>localStorage.setItem('favoriteflavor','vanilla'); </code></pre> <p>If you read out the favoriteflavor key, you will get back “vanilla”:</p> <pre><code>var taste = localStorage.getItem('favoriteflavor'); // -> "vanilla" </code></pre> <p>To <strong>remove</strong> the item, you can use — can you guess? — the <code>removeItem()</code> method:</p> <pre><code>localStorage.removeItem('favoriteflavor'); var taste = localStorage.getItem('favoriteflavor'); // -> null </code></pre> <p>That’s it! You can also use <strong>sessionStorage</strong> instead of <strong>localStorage</strong> if you want the data to be maintained only until the browser window closes.</p> <p>The complete <a href="http://coding.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/" rel="nofollow">reference here</a>. It should give you more knowledge about <code>localStorage</code>.</p> |
30,771,239 | 0 | Array of Protocol instances won't work with contains method <p>I have a protocol that I am using to define what makes up the content of a note. A note can have many different content types, so a protocol seemed like the best way to go.</p> <pre><code>public protocol Content { var contentType: String { get } } </code></pre> <p>I then have an implementation of that protocol</p> <pre><code>public class PlainTextContent: Content { public var contentType: String { return "Plain Text" } public var text: String = String() public init(content: String) { self.text = content } } </code></pre> <p>This is a simplified example of the two objects. Next I have a <code>Note</code> class that holds an <code>Array</code> of <code>Content</code> protocol implementations.</p> <pre><code>public class Note { public private(set) var noteContent: [Content] = [] public var title: String = String() public var date: NSDate public init() { self.date = NSDate() } func insertContent(content: Content) -> Bool { if contains(self.noteContent, content) { return false } self.noteContent.append(content) return true } func deleteContent(content: Content) -> Bool { return false } } </code></pre> <p>The problem that I have is that when I do</p> <pre><code>if contains(self.noteContent, content) {} </code></pre> <p>the compiler tells me</p> <blockquote> <p>Note.swift:21:12: Cannot find an overload for 'contains' that accepts an argument list of type '([Content], Content)'</p> </blockquote> <p>I have looked a <a href="http://stackoverflow.com/questions/24102024/how-to-check-if-an-element-is-in-an-array">few examples</a> on <a href="http://stackoverflow.com/questions/28615434/xcode-swift-check-if-array-contains-object">Stackoverflow</a> and I'm doing as they show. Is there an issue with how I am defining my protocol in order for me to use it as an array and the associated global functions?</p> <h2>Edit</h2> <p>I have also tried to make the protocol inherit from <code>Equatable</code>, at which point I get the following compiler error</p> <blockquote> <p>Protocol 'Content' can only be used as a generic constraint because it has Self or associated type requirements</p> </blockquote> <p>I'm a little confused as to how I can perform equality checks against the array of protocols. Is that something that Swift doesn't support? I'm coming from a C# background, so not sure how Swift handles protocols fully.</p> |
23,162,806 | 0 | <p>There's a better way.</p> <p>jQuery documentation for <a href="https://api.jquery.com/deferred.promise/" rel="nofollow">Deferred.promise([target])</a> says :</p> <blockquote> <p>If target is provided, <code>deferred.promise()</code> will attach the methods onto it and then return this object rather than create a new one. This can be useful to attach the Promise behavior to an object that already exists.</p> </blockquote> <p>Thus, you can define your own promise methods as follows :</p> <pre><code>var myPromiseMethods = { myMethod1: function() { ... }, myMethod2: function() { ... }, myMethod3: function() { ... } }; </code></pre> <p>Then, you can make your methods available as follows :</p> <pre><code>var dfrd = $.Deferred(); ... return dfrd.promise(myPromiseMethods).myMethod(); </code></pre> <p>In general, you will want to write your methods something like this :</p> <pre><code>myMethod1: function() { var promise = this; //do something awesome here return promise; } </code></pre> <p>By returning <code>this</code> or <code>promise</code>, the method becomes chainable like the built-in Promise methods, eg :</p> <pre><code>var dfrd = $.Deferred(); ... return dfrd.promise(myPromiseMethods).myMethod().then(...); </code></pre> <h2>Example</h2> <p>You can define the object containing the custom method in any convenient scope. In this example, I simply name the object <code>é</code> (altGreen-E under Windows), which is compact, distinctive and unlikely to be used for other purposes. </p> <p>So let's define an <code>invert()</code> method which reverses the sense of a promise - resolve becomes reject and reject becomes resolve.</p> <pre><code>var é = { invert: function() { var promise = this; return $.Deferred(function(dfrd) { promise.then(dfrd.reject, dfrd.resolve); }).promise(); } }; var dfrd = $.Deferred(); dfrd.promise(é).invert().done(function(str) { alert('done: ' + str); }).fail(function(str) { alert('fail: ' + str); }); dfrd.reject('*'); </code></pre> <p>As you can see, the methods defined in <code>é</code> become available to any promise created with <code>dfrd.promise(é)</code>. </p> <p><strong><a href="http://jsfiddle.net/R8Evv/" rel="nofollow">DEMO</a></strong></p> |
5,922,713 | 0 | Is there a way to get Mysql to make the unique ID generate with letters and numbers? (or PHP) <p>Is there a way i could make the unique id (primary key) in Mysql generate with numbers and letters to keep the id as short as possible? If I cant do this in Mysql how could i get PHP to generate this? Thanks :)</p> |
29,017,782 | 0 | How do you extend a class with a jQuery wrapped set? <p>The following almost works...</p> <pre><code>$el = -> $el:: = $ '#test' new class extends $el constructor: -> @append '<h1>Worked!</h1>' # this will overflow the stack @find('[role=test2]').append '<h2>Also Worked!</h2>' </code></pre> <p>Example here: <a href="http://jsfiddle.net/66a3jdot/" rel="nofollow">http://jsfiddle.net/66a3jdot/</a></p> |
9,583,911 | 0 | jquery form field message on submit <p><a href="http://jsfiddle.net/XeELs/24/" rel="nofollow">http://jsfiddle.net/XeELs/24/</a></p> <p>I'm having problems with this Fiddle is not working the message Error. I'm using the CSS3-html5 form validation and I need to implement it within CSS possibly <code>valid</code> and <code>invalid</code></p> |
14,940,003 | 0 | <p>Reserved words are a moving target. If the dbms doesn't expose them through a public interface, there isn't usually a good programmatic way to get to them.</p> <p>If you don't want to guard them with brackets, you risk incorporating symbols that are not reserved in your currently used version of SQL Server, but <em>are</em> reserved in some future version.</p> <p>I think your best bet is to use the quoting mechanism your dbms provides, since it's designed to deal with exactly this problem. For SQL Server, that means square brackets.</p> |
3,927,498 | 0 | <p>As far as I know, mongodb doesn't support queries against dynamic values. But you could use a javascript function:</p> <pre><code>scope :unresolved, :where => 'this.updated_at >= this.checked_at' </code></pre> <p>To speed this up you could add an attribute like "is_unresolved" which will be set to true on update when this condition is matched ( and index that ).</p> |
11,653,698 | 0 | How do I tie in my image handler with an image control? <p>I've been looking around and reading about handlers, but I don't fully understand how to implement them for my situation.</p> <p>I want display a screenshot from the user's clipboard. I already have code that retrieves the image from the clipboard into a bitmap format. This is what I have:</p> <pre><code>var dataobj = new DataObject(); dataobj = (DataObject)Clipboard.GetDataObject(); System.Drawing.Image img = dataobj.GetData(DataFormats.Bitmap) as System.Drawing.Image; original = (System.Drawing.Image)img.Clone(); img = resizeImage(img, new Size(670, 500)); String s = "c:/Temp/temp.png"; img.Save(s, ImageFormat.Png); Image1.ImageUrl = s; Image1.DataBind(); </code></pre> <p>My problem was that I am not able to save the images to the hard disk.</p> <p>My first question is will an image handler help me in this situation?</p> <p>if it will, how do I modify that code and tie it into my image handler with this code:</p> <pre><code>public class getmyimage : IHttpHandler { public void ProcessRequest(HttpContext context) { HttpResponse r = context.Response; r.ContentType = "image/png"; // Write the requested image r.WriteFile("temp.png"); } public bool IsReusable { get { return false; } } } </code></pre> |
13,303,978 | 0 | <p>Get rid of that new at the beginning. It's <code>Charts.newColumnChart()</code>, not <code>new Charts.newColumnChart()</code>.</p> |
21,111,770 | 0 | Aggregate intraday data <p>As from my previous question, I have this query to perform data aggregation from intraday to daily data</p> <pre><code>SELECT symbol, date, MAX(high) AS high, MIN(low) as low, SUM(volume) as volume, (select open from A2A a2 where a1.symbol = a2.symbol and a1.date = a2.date order by time limit 1) as open, (select close from A2A a2 where a1.symbol = a2.symbol and a1.date = a2.date order by time desc limit 1) as close FROM A2A a1 WHERE date >= date_sub(CURDATE(), interval 100 day) GROUP BY symbol, date ORDER BY symbol, date; </code></pre> <p>but this return less then 100 daily aggregated rows since it use calendar days.</p> <p>1) How to modify this query to get 100 latest records?</p> <p>2) How to aggregate to 5 minute data instead of daily (i.e., first row aggregates data from 0900 up to 0904, then from 0905 up to 0909, etc.)?</p> <p>I use mySQL 5.6.11, data stored are as follow</p> <p><img src="https://i.stack.imgur.com/NKmdr.png" alt="enter image description here"></p> <p>I store stock market data 1 minute per row, I have 511 1 minute rows for every day (from 0900 up to 1730).</p> |
5,681,585 | 0 | <p>If you have a dual-core computer and a process that's taking 50%, it means it's using one core, at its maximum capability.</p> <p><br> Compiling is a complex operation ; and it doesn't surprise me that it'd use a full CPU for some time <em>(depending on the size of your project)</em>.</p> <p>Using a CPU at its maximum, a bad thing ? Well, if you have a CPU, why not just use it ;-) <br>I don't think it can damage anything, at least if that doesn't last <em>too long</em> and your CPU is properly cooled. <br>I've had my quad-core CPU run at 100% <em>(on each core)</em> for several days in a row ; I've seen absolutly no problem since <em>(the fans were working harder for that time, but it's all)</em></p> <p><br> <code>jawaw</code> is the process that corresponds to the execution of JAVA <em>(at least for some programs)</em> ; and Eclipse is developped in JAVA ; so no surprise here either.</p> |
7,751,588 | 0 | <p>Try changing</p> <pre><code>exec('gpg --homedir $path --recipient $recipient --output $encrypted_file --encrypt $plain_file --yes --always-trust', $answer, $rtn); </code></pre> <p>To</p> <pre><code>exec("gpg --homedir $path --recipient $recipient --output $encrypted_file --encrypt $plain_file --yes --always-trust", $answer, $rtn); </code></pre> <p>Notice I changed single quotes to double</p> <p><a href="http://php.net/manual/en/language.types.string.php" rel="nofollow">http://php.net/manual/en/language.types.string.php</a></p> |
25,112,397 | 0 | How can I make ExtUtils::Manifest include empty directories? <p>I am trying to build a Perl module for distribution. The directory structure looks like this:</p> <pre><code>demo demo/files demo/examples/example1.pl demo/scripts lib </code></pre> <p>I used this command to generate the MANIFEST file:</p> <pre><code>perl -e "use ExtUtils::Manifest qw(mkmanifest); mkmanifest();" </code></pre> <p>The file is created but all of the empty folders are ignored, so <code>demo/files</code> and <code>demo/scripts</code> are not in the MANIFEST.</p> <p>How can I tell <a href="https://metacpan.org/pod/ExtUtils::Manifest" rel="nofollow"><code>ExtUtils::Manifest</code></a> to include empty folders?</p> |
29,694,944 | 0 | <p>This should work:</p> <pre><code>@ECHO OFF FOR /F "tokens=*" %%a IN ('ver') DO ( SET ver=%%a ) SET v1=%ver:~27,1% SET v2=%ver:~29,1% IF %v1% LSS 6 GOTO JUMPTO IF %v2% LSS 2 GOTO JUMPTO ECHO doing something PAUSE GOTO:EOF :JUMPTO ECHO Windows version too old! PAUSE </code></pre> |
4,880,888 | 0 | How to Circumvent Perl's string escaping the replacement string in s///? <p>I'm not sure what exactly to call this, but I've been able to reproduce my problem with two one-liners.</p> <p>Starting from a file 'test.txt' containing the following:</p> <pre><code>foo </code></pre> <p>After running the following command (in bash):</p> <pre><code>perl -n -e "s/(\w)oo/$1ar/; print;" test.txt </code></pre> <p>the output is '<code>far</code>'</p> <p>However, when I introduce a variable containing the replacement string, </p> <pre><code>perl -n -e '$bar = q($1ar); s/(\w)oo/$bar/; print;' test.txt </code></pre> <p>the output is '<code>$1ar</code>'.</p> <p>What do I need to change so that the second program will also output '<code>far</code>' and what keywords do I need to learn that would have made this answer Googleable?</p> <p>Also, I tried changing the second one to s///e, to no effect.</p> <p>Edit: This wasn't really the question I wanted to ask, which is <a href="http://stackoverflow.com/questions/4881345/how-to-circumvent-perls-string-escaping-the-replacement-string-in-s-when-its">here</a>.</p> |
9,263,743 | 0 | <p>Another caveat was running Android SDK Manager in Windows 7 without administrator privileges. It would try to install support package, but would always fail, and the actual package never got downloaded to</p> <blockquote> <p>C:\Program Files (x86)\Android\android-sdk\extras\android\support\v4\android-support-v4.jar</p> </blockquote> |
10,150,139 | 0 | Bug in JavaScript V8 regex engine when matching beginning-of-line? <p>I have a pretty nifty tool, <a href="https://github.com/ddopson/underscore-cli" rel="nofollow">underscore-cli</a>, that's getting the strangest behavior when printing out the help / usage information.</p> <p>In the usage() function, I do this to indent blocks of text (eg, the options):</p> <pre><code>str.replace(/^/, " "); </code></pre> <p>This regex, in addition to being pretty obvious, comes straight out of TJ Hollowaychuk's <a href="https://github.com/visionmedia/commander.js" rel="nofollow">commander.js</a> code. The regex is correct.</p> <p>Yet, I get bizzare spaces inserted into the middle of my usage text. like this:</p> <pre> Commands: ... values Retrieve all the values of an object's properties. extend <object> Override properties in the input data. defaults <object> Fill in missing properties in the input data. any <exp> Return 'true' if any of the values in the input make the expression true. Expression args: (value, key, list) all <exp> Return 'true' if all values in the input make the expression true. Expression args: (value, key, list) isObject Return 'true' if the input data is an object with named properties isArray Return 'true' if the input data is an array isString Return 'true' if the input data is a string ... </pre> <p>99% chance, this HAS to be a bug in V8.</p> <p>Anyone know why this happens, or what the easiest work-around would be? </p> <p>Yup, turns out this <strong>IS</strong> a V8 bug, 1748 to be exact. Here's <a href="https://github.com/ddopson/underscore-cli/commit/bad0802b1fdc65de8623a7950a831bf5828bf283" rel="nofollow">the workaround I used in the tool</a>:</p> <pre><code>str.replace(/(^|\n), "$1 "); </code></pre> |
25,688,324 | 0 | Number of comboboxes increase after the first set of results <pre><code>I am populating my datagrid based on a value in the textbox. </code></pre> <p>One of the field values in my grid view is a combobox.On a particular text box entry it shows me the correct results but wen I give another value in the text box, the combobox increases its number which means If I enter 100, the data is populated correctly in my combobox but for any value that is provided next the number of combobox becomes 2.I don't know why this happens. This is the code on button click. please help</p> <pre><code> DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn(); combo.HeaderText = "Supplier"; //execute sql data adapter to get supplier values DataTable dt = obj.SqlDataTable("select name1 from blahblah"); //foreach (DataRow supplier in dt.DataSet.Tables[0].Rows) //{ // combo.Items.Add(supplier[0]); //} //dataGridView1.Columns.Add(combo); foreach (DataRow row in dt.Rows) { combo.Items.Add(row["NAME1"].ToString()); } dataGridView1.Columns.Add(combo); </code></pre> |
19,344,785 | 0 | <blockquote> <p>Any suggestions which api or util to use for that purpose in JAVA?</p> </blockquote> <p>Main suggestion ... don't do it. It should be up to the end user to think up a passphrase. Any systematic scheme you implement for generating passphrases will be vulnerable to someone attacking your system.</p> <p>I am not aware of an API or utility that does this. But if you did find such an API or utility, you should immediately be suspicious of it:</p> <ul> <li><p>any "common" scheme for generating passphrases will attract attention from people trying to defeat it</p></li> <li><p>you should be concerned that someone has incorporated a backdoor in the scheme.</p></li> </ul> <p>The second problem is that a generated passphrase consisting of random English words won't be memorable, and hence the user is likely to write it down. Once they have done that, your security is defeasible by looking for bits of paper in their stolen wallet, etcetera.</p> <hr> <blockquote> <p>Well, I am also generating a random url and with each url a pin will be associated. URL is sent thru mail but PIN will be texted on their cells. So it wont be an easy hacking attack since my URL is also random. </p> </blockquote> <p>If someone can access the user's browser history, or snoop his network traffic, then they can find out what the random URL is.</p> <hr> <blockquote> <p>Or random number as PIN is fine?</p> </blockquote> <p>A randomly generated PIN is probably better than a non-random one (or one supplied by the user!) but neither is up to scratch ... unless they have 10+ digits.</p> |
38,353,235 | 0 | <pre><code>/**** get some dates to play with ****/ data dates(keep=i thisdate); offset = input('01Jan2015',DATE9.); do i=1 to 100; thisdate = offset + round(599*ranuni(1)+1); *** within 600 days from offset; output; end; format thisdate date9.; run; /**** BTW: intnx('month',thisdate,1)-1 = first day of next month. Deduct 1 to get the last day of the current month. intnx('month',thisdate,0,"BEGINNING") = first day of the current month ****/ proc sql; create table first5_last5 AS SELECT * FROM dates /* replace with name of your data set */ WHERE /* replace all occurences of 'thisdate' with name of your date variable */ ( intnx('month',thisdate,1)-5 <= thisdate <= intnx('month',thisdate,1)-1 ) OR ( intnx('month',thisdate,0,"BEGINNING") <= thisdate <= intnx('month',thisdate,0,"BEGINNING")+4 ) ORDER BY thisdate; quit; </code></pre> |
6,956,515 | 0 | <p>Why are you replacing it with <code>\n</code>? </p> <p>Try to replace it with an <strong>empty string</strong> instead, like <code>''</code>. Try to replace <code>\r\n</code> with <code>""</code> and <code>\n</code> with <code>""</code></p> |
2,987,260 | 0 | <p>you have to MIME-encode your post: a binary post in an NNTP newsgroup is like a mail with an attachment. </p> <p>the file has to be encoded in ASCII, generally using the <code>base64</code> encoding, then the encoded file is packaged iton a multipart MIME message and posted...</p> <p>have a look at the <a href="http://docs.python.org/library/email.html#module-email" rel="nofollow noreferrer"><code>email</code></a> module: it implements all that you want.</p> <p>i encourage you to read <a href="http://tools.ietf.org/html/rfc3977" rel="nofollow noreferrer"><code>RFC3977</code></a> which is the official standard defining the NNTP protocol.</p> <p><em>for the second part of your question:</em></p> <p>use <a href="http://docs.python.org/library/stringio.html#module-StringIO" rel="nofollow noreferrer"><code>StringIO</code></a> to build a fake file object from a string (the <code>post()</code> method of nntplib accepts open file objects). <code>email.Message</code> objects have a <code>as_string()</code> method to retrieve the content of the message as a plain string.</p> |
16,713,231 | 0 | <p>It seems that you name table <code>products AS p</code> and then later also <code>product_fields AS p</code>. Try this:</p> <pre><code>SELECT p.*, c.value AS color, g.value AS gender, p.value AS price FROM products p LEFT JOIN product_fields c ON c.product_id = p.id AND c.name = 'color' LEFT JOIN product_fields g ON g.product_id = p.id AND g.name = 'gender' LEFT JOIN product_fields pr ON pr.product_id = p.id AND pr.name = 'price' </code></pre> <p>Note, that you use <code>LEFT JOIN</code>, which allows a match NULL values. maybe all you need to do is changing to <code>INNER JOIN</code>?</p> <pre><code>SELECT p.*, c.value AS color, g.value AS gender, p.value AS price FROM products p INNER JOIN product_fields c ON c.product_id = p.id AND c.name = 'color' INNER JOIN product_fields g ON g.product_id = p.id AND g.name = 'gender' INNER JOIN product_fields pr ON pp.product_id = p.id AND pp.name = 'price' </code></pre> |
37,709,922 | 0 | <p>Probably the problem is rather server-side. Your server have to redirect all the routes to <code>index.html</code> to let Angular make its job. </p> |
9,160,042 | 0 | <p>In cake2 you can use a cleaner approach - with or without the new response object: <a href="http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2/" rel="nofollow">http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2/</a></p> <p>The headers will be set by cake itself from the controller. It's not good coding (anymore) to set them in the layout (I used to do that, as well^^).</p> <p>These days the <a href="https://github.com/ceeram/CakePdf" rel="nofollow">CakePdf plugin</a> has matured quite a bit into a very useful tool for PDF generation. I recommend using that in Cake2.x.</p> <p>See <a href="http://www.dereuromark.de/2014/04/08/generating-pdfs-with-cakephp" rel="nofollow">http://www.dereuromark.de/2014/04/08/generating-pdfs-with-cakephp</a></p> |
33,394,491 | 0 | <p>Given your image, you can target this with pure CSS:</p> <pre><code>.institution-selector li { /*this is all list items */ } .institution-selector li li { /*this is all second or third level list items */ } .institution-selector li li li { /*this is all third level list items */ } .institution-selector li:last-child { /*this is the last item in a list of items */ } .institution-selector li ul { /*this is a list within a list item */ } </code></pre> <p>etc.</p> |
39,622,541 | 0 | i am trying to update my data with an image updation too but the image isset would not work in php <p>Hey guys i have created a register form with an image upload too but when i try to update this form i try to get the id but the isset of my image is not working so it just wont run my update query do check it out </p> <p>this is the updation form where all the values will be displayed for edit now can i run the update function in the isset condition of my submit button and then update the data</p> <pre><code> <title>Register Update</title> <?php //error_reporting(0); $id=$_GET['id']; function __autoload($classname) { include "$classname.php"; } $obj = new connect(); $st=$obj->con(); if (isset($_POST['sub'])) { $upd= new update(); $upd->updatedata($_POST); } $qry = "select * from register "; $run = mysqli_query($st,$qry); $row = mysqli_fetch_assoc($run); { $g = $row['gen']; $l = $row['lang']; } $query=mysqli_query($st,"select * from register where id='$id'"); //echo "<ul>"; while($query2=mysqli_fetch_assoc($query)) { //print_r($query2); echo "<form method='POST' action='RegisterRetrieve.php'>"; echo "<table>"; ?> <p><input type="hidden" name="sid" value="<?php echo $query2['id']; ?>"></p> <tr> <td> First Name: </td> <td><input type="text" name="uname" value="<?php echo $query2['uname']; ?>"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pwd" value="<?php echo $query2['pwd']; ?>"></td> </tr> <tr> <td>Email Id:</td> <td><input type="text" name="emailid" value="<?php echo $query2['emailid']; ?>" </td> </tr> <tr> <td>Radio Button: Are you male or female?</td> <?php if ($g == "male"){ echo "<td><input type='radio' name='gen' value='Male' id='gen' checked> Male <input type='radio' name='gen' value='Female' id='gen'> Female </td>"; } else { echo "<td><input type='radio' name='gen' value='Male' id='gen'> Male <input type='radio' name='gen' value='Female' id='gen' checked> Female </td>"; } ?> </tr> <tr> <td>Check Box: Check the languages you know?</td> <td><?php $lang=explode(',',$l); //print_r($lang); if(in_array('Cricket', $lang)) echo '<input type="checkbox" name="lang[0]" value="Cricket" checked>Cricket'; else echo '<input type="checkbox" name="lang[0]" value="Cricket">Cricket'; if(in_array('Basketball', $lang)) echo '<input type="checkbox" name="lang[1]" value="Basketball" checked>Basketball'; else echo '<input type="checkbox" name="lang[1]" value="Basketball">Basketball'; if(in_array('Hockey', $lang)) echo '<input type="checkbox" name="lang[2]" value="Hockey" checked>Hockey'; else echo '<input type="checkbox" name="lang[2]" value="Hockey">Hockey'."<br>"; ?> </td> </tr> <tr> <td>Mobile No:</td> <td><input type="text" name="mobile" value="<?php echo $query2['mobile']; ?>" </td> </tr> <tr> <td>10th Marks:</td> <td><input type="text" name="marks_10" value="<?php echo $query2['10marks'];?>" </td> </tr> <tr> <td> 12th Marks:</td> <td><input type="text" name="marks_12" value="<?php echo $query2['12marks'];?>"</td> </tr> <tr> <td> Browse Image:</td> <td><input type="file" name="file1"></td> <td><img src='img/<?php echo $query2['name'];?>' width='150px' height='150px'></td> </tr> <tr> <td> <select name="priority"> <option value="admin"> admin </option> <option value="<?php echo $query2['priority']; ?>"><?php echo $query2['priority']; ?> </option> <option value="superadmin"> superadmin </option> </select> </td> </tr> <tr> <td></td> <td> <input type="submit" value="submit" name="sub"><br> </td> </tr> <?php echo "<table>"; echo "</form>"; } //echo "</ul>"; ?> </code></pre> <p>now my update query which i m using but when i try to isset my image it just wont go in that condition</p> <pre><code> <?php class update extends connect { function updatedata($rel) { $obj= new connect(); $obj->con(); extract($_POST); $id=$_GET['id']; $line = implode("," ,$lang); print_r($_POST); if(isset($_FILES["file1"])) { extract($_POST); echo "hello"; $name = $_FILES['file1']['name']; $type = $_FILES['file1']['type']; $size = $_FILES['file1']['size']; $tmp_name = $_FILES['file1']['tmp_name']; $loc = 'img/'; $ext = substr($name,strpos($name,'.')+1); if($_FILES['file1']['size']>= '10000' || $_FILES['file1']['size']<="23000000") { //echo $size; } else{ // echo "size is not supported"; } $val = $_FILES['file1']['size']; if($ext == 'jpg' || $ext == 'png') { //echo $lang; //print_r($_POST); //exit; $val =("update register set uname='$uname',pwd='$pwd',emailid='$emailid',gen='$gen',lang='$line',mobile='$mobile',10marks='$marks_10',12marks='$marks_12' file1='$name' where id=$sid"); //print_r($qry); $res=mysqli_query($this->con(),$val); //print_r($run); if($res) { move_uploaded_file($tmp_name,$loc.$name); //echo "data saved"; //echo "Data inserted"; } else { //echo "Data Not Inserted"; } } } } //print_r($val); // return $res; } ?> </code></pre> |
15,244,567 | 0 | <p>Your issue seems to be caused by the line break (which insert a space in the rendered html document). If you don't need that space b/w those two element then you can float both those element to left, it will ignore the space.</p> |
26,956,393 | 0 | Java plugin library shading <p>I'm building a Java based HTTP Server with a bukkit-like (minecraft) plugin system. And I want to load plugin libraries in such a way that they don't interfere with each other, e.g. if two plugins package the same library in their jar something might go wrong.</p> <p>I know this can be done with "maven shading". However, the only thing about maven I know is how to add dependencies to a project. And maven tutorials are not making me any wiser.</p> <p>I have read up about somethings like build goals, yet nowhere any pom.xml examples explaining how this works or what kind of options you have. And when I search for "Java plugin maven shading" or similar the only results I get are about the maven shading plugin (which I don't understand the first thing about either)</p> <p>I don't want to get too deep into maven commandline, I'm using a eclipse maven plugin.</p> <p>Other solutions are welcome as well.</p> |
30,817,189 | 0 | <p>Right click on the Module --><code>Open Module Settings</code> --> Select <code>Dependencies</code> tab --> Click on <code>add(+)</code> button --> Select <code>Library dependency</code> --> Now from list select <code>Play service</code> --> Click <code>Apply</code> --> Clock <code>Ok</code></p> <p><strong>Update</strong></p> <p>Actually there is <code>GoogleApiClient.OnConnectionFailedListener</code> interface but not <code>GooglePlayServicesClient.OnConnectionFailedListener</code>. For reference check the link <a href="http://developers.google.com/games/services/android/init" rel="nofollow">developers.google.com/games/services/android/init</a> </p> |
9,476,616 | 0 | <p>Create a new <code>Map</code> with refnum as key and qty as value.</p> <pre><code>Map<String,Integer> qtyMap=new HashMap<String,Integer>(); </code></pre> <p>while iterating, try</p> <pre><code>String refNum=transItem.getRefNum(); // Mark for removal ? if this is not the first item in the list with the refnum boolean remove=true; Integer currentQty=qtyMap.get(refNum); if(currentQty==null){ currentQty=0; // this doesnt exist already in the map, this is the first item with this reference // number in the list, so you should keep this without removing remove=false; } currentQty=currentQty+transItem.getQty(); qtyMap.put(refNum,currentQty); // if the remove is true then remove this item from the list. if(remove){ groupTransItems.remove(); } </code></pre> <p>This will sum up the qty for refnum's in the map and once your iteration is over, the map will have the sums of quantities for each refnum. You will have to iterate the list once more to set the current qty to each item from the map [EDIT] :- Added the iterating time removal.</p> |
17,431,892 | 0 | <p>I think the problem you are having is that the <code>getQueryString</code> method you are using is looking for the "?" operator in the URL, as in a traditional GET request (e.g. <code>?id=1</code>). Instead, try passing the domain as a parameter in the controller method. For example:</p> <p>In your <code>routes</code> file:</p> <pre><code>GET /customer/:domain controllers.Application.function(domain: String) </code></pre> <p>Then in your Play controller (assuming Play Framework 2.x):</p> <pre><code>public static Result function(String domain){ //Do something with the passed domain string here return ok(...); } </code></pre> |
23,815,659 | 0 | Timer thread has exited with code 259 (0x103) <p>I want to make a clock which display UTC and Local together. So, I used Timer class from System.Threading like below:</p> <pre><code>private static object _lockObj = new object(); static bool isDisplaying = false; public MainWindow() { InitializeComponent(); System.Threading.Timer _timer = _timer = new System.Threading.Timer(timer_expired, null, 0, 1000); } private void timer_expired(object state) { if(!isDisplaying) lock (_lockObj) { this.Dispatcher.BeginInvoke(new Action(() => { this.UTC_TIME.Text = DateTime.UtcNow.ToString("MMM-dd HH:mm:ss"); this.LOCAL_TIME.Text = DateTime.Now.ToString("MMM-dd HH:mm:ss"); })); isDisplaying = false; } } </code></pre> <p>But a few minutes later like 15 minutes or so, the clock stops. In a debug mode, I can see: </p> <pre><code>The thread 0x1e10 has exited with code 259 (0x103). </code></pre> <p>How can I run this clock works all the time?</p> |
9,503,007 | 0 | <p>It's because the font is missing hinting, as already noted. Mac OS always strips away the hinting data anyway, as its rasterizer "auto-hints" the font itself.</p> <p>However, there is a great little software which uses the automatic hinting of FreeType and embeds the data into the file, i.e. it auto-hints the font for you.</p> <p>See here: <a href="http://www.freetype.org/ttfautohint/" rel="nofollow">http://www.freetype.org/ttfautohint/</a></p> |
32,852,770 | 0 | <p>When you run Spark in <strong>client mode</strong>, the driver process runs <strong>locally</strong>. In <strong>cluster mode</strong>, it runs <strong>remotely</strong> on an ApplicationMaster.</p> <p>In other words you will need all the nodes to see each other. Spark driver definitely needs to communicate with all the worker nodes. If this is a problem try to use the <code>yarn-cluster</code> mode, then the driver will run inside your cluster on one of the nodes.</p> |
3,940,706 | 0 | <p>Use a regex like this:</p> <pre><code>string input = "\"John Smith\" Pocahontas"; Regex rx = new Regex(@"(?<="")[^""]+(?="")|[^\s""]\S*"); for (Match match = rx.Match(input); match.Success; match = match.NextMatch()) { // use match.Value here, it contains the string to be searched } </code></pre> |
36,159,798 | 0 | <p>You can accomplish this with ::before and ::after without knowing the width of container or background color, and to achieve greater styling of the line breaks. For example, this can be modified to make double-lines, dotted lines, etc.</p> <p><a href="https://jsfiddle.net/z8jddc0o/1/">JSFiddle</a></p> <p>CSS, and HTML usage:</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>.hr-sect { display: flex; flex-basis: 100%; align-items: center; color: rgba(0, 0, 0, 0.35); margin: 8px 0px; } .hr-sect::before, .hr-sect::after { content: ""; flex-grow: 1; background: rgba(0, 0, 0, 0.35); height: 1px; font-size: 0px; line-height: 0px; margin: 0px 8px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><div class="hr-sect">CATEGORY</div></code></pre> </div> </div> </p> |
30,586,123 | 0 | elasticsearch bool filter should clause performance <p>first query:</p> <pre><code> { "query" : { "filtered" : { "filter" : { "bool" : { "must" : [ {"term" : {"user1_id" : "1"}}, {"range" : {"day" : {"gte" : "2015-04-01", "lte" : "2015-04-30"}}} ] } } } } </code></pre> <p>In relational SQL, the first query equals to SQL:</p> <pre><code>select * from table where user1_id =1 and (day>=2015-04-01 and day <= 2015-04-30) </code></pre> <p>Second query:</p> <pre><code>{ "query" : { "filtered" : { "filter" : { "bool" : { "should" : [{"term" : {"user1_id" : "1"}}, {"term" : {"user2_id" : "1"}}], "must" : {"range" : {"day" : {"gte" : "2015-04-02", "lte" : "2015-04-30"}} }, "_cache" : true } } } } } </code></pre> <p>In relational SQL, the second query equals to SQL: </p> <pre><code>select * from table where (user1_id =1 or user2_id = 1) and (day>=2015-04-01 and day <= 2015-04-30) </code></pre> <p>The difference is, </p> <p>the first query only considers <code>user1_id</code>, while the second one also check <code>user2_id</code>.</p> <p>both <code>user1_id</code> and <code>user2_id</code> are indexed.</p> <p>However, the performance differs a lot. </p> <p>the first query took 5 seconds, while the second one took 20 seconds.</p> <p>Is there any better way for the second query?</p> <p>Mapping:</p> <pre><code> user1_id: type: "string" index: "not_analyzed" doc_values: true user2_id: type: "string" index: "not_analyzed" doc_values: true day: type: "date" format: "YYYY-MM-dd" ignore_malformed: true doc_values: true </code></pre> <p>If I run the first query twice, the first time is <code>user1_id</code>, the second time is <code>user2_id</code>, then combine two results. It is much faster than using the second query. </p> <p>Have 10 Billion documents in total. AWS, m2.4xlarge, 8 instances in total. </p> <p><code>/usr/bin/java -Xms30g -Xmx30g</code> </p> |
40,095,673 | 0 | Incrontab not processing IF statement <p>First off I'm a Windows guy but getting tasked with Linux now. I am using <code>incrontab</code> to watch a directory on an Oracle Linux server. </p> <p>I am trying to modify it so that if it sees file <code>F078311</code> it will echo Test to the log file. Otherwise it will check to see if the file matches the 2nd format and executes that echo.</p> <p>It is running the 2nd IF and echo'ing the date to the log but is not echoing the Test to the log. Is there something wrong with my syntax? </p> <p>It is watching the <code>/export</code> directory. and <code>$1</code> would be <code>/export/F073811</code></p> <pre><code>incrontab -l /export IN_MODIFY,IN_CLOSE_WRITE,IN_MOVED_TO /usr/local/scripts/EXPrename.sh $@/$# </code></pre> <p>Shell script:</p> <pre><code>#!/bin/bash # This file is invoked using incron and will rename the file with the current date. # Set newdate as current date, YYYYMMDD-HHMMSS newdate="$(date +%Y%m%d-%H%M%S)" #Sets the filename as the filename_YYYYMMDD-HHMMSS filename="A$newdate.txt" joblog="/logs/joblog.log" [[ ( $1 =~ F073811$ ) ]] && echo Test >> /logs/joblog.log #checks to file format to see if it looks like name_YYYYMMDD-HHMMSS. If it does not then it renames the file to that format. [[ ! ( $1 =~ A[0-9]{8}-[0-9]{6}\.txt$ ) ]] && echo ---- `date` ------ >> "$joblog" </code></pre> |
7,405,278 | 0 | DDD: how to keep a complex value object immutable? <p>I'd like to model an <code>Address</code> as a value object. As it is a good practice to make it immutable, I chose not to provide any setter, that might allow to modify it later.</p> <p>A common approach is to pass the data to the constructor; however, when the value object is pretty big, that may become quite bloated:</p> <pre><code>class Address { public function __construct( Point $location, $houseNumber, $streetName, $postcode, $poBox, $city, $region, $country) { // ... } } </code></pre> <p>Another approach whould be to provide the arguments as an array, resulting in a clean constructor, but that might mess up the implementation of the constructor:</p> <pre><code>class Address { public function __construct(array $parts) { if (! isset($parts['location']) || ! $location instanceof Point) { throw new Exception('The location is required'); } $this->location = $location; // ... if (isset($parts['poBox'])) { $this->poBox = $parts['poBox']; } // ... } } </code></pre> <p>That also looks a bit unnatural to me.</p> <p>Any advice on how to correctly implement a pretty big value object?</p> |
34,393,884 | 0 | How to get image URL property from Wikidata item by API? <p>I've made an android app that uses the JSON Google image search API to provide images but I have noticed that Google have stopped supporting it. I have also discovered that Wikidata sometimes provides a image property on some items, however I can't seem to get the URL location of the image using the Wikidata API.</p> <p>Is there any way to get the image URL property from items in Wikidata?</p> |
395,834 | 0 | <p>Be careful of code snippets you find on the web. Often they contain sql in html, which is bad practice, as well as security vulnerabilities such as sql injection. I've seen few that use prepared statements, which is good for security.</p> |
711,966 | 0 | <p>I think you'll have to use an XmlWriter. Or ToString.</p> <p>Just found <a href="http://msdn.microsoft.com/en-us/library/bb387027.aspx" rel="nofollow noreferrer">this article</a> which seems to agree.</p> |
14,819,212 | 0 | before_filter doesn't seem to "kick in" <p>I'm trying to get before_filter to work on the actions that requires the user to be logged in, however something must be wrong because it's not.</p> <p>I use a helper file called 'session_helper.rb' for login/logout as well as for checking if the user is logged in (signed_in?). That works fine if used inside an action or in the view, however while using it with the before_filer it's not working. If I log out the user and try to access '/projects/new' it's possible to do that, while it shouldn't be.</p> <p>What am I doing wrong?</p> <p><strong>project controller:</strong></p> <pre><code>class ProjectsController < ApplicationController before_filter :signed_in?, :except => [:index] // <-- doesn't prevent e.g. the action "new" to be executed def new @project = Project.new @users = (current_user.blank? ? User.all : User.find(:all, :conditions => ["id != ?", current_user.id])) end def index @projects = Project.all if signed_in? // <-- works as it should @users_projects = Project.where(:user_id => current_user.id) end end ... other actions ... end </code></pre> <p><strong>sessions_helper.rb</strong></p> <pre><code>module SessionsHelper def sign_in(user) cookies.permanent[:remember_token] = user.remember_token self.current_user = user end def signed_in? !current_user.nil? end def current_user=(user) @current_user = user end def current_user @current_user ||= User.find_by_remember_token(cookies[:remember_token]) end def sign_out self.current_user = nil cookies.delete(:remember_token) end end </code></pre> |
6,432,324 | 0 | <p>Ooo, a good question :)</p> <p>As far as I know, Mark and Sweep is only used for reference counting event listeners since they're the only ones that can have 'weak listeners'. Everything else is straight up memory reference counting. Essentially, your biggest problem would be cleaning up event listeners, but if the event listeners are within your class (listening to itself, or it's children or even outside events) they should be GC'ed properly if the object is dereferenced throughout your app (don't store it somewhere else).</p> <p>If you let object or properties be publically visible, it is possible for other classes to references them and it could prevent GC of your class (it really depends how it's referenced and all). The only to combat that is to try to encapsulate as much as possible (one class handles it's own dereferencing; look into IDisposable) so that others can't reference and try to adhere to good coding practices (preventing spaghetti code).</p> |
14,214,733 | 0 | XSLT looping though XML to check if value exists <p>XML:</p> <pre><code><amenities> <record> <thekey>77</thekey> <thevalue>Balcony</thevalue> </record> <record> <thekey>75</thekey> <thevalue>Cable</thevalue> </record> <record> <thekey>35</thekey> <thevalue>High Speed Internet</thevalue> </record> <record> <thekey>16</thekey> <thevalue>Fireplace</thevalue> </record> <record> <thekey>31</thekey> <thevalue>Garage</thevalue> </record> <record> <thekey>32</thekey> <thevalue>Phone</thevalue> </record> </amenities> </code></pre> <p>I need to check each record in amenities to find out if "35" (high speed internet) exists. The records in amenities can vary. Sometimes it will have 35 (high speed internet) and sometimes it will not. I need to be able to check this in XSLT.</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.