Daily Archives

Articles indexed Wednesday March 17 2010

Page 1/128 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Resources for rails widget creation

    - by Kenji Crosland
    My rails app is about to go live and I'm trying to figure out how to create a widget based on data on the site. My Javascript is not too hot--limited to the O'reilly head first book on JS. I can read simple Javascript okay but when it comes to writing it I'm a little lost. That said, I hope to roll out a widget, maybe a wordpress plugin too soon after my app is launched. Does anyone know of any rails plugins, javascript templates, tutorials or books that can get me going? I did ask a similar question before here: But my limited knowledge of JS kept me from implementing the suggested answer properly.

    Read the article

  • How to avoid reallocation using the STL (C++)

    - by Tue Christensen
    This question is derived of the topic: http://stackoverflow.com/questions/2280655/vector-reserve-c I am using a datastructur of the type vector<vector<vector<double> > >. It is not possible to know the size of each of these vector (except the outer one) before items (doubles) are added. I can get an approximate size (upper bound) on the number of items in each "dimension". A solution with the shared pointers might be the way to go, but I would like to try a solution where the vector<vector<vector<double> > > simply has .reserve()'ed enough space (or in some other way has allocated enough memory). Will A.reserve(500) (assumming 500 is the size or, alternatively an upper bound on the size) be enough to hold "2D" vectors of large size, say [1000][10000]? The reason for my question is mainly because I cannot see any way of reasonably estimating the size of the interior of A at the time of .reserve(500). An example of my question: vector A; A.reserve(500+1); vector temp2; vector temp1 (666,666); for(int i=0;i<500;i++) { A.push_back(temp2); for(int j=0; j< 10000;j++) { A.back().push_back(temp1); } } Will this ensure that no reallocation is done for A? If temp2.reserve(100000) and temp1.reserve(1000) where added at creation will this ensure no reallocation at all will occur at all? In the above please disregard the fact that memory could be wasted due to conservative .reserve() calls. Thank you all in advance!

    Read the article

  • PHP explode not filling in array spot 0

    - by Billy Winterhouse
    I have a file we will call info.txt under UNIX format that has only the following in it: #Dogs #Cats #Birds #Rabbits and am running this against it: $filename = "info.txt"; $fd = fopen ($filename, "r"); $contents = fread ($fd,filesize ($filename)); fclose ($fd); $delimiter = "#"; $insideContent = explode($delimiter, $contents); Now everything looks to be working fine except when I display the array I get the following. [0] => [1] => Dogs [2] => Cats [3] => Birds [4] => Rabbits I checked the .txt file to make sure there wasn't any space or hidden characters in front of the first # so I'm at a loss of why this is happening other than I feel like I'm missing something terribly simple. Any ideas? Thanks in advanced!

    Read the article

  • WPF Auto height in code

    - by Karim
    How could I set the value of the Height property of a WPF control in C# code to "Auto"? <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> I want to reproduce this behavior in the code behind. Any ideas? Thanks in advance

    Read the article

  • Can not delete row from MySQL

    - by Drew
    Howdy all, I've got a table, which won't delete a row. Specifically, when I try to delete any row with a GEO_SHAPE_ID over 150000000 it simply does not disappear from the DB. I have tried: SQLyog to erase it. DELETE FROM TABLE WHERE GEO_SHAPE_ID = 150000042 (0 rows affected). UNLOCK TABLES then 2. As far as I am aware, bigint is a valid candidate for auto_increment. Anyone know what could be up? You gotta help us, Doc. We’ve tried nothin’ and we’re all out of ideas! DJS. PS. Here is the table construct and some sample data just for giggles. CREATE TABLE `GEO_SHAPE` ( `GEO_SHAPE_ID` bigint(11) NOT NULL auto_increment, `RADIUS` float default '0', `LATITUDE` float default '0', `LONGITUDE` float default '0', `SHAPE_TYPE` enum('Custom','Region') default NULL, `PARENT_ID` int(11) default NULL, `SHAPE_POLYGON` polygon default NULL, `SHAPE_TITLE` varchar(45) default NULL, `SHAPE_ABBREVIATION` varchar(45) default NULL, PRIMARY KEY (`GEO_SHAPE_ID`) ) ENGINE=MyISAM AUTO_INCREMENT=150000056 DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC; SET FOREIGN_KEY_CHECKS = 0; LOCK TABLES `GEO_SHAPE` WRITE; INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (57, NULL, NULL, NULL, 'Region', 10, NULL, 'Washington', 'WA'); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (58, NULL, NULL, NULL, 'Region', 10, NULL, 'West Virginia', 'WV'); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (59, NULL, NULL, NULL, 'Region', 10, NULL, 'Wisconsin', 'WI'); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (150000042, 10, -33.8833, 151.217, 'Custom', NULL, NULL, 'Sydney%2C%20New%20South%20Wales%20%2810km%20r', NULL); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (150000043, 10, -33.8833, 151.167, 'Custom', NULL, NULL, 'Annandale%2C%20New%20South%20Wales%20%2810km%', NULL); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (150000048, 10, -27.5, 153.017, 'Custom', NULL, NULL, 'Brisbane%2C%20Queensland%20%2810km%20radius%2', NULL); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (150000045, 10, 43.1002, -75.2956, 'Custom', NULL, NULL, 'New%20York%20Mills%2C%20New%20York%20%2810km%', NULL); INSERT INTO `GEO_SHAPE` (`GEO_SHAPE_ID`, `RADIUS`, `LATITUDE`, `LONGITUDE`, `SHAPE_TYPE`, `PARENT_ID`, `SHAPE_POLYGON`, `SHAPE_TITLE`, `SHAPE_ABBREVIATION`) VALUES (150000046, 10, 40.1117, -78.9258, 'Custom', NULL, NULL, 'Region1', NULL); UNLOCK TABLES; SET FOREIGN_KEY_CHECKS = 1;

    Read the article

  • How can I implement an abstract singleton class in Java?

    - by Simon
    Here is my sample abstract singleton class: public abstract class A { protected static A instance; public static A getInstance() { return instance; } //...rest of my abstract methods... } And here is the concrete implementation: public class B extends A { private B() { } static { instance = new B(); } //...implementations of my abstract methods... } Unfortunately I can't get the static code in class B to execute, so the instance variable never gets set. I have tried this: Class c = B.class; A.getInstance() - returns null; and this ClassLoader.getSystemClassLoader().loadClass("B"); A.getInstance() - return null; Running both these in the eclipse debugger the static code never gets executed. The only way I could find to get the static code executed is to change the accessibility on B's constructor to public, and to call it. I'm using sun-java6-jre on Ubuntu 32bit to run these tests.

    Read the article

  • Calling C# object method from IronPython

    - by Jason
    I'm trying to embed a scripting engine in my game. Since I'm writing it in C#, I figured IronPython would be a great fit, but the examples I've been able to find all focus on calling IronPython methods in C# instead of C# methods in IronPython scripts. To complicate things, I'm using Visual Studio 2010 RC1 on Windows 7 64 bit. IronRuby works like I expect it would, but I'm not very familiar with Ruby or Python syntax. What I'm doing: ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); //Test class with a method that prints to the screen. scope.SetVariable("test", this); ScriptSource source = engine.CreateScriptSourceFromString("test.SayHello()", Microsoft.Scripting.SourceCodeKind.Statements); source.Execute(scope); This generates an error, "'TestClass' object has no attribute 'SayHello'" This exact set up works fine with IronRuby though using "self.test.SayHello()" I'm wary using IronRuby though because it doesn't appear as mature as IronPython. If it's close enough, I might go with that though. Any ideas? I know this has to be something simple.

    Read the article

  • How to use "this" and not "this" selectors in jQuery

    - by tg4FSI
    I have 4 divs with content like below: <div class="prodNav-Info-Panel">content</div> <div class="prodNav-Usage-Panel">content</div> <div class="prodNav-Guarantee-Panel">content</div> <div class="prodNav-FAQ-Panel">content</div> And a navigation list like this: <div id="nav"> <ul id="navigation"> <li><a class="prodNav-Info" ></a></li> <li><a class="prodNav-Usage" ></a></li> <li><a class="prodNav-Guarantee"></a></li> <li><a class="prodNav-FAQ" ></a></li> </ul> </div> When the page is first displayed I show all the content by executing this: $('div.prodNav-Usage-Panel').fadeIn('slow'); $('div.prodNav-Guarantee-Panel').fadeIn('slow'); $('div.prodNav-FAQ-Panel').fadeIn('slow'); $('div.prodNav-Info-Panel').fadeIn('slow'); Now, when you click the navigation list item it reveals the clicked content and hides the others, like this: $('.prodNav-Info').click( function() { $('div.prodNav-Info-Panel').fadeIn('slow'); $('div.prodNav-Usage-Panel').fadeOut('slow'); $('div.prodNav-Guarantee-Panel').fadeOut('slow'); $('div.prodNav-FAQ-Panel').fadeOut('slow'); }); So what I have is 4 separate functions because I do not know which content is currently displayed. I know this is inefficient and can be done with a couple of lines of code. It seems like there is a way of saying: when this is clicked, hide the rest. Can I do this with something like $(this) and $(not this)? Thanks, Erik

    Read the article

  • Will Windows Phone 7 Support Multitasking third party apps

    - by Christopher Edwards
    Obviously it's early days, I do not know whether this is information that is in the public domain or not yet, but... I have trawled through some of this site - http://www.windowsphone7series.com/ but I can't seem to find the answer. Specifically will I be able to write an app on the phone that updates the cloud with the phones current GPS position in the background even when other apps are running in the foreground.

    Read the article

  • Replace text in Word Document via ASP.NET

    - by jreedinc
    How can I replace a string/word in a Word Document via ASP.NET? I just need to replace a couple words in the document, so I would like to stay AWAY from 3rd party plugins & interop. I would like to do this by opening the file and replacing the text. The following attempts were made: I created a StreamReader and Writer to read the file but I think that I am reading and writing in the wrong format. I think that Word Documents are stored in binary?? If word documents are binary, how would I read and write the file in binary? Dim template As String = Request.MapPath("documentName.doc") If File.Exists(template) Then Dim sr As New StreamReader(template) Dim content As String = sr.ReadToEnd() sr.Close() Dim sw As New StreamWriter(template) content = content.Replace("@ T O D A Y S D A T E", Date.Now.ToString("MM/dd/yyyy")) sw.Write(content) sw.Close() Else

    Read the article

  • Weird RecordStore behavior when RecordStoreFullException occurs

    - by Michael P
    Hello everyone! I'm developing a small J2ME application that displays bus stops timetables - they are stored as records in MIDP RecordStores. Sometimes records can not fit a single RecordStore, especially on record update - using setRecord method - a RecordStoreFullException occurs. I catch the exception, and try to write the record to a new RecordStore along with deleting the previous one in the old RecordStore. Everything works fine except of deleting record from RecordStore where the RecordStoreFullException occurs. If I make an attempt to delete record that could not be updated, another Exception of type InvalidRecordIDException is thrown. This is weird and undocumented in MIDP javadoc. I have tested it on Sun WTK 2.5.2, MicroEdition SDK 3.0 and Nokia Series 40 SDK. Furthermore I created a code that reproduces this strange behaviour: RecordStore rms = null; int id = 0; try { rms = RecordStore.openRecordStore("Test", true); byte[] raw = new byte[192*10024]; //Big enough to cause RecordStoreFullException id = rms.addRecord(raw, 0, 160); rms.setRecord(id, raw, 0, raw.length); } catch (Exception e) { try { int count = rms.getNumRecords(); RecordEnumeration en = rms.enumerateRecords(null, null, true); count = en.numRecords(); while(en.hasNextElement()){ System.out.println("NextID: "+en.nextRecordId()); } rms.deleteRecord(id); //this won't work! rms.setRecord(id, new byte[5], 0, 5); //this won't work too! } catch (Exception ex) { ex.printStackTrace(); } } I added extra enumeration code to produce other weird behavior - when RecordStoreFullException occurs, count variable will be set to 1 (if RMS was empty) by both methods - getNumRecords and numRecords. System.out.println will produce NextID: 0! It is not acceptable because record ID can not be 0! Could someone explain this strange behavior? Sorry for my bad English.

    Read the article

  • AppFabric Caching Feedback

    - by Michael Stephenson
    We are running a survey to collect feedback around scenarios where people were experimenting with velocity on windows 2003 in the CTP but are now in a position where the beta requires windows 2008. We would like to understand how important this scenario is precieved to be. If you are in the Connected Systems Community and would like to provide feedback please complete the following survey http://www.surveymonkey.com/s/N3VKZWN

    Read the article

  • Can I get the "value" of an arbitrary statement in JavaScript (like eval does, but without eval)

    - by tlrobinson
    In JavaScript is there a way to get the "value" of a statement in the same way that function() { return eval("if (true) { 1 }"); } returns "1"; function() { return if (true) { 1 } } and all similar permutations I've tried are not valid syntax. Is eval just blessed with special powers to determine the "last" value of a statement in an expression? Use case is a REPL that evaluates arbitrary expressions and returns the result. eval works, but I want to wrap it in function.

    Read the article

  • Recommendations on developing a WPF application without using MVVM or similar

    - by Metro Smurf
    We were building out the next version of an in-house thick-client application using WPF/Prism (Composite Application Library). As we were nearly done with the client our team was put under new management and shortly thereafter: We were then directed to drop the Prism framework to keep things simple. This includes not using any type of Inversion of Control. We were directed to build out the WPF application without using MVVM or similar; and more along the lines of a traditional WinForm application. The idea is that if a developer sees a control in Visual Studio’s designer view, then (s)he should be able to click on the control and see exactly what it's doing without having to traverse through a view-model (or similar). We have now been tasked with building out the WPF application using one primary Window, use a Frame Control to contain the content, and use a Ribbon outside of the frame for the menu items. Reason we were provided to use Frame Control: a. We will show a view in the Frame with a Page (not a user control) and then load the page in the Frame. b. When a new view is to be shown in the Frame, the current view (Page) will be closed/disposed and the new view (Page) will take its place in the Frame. c. When a developer looks at the Page in design view, (s)he will be able to click on any control and see exactly what is being done. Given the restrictions of 1 and 2 above, we’d like to present another method of building out the application that: Can be presented as an alternative to using the “Frame Methodology” (item 3 above) but still provides the same type of functionality. Does not use MVVM (see #1 and #2 above). Provided the direction we’ve been given, any suggestions as to an alternative we can present? I’d request that the responses be kept on the professional level and thank you in advance.

    Read the article

  • sscanf wrapping function to advance string pointer in C

    - by Dusty
    I have a function that makes a series of calls to sscanf() and then, after each, updates the string pointer to point to the first character not consumed by sscanf() like so: if(sscanf(str, "%d%n", &fooInt, &length) != 1) { // error handling } str+=length; In order to clean it up and avoid duplicating this several times over, i'd like to encapsulate this into a nice utility function that looks something like the following: int newSscanf ( char ** str, const char * format, ...) { int rv; int length; char buf[MAX_LENGTH]; va_list args; strcpy(buf, format); strcat(buf, "%n"); va_start(args, format); rv = vsscanf(*str, buf, args, &length); va_end(args); *str += length; return rv; } Then I could simply the calls as below to remove the additional parameter/bookkeeping: if(newSscanf(&str, "%d", &fooInt) != 1) { // error handling } Unfortunately, I can't find a way to append the &length parameter onto the end of the arg list directly or otherwise inside newSscanf(). Is there some way to work around this, or am I just as well off handling the bookkeeping by hand at each call?

    Read the article

  • Auto-Insert double quotes for HTML attributes broken

    - by ScottS
    In VS2008, it used to be that whenever I was typing an html attribute in an .aspx page when I hit '=' a pair of double quotes was automatically inserted and the cursor placed inside them. I guess I've changed a setting, but I don't know what to change to get that functionality back. I am using Resharper if it makes a difference.

    Read the article

  • Error: Expected specifier-qualifier-list before ... in XCode Core Data

    - by Doron Katz
    Hi guys, I keep on getting this error "error: expected specifier-qualifier-list for core data code im working with, in the app delegate. Now when i get this error and about 40 other errors relating to managedobjectcontext etc, i thought maybe the library needs to be imported. Now i havent done this before, but i went to Frameworks group and add existing frameworks and it added CoreData.framework. I re-build and it still came up with the error. Do I need to import anything in the headers explicitly or is there some other step i need to do? Thanks

    Read the article

  • Random select rows via JPA

    - by Ke
    In Mysql, SELECT id FROM table ORDER BY RANDOM() LIMIT 5 this sql can select 5 random rows. How to do this via JPA Query (Hibernate as provider, Mysql database)? Thanks.

    Read the article

  • Telerik RadEditor for MOSS - How do I suppress min-width inline CSS?

    - by James
    I'm having an issue with the RadEditor for MOSS, I'm really baffled as to the source of this issue. I tried using Firebug to find where any min-* CSS settings are happening and search came up empty, but I know it's happening because the downloaded page markup does not have that inline CSS. I believe that one of the Telerik control emitted Javascripts is what is adding inline CSS style to the top level div of the editor, namely min-height, min-width. This is causing layout issues on my page. My question is why is it doing this, and more importantly how do I prevent this from happening? <div style="height: 300px; width: 100%; min-height: 300px; min-width: 1133px;" class="RadEditor Default reWrapper ms-input"> Related thread

    Read the article

  • SAT Thread and Process output capture in c#

    - by alex
    Hi: This is a strange problem I encountered. I have an window application written in c# to do testing. It has a MDI parent form that is hosting a few children forms. One of the forms launch test cripts by creating processes and capture the scripts output to a text box. Another form open serial port and monitoring the status of the device I am working on(like a shell). If I ran both of them together, the output of the script seems only appear in the text box after the test is done. However, If I don't open the serial port form, the output of the script is captured in real time. Does anyone knows what's causing the problem? I notice the onDataReceived even handler for serial port form has a [SAThread] header to it. Will this cause the serial port thread having higher priority than other processes? Thanks in advance.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >