Daily Archives

Articles indexed Monday May 31 2010

Page 21/98 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • How to make "int" parse blank strings?

    - by Alex B
    I have a parsing system for fixed-length text records based on a layout table: parse_table = [\ ('name', type, length), .... ('numeric_field', int, 10), # int example ('textc_field', str, 100), # string example ... ] The idea is that given a table for a message type, I just go through the string, and reconstruct a dictionary out of it, according to entries in the table. Now, I can handle strings and proper integers, but int() will not parse all-spaces fields (for a good reason, of course). I wanted to handle it by defining a subclass of int that handles blank strings. This way I could go and change the type of appropriate table entries without introducing additional kludges in the parsing code (like filters), and it would "just work". But I can't figure out how to override the constructor of a build-in type in a sub-type, as defining constructor in the subclass does not seem to help. I feel I'm missing something fundamental here about how Python built-in types work. How should I approach this? I'm also open to alternatives that don't add too much complexity.

    Read the article

  • Read media stream from servlet in a webpage?

    - by khue
    Hi, I have a servlet that construct response to a media file request by reading the file from server: File uploadFile = new File("C:\TEMP\movie.mov"); FileInputStream in = new FileInputStream(uploadFile); Then write that stream to the response stream. My question is how do I play the media file in the webpage using or tag to read the media stream from the response. Thank you very much. Regards K.

    Read the article

  • change text color using jquery

    - by pradeep
    <input type='radio' name='specific_consultant' id='specific_consultant_no' value='no'>No</input> hii. i have a radio button like this . on click of this radio button , i need to change text color of text like No .. how do i do it..

    Read the article

  • generating images by user id php + mysql

    - by jay
    function user_image($id, $increment_views = false) { $id = mysql_real_escape_string($id); $q = mysql_query("SELECT * FROM `images` WHERE `id` = '$id'"); if (mysql_num_rows($q)) { $return = mysql_fetch_assoc($q); $q = mysql_query("SELECT * FROM `sources` WHERE `source_id` = $return[id] AND `source_flagged` = 0"); while ($r = mysql_fetch_assoc($q)) { $return['sources'][] = $r; } if ($increment_views) { $q = mysql_query("UPDATE `images` SET `views` = `views` + 1 WHERE `id` = $return[id]"); } return $return; } else { return false; } }

    Read the article

  • Tiling rectangles seamlessly in WPF while maintaing subpixel accuracy?

    - by Jens
    I have had the problem described in the question Tiling rectangles seamlessly in WPF, but am not really happy with the answers given there. I am painting a bar chart by painting lots of rectangles right next to each other. Depending on the scale of the canvas containing them, there are small gaps visible between some of them as a result from sub-pixel rendering. I learned from the above question how to make my rectangles fit with the screen pixels, removing that effect. Unfortunately, my chart may display way more bars than there are pixels. Apart from the tiny gaps (which manifest as a periodic change in color saturation), this works well. If I snap each bar with the screen pixels, most of the bars vanish, though, so I am looking for another solution. Thanks in advance!

    Read the article

  • Error: No mapping exists from object type....

    - by jakesankey
    Here is the code for my simple parsing application. I am getting an error that states 'No mapping exists from type System.Text.RegularExpressions.Match to a known managed provider native type'. This started to occur when I switched from using Split('_') to RegEx.Match for defining RNumberE, RNumberD, etc. Any guidance is appreciated. using System; using System.Data; using System.Data.SQLite; using System.IO; using System.Text.RegularExpressions; using System.Threading; using System.Collections.Generic; using System.Linq; using System.Data.SqlClient; namespace JohnDeereCMMDataParser { internal class Program { public static List<string> GetImportedFileList() { List<string> ImportedFiles = new List<string>(); using (SqlConnection connect = new SqlConnection(@"Server=FRXSQLDEV;Database=RX_CMMData;Integrated Security=YES")) { connect.Open(); using (SqlCommand fmd = connect.CreateCommand()) { fmd.CommandText = @"SELECT FileName FROM CMMData;"; fmd.CommandType = CommandType.Text; SqlDataReader r = fmd.ExecuteReader(); while (r.Read()) { ImportedFiles.Add(Convert.ToString(r["FileName"])); } } } return ImportedFiles; } private static void Main(string[] args) { Console.Title = "John Deere CMM Data Parser"; Console.WriteLine("Preparing CMM Data Parser... done"); Console.WriteLine("Scanning for new CMM data..."); Console.ForegroundColor = ConsoleColor.Gray; using (SqlConnection con = new SqlConnection(@"Server=FRXSQLDEV;Database=RX_CMMData;Integrated Security=YES")) { con.Open(); using (SqlCommand insertCommand = con.CreateCommand()) { Console.WriteLine("Connecting to SQL server..."); SqlCommand cmdd = con.CreateCommand(); string[] files = Directory.GetFiles(@"C:\Documents and Settings\js91162\Desktop\CMM WENZEL\", "*_*_*.txt", SearchOption.AllDirectories); List<string> ImportedFiles = GetImportedFileList(); insertCommand.Parameters.Add(new SqlParameter("@FeatType", DbType.String)); insertCommand.Parameters.Add(new SqlParameter("@FeatName", DbType.String)); insertCommand.Parameters.Add(new SqlParameter("@Axis", DbType.String)); insertCommand.Parameters.Add(new SqlParameter("@Actual", DbType.Decimal)); insertCommand.Parameters.Add(new SqlParameter("@Nominal", DbType.Decimal)); insertCommand.Parameters.Add(new SqlParameter("@Dev", DbType.Decimal)); insertCommand.Parameters.Add(new SqlParameter("@TolMin", DbType.Decimal)); insertCommand.Parameters.Add(new SqlParameter("@TolPlus", DbType.Decimal)); insertCommand.Parameters.Add(new SqlParameter("@OutOfTol", DbType.Decimal)); foreach (string file in files.Except(ImportedFiles)) { var FileNameExt1 = Path.GetFileName(file); cmdd.Parameters.Clear(); cmdd.Parameters.Add(new SqlParameter("@FileExt", FileNameExt1)); cmdd.CommandText = @" IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'RX_CMMData' AND TABLE_NAME = 'CMMData')) BEGIN SELECT COUNT(*) FROM CMMData WHERE FileName = @FileExt; END"; int count = Convert.ToInt32(cmdd.ExecuteScalar()); con.Close(); con.Open(); if (count == 0) { Console.WriteLine("Preparing to parse CMM data for SQL import..."); if (file.Count(c => c == '_') > 5) continue; insertCommand.CommandText = @" INSERT INTO CMMData (FeatType, FeatName, Axis, Actual, Nominal, Dev, TolMin, TolPlus, OutOfTol, PartNumber, CMMNumber, Date, FileName) VALUES (@FeatType, @FeatName, @Axis, @Actual, @Nominal, @Dev, @TolMin, @TolPlus, @OutOfTol, @PartNumber, @CMMNumber, @Date, @FileName);"; string FileNameExt = Path.GetFullPath(file); string RNumber = Path.GetFileNameWithoutExtension(file); int index2 = RNumber.IndexOf("~"); Match RNumberE = Regex.Match(RNumber, @"^(R|L)\d{6}(COMP|CRIT|TEST|SU[1-9])(?=_)", RegexOptions.IgnoreCase); Match RNumberD = Regex.Match(RNumber, @"(?<=_)\d{3}[A-Z]\d{4}|\d{3}[A-Z]\d\w\w\d(?=_)", RegexOptions.IgnoreCase); Match RNumberDate = Regex.Match(RNumber, @"(?<=_)\d{8}(?=_)", RegexOptions.IgnoreCase); if (RNumberD.Value == @"") continue; if (RNumberE.Value == @"") continue; if (RNumberDate.Value == @"") continue; if (index2 != -1) continue; /* string RNumberE = RNumber.Split('_')[0]; string RNumberD = RNumber.Split('_')[1]; string RNumberDate = RNumber.Split('_')[2]; */ DateTime dateTime = DateTime.ParseExact(RNumberDate.Value, "yyyyMMdd", Thread.CurrentThread.CurrentCulture); string cmmDate = dateTime.ToString("dd-MMM-yyyy"); string[] lines = File.ReadAllLines(file); bool parse = false; foreach (string tmpLine in lines) { string line = tmpLine.Trim(); if (!parse && line.StartsWith("Feat. Type,")) { parse = true; continue; } if (!parse || string.IsNullOrEmpty(line)) { continue; } Console.WriteLine(tmpLine); foreach (SqlParameter parameter in insertCommand.Parameters) { parameter.Value = null; } string[] values = line.Split(new[] { ',' }); for (int i = 0; i < values.Length - 1; i++) { SqlParameter param = insertCommand.Parameters[i]; if (param.DbType == DbType.Decimal) { decimal value; param.Value = decimal.TryParse(values[i], out value) ? value : 0; } else { param.Value = values[i]; } } insertCommand.Parameters.Add(new SqlParameter("@PartNumber", RNumberE)); insertCommand.Parameters.Add(new SqlParameter("@CMMNumber", RNumberD)); insertCommand.Parameters.Add(new SqlParameter("@Date", cmmDate)); insertCommand.Parameters.Add(new SqlParameter("@FileName", FileNameExt)); insertCommand.ExecuteNonQuery(); insertCommand.Parameters.RemoveAt("@PartNumber"); insertCommand.Parameters.RemoveAt("@CMMNumber"); insertCommand.Parameters.RemoveAt("@Date"); insertCommand.Parameters.RemoveAt("@FileName"); } } } Console.WriteLine("CMM data successfully imported to SQL database..."); } con.Close(); } } } }

    Read the article

  • how to select distinct rows for a column

    - by Satoru.Logic
    Hi, all. I have a table x that's like the one bellow: id | name | observed_value | 1 | a | 100 | 2 | b | 200 | 3 | b | 300 | 4 | a | 150 | 5 | c | 300 | I want to make a query so that in the result set I have exactly one record for one name: (1, a, 100) (2, b, 200) (5, c, 300) If there are multiple records corresponding to a name, say 'a' in the table above, I just pick up one of them. In my current implementation, I make a query like this: select x.* from x , (select distinct name, min(observed_value) as minimum_val from x group by name) x1 where x.name = x1.name and x.observed_value = x1.observed_value; But I think there may be some better way around, please tell me if you know, thanks in advance.

    Read the article

  • cocoa Expected specifier-qualifier-list before struct

    - by Circle
    I read the other posted solutions to using structs and resolving the "Expected specifier-qualifier-list before struct" related errors, but those aren't working. Is it different in Objective C? Do I need to declare my struct somewhere else in the class? It gives me the error on the line where I declare the typedef. Here is how it looks right now: @interface ClassA : NSObject { NSString *name; typedef struct _point { uint32_t x; uint64_t y; } Point; Point a; } @end

    Read the article

  • array of objects of a class

    - by anurag18294
    #include class test{ int a; char b; public: test() { cout<<"\n\nDefault constructor being called"; } test(int i,char j) { a=i; b=j; cout<<"\n\nConstructor with arguments called"; } }; int main() { test tarray[5]; test newobj(31,'z'); }; In the above code snippet can we intialize values to tarray[5].

    Read the article

  • PHP Combo Box AJAX Refresh

    - by bhs
    I have a PHP page that currently has 4 years of team positions in columns on the page. The client wants to select the players in positions and have first, second and thrid choices. Currently the page shows 4 columns with sets of combos for each position. Each combo has a full set of players in it and the user chooses the player he wants from the combos. On submit the player positions are stored in the database. However, the client now wants to change the page so that when he selects a player in a year and position then the player is removed from the combo and can no longer be selected for that year. I've used a bit of AJAX but was wondering if anyone had any thoughts/suggestions. The page is currently quite slow so they want it speeded up as well. The page layout is currently like this POISTION YEAR1 YEAR2 YEAR3 YEAR4 1 COMBOC1 COMBOC1 COMBOC1 COMBOC1 COMBOC2 COMBOC2 COMBOC2 COMBOC2 COMBOC3 COMBOC3 COMBOC3 COMBOC3 2 same as above COMBOC1, 2 and 3 all currently have the same players - when a player is selected it needs to be removed for all combos below it. I was thinking of starting by changing the page design and having text boxes for the players and a single player select under each year like this: POISTION YEAR1 YEAR2 YEAR3 YEAR4 1 <PLAYER><POSITION><CHOICE> ... [TEXT BOX CHOICE1] [TEXT BOX CHOICE2] [TEXT BOX CHOICE3] 2 ... Then I only have 1 combo box for each year to worry about - I do however have the same problem of refreshing the combo box and removing the player that has been selected, and I'd prefer to do it withough a page submit. Sorry for the long posting - cheers

    Read the article

  • Unexpected space between DIV elements

    - by jon
    my code for the php page displaying the divs <?php session_start(); require_once("classlib/mainspace.php"); if (isset($_SESSION['username'])==FALSE) { header("location:login.php"); } $user = new User($_SESSION['username']); ?><!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style/style.css" /> <title>SimpleTask - Home</title> </head> <body> <div id="main"> <div id="menu"> <div id="items"> <ul> <li><a href="home.php">home</a></li> <li>&bull;</li> <li><a href="projects.php">my projects</a></li> <li>&bull;</li> <li><a href="comments.php">my comments</a></li> </ul> </div> <div id="user"> <p>Welcome, <?php echo $user->GetRealName(); ?><br/><a href="editprofile.php">edit profile</a> &bull; <a href="logout.php">logout</a></p> </div> </div> <div id="content"> <h1>HOME</h1> </div> <div id="footer"> <p>footer text goes here here here here</p> </div> </div> </body> </html> and you can find my CSS here http://tasker.efficaxdevelopment.com/style/style.css and to view the live page go here http://tasker.efficaxdevelopment.com/login.php username:admin password:password

    Read the article

  • informix- datetime manipulation

    - by asdf
    Hi, i have 2 fields in a table test1 onlydate Date onlytime DATETIME HOUR to MINUTE and 1 fields in a table test2 dateandtime DATETIME YEAR to SECOND now i need to append the value of onlydate and onlytime field and set it to dateandtime field. Please help.

    Read the article

  • how to connect java and mysql using mysql connector java 5.1.12

    - by user225269
    I'm still a beginner in java. I dont have any idea on how to import the files that I have downloaded into my java class. Its in this path: E:\Users\user\Downloads\mysql-connector-java-5.1.12 I don't know what to do with the files I extracted from the file that I have downloaded in the mysql site for me to connect my java application and mysql database. I'm using Netbeans 6.8. And have also installed wampserver. ive already check out This: http://stackoverflow.com/questions/2118369/java-trouble-connecting-to-mysql and this: http://stackoverflow.com/questions/1640910/connecting-to-a-mysql-database But they don't seem to have answers on how to make use of the mysql java connector file from mysql site. Please help, thanks.

    Read the article

  • Provide "Paste Link" Functionality in C# Winforms App

    - by Tim
    I would like to add Copy-Paste Link functionality to an application. The application replaces a complex Excel workbook. I would like to be able to copy tables, text, and charts from the application and use Paste Link in MS Word. For the uninitiated: With Excel, when you use Paste Link for the tables, text, charts, etc. the items update in Word when you change them in Excel. Does anyone know for sure if this is/is not possible (is it some proprietary feature of MS Word-Excel)? If not, can anyone point me to some resources that will help (either an app that does this or a tutorial/write-up). Thanks!

    Read the article

  • How to trigger the event together on each two deferent class.

    - by XBasic3000
    I have two object class on a single unit, is it posible to trigger the two events? let say the FIRSTCLASS event is fired, The SECONDCLASS also will fired? Assuming...... //{Class 1}------------------------------------------------------------- type TOnEventTrigger = procedure(Sender : Tobject; Value :integer); TMyFirstClass = Class(Tcomponent) private .... public .... OnEventTrigger : TOnEventTrigger read Fevent write Fevent; end; procedure TMyFirstClass.FEvnt(Sender : Tobject; Value :integer); begin // here is normaly triggers the event // if Assigned(OnEventTrigger) then OnEventTrigger(Self,FSomevalue); // POSTMessage(GetForegroundWindow,WM_USER+3,0,0); // this is what i did here to get the result of FSomevalue // but this is not ideal. It work only on focus window. end; //{Class 2}------------------------------------------------------------- type TOnEventTrigger = procedure(Sender : Tobject; Value :integer); TMySecondClass = Class(Tobject) private .... public .... OnEventTrigger : TOnEventTrigger; read Fevent write Fevent; end; procedure TMySecondClass.FEvnt(Sender : Tobject; Value :integer); begin // I wanted here to trigger, whenenver the above is fired // if Assigned(OnEventTrigger) then OnEventTrigger(Self,FSomevalue); end;

    Read the article

  • Twitter oauth php problems

    - by Patrick Gates
    I'm writing some backend script for a twitter app and heres how it's going On the app you click a button that sends you to login.php on my server which logs into my database connects to twitter with my consumer key and secret: $to = new TwitterOAuth($consumer_key, $consumer_secret); $tok = $to->getRequestToken(); $request_link = $to->getAuthorizeURL($tok); and then writes the token and secret to the database, sets a session equal to the id in the database of the token and secret and then redirects to the "$request_link" You then go through the process of logging in and such on twitter and it redirects you to callback.php on my server Callback.php consists of logging into the database again, getting the new token and secret, and then writing the new token and secret to the database and then prompts you to go back to the app Then on the app, all I'm trying to do is access the basic credentials$to->get('account/verify_credentials') and it keeps coming back "could not authenticate you" What am I doing wrong?? Thank you for all the help :)

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >