w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Convert to string, remove some parts and convert back to byte[]
What you are looking for is Encoding.GetString not Base64 string. var newstr = String.Join(Environment.NewLine, Encoding.UTF8.GetString(buf) .Split(new char[] { ' ', ' ' }) .Skip(4)); buf = Encoding.UTF8.GetBytes(newstr);

Categories : C#

ubuntu - using imagemagick convert utlity to convert image into a multipage pdf
you can crop each image into sections and then put it back together like this. the dimensions are the size it will crop each part of the page into. convert aaaaaaaaa.png -crop 943x1360 +repage multipage.pdf

Categories : Ubuntu

convert latest date to convert into time_ago format
You are using time values for dates. Why not just use DateTime.to_date (docs) and then compare dates? Next, the Enumerable#max method compares elements on their <=>-method. It doesn't change type or value. Maybe this helps you out: max = [Time.now, Time.now-2.hours].max # => 2013-07-08 19:05:35 +0200 max = [Time.now, Time.now-2.hours].map(&:to_date).max # => Mon, 08 Jul 2013 ActionView::DateHelpers.time_ago_in_words(max) # => "about 10 minutes ago"

Categories : Ruby On Rails

convert a hexadecimal into a decimal via string convert in java
Use the overloaded Integer.parseInt method that takes a second parameter for the radix: Integer.parseInt(str1, 16);

Categories : Java

How do I read binary data, convert it to an int, then convert it back in C++?
I figured it out. A couple things I learned were that you can perform calculations on 8-bit char variables (with a max value of 255 unsigned), so I didn't need to change it to an int array, however, I did because it gave me more headroom to work with (without worrying about clipping the values at 255). I have included the entire program (with the header include list), as I also think this is a common question, and this by far is the simplest way I've seen to do it (the other ways I couldn't figure out -- they were much more complicated than this to do the same thing). It reads the wav file, then it performs an operation on the data portion (beginning at the 45'th byte), then it does the reverse, and writes the file, which is a copy of the original. #include <iostream> #include &l

Categories : C++

Using hg convert to convert git repo to old svn format
You can use a current version of Subversion to dump the repository into a version-agnostic format (svnadmin dump), then use the older version of Subversion to load that dumpfile into a new repository (svnadmin load). Otherwise, I would suggest finding older versions of the hg & git based tools that support that older version of Subversion.

Categories : GIT

How can I convert a query string into a a shorter alphanumeric string (and convert it back again) in PHP?
You can use base64_encode() and base64_decode(), but if you want it as a filename, you'll likely hit filename length limit of filesystem (255 chars for ext3). If it's possible you hit this limit, you can use each X chars as directory name, and create full path.

Categories : PHP

JavaScript: Need functions to convert a string containing binary to hex, then convert back to binary
Try this jsfiddle. The more interesting functions to you are here. Not necessarily the cleanest or most efficient ones, but yea: // converts binary string to a hexadecimal string // returns an object with key 'valid' to a boolean value, indicating // if the string is a valid binary string. // If 'valid' is true, the converted hex string can be obtained by // the 'result' key of the returned object function binaryToHex(s) { var i, k, part, accum, ret = ''; for (i = s.length-1; i >= 3; i -= 4) { // extract out in substrings of 4 and convert to hex part = s.substr(i+1-4, 4); accum = 0; for (k = 0; k < 4; k += 1) { if (part[k] !== '0' && part[k] !== '1') { // invalid character return { valid: fa

Categories : Javascript

How to convert vector to string and convert back to vector
The easiest thing would be to insert a space character as a separator when you're writing, as that's the default separator for operator>> sw << v[i] << ' '; Now you can read back into an int variable directly, formatted stream input will do the conversion for you automatically. Use vector's push_back method to add values to it as you go.

Categories : C++

Using rsvg-convert can one convert multi page or multi file SVG to multi page PDF?
you can provide a list of .svg files when converting to pdf. rsvg-convert -f pdf -o out.pdf file1.svg file2.svg file3.svg alternatively you can convert all .svg files in a folder to 1 pdf like this: rsvg-convert -f pdf -o out.pdf *.svg

Categories : Linux

Convert XML to CSV
import csv import sys import xml.etree.ElementTree as etree if __name__ == "__main__": file_name = sys.argv[1] csv_file_name = '.'.join(file_name.split('.')[:-1]) + ".csv" root = etree.parse(file_name).getroot() with open(csv_file_name, 'w') as file_: writer = csv.writer(file_, delimiter=" ") for a in zip(root.findall("drillholes/hole/collar"), root.findall("drillholes/hole/toe"), root.findall("drillholes/hole/cost")): writer.writerow([x.text for x in a])

Categories : Python

Convert C# to PHP
Your arrays don't look right. ItemLines and PaymentLines should be arrays instead of an object containing an array. Even though StartSale returns them as objects, they should still be an array for the call to SaveSale. The reason they are returned as objects is a quirk of the PHP SoapClient. What happens is, if there is just one element in the array, the SoapClient gives you an object with its properties set as the single element properties. However if there is more than one element in the array, you get an array of objects instead, and so is one level deeper than the result when there's only a single element. So because they are returned with no elements from StartSale, they are given as objects instead of an empty array. ... ... $Sale->StartSaleResult->ItemLines = array($line);

Categories : C#

Convert pdf to png in R
The result of im.convert is probably not satisfactory because it uses the default resolution, which is 74 dpi. You can increase the resolution by passing an extra parameter: im.convert("bm.pdf", output = "bm.png", extra.opts="-density 150") -density 150 will double the resolution and your PNGs and JPEGs will look nicer. But in general it is probably better to use png() and jpeg() to generate the plots and use appropiate parameters to get the same results as with pdf(). For example: pdf(width=5, height=5) plot(1:10) dev.off() png(width=5, height=5, units="in", res=150) plot(1:10) dev.off()

Categories : R

How do I convert to UTC?
Just throw that string into a Date() function and you should get it back as a Javascript Date object. var myDate = new Date('2013-06-08T06:00:00.000-07:00'); To get it back as a formal UNIX timestamp, you just need to convert it back to a number, and divide by 1000 (as there are a thousand ms in a second), but it looks like you're looking for the ms value, not a formal UNIX timestamp. Easiest way would be to use the + prefix operator. var myUnixTimestamp = +myDate; // 1370696400000

Categories : Javascript

c# convert UTC to EDT
I suspect your UnixTimeStampToDateTime method is incorrect. Assuming it's taking the number of seconds since the Unix epoch, it should return a DateTime with a Kind of Utc already, e.g. private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); public static DateTime UnixTimeStampToDateTime(double secondsSinceUnixEpoch) { return UnixEpoch.AddSeconds(secondsSinceUnixEpoch); } EDIT: Now that we can see the existing implementation - yes, it's inappropriate. There's no reason why you should want to create an Unspecified value and then convert it to a Local one. Using the above should be fine, and more useful in general. Any existing calls which need a system local value should call ToLocalTime on the result of UnixTimeStampToDateTime. (Alter

Categories : C#

Convert XML to CSV with PHP
Try this $filexml='test.xml'; if (file_exists($filexml)) { $xml = simplexml_load_file($filexml); $f = fopen('test.csv', 'w'); createCsv($xml, $f); fclose($f); } function createCsv($xml,$f) { foreach ($xml->children() as $item) { $hasChild = (count($item->children()) > 0)?true:false; if( ! $hasChild) { $put_arr = array($item->getName(),$item); fputcsv($f, $put_arr ,',','"'); } else { createCsv($item, $f); } } }

Categories : PHP

How to convert HSB to RGB
Here is a Delphi a translation of C code found here: http://www.cs.rit.edu/~ncs/color/t_convert.html function RGBFP(R, G, B: Double): TColor; const RGBmax = 255; begin Result := RGB(Round(RGBmax * R), Round(RGBmax * G), Round(RGBmax * B)); end; function HSVtoRGB(H, S, V: Double): TColor; var i: Integer; f, p, q, t: Double; begin Assert(InRange(H, 0.0, 1.0)); Assert(InRange(S, 0.0, 1.0)); Assert(InRange(V, 0.0, 1.0)); if S = 0.0 then begin // achromatic (grey) Result := RGBFP(V, V, V); exit; end; H := H * 6.0; // sector 0 to 5 i := floor(H); f := H - i; // fractional part of H p := V * (1.0 - S); q := V * (1.0 - S * f); t := V * (1.0 - S * (1.0 - f)); case i of 0: Result := RGBFP(V, t, p); 1: Result := RGBFP(q, V, p); 2: Re

Categories : Delphi

How to convert xml to csv using xsl
Try this XSLT to get your desired output: <xsl:template match="portfolio"> <xsl:text>"Name";"Price"</xsl:text> <xsl:text>&#10;</xsl:text> <xsl:for-each select="stock"> <xsl:text>"</xsl:text> <xsl:value-of select="name"/> <xsl:text>";</xsl:text> <xsl:text>"</xsl:text> <xsl:value-of select="price"/> <xsl:text>"</xsl:text> <xsl:text>&#10;</xsl:text> </xsl:for-each> </xsl:template>

Categories : Xml

Convert from txt to xml
you get the string from the file while reading and then write the condition for serial number Example String sample = "282826228ff"; String output = sample.replaceAll("\D+",""); Output: 282826228

Categories : Java

Why do we convert from RGB to HSV
According to http://en.wikipedia.org/wiki/HSL_and_HSV#Use_in_image_analysis : Because the R, G, and B components of an object’s color in a digital image are all correlated with the amount of light hitting the object, and therefore with each other, image descriptions in terms of those components make object discrimination difficult. Descriptions in terms of hue/lightness/chroma or hue/lightness/saturation are often more relevant. Also some good info here

Categories : Opencv

Convert MP3 to WAV on WP8
Not sure this will work on WP8 but you can try it. In WPF, I use NAudio. You can add it to your project via nuget. After, you can use the following snippet : public static void Mp3ToWav(string mp3File, string outputFile) { using (Mp3FileReader reader = new Mp3FileReader(mp3File)) { WaveFileWriter.CreateWaveFile(outputFile, reader); } }

Categories : Windows Phone 8

Why does 0.43 convert to 43?
Because the decimal separator of your culture is the , and not the . probably. Try doing (0.5).ToString() and see if you have your result as 0.5 or 0,5. The truth is that you shouldn't use the Replace, you should do: var culture = new CultureInfo("someculturegoeshere"); and then Decimal Cbm = Decimal.Parse(strCbm, culture);

Categories : C#

Convert to PDF using PHP
Fpdf and Fpdi are good PHP plugins to deal with reading/writing PDFs. I've only ever done the uploading and signing of PDFs but there is probably some way to utilize one of those tools to work with doc/docx files. http://www.setasign.de/products/pdf-php-solutions/fpdi/ http://www.fpdf.org

Categories : PHP

How to convert "03" to int in C
The string literal "03" specifies a string consisting of two characters; the first has the value 3, and the second is the implicit '' null character terminator. The character with the value 3 is typically not a printable character. In particular, it's not the digit '3'. If you want to extract the int value 3 from that string, you can do it like this: int result = ((char*)message)[0]; But that doesn't seem like a particularly useful thing to do. I have to wonder (1) why you declared message as void* rather than as char*, and (2) why you're using a string containing the control character '03' to represent the integer value 3. The usual way to represent an integer value as a string represents the integer 3 as "3", not as '03'. You can certainly represent (small) integer values as sing

Categories : C

cannot convert from 'int *' to 'int'
The problem is in your swap function. Your swap function should be as follows: void swapnum( int *i, int *j ) { // Checks pre conditions. assert( i != NULL ); assert( j != NULL ); // Defines a temporary integer, temp to hold the value of i. int const temp = *i; // Mutates the value that i points to to be the value that j points to. *i = *j; // Mutates the value that j points to to be the value of temp. *j = temp; } ... this is because i and j are pointers. Observe that when you call swapnum you are passing the address of i and the address of j, hence pointers are needed to point to those memory addresses. To get the value of a memory address (a pointer) you must dereference it using this fancy * syntax, *i implies value of what i points at.

Categories : C

Convert crt to pem with private key
How do you create private key of the certificate you already have? You must have private key to sign the certificate signing request (CSR). You can export this private key into any format (provided that it is marked as exportable) you want. If you can export the private key then one solution is that you can concatenate your file with private key and public key if it is supported by your application. Another way is to combine them into pfx or PKCS #12 file. You can see the about openssl pkcs12 here.

Categories : Windows

Convert Image to SVG using C#
I've used the website below and got great results converting logos and what-have-you to vector formats. I have no connection to them: http://vectormagic.com/home

Categories : C#

Convert object to another
Automapper is there to help you out. or if you have only class then it is fairly simple to write one of your own. private mycustomer(customer c) { return new mycustomer { name = c.Name, address = c.address,email = c.email }; } You should not however that you don't need inheritance to map. public class mycustomer : customer should be public class mycustomer You should also use this naming convention public class MyCustomer { public string Name {get; set} public string Address{get;set} public string Email {get;set} }

Categories : C#

Need to convert %20 to - using .htaccess
First of all: %{THE_REQUEST} will ALWAYS contain spaces. It is in the form of GET /index.html HTTP/1.1. The url itself will never contain actual spaces, because that is an invalid character in an url. It will always be in the form of %20. What I suggested in this question was something like this: #This will rewrite every single space in the url to a dash RewriteCond %{ENV:stripspaces} 1 RewriteRule ^(.*)%20(.*)$ $1-$2 [N] #This will tell that when the requirements for this rule are met, #spaces should be rewritten. #You probably don't want that top happen for each url RewriteCond %{REQUEST_URI} %20 RewriteRule ^(.*)$ $1 [E=stripspaces:1,E=redirect:1,N] RewriteCond %{ENV:redirect} 1 RewriteRule ^(.*)$ $1 [R,E=!stripspaces,E=!redirect,QSA] I think this will work for you too. If you real

Categories : Htaccess

Convert from UTF-8 to unicode c++
I just wrote some code to do this yesterday... I'm not saying this is the "perfect" way to do this, but it appears to work for all testcases I've run through it (I wrote both directions for that purpose). I'll leave it to you to translate "%NN" to an integer value. #include <iostream> #include <deque> std::deque<int> unicode_to_utf8(int charcode) { std::deque<int> d; if (charcode < 128) { d.push_back(charcode); } else { int first_bits = 6; const int other_bits = 6; int first_val = 0xC0; int t = 0; while (charcode >= (1 << first_bits)) { { t = 128 | (charcode & ((1 << other_bits)-1)); charcode >>= other_bits;

Categories : C++

How to convert .png file to .bmp?
There is a opensource project on Github that allows reading and saving of BMP files (and other file formats) in PHP. The project is called PHP Image Magician.

Categories : PHP

Convert doc to pdf using Apache POI
The task at hand is converting doc to pdf with having all formattings like tables, images, alignments. Creating an own converter class There already are WordToXxxConverter classes in Apache POI, namely WordToFoConverter, WordToHtmlConverter, and WordToTextConverter. The latter one most likely is too lossy to serve as an example for your requirements but the former two are adequate. All these converter classes are derived from the common base class AbstractWordConverter which provides a basic framework for word conversion classes. Furthermore all these classes make use of a matching *DocumentFacade class which wraps the concrete target (or some intermediate) format creation: FoDocumentFacade, HtmlDocumentFacade, or TextDocumentFacade. To implement your task converting doc to pdf with ha

Categories : Java

convert apklib to jar
I tried changing the packaging to jar and that failed. I think you'd be better of fixing the problem cause the JAR packaging to fail instead of trying to convert from Java bytecodes to Davlik and back again. If you mentioned how it failed, we might be able to help you with that ... Here's a thought. Create a second Maven project / POM with packaging "jar" and move all of the (reusable) Java code there. Then make that project a dependency of this one.

Categories : Java

How do I convert the following SQL such that there is no Cursor?
This should do what you want (if I understood you correctly, that is): INSERT INTO Table3 (BIN,PID,BillCode,PlanName,CCount,AvgPaidPer) SELECT B.[BIN Nbr], B.[P ID], B.MinBillCode, B.MinPlanName, B.CCount, B.PerC FROM Table2 A CROSS APPLY (SELECT TOP 10 [BIN Nbr], [P ID], MIN([Bill Code]) MinBillCode, MIN([Plan Name]) MinPlanName, COUNT(*) CCount, SUM([Total Price])/COUNT(*) PerC FROM Table2 WHERE [BIN Nbr] = A.[BIN Nbr] AND [P ID] = A.[P ID] GROUP BY [BIN Nbr], [P ID] ORDER BY [P ID], SUM([Total Price]) DESC) B WHERE A.[Rx Date] >= @fromdate AND A.[Rx D

Categories : SQL

Convert to singleton
I like doing something like this... function MySingletonClass() { if ( arguments.callee._singletonInstance ) return arguments.callee._singletonInstance; arguments.callee._singletonInstance = this; this.Foo = function() { // ... } } var a = new MySingletonClass() var b = MySingletonClass() Print( a === b ); // prints: true I think it should be easy to implement and test. From here... https://code.google.com/p/jslibs/wiki/JavascriptTips#Singleton_pattern Hope this helps.

Categories : Javascript

Convert GLSL to C or C++
What you are asking about is a memory-mapping-function. The following formula will do the trick: int output_color = pixels[vec2_coord_y * 256 + vec2_coord_x]; //assuming output_color is stored in format XXBBGGRR: color_r = (output_color & 0x000000FF); color_g = (output_color & 0x0000FF00) >> 8; color_b = (output_color & 0x00FF0000) >> 16;

Categories : C++

Convert JSON to RSS via Web API?
You could implementing your own RSS or Atom custom MediaTypeFormatter. You can implement it so that the request will use this formatter when the accept header is set to application/atom+xml or application/rss+xml. Filip has a blog describing this: RSS & Atom MediaTypeFormatter for ASP.NET WebAPI

Categories : C#

Can I convert my TODO to a git bug?
You can easily extract all your //TODOs with grep: grep TODO -rnf * > TODOs.txt Then it should be possible to write a small script that reads this TODOs.txt file and makes use of Github's api to create new issues: POST /repos/:owner/:repo/issues { "title": "Found a bug", "body": "I'm having a problem with this.", "assignee": "octocat", "milestone": 1, "labels": [ "Label1", "Label2" ] } But this is left as an exercise ;)

Categories : Java

Convert 24h to AM/PM format
You could use strftime to format times as you require and use this as the x aesthetic. You will then have to also use a grouping aesthetic. We use lubridate to make it easy to work with hours. Try this: require(lubridate) hod$time <- tolower( strftime( Sys.Date()+hours(hod$h) , "%I %p" ) ) # [1] "12 am" "12 am" "12 am" "12 am" "12 am" "01 am" "01 am" "01 am" "01 am" "01 am" ggplot(hod, aes( x = time , y=mean, colour=as.factor(t) , group = t ) ) + geom_line(size = .1) + geom_point()

Categories : R

Convert XML String To CSV?
Try this: ' First read your XML string in Dim doc As XDocument = XDocument.Parse(xmlString) ' Create a string builder to hold the output CSV Dim theOutput As New StringBuilder(1000) ' Loop through the nodes of the XML For Each node As XElement In doc.Descendants("name of element you want to start at") For Each innerNode As XElement In node.Elements() theOutput.AppendFormat("{0},", innerNode.Attribute("data").Value) Next ' Remove trailing comma theOutput.Remove(theOutput.Length - 1, 1) theOutput.AppendLine() Next ' Write output to file and do whatever you want the file here File.WriteAllText("path to file.csv", theOutput.ToString())

Categories : Xml



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.