I'm searching for a way to parse the whole directory with source code with semantic. Is this possible to do without explicitly opening each file in emacs ?
I'm looking for some regular expression to help parse my CSV file.
The file has lines of
number,number
number,number
Comment I want to skip
number,number
number,number
Ex:
319,5446
564425,87
Text to skip
27,765564
I read each line into a string and I wanted to use some regular express to make sure the line matches the pattern of (number,number). If not then don't use the line.
How to handle the case where the token 'for' is used in two different situations in the language to parse? Such as statement and as a "parameter" as the following example:
echo for print example
for i in {0..10..2}
do
echo "Welcome $i times"
done
Output:
for print example
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
Thanks.
Hi! I am looking for method for parsing route path like this:
ActionController::Routing.new("post_path").parse
#=> {:controller => "posts", :action => "index"}
It should be opposite to url_for
Upd
I've found out:
http://stackoverflow.com/questions/2222522/what-is-the-opposite-of-url-for-in-rails-a-function-that-takes-a-path-and-genera
ActionController::Routing::Routes.recognize_path("/posts")
So now I need to convert posts_path into "/posts"
Hi guys
i need to make test of jtree component in my project. But i dont get any undertandable example on the internet. If anyone experienced about this . pls share sample or example code.Any help will be appreciated.
(I want to check tree nodes...)
Hi Guys,
Im trying to sort a column of data in a gtk tree view column non alphabetically. I cant seem to find a function in the GTK libraries that cant do such a thing
Does anyone here know of a way to do this?
Regards
Paul
Hi,
say there is an xml file, which not created by me, with a known schema (for example, rss).
how would you parse it with C#? would you do that manually by XDocument etc, or would you use XMLSerializer and create a correspond class? or would you use Visual Studio tools to generate classes using a dtd file (that you'll write).
what do you think the most aesthetic, easy, not error-prone way?
I want to test a service (Bar) that invokes another service (Foo) and returns a promise. The test is currently failing with this error:
Error: Unexpected request: GET foo.json
No more request expected
Here are the service definitions:
// Foo service returns new objects having get function returning a promise
angular.module('foo', []).
factory('Foo', ['$http', function ($http) {
function FooFactory(config) {
var Foo = function (config) {
angular.extend(this, config);
};
Foo.prototype = {
get: function (url, params, successFn, errorFn) {
successFn = successFn || function (response) {};
errorFn = errorFn || function (response) {};
return $http.get(url, {}).then(successFn, errorFn);
}
};
return new Foo(config);
};
return FooFactory;
}]);
// Bar service uses Foo service
angular.module('bar', ['foo']).
factory('Bar', ['Foo', function (Foo) {
var foo = Foo();
return {
getCurrentTime: function () {
return foo.get('foo.json', {}, function (response) {
return Date.parse(response.data.now);
});
}
};
}]);
Here is my current test:
'use strict';
describe('bar tests', function () {
var currentTime, currentTimeInMs, $q, $rootScope, mockFoo, mockFooFactory, Foo, Bar, now;
currentTime = "March 26, 2014 13:10 UTC";
currentTimeInMs = Date.parse(currentTime);
beforeEach(function () {
// stub out enough of Foo to satisfy Bar service:
// create mock object with function get: function(url, params, successFn, errorFn)
// that promises to return a response with this property
// { data: { now: "March 26, 2014 13:10 UTC" }})
mockFoo = {
get: function (url, params, successFn, errorFn) {
successFn = successFn || function (response) {};
errorFn = errorFn || function (response) {};
// setup deferred promise
var deferred = $q.defer();
deferred.resolve({data: { now: currentTime }});
return (deferred.promise).then(successFn, errorFn);
}
};
// create mock Foo service
mockFooFactory = function(config) {
return mockFoo;
};
module(function ($provide) {
$provide.value('Foo', mockFooFactory);
});
module('bar');
inject(function (_$q_, _$rootScope_, _Foo_, _Bar_) {
$q = _$q_;
$rootScope = _$rootScope_;
Foo = _Foo_;
Bar = _Bar_;
});
});
it('getCurrentTime should return currentTimeInMs', function () {
Bar.getCurrentTime().then(function (serverCurrentTime) {
now = serverCurrentTime;
});
$rootScope.$apply(); // resolve Bar promise
expect(now).toEqual(currentTimeInMs);
});
});
The error is being thrown at $rootScope.$apply(). I also tried using $rootScope.$digest(), but it gives the same error.
Thanks in advance for any insight you can give me.
Hi everyone,
I'm fighting with socket programming now and I've encountered a problem, which I don't know how to solve in a portable way.
The task is simple : I need to send the array of 16 bytes over the network, receive it in a client application and parse it. I know, there are functions like htonl, htons and so one to use with uint16 and uint32. But what should I do with the chunks of data greater than that?
Thank you.
I've been doing a research about the best algorithm to use in creating a binary tree implementation. THe top entry in my list is nested sets. Are there any other alternative or better algorithm??
Hi I'm trying to run a WordPress plugin and I get the following error:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /nfs/c03/h05/mnt/52704/domains/creathive.net/html/wp-content/plugins/qr-code-tag/lib/qrct/QrctWp.php on line 13
What would be the problem here? Line 13 is the public bit
EDIT: Here is some code:
class QrctWp
{
public $pluginName = 'QR Code Tag';
Hello,
Can anyone tell me how to parse a local xml file stored in the system using SAX ,with an example code.please also tell me where can i find information on that
"8,5,,1,4,7,,,,7,,1,9,3,6,,,8,6,3,9,,2,5,4,,,,,3,2,,,7,4,1,1,,4,,6,9,,5,,,,5,,,1,,6,3,,,6,5,,,,7,4,,1,7,6,,,,8,,5,,,7,1,,3,9,"
I'm doing a programming challenge where i need to parse this sequence into my sudoku script.
Need to get the above sequence into 8,5,0,1,4,7,0,0,0,7,0,1,9,3,6,0,0,8.........
I tried re but without success, help is appreciated, thanks.
Hi,
I want to parse google and yandex search results for my little website analyzer utility.
so i should send hundreds requests per minute. What is good practice for this issue?
Is google search api a good way?
I'd like my Python script to read some data out of a postgresql dump file. The Python will be running on a system without postgresql, and needs to process the data in a dump file.
It looks fairly straightforward to parse the CREATE TABLE calls to find the column names, then the INSERT INTO rows to build the contents. But I'm sure there would be quite a few gotchas in doing this reliably. Does anyone know of a module which will do this?
I would like to split a string using multiple chars to split upon. For example, consider spin text format:
This is a {long|ugly|example} string
I would want to parse this string and split it on the "{", "|", and "}" chars
myString.Split('|','{','}')
Now I have tokens to play with, but what I would like is to retain the info about which char was used to split each piece of the array that is returned.
Any existing code that can do something like this?
Which one would you choose? My important attributes are (not in order)
Support & Future enhancements
Community & general knowledge
base (on the Internet)
Comprehensive (i.e proven to
parse a wide range of *.*ml pages)
Performance
Memory Footprint (runtime, not the code-base)
I'd like to programatically determine the "publish location" (the location on the server which contains the installation) of the click-once application I'm running. I know that the appref-ms file contains this information and I could parse this file to find it but the application has no idea as to the location of the appref-ms file and I can't seem to find a way of determining this location.
Does anyone have any ideas how I can easily determine the publish location from within my application?
I'm creating a tree of folders and files in java. Windows and OSX return the system icons and name with the following code:
new JFileChooser().getIcon(File f);
new JFileChooser().getName(File f);
Is there any possibility to get the icons and name of unix systems?. A system command would be ok too.
Thanks.
I want to convert a string like this:
'10/15/2008 10:06:32 PM'
into the equivalent DATETIME value in Sql Server.
In Oracle, I would say this:
TO_DATE('10/15/2008 10:06:32 PM','MM/DD/YYYY HH:MI:SS AM')
This question implies that I must parse the string into one of the standard formats, and then convert using one of those codes. That seems ludicrous for such a mundane operation. Is there an easier way?
How can I cache an XSD schema (residing on disk) to be reused when parsing XMLs in Xerces (C++)?
I would like to load the XSD schema when starting the process, then, whenever I need to parse an XML, to validate it first using this loaded schema.
i am using XML as my backend for the application...
LXML is used to parse the xml.
How can i encrypt this xml file to make sure that the data is protected......
thanks in advance.
Hey guys, I have the following HTML structure that I am trying to pull information from:
// Product 1
<div class="productName">
<span id="product-name-1">Product Name 1</span>
</div>
<div class="productDetail">
<span class="warehouse">Warehouse 1, ACT</span>
<span class="quantityInStock">25</span>
</div>
// Product 2
<div class="productName">
<span id="product-name-2">Product Name 2</span>
</div>
<div class="productDetail">
<span class="warehouse">Warehouse 2, ACT</span>
<span class="quantityInStock">25</span>
</div>
…
// Product X
<div class="productName">
<span id="product-name-X">Product Name X</span>
</div>
<div class="productDetail">
<span class="warehouse">Warehouse X, ACT</span>
<span class="quantityInStock">25</span>
</div>
I don't have control of the source html and as you'll see productName and it's accompanying productDetail are not contained within a common element.
Now, I am using the following php code to try and parse the page.
$html = new DOMDocument();
$html->loadHtmlFile('product_test.html');
$xPath = new DOMXPath($html);
$domQuery = '//div[@class="productName"]|//div[@class="productDetail"]';
$entries = $xPath->query($domQuery);
foreach ($entries as $entry) {
echo "Detail: " . $entry->nodeValue) . "<br />\n";
}
Which prints the following:
Detail: Product Name 1
Detail: Warehouse 1, ACT
Detail: 25
Detail: Product Name 2
Detail: Warehouse 2, ACT
Detail: 25
Detail: Product Name X
Detail: Warehouse X, ACT
Detail: 25
Now, this is close to what I want. But I need to do some processing on each Product, Warehouse and Quantity stock and can't figure out how to parse it out into separate product groups. The final output I am after is something like:
Product 1:
Name: Product Name 1
Warehouse: Warehouse 1, ACT
Stock: 25
Product 2:
Name: Product Name 2
Warehouse: Warehouse 2, ACT
Stock: 25
I can't just figure it out, and I can't wrap my head around this DOM stuff as the elements don't quite work the same as a standard array.
If anyone can assist, or point me in the right direction I will be ever appreciative.
How can I do the equivalent of the Ruby snippet below using Java?
require 'net/http'
res = Net::HTTP.get_response(URI.parse("http://somewhere.com/isalive")).body
I need to determind when a file has been uploaded via an ftp account so i can parse the data and insert into a db.
I could do this 2 different ways, either set up a schedule or watch the directory for any change. Either option would be fine.
I'm new to the apache /php space so any keywords that i can search upon would be handy.
Thanks.