Daily Archives

Articles indexed Thursday April 8 2010

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

  • Get a image from a uiview

    - by Monobono
    Hi I want to perform a shrink animation on a UITableVIew. I experimented a bit and found out that the animation runs much faster when I shrink a UIImageView with an image of the current state of the tableview instead of shrinking the table view itself. I grabbed the image in a method in my main viewcontroller prior to the animation: UIGraphicsBeginImageContext(mainTableView.bounds.size); [resizeContainer.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Works like a charm, at least almost. On very rare occasions I get weird graphic glitches, where the UIImage starts to overlap a toolbar that lies underneath it. I just want to make sure that I am getting the image in the right way. I am laking the necessary understand of GraphicContexts to be sure about it. To cut a long story short, is my code correct? Thx

    Read the article

  • Ruby on Rails form_remote_tag missing template

    - by Donald Hughes
    I'm using form_remote_tag(:url => {:controller => "home", :action => "search"}, :update => "mydiv"). When I click submit on the form "mydiv" is populated with the error "Template is missing. Missing template home/search.erb in view path app/views". I've tried multiple render options in def search, but they all result in the same error. It looks like the search method is trying to use it's default render even though I'm specifying what I want. I've tried: render 'index' render :text => 'Return this from my method!' Is my url incorrect? Is it not submitting back to my home controller's search method?

    Read the article

  • command binding for ribbon control

    - by kartik
    I'm trying to use the Microsoft ribbon control programatically using C#. Everything is fine but I'm unable to bind the command through the RibbonCommand. Can anyone give me an example of how to do this? My actual code is: Ribbon rbn = new Ribbon(); RibbonTab file = new RibbonTab(); file.Name = "file"; file.Label = "FILE"; RibbonTab edit = new RibbonTab(); edit.Name = "edit"; edit.Label = "Edit"; RibbonGroupPanel rbgp = new RibbonGroupPanel(); RibbonGroup rbg = new RibbonGroup(); RibbonButton rbtn = new RibbonButton(); rbtn.Content = "New"; RibbonCommand rcomnd = new RibbonCommand(); rcomnd.LabelTitle = "NEW"; rcomnd.ToolTipDescription = "THIS IS NEW"; rcomnd.LargeImageSource = imgSource; rcomnd.Execute(rbtn, rbtn); rbtn.IsEnabled = true; //rcomnd.SmallImageSource = imgSource; rcomnd.CanExecute +=new CanExecuteRoutedEventHandler(rcomnd_CanExecute); rcomnd.Executed +=new ExecutedRoutedEventHandler(rcomnd_Executed); CommandBinding cmdb = new CommandBinding(ApplicationCommands.New); cmdb.Command = ApplicationCommands.New; cmdb.Executed +=new ExecutedRoutedEventHandler(cmdb_Executed); CommandBind.Add(cmdb); //rcomnd.Executed += new ExecutedRoutedEventHandler(OnAddNewEntry);*/ rbtn.Click +=new System.Windows.RoutedEventHandler(rbtn_Click); rbtn.Command = rcomnd; But the bindings are not working and the button is not enabled.

    Read the article

  • How do I close a database connection in a WCF service?

    - by Dan
    I have been unable to find any documentation on properly closing database connections in WCF service operations. I have a service that returns a streamed response through the following method. public virtual Message GetData() { string sqlString = BuildSqlString(); SqlConnection conn = Utils.GetConnection(); SqlCommand cmd = new SqlCommand(sqlString, conn); XmlReader xr = cmd.ExecuteXmlReader(); Message msg = Message.CreateMessage( OperationContext.Current.IncomingMessageVersion, GetResponseAction(), xr); return msg; } I cannot close the connection within the method or the streaming of the response message will be terminated. Since control returns to the WCF system after the completion of that method, I don't know how I can close that connection afterwards. Any suggestions or pointers to additional documentation would be appreciated. Dan

    Read the article

  • How do I set values for a class without using any setter methods?

    - by fari
    Please can anyone help me public class KalaGameState implements Cloneable { // your code goes here public KalaGameState(int startingStones) throws InvalidStartingStonesException { // your code goes here } public int getTurn() { // your code goes here } public int getKala(int playerNum) throws IllegalPlayerNumException { // your code goes here } public int getNumStones(int sidePitNum) throws IllegalSidePitNumException { // your code goes here } public int getNumStones(int playerNum, int sidePitNum) throws IllegalPlayerNumException, IllegalSidePitNumException { // your code goes here } public int getScore(int playerNum) throws IllegalPlayerNumException { // your code goes here } private int getSidePitArrayIndex(int sidePitNum) throws IllegalSidePitNumException { // your code goes here } public boolean gameOver() { // your code goes here } public void makeMove(int sidePitNum) throws IllegalSidePitNumException, IllegalMoveException { // your code goes here } }

    Read the article

  • T-SQL XML Query, how to seperate matching nodes into individual rows?

    - by FlySwat
    I have a table that has a column full of XML like: <parent> <child> <name>Sally</name> </child> <child> <name>Bobby</name> </child> </parent> I'm trying to extract all of the names of the children into seperate rows. My desired resultset would look like: Sally Bobby However, if I do something like: SELECT data.query('data(//parents/child/name)') FROM stuff I get back a single row that looks like Sally Bobby What am I doing wrong with the XPath?

    Read the article

  • How do you post content to a specific template position?

    - by ?????
    I can't figure this out. I purchased a template / theme from RocketTheme, but I can't figure out how to add content at a specific position. The templates have "module positions" that collapse. I'd like to add some content at one of the module positions. If I add articles, they seem to go into "mainbody". But I'd like to have content in other areas of the template. How do I take some text, images, or other content, and get them to display in these other positions (i.e., TOP-A, or FEATURE-A, etc)?

    Read the article

  • NSData's writeToFile method failing with server address

    - by Ricky
    Hi. I am trying to write an NSData object to a directory like so; [myData writeToFile:[NSString stringWithFormat:@"%@/%@.txt", path, filename] atomically:YES]; I receive no errors or warnings but I am assuming the write fails because the path variable has the format of afp://10.0.0.20/username/Desktop. I am connected to the networked share. Do I need to modify the string or take a different approach here? TIA, Ricky.

    Read the article

  • AVG 9 (Internet Security Business Edition) and IIS 6.0

    - by Dave Holland
    Are any of you using AVG 9 Internet Security Business Edition along with IIS 6.0 and if so have you experienced problems? We just went from 8.5 to 9.0... Luckily I tried on only one of the servers in the web farm first to run for a week to make sure it played well with my servers. A few hours after the install all web apps were giving a "connection refused" error. Neither iisrest or restarting world wide web publishing services resolves the issue, only rebooting the machine brings the webs back up. They are all ASP.Net sites by the way (v2.5). What's interesting is if I take the machine out of the load balancer, the machine runs fine and the webs are just fine for days... as soon as i put it back in the pool it's only a few hours before its sad. The only thing I can think of right now is that the Resident Shield may be causing an issue, any thoughts?

    Read the article

  • ASP.NET MVC Resource not found

    - by TheLorax
    I am working on an MVC project in Visual Studio 2010 with .NET Framework 4.0 + MVC2 and everything works if I set the target framework to .NET 4.0. However, my host does not offer .NET 4.0 in order to deploy the site I need to get it working on .NET 3.5. I tried converting it to ASP.NET 3.5 and everything builds just fine except now when I try to load the homepage, I get a 404 Error saying: The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /home Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927 Anyone know why this is? Thank You for Your help. TheLorax

    Read the article

  • New computer crashing

    - by Alister
    I've just built a new computer and it crashes occasionally - it just switches off and then restarts and I'm not sure about the best way to diagnose the problem. All the components are seated nicely and nothing seems to be overheating, the bios is set to fail-safe. What tools could I use to track down any possible issues? I've run memtest86+ with no problems. It's running Win7 Ultimate.

    Read the article

  • Acer Aspire 1360 Recovery CDs

    - by John
    I have replaced a dead hard disk in an out of warranty Acer Apire 1360 laptop. The two recovery CDs I have dont appear to be bootable, they just contain .hdd and .ghs (image?) files. On the original broken hard drive there was a hidden partition which could be invoked by pressing alt+f10 when booting. You would then be prompted for the 2 recovery CDs to perform the restore. Obviously the new hard drive does not contain the hidden Acer recovery partition. This being the case, how do I go about restoring Win XP? The 2 CDs are called Aspire 1360/1520 Serires Recovery CD Disk 1 of 2 and 2 of 2. Am I missing a futher bootable recovery CD? Can anyone confirm how many restore CDs originally came with the laptop.

    Read the article

  • CPU on ubuntu goes crazy

    - by n179911
    Hi, I am running ubuntu 9.10. At the sudden the CPU goes crazy and when I do top, it is used by a command called 'dd' and it is run by USER 'root'. It keeps going to for 15 minutes. Can you please tell what is it doing? and if I can kill it by reboot my machine? Thank you.

    Read the article

  • Regex to match words and those with an apostrophe

    - by Beau Martínez
    I'm looking for a regex to only match words, possibly including numbers, and possibly with an apostrophe at the beginning, middle, or end; and ignore everything else. So these would be matched verbatim: 'bout it's persons' But these would be ignored: ' '' However, for words like 'open', open should be matched.

    Read the article

  • Quick fix, Read text in a text box?

    - by Tony C
    I have a simple text reading code for Visual Basic: Dim fileReader As String fileReader = My.Computer.FileSystem.ReadAllText("C:\test.txt") MsgBox(fileReader) I have used this in the past, but I usually make the text display in a text box. I know this is sort of a "newb" question but I can't remember how to display the text in a textbox. If you guys could help me out that would be great!

    Read the article

  • Nested DataPagers problem

    - by diamandiev
    Sample code <asp:Repeater> <ItemTemplate> <asp:ListView DataSource=<%# Container.DataItem.Items %> ... /> <asp:DataPager .... /> </ItemTemplate> </asp:Repeater> This does not work. The repeater data source is not a datasource control It is set like so repeater.DataSource = datasource repeater.DataBind()

    Read the article

  • How to draw an Arc in OpenGL

    - by rpgFANATIC
    While making a little Pong game in C++ OpenGL, I decided it'd be fun to create arcs (semi-circles) when stuff bounces. I decided to skip Bezier curves for the moment and just go with straight algebra, but I didn't get far. My algebra follows a simple quadratic function (y = +- sqrt(mx+c)). This little excerpt is just an example I've yet to fully parameterize, I just wanted to see how it would look. When I draw this, however, it gives me a straight vertical line where the line's tangent line approaches -1.0 / 1.0. Is this a limitation of the GL_LINE_STRIP style or is there an easier way to draw semi-circles / arcs? Or did I just completely miss something obvious? void Ball::drawBounce() { float piecesToDraw = 100.0f; float arcWidth = 10.0f; float arcAngle = 4.0f; glBegin(GL_LINE_STRIP); for (float i = 0.0f; i < piecesToDraw; i += 1.0f) // Positive Half { float currentX = (i / piecesToDraw) * arcWidth; glVertex2f(currentX, sqrtf((-currentX * arcAngle)+ arcWidth)); } for (float j = piecesToDraw; j > 0.0f; j -= 1.0f) // Negative half (go backwards in X direction now) { float currentX = (j / piecesToDraw) * arcWidth; glVertex2f(currentX, -sqrtf((-currentX * arcAngle) + arcWidth)); } glEnd(); } Thanks in advance.

    Read the article

  • Getting template metaprogramming compile-time constants at runtime

    - by GMan - Save the Unicorns
    Background Consider the following: template <unsigned N> struct Fibonacci { enum { value = Fibonacci<N-1>::value + Fibonacci<N-2>::value }; }; template <> struct Fibonacci<1> { enum { value = 1 }; }; template <> struct Fibonacci<0> { enum { value = 0 }; }; This is a common example and we can get the value of a Fibonacci number as a compile-time constant: int main(void) { std::cout << "Fibonacci(15) = "; std::cout << Fibonacci<15>::value; std::cout << std::endl; } But you obviously cannot get the value at runtime: int main(void) { std::srand(static_cast<unsigned>(std::time(0))); // ensure the table exists up to a certain size // (even though the rest of the code won't work) static const unsigned fibbMax = 20; Fibonacci<fibbMax>::value; // get index into sequence unsigned fibb = std::rand() % fibbMax; std::cout << "Fibonacci(" << fibb << ") = "; std::cout << Fibonacci<fibb>::value; std::cout << std::endl; } Because fibb is not a compile-time constant. Question So my question is: What is the best way to peek into this table at run-time? The most obvious solution (and "solution" should be taken lightly), is to have a large switch statement: unsigned fibonacci(unsigned index) { switch (index) { case 0: return Fibonacci<0>::value; case 1: return Fibonacci<1>::value; case 2: return Fibonacci<2>::value; . . . case 20: return Fibonacci<20>::value; default: return fibonacci(index - 1) + fibonacci(index - 2); } } int main(void) { std::srand(static_cast<unsigned>(std::time(0))); static const unsigned fibbMax = 20; // get index into sequence unsigned fibb = std::rand() % fibbMax; std::cout << "Fibonacci(" << fibb << ") = "; std::cout << fibonacci(fibb); std::cout << std::endl; } But now the size of the table is very hard coded and it wouldn't be easy to expand it to say, 40. The only one I came up with that has a similiar method of query is this: template <int TableSize = 40> class FibonacciTable { public: enum { max = TableSize }; static unsigned get(unsigned index) { if (index == TableSize) { return Fibonacci<TableSize>::value; } else { // too far, pass downwards return FibonacciTable<TableSize - 1>::get(index); } } }; template <> class FibonacciTable<0> { public: enum { max = 0 }; static unsigned get(unsigned) { // doesn't matter, no where else to go. // must be 0, or the original value was // not in table return 0; } }; int main(void) { std::srand(static_cast<unsigned>(std::time(0))); // get index into sequence unsigned fibb = std::rand() % FibonacciTable<>::max; std::cout << "Fibonacci(" << fibb << ") = "; std::cout << FibonacciTable<>::get(fibb); std::cout << std::endl; } Which seems to work great. The only two problems I see are: Potentially large call stack, since calculating Fibonacci<2 requires we go through TableMax all the way to 2, and: If the value is outside of the table, it returns zero as opposed to calculating it. So is there something I am missing? It seems there should be a better way to pick out these values at runtime. A template metaprogramming version of a switch statement perhaps, that generates a switch statement up to a certain number? Thanks in advance.

    Read the article

  • Is this a situation where Qt Model/View architecture is not useful?

    - by csmithmaui
    Hi, I am writing a GUI based application where I read a string of values from serial port every few seconds and I need to display most of the values in some type graphical indicator(I was thinking of QprogressBar maybe) that displays the range and the value. Some of the other data that I am parsing from the string are the date and fault codes. Also, the data is hierarchical. I wanted to use the model/view architecture of Qt because I have been interested in MVC stuff for a while but have never quite wrapped my brain around how to implement it very well. As of now, I have subclassed QAbstractItemModel and in the model I read the serial port and wrap the items parsed from the string in a Tree data structure. I can view all of the data in a QtreeView with no issues. I have also began to subclass QAbstractItemView to build my custom view with all of the Graphical Indicators and such. This is where I am getting stuck. It seems to me that in order for me to design a view that knows how to display my custom model the view needs to know exactly how all of the data in the model is organized. Doesn't that defeat the purpose of Model/View? The QTreeView I tested the model with is basically just displaying the model as it is setup in the Tree structure but I don't want to do that because the data is not all of the same type. Is the type of data or the way you would like to present it to the user a determining factor in whether or not you should use this architecture? I always assumed it was just always better to design in an MVC style. It seems to me like it might have been better to just subclass QWidget and then read in from the serial port and update all of subwidgets(graphical indicators, labels, etc...) from the subclass. Essentially, do everything in one class. Does anybody understand this issue that can explain to me either what I am missing or why I shouldn't be doing it this way. As of now I am a little confused. Thanks so much for any help!

    Read the article

  • Python Mindstorms RCX

    - by Kyle Schmidt
    I've got 30 unopened Lego Mindstorms kits that I'd love to use in my intro programming class to do some simple robotics stuff at the end of the year. We're using Python in the class, so I'd prefer there to be a way for the kids to write the programs in Python. Unfortunately, these are old kits with RCX bricks - not the newer NXT ones, so most of the projects like NXT_Python can't help me. Is there any way to make that happen?

    Read the article

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