Search Results

Search found 31491 results on 1260 pages for 'simple talk'.

Page 68/1260 | < Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >

  • Simple regular expression for decimal numbers?

    - by finch
    I know this may be the simplest question ever asked on Stack Overflow, but what is the regular expression for a decimal with a precision of 2? Valid examples: 123.12 2 56754 92929292929292.12 0.21 3.1 Invalid examples: 12.1232 2.23332 e666.76 Sorry for the lame question, but for the life of me I haven't been able to find anyone that can help! The decimal place may be option, and that integers may also be included.

    Read the article

  • Simple ASP function question

    - by J Harley
    Good Morning, I have got the following function: FUNCTION queryDatabaseCount(sqlStr) SET queryDatabaseCountRecordSet = databaseConnection.Execute(sqlStr) If queryDatabaseCountRecordSet.EOF Then queryDatabaseCountRecordSet.Close queryDatabaseCount = 0 Else QueryArray = queryDatabaseCountRecordSet.GetRows queryDatabaseCountRecordSet.Close queryDatabaseCount = UBound(QueryArray,2) + 1 End If END FUNCTION And the following dbConnect: SET databaseConnection = Server.CreateObject("ADODB.Connection") databaseConnection.Open "Provider=SQLOLEDB; Data Source ="&dataSource&"; Initial Catalog ="&initialCatalog&"; User Id ="&userID&"; Password="&password&"" But for some reason I get the following error: ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed. /UBS/DBMS/includes/blocks/block_databaseoverview.asp, line 30 Does anyone have any suggestions? Many Thanks, Joel

    Read the article

  • Jquery Javascript function, simple error, can't find it!

    - by CodingIsAwesome
    When my page loads it calls the function like below: <body onLoad='changeTDNodes()'> And the code it calls is below: enter code here <script src='jquery-1.4.2.min.js' type='text/javascript'></script> <script> function changeTDNodes() { var threshValue = 10; $(".threshold").each(function(elem) { if($("b",elem).innerText > threshValue) { elem.addClass("overThreshold"); } }); }); } I have the class setup correctly in CSS .overThreshold { td{font-size:72px;} th{font-size:72px;} } But no classes are being changed, whats going on? Thanks for all your help!

    Read the article

  • how to make a simple collision detection of bitmaps in Android

    - by Dritan Berna
    I already have a code with collision but it has check for winners and ontouch method that I don't really need because my bitmaps are moving itself and I just want them to collide if they overlap. private boolean checkCollision(Grafika first, Grafika second) { boolean retValue = false; int width = first.getBitmap().getWidth(); int height = first.getBitmap().getHeight(); int x1start = first.getCoordinates().getX(); int x1end = x1start + width; int y1start = first.getCoordinates().getY(); int y1end = y1start + height; int x2start = second.getCoordinates().getX(); int x2end = x2start + width; int y2start = second.getCoordinates().getY(); int y2end = y2start + height; if ((x2start >= x1start && x2start <= x1end) || (x2end >= x1start && x2end <= x1end)) { if ((y2start >= y1start && y2start <= y1end) || (y2end >= y1start && y2end <= y1end)) { retValue = true; } } return retValue; }

    Read the article

  • Simple average calculation

    - by sasquatch90
    I'm trying to write program calculating average of given numbers stored in an array. Amount of numbers should be not more than 100, and user should input them until a !int variable is given : #include <iostream> #include <conio.h> using namespace std; double average(int tab[], int i){ int sum=0; for(int j=0; j<i; ++j){ sum+=tab[j]; } return (double)sum/i; } int main() { int tab[100]; int n=0; int number=0; do { if(n < 100){ cout << "Give " << n+1 << " number : "; cin >> number; tab[n]=number; number=0; ++n; } else{ break; } } while( !isdigit(number) ); cout << average(tab, n) << endl; getch(); return 0; } Why after giving char, it prints me 'Give n number:' for all empty cells of my array ? It should end and use only given numbers.

    Read the article

  • Simple binary File I/O problem with cstdio(c++)

    - by Atilla Filiz
    The c++ program below fails to read the file. I know using cstdio is not good practice but that what I am used to and it should work anyway. $ ls -l l.uyvy -rw-r--r-- 1 atilla atilla 614400 2010-04-24 18:11 l.uyvy $ ./a.out l.uyvy Read 0 bytes out of 614400, possibly wrong file code: #include<cstdio> int main(int argc, char* argv[]) { FILE *fp; if(argc<2) { printf("usage: %s <input>\n",argv[0]); return 1; } fp=fopen(argv[1],"rb"); if(!fp) { printf("erör, cannot open %s for reading\n",argv[1]); return -1; } int bytes_read=fread(imgdata,1,2*IMAGE_SIZE,fp); //2bytes per pixel fclose(fp); if(bytes_read < 2*IMAGE_SIZE) { printf("Read %d bytes out of %d, possibly wrong file\n", bytes_read, 2*IMAGE_SIZE); return -1; } return 0; }

    Read the article

  • simple question of pushViewController

    - by user217572
    messagecontroller is nothing but object of initialize nib file. [self.navigationController pushViewController:messageController animated:YES]; this statement executes in normal condition this statement also works on state maintainace testing , this line executes properly but not open new view ,why?

    Read the article

  • Java Newbie can't do simple Math, operator error

    - by elguapo-85
    Trying to do some really basic math here, but my lack of understanding of Java is causing some problems for me. double[][] handProbability = new double[][] {{0,0,0},{0,0,0},{0,0,0}}; double[] handProbabilityTotal = new double[] {0,0,0}; double positivePot = 0; double negativePot = 0; int localAhead = 0; int localTied = 1; int localBehind = 2; //do some stuff that adds values to handProbability and handProbabilityTotal positivePot = (handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0)); negativePot = (handProbability[localAhead][localBehind] + (handProbability[localAhead][localTied] / 2.0) + (handProbability[localTied][localBehind] / 2.0) ) / (handProbabilityTotal[localAhead] + (handProbabilityTotal[localTied] / 2.0)); The last two lines are giving me problems (sorry for their lengthiness). Compiler Errors: src/MyPokerClient/MyPokerClient.java:180: operator / cannot be applied to double[],double positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) ); ^ src/MyPokerClient/MyPokerClient.java:180: operator + cannot be applied to double, positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) ); ^ src/MyPokerClient/MyPokerClient.java:180: operator / cannot be applied to double, positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) ); Not really sure what the problem is. You shouldn't need anything special for basic math, right?

    Read the article

  • Simple getJSON does not work...

    - by user54197
    JSON function(Index) does not fire. Any Ideas? <script type="text/javascript"> $(document).ready(function() { alert("This alert is displayed :("); $("form[action$='GetQuote']").submit(function() { $.getJSON($(this).attr("action"), $(this).serialize(), function(Result) { alert("This alert is not shown :("); $("#name").html(Result.name); $("#address").html(Result.address); }); return false; }); }); </script> CONTROLLERS... public JsonResult GetQuote(string dataName) { if (dataName != "" || dataName != null) return new JsonResult { Data = new Result { name = "Hello", address = "World" } }; else return null; }

    Read the article

  • How to create a simple Proxy to access web servers in C

    - by jesusiniesta
    Hi. I’m trying to create an small Web Proxy in C. First, I’m trying to get a webpage, sending a GET frame to the server. I don’t know what I have missed, but I am not receiving any response. I would really appreciate if you can help me to find what is missing in this code. int main (int argc, char** argv) { int cache_size, //size of the cache in KiB port, port_google = 80, dir, mySocket, socket_google; char google[] = "www.google.es", ip[16]; struct sockaddr_in socketAddr; char buffer[10000000]; if (GetParameters(argc,argv,&cache_size,&port) != 0) return -1; GetIP (google, ip); printf("ip2 = %s\n",ip); dir = inet_addr (ip); printf("ip3 = %i\n",dir); /* Creation of a socket with Google */ socket_google = conectClient (port_google, dir, &socketAddr); if (socket_google < 0) return -1; else printf("Socket created\n"); sprintf(buffer,"GET /index.html HTTP/1.1\r\n\r\n"); if (write(socket_google, (void*)buffer, LONGITUD_MSJ+1) < 0 ) return 1; else printf("GET frame sent\n"); strcpy(buffer,"\n"); read(socket_google, buffer, sizeof(buffer)); // strcpy(message,buffer); printf("%s\n", buffer); return 0; } And this is the code I use to create the socket. I think this part is OK, but I copy it just in case. int conectClient (int puerto, int direccion, struct sockaddr_in *socketAddr) { int mySocket; char error[1000]; if ( (mySocket = socket(AF_INET, SOCK_STREAM, 0)) == -1) { printf("Error when creating the socket\n"); return -2; } socketAddr->sin_family = AF_INET; socketAddr->sin_addr.s_addr = direccion; socketAddr->sin_port = htons(puerto); if (connect (mySocket, (struct sockaddr *)socketAddr,sizeof (*socketAddr)) == -1) { snprintf(error, sizeof(error), "Error in %s:%d\n", __FILE__, __LINE__); perror(error); printf("%s\n",error); printf ("-- Error when stablishing a connection\n"); return -1; } return mySocket; } Thanks!

    Read the article

  • Need help with a simple ASP.NET ModalPopupExtender example

    - by remdao
    I'm new to ASP.NET and I'm trying to get this Ajax ModalPopupExtender working. This is an example i found on the net, but nothing happens when btnpopup is clicked. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ModalTestProject._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:scriptmanager id="ScriptManager1" runat="server"> </asp:scriptmanager> <asp:Button ID="btnpopup" runat="server" Text="Button" /> <ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btnpopup" PopupControlID="pnlpopup" CancelControlID="btnCancelpopup" EnableViewState="true" DropShadow="true" /> <asp:Panel ID="pnlpopup" runat="server" Width="400px"> test <asp:Button ID="btnCancelpopup" runat="server" Text="Button" /> </asp:Panel> </form> </body> </html>

    Read the article

  • Optimizing simple search script in PowerShell

    - by cc0
    I need to create a script to search through just below a million files of text, code, etc. to find matches and then output all hits on a particular string pattern to a CSV file. So far I made this; $location = 'C:\Work*' $arr = "foo", "bar" #Where "foo" and "bar" are string patterns I want to search for (separately) for($i=0;$i -lt $arr.length; $i++) { Get-ChildItem $location -recurse | select-string -pattern $($arr[$i]) | select-object Path | Export-Csv "C:\Work\Results\$($arr[$i]).txt" } This returns to me a CSV file named "foo.txt" with a list of all files with the word "foo" in it, and a file named "bar.txt" with a list of all files containing the word "bar". Is there any way anyone can think of to optimize this script to make it work faster? Or ideas on how to make an entirely different, but equivalent script that just works faster? All input appreciated!

    Read the article

  • How to make some simple GUI controls?

    - by daniels
    I need to make a DirectX or OpenGL app and i will need a custom GUI for that. I think a button, a input text box, a list box (that will need a scroll bar as there will be more items that can fit on the screen) and a slider control will be enough. I know about CeGUI framework but i just don't like it, way too many XML files for my taste. My question is where should i start in learning how to do this custom GUI controls, are there any tutorial available or any material that could get me started? I haven't done a GUI contol myself before.

    Read the article

  • Mod Rewrite - Simple Question

    - by bob
    This is my current .htaccess Options +FollowSymLinks DirectoryIndex index.php RewriteEngine On RewriteBase /product/ RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.+)\.php$ ./$1/ [R=301,L] RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L] RewriteRule ^contact/?$ ./contact.php [QSA,L] Everything is working fine now.. /product/contact return to /product/contact/ /product/contact.php return to /product/contact/ Question.. How to make all my .php will be /contact/ /help/ /faq/ Now I should to add contact.php help.php faq.php to the htaccess I tried to add RewriteRule ^(.*)/$ $1.php [QSA,L] but it will be return loop. Let me know how to fix it ;)

    Read the article

  • can this simple SQL query be optimized?

    - by ibiza
    Hi, I have the following query : SELECT COUNT(*) FROM Address adr INNER JOIN Auditable a on adr.UniqueId = a.UniqueId on a big DB (1.3M adresses, 4M+ auditables) both UniqueId columns are clustered primary keys the query is taking quite long to complete...I feel dumb, but is there any way to optimize it? I want to count all the address entries that have an underlying auditable... thanks!

    Read the article

  • Simple modal div in jQuery?

    - by jasondavis
    I have tried almost all of the jQuery Modal plkugins I can find on the net but they are all much to bulky for what I need. I dont need all the fancy features, I want to be able to open a div and have the background of the page go transparent grey like the photo below and have my div be on top of it, that is all I need to do so I would like to write some jquery to do this instead of using a bulky plugin. Does anyone have any small code that can do this task? Is the transparent background an image or just css?

    Read the article

  • How to fix this simple SQL query?

    - by morpheous
    I have a database with three tables: user_table country_table city_table I want to write ANSI SQL which will allow me to fetch all the user data (i.e. user details including the name of the country of the last school and the name of the city they live in now). The problem I am having is that I have to use a self join, and I am getting slightly confused. The schema is shown below: CREATE TABLE user_table (id int, first_name varchar(16), last_school_country_id int, city_id int); CREATE TABLE country_table (id int, name varchar(32)); CREATE TABLE city_table (id int, country_id int, name varchar(32)); This is the query I have come up with so far, but the results are wrong, and sometimes, the db engine (mySQL), asks me if I want to show all [HUGE NUMBER HERE] results - which makes me suspect that I am unintentionally creating a cartesian product somewhere. Can someone explain what is wrong with this SQL statement, and what I need to do to fix it? SELECT usr.id AS id, usr.first_name, ctry1.name as loc_country_name, ctry2.name as school_country_name, city.name as loc_city_name FROM user_table usr, country_table ctry1, country_table ctry2, city_table city WHERE usr.last_school_country_id=ctry2.id AND usr.city_id=city.id AND city.country_id=ctry1.id AND ctry1.id=ctry2.id;

    Read the article

  • Simple matrix example using C++ template class

    - by skyeagle
    I am trying to write a trivial Matrix class, using C++ templates in an attempt to brush up my C++, and also to explain something to a fellow coder. This is what I have som far: template class<T> class Matrix { public: Matrix(const unsigned int rows, const unsigned int cols); Matrix(const Matrix& m); Matrix& operator=(const Matrix& m); ~Matrix(); unsigned int getNumRows() const; unsigned int getNumCols() const; template <class T> T getCellValue(unsigned int row, unsigned col) const; template <class T> void setCellValue(unsigned int row, unsigned col, T value) const; private: // Note: intentionally NOT using smart pointers here ... T * m_values; }; template<class T> inline T Matrix::getCellValue(unsigned int row, unsigned col) const { } template<class T> inline void Matrix::setCellValue(unsigned int row, unsigned col, T value) { } I'm stuck on the ctor, since I need to allocate a new[] T, it seems like it needs to be a template method - however, I'm not sure I have come accross a templated ctor before. How can I implemnt the ctor?

    Read the article

  • Simple wxPython Frame Contents Resizing - Ratio?

    - by Wes
    I have a wxPython app with one frame and one panel. On that panel are a number of static boxes, each of which has buttons and textboxes. I have just begun reading about sizers, but they seem like they might be more than what I need, or it could that they are exactly what I need but I don't know how to use them correctly! The frame currently opens at 1920 x 1080. If the user drags the bottom right corner to resize the app, I just want everything to get smaller or larger as needed to keep the same size ratio. Is this possible? Thank you! edit: additional info: I used wxPython 2.8 and Boa to construct the GUI. I am contemplating trying another gui ide. So after reading some more about sizers, I am thinking about doing the following: add a gridsizer and basically divide my window's elements into rows and columns, then set each row and column's size as necessary until I achieve the original layout. Then I guess set the rows and columns to resize correctly? Is this a decent idea?

    Read the article

  • need help with a simple SQL update statement.

    - by Tony
    There's a field with type of varchar. It actually stores a float point string. Like 2.0 , 12.0 , 34.5 , 67.50 ... What I need is a update statement that remove the ending zeros of fields like 2.0 , 12.0 , change them to their integer representation , that is 2 , 12 ...,and leave 3.45 , 67.50 unchanged . How should I do this ? I am using oracle 10.

    Read the article

  • Simple C question

    - by Meko
    HI all. I am trying to make little program that reads data from file which has name of user and some data for that user. I am new on C , and how can i calculate this data for its user?line by line reading and adding each char in array? And how can I read line? is there any function?

    Read the article

  • Very simple python functions takes spends long time in function and not subfunctions

    - by John Salvatier
    I have spent many hours trying to figure what is going on here. The function 'grad_logp' in the code below is called many times in my program, and cProfile and runsnakerun the visualize the results reveals that the function grad_logp spends about .00004s 'locally' every call not in any functions it calls and the function 'n' spends about .00006s locally every call. Together these two times make up about 30% of program time that I care about. It doesn't seem like this is function overhead as other python functions spend far less time 'locally' and merging 'grad_logp' and 'n' does not make my program faster, but the operations that these two functions do seem rather trivial. Does anyone have any suggestions on what might be happening? Have I done something obviously inefficient? Am I misunderstanding how cProfile works? def grad_logp(self, variable, calculation_set ): p = params(self.p,self.parents) return self.n(variable, self.p) def n (self, variable, p ): gradient = self.gg(variable, p) return np.reshape(gradient, np.shape(variable.value)) def gg(self, variable, p): if variable is self: gradient = self._grad_logps['x']( x = self.value, **p) else: gradient = __builtin__.sum([self._pgradient(variable, parameter, value, p) for parameter, value in self.parents.iteritems()]) return gradient

    Read the article

< Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >