Skip to main content

Posts

Showing posts with the label parsing

Objective C parse hex string to integer

I would like to know how to parse a hex string, representing a number, in objective c. I am willing to use both an objective, or a C based method, either is fine. example: #01FFFFAB should parse into the integer: 33554347 Any help would be appreciated!

Parsing JSON Feed iOS 5

I'm pretty new to iOS development, and I'm wanting to parse the values of a JSON twitter feed, so I can pull them through into a tableView. So far, I have the information from the feed logging into my console bar as a string, but I'm stuck with where to go next. My current code is: - (void)loadTweets { NSString *twitterURL = [NSString stringWithFormat:@"https://api.twitter.com/1/statuses/user_timeline.json?screen_name=evostikleague&count=%d", tweetCellCount]; NSURL *fullURL = [NSURL URLWithString:twitterURL]; NSError *error = nil; NSData *dataURL = [NSData dataWithContentsOfURL:fullURL options:0 error:&error]; NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]; NSLog(@"Everything:\n%@", strResult); } Which gives me the raw data from the feed: [{"id_str":"171930825225551872","coordinates":null,"in_reply_to_status_id_str":null,"place":null,"po

Splitting a CSV into an object with javascript/jquery

I have an ordered array which looks like this:- [-0.0020057306590257895, 50, 0.09598853868194843, 50, 0.19398280802292264, 49.99999999999999, 0.2919770773638969, 50] What I would like to do is the following: Take each 'odd' entry and make it the 'key index in an object, which can be achieved by rounding the value and multiplying by 10 e.g. (Math.round(-0.0020057306590257895 * 10) should be index 0 and Math.round(0.09598853868194843 * 10) should be index 1 etc) Take the 'even' values and make them the corresponding values in the object. So... The above CSV file should return the following object:- { 0: 50, 1: 50, 2: 49.99999999999999, 3: 50 } Does anyone one know how I can parse this CSV to produce the required array using either jQuery or plain javascript?

How to extract relative URL from argument values from request string?

I have a request url / string var like http://ip_or_url:4773/image_renderer.service?action=resize&from_format=png&from_url=http://ip_or_url:4773/my_file.user.file&to_format=jpg&w=1920&h=1200 It looks terribly scary. I wonder how to extract from_url=http://195.19.243.13:4773/my_file.user.file argument pair from it and then extract relative file url from that pair value my_file.user.file ?

Needing to expand this regex URL/mail parser a bit further

function make_clickable($text) { $ret = ' ' . $text; $ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a target=\"_blank\" href=\"http://\\2\" >\\2</a>'", $ret); $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); $ret = substr($ret, 1); return($ret); } Problems: http://www.google.com , http://www.google.com ; http://www.google.com . http://www.google.com : http://www.google.com ? (http://www.google.com) as well as make sure that other domains lik

Posting Data to Amazon using curl

when we enter a keyword (search term) in amazon kindle book store, search brings a list of books back. I am trying to scrap the above said amazon kindle book search, i have some basic/usage idea of CURL in php, but i have never posted variables using curl. I tried at my level. but havent succeeded yet. the only thing i know is i should post "key-word" variable to amazon and should grab the result. The problem with this step is that the key-word is submited to the form and only a part of the page is refreshed everytime key-word is entered. can somebody help me telling the step required? which data i will need to post icluding key-word? how can i know about the header /user agent required for this? what information will be required for this process? which elements will be posted ? I have tried using fiddler but as i am new to it, i am not getting the concepts. The link i want to parse is amazon.com Guideline please, if i get the what need