In the C language: How do I convert unsigned long value to a string (char *) and keep my source code portable or just recompile it to work on other platform (without rewrite code)
First of all, I get the name of the current window
win32gui.GetWindowText(win32gui.GetForegroundWindow())
k, no problem with that...
But now, how can I make an if with the result for having an specific string on it...
For example, the result gave me
C:/Python26/
How can I make an True of False for the result containing the word, 'python' ?
I'm trying with re.search, but I'm not being able to make it do it
Hi All,
I have following:
temp = "aaaab123xyz@+"
lists = ["abc", "123.35", "xyz", "AND+"]
for list in lists
if re.match(list, temp, re.I):
print "The %s is within %s." % (list,temp)
The re.match is only match the beginning of the string, How to I match substring in between too.
Hi,
My rails application requires few values to be specified in the text box.
My web page contains few text boxes .How can i specify the values of these text boxes in the url as query string while using webrick?can any one help, am new to this.
Thanks in advance.
the Text property of control on winform is always string type, so if i wanna expose property of other type for custom control, i have to do the conversion as following, if i have dozens of properties to expose, it will be such pain for me.
public int ImageGroupLength
{
get
{
return int.Parse(this.imageGroupLength.Text);
}
set
{
this.imageGroupLength.Text = value.ToString();
}
}
so, is there any elegant way to do the conversion?
Would somebody care to help me out with a regex to reliably recognize and remove any number, followed by a dot, in the beginning of a string? So that
1. Introduction
becomes
Introduction
and
1290394958595. Appendix A
becomes
Appendix A
I have a few classes: SomeClass1, SomeClass2.
How can I create a new instance of one of these classes by using the class name from a string?
Normally, I would do:
var someClass1 = new SomeClass1();
How can I create this instance from the following:
var className = "SomeClass1";
I am assuming I should use Type.GetType() or something but I can't figure it out.
Thanks.
I have been given a file that has its string like this
blah blah DUMMY blah blah DUMMY blah blah VALUE blahX blahY KEY
Some values/keys are optional, i cannot depend on order. With regular expressions using C# how do i write an regex that takes the value directly behind the key? I know i could write it in such a way it will match the first DUMMY but i cant think of how to make the VALUE instead.
I can use JavaScript's split to put a comma-separated list of items in an array:
var mystring = "a,b,c,d,e";
var myarray = mystring.split(",");
What I have in mind is a little more complicated. I have this dictionary-esque string:
myvalue=0;othervalue=1;anothervalue=0;
How do I split this so that the keys end up in one array and the values end up in another array?
Hii,
I have a query string like "http://project/page1.aspx?userID=5". The operation won't be performed, if the 'userID' parameter changed manually. How it is possible?
http://mycloud.net/js/file.js#foo=bar
I'm trying to load a cross domain javascript file, and want to pass a variable along on the query string. I have seen the above '#' method used, but am unsure of how to extract the 'foo' value from within the file.js. Any clues how to handle this without the aid of server side help?
Thanks.
There is a byte at a specific index in a byte string which represents eight flags; one flag per bit in the byte. If a flag is set, its corresponding bit is 1, otherwise its 0. For example, if I've got
b'\x21'
the flags would be
0001 0101 # Three flags are set at indexes 3, 5 and 7
# and the others are not set
What would be the best way to get each bit value in that byte, so I know whether a particular flag is set or not? (Preferably using bitwise operations)
I need to sort string, and I came up with the following function.
def mysort(comb_):
str = []
size = len(comb_)
for c in comb_:
str.append(c)
str.sort()
return ''.join(str)
Is there any way to make it compact?
I'm using the following command in my web application to find all files in the current directory that contain the string foo (leaving out svn directories).
find . -not -ipath '.*svn*' -exec grep -H -E -o "foo" {} \; > grep_results.txt
How do I find out the files that doesn't contain the word foo?
Hi, I need date string using sql statement like..
select getDate()
this will return 2010-06-08 16:31:47.667
but I need in this format 201006081631 = yyyymmddhoursmin
How can I get this?
Thanks
I have a long String from a WYSIWYG (in my case YUI) which I then send as html email.
since its an email all CSS needs to be inline so how should i unescape this:
<span style=\"color: #c00000; font-size: 14px;\">
Is .gsub '\"' , '"' enough?
I want to create a makefile variable that is a multi-line string (e.g. the body of an email release announcement). something like
ANNOUNCE_BODY="
Version $(VERSION) of $(PACKAGE_NAME) has been released
It can be downloaded from $(DOWNLOAD_URL)
etc, etc"
But I can't seem to find a way to do this. Is it possible?
In a .Net web application I use the public DataRow[] Select(string filterExpression) method in many places. Due to a last minute change characters such as ' and " are now valid input. What options do I have, is there a way to change the filterExpression in an adequate way and still preserve the Select functionality on the datatable, can I switch to LINQ?
Hi
I want to change a USER AGENT string in runnig internet explorer (or after launching). So i cannt change throught a register key. Is there other way to do that issue?
Hey all,
I'm trying to make a system call in Python and store the output to a string that I can manipulate in the Python program.
#!/usr/bin/python
import subprocess
p = subprocess.Popen("pwd")
# edit - actual command I want to store output of
p2 = subprocess.Popen("ntpq -p")
I've tried a few things including some of the suggestions here:
http://stackoverflow.com/questions/1996518/retrieving-the-output-of-subprocess-call
but without any luck.
Many thanks!
I've got some analysis code (myprog) that sucks in data using the following:
if(5 == fscanf(in, "%s%lf%f%f%f", tag, & sec, & tgt, & s1, & s2))
which works just fine. But in the situation where I've got data files that are separated by commas, I'm currently doing something like:
sed 's/,/ /g' data | myprog
Can I modify the format string in the fscanf() function to accept both delimitation formats?
Hello!
Is there any fast way to convert given byte (like, by number - 65) to it's text hex representation?
Basically, I want to convert array of bytes into (I am hardcoding resources) their code-representation like
BYTE data[] = {0x00, 0x0A, 0x00, 0x01, ... }
How do I automate this Given byte -> "0x0A" string conversion?