pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
19,620,613
0
<p>Such error can not be generated by Protector. It probably means that you assign your entity with <code>accept_nested_attributes</code> and it is exactly the instance of UrlType that invalidates, not the assignment of <code>url_type_id</code>.</p>
1,549,527
0
<pre><code>dups = {} newlist = [] for x in biglist: if x['link'] not in dups: newlist.append(x) dups[x['link']] = None print newlist </code></pre> <p>produces</p> <pre><code>[{'link': 'u2.com', 'title': 'U2 Band'}, {'link': 'abc.com', 'title': 'ABC Station'}] </code></pre> <p>Note that here I used a dictionary. This makes the test <code>not in dups</code> much more efficient than using a list.</p>
2,772,434
0
<p>The first thing that comes to my mind is: cellpadding/cellspacing. Try setting each to 0.</p>
15,604,707
0
<p>Adapting basic algorithms like this from Flash to Canvas is actually not that difficult. If you need a canvas framework that's close to the AS3/Flash you can take a look at EaselJS: <a href="http://createjs.com/#!/EaselJS" rel="nofollow">http://createjs.com/#!/EaselJS</a></p> <p>Here's an article on Hexagon Tiles: <a href="http://www.emanueleferonato.com/2008/04/16/understanding-hexagonal-tiles/" rel="nofollow">http://www.emanueleferonato.com/2008/04/16/understanding-hexagonal-tiles/</a></p>
25,109,460
0
Export strings to email body <p>I have searched and I only found a similar question that was unanswered. I have a final report made of answers that have been input throughout the app. Now I've reached the end and I want to, basically, export the report to the email body.</p> <pre><code>package com.toc.maintenancereport; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; public class Report extends Activity { Button sendmail; TextView elec1out, elec2out, elec3out, gasout, waterout, item1out, item2out, item3out, item4out, item5out, item6out, glsout, golfout, candlesout, gu10out, mr16out, g4capsout, fridgeout, cookhoodout, lamp1out, lamp2out, lamp3out, postout, cleanout, ironout, hairdryerout, hooverout, binsout, roofout, garageout, spaceout, outsideout, orderout, siliconeout, handlesout, furnitureout, wallsout, curtainsout, drawsout, itemsout, showerout, holesout, leaksout, tapsout, toiletsout, radout, thermoout, heatingout, wtanksout, hwaterout, boilerout, ovenout, clocksout, bulbsout, name, kettleout, tvout, fblanket, phoneout, fdoor, salarm, fescape, windowsout, consumerout, callout, internetout, issuesout; String reportemail, elec1, elec2, elec3, gas, water, stockitem1, stockitem2, stockitem3, stockitem4, stockitem5, stockitem6, priceitem1, priceitem2, priceitem3, priceitem4, priceitem5, priceitem6, item1, item2, item3, item4, item5, item6, gls, golf, candles, gu10, mr16, g4caps, fridge, cookhood, lamp1, lamp2, lamp3, lamp1price, lamp2price, lamp3price, post, clean, iron, hairdryer, hoover, bins, roof, garage, space, outside, order, silicone, handles, furniture, walls, curtains, draws, items, shower, holes, leaks, taps, toilets, rad, thermo, heating, wtanks, hwater, boiler, oven, clocks, name2, internet, phone, kettle, tv, windows, consumer, firedoor, smokealarm, fireescape, fireblanket, property, date2, dateend, bulbs, issues = ""; String callt1 = ""; String callt2 = ""; String callt3 = ""; String callt4 = ""; String callt5 = ""; String callt6 = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.report); SharedPreferences dados = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); name = (TextView) findViewById(R.id.namereport); fblanket = (TextView) findViewById(R.id.whyfireblanket); fescape = (TextView) findViewById(R.id.whyfireescape); salarm = (TextView) findViewById(R.id.whysmokealarme); fdoor = (TextView) findViewById(R.id.whyfiredoor); callout = (TextView) findViewById(R.id.callouttv); consumerout = (TextView) findViewById(R.id.consumertv); windowsout = (TextView) findViewById(R.id.windowstv); tvout = (TextView) findViewById(R.id.tvtv); kettleout = (TextView) findViewById(R.id.kettletv); phoneout = (TextView) findViewById(R.id.phonetv); internetout = (TextView) findViewById(R.id.internettv); bulbsout = (TextView) findViewById(R.id.bulbstv); clocksout = (TextView) findViewById(R.id.clockstv); ovenout = (TextView) findViewById(R.id.oventv); boilerout = (TextView) findViewById(R.id.boilertv); hwaterout = (TextView) findViewById(R.id.hwatertv); wtanksout = (TextView) findViewById(R.id.wtankstv); heatingout = (TextView) findViewById(R.id.heatingtv); thermoout = (TextView) findViewById(R.id.thermotv); radout = (TextView) findViewById(R.id.radtv); toiletsout = (TextView) findViewById(R.id.toiletstv); tapsout = (TextView) findViewById(R.id.tapstv); leaksout = (TextView) findViewById(R.id.leakstv); holesout = (TextView) findViewById(R.id.holestv); showerout = (TextView) findViewById(R.id.showertv); itemsout = (TextView) findViewById(R.id.itemstv); drawsout = (TextView) findViewById(R.id.drawstv); curtainsout = (TextView) findViewById(R.id.curtainstv); wallsout = (TextView) findViewById(R.id.wallstv); furnitureout = (TextView) findViewById(R.id.furnituretv); handlesout = (TextView) findViewById(R.id.handlestv); siliconeout = (TextView) findViewById(R.id.siliconetv); orderout = (TextView) findViewById(R.id.ordertv); outsideout = (TextView) findViewById(R.id.outsidetv); spaceout = (TextView) findViewById(R.id.spacetv); garageout = (TextView) findViewById(R.id.garagetv); roofout = (TextView) findViewById(R.id.rooftv); binsout = (TextView) findViewById(R.id.binstv); hooverout = (TextView) findViewById(R.id.hoovertv); hairdryerout = (TextView) findViewById(R.id.hairdryertv); ironout = (TextView) findViewById(R.id.irontv); cleanout = (TextView) findViewById(R.id.cleantv); postout = (TextView) findViewById(R.id.posttv); glsout = (TextView) findViewById(R.id.glstv); golfout = (TextView) findViewById(R.id.golftv); candlesout = (TextView) findViewById(R.id.candlestv); gu10out = (TextView) findViewById(R.id.gu10tv); mr16out = (TextView) findViewById(R.id.mr16tv); g4capsout = (TextView) findViewById(R.id.g4capstv); fridgeout = (TextView) findViewById(R.id.fridgetv); cookhoodout = (TextView) findViewById(R.id.choodtv); lamp1out = (TextView) findViewById(R.id.lamp1tv); lamp2out = (TextView) findViewById(R.id.lamp2tv); lamp3out = (TextView) findViewById(R.id.lamp3tv); item1out = (TextView) findViewById(R.id.item1tv); item2out = (TextView) findViewById(R.id.item2tv); item3out = (TextView) findViewById(R.id.item3tv); item4out = (TextView) findViewById(R.id.item4tv); item5out = (TextView) findViewById(R.id.item5tv); item6out = (TextView) findViewById(R.id.item6tv); elec1out = (TextView) findViewById(R.id.meterelec1tv); elec2out = (TextView) findViewById(R.id.meterelec2tv); elec3out = (TextView) findViewById(R.id.meterelec3tv); gasout = (TextView) findViewById(R.id.metergastv); waterout = (TextView) findViewById(R.id.meterwatertv); issuesout = (TextView) findViewById(R.id.issuestv); sendmail=(Button)findViewById(R.id.bdonereport); name2 = dados.getString("Nome", "Nome"); date2 = dados.getString("Date", "dd/MMM/yyyy"); dateend = dados.getString("enddate", "dd/MMM/yyyy"); property = dados.getString("Property", "Property"); callt1 = dados.getString("Job1", ""); callt2 = dados.getString("Job2", ""); callt3 = dados.getString("Job3", ""); callt4 = dados.getString("Job4", ""); callt5 = dados.getString("Job5", ""); callt6 = dados.getString("Job6", ""); name.setText("Name: " + name2 + ". " + "\nTime started: " + date2 + "\nTime ended: " + dateend + "\nProperty: " + property); fireblanket = dados.getString("Whyfireblanket", "Not Checked"); fblanket.setText("*Fire Blanket: " + fireblanket); fireescape = dados.getString("Whyfireescape", "Not Checked"); fescape.setText("*Fire Escape Intructions on Front door and all escape routes clear: " + fireescape); smokealarm = dados.getString("Whysmokealarm", "Not Checked"); salarm.setText("*Smoke alarms are tested and left in working order: " + smokealarm); firedoor = dados.getString("Whyfiredoor", "Not Checked"); fdoor.setText("*Fire doors are closing properly and are not blocked: " + firedoor); consumer = dados.getString("Whyconsumer", "Not Checked"); consumerout .setText("*The consumer unit is OK and everything is working: " + consumer); windows = dados.getString("Whywindows", "Not Checked"); windowsout .setText("*Are the windows opening correctly and in good condition? Are keys in place: " + windows); tv = dados.getString("Whytv", "Not Checked"); tvout.setText("*Are the TV,DVD player and remotes all working: " + tv); kettle = dados.getString("Whykettle", "Not Checked"); kettleout.setText("*Kettle,Toaster and Microwave all working: " + kettle); phone = dados.getString("Whyphone", "Not Checked"); phoneout.setText("*Phone has a dial tone and is barred for outgoing calls: " + phone); internet = dados.getString("Whyinternet", "Not Checked"); internetout .setText("*Is the Internet working with the settings written on the top: " + internet); bulbs = dados.getString("Whybulbs", "Not Checked"); bulbsout.setText("*Are ALL the bulbs working: " + bulbs); clocks = dados.getString("Whyclocks", "Not Checked"); clocksout.setText("*Are ALL the clocks set to the correct time: " + clocks); oven = dados.getString("Whyoven", "Not Checked"); ovenout.setText("*Is the oven working and the time set: " + oven); boiler = dados.getString("Whyboiler", "Not Checked"); boilerout.setText("*Is the pressure on the boiler correct: " + boiler); hwater = dados.getString("Whyhwater", "Not Checked"); hwaterout .setText("*Is the hot water working and at a good temperature: " + hwater); wtanks = dados.getString("Whywtanks", "Not Checked"); wtanksout.setText("*Are the water tanks full: " + wtanks); heating = dados.getString("Whyheating", "Not Checked"); heatingout.setText("*Is the Heating working in every room: " + heating); thermo = dados.getString("Whythermo", "Not Checked"); thermoout .setText("*Is the thermostat set to 18° (winter and if a guest is moving in) or off(summer or no guest): " + thermo); rad = dados.getString("Whyrad", "Not Checked"); radout.setText("*Are the rad controls correct?: " + rad); toilets = dados.getString("Whytoilets", "Not Checked"); toiletsout.setText("*Are the toilets flushing correctly: " + toilets); taps = dados.getString("Whytaps", "Not Checked"); tapsout.setText("*Are the tap washers/o-rings OK: " + taps); leaks = dados.getString("Whyleaks", "Not Checked"); leaksout.setText("*Are there any leaks(under the sinks, behind the toilets, around the showers, etc.): " + leaks); holes = dados.getString("Whyholes", "Not Checked"); holesout.setText("*Are all plug holes draining well: " + holes); shower = dados.getString("Whyshower", "Not Checked"); showerout .setText("*Are all showers working well, no leaks and shower heads in good order: " + shower); items = dados.getString("Whyitems", "Not Checked"); itemsout.setText("*Are there any items in the property that should not be there: " + items); draws = dados.getString("Whydraws", "Not Checked"); drawsout.setText("*Have all the draws and cupboards been opened to make sure they are OK: " + draws); curtains = dados.getString("Whycurtains", "Not Checked"); curtainsout .setText("*Are the curtains and blinds opening and closing correctly and fixed well: " + curtains); walls = dados.getString("Whywalls", "Not Checked"); wallsout.setText("*Are the carpets, upholstry and walls in good condition: " + walls); furniture = dados.getString("Whyfurniture", "Not Checked"); furnitureout.setText("*Is the furniture all in good order: " + furniture); handles = dados.getString("Whyhandles", "Not Checked"); handlesout .setText("*Are the door handles and locks working and not loose: " + handles); silicone = dados.getString("Whysilicone", "Not Checked"); siliconeout .setText("*Is the silicone in the bathrooms and kitchen in good order: " + silicone); order = dados.getString("Whyorder", "Not Checked"); orderout.setText("*Is the furniture positioned correctly: " + order); outside = dados.getString("Whyoutside", "Not Checked"); outsideout .setText("*Is the outside of the property clean and in order: " + outside); space = dados.getString("Whyspace", "Not Checked"); spaceout.setText("*Is the parking space empty and clearly marked: " + space); garage = dados.getString("Whygarage", "Not Checked"); garageout.setText("*Is the garage clean and clear: " + garage); roof = dados.getString("Whyroof", "Not Checked"); roofout.setText("*Are the gutters clear, roof OK, Brickwork OK, Window seals OK: " + roof); bins = dados.getString("Whybins", "Not Checked"); binsout.setText("*Are the bins are empty and clear: " + bins); hoover = dados.getString("Whyhoover", "Not Checked"); hooverout.setText("*Hoover working and empty: " + hoover); hairdryer = dados.getString("Whyhairdryer", "Not Checked"); hairdryerout.setText("*Hairdryer working: " + hairdryer); iron = dados.getString("Whyiron", "Not Checked"); ironout.setText("*Iron working: " + iron); clean = dados.getString("Whyclean", "Not Checked"); cleanout.setText("*Are the windows clean outside: " + clean); post = dados.getString("Whypost", "Not Checked"); postout.setText("*Collected all post from the property and postbox: " + post); gls = dados.getString("GLS", "0"); glsout.setText("*GLS: " + gls); golf = dados.getString("Golf", "0"); golfout.setText("*Golf: " + golf); candles = dados.getString("Candles", "0"); candlesout.setText("*Candles: " + candles); gu10 = dados.getString("GU-10", "0"); gu10out.setText("*GU-10: " + gu10); mr16 = dados.getString("MR-16", "0"); mr16out.setText("*MR-16: " + mr16); g4caps = dados.getString("G4-Caps", "0"); g4capsout.setText("*G4-Caps: " + g4caps); fridge = dados.getString("Fridge", "0"); fridgeout.setText("*Fridge: " + fridge); cookhood = dados.getString("Cooker_Hood", "0"); cookhoodout.setText("*Cooker Hood: " + cookhood); lamp1 = dados.getString("lamp1", "0"); lamp1price = dados.getString("lamp1price", "0"); lamp1out.setText("*Other lamp: " + lamp1 + ". Cost " + lamp1price + "£"); lamp2 = dados.getString("lamp2", "0"); lamp2price = dados.getString("lamp2price", "0"); lamp2out.setText("*Other lamp: " + lamp2 + ". Cost " + lamp2price + "£"); lamp3 = dados.getString("lamp3", "0"); lamp3price = dados.getString("lamp3price", "0"); lamp3out.setText("*Other lamp: " + lamp3 + ". Cost " + lamp3price + "£"); item1 = dados.getString("item1", ""); priceitem1 = dados.getString("price1", ""); stockitem1 = dados.getString("stock1", ""); item1out.setText("*Item: " + item1 + ". Price: " + priceitem1 + "£. Stock:" + stockitem1 + "£."); item2 = dados.getString("item2", ""); priceitem2 = dados.getString("price2", ""); stockitem2 = dados.getString("stock2", ""); item2out.setText("*Item: " + item2 + ". Price: " + priceitem2 + "£. Stock:" + stockitem2 + "£."); item3 = dados.getString("item3", ""); priceitem3 = dados.getString("price3", ""); stockitem3 = dados.getString("stock3", ""); item3out.setText("*Item: " + item3 + ". Price: " + priceitem3 + "£. Stock:" + stockitem3 + "£."); item4 = dados.getString("item4", ""); priceitem4 = dados.getString("price4", ""); stockitem4 = dados.getString("stock4", ""); item4out.setText("*Item: " + item4 + ". Price: " + priceitem4 + "£. Stock:" + stockitem4 + "£."); item5 = dados.getString("item5", ""); priceitem5 = dados.getString("price5", ""); stockitem5 = dados.getString("stock5", ""); item5out.setText("*Item: " + item5 + ". Price: " + priceitem5 + "£. Stock:" + stockitem5 + "£."); item6 = dados.getString("item6", ""); priceitem6 = dados.getString("price6", ""); stockitem6 = dados.getString("stock6", ""); item6out.setText("*Item: " + item6 + ". Price: " + priceitem6 + "£. Stock:" + stockitem6 + "£."); elec1 = dados.getString("elec1", "0"); elec1out.setText("*Elec1: " + elec1); elec2 = dados.getString("elec2", "0"); elec2out.setText("*Elec2: " + elec2); elec3 = dados.getString("elec3", "0"); elec3out.setText("*Elec3: " + elec3); gas = dados.getString("gas", "0"); gasout.setText("*Gas: " + gas); water = dados.getString("water", "0"); waterout.setText("*Water: " + water); issues = dados.getString("issues", "none"); issuesout.setText("*Side note: " + issues); if (callt1.equals("") &amp;&amp; callt2.equals("") &amp;&amp; callt3.equals("") &amp;&amp; callt4.equals("") &amp;&amp; callt5.equals("") &amp;&amp; callt6.equals("")) { callout.setText("No Jobs done."); } else if (!callt1.equals("") &amp;&amp; !callt2.equals("") &amp;&amp; !callt3.equals("") &amp;&amp; !callt4.equals("") &amp;&amp; !callt5.equals("") &amp;&amp; callt6.equals("")) { callout.setText("Jobs done:\n1." + callt1 + "\n2." + callt2 + "\n3." + callt3 + "\n4." + callt4 + "\n5." + callt5); } else if (!callt1.equals("") &amp;&amp; !callt2.equals("") &amp;&amp; !callt3.equals("") &amp;&amp; !callt4.equals("") &amp;&amp; callt5.equals("") &amp;&amp; callt6.equals("")) { callout.setText("Jobs done:\n1." + callt1 + "\n2." + callt2 + "\n3." + callt3 + "\n4." + callt4); } else if (!callt1.equals("") &amp;&amp; !callt2.equals("") &amp;&amp; !callt3.equals("") &amp;&amp; callt4.equals("") &amp;&amp; callt5.equals("") &amp;&amp; callt6.equals("")) { callout.setText("Jobs done:\n1." + callt1 + "\n2." + callt2 + "\n3." + callt3); } else if (!callt1.equals("") &amp;&amp; !callt2.equals("") &amp;&amp; callt3.equals("") &amp;&amp; callt4.equals("") &amp;&amp; callt5.equals("") &amp;&amp; callt6.equals("")) { callout.setText("Jobs done:\n1." + callt1 + "\n2." + callt2); } else if (!callt1.equals("") &amp;&amp; callt2.equals("") &amp;&amp; callt3.equals("") &amp;&amp; callt4.equals("") &amp;&amp; callt5.equals("") &amp;&amp; callt6.equals("")) { callout.setText("Jobs done:\n1." + callt1); } else { callout.setText("Jobs done:\n1." + callt1 + "\n2." + callt2 + "\n3." + callt3 + "\n4." + callt4 + "\n5." + callt5 + "\n6." + callt6); reportemail="funny"; } sendmail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent sendmail = new Intent(Intent.ACTION_SEND); sendmail.setData(Uri.parse("mailto:")); sendmail.setType("text/html"); sendmail.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); sendmail.putExtra(Intent.EXTRA_SUBJECT, "Report"); //here is where my problem begins: I want to fill the body with the details above but I cannot find a way. sendmail.putExtra(Intent.EXTRA_TEXT , ); startActivity(Intent.createChooser(sendmail, "Send mail...")); finish(); Log.i("Finished sending email...", ""); } }); } } </code></pre>
5,126,721
0
Rails not reloading session on ajax post <p>I'm experiencing a very strange problem with Rails and ajax using jQuery (although I don't think it's specific to jQuery).</p> <p>My Rails application uses the cookie session store, and I have a very simple login that sets the user id in the session. If the user_id isn't set in the session, it redirects to a login page. This works with no problems. JQuery GET requests work fine too. The problem is when I do a jQuery POST - the browser sends the session cookie ok (I confirmed this with Firebug and dumping request.cookies to the log) but the session is blank, i.e. session is {}.</p> <p>I'm doing this in my application.js:</p> <pre><code>$(document).ajaxSend(function(e, xhr, options) { var token = $("meta[name='csrf-token']").attr('content'); xhr.setRequestHeader('X-CSRF-Token', token); }); </code></pre> <p>and here is my sample post:</p> <pre><code>$.post('/test/1', { _method: 'delete' }, null, 'json'); </code></pre> <p>which should get to this controller method (_method: delete):</p> <pre><code>def destroy respond_to do |format| format.json { render :json =&gt; { :destroyed =&gt; 'ok' }.to_json } end end </code></pre> <p>Looking at the log and using Firebug I can confirm that the correct cookie value is sent in the request header when the ajax post occurs, but it seems that at some point Rails loses this value and therefore loses the session, so it redirects to the login page and never gets to the method.</p> <p>I've tried everything I can think of to debug this but I'm coming around to the idea that this might be a bug in Rails. I'm using Rails 3.0.4 and jQuery 1.5 if that helps. I find it very strange that regular (i.e. non-ajax) get and post requests work, and ajax get requests work with no problems, it's just the ajax posts that don't.</p> <p>Any help in trying to fix this would be greatly appreciated!</p> <p>Many thanks,<br> Dave</p>
18,079,494
0
<p>First of all, a service does not imply that a separate thread is running, but I guess this is what you want to do. If you run several threads, there is no way of the AndroidOS to terminate them besides killing the whole Dalvik VM. And this means that you have no way of knowing when you are about to be terminated. If you have a service with a thread and use proper life-cycle management, i.e. kill the thread when Android notifies the service that it is about to stop it, then it is easy to maintain state.</p> <p>Regarding your question: use several services with one thread each</p>
28,377,503
0
Why is CoreLocation (Mac OS X) not remembering my choice to allow its use? <p>I'm probably being very stupid, but I can't work out why the following is happening:</p> <p>I have an app on Mac OS X which uses CoreLocation. Below is the the relevant code:</p> <p>It asks for permission to use my location every time it launches and never remembers that I have already granted use of location data.</p> <p>The app never appears in the 'Privacy' Preference pane.</p> <p>Am I missing something?</p> <p>Thanks.</p> <pre><code>#pragma mark - General Instance Methods - (void)determineLocation { if (self.locationManager) { DDLogWarn(@"determinLocation called, but we already have a locationManager instance variable..."); DDLogWarn(@"This is a bug."); } self.currentlocationName = @"Location unknown"; if (![CLLocationManager locationServicesEnabled]) { DDLogWarn(@"Location Services not enabled."); [self fallBackToHardcodedLocation]; return; } // Location services are available. self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; // Coarse-grained location accuracy required. self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; self.locationManager.distanceFilter = 1000; // meters - 1km [self.locationManager startUpdatingLocation]; } #pragma mark - Location Manager Delegate Methods - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { DDLogVerbose(@"Our authorisation to use the location manager has changed."); switch (status) { case kCLAuthorizationStatusNotDetermined: DDLogError(@"LocationManager Authorisation status not determined. (User hasn't chosen yet)"); break; case kCLAuthorizationStatusAuthorized: DDLogVerbose(@"We are now authorised for locationServices."); [self.locationManager startUpdatingLocation]; break; case kCLAuthorizationStatusDenied: DDLogWarn(@"LocationManager: We are now explicitly denied!"); [self.locationManager stopUpdatingLocation]; break; case kCLAuthorizationStatusRestricted: DDLogWarn(@"LocationManager We are now restricted! (not authorised - perhaps due to parental controls...)"); [self.locationManager stopUpdatingLocation]; break; default: break; } } - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { // Main callback for location discovery..§ CLLocation* location = [locations lastObject]; NSDate* eventDate = location.timestamp; NSTimeInterval howRecent = [eventDate timeIntervalSinceNow]; if (abs(howRecent) &lt; 15.0) { // Event is recent. Do something with it. if (location.horizontalAccuracy &gt; 1000) { DDLogWarn(@"Location Accuracy is worse than 1km, discarding..."); } else { [self updateLocation:location]; } return; } DDLogWarn(@"Stale location data..."); [self updateLocation:location]; } </code></pre> <p>It always asks permission: (kCLAuthorizationStatusNotDetermined appears to always be the case.)</p> <pre><code> 2015-02-07 01:03:36:127 Central Heating[2260:30b] LocationManager Authorisation status not determined. (User hasn't chosen yet) </code></pre> <p><img src="https://i.stack.imgur.com/daigk.png" alt="CoreLocation permission always asked"> (Dialog text: "Central Heating" would like to use your current location. Your location is needed for weather forecasting. [Don't allow] [OK])</p>
13,504,438
0
<p>If you want to install a Chrome extension via other software, <a href="http://developer.chrome.com/extensions/external_extensions.html" rel="nofollow">this might help</a>.</p> <p>However, I believe that the user now has to approve the installation under the Wrench icon.</p>
14,886,455
0
<p>In PHP, much like HTML, a line-break/carriage return is generally just used to make your text more legible. This is so that future code edits are simple an easy to make. </p> <p>Not sure if this is completely relevant but I've found another post which relates to PHP formatting: <a href="http://stackoverflow.com/questions/3350560/php-coding-style-best-practices">PHP Coding style - Best practices</a></p>
4,467,302
0
<p>You may remove that page with no problems. However, you will have to supply the WSDL to your clients in some other manner. You can simply post the WSDL to some secure area of your web site, or even email it to them.</p>
621,411
0
Setting maximum number of Columns for ListView <p>How do we fix the maximum number of columns for a particular ListView control? Is there any thing like this:</p> <pre><code>listViewControl.MaximumColumns = 3; </code></pre>
3,667,781
0
<p>(My second attempt at the answer.)</p> <p>This is rather an elaboration of Anthony Williams's answer.</p> <p>Both iterators that you need are available in the Boost libraries (your own myIter is lacking functionality which may make your code uncompilable with other compilers).</p> <pre><code>#include &lt;set&gt; #include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;boost/iterator/counting_iterator.hpp&gt; #include &lt;boost/iterator/transform_iterator.hpp&gt; #include &lt;boost/mem_fn.hpp&gt; struct point { point(int X, int Y):x(X), y(Y){} int x; int y; }; bool operator&lt; (const point&amp; a, const point&amp; b) { return a.x &lt; b.x || (a.x == b.x &amp;&amp; a.y &lt; b.y); } int main() { std::set &lt;point&gt; myset; myset.insert(point(1, 1)); myset.insert(point(3, 2)); myset.insert(point(5, 3)); //find the missing elements in set for `point.x` using `set_difference` std::set&lt;int&gt; missing; using namespace boost; std::set_difference( counting_iterator&lt;int&gt;(myset.begin()-&gt;x+1), counting_iterator&lt;int&gt;(myset.rbegin()-&gt;x), make_transform_iterator( myset.begin(), mem_fn(&amp;point::x)), make_transform_iterator( myset.end(), mem_fn(&amp;point::x)), std::inserter(missing, missing.begin())); std::copy(missing.begin(), missing.end(), std::ostream_iterator&lt;int&gt;(std::cout, " ")); } </code></pre> <p>Points of interest:</p> <ul> <li><code>point</code> needs to be "less-than" comparable, if you want to store them in a <code>set</code></li> <li><code>boost::counting_iterator</code> is a better <code>myIter</code></li> <li><code>boost::transform_iterator</code> allows you to apply a function to the value when dereferenced. In combination with <code>boost::mem_fn</code> it obtains the <code>Point::x</code> member when the iterator is dereferenced.</li> <li>use the helper function <code>std::inserter</code> to get the template arguments deduced</li> <li>the results don't have to be stored in a <code>set</code> (neither does the input have to come from a <code>set</code>, as long as the range is sorted with respect to the used predicate - here comparing the x member.</li> </ul>
33,817,217
0
Using ffserver to do UDP multicast streaming <p>Here's the deal. I'm working with IPTV hardware and I need to output a bunch of demo streams. These are MPEG2 transport stream that need to be straight up UDP Multicast streams. I have an ffmpeg command that works great:</p> <p><code>ffmpeg -re -i /Volumes/Data/DemoVideos/GRAILrpsp.ts -acodec copy -vcodec copy -f mpegts udp://239.192.1.82:12000[ttl=1,buffer_size=2097157] </code></p> <p>What I would like to do is convert this into an ffserver config file instead of having to start a whole bunch of ffmpeg streams and then figuring out how to get them to loop. I'm sure I can do it with the right scripting but what a pain, isn't that what ffserver is for? But I can't find any documentation on doing UDP streaming using ffserver. You can set a multicast address and port but it goes to RTP which this hardware isn't designed for. Any help would be greatly appreciated.</p>
7,159,977
0
<p>No a handler is a separate object class and so one would not need to be defined if you were making an Activity.</p> <p><a href="http://developer.android.com/reference/android/app/Activity.html" rel="nofollow">Activity</a></p> <p>A handler would be used if you wanted to go do something in another thread/class and call back to the activity/ui.</p> <p><a href="http://developer.android.com/reference/android/os/Handler.html" rel="nofollow">Handler</a></p>
34,277,206
0
<p>kaylum answered perfectly when you split your project in more than a source file (the .c files) you have to compile them all into an object file (the .o files) then the compiler can merge your object file in an exec file.</p> <p>the undefined reference error means that your program use something that has not been compiled.</p> <p>gcc func.c main.c -o this option specify that the two source file will be compiled in the same object file so there will the reference of the function that you call in your program.</p>
12,801,510
0
<p>It's still a regular many-to-many relationship, and it should get mapped correctly by default. Specific business (validation) rules do not change its nature.</p> <p>You can implement <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.ivalidatableobject.aspx" rel="nofollow">IValidatableObject</a> if you want to enforce specific cardinalities when saving.</p>
6,114,867
0
<p>For your custom classes to return a stable hash code you should override the GetHashCode() method or else the GetHashCode method of the Object class will be used, which I think can vary a lot. (Might even be instance specific).</p>
1,919,672
0
<p>If <code>c_str()</code> is returning to you a copy of the string object internal buffer, you can just use <code>const_cast&lt;&gt;</code>.</p> <p>However, if <code>c_str()</code> is giving you direct access tot he string object internal buffer, make an explicit copy, instead of removing the const.</p>
19,119,459
0
<p>Try the following:</p> <pre><code>saySomething | Tee-Object -Variable something </code></pre> <p>This should work exactly as you want.</p>
23,104,433
0
<p>There is no built in method in pandas I can think of, you would have to save the original df prior to the update and then compare, the trick is to ensure that <code>NaN</code> comparisons are treated the same as non-zero values, here df3 is a copy of df prior to the call to update:</p> <pre><code>In [104]: df.update(df2) df Out[104]: A B C D E axis1 A NaN NaN NaN NaN 1 Apple 1 NaN NaN 1 1 Linux 1 1 1 NaN 1 Unix 1 1 NaN 1 1 Window 1 NaN 1 NaN NaN [5 rows x 5 columns] In [105]: df3 Out[105]: A B C D E axis1 A NaN NaN NaN NaN NaN Apple 1 NaN NaN 1 NaN Linux 1 1 1 NaN NaN Unix 1 1 NaN 1 NaN Window NaN NaN 1 NaN NaN [5 rows x 5 columns] In [106]: # compare but notice that NaN comparison returns True df!=df3 Out[106]: A B C D E axis1 A True True True True True Apple False True True False True Linux False False False True True Unix False False True False True Window True True False True True [5 rows x 5 columns] In [107]: # use numpy count_non_zero for easy counting, note this gives wrong result np.count_nonzero(df!=df3) Out[107]: 16 In [132]: ~((df == df3) | (np.isnan(df) &amp; np.isnan(df3))) Out[132]: A B C D E axis1 A False False False False True Apple False False False False True Linux False False False False True Unix False False False False True Window True False False False False [5 rows x 5 columns] In [133]: np.count_nonzero(~((df == df3) | (np.isnan(df) &amp; np.isnan(df3)))) Out[133]: 5 </code></pre>
30,631,276
0
if ($_server request_method == post ) don't work when form post <p>I have a form for register and I used <code>securimage</code> captcha in my project. When I want echo something after <code>session_start();</code> like <code>print_r($_post)</code> result is <code>array()</code> but when I comment all <code>if</code> condition that's work, why? And when I submit my form to this page but for this condition don't submit just page refresh: </p> <pre><code>if ($_server request_method == post )//stop here don't go inside if condition </code></pre> <p>And this is my <code>register.php</code> page codes:</p> <pre><code>&lt;?PHP session_start(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { include_once dirname(__FILE__).'/process/dbconfig.php'; $flag=true; echo"Asb"; if(isset($_POST['captcha_code'])){ include_once dirname(__FILE__) . '/captcha/securimage.php'; $captcha = $_POST['captcha_code']; $image = new Securimage(); echo $_POST['captcha_code']; if ($image-&gt;check($_POST['captcha_code'] ) == false) { $flag=false; $_SESSION['caperr']='Invalid captcha code'; //$err='Invalid captcha code'; header('Location: '.'reister.php'); } //print_r($_SESSION['caperr']); if(isset($_POST['firstname']) &amp;&amp; isset($_POST['lastname']) &amp;&amp; isset($_POST['username']) &amp;&amp; isset($_POST['password1']) &amp;&amp; isset($_POST['password2']) &amp;&amp; isset($_POST['day']) &amp;&amp; isset($_POST['year']) &amp;&amp; isset($_POST['month']) &amp;&amp; isset($_POST['cell']) &amp;&amp; isset($_POST['agree']) &amp;&amp; isset($_POST['gen']) &amp;&amp; ($_POST['password1']==$_POST['password2']) &amp;&amp; $flag &amp;&amp; isset($_POST['agree'])){ $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password); $sql = $conn-&gt;prepare('Insert into users(firstname,lastname,username,password,birthday,gender,phone)values(:firstname,:lastname,:user,:pass,:birth,:gen,:phone)'); $user=$_POST['username']; $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $pass=md5($_POST['password1']); $birth=$_POST['day'].'-'.$_POST['month'].'-'.$_POST['year']; $gen=$_POST['gen']; $phone=$_POST['cell']; $sql-&gt;bindParam(':user',$user,PDO::PARAM_STR,60); $sql-&gt;bindParam(':firstname',$firstname,PDO::PARAM_STR,50); $sql-&gt;bindParam(':lastname',$lastname,PDO::PARAM_STR,80); $sql-&gt;bindParam(':pass',$pass,PDO::PARAM_STR,60); $sql-&gt;bindParam(':gen',$gen,PDO::PARAM_BOOL); $sql-&gt;bindParam(':birth',$birth,PDO::PARAM_STR,10); $sql-&gt;bindParam(':phone',$phone,PDO::PARAM_STR,11); if($sql-&gt;execute()){ $_SESSION['success']='Your register is successful! '; } } else{ if(!($_POST['password1']==$_POST['password2'])){ $_SESSION['errsubmitp']='Your passwords must same!'; } else $_SESSION['errsubmit']='Please fill all inputs!'; $_SESSION['caperr']='Invalid captcha code'; header('Location: '.'reister.php'); } } else{ echo "uuuuuuuuuuuuuuuuuuu"; $_SESSION['captchafill']='Please Fill captcha code'; header('Location: '.'reister.php'); } } ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Register&lt;/title&gt; &lt;link href="content/css/main.css" rel="stylesheet" /&gt; &lt;script src="content/js/jquery.js"&gt;&lt;/script&gt; &lt;script src="content/js/jBox.min.js"&gt;&lt;/script&gt; &lt;link href="content/css/jBox.css" rel="stylesheet" /&gt; &lt;script src="content/js/icheck.js"&gt;&lt;/script&gt; &lt;link href="content/css/minimal.css" rel="stylesheet" /&gt; &lt;script src="content/js/js.js"&gt;&lt;/script&gt; &lt;link href="content/css/chosen.min.css" rel="stylesheet" /&gt; &lt;script src="content/js/chosen.jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="page"&gt; &lt;div id="head"&gt; &lt;h2&gt;Create your account&lt;/h2&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="lefthalf"&gt; &lt;span id="ajax_user" class="ajax_username"&gt;&lt;/span&gt; &lt;?php if(isset($_SESSION['success'])) {?&gt; &lt;div id="success" style="height: 60px;background-color: #53a642; text-align: center;"&gt; &lt;div&gt; &lt;p style=" margin-left: 62px; float: left;"&gt;&lt;?= $_SESSION['success']?&gt;&lt;/p&gt; &lt;a href="login.php" style="text-decoration: none;color: #ff0; margin-left: 7px; margin-top: 15px; float: left;"&gt;Login&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php unset($_SESSION['success']); }?&gt; &lt;form action="register.php" method="post"&gt; &lt;?php if(isset($_SESSION['errsubmit'])){ ?&gt; &lt;span id="all"&gt;&lt;?=$_SESSION['errsubmit'];?&gt;&lt;/span&gt; &lt;?php unset($_SESSION['errsubmit']); }?&gt; &lt;div id="name"&gt; &lt;label&gt;Name&lt;/label&gt; &lt;input type="text" class="tooltip" name="firstname" placeholder="First" id="first" title="Please Enter Your FirstName!" style="margin-right:10px;" /&gt; &lt;input type="text" class="tooltip" name="lastname" placeholder="Last" id="last" title="Please Enter Your LastName!" /&gt; &lt;span id="firsterr"&gt;&lt;/span&gt; &lt;span id="lasterr"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div id="username"&gt; &lt;label&gt;Choose your username&lt;/label&gt; &lt;input type="text" id="usernamef" name="username" class="tooltip" title="Please Enter Your UserName!" placeholder="Enter Username" /&gt; &lt;span id="usernameerr" class="tooltip"&gt;&lt;/span&gt; &lt;span id="valid"&gt;&lt;/span&gt; &lt;label&gt;Create a password&lt;/label&gt; &lt;input type="password" name="password1" id="pass" class="tooltip" title="Please Enter Your Password!" placeholder="Enter Your password" /&gt; &lt;span id="passerr"&gt;&lt;/span&gt; &lt;label&gt;Confirm your password&lt;/label&gt; &lt;input type="password" id="conf" name="password2" class="tooltip" title="Please Confirm Your Password!" placeholder="Confirm Your password" /&gt; &lt;span id="conferr"&gt;&lt;/span&gt; &lt;?php if(isset($_SESSION['errsubmitp'])){?&gt; &lt;span id="confierr2"&gt;&lt;?=$_SESSION['errsubmitp'];?&gt;&lt;/span&gt; &lt;?php unset($_SESSION['errsubmitp']); }?&gt; &lt;span id="confierr"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div id="born"&gt; &lt;label&gt;Birthday&lt;/label&gt; &lt;div id="test"&gt; &lt;select class="my_select_box chosen-select-no-results" tabindex="-1" id="month" data-placeholder="Month" name="month"&gt; &lt;option&gt;&lt;/option&gt; &lt;option value="1"&gt;January&lt;/option&gt; &lt;option value="2"&gt;February&lt;/option&gt; &lt;option value="3"&gt;March&lt;/option&gt; &lt;option value="4"&gt;April&lt;/option&gt; &lt;option value="5"&gt;May&lt;/option&gt; &lt;option value="6"&gt;June&lt;/option&gt; &lt;option value="7"&gt;July&lt;/option&gt; &lt;option value="8"&gt;August&lt;/option&gt; &lt;option value="9"&gt;September&lt;/option&gt; &lt;option value="10"&gt;October&lt;/option&gt; &lt;option value="11"&gt;November&lt;/option&gt; &lt;option value="12"&gt;December&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;input type="text" placeholder="Day" name="day" id="day" class="tooltip" title="Please Enter Your Born Day!" maxlength="2" onkeydown="prevent('#day');" /&gt; &lt;input type="text" placeholder="Year" name="year" id="year" class="tooltip" title="Please Enter Your Born Year!" maxlength="4" onkeydown="prevent('#year');" /&gt; &lt;span id="montherr"&gt;&lt;/span&gt; &lt;span id="dayerr"&gt;&lt;/span&gt; &lt;span id="yearerr"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div id="info"&gt; &lt;label&gt;Gender&lt;/label&gt; &lt;select id="gen" class="my_select_box chosen-select-no-results" name="gen"&gt; &lt;option value="13"&gt;I am ...&lt;/option&gt; &lt;option value="Male"&gt;Male&lt;/option&gt; &lt;option value="Fmale"&gt;Fmale&lt;/option&gt; &lt;/select&gt; &lt;span id="gendererr"&gt;&lt;/span&gt; &lt;label&gt;Mobile phone&lt;/label&gt; &lt;div id="cell"&gt; &lt;span&gt;+98&lt;/span&gt; &lt;input type="tel" id="tel" name="cell" class="tooltip" title="Please Enter Your Mobile!" maxlength="11" onkeydown="prevent('#tel');" /&gt; &lt;/div&gt; &lt;span id="tellerr"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div id="captcha1"&gt; &lt;img id="captcha" src="captcha/securimage_show.php" alt="Captcha Image"/&gt; &lt;br/&gt; &lt;input type="text" name="captcha_code" size="6" maxlength="6" id="captcha_code"/&gt; &lt;br/&gt; &lt;a href="#" onclick="document.getElementById('captcha').src='captcha/securimage_show.php?'+Math.random();return false;"&gt;AAA&lt;/a&gt; &lt;/div&gt; &lt;?php if(isset($_SESSION['captchafill'])){?&gt; &lt;span id="chaperr1"&gt;&lt;?php $_SESSION['captchafill'];?&gt;&lt;/span&gt; &lt;?php }unset($_SESSION['captchafill']);?&gt; &lt;span id="chaperr"&gt;&lt;/span&gt; &lt;div id="agree"&gt; &lt;input type="checkbox" id="agg" name="agree"/&gt; &lt;span style="margin-left:5px;"&gt;I agree to the term of services ...&lt;/span&gt; &lt;/div&gt; &lt;div id="register"&gt; &lt;input type="submit" value="Register" id="reg" disabled="disabled" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I see same question but any of theme has my question answer. Please help me to handle this problem. I echo <code>var_dump($_SERVER)</code> before <code>if ($_SERVER['REQUEST_METHOD'] == 'post')</code> and this is my result:</p> <pre><code>array(45) { ["MIBDIRS"]=&gt; string(24) "C:/xampp/php/extras/mibs" ["MYSQL_HOME"]=&gt; string(16) "\xampp\mysql\bin" ["OPENSSL_CONF"]=&gt; string(31) "C:/xampp/apache/bin/openssl.cnf" ["PHP_PEAR_SYSCONF_DIR"]=&gt; string(10) "\xampp\php" ["PHPRC"]=&gt; string(10) "\xampp\php" ["TMP"]=&gt; string(10) "\xampp\tmp" ["HTTP_HOST"]=&gt; string(14) "localhost:8181" ["HTTP_CONNECTION"]=&gt; string(10) "keep-alive" ["CONTENT_LENGTH"]=&gt; string(3) "207" ["HTTP_CACHE_CONTROL"]=&gt; string(9) "max-age=0" ["HTTP_ACCEPT"]=&gt; string(74) "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" ["HTTP_ORIGIN"]=&gt; string(21) "http://localhost:8181" ["HTTP_USER_AGENT"]=&gt; string(113) "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36" ["CONTENT_TYPE"]=&gt; string(33) "application/x-www-form-urlencoded" ["HTTP_REFERER"]=&gt; string(36) "http://localhost:8181/a2/reister.php" ["HTTP_ACCEPT_ENCODING"]=&gt; string(13) "gzip, deflate" ["HTTP_ACCEPT_LANGUAGE"]=&gt; string(23) "en-US,en;q=0.8,fa;q=0.6" ["HTTP_COOKIE"]=&gt; string(36) "PHPSESSID=knkseus8v498m0p1au7q84lqd4" ["PATH"]=&gt; string(1170) "C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;E:\SoftWare\Programming soft\JaVa\android\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;E:\SoftWare\Programming soft\JaVa\android\adt-bundle-windows-x86_64-20131030\sdk\tools;C:\Program Files (x86)\Java\jdk1.6.0_45\bin;C:\Program Files\nodejs\;C:\Users\Farshid\Downloads\Compressed\apache-ant-1.9.4\bin;C:\Program Files\nodejs;C:\Program Files (x86)\Java\jdk1.6.0_45\bin;C:\Users\Farshid\AppData\Local\Code\bin;C:\Users\Farshid\AppData\Roaming\npm;C:\Program Files (x86)\Git\bin" ["SystemRoot"]=&gt; string(10) "C:\Windows" ["COMSPEC"]=&gt; string(27) "C:\Windows\system32\cmd.exe" ["PATHEXT"]=&gt; string(53) ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" ["WINDIR"]=&gt; string(10) "C:\Windows" ["SERVER_SIGNATURE"]=&gt; string(96) " Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 Server at localhost Port 8181 " ["SERVER_SOFTWARE"]=&gt; string(46) "Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3" ["SERVER_NAME"]=&gt; string(9) "localhost" ["SERVER_ADDR"]=&gt; string(3) "::1" ["SERVER_PORT"]=&gt; string(4) "8181" ["REMOTE_ADDR"]=&gt; string(3) "::1" ["DOCUMENT_ROOT"]=&gt; string(15) "C:/xampp/htdocs" ["REQUEST_SCHEME"]=&gt; string(4) "http" ["CONTEXT_PREFIX"]=&gt; string(0) "" ["CONTEXT_DOCUMENT_ROOT"]=&gt; string(15) "C:/xampp/htdocs" ["SERVER_ADMIN"]=&gt; string(20) "postmaster@localhost" ["SCRIPT_FILENAME"]=&gt; string(30) "C:/xampp/htdocs/a2/Reister.php" ["REMOTE_PORT"]=&gt; string(5) "24763" ["GATEWAY_INTERFACE"]=&gt; string(7) "CGI/1.1" ["SERVER_PROTOCOL"]=&gt; string(8) "HTTP/1.1" ["REQUEST_METHOD"]=&gt; string(4) "POST" ["QUERY_STRING"]=&gt; string(0) "" ["REQUEST_URI"]=&gt; string(15) "/a2/reister.php" ["SCRIPT_NAME"]=&gt; string(15) "/a2/reister.php" ["PHP_SELF"]=&gt; string(15) "/a2/reister.php" ["REQUEST_TIME_FLOAT"]=&gt; float(1433452977.521) ["REQUEST_TIME"]=&gt; int(1433452977) } </code></pre> <p><strong>Edit:</strong><br> <a href="https://goo.gl/uUQ9O8" rel="nofollow">This</a> my project link for download</p>
20,440,967
0
<p>If you define your endpoint within a <code>resource</code> block, for example:</p> <pre><code>module MyApiModule class MyApiClass &lt; Grape::API resource :foo do get :time do {epoch_time: Time.now.to_i.to_s} end end resource :bar do get :bar_time do {epoch_bar_time: Time.now.to_i.to_s} end end end end </code></pre> <p>... you will see this nice separators:</p> <p><img src="https://i.stack.imgur.com/t4grz.png" alt="enter image description here"></p>
23,267,553
0
Keep the code in <# #> bracers <p>My problem is pretty simple but I don't know how to solve it. It happens when XCode suggest me an existing function or code snippet. Some places (where I should place my variables) are surrounded by <code>&lt;#</code> and <code>#&gt;</code> "bracers". It's very usefull function - I can use <kbd>tab</kbd> to move to the next place where I should place my code. But when I have to implement code completion in reactive cocoa:</p> <pre><code>[[signal subscribeError:&lt;#^(NSError *error)errorBlock#&gt; completed:&lt;#^(void)completedBlock#&gt;] </code></pre> <p>I don't know how to remove <code>&lt;#</code> and <code>#&gt;</code> "bracers" to keep (for the following example) <code>(NSError *error)errorBlock</code>.</p>
8,658,079
0
register and login in one page changes my url <p>Im having the following issue.</p> <p>I have a View typed to a class SiteAuthenticationVM.cs.</p> <p>The name of my view is "SiteAuthentication.cshtml" into the folder Views/Users</p> <p>For other hand, i have one controller called UsersController with 4 actions:</p> <pre><code>[HttpGet] public ActionResult Registration() { return View("SiteAuthentication"); } [HttpPost] public ActionResult Registration(SiteAuthenticationVM usertoregister) { return View("SiteAuthentication",usertoregister); } [HttpGet] public ActionResult Login() { return View("SiteAuthentication"); } [HttpPost] public ActionResult Login(SiteAuthenticationVM usertologin) { return View("SiteAuthentication",usertoregister); } </code></pre> <p>I have 2 routes defined:</p> <ul> <li><p>"/register" is handled by UsersController Registration action.</p></li> <li><p>"/login" is handled by UsersController Login action.</p></li> </ul> <p>When i post my Login form is posted to /login if previously i was in url "/register", it changes to /login. Is there any way to keep my url "/register" for both post actions?</p> <p>Is a bad practice if the url changes? </p>
31,390,532
0
<p>Use <a href="http://developer.android.com/reference/android/content/Context.html#getFileStreamPath(java.lang.String)" rel="nofollow">getFileStreamPath()</a> like this:</p> <pre><code>String fileName = "webImage"; //... Uri uri = Uri.fromFile(getFileStreamPath(fileName)); </code></pre>
26,386,337
0
<p>There's surprisingly little in the standard about this. About all we hear about redeclaration is:</p> <blockquote> <p><code>[C++11: 3.1/1]:</code> A declaration (Clause 7) may introduce one or more names into a translation unit or redeclare names introduced by previous declarations. <em>[..]</em></p> </blockquote> <p>and the only relevant part of <code>auto</code>'s semantics:</p> <blockquote> <p><code>[C++11: 7.1.6.4/3]:</code> Otherwise, the type of the variable is deduced from its initializer. <em>[..]</em></p> </blockquote> <p>(reminding us that the type of <code>x</code> is <code>int</code>).</p> <p>We know that a variable must be given the same type by all declarations:</p> <blockquote> <p><code>[C++11: 3.5/10]:</code> After all adjustments of types (during which typedefs (7.1.3) are replaced by their definitions), <strong>the types specified by all declarations referring to a given variable or function shall be identical</strong>, except that declarations for an array object can specify array types that differ by the presence or absence of a major array bound (8.3.4). A violation of this rule on type identity does not require a diagnostic.</p> </blockquote> <p>and the "after all adjustments of types" ought to take care of any questions regarding <code>auto</code>'s participation in all of this; my interpretation, then, is that <strong>this is inherently a valid redeclaration (and definition) of the <code>x</code> at global scope with type <code>int</code>, and that Clang is correct</strong>. Even if we propose that <code>auto</code> does not count as "adjustment of type", since no diagnostic is required, at worst <em>all</em> listed implementations are compliant in their own way.</p> <p>I believe GCC and Visual Studio are taking the following as inspiration:</p> <blockquote> <p><code>[C++11: 7.1.6.4/5]:</code> A program that uses <code>auto</code> in a context not explicitly allowed in this section is ill-formed.</p> </blockquote> <p>&hellip;but I think that this is short-sighted. It seems unlikely that the standard language is intended to prohibit the usual redeclaration rules, just because they are not repeated or explicitly referenced from within <code>7.1.6.4</code>.</p> <p>C++14 adds wording that relates to declarations of <em>functions</em> with deduced types:</p> <blockquote> <p><code>[C++14: 7.1.6.4/13]:</code> Redeclarations or specializations of a function or function template with a declared return type that uses a placeholder type shall also use that placeholder, not a deduced type. <em>[..]</em></p> </blockquote> <p>By symmetry one might suggest that, in your <code>int</code> case, it is intended that GCC and VS be correct in rejecting the program. However, this is a different feature (since deduction cannot be applied to mere declarations) and thus a different scenario.</p> <p>Either way, improved standard wording would help here. I consider it a [reasonably minor] editorial defect.</p>
20,482,410
0
<p>You never check for 'eof' in your read loop in readInput(). This means you have garbage values (perhaps 0) for these lines after you hit eof:</p> <pre><code> inputFile &gt;&gt; data[i].name; inputFile &gt;&gt; data[i].idNum; inputFile &gt;&gt; data[i].testNum; </code></pre> <p>Then what do you suppose is going to happen here, if data[i].testNum is zero?</p> <pre><code> data[i].average = total / data[i].testNum; </code></pre> <p>You might consider checking <code>inputFile.good()</code> before each read from the stream, and handle it appropriately when it returns false.</p>
25,892,363
0
ServiceBus type - queue segregation best practises <p>Let's say there is service bus instance working in one way mode. The service bus generates two kinds of messages: Foo and Bar. Both of these message types are to be saved in database. </p> <p>So I can see two approaches for doing so:</p> <ol> <li><p>Have two queues (FooQueue, BarQueue) and two bus instances (two processes) - one for receiving from FooQueue and one for receiving from BarQueue</p></li> <li><p>Have one queue and one bus instance with two handlers for Foo and Bar messages</p></li> </ol> <p>I would like to ask what are best practises (maybe even decision tree? :) ) for deciding when to use which approach.</p> <p>Thanks in advance</p>
21,251,917
0
<p>alter you table so that it is setup as DELETE CASCADE.</p> <p>In hibernate this would be like</p> <pre><code>&lt;set name="stockDailyRecords" cascade="delete" table="stock_daily_record" ...&gt; &lt;key&gt; &lt;column name="STOCK_ID" not-null="true" /&gt; &lt;/key&gt; &lt;one-to-many class="com.mkyong.common.StockDailyRecord" /&gt; &lt;/set&gt; </code></pre> <p>see this <a href="http://www.mkyong.com/hibernate/hibernate-cascade-example-save-update-delete-and-delete-orphan/" rel="nofollow">link</a></p>
9,585,330
0
Cmake with MinGW fails compile test <p>I am trying to compile OpenCV on windows using CMAKE and MinGW on Windows. However, when I try to do that I am getting the following error:</p> <pre><code>The C compiler identification is GNU The CXX compiler identification is GNU Check for working C compiler: C:/MinGW/bin/gcc.exe CMake Error: Generator: execution of make failed. Make command was: make "cmTryCompileExec\fast" Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE): The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program. </code></pre> <p>Does anyone know what could be an issue?</p>
14,885,667
0
<p>Look at your <a href="https://ccrma.stanford.edu/courses/422/projects/WaveFormat/" rel="nofollow">RIFF header</a>. This will tell you the endianness of the Wav file. </p> <p>Use that endian-ness to read in your 32-bit floats correctly. For example: If your system is little endian (say, based on an x86 processor) and your wav file is big endian(say, created on an old PPC mac), you will need to do a <a href="http://stackoverflow.com/questions/2182002/convert-big-endian-to-little-endian-in-c-without-using-provided-func">32-bit endian swap</a> after you read in the data so that your float variable actually contains data that makes sense (this is usually a value between -1.0f and 1.0f )</p>
27,164,649
0
<p>if i am getting you right, you can call the following function on your desired event to switch between the markers without clicking.</p> <pre><code>marker1.showInfoWindow(); marker2.showInfoWindow(); marker3.showInfoWindow(); </code></pre> <p>Mark as right if it works for you .:)</p> <p>P.S: An info window can be hidden by calling hideInfoWindow().</p>
7,403,775
0
<p>Because <code>c</code> is a character and not an integer.</p> <p>The ASCII value of '0' is 48 so a '0' would be index 48 in the <code>n[c]</code> statement and the programmer wanted '0' to be index 0 because <code>n</code> was defined <code>n[10]</code>, so the ASCII value is converted to its integer equivalent by subtracting the code for '0' so: <code>'0' - '0' = 0</code>, <code>'1' - '0' = 1</code>, etc. The ASCII codes for '0' to '9' are 48 to 57 so the conversion is sound.</p> <p>As for why, I guess someone is counting the frequency of the digits '0' to '9' in some text.</p>
20,108,569
0
<p>You need this in your CSS:</p> <pre><code>#nav-wrap .container .wsite-menu-default { display:table; margin:auto; } </code></pre> <p>Here is your fiddle working <strong><a href="http://jsfiddle.net/58sqQ/2/" rel="nofollow">http://jsfiddle.net/58sqQ/2/</a></strong></p>
24,837,331
0
<p>you need to add a var as xmlhttp; on starting to get the status result please use below code i modify it,</p> <pre><code>&lt;script&gt; //Ajax to send request.. function sendPayment() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { alert(xmlhttp.readyState);// this always returns = 1 alert(xmlhttp.responseText) ; //this is always empty. if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { if (xmlhttp.responseText=='1') { alert('success'); } } } xmlhttp.open("POST","payments/callSSL.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(Id=100); return false; } &lt;/script&gt; </code></pre>
33,125,090
0
<p>As you say "correct" to all our assumptions, ...</p> <ul> <li>you only use the time part of rounded_time and we must ignore the date part</li> <li>the batch that shall pick 12:15, 12:30, 12:45, and 13:00 runs after 13:00 and before 14:00</li> </ul> <p>This leads to a WHERE clause like this:</p> <pre><code>where extract(hour from systimestamp) - 1 = extract(hour from cast(rounded_time as timestamp) - interval '1' minute) </code></pre> <p>Here we extract the current hour when the batch is executing the query and subtract one. This would give us 12 for the batch running after 13:00 and before 14:00.</p> <p>And we take rounded_time, subtract a minute to get from 12:00 to 11:59 and from 13:00 to 12:59, and extract the hour. So we get 12 for all records after 12:00 until 13:00.</p> <p>The complete query:</p> <pre><code>select domain, mode, channel, kpi, sum(value), avg(avgtm), to_char(sysdate, 'hh24') || ':00' from t1 where extract(hour from systimestamp) - 1 = extract(hour from cast(rounded_time as timestamp) - interval '1' minute) group by domain, mode, channel, kpi; </code></pre>
2,322,315
0
<p>You might be using too many keys or opening and closing them too many times. Storing all your values under one key and keeping it open until you finish writing to it might improve performance.</p>
8,241,360
0
<p>Find out the real encoding of the source document. It might be <code>WIN1251</code>. Either transcode it (for instance with <a href="http://en.wikipedia.org/wiki/Iconv" rel="nofollow">iconv</a>) or set the <code>client_encoding</code> of PostgreSQL accordingly.</p> <p>If you don't have a setting in <code>pyodbc</code> (which I don't know), you can always issue a plain SQL command:</p> <pre><code>SET CLIENT_ENCODING TO 'WIN1251'; </code></pre> <p>More in the chapter <a href="http://www.postgresql.org/docs/current/interactive/multibyte.html#AEN32070" rel="nofollow">"Automatic Character Set Conversion Between Server and Client"</a> of the manual.</p>
33,291,992
0
<p>This is because the html that is bound to your knockout observable array is mangled when datatables is initialized... The html is copied and reformatted to be "datatables" after initialization. so the elements that you view after datatables initialization are not the same elements that knockout has bound to. I have created a custom binding to use datatables with knockout. it is dependent upon a fork of knockout which adds before render all and after render all events. I have created a pull request with the knockout git hub repository. If the below solution helps you please leave a comment on the pull request to get it merged into knockout 3.4... thanks.</p> <p><a href="http://jsfiddle.net/zachpainter77/4tLabu56/" rel="nofollow">fiddle of working solution</a></p> <p><a href="https://github.com/knockout/knockout/pull/1856" rel="nofollow">my pull request</a></p> <pre><code>ko.bindingHandlers.DataTablesForEach = { init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var nodes = Array.prototype.slice.call(element.childNodes, 0); ko.utils.arrayForEach(nodes, function (node) { if (node &amp;&amp; node.nodeType !== 1) { node.parentNode.removeChild(node); } }); return ko.bindingHandlers.foreach.init(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext); }, update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { var value = ko.unwrap(valueAccessor()), key = "DataTablesForEach_Initialized"; var newValue = function () { return { data: value.data || value, beforeRenderAll: function (el, index, data) { if (ko.utils.domData.get(element, key)) { $(element).closest('table').DataTable().clear(); $(element).closest('table').DataTable().destroy(); } }, afterRenderAll: function (el, index, data) { $(element).closest('table').DataTable(value.options); } }; }; ko.bindingHandlers.foreach.update(element, newValue, allBindingsAccessor, viewModel, bindingContext); //if we have not previously marked this as initialized and there is currently items in the array, then cache on the element that it has been initialized if (!ko.utils.domData.get(element, key) &amp;&amp; (value.data || value.length)) { ko.utils.domData.set(element, key, true); } return { controlsDescendantBindings: true }; } }; </code></pre>
455,421
0
<p>Yes, definitely. I use subversion for all my personal projects, for the same reasons you cited above. </p> <p>I wouldn't even consider doing any coding without a VCS, no matter how small the project. I have one big repository that has many folders in it for all of my small projects, and if I am working on a larger project, it will get its own repository.</p>
3,468,788
0
<p>The HTML5 spec has an <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address" rel="nofollow noreferrer">interesting take on the issue of valid email addresses</a>:</p> <blockquote> <p>A valid e-mail address is a string that matches the ABNF production 1*( atext / "." ) "@" ldh-str 1*( "." ldh-str ) where atext is defined in RFC 5322 section 3.2.3, and ldh-str is defined in RFC 1034 section 3.5.</p> </blockquote> <p>The nice thing about this, of course, is that you can then take a look at the open source browser's <a href="https://bug555559.bugzilla.mozilla.org/attachment.cgi?id=461895" rel="nofollow noreferrer">source code for validating it</a> (look for the <code>IsValidEmailAddress</code> function). Of course it's in C, but not too hard to translate to JS.</p>
34,702,344
0
Nginx ReWrite Engine - Transform Apache Rules to Nginx <p>I need to transform those Apache rules to Nginx for my MVC. </p> <p>Apache Rules :</p> <pre><code>RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f RewriteCond %{SCRIPT_FILENAME} !maintenance.html RewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RwriteRule ^(.+)$ index.php?url=$1 [QSA,L] </code></pre> <p>I think that some of it i can handle for the first part for the maintenance i think that this can help:</p> <pre><code>location / { root /var/www/myapp.com/current/public; try_files /system/maintenance.html $uri $uri/index.html $uri.html @app-server_cluster; </code></pre> <p>}</p> <p>but the second block of the QSA,L i don't know. </p> <p>Thanks for your Help!</p>
27,938,794
0
<p>I haven't used that particular library before, but do you have anything against using the one in Android's support library? Works perfectly for me...</p> <pre><code>import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; </code></pre> <p>AND</p> <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_container" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;/android.support.v4.widget.SwipeRefreshLayout&gt; </code></pre>
35,118,493
0
<h2>Methods</h2> <p>You could use one of the following methods:</p> <ul> <li><code>float:left;</code> on <code>.menu</code></li> <li><code>display:inline-block;</code> + <code>vertical-align:top;</code> on <code>.menu</code></li> <li><code>position:absolute;</code> on <code>#changetitle</code></li> </ul> <p>With the <code>float</code> and <code>vertical-align</code> methods, you'll need to remove the <code>margin-right</code> on <code>.menu ul</code> (<code>float</code> will also work if you give the menu a width). With <code>position:absolute</code> you're goning to spend a whole lot of time getting the <code>left</code> and <code>top</code> values right :P</p> <h2>Which is best?</h2> <p>Probably <code>inline-block</code>. It's the easiest to set up, and just works. Best of all, it's <em>dynamic</em>. If you want to add another menu item at a later date and have to make the <code>.menu</code> div bigger, you don't have to change the CSS, whereas <code>float</code> usually would require you to set a width on <code>.menu</code> and <code>position:absolute</code> <em>definitely</em> requires that (as it is telling the browser exactly at what pixel to put <code>#changetitle</code>. If you're going to have more columns continue this design throughout the rest of the page, you <em>may</em> want to consider using <code>column</code> or <code>display:table</code> (<strong>never</strong> an actual <code>&lt;table&gt;</code> :P)</p> <p>Long story short, use <code>inline-block</code>.</p> <p>Here's a working demo: <a href="https://jsfiddle.net/mnfgo32g/12/" rel="nofollow">https://jsfiddle.net/mnfgo32g/12/</a></p>
26,563,318
0
<p>The problem is likely to be the <code>ZeroBytePadding</code>. The one of Bouncy always adds/removes at least one byte with value zero (a la PKCS5Padding, 1 to 16 bytes of padding) but the one of PHP only pads until the first block boundary is encountered (0 to 15 bytes of padding). I've discussed this with David of the legion of Bouncy Castle, but the PHP zero byte padding is an extremely ill fit for the way Bouncy does padding, so currently you'll have to do this yourself, and use the cipher without padding.</p> <p>Of course, as a real solution, rewrite the PHP part to use AES (<code>MCRYPT_RIJNDAEL_128</code>), CBC mode encryption, HMAC authentication, a real Password Based Key Derivation Function (PBKDF, e.g. PBKDF2 or bcrypt) and PKCS#7 compatible padding instead of this insecure, incompatible code. Alternatively, go for OpenSSL compatibility or a known secure container format. </p>
41,074,549
0
<p>I might have understood your problem wrong, but try this.</p> <p>Give your anchor tag an id.</p> <p><code>&lt;a id='anchor_sym'&gt;&lt;/a&gt;</code></p> <p>Then, in <code>onClick()</code> method, do on of following:</p> <pre><code>/* Plain Javascript*/ var element = document.getElementById("anchor_sym"); element.className += " glyphicon-chevron-left"; element.className = element.className.replace("glyphicon-chevron-right", ""); /* Using JQuery*/ $('anchor_sym') .addClass('glyphicon-chevron-left') .removeClass('glyphicon-chevron-right'); </code></pre>
22,050,031
0
android - Develop apps using Visual Basic <p>is it possible to develop android apps using Visual Basic? if yes, how?</p> <p>i have been working with it for a while and eclipse is quite difficult to use. i'd seriously prefer using VS</p>
36,968,869
0
Animating SVG rect x property via CSS <p>I have a classic mobile three-bars menu button made with SVG. I would like to animate each bar on click.</p> <p>This is my code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#menu_button').click( function() { $(this).toggleClass('open'); } );</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>#menu_button .rectangle { left: 0; x: 0; transition: all ease 1s; } #menu_button .rectangle.first { transform: rotate(0deg); top: 0; y: 0; } #menu_button .rectangle.second { transform: rotate(0deg); transform-origin: 8px 9px; top: 6px; y: 6; } #menu_button .rectangle.third { transform: rotate(0deg); transform-origin: 11px 9px; top: 12px; y: 12; } #menu_button.open .rectangle.first { top: 23.2px; y: 23.2px; } #menu_button.open .rectangle.second { transform: rotate(405deg); } #menu_button.open .rectangle.third { transform: rotate(495deg); left: 0; x: 0; top: 8px; y: 8; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt; &lt;svg width="22" height="35" id="menu_button" class="hidden-sm hidden-md hidden-lg"&gt; &lt;rect style="opacity:1; fill:#eb671f; fill-opacity:1;stroke:none;" class="rectangle first" width="22" height="2" x="0" y="0" /&gt; &lt;rect style="opacity:1; fill:#eb671f; fill-opacity:1;stroke:none;" class="rectangle second" width="22" height="2" x="0" y="6" /&gt; &lt;rect style="opacity:1; fill:#eb671f; fill-opacity:1;stroke:none;" class="rectangle third" width="22" height="2" x="0" y="12" /&gt; &lt;/svg&gt;</code></pre> </div> </div> </p> <p>JSFiddle for those like me who can't run the snippet: <a href="https://jsfiddle.net/9rkoLcx8/2/" rel="nofollow noreferrer">https://jsfiddle.net/9rkoLcx8/2/</a></p> <p>The issue is with Firefox.</p> <p>I mean, everything is working fine on Chrome and Opera, this doesn't work on Safari (it has no animation but it's still ok as it doesn't break things up), and works half in firefox: it rotates correctly but doesn't animate the <code>x</code> and <code>y</code> of SVG rects.</p> <p><a href="https://i.stack.imgur.com/XjHNn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XjHNn.png" alt="enter image description here"></a></p> <p>This is what I think: <code>x</code> and <code>y</code> are <code>rect</code> attributes, not CSS properties, so not only they shouldn't work on Firefox, they shouldn't work on Chrome and Opera too. That's why I added <code>top</code> and <code>left</code>, but it still doesn't work.</p> <p>Is there a way to make the animation of <code>x</code> and <code>y</code> work in Firefox too?</p>
37,961,592
0
Javascript onclick with img is not working on IE10 with HTML 5 enable <p>We have a legacy HTML+JavaScript code which has been written approx 15 years back. We are enabling some of the feature in the code by using HTML5 like as search box etc.</p> <p>While enabling HTML-5, checkbox stop working on IE-10, same code is working on Firefox and chrome. Checkbox functionality has been implemented using tag.</p> <p>Below is the snapshot of the code.</p> <pre><code>function ClickCheckBoxImage (object) { if( !IsDisabled (object)) { SetCheckBoxImage (object, !IsChecked (object)) eval (object.getAttribute ("onchange")) } } Page.prototype.AddCheckBox = function (name, value, onChange, forceNavUpdate, rebootOnChange, isReadOnly, condition) { var checkBox var checkBoxHelper var checked = value.toLowerCase() == "true" var newElement = document.createDocumentFragment() var checkBoxName = name + "checkbox" onChange = (!onChange) ? "" : onChange + ";" if (isReadOnly == null) isReadOnly = false if(userNameglobal == 4) isReadOnly = true onClick = "ClickCheckBoxImage(this);" onChange += 'UpdateDependentRows (document.getElementById(\''+name+'\'));' if (this.autoSubmit) onChange += 'SubmitOnChangeOf (\''+checkBoxName+'\');' if (forceNavUpdate) onClick += 'UpdateNavReloadCB(this);' // Create the checkbox Image checkBox = CreateElement ('&lt;img class="checkbox" '+ ' name="'+checkBoxName+'" id="'+checkBoxName+'" onclick="'+onClick+'"&gt;') checkBox.setAttribute ("onchange", onChange) checkBox.setAttribute ("disabled", isReadOnly) checkBox.setAttribute ("helper", name) SetImageValue (checkBox, checked) checkBox.src = GetCheckBoxImageName (checkBox) this.SetCommonAttributes (checkBox, rebootOnChange, condition); newElement.appendChild (checkBox); // Create the helper checkBoxHelper = CreateElement ('&lt;input type="hidden" id="'+name+ '" name="'+name+'" value="'+value+'"&gt;'); this.SetCommonAttributes (checkBoxHelper, rebootOnChange, condition); newElement.appendChild (checkBoxHelper); return newElement; } </code></pre> <p>Function ClickCheckBoxImage() has been set to onclick. While debugging the issue, It has been seen that ClickCheckBoxImage() is not calling in case of IE-10, but it is calling in case firefox and chrome.</p> <p>Please help me to resolve this issue.</p> <p>Thanks in advance.</p>
41,023,575
0
How to design a Snake and Ladder game without using HashMap? <p>I was asked this question once which I replied using a HashMap. But then again I was asked to use another data structure. Can some one think of some other approach</p>
18,458,439
0
<p>Try to create the table as below:</p> <pre><code>CREATE TABLE t1 (dt DATETIME(6) NOT NULL); </code></pre> <p><strong><a href="http://sqlfiddle.com/#!9/a9086/1/0" rel="nofollow">SQL Fiddle</a></strong></p>
28,931,812
0
<p>You put everything in a loop. Why? You should use the loop only to check whether the username is taken or not and send your messages outside of it. </p> <p>First of all you'd like to force your loop to work only as long as it should. You can do it by declaring <code>isUsed</code> before it and adding it to the condition. Then, in the loop, you only check whether the name is taken and change the value of your variable. The loop will either iterate through all the clients or end when it encounters the first name that matches your condition. When the loop is over, you should decide which command you send basing on the results.</p> <pre><code>bool isUsed = false; for (int i = 0; i &lt; clientsInfoList.Count &amp;&amp; !isUsed; i++) { isUsed = String.Equals(clientsInfoList[i].Item3, Username); } if (isUsed) { Console.WriteLine("Username is already used!"); udpServer.Send(Encoding.ASCII.GetBytes("REFUSED"), Encoding.ASCII.GetByteCount("REFUSED"), remoteEP); } else { clientsInfoList.Add(new Tuple&lt;int, IPEndPoint, string&gt;(id, remoteEP, Username)); Console.WriteLine("Username has been added to the list :)"); udpServer.Send(Encoding.ASCII.GetBytes("ACCEPTED"), Encoding.ASCII.GetByteCount("ACCEPTED"), remoteEP); } </code></pre>
27,097,738
0
<p>Your question raises some interesting issues. I will try to explain how you can fix it, but, as @Uri mentions, there may be better ways to address your problem.</p> <p>I've assumed <code>@tranfee</code> is to be set equal to the first value in the hash whose key begins with <code>"tran"</code> and that <code>@rate</code> is to be set equal to the first value in the hash whose key begins with <code>"rate"</code>. If that interpretation is not correct, please let me know.</p> <p>Note that I've put <code>initialize</code> in the <code>PaymentType</code> module in a class (<code>Papa</code>) and made <code>TranFee</code> and <code>Rate</code> subclasses. That's the only way you can use <code>super</code> within <code>initialize</code> in the subclasses of that class.</p> <p><strong>Code</strong></p> <pre><code>class Transaction attr_reader :tranfee, :rate def initialize(hash={}) o = PaymentType::TranFee.new(hash) @tranfee = o.instance_variable_get(o.instance_variables.first) o = PaymentType::Rate.new(hash) @rate = o.instance_variable_get(o.instance_variables.first) end end </code></pre> <p>.</p> <pre><code>module PaymentType class Papa def initialize(hash, prefix) key, value = hash.find { |key,value| key.start_with?(prefix) &amp;&amp; value } (raise ArgumentError, "No key beginning with #{prefix}") unless key instance_variable_set("@#{key}", value) self.class.singleton_class.class_eval { attr_reader key } end end class TranFee &lt; Papa def initialize(hash) super hash, "tran" end end class Rate &lt; Papa def initialize(hash) super hash, "rate" end end end </code></pre> <p>I believe the method <a href="http://ruby-doc.org/core-2.1.1/Object.html#method-i-singleton_class" rel="nofollow">Object#singleton_class</a> has been available since Ruby 1.9.3.</p> <p><strong>Example</strong></p> <pre><code>reg_debit = {"name" =&gt; "reg_debit", "rate_base" =&gt; 0.0005, "tran_fee" =&gt; 0.21, "rate_basis_points" =&gt; 0.002, "tran_auth_fee" =&gt; 0.10} a = Transaction.new reg_debit p Transaction.instance_methods(false) #=&gt; [:tranfee, :rate] p a.instance_variables #=&gt; [:@tranfee, :@rate] p a.tranfee #=&gt; 0.21 p a.rate #=&gt; 0.0005 </code></pre>
19,386,826
0
<p>Unfortunately since UDP has no concept of a "connection", there is no way for the OS (or you) to distinguish between "old" data and "new" data.</p> <p>Specifically on Win32, there's an <code>SIO_FLUSH</code> ioctl which you can pass to <code>WSAIoctl()</code>. I haven't tried this, and it seems that it's only relevant for the send queue.</p> <p>See also: <a href="http://stackoverflow.com/questions/15980438/clean-window-socket-internal-buffer">clean window socket internal buffer</a></p>
24,510,132
0
<p>You don't need a regex for that, you can use <code>encodeURI</code></p> <pre><code>url = url.replace(/null/g, ""); url = encodeURI(url); </code></pre>
31,966,126
1
what is the difference between x.type and type(x) in Python? <p>Consider the following lines </p> <pre><code>import theano.tensor as T x = T.dscalar('x') y = T.dscalar('y') z = x+y </code></pre> <p>And then,</p> <pre><code>In [15]: type(x) Out[15]: theano.tensor.var.TensorVariable </code></pre> <p>while,</p> <pre><code>In [16]: x.type Out[16]: TensorType(float64, scalar) </code></pre> <p>Why type(x) and x.type give two different pieces of information ? What information is conveyed by them ?</p> <p>I also see that referring to <a href="http://deeplearning.net/software/theano/tutorial/adding.html" rel="nofollow">Theano tutorial</a> ,</p> <pre><code>&gt;&gt;&gt; type(x) &lt;class 'theano.tensor.basic.TensorVariable'&gt; &gt;&gt;&gt; x.type TensorType(float64, scalar) </code></pre> <p>Why type(x) output is different in my case ? Are these caused by version specific implementation differences and what is signified by this difference ?</p>
11,936,550
0
<blockquote> <p>Can i now go and change the position of the characters in the string?</p> </blockquote> <p>No. Strings in .NET are immutable – they cannot be changed. In order to modify a string in VB, you call a function which creates a <em>new</em> string based off the modified contents of the old string. That’s what all the <a href="http://msdn.microsoft.com/en-us/library/system.string_methods.aspx" rel="nofollow">string methods</a> are doing.</p> <p>It’s not entirely clear what your encryption function is supposed to do though. It seems to permute the letter positions, but what schema does it use for that?</p>
5,969,274
0
<p>For others who are in the same requirement, you may consider my columnchooser implementation. My Dialog Form Declaration. (Dialog box which will be shown when columnchooser button is clicked.</p> All required fields will not be allowed to remove.</p> <p>Creating the ColumnChooser Button for my Grid.</p> <pre><code>jq("#grid").jqGrid('navButtonAdd','#pager',{ caption: "Columns", title: "Customize Columns", onClickButton : function (){ /*jq("#grid").jqGrid('columnChooser',{ height:columnChooserHt });*/ createDialogDiv(); jq( "#dialog-form" ).dialog('open'); } }); </code></pre> <p>Adding Save(OK) and Cancel Buttons to my Div.</p> <pre><code>jq(function(){ jq( "#dialog-form" ).dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { "OK": function() { changeColView(); jq( "#dialog-form" ).dialog('close'); }, Cancel: function() { jq( "#dialog-form" ).dialog('close'); } }, close: function() { } }); }); </code></pre> <p>Function which inserts the column names with the select boxes which needed to be displayed on the ColumnChooser Dialog Box.</p> <pre><code>function createDialogDiv(){ var colModelDiv = jq("#grid").jqGrid('getGridParam','colModel'); var colNamesDiv = jq("#grid").jqGrid('getGridParam','colNames'); //alert(JSON.stringify(colModelDiv)); //alert(JSON.stringify(colNameDiv)); var container = document.getElementById('dialog-form'); //alert(colNamesDiv.length); var chckBox=""; for(i=0;i&lt;colNamesDiv.length;i++){ if(colModelDiv[i].hidden &amp;&amp; colModelDiv[i].hidden == true ){ chckBox+="&lt;input type='checkbox' id='"+colNamesDiv[i]+"' name='"+colNamesDiv[i]+"' value='"+colModelDiv[i].name+"'&gt;"+colNamesDiv[i]+"&lt;/input&gt;&lt;br/&gt;"; }else{ if(colModelDiv[i].editrules &amp;&amp; colModelDiv[i].editrules.required){ chckBox+="&lt;input type='checkbox' id='"+colNamesDiv[i]+"' name='"+colNamesDiv[i]+"' value='"+colModelDiv[i].name+"' disabled&gt;"+colNamesDiv[i]+"&lt;/input&gt;&lt;br/&gt;"; } else chckBox+="&lt;input type='checkbox' id='"+colNamesDiv[i]+"' name='"+colNamesDiv[i]+"' value='"+colModelDiv[i].name+"' checked&gt;"+colNamesDiv[i]+"&lt;/input&gt;&lt;br/&gt;"; } } container.innerHTML=chckBox; } </code></pre> <p>Finally the actual method which changes the Columns chosen from Columnchooser.</p> <pre><code>function changeColView(){ var colModelDiv = jq("#grid").jqGrid('getGridParam','colModel'); var colNamesDiv = jq("#grid").jqGrid('getGridParam','colNames'); for(i=0;i&lt;colNamesDiv.length;i++){ var chckBox=document.getElementById(colNamesDiv[i]); if(chckBox &amp;&amp; chckBox.value &amp;&amp; (!(chckBox.checked || chckBox.disabled))){ jq("#grid").jqGrid('hideCol',chckBox.value); } if(chckBox &amp;&amp; chckBox.checked){ jq("#grid").jqGrid('showCol',chckBox.value); } } jq("#grid").trigger('reloadGrid'); } </code></pre> <p>Plz let me know your thoughts on this one.</p>
22,239,624
0
PHP Twitterify function regex doesn't exclude starting numbers <p>I'm using the code</p> <pre><code>function twitterify($ret) { $ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t&lt; ]*)#", "\\1&lt;a href=\"\\2\" target=\"_blank\"&gt;\\2&lt;/a&gt;", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r&lt; ]*)#", "\\1&lt;a href=\"http://\\2\" target=\"_blank\"&gt;\\2&lt;/a&gt;", $ret); $ret = preg_replace("/@(\w+)/", "&lt;a href=\"http://www.twitter.com/\\1\" target=\"_blank\"&gt;@\\1&lt;/a&gt;", $ret); $ret = preg_replace("/#(\w+)/", "&lt;a href=\"http://twitter.com/search?q=\\1\" target=\"_blank\"&gt;#\\1&lt;/a&gt;", $ret); return $ret; } </code></pre> <p>to parse text from Tweets and add links. If #1 appears in the Tweet text then a hashtag link will be created for it. That's incorrect since hashtags can't start with numbers.</p> <p>How can the regular expressions be modified to correct this?</p> <p>Also special characters should be excluded according to <a href="http://www.hashtags.org/platforms/twitter/what-characters-can-a-hashtag-include/" rel="nofollow">this</a>.</p>
23,273,433
0
javascript/jquery ignore or override :hover style <p><strong>Short Description:</strong> I want to use JS/JQuery to take precedence over the CSS :hover psuedo-class for specific brief moments without removing the CSS rule for the other <em>majority</em> of cases. Since the site is already script-heavy enough I'm trying to find a solution that doesn't require me to nuke the CSS interaction and rely on mouseover/mouseout events. In my case there's a marked performance difference between the two.</p> <p><strong>Details:</strong> I've created a CSS-based dropdown shopping cart viewer. I rigged up some JQuery to force the cart open when the user triggers certain page interactions like adding an item to the cart. When the cart is "programmatically opened" an 8 second timer is used to close it. All that works. <strong>The Problem:</strong> I also want to add a click handler to the cart so that when the user clicks on it it will be explicitly closed whether the 8second timeout has expired or not. However, when they click on the cart they are - by definition - hovering over it, kicking in the :hover state and keeping it from closing. Is there a way to temporarily disable the :hover rule and then once the cart has closed reinstate it.</p> <p><strong>HTML:</strong></p> <pre><code>&lt;span class="minicart-wrapper"&gt; &lt;a class="minicart-anchor" href="..."&gt;Shopping Cart&lt;/a&gt; &lt;div id="minicart"&gt; ... &lt;/div&gt; &lt;/span&gt; </code></pre> <p><strong>CSS:</strong></p> <pre><code>.minicart-wrapper #minicart { display: none; } .minicart-wrapper:hover #minicart, .minicart-wrapper #minicart.open { display: block; } </code></pre> <p><strong>JQuery:</strong></p> <pre><code>function openMinicart() { var minicart = jQuery('#minicart'); minicart.addClass('open'); minicart.bind('click', {}, closeMinicart); window.setTimeout(closeMinicart, 8000); } function closeMinicart() { var minicart = jQuery('#minicart'); minicart.removeClass('open'); minicart.unbind('click', closeMinicart); } </code></pre> <p><strike><strong>I've tried:</strong> a few suggestions I found here like changing <code>.minicart-wrapper:hover #minicart</code> to <code>.minicart-wrapper:hover #minicart.canhover</code>. I then added <code>removeClass(canhover)</code> to the beginning of closeMinicart() and <code>setTimeout(function(){jQuery('#minicart').addClass('canhover')},500);</code> to the end of it. However it seems that this is too short a timeout for the browser to refresh it's hover-state and before it's done rendering the hover re-triggers and the cart stays put.</strike></p> <p>Thanks for any suggestions.</p> <p><strong>Edit:</strong> Thanks Jedison. Here's the JSFiddle: <a href="http://jsfiddle.net/WJS3h/" rel="nofollow">http://jsfiddle.net/WJS3h/</a> . Also fixed some bugs in the sample.</p> <p><strong>Edit 2:</strong> Turns out I had a code error (oops) and the can-not-hover class method is the way to go. Thanks to everyone who commented.</p>
20,623,296
0
<p>The issue is that the images change the height of the div. You can keep them from doing that by floating them. Also, if you want them to always fit within the container, you'll need to adjust the width of the images. So, something like this might work:</p> <pre><code>#cool img { float:left; width:25%; height: auto; } </code></pre> <p>In the interest of creating semantic HTML, you may want to change your markup to something more like the following:</p> <pre><code>&lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;img src="/my/cool/image.png" alt="Menu item 1"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;img src="/my/cool/image.png" alt="Menu item 2"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;img src="/my/cool/image.png" alt="Menu item 3"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre>
37,824,729
1
How to use random.randint to find random 0 and 1 with not equal propbability <p>I am using <a href="https://pypi.python.org/pypi/deap" rel="nofollow">DEAP</a> toolbox in Python for Genetic Algorithm. </p> <p><code>toolbox.register("attr_bool", random.randint, 0, 1)</code> is a function randomly chooses 0 and 1 for populations in GA. I want to force GA to choose 0 and 1 randomly but with for example 80% one and the rest zero. </p> <p>I think <code>srng.binomial(X.shape, p=retain_prob)</code> is a choice, but I want to use <code>random.randint</code> function. Wondering how we can do that? </p>
26,960,261
0
same method signature in interface and class <pre><code>interface TestInterface { void work(); } class TestClass { public void work(){ System.out.println("Work in CLASS"); } } public class Driver extends TestClass implements TestInterface { public static void main(String[] args) { new TestClass().work(); } } </code></pre> <p>Can any one explain to me, why just because the same work method signature exists in TestClass this class compiles fine?</p>
8,074,650
0
<pre><code>$('#show_existing_suggestions').live('click',function(){}); </code></pre> <p><a href="http://api.jquery.com/live/" rel="nofollow">http://api.jquery.com/live/</a></p>
7,609,129
0
Custom RouteMap <p>Hi I have to route an old path, that was containing the old webform, to my new controller.</p> <p>I tried this:</p> <pre><code> routes.MapRoute( "DownloadLink", "products/pippo/download/{*catchall}", new { controller = "Downloads", action = "Index"} ); </code></pre> <p>To have my controller called with <a href="http://mysite.com/products/pippo/download/" rel="nofollow">http://mysite.com/products/pippo/download/</a> but what I receive it's a 404 Status Code, what am I doing wrong?</p> <p>Thanks in advance</p>
15,355,246
0
<p>I would recommend you to use android <a href="http://developer.android.com/reference/android/app/DownloadManager.html" rel="nofollow">DownloadManager package</a>, which takes care of all issues related to huge files download. <br></p> <p>Copied from the Android document site: <br><br> <code>The download manager is a system service that handles long-running HTTP downloads. Clients may request that a URI be downloaded to a particular destination file. The download manager will conduct the download in the background, taking care of HTTP interactions and retrying downloads after failures or across connectivity changes and system reboots.</code> <br><br> A very good example of using <code>DownloadManager</code> is provided <a href="http://www.mysamplecode.com/2012/09/android-downloadmanager-example.html" rel="nofollow">here</a>.</p> <p>Hope this helps !!</p>
23,604,821
0
<p>If you simply want to squash all commits into a single, initial commit, just reset the repository and amend the first commit:</p> <pre><code>git reset hash-of-first-commit git add -A git commit --amend </code></pre> <p>Git reset will leave the working tree intact, so everything is still there. So just add the files using git add commands, and amend the first commit with these changes. Compared to rebase -i you'll lose the ability to merge the git comments though.</p>
27,137,862
0
DIV is not displaying in IE8 onwards due to CSS class <p>When I create a div like below, it is displaying in IE7, but not displaying on IE8 and later versions. When I view source code, I can see this div in all IE versions, but not displaying in IE8 and plus.</p> <p>My Aspx code:</p> <pre><code>&lt;div runat="server" id="divLoginImage" class="loginImage"&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.loginImage { position: absolute; left: -500px; top: 10px; } </code></pre> <p>Please note that if I remove class attribute as show below, this is working fine.</p> <pre><code>&lt;div runat="server" id="divLoginImage" &gt; &lt;/div&gt; </code></pre> <p>What is wrong with my CSS?</p>
19,100,513
0
Checking pointer to pointer is not null <p>*A few things to be noted in the code: cfield<b>p</b> is a pointer and cfield<b>pp</b> is a pointer to pointer.</p> <p>I want to know the uses of the new macro (see the code below). We are passing the address of <code>cfieldp</code>,<code>(&amp;cfieldp)</code> instead of <code>cfieldp</code> and comparing it to null. What is its use? Does it stop a memory leak?</p> <pre><code>// Custom data type: typedef struct custom_field { int test; } custom_field_t; // Old macro: #define CUSTOM_CLEAN(cfieldp) \ { \ ..... // Calls free() to free memory \ } // New macro: #define CUSTOM_CLEAN_NEW(cfieldpp) \ { \ if ((cfieldpp)) { \ CUSTOM_CLEAN(*(cfieldpp)) \ } \ } // Code: custom_field_t *cfieldp = NULL; ......// *cfieldp may or may not be null ...... CUSTOM_CLEAN(cfieldp); // Old macro //CUSTOM_CLEAN or CUSTOM_CLEAN_NEW will be executed, not both. CUSTOM_CLEAN_NEW(&amp;cfieldp); // New macro, replacement of CUSTOM_CLEAN </code></pre>
38,876,686
0
<p>If you want to avoid forwarding landing page then use:</p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|swf|css|html|js|ico|pdf)$ RewriteCond %{REQUEST_URI} !^/app\.php(/.*)?$ [NC] RewriteRule ^(.+)$ app.php/$1 [L] </code></pre> <p><code>.+</code> will match anything but not the landing page.</p> <p>In case you want to exclude all the top level domain URLS then use:</p> <pre><code>RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC] RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|swf|css|html|js|ico|pdf)$ RewriteCond %{REQUEST_URI} !^/app\.php(/.*)?$ [NC] RewriteRule ^(.*)$ app.php/$1 [L] </code></pre>
34,204,307
0
<p>Just use the built-in <code>isName</code> method:</p> <pre><code>public static boolean isName(CharSequence name) </code></pre> <p>This returns whether or not a name is a syntactically valid qualified name in the latest source version.</p> <p>See the <a href="http://docs.oracle.com/javase/8/docs/api/javax/lang/model/SourceVersion.html#isName-java.lang.CharSequence-" rel="nofollow">isName()</a> documentation.</p>
7,670,123
0
insert element in every position of nested list <p>In Maple 15, I have a nested list like this one (only 2 levels of nesting):</p> <pre><code>[[a,b],[c],[d,e,f]] </code></pre> <p>I want to create 6 lists from that one (the number of elements..), like these:</p> <pre><code>[[x,a,b],[c],[d,e,f]] [[a,x,b],[c],[d,e,f]] [[a,b],[x,c],[d,e,f]] [[a,b],[c],[x,d,e,f]] [[a,b],[c],[d,x,e,f]] [[a,b],[c],[d,e,x,f]] </code></pre> <p>I tried but I have super complex loops and it doesn't work.. any more brilliant idea?</p>
33,903,608
0
<h2><a href="http://jsfiddle.net/adriancarriger/t8Lyarmc/10/" rel="nofollow">Working Fiddle</a></h2> <p>It looks like you're not selecting the current slide's image. I found the current slide by looping through the slides and checking their opacity.</p> <h2>Remove this</h2> <pre><code>var sr = $(this).attr('src'); </code></pre> <h2>Replace with this</h2> <pre><code>var sr; $(this).closest('.slides').find('.slide-container').each(function(index) { if ($(this).find('.slide').css("opacity") === 1) { sr = $(this).find('img').attr('src'); } }); </code></pre>
24,610,631
0
<p>This is what the <a href="http://msdn.microsoft.com/en-us/library/vstudio/ms227424.aspx" rel="nofollow"><code>ValidationGroup</code></a> property is for. Suppose you have the following controls:</p> <pre><code>&lt;asp:RequiredFieldValidator ID="rfv1" runat="server" ValidationGroup="Group1" /&gt; &lt;asp:RequiredFieldValidator ID="rfv2" runat="server" ValidationGroup="Group1" /&gt; &lt;asp:RequiredFieldValidator ID="rfv3" runat="server" ValidationGroup="Group2" /&gt; &lt;asp:Button ID="btn1" runat="server" ValidationGroup="Group1" Text="Button 1" /&gt; &lt;asp:Button ID="btn2" runat="server" ValidationGroup="Group2" Text="Button 2" /&gt; </code></pre> <p>In the example above, <code>btn1</code> will only cause validation for the controls validated by <code>rfv1</code> and <code>rfv2</code>, whilst <code>btn2</code> will only cause validation for the control validated by <code>rfv3</code>.</p>
3,000,964
0
<p>If you're a registered developer, I would suggest visiting developer.apple.com/iphone and signing in there. Otherwise, we can't really discuss it. </p>
11,224,332
0
I have to query a MS SQL DB using java <p>I have to query a MS SQL DB using java. I am querying DB using following code</p> <pre><code> Class.forName("net.sourceforge.jtds.jdbc.Driver"); Connection conn = DriverManager.getConnection( "jdbc:jtds:sqlserver://XXX.XX.XX&gt;XX:1433/DBNAME", "USERNAME", "Password"); querystr="select DATEDIFF(second,Finish_Time,ReqTime) As FinishDifference from DB.SCHEMA.TABLE where ID='123'"; Statement stmt=conn.createStatement(); ResultSet res=stmt.executeQuery(querystr); System.out.print(res.getRow()); </code></pre> <p>When I query DB manually using query string, I am able to successfully gets results but res.getRow() shows 0.</p>
35,406,936
0
<p>I suggest you to get more information about Data modeling in Cassandra. I've read <a href="http://www.cs.wayne.edu/andrey/papers/TR-BIGDATA-05-2015-CKL.pdf" rel="nofollow">A Big Data Modeling Methodology for Apache Cassandra</a> and <a href="http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling" rel="nofollow">Basic Rules of Cassandra Data Modeling</a> as useful articles in this case. They will help you understanding about modelling the tables based on your queries (Query-Driven methodology) and data duplication and its advantages/disadvantages. </p>
40,020,062
0
<p>Standard method would be to use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.eig.html" rel="nofollow">numpy.linalg.eig</a>.</p> <pre><code>from numpy import linalg as LA w, v = LA.eig(np.diag((1, 2, 3))) # w: # array([ 1., 2., 3.]) # v: # array([[ 1., 0., 0.], # [ 0., 1., 0.], # [ 0., 0., 1.]]) </code></pre> <p>Obviously, if your matrix is very specific (let's say very large and sparse), usually you want to use iterative approach (e.g. <em>Krylov subspace method</em>) to find most dominant eigenvalues. See <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/arpack.html" rel="nofollow">discussion</a> for more details.</p>
5,475,890
0
<p>You are using the wrong overload for the <code>.ActionLink</code>. Try this instead...</p> <pre><code>&lt;%= Html.ActionLink(item.venue, "Details", "Venues", new { name = item.venue }, new {}) %&gt; </code></pre> <p>It is currently selecting <a href="http://msdn.microsoft.com/en-us/library/dd492124.aspx"><code>string, string, object, object</code></a> overload. Your "Venues" string is being used for routing data.</p>
37,241,002
0
d3 force graph using node names for links <p>I've been at this for a few days now, and I've seen the questions on stackoverflow and other places, but I am missing something.</p> <p>Lets say we have the following JSON:</p> <pre><code>{ "nodes":[ {"name":"node1"}, {"name":"node2"}, {"name":"node3"}, {"name":"node4"} ], "links":[ {"source":"node1","target":"node2"}, {"source":"node1","target":"node3"}, {"source":"node1","target":"node4"} ] } </code></pre> <p>Why do the following two pieces of code yield the same output in the console, but the second gives me an error (Uncaught TypeError: Cannot read property 'push' of undefined)?</p> <pre><code>links = links.map(function(l) { var sourceNode = nodes.filter(function(n) { return n.name === l.source; })[0]; var targetNode = nodes.filter(function(n) { return n.name === l.target; })[0]; return { source: sourceNode, target: targetNode }; }); </code></pre> <p>_ </p> <pre><code>links.forEach(function(link) { link.source = {name: link.source}; link.target = {name: link.target}; }); </code></pre> <p>Console output:</p> <pre><code>[{"source":{"name":"node1"},"target":{"name":"node2"}}, {"source":{"name":"node1"},"target":{"name":"node3"}}, {"source":{"name":"node1"},"target":{"name":"node4"}}] </code></pre>
40,294,340
1
taking the product of the elements of tuples based on their sum <p>I would greatly appreciate any feedback regarding the following question. So far I wrote a code on Python that generates the combination of 2 dimensional tuples in which each element is a value from 1 through 4. So for (a1,a2), a1 and a2 can be any value from 1 through 4</p> <p>Thus this generated the following tuples</p> <pre><code>tuple_combinations = [(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4)] </code></pre> <p>I then took the sum of the elements for each tuple which generated:</p> <pre><code>sum_tuple_combinations = [2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8] </code></pre> <p>Now I need help with computing the product of the elements for tuples whose sum are 5. So for this example that would be the product of tuples (2,3), (3,2) , (1,4) and (4,1) which would give me </p> <pre><code> [6,6,4,4] </code></pre> <p>How would I code that on Python? </p> <p>this is what I've done so far:</p> <pre><code> import itertools x = [1,2,3,4] combinations= [p for p in itertools.product(x, repeat=2)] print(combinations) sum_of_combinations = map(sum, combinations) print(sum_of_combinations) #product_of_combinations = [x*y for sum_of_combinations = 5] </code></pre> <p>Moreover, although this solves the 2 dimensional case, where n=2 ,I would like to consider the product of the elements in the tuple for other dimensions such as n=200 and so on. Thus, especially for dimensions such as N=200 I was wondering if there was a computationally inexpensive way to accomplish this?</p>
27,174,953
0
<p>Because that's the easiest way to distribute everything while keeping it up to date. By offloading build costs to the users, library authors only need to provide source code.</p> <p>This can be mitigated in various ways. For example, <a href="https://github.com/bananu7/potato-empires" rel="nofollow">my CI setup</a> uses CircleCI and Heroku. Nodes on both hold precached cabal sandboxes (it's actually very easy to set up). I build my project on Heroku, but there's no reason why you couldn't take prebuilt artifacts from your CI and deploy them directly.</p> <p>As for dynamic linking, there's a possibility to link Haskell modules dynamically, but shared libraries more often than not are a source of problems. One look at Windows DLL hell should be enough to see this, and most commercial applications simply ship DLLs they use anyway. If a library changes, the DLLs have to be replaced anyway, and the way Cabal does it makes it simplest to have latest and greatest versions of everything.</p>
20,732,532
0
Why does AngularJS swallow event and cause jQueryUI calendar (of datepicker) to not display? <p>I have a problem where jQuery datepicker fails to display the calendar, because something swallows the event. It seems like it might be AngularJS causing the problem. You can see it at: <a href="http://jsfiddle.net/daylight/GAyY3/" rel="nofollow">jsfiddle.net example</a></p> <p>In the jsfiddle example, I've created one datepicker at the bottom of the page which appears all the time and isn't initialized until you click the <strong>[Init DatePicker]</strong> button.</p> <p>Here's the init() method where I initialize the jQuery Datepicker as detailed in jquery docs.</p> <pre><code>function init(selId) { if (console.log !== undefined) { console.log("init()..."); } $(function() { $( ".datepicker" ).datepicker({ changeMonth: true, changeYear: true }); }); if (selId !== undefined) { $(".datepickFix").on("click","#" + selId, function (){ $(".datepicker").datepicker( "show" ); }); } else { $(".datepickFix").on("click",".datepickFix", function (){ $(".datepicker").datepicker( "show" ); }); } } </code></pre> <p><strong>Try This</strong></p> <p>Go ahead and click the "edit" box or [click me] text and you'll see that it doesn't display the jQuery Datepicker. </p> <p><strong>Works As Expected</strong></p> <p>Now, click the [Init DatePicker] button and again, attempt to click the "edit" box and you'll see the calendar display as you expect. If you click the [click me] text it will also display. Everything works as expected.</p> <p><strong>ng-repeat - addrow() calls init()</strong> However, now click an the [Add Row] button and notice that I am doing an ng-repeat in AngularJS to add rows to a table. The row contains another "datepicker" and the Init() code is called upon adding the row.</p> <p>I also call init() from the onclick of the div just to make it fire.</p> <p><strong>The Datepicker Still Doesn't Display</strong></p> <p>However, notice that even though the init() is called -- confirmed by console.log -- you will see that clicking on the "edit" box (jquery datepicker) in the new row <strong>does not display the datepicker</strong>.</p> <p>Now, if you click the [click me] text in the row or you click the [Init DatePicker] the calendar will now show.</p> <p><strong>Clicking [Add Row] button twice makes the first-added row work, not the other</strong> Also, if you click the <strong>[Add row]</strong> button twice, the calendar will show upon initially clicking the first-added row.</p> <p>However, if I call init() multiple times that doesn't work either. Can anyone shed some light on this issue?</p>
18,099,535
0
<pre><code>[WebMethod(Description = "Returns a Fruit XML")] public XmlElement GetALLFruits() { Fruit fruit = new Fruit(); fruit.Name = "Mango La Ka Buma"; fruit.expiryDate = "11/11/1911"; fruit = getFruitCrateDetails(fruit);//This is call to method 1. Don't worry your values will not be lost fruit.Name will remain as it is. return fruit.xml; //just giving example syntax might be wrong } public Fruit getFruitCrateDetails(Fruit fruit) { FruitCrate crate = new FruitCrate(); crate.id = 999; fruit.crate.Add(crate);//Now no other method should set crateValues return fruit; } public Fruit getFruitCrateDetails1(Fruit fruit) { SomeNewProperty = "test"; fruit.PropertyName = SomeNewProperty;//Now no other method should set value for SomeNewProperty return fruit; } </code></pre> <p>Please read the comments. And i have not tested the code. So there are possibilities that you may not get the desired output. I have tried my best to explain you.</p>
11,086,185
0
<p><strong>Short fix:</strong></p> <p>In the <code>onTabSelected</code> method, before using <code>if (mFragment == null)</code> you need to try to get the fragment (using <code>mFragment = getSupportFragmentManager().findFragmentByTag(mTag)</code>). You can also set this from the outside but I don't see you doing this.</p> <p>Checking <code>if(savedInstanceState == null)</code> on <code>onCreate</code> could also solve this and I consider it a better approach though! :)</p>
29,214,145
0
Sql server display string in when statement <p>I have the following query</p> <pre><code>select (case when object like'%service%' then (object) when class like '%service%' then (class)end) From db group by (case when object like '%service%' then object when object_class like '%service%' then object_class end) </code></pre> <p>this query check if value of each column contains 'service' than display the data, i need instead of data only display, data and string<br/> Some thing like <code>when object like'%service%' then (object),'string'</code></p> <p>String will be a variable which is stored in unknown column at results </p> <ol> <li>column1 column2</li> <li>objet1 mystring</li> <li>objet2 mystring</li> <li>objet3 mystring</li> </ol>
13,342,209
0
<p>string myTime = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("it-IT"));</p> <p>the example use italian culture code, for a list of available culture codes check out <a href="http://sharpertutorials.com/list-of-culture-codes/" rel="nofollow">this</a></p>
2,730,117
0
C++ - Efficient container for large amounts of searchable data? <p>I am implementing a text-based version of Scrabble for a College project.</p> <p>My dictionary is quite large, weighing in at around 400.000 words (<code>std::string</code>).</p> <p>Searching for a valid word will suck, big time, in terms of efficiency if I go for a <code>vector&lt;string&gt;</code> ( O(n) ). Are there any good alternatives? Keep in mind, I'm enrolled in freshman year. Nothing TOO complex!</p> <p>Thanks for your time!</p> <p>Francisco</p>
33,282,185
0
<p>The first thing to point out is that there is nothing like racing condition. The right terminology is just <strong>race condition</strong>. Keep this in mind for the future ;-)</p> <p>I suppose you are using a BroadcastReceiver to receive messages and that you have created the object and tell it to run in a separate thread because of the animation. This means that your showFab method can be called twice in one time. To handle this, define the method as <a href="https://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html" rel="nofollow">synchronized</a>.</p>
12,804,934
0
<p>from the <a href="http://docs.python.org/tutorial/datastructures.html#dictionaries" rel="nofollow">docs</a>:'</p> <blockquote> <p>It is best to think of a dictionary as an unordered set of key: value pairs, with the requirement that the keys are unique (within one dictionary)</p> </blockquote>
35,365,216
0
<p>This should work for you.</p> <pre><code>require '/PHPMailer-master/PHPMailerAutoload.php'; require '/PHPMailer-master/class.phpmailer.php'; $mail = new PHPMailer(true); if(isset($_POST['submit'])){ $to = "[email protected]"; $from = $_POST['text_96']; $fullname = $_POST['text_95']; $email = $_POST['text_96']; $dob = $_POST['date_12']; $addr = $_POST['textarea_31']; $maths = $_POST['text_93']; $english = $_POST['text_31']; $holidayst = $_POST['date_74']; $holidayend = $_POST['date_91']; $distance = $_POST['number_58']; $awayhome = $_POST['selectlist_90']; foreach($_POST['checkbox'] as $key=&gt;$val){$apprent .= $val.' ';} //$fileatt = $_POST['file']; $reasontext = $_POST['textarea_60']; $message = "Message"; $mail-&gt;setFrom($from, $fullname); $mail-&gt;addAddress('[email protected]'); $mail-&gt;addAttachment($_FILES['file']['name']); if (isset($_FILES['file']) &amp;&amp; $_FILES['file']['error'] == UPLOAD_ERR_OK) { $mail-&gt;AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']); } $mail-&gt;Subject = 'subject'; $mail-&gt;Body = $message; try{ $mail-&gt;send()) { header('Location: success.html'); }catch(Exception $e) { header('Location: error.html'); } finally{ $message = NULL; $headers = NULL; } } </code></pre>
6,797,243
0
<p>You should use a webhook, not the email service.</p> <p><a href="http://help.github.com/post-receive-hooks/" rel="nofollow">http://help.github.com/post-receive-hooks/</a></p>
2,375,126
0
How to programmatically click an element with MooTools? <p>In jQuery, I've done stuff like this in the past:</p> <pre><code>$('#someCheckbox').click(); </code></pre> <p>And everything works as if the user just clicked on the element normally. However the same doesn't work in MooTools:</p> <pre><code>$('someCheckbox').fireEvent('click'); </code></pre> <p>The checkbox doesn't get checked, nor do any of the bound event handlers fire.</p> <p>Is there a way to do this? I need the already bound "click" event handlers to fire, so just setting it's "checked" attribute isn't an option.</p> <p>Thanks</p>
23,757,900
0
<p>How about something like this:</p> <pre><code>create table #tempTab(Num int,rtype char(1),amount decimal(8,2)); insert into #tempTab values (110200014,'A',19259.00), (110200014,'D',-802.46), (110200014,'D',-1604.92) select * from #tempTab t cross apply (select amount from #tempTab where rtype = 'A' and Num = t.Num) pa; </code></pre>
6,289,011
0
<p>Keys inside <code>appSettings</code> are retrieved as <code>NameValueCollection</code> which by definition</p> <blockquote> <p>Represents a collection of associated String keys and String values that can be accessed either with the key or with the index.</p> </blockquote> <p>So you can have only the data type <code>string</code> as <code>value</code> for an AppSettings <code>key</code></p> <p>And yes, <code>AppSettings</code> is the only place where you can store your settings.<br> MSDN defines AppSettings like this.</p> <blockquote> <p>Contains custom application settings, such as file paths, XML Web service URLs, or any information that is stored in the.ini file for an application.</p> </blockquote>
6,755,697
0
<pre><code>$result = mysql_query("SELECT * FROM stores where StoreID=$id order by city"); if (!$result) { die('Invalid query: ' . mysql_error()); }else{ while($row = mysql_fetch_assoc($result)){ echo $row['city']." : ".$row['street']."&lt;br /&gt;"; } } </code></pre> <p>while() is fetching results step by step, so it will give it your result</p>
21,499,729
0
jQuery multiple else if statements <p>I am trying to set a padding on a div based on the window height size. I simply couldn't find a better working way to center my content div vertically in another div with unknown dimensions. My code is as it follows:</p> <pre><code>&lt;script&gt; $(document).ready(function(){ var window_height = $(window).height(); var home_content = $('#home-content'); if(window_height &lt;= 600) { home_content.css({"padding-top", "13px"}); } else if(window_height &gt; 600 &amp;&amp; window_height &lt;= 768) { home_content.css({"padding-top", "97px"}); } else if(window_height &gt; 768 &amp;&amp; window_height &lt;= 800) { home_content.css({"padding-top", "113px"}); } else if(window_height &gt; 800 &amp;&amp; window_height &lt;= 900) { home_content.css({"padding-top", "163px"}); } else if(window_height &gt; 900 &amp;&amp; window_height &lt;= 1050) { home_content.css({"padding-top", "238px"}); } else if(window_height &gt; 1050 &amp;&amp; window_height &lt;= 1080) { home_content.css({"padding-top", "253px"}); } else if(window_height &gt; 1080 &amp;&amp; window_height &lt;= 1200) { home_content.css({"padding-top", "313px"}); } else { } }); &lt;/script&gt; </code></pre> <p>It is not working. My web site is stuck on the preloader and simply won't load anyhing. Any ideas where am I doing it wrong?</p>
21,928,405
0
<p>the base Docker containers don't start services like cron - they only start what you specify in the ENTRYPOINT/CMD</p> <p>some 'fatter' containers use things like supervisord to start services - but where possible, its more maintainable to separate services into different containers and share data using with volume containers, or --link</p>
235,534
0
<p>This creates your typical hierarchical table and uses a CTE to select the hierarchy structure and create a path for each item.</p> <pre><code>CREATE TABLE tblHierarchy (ID int, ParentID int NULL, Name varchar(128)); INSERT INTO tblHierarchy VALUES (1, NULL, '1'); INSERT INTO tblHierarchy VALUES (2, NULL, '2'); INSERT INTO tblHierarchy VALUES (3, NULL, '3'); INSERT INTO tblHierarchy VALUES (4, 1, '1.1'); INSERT INTO tblHierarchy VALUES (5, 1, '1.2'); INSERT INTO tblHierarchy VALUES (6, 4, '1.1.1'); WITH Parent AS ( SELECT ID, ParentID, Name AS Path FROM tblHierarchy WHERE ParentID IS NULL UNION ALL SELECT TH.ID, TH.ParentID, CONVERT(varchar(128), Parent.Path + '/' + TH.Name) AS Path FROM tblHierarchy TH INNER JOIN Parent ON Parent.ID = TH.ParentID ) SELECT * FROM Parent </code></pre> <p>OUTPUT:</p> <pre><code>ID ParentID Path 1 NULL 1 2 NULL 2 3 NULL 3 4 1 1/1.1 5 1 1/1.2 6 4 1/1.1/1.1.1 </code></pre>