convert

How do I easily determine the age from an birthday? (php)

Possible Duplicate: Calculate years from date Hi, I have a table with a field representing the birthday. How do I find the age of the person from that date? This is what I have. $qPersoonsgegevens = "SELECT * FROM alg_persoonsgegevens WHERE alg_persoonsgegevens_leerling_ID = $leerling_id"; $rPersoonsgegevens = mysql_query(...

Convert a String in C++ Code

Hello, I'm learning C++ and developing a project to practice, but now i want to turn a variable(String) in code, like this, the user have a file that contains C++ code, but i want that my program reads that file and insert it into the code, like this: #include <iostream> #include <fstream> #include <string> #include <cstdlib> using name...

How to convert between two types of document markup with regex in C#?

Hi I am trying to convert between html-style markup such as bold and italics into my own custom markup format: <b>Bold word</b> ---> * Bold word * So the bold tag is converted to wrapping stars, etc. Whats the easiest/best/fastest way to do this? Parsing the string manually is easy enough, but what about regular expressions? I am u...

Convert list of floats into buffer in Python?

I am playing around with PortAudio and Python. data = getData() stream.write( data ) I want my stream to play sound data, that is represented in Float32 values. Therefore I use the following function: def getData(): data = [] for i in range( 0, 1024 ): data.append( 0.25 * math.sin( math.radians( i ) ) ) return dat...

Re-using a single file with basic ruby tested code in rails?

I got this code in a single file snippet.rb and it runs as expected. This script if from dzone snippet that fetches the thumbnail of the URL at the current time. Now I wan to integrate this functionality with Rails and here I'm stuck how to begin. Should I put this in some ruby file inside lib directory or make it modules??? I'm not muc...

PHP: Converting from UTF-8 HTML

I have a French site that I want to parse, but am running into problems converting the (uft-8) html to latin-1. The problem is shown in the following phpunit test case: class Test extends PHPUnit_Framework_TestCase { private static function fromHTML($str){ return html_entity_decode($str, ENT_QUOTES, 'UTF-8'); } publi...

convert batch files to exes

I'm wondering if it's possible to convert batch files to executables using C++? I have plenty of batch files here and I would like to convert them to executables (mainly to obfuscate the code). I understand that there are 3rd party tools that can do this but I was thinking that this would be a good opportunity for a programming project. ...

How to read a single BIT in an Array of Bytes?

The problem is that I have an Array of Byte with 200 Indexes and just want to check that is the Fourth bit of MyArray[75] is Zero(0) or One(1). byte[] MyArray; //with 200 elements //check the fourth BIT of MyArray[75] ...

How do I convert unicode characters to floats in Python?

I am parsing a webpage which has Unicode representations of fractions. I would like to be able to take those strings directly and convert them to floats. For example: "⅕" would become 0.2 Any suggestions of how to do this in Python? ...

How do I calculate the numeric value of a string with unicode components in python?

Along the lines of my previous question, http://stackoverflow.com/questions/1263796/how-do-i-convert-unicode-characters-to-floats-in-python , I would like to find a more elegant solution to calculating the value of a string that contains unicode numeric values. For example, take the strings "1⅕" and "1 ⅕". I would like these to resolve...

Convert Number to Corresponding Excel Column

Hi, I need some help in doing a logic that would convert a numeric value to corresponding MS Excel header value. For example: 1 = "A" 2 = "B" 3 = "C" 4 = "D" 5 = "E" ......... 25 = "Y" 26 = "Z" 27 = "AA" 28 = "AB" 29 = "AC" 30 = "AD" ......... Would appreciate some .NET codes (C# or VB) for this. Thanks. ...

Binary String to Integer

Hello, I have a binary string, entered by the user, which I need to convert to an integer. At first I naivly used this simple line: Convert.ToInt32("11011",2); Unfortunately this throws an exception if the user enters the integer directly. Convert.ToInt32("123",2); // throws Exception How can I make sure that the string entered b...

Third party library to convert image into pdf and eps format on the fly?

I have an upcoming .NET project that would require conversion from image (bitmap) into .pdf and .eps format. We would prefer to use third party library tool to do this rather than spending the time to reinvent the wheel. Here is the basic requirement: Preferrably a pure .NET library (we might put this converter code in Silverlight appl...

Lighttpd mod_rewrite to Apache Mod_rewrite

Hello, I am looking for some help here. I am trying to convert lighttpd mod_rewrite to apache mod_rewrite Here it is. Lighttpd url.rewrite-once = ( "/torrent/([0-9A-F]{2,2})([0-9A-F]{2,2})([0-9A-F]{36,36}).*" => "/t3/$1/$2/$3.torrent", ) I look up multiply tutorials of apache's mod_rewrite but really no help. Here what I came up...

How to convert float to int with Java

I used the following line to convert float to int, but not as accurate as I'd like : float a=8.61f; int b; b=(int)a; The result is : 8 [ It should be 9 ] When a=-7.65f, the result is : -7 [ It should be -8 ] What's the best way to do it ? ...

How do I convert from int to long in Java?

I keep finding both on here and Google people having troubles going from long to int and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going from int to Long. The only other answers I've found were "Just set it as Long in the first place" which really doesn't address the question. Ca...

Convert Python dict to object

Hi, I'm searching for an elegant way to convert a normal Python dict with some nested dicts to an object. For example: >>> d = {'a': 1, 'b': {'c': 2}, 'd': ["hi", {'foo': "bar"}]} Should be accessible in this way: >>> x = dict2obj(d) >>> x.a 1 >>> x.b.c 2 >>> x.d[1].foo bar I think, this is not possible without recursion, but wha...

Convert Java's java.util.calendar to PHP code

I'm looking to convert this line of code to PHP's mktime(): Calendar timeStartPoint = Calendar.getInstance(); timeStartPoint.set(11, 0); timeStartPoint.set(12, 0); timeStartPoint.set(13, 0); timeStartPoint.set(14, 0); timeStartPoint.set(5, monthStartPoint ? 1 : 5); timeStartPoint.set(2, 0); timeStartPoint.set(1, 2004); I imagine 1 is...

Java BigDecimal remove decimal and trailing numbers

Hello all, I'm new to Java and trying to take a BigDecimal (for example 99999999.99) and convert it to a string but without the decimal place and trailing numbers. Also, I don't want commas in the number and rounding is not needed. I've tried: Math.Truncate(number) but BigDecimal is not supported. Any ideas? Thanks very much. ...

Ruby - read bytes from a file, convert to integer

Hey, I'm trying to read unsigned integers from a file (stored as consecutive byte) and convert them to Integers. I've tried this: file = File.new(filename,"r") num = file.read(2).unpack("S") #read an unsigned short puts num #value will be less than expected What am I doing wrong here? Cheers, Pete ...