Daily Archives

Articles indexed Monday June 4 2012

Page 10/19 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Mustache vs other engines. Maybe I should use another template engine?

    - by marcioAlmada
    I'm passing an object to mustache and this object has a method with one parameter. Is something like this possible with Mustache and PHP? {{object.method(parameter)}} If it gets too laborious to achieve this with Mustache, what template engine would you recommend? Remember I need to pass parameters to object methods while in the view context (like we do with helpers). The nearest as possible to mustache syntax is welcome.

    Read the article

  • Loading HTML5 video on iPad via onclick event tied to a div

    - by joncys
    I'm developing an HTML5 application (a game), that automatically preloads 5 video files. I'm able to do so correctly on Safari for PC, so there are no overlooked problems with file formats, codecs or such. The load fails on an iPad. As an official guide for video on iOS puts it: This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not. Does this mean, that I have no means to initiate the loading of video after a user initiated action, if that action hasn't been tied to a video element (user clicked on a regular div — I request loading and displaying of a video, compared to the user actually clicking on a video element to load and play that particular element)? Thanks for your help!

    Read the article

  • Codeigniter URI Routing

    - by justin
    I have check the codeigniter user guide, But I was not lucky to solve my problem. I have created a webpage on my localhost. When I go to http://localhost/webpage/ it is okay. It will go to the default controller. My default controller is Homepage and there are methods named index, guarantee and about When I go to my routes.php, I added this: $route['guarantee'] = "homepage/guarantee"; $route['about_us'] = "homepage/about"; Then try to access it http://localhost/webpage/guarantee and http://localhost/webpage/about_us it show ERROR 404 But when I do it like this $route['default_controller'] = "homepage/guarantee"; The guarantee page will be displayed. Can anyone help me with this issue? Thanks.

    Read the article

  • friending istream operator with class

    - by user1388172
    hello i'm trying to overload my operator >> to my class but i ecnouter an error in eclipse. code: friend istream& operator>>(const istream& is, const RAngle& ra){ return is >> ra.x >> ra.y; } code2: friend istream& operator>>(const istream& is, const RAngle& ra) { is >> ra.x; is >> ra.y; return is } Both crash and i don't know why, please help. EDIT: ra.x & ra.y are both 2 private ints of my class; Full error: error: ..\/rightangle.h: In function 'std::istream& operator>>(std::istream&, const RAngle&)': ..\/rightangle.h:65:12: error: ambiguous overload for 'operator>>' in 'is >> ra.RAngle::x' ..\/rightangle.h:65:12: note: candidates are: c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:122:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:122:7: note: no known conversion for argument 1 from 'const int' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}' c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:126:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>, std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:126:7: note: no known conversion for argument 1 from 'const int' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}' c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:133:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:133:7: note: no known conversion for argument 1 from 'const int' to 'std::ios_base& (*)(std::ios_base&)' c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:241:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:241:7: note: no known conversion for argument 1 from 'const int' to 'std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}' ..\/rightangle.h:66:12: error: ambiguous overload for 'operator>>' in 'is >> ra.RAngle::y' ..\/rightangle.h:66:12: note: candidates are: c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:122:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:122:7: note: no known conversion for argument 1 from 'const int' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}' c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:126:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>, std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:126:7: note: no known conversion for argument 1 from 'const int' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}' c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:133:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:133:7: note: no known conversion for argument 1 from 'const int' to 'std::ios_base& (*)(std::ios_base&)' c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:241:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] <near match> c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/istream:241:7: note: no known conversion for argument 1 from 'const int' to 'std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}''

    Read the article

  • Writing to a new log file each day with TraceSource

    - by Cipher
    I am using a logger in my application to write to files. The source, switch and listeners have been defined in the app.config file as follows: <system.diagnostics> <sources> <source name="LoggerApp" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch"> <listeners> <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="myListener.log" /> </listeners> </source> </sources> <switches> <add name="sourceSwitch" value="Information" /> </switches> </system.diagnostics> Inside, my .cs code, I use the logger as follows: private static TraceSource logger = new TraceSource("LoggerApp"); logger.TraceEvent(TraceEventType.Information, 1, "{0} : Started the application", DateTime.Now); What would I have to do to create a new log file each day instead of writing to the same log file every time?

    Read the article

  • Why does my Google maps api v3 and side panel not fill my page upon resizing?

    - by Gavin
    I'm developing a web page and I have a side panel on the left with a search bar and a Google maps api v3 filling the rest of the page to the right. When I make the browser very small vertically, there is a white space between the side panel and the map, and the bottom of the browser. However, the text continues to the bottom of the browser. It looks like: Here's my css code: <style type="text/css"> body {margin:0;} #panel {height:100%; width:300px; position:absolute; padding:0;background-color:#8C95A0;} #header {padding:2px; text-align:center} #address_instruction {position:relative; top:7%; padding:2px; text-align:center} #geocoder {position:relative; top:8%; padding:2px; text-align:center} #toggle_instruction {position:relative; top:22%; padding:2px; text-align:center} #layers {position:relative; top:25%; padding:2px; text-align:center} #layer0 {padding:2px; text-align:center} #layer1 {padding:2px; text-align:center} #layer2 {padding:2px; text-align:center} #link {top:50%; position:relative; padding:2px; text-align:center} #map_canvas {height:100%; left:300px; right:0px; position:absolute; padding:0;} </style> The IDs within #panel refer to the items on the left hand side in the panel. Why don't the side panel background color and map extend to the bottom of the browser?

    Read the article

  • How do I stop a bouncy JQuery animation?

    - by Miguel
    In a webapp I'm working on, I want to create some slider divs that will move up and down with mouseover & mouseout (respectively.) I currently have it implemented with JQuery's hover() function, by using animate() and reducing/increasing it's top css value as needed. This works fairly well, actually. The problem is that it tends to get stuck. If you move the mouse over it (especially near the bottom), and quickly remove it, it will slide up & down continuously and won't stop until it's completed 3-5 cycles. To me, it seems that the issue might have to do with one animation starting before another is done (e.g. the two are trying to run, so they slide back and forth.) Okay, now for the code. Here's the basic JQuery that I'm using: $('.slider').hover( /* mouseover */ function(){ $(this).animate({ top : '-=120' }, 300); }, /* mouseout*/ function(){ $(this).animate({ top : '+=120' }, 300); } ); I've also recreated the behavior in a JSFiddle. Any ideas on what's going on? :) ==EDIT== UPDATED JSFiddle

    Read the article

  • How to get rid of the 'progress' cursor?

    - by Ivan
    I have an interval that launches an AJAX call to check if there is any update for the page (I imagine that it's similar to the mechanism used by Facebook or StackExchange to check for new notifications). The problem is that this call changes the cursor to the 'progress' or 'busy' cursor (visual problem) and disables to option to click on links (functional problem). I suppose both problems are related. How can get rid of this effect or at least minimize the consequences? Some code: setInterval(function() { try { var mid = $($("ul#alert-messages li.regular")[0]).attr('ref'); call_ajax('/load_alerts', {num:0, id:mid}, function (data) { if (data.ok) { for (var i=0; i<data.result.length; i++) { // .... } // ... } }, function() {}, // Do not show any error for this!! false); // Do not change cursor! } catch (e) {} }, 15000); function call_ajax(url, data, fnSuccess, fnError) { $.ajax({ 'url': url, 'type': 'POST', 'data': data, 'dataType': "json", 'success' : function(data) { if (fnSuccess) { fnSuccess(data); } else { if (typeof data.msg != 'undefined') { topBar(data.msg, typeof data.ok != 'undefined' && data.ok? 'message' : 'error'); } } }, error : function (jqXHR, textStatus, errorThrown) { console.log(errorThrown); if (fnError) { fnError(STR_ERROR_AJAX + textStatus); } else { topBar(STR_ERROR_AJAX + textStatus, 'error'); } } }); }

    Read the article

  • How to create-edit-remove excel files?

    - by Giuseppe
    i am doing a project that has some simple values(login,password,name,age). I was searching on the internet how to create an excel file on Visual C++, and i cant undestand it . I just want the simple way, i just want to see on my excel files 2 colums one having some login codes of my program and on the other the passwords. My programing level its not really high and im not an english speaker, so id like you guys to explain a bit or give me something simple. Thanks for your time

    Read the article

  • WPF Event Handler in Another Class

    - by Nathan Tornquist
    I have built a series of event handlers for some custom WPF controls. The event handles format the text displayed when the user enters or leaves a textbox based on the type of data contained (Phone number, zip code, monetary value, etc.) Right now I have all of the events locally in the C# code directly attached to the xaml. Because I have developed a could controls, this means that the logic is repeated a lot, and if I want to change the program-wide functionality I would have to make changes everywhere the event code is located. I am sure there is a way to put all of my event handlers in a single class. Can anyone help point me in the correct direction? I saw this article: Event Handler located in different class than MainWindow But I'm not sure if it directly relates to what I'm doing. I would rather make small changes to the existing logic that I have, as it works, then rewrite everything into commands. I would essentially like to something like this if possible: LostFocus="ExpandedTextBoxEvents.TextBox_LostFocus" It is easy enough to do something like this: private void TextBoxCurrencyGotFocus(object sender, RoutedEventArgs e) { ExpandedTextBoxEvents.TextBoxCurrencyGotFocus(sender, e); } private void TextBoxCurrencyLostFocus(object sender, RoutedEventArgs e) { ExpandedTextBoxEvents.TextBoxCurrencyLostFocus(sender, e); } But that is less elegant.

    Read the article

  • Restlet/Jackson works differently when object implements Serializable

    - by ravyoli
    I am sending an object with some primitive fields using Restlet with Jackson converter. Up until now it worked great. But then I needed my object to implement Serializable, because I need to store it in memcache of GAE. For some reason - when the class implements Serializable, things stop working. Restlet sends a different string representation from before, and I can't even print that string in the server. I tried printing its byte value, char-by-char and the first numbers are: 0xfffd 0xfffd 0x0000 0x0005 0x0073 0x0072 Thanks a lot!

    Read the article

  • How to disable translations during unit tests in django?

    - by Denilson Sá
    I'm using Django Internationalization tools to translate some strings from my application. The code looks like this: from django.utils.translation import ugettext as _ def my_view(request): output = _("Welcome to my site.") return HttpResponse(output) Then, I'm writing unit tests using the Django test client. These tests make a request to the view and compare the returned contents. How can I disable the translations while running the unit tests? I'm aiming to do this: class FoobarTestCase(unittest.TestCase): def setUp(self): # Do something here to disable the string translation. But what? # I've already tried this, but it didn't work: django.utils.translation.deactivate_all() def testFoobar(self): c = Client() response = c.get("/foobar") # I want to compare to the original string without translations. self.assertEquals(response.content.strip(), "Welcome to my site.")

    Read the article

  • NSFetchedResultsChangeUpdate crashes when called on a searched tableview

    - by Zachary Fisher
    So I nearly have this thing figured out, but I am stumbling over the NSFetchedResultsChangeUpdate when I update my managedObjectContext from a detail view that was entered after searching the table. I have a tableview generated from a core data set. I can enter a detail view from this table and make changes without any issue. I can also search the table and make changes MOST of the time without any issues. However, on certain objects, I get an "Exception was caught during Core Data change processing". I tracked this down to the NSFetchedResultsChangeUpdate. I'm using the following code: case NSFetchedResultsChangeUpdate: if (searchTermForSegue) { NSLog(@"index info:%@.....",theIndexPath); NSLog(@"crashing at the next line"); [self fetchedResultsController:self.searchFetchedResultsController configureCell:[tableView cellForRowAtIndexPath:theIndexPath] atIndexPath:theIndexPath]; break; } else { [self fetchedResultsController:controller configureCell:[tableView cellForRowAtIndexPath:theIndexPath] atIndexPath:theIndexPath]; } break; When the table is not being searched, it runs the else method and that works 100% of the time. When the table is being searched, it runs the if (searchTermForSegue) and that works most of the time, but not always. I logged theIndexPath and discovered the following: When it works, theIndexPath is correctly reporting the objects indexPat, when it fails, the wrong theIndexPath has been called. For example, if I do a search that narrows the tableView to 3 sections, 2 items in first, 1 in second, 1 in third, I get the following nslog: On first object: index info:<NSIndexPath 0xb0634d0> 2 indexes [0, 0]..... on second object: index info:<NSIndexPath 0xb063e70> 2 indexes [0, 1]..... on third object: index info:<NSIndexPath 0xb042880> 2 indexes [1, 0]..... but on the last object: index info:<NSIndexPath 0x9665790> 2 indexes [2, 17]..... it should be calling [2, 0] Note that I am simply updating these objects, not deleting them or adding new ones. Any thoughts would be appreciated!

    Read the article

  • problems adding an App Engine app to a Google Apps domains

    - by Ron
    We have been adding domains to our app without any issues for past couple months, following these instructions https://developers.google.com/appengine/articles/domains Since yesterday we have not been able to, when clicking Activate this service we get this error message "An error occurred while trying to install this application. Please try again later." We have tried this also with older domains and with different apps and getting the same error, so the problem seems to be more widespread, not isolated to particular domains / apps. Does anyone know how to solve? Thanks Ron

    Read the article

  • Insert multiple line breaks into a JavaScript string (regex) (CodeMirror)

    - by PJH
    I have a few strings and I would like to insert some line breaks into them at certain points. I figured out a few of the logistics but as a whole I can't seem to crack this problem, probably because I have limited experience with regex. Basically I have a long string of XML tags that is all on one line. I want to add line breaks at certain points to get the data more formatted and looking nice. I am using CodeMirror to display this data on a webpage but for some reason its all on line #1. So I need to go from something like this: <Sample><Name></Name><PhoneNumber><AreaCode></AreaCode><Number></Number></PhoneNumber></Sample> To something like this: <Sample> <Name></Name> <PhoneNumber> <AreaCode></AreaCode> <Number></Number> </PhoneNumber> </Sample> CodeMirror will take care of the rest of the formatting all I need to do is insert the line breaks in the right spot using regex or a loop of some sort. The Tags will or can change so I am guessing regex has to be used. I have had success inserting line breaks with \n and &#xD but can't seem to get regex to detect the proper locations. Any help would be greatly appreciated. Thanks. UPDATE I overlooked this but the brackets are in fact being sent as < and > So example tag would look like: &lt;PhoneNumber&gt; or &lt;/PhoneNumber&gt; So basically need to insert a \n after every &gt; that is a closing tag or a beginning tag that contains children tags.

    Read the article

  • How to create multiple Repository object inside a Repository class using Unit Of Work?

    - by Santosh
    I am newbie to MVC3 application development, currently, we need following Application technologies as requirement MVC3 framework IOC framework – Autofac to manage object creation dynamically Moq – Unit testing Entity Framework Repository and Unit Of Work Pattern of Model class I have gone through many article to explore an basic idea about the above points but still I am little bit confused on the “Repository and Unit Of Work Pattern “. Basically what I understand Unit Of Work is a pattern which will be followed along with Repository Pattern in order to share the single DB Context among all Repository object, So here is my design : IUnitOfWork.cs public interface IUnitOfWork : IDisposable { IPermitRepository Permit_Repository{ get; } IRebateRepository Rebate_Repository { get; } IBuildingTypeRepository BuildingType_Repository { get; } IEEProjectRepository EEProject_Repository { get; } IRebateLookupRepository RebateLookup_Repository { get; } IEEProjectTypeRepository EEProjectType_Repository { get; } void Save(); } UnitOfWork.cs public class UnitOfWork : IUnitOfWork { #region Private Members private readonly CEEPMSEntities context = new CEEPMSEntities(); private IPermitRepository permit_Repository; private IRebateRepository rebate_Repository; private IBuildingTypeRepository buildingType_Repository; private IEEProjectRepository eeProject_Repository; private IRebateLookupRepository rebateLookup_Repository; private IEEProjectTypeRepository eeProjectType_Repository; #endregion #region IUnitOfWork Implemenation public IPermitRepository Permit_Repository { get { if (this.permit_Repository == null) { this.permit_Repository = new PermitRepository(context); } return permit_Repository; } } public IRebateRepository Rebate_Repository { get { if (this.rebate_Repository == null) { this.rebate_Repository = new RebateRepository(context); } return rebate_Repository; } } } PermitRepository .cs public class PermitRepository : IPermitRepository { #region Private Members private CEEPMSEntities objectContext = null; private IObjectSet<Permit> objectSet = null; #endregion #region Constructors public PermitRepository() { } public PermitRepository(CEEPMSEntities _objectContext) { this.objectContext = _objectContext; this.objectSet = objectContext.CreateObjectSet<Permit>(); } #endregion public IEnumerable<RebateViewModel> GetRebatesByPermitId(int _permitId) { // need to implment } } PermitController .cs public class PermitController : Controller { #region Private Members IUnitOfWork CEEPMSContext = null; #endregion #region Constructors public PermitController(IUnitOfWork _CEEPMSContext) { if (_CEEPMSContext == null) { throw new ArgumentNullException("Object can not be null"); } CEEPMSContext = _CEEPMSContext; } #endregion } So here I am wondering how to generate a new Repository for example “TestRepository.cs” using same pattern where I can create more then one Repository object like RebateRepository rebateRepo = new RebateRepository () AddressRepository addressRepo = new AddressRepository() because , what ever Repository object I want to create I need an object of UnitOfWork first as implmented in the PermitController class. So if I would follow the same in each individual Repository class that would again break the priciple of Unit Of Work and create multiple instance of object context. So any idea or suggestion will be highly appreciated. Thank you

    Read the article

  • Recursion - Ship Battle

    - by rgorrosini
    I'm trying to write a little ship battle game in java. It is 100% academic, I made it to practice recursion, so... I want to use it instead of iteration, even if it's simpler and more efficient in most some cases. Let's get down to business. These are the rules: Ships are 1, 2 or 3 cells wide and are placed horizontally only. Water is represented with 0, non-hit ship cells are 1, hit ship cells are 2 and sunken ships have all it's cells in 3. With those rules set, I'm using the following array for testing: int[][] board = new int[][] { {0, 1, 2, 0, 1, 0}, {0, 0, 1, 1, 1, 0}, {0, 3, 0, 0, 0, 0}, {0, 0, 2, 1, 2, 0}, {0, 0, 0, 1, 1, 1}, }; It works pretty good so far, and to make it more user-friendly I would like to add a couple of reports. these are the methods I need for them: Given the matrix, return the amount of ships in it. Same as a), but separating them by state (amount of non-hit ships, hit and sunken ones). I will need a hand with those reports, and I would like to get some ideas. Remember it must be done using recursion, I want to understand this, and the only way to go is practice! Thanks a lot for your time and patience :).

    Read the article

  • is that possible to crack Private key with Decrypted message and public key?

    - by matt clarck
    for example company B send an encrypted email with company A's public key (RSA/PGP/SSH/openSSL/...) the employer receive the encrypted email and send it to his boss who have the private key to decrypt message. the boss give decrypted email back to employer to work on it. question is can employer compare encrypted email with decrypted version and find out what is private key ? if it is possible then is there anyway to protect cracking private key from decrypted messages and comparing with encrypted messages/public key ?

    Read the article

  • Java Http request on api.stackexchange with json response

    - by taoder
    I'm trying to use the api-stackexchange with java but when I do the request and try to parse the response with a json parser I have an error. public ArrayList<Question> readJsonStream(InputStream in) throws IOException { JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8")); reader.setLenient(true); try { System.out.println(reader.nextString()); // ? special character return readItem(reader); } finally { reader.close(); } } public ArrayList<Question> readItem(JsonReader reader) throws IOException { ArrayList<Question> questions = new ArrayList<Question>(); reader.beginObject(); while (reader.hasNext()) { System.out.println("here");//not print the error is before String name = reader.nextName(); if (name.equals("items")) { questions = readQuestionsArray(reader); } } reader.endObject(); return questions; } public final static void main(String[] args) throws Exception { URIBuilder builder = new URIBuilder(); builder.setScheme("http").setHost("api.stackexchange.com").setPath("/2.0/search") .setParameter("site", "stackoverflow") .setParameter("intitle" ,"workaround") .setParameter("tagged","javascript"); URI uri = builder.build(); String surl = fixEncoding(uri.toString()+"&filter=!)QWRa9I-CAn0PqgUwq7)DVTM"); System.out.println(surl); Test t = new Test(); try { URL url = new URL(surl); t.readJsonStream(url.openStream()); } catch (IOException e) { e.printStackTrace(); } } And the error is: com.google.gson.stream.MalformedJsonException: Expected literal value at line 1 column 19 Here is an example of the Json : { "items": [ { "question_id": 10842231, "score": 0, "title": "How to push oath token to LocalStorage or LocalSession and listen to the Storage Event? (SoundCloud Php/JS bug workaround)", "tags": [ "javascript", "javascript-events", "local-storage", "soundcloud" ], "answers": [ { "question_id": 10842231, "answer_id": 10857488, "score": 0, "is_accepted": false } ], "link": "http://stackoverflow.com/questions/10842231/how-to-push-oath-token-to-localstorage-or-localsession-and-listen-to-the-storage", "is_answered": false },... So what's the problem? Is the Json really malformed? Or did I do something not right? Thanks, Anthony

    Read the article

  • OPTICS Clustering algorithm. How to get the best epsilon

    - by Marco Galassi
    I am implementing a project which needs to cluster geographical points. OPTICS algorithm seems to be a very nice solution. It needs just 2 parameters as input(MinPts and Epsilon), which are, respectively, the minimum number of points needed to consider them as a cluster, and the distance value used to compare if two points are in can be placed in same cluster. My problem is that, due to the extreme variety of the points, I can't set a fixed epsilon. Just look at the image below. The same points structure but in a different scale would result very different. Suppose to set MinPts=2 and epsilon = 1Km. On the left, the algorithm would create 2 clusters(red and blue), but on the right it would create one single cluster containing all of the points(red), but I would like to obtain 2 clusters even on the right. So my question is: is there any kind of way to calculate dynamically the epsilon value to get this result? Thank you very much and excuse my for my poor english. Marco

    Read the article

  • MySQLi insert into prepare error

    - by JPM
    Hi I inserted a lot of stuff into a mysql databse. But now I get an error in the prepare statement. I see Database prepare error. What am I doing wrong? This is my Code: $sql = "INSERT INTO Contact (IP,To,Name,Email,Subject,Text) VALUES ( ?, ?, ?, ?, ?, ? ) "; if (!$stmt = $db->prepare($sql)) { echo 'Database prepare error'; exit; } $stmt->bind_param('ssssss', $ip_contact, $to_contact, $name_contact, $email_contact, $subject_contact, $text_contact); if (!$stmt->execute()) { echo 'Database execute error'; exit; } $stmt->close(); My SQL table looks like this: Contact: - ID int(11) auto_increment primary key - IP varchar(15) - To varchar(5) - Name varchar(20) - Email varchar(20) - Subject varchar(20) - Text varchar(600)

    Read the article

  • Combining XmlSerializer and XmlWriter?

    - by num3ric
    In addition to a list of objects I am serializing to an xml file using C#'s XmlSerializer, I would like to store a few more independent elements (mainly strings from textboxes) in the same xml. public static void SaveBehaviors(ObservableCollection<Param> listParams) { XmlSerializer _paramsSerializer = new XmlSerializer(listParams.GetType()); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); path += "\\test.xml"; using (TextWriter writeFileStream = new StreamWriter(path)) { _paramsSerializer.Serialize(writeFileStream, listParams); using (XmlWriter writer = XmlWriter.Create(writeFileStream)) { writer.WriteStartElement("Foo"); //test entry... writer.WriteAttributeString("Bar", "Some & value"); writer.WriteElementString("Nested", "data"); writer.WriteEndElement(); } } } However, deserializing "test.xml" results in an error because of the added element. I suppose writing in the serialized xml file is prohibited and should be avoided?

    Read the article

  • Why does System.Threading.Timer callback successfully update UI?

    - by Geo P
    I have several System.Threading.Timers on my form application with callbacks that update the UI...successfully - i.e. without throwing errors. I had built these earlier, before I knew that UI should not be updated on any thread other than the UI thread. Now I am confused as to why it does not throw cross-thread exceptions when I am updating UI on these separate threading.timer threads? I will be changing these callbacks so that the UI updates are invoked on UI thread, but I am curious as to why this works. Edit: My application is a WinForms Application.

    Read the article

  • Android reset activity component state on navigation back

    - by Aure77
    I have 2 activities in my application. In activity1, I set some configuration and I modify the state of some component (ex: set button state disabled). And I navigate to activity2. In activity2 I do some stuff and at end, I finish this activity and come back to activity1. But In activity1, my components state are the same when I leave this activity. How to reset the components state with valuesdeclared in XML file (layout) ?

    Read the article

  • Autoscaling in a modern world&hellip;. Part 2

    - by Steve Loethen
    When we last left off, we had a web application spinning away in the cloud, and a local console application watching it and reacting to changes in demand.  Reactions that were specified by a set of rules.  Let’s talk about those rules. Constraints.  The first set of rules this application answered to were the constraints. Here is what they looked like: <constraintRules> <rule name="default" enabled="true" rank="1" description="The default constraint rule"> <actions> <range min="1" max="4" target="AutoscalingApplicationRole"/> </actions> </rule> </constraintRules> Pretty basic.  We have one role, the “AutoscalingApplicationRole”, and we have decided to have it live within a range of 1 to 4.  This rule does not adjust, but instead, set’s limits on what other rules can do.  It has a rank, so you can have you can specify other sets of constraints, perhaps based on time or date, to allow for deviations from this set.  But for now, let’s keep it simple.  In the real world, you would probably use the minimum to set a lower end SLA.  A common value might be a 2, to prevent the reactive rules from ever taking you down to 1 role.  The maximum is often used to keep a rule from driving the cost up, setting an upper limit to prevent you waking up one morning and find a bill for hundreds of instances you didn’t expect.  So, here we have the range we want our application to live inside.  This is good for our investigation and testing.  Next, let’s take a look at the reactive rules.  These rules are what you use to react (hence reactive rules) to changing demands on your application.  The HOL has two simple rules.  One that looks at a queue depth, and one that looks at a performance counter that reports cpu utilization.  the XML in the rules file looks like this: <reactiveRules> <rule name="ScaleUp" rank="10" description="Scale Up the web role" enabled="true"> <when> <any> <greaterOrEqual operand="Length_05_holqueue" than="10"/> <greaterOrEqual operand="CPU_05_holwebrole" than="65"/> </any> </when> <actions> <scale target="AutoscalingApplicationRole" by="1"/> </actions> </rule> <rule name="ScaleDown" rank="10" description="Scale down the web role" enabled="true"> <when> <all> <less operand="Length_05_holqueue" than="5"/> <less operand="CPU_05_holwebrole" than="40"/> </all> </when> <actions> <scale target="AutoscalingApplicationRole" by="-1"/> </actions> </rule> </reactiveRules> <operands> <performanceCounter alias="CPU_05_holwebrole" performanceCounterName="\Processor(_Total)\% Processor Time" source="AutoscalingApplicationRole" timespan="00:05:00" aggregate="Average" /> <queueLength alias="Length_05_holqueue" queue="hol-queue" timespan="00:05:00" aggregate="Average"/> </operands> These rules are currently contained in a file called rules.xml, that is in the root of the console application.  The console app, starts up, grabs the rules and starts watching the 2 operands.  When it detects a rule has been satisfied, it performs the desired action.  (here, scale up or down my 1). But I want to host the autoscaler  in the cloud.  For my first trick, I will move the rules (and another file called services.xml) to azure blob storage.  Look for part 3.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >