Assume color = "orange";
Ruby:
puts("My favorite color is #{color.downcase() + 'ish'} -- at least for now.");
PHP:
print("My favorite color is {strtolower( $color ) + 'ish'} -- at least for now.");
The PHP version does not work like I would like it to. I'm not looking for any language wars, I just want to know if anyone knows of a...
Hi, I'm a python newbie (2 weeks) and I'm having trouble formatting a datetime.timedelta object.
Here's what I'm trying to do. I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event. I would like to display that duration in the format of hours:minutes.
I ha...
I know in php you are able to make a call like:
$function_name = 'hello';
$function_name();
function hello() { echo 'hello'; }
Is this possible in .Net?
...
std::string sAttr("");
sAttr = sAttr+VAL_TAG_OPEN+sVal->c_str()+VAL_TAG_CLOSE;
else where in the code I have defined
const char VAL_TAG_OPEN[] = "<value>";
sVal is a variable that is retrieved off of a array of string pointers. This works fine in most of the system, windows and linux. However at a customer site, where to my belief...
I have a List containing a lot of paths. I have a specific path I want to check against this list to see if there are any paths there that uses this path, ie:
f.StartsWith(r.FILENAME) && f != r.FILENAME
What would be the fastest way of doing this?
edit: Complete function from answer below:
static bool ContainsFragment(string[] pat...
Why do I fail to extract an integer value into Num variable ?
#include <sstream>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
string Digits("1 2 3");
stringstream ss(Digits);
string Temp;
vector<string>Tokens;
while(ss >> Temp)
Tokens.push_back(Temp);
ss.str(Tokens[0]);
...
Anyone know a better way to do this?
Dim Result1,Result2,FinalResult As String
Result1 = Left(sXMLResponse, sXMLResponse.IndexOf("<start>"))
Result2 = Mid(sXMLResponse, sXMLResponse.IndexOf("<end>"))
FinalResult =Result1 & Result2
Surely there is a built in String.Remove(StringOne, StringTwo) Method or something more graceful?
...
Hello i been trying to get a tokenizer to work using the boost library tokenizer class.
I found this tutorial on the boost documentation:
http://www.boost.org/doc/libs/1 _36 _0/libs/tokenizer/escaped _list _separator.htm
problem is i cant get the argument's to escaped _list _separator("","","");
but if i modify the boost/tokenizer.hpp...
Hi to all.
I want to perform a global replace of string using String.replace in Javascript.
In the documentation i read that i can do this with /g, i.e. for example;
var mystring = mystring.replace(/test/g, mystring);
and this will replace all occurrences inside mystring. No quotes for the expression.
But if i have a variable to f...
Hello,
I am using the format ToString("0,0") to display a number like 5000 as 5,000 but if the number is 0 - 9, it displays 01, 02, 03, etc. Does anyone know the correct syntax so it does not display the leading 0?
Thanks,
XaiSoft
...
The following code produces the output "xyz"
a = %w{x y z}
print a.to_s
Is there an option that can be added to the block to allow spaces to be added?
For example, I thought that by changing the code to this I might be able to space-separate the elements to produce an output of "x y z"
a = %w{"x " "y " "z "}
print a.to_s
Instead...
In my Ruby app, I've used the following method and regular expression to remove all HTML tags from a string:
str.gsub(/<\/?[^>]*>/,"")
This regular expression did just about all I was expecting it to, except it caused all quotation marks to be transformed into “
and all single quotes to be changed to ”
.
What's the obviou...
I'm trying to concat "(" + mouseX + ", " + mouseY ")". However, mouseX and mouseY are ints, so I tried using a stringstream as follows:
std::stringstream pos;
pos << "(" << mouseX << ", " << mouseY << ")";
_glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str());
And it doesn't seem to work.
I get the following error:
mouse.cpp:7...
So if you have a html List Box, also called a multiple select, and you want to generate a comma delimited string that lists all the values in that List Box you can you can do that with the following example. The list_to_string() js function is the only important thing here. You can play with this page at http://josh.gourneau.com/sandbox...
In Ruby, I have:
require 'uri'
foo = "et tu, brutus?"
bar = URI.encode(foo) # => "et%20tu,%20brutus?"
I'm trying to get bar to equal "et%20tu,%20brutus%3f" ("?" replaced with "%3F") When I try to add this:
bar["?"] = "%3f"
the "?" matches everything, and I get
=> "%3f"
I've tried
bar["\?"]
bar['?']
bar["/[?]"]
bar["/[\?]"...
// Reads NetworkStream into a byte buffer.
NetworkStream ns;
System.Net.Sockets.TcpClient client = new TcpClient();
byte[] receiveBytes = new byte[client.ReceiveBufferSize];
ns.Read(receiveBytes, 0, (int)client.ReceiveBufferSize);
String returndata = Encoding.UTF8.GetString(receiveBytes);
I am successfully reading from a client and s...
I came across this line in some code and can't find the syntax defined anywhere:
*(float *)csCoord.nX = lImportHeight* .04f; /* magic number to scale font size */
If I remove the f from .04f then the compiler gives a warning about possible data loss due to a conversion from 'double' to 'float'. I assume the f is doing some sort...
I've got a multidimensional array:
foo = [["a","b","c"], ["d", "e", "f"], ["g", "h", "i"]]
Now I need to ruturn the "coordinates" of "f", which should be (1,2). How can I do this without knowing which "row" "f" is in? I've been trying to use the index method, but this only works when I tell it where to look, i.e.
foo[1].index("f") #...
I have the method (Delphi 2009):
procedure TAnsiStringType.SetData(const Value: TBuffer; IsNull: boolean = False);
begin
if not IsNull then
FValue:= PAnsiString(Value)^;
inherited;
end;
This is an abstract method on the base class, where "Value: Pointer" expects the pointer of the corresponding data, as:
String = PString
Ansi...
I'm trying to extract email addresses from plain text transcripts of emails.
I've cobbled together a bit of code to find the addresses themselves, but I don't know how to make it discriminate between them; right now it just spits out all email addresses in the file. I'd like to make it so it only spits out addresses that are preceeded b...