w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

Get sub-string for major version out of full version string
Using regex: >>> s = '1.2.3.4.5.6.7' >>> re.search(r'(d+.d+)', s).group() '1.2' Timing comparisons: >>> r = re.compile(r'^(d+.d+)') >>> s = '100.21.3.4.5.6.7' >>> %timeit r.search(s).group() 100000 loops, best of 3: 1.43 us per loop >>> %timeit '.'.join(s.split('.')[:2]) 1000000 loops, best of 3: 2.32 us per loop >>> %timeit '.'.join(s.split('.', 2)[:-1]) 100000 loops, best of 3: 1.28 us per loop >>> s = '100.21.3.4.5.6.7'*100 >>> %timeit r.search(s).group() 1000000 loops, best of 3: 1.96 us per loop >>> %timeit '.'.join(s.split('.')[:2]) 10000 loops, best of 3: 40.4 us per loop >>> %timeit '.'.join(s.split('.', 2)[:-1]) 100000 loops, best of 3: 2.01 us per loop >>> s = '100.2

Categories : Python

- The method setString(int, String) in the type PreparedStatement is not applicable for the arguments (String, String, String, String, String,
PreparedStatement.setString() is not a variable arity method; it doesn't take variable no. of arguments. Each placeholder(?) must be set individualy using stmt.setString(1, "Charlie Sheen"); stmt.setString(2, "help@glomindz.com"); and so on. Using Spring's JdbcTemplate jdbcTemplate.update("INSERT INTO spl_user_master(name,email,mobile,password,role,status,last_update)VALUES(?,?,?,?,?,?,?)", new Object[] { "Charlie Sheen","help@glomindz.com","9654087107","cbf51a71a11d7ec348b0d7e9b2f0055f","admin","3","null"});

Categories : Java

htaccess redirect dynamic url with no query string to query string version
Reason why it is not working is because %1 is the matching group captured in RewriteCond and you aren't capturing anything in your RewriteCond. Variables captured in RewriteRule are denoted by $1, $2, $3 etc. Replace your code with this: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{QUERY_STRING} ^$ RewriteRule ^([^.]+..+)$ /link-building-services/?website=$1 [R=301,L]

Categories : Htaccess

error C2664 cannot convert parameter 1 from 'std::string (__thiscall ClassName::* )(std::string)' to 'std::string (__cdecl *)(std::string)
In your real use-case can you simply make FunctionToBePointed a static method? static std::string Class1::FunctionToBePointed(std::string msg) { return msg; } If yes your code should work. The reason is that instance methods are implicitly called with an hidden this pointer, this is the thiscall calling convention, whereas static methods simply use the cdecl convention because they don't work on any instance. EDIT: A sample with Boost::bind: The MyClass C# class: using System; using System.ComponentModel; public class MyClass : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate{}; private string name; public string Name { get { return name; } set { if (name

Categories : Visual C++

Why can't i pass Dictionary to IEnumerable> as generic type
Because it's a ref parameter. A ref parameter means that the method can assign a new value to the field / variable passed by the caller. Had your code been legal, the method would be able to assign a List<KeyValuePair<string, string>>, which is obviously wrong. You should not use ref parameters.

Categories : C#

search in fread definition to find string
The array_search() function is for arrays, what you have is a string. You can use strpos() to determine the position and substr() to extract the portion you need. $index = strpos($JunkHead3, '/d'); $result = substr($JunkHead3, $index+2, 1); http://www.php.net/manual/en/function.strpos.php http://www.php.net/manual/en/function.substr.php However I prefer using regular expressions, even though at first they seem a bit cryptic. $result = preg_replace('/^.*\/d(.).*$/', '$1', $JunkHead3); http://php.net/manual/en/function.preg-replace.php

Categories : PHP

can I use hash.each even if i'm passing only a string key? Dictionary without definition
You're trying to call each on a String in @d.add('fish'), which isn't allowed. You could just add the following line above definition.each do |word, meaning|: definition = { definition => nil } unless definition.is_a? Hash although this could have unexpected consequences if you are passing different kinds of objects to add.

Categories : Ruby

how do i convert Dictionary string string to array of key value pair of string and string using linq and c#
try below , you may need to change the set properties of new object accordingly ArrayOfKeyValueOfstringstringKeyValueOfstringstring[] array = valuePairs.Select(pair => new ArrayOfKeyValueOfstringstringKeyValueOfstringstring(){ Key= pair.Key, Value= pair.Value}).ToArray();

Categories : C#

Html.fromHtml within Gmail Sender .sendMail(string, string, string, string)
It has turned out that GMailSender is a custom class published by a stackoverflow user in this post. The easiest way to send HTML instead of plain text is to change the sendMail method from the link above and replace text/plain by text/html. Or you can add a parameter to the method and make it more customizable: public synchronized void sendMail(String subject, String body, String sender, String recipients, boolean isHtml) throws Exception { try{ MimeMessage message = new MimeMessage(session); String messageType = isHtml ? "text/html" : "text/plain"; DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), messageType)); message.setSender(new InternetAddress(sender)); message.setSubject(subject); mess

Categories : Android

The method managedQuery(Uri, String[], String, String[], String) from the type Activity is deprecated
The managedQuery method is deprecated, meaning it should no longer be used and there is an updated method available. The replacement for this is getContentResolver().query(): cursor = activity.getContentResolver().query(imageUri, proj, null, null, null); You can normally find out why the method is deprecated, and what you should use instead, by a quick Google of the method name, or depending on how good the javadoc is it may inform you through your IDE.

Categories : Java

Concatenate C macro definition string to literal strings
you can do: printf("Blah%d", TAG_LEN); or if you have a string char *yourString;// initiate it with your value printf("Blah%s%d",yourString, TAG_LEN);

Categories : C

Qt Creator. Why do I get an error about glut when compiling release version, but not debug?
For static single executables you will first need a commercial license for QT. This being said you can change the mkspecs in $QTDIRmkspecs$COMPILERVERSIONqmake.conf to use static linking. For example win32-msvc2008 (2008 Visual Studio Compiler) set CFLAGS and CXXFLAGS from QMAKE_CFLAGS_RELEASE = -O2 -MD to QMAKE_CFLAGS_RELEASE = -O2 -MT (MD => MT, MDd => MTd). Furthormore you will static libs of QT and GLUT. These typically end in .lib (not .dll). You probably will need to compile QT from Source for getting static-compatible libraries. When compiling QT remember to compile with opengl support. There is a good documentation at http://qt-project.org/wiki/Build_Static_Qt_For_Windows_With_Gcc_German for gcc, and you can also find examples for MSVC. After these prerequisites are me

Categories : C++

Parcelable protocol requires a Parcelable.Creator object called CREATOR (I do have CREATOR)
my dear friends you are not maintain the sequence in parcel in method writeToParcel you first put String but in Constructor you take first integer it is not valid in android, I have give you code which makes correct order to putting data in to Parcel visit this link so correct code is just Replace with public class FriendDetail implements Parcelable { private String full_name; private int privacy; public HeatFriendDetail(Parcel in) { this.full_name = in.readString(); this.privacy = in.readInt(); } public HeatFriendDetail() { } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.full_name); dest.writeInt(this.privacy); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public HeatFriendDetail create

Categories : Java

Is it better to make a method for returning a string from an Enum? or to have an extra string variable to hold the string value?
Your getSize() method can be reduced to: public string getSize() { return pSize.ToString(); } Given that the method is really this simple, it seems rather pointless to provide this as a separate method. If you simply expose pSize as a property (or read-only property) the user can simply call ToString() on that property: public EnumSize Size { get { return this.pSize; } }

Categories : C#

create constructor string string1,string string2,string string3,Object object1
you should pass View.OnClickListener to your MyCard constructor instead of Object Change public MyCard(String title, String desc, String string, Object setOnClickListener){ super(title, desc); } with public MyCard(String title, String desc, String string, View.OnClickListener setOnClickListener){

Categories : Java

How can we check if string is a version number or not
If you're using bash, you can use the =~ regex match binary operator, for example: pax> if [[ 1.x20.3 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]] ; then echo yes ; fi pax> if [[ 1.20.3 =~ ^[0-9]+.[0-9]+.[0-9]+$ ]] ; then echo yes ; fi yes For your particular test data, the following regex will do the trick: ^[0-9]+(.[0-9]+)*$ (a number followed by any quantity of .<number> extensions) although, if you want to handle edge cases like 1.2-rc7 or 4.5-special, you'll need something a little more complex.

Categories : Shell

Extracting numbers from weird version string
By using a combination of masks and shifts: int main() { const uint32_t v = 0x00870016; const uint16_t major = (v & 0xFFFF0000) >> 16; const uint16_t minor = v & 0x0000FFFF; cout << major << "." << minor << " "; } Output: 135.22 Explanation: 0x00870016 is a 32-bit number. Your major version number is composed from the 16 most-signifigant digits, and the minor version number is the 16 least-signifigant digits. In order to extract the major version number, let's find out that the 16 MSBits are by masking the input value with 0xFFFF0000 -- a number where all 16 of the most-signifigant digits are set to 1 and all the least-sig bits are 0: 0x00870016 && 0xFFFF0000 = 0x00870000 The resulting value is your major version nu

Categories : C++

Making a List in C# with three flexible elements in one datatype
If you're asking for the syntax to initialize a list with multiple elements at once, then: var l = new List<string>{ "string1", "string2", "string3" .... }; If you are looking for a way to hold three strings in a single list-item, without using Tuples or custom classes, there's no way to do that, I'm afraid. EDIT: Unless you're generating strings - in which case you could generate them in an annonymous type, such as: Enumerable .Range(1, 100) .Select(i => new { string1 = "string1" + i, string2 = "string2" + i, string3 = "string3" + i }); But that's really weird. Also, you could use a list of Lists, such as: var l = new List<List<string>> { new List<string> { "string 1", "string 2", "string 3" }, new

Categories : C#

Decrypt string with Rijndael return "System.SecureString" (as a string) but not the string
I have implemented rijndael in the past, and here is my version if this is any help: private static string Encrypt(string plainText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize) { // Convert strings into byte arrays. // Let us assume that strings only contain ASCII codes. // If strings include Unicode characters, use Unicode, UTF7, or UTF8 // encoding. var initVectorBytes = Encoding.ASCII.GetBytes(initVector); var saltValueBytes = Encoding.ASCII.GetBytes(saltValue); // Convert our plaintext into a byte array. // Let us assume that plaintext contains UTF8-encoded characters. var plainTextBytes = Encoding.

Categories : C#

java. is there any google's guava interface to replace Map>?
Yes, it's called Table: A collection that associates an ordered pair of keys, called a row key and a column key, with a single value. A table may be sparse, with only a small fraction of row key / column key pairs possessing a corresponding value. The mappings corresponding to a given row key may be viewed as a Map whose keys are the columns. The reverse is also available, associating a column with a row key / value map. Note that, in some implementations, data access by column key may have fewer supported operations or worse performance than data access by row key. There are few implementations: ArrayTable (backed by two-dimentional array, see the documentation), ForwardingTable (implements decorator pattern), HashBasedTable (~ HashMap<R, HashMap<C, V>),

Categories : Java

jQuery: how do I insert html into a string, both before the string (the easy part) and WITHIN the string?
You need to insert the start tag at the same time as the end tag. var index = $('.entry-title').html().indexOf('...'); $('.entry-title').html('<span class="category">' + $('.entry-title').html().substring(0, index) + '</span>' + $('.entry-title').html().substring(index));

Categories : Jquery

jQuery $.ajax glitch, adding version string?
You seem to have hit this jQuery bug http://bugs.jquery.com/ticket/8417 which is indeed reported to appear again in some newer jQuery versions (jquery 1.8.3 for example) Maybe try the workaround of replacing dataType: 'json' with contentType: "application/json; charset=utf-8" in your ajax options and see if this works for you. Please see also this thread http://forum.jquery.com/topic/strange-string-at-the-end-of-my-mesages-jquery15012356981023933311-1302979842877

Categories : Jquery

How do you refer to the mac command key in the String version of Java's KeyStroke.getKeystroke?
I had to go to the source code for AWTKeyStroke getAWTKeyStroke(String s) to see all of the acceptable modifier terms, and then do a little trial and error, to check that the modifier syntax for the command key is "meta".

Categories : Java

Netty (4.0.4) version compress/decompress string messages error
You need to add the following dependency in your pom.xml: <dependency> <groupId>com.jcraft</groupId> <artifactId>jzlib</artifactId> <version>1.1.2</version> </dependency> This is because netty declare all dependencies as optional.

Categories : Java

In GWT how do I display an image from the appengine server given the string version of the blobstore key
Finally after two days of scouring Google and stack-overflow and trying I got it! On the server I got the upload url thus: ImagesService imagesService = ImagesServiceFactory.getImagesService(); ServingUrlOptions suo = ServingUrlOptions.Builder.withBlobKey(blobKey); String image_url = imagesService.getServingUrl(suo); item.setProperty("image_url", image_url); The appengine API produced a url which didn't work on the local mode [I think it has to do with sop cross platform issues] http://0.0.0.0:8888/_ah/img/mR9SOTSEizec4gZYsRnuEw but it provided a clue: namely the /_ah/img/ part of the String So I decided to try it and gave this URL to the image "/_ah/img/mR9SOTSEizec4gZYsRnuEw" Here is the client side code. String imageKey = result.ge

Categories : Java

Jackson Custom Deserialization for Mapping Class Name String to Actual Class Definition
I hope you haven't spend too much time writing custom stuff. What you can use, out of the box, is to annotation @JsonTypeInfo (see javadoc): it makes Jackson automatically read/write additional type information. And one possible inclusion mechanism is As.PROPERTY, in which case class name (or type name) is added as virtual property to use. Name of property can be customized as well.

Categories : Java

Convert Colon Separated String to a Dictionary
string s = "Number1.pdf:Alpha1.pdf; Number2.pdf:Alpha2.pdf; Number3.pdf:Alpha3.pdf;"; var names = s.Replace(".pdf","") .Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Split(':')) .ToDictionary(x => x[0].Trim(), x => x[1]);

Categories : C#

How to merge a txt file as a [string] and a output [string] to 1 string in Haskell?
fileLines :: FilePath -> IO [String] fileLines file = readFile file >>= (x -> return $ lines x) main = do lines <- fileLines "directory.txt" putStr $ show $ (combinations pre suf letters) ++ lines

Categories : Haskell

invalid conversion from 'std::string (*)(std::ofstream&, const string&, std::string, int
typedef std::string (*f_write)( std::ofstream& fout, const std::string& level_file, std::string& what_to_write, int line_num); std::string write_file( std::ofstream& fout, const std::string& level_file, std::string what_to_write, int line_num); Can you spot a difference? (Hint: compare the types of the third parameters).

Categories : C++

How can I create a DateTime String using a date String and time String?
final Calendar c = Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH); mDay = c.get(Calendar.DAY_OF_MONTH); String date=mYear+"-"+mMonth+"-"+mDay+time+... so on

Categories : Java

How to determine if string contains array, object array or function definition
[{ label: "Choice1", value: "value1" },{ label: "Choice2", value: "value2" }] isn't json, but assuming that it should be, because you mentioned that in the question, console.log(typeof JSON.parse(string)) Should work nicely for anything but functions.

Categories : Javascript

mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables
The characters in the string should not be separated by commas: $stmt->bind_param("sss...", /* variables */); You can see this format demonstrated in the examples on the manual page.

Categories : Mysql

Prefixing string resource identifier to select alternate version at run time
Firstly, your code could be a bit better like this: int resource = someBooleanCondition ? R.string.my_string2 : R.string.alt_string2; String selectivestring2 = getResources().getString(resource); As you described, that could be done with reflection, here is a very simple example: package br; import java.lang.reflect.Field; final class R { public static final class string { public static final int alt_string1=0x7f060601; public static final int alt_string2=0x7f060101; } } public class StaticReflection { public static boolean globalVariable = false; //this would be android method getString public static String fakeGetString(int id){ switch (id){ case R.string.alt_string1: return "it"; case R.string.alt_string2: re

Categories : Java

How to support two version of structure definition in one asn.1 file
The error says it all. You cannot have two definitions for a type. The names used in the ENUMERATED can be changed without consequence for BER encodings (XER encodings might be impacted; I'd have to look that up). Thus, the two definitions are equivalent and you can just pick one.

Categories : Misc

Visual C++ Release build - is string getting corrupted when passed across DLL because compiled with different runtime version?
If you pass non-POD (plain old datatypes) between DLL/EXE boundaries (like STL string or CRT FILE pointers) you must use the same shared CRT. In your case, you must recompile all DLLs/LIBs with the same compiler! See also: I can pass std::string for a Dll and what i can do with DLL´s?

Categories : Visual C++

Connection String for SQL Server 2008 (version 10.0.1600) in Application Configuration File
You can use either server= or Data Source= (those two are equivalent), and you can use either database= or Initial Catalog= (again: those are equivalent) - take your pick, use whatever you prefer. But you just need to define at least server, database, either Integrated Security=SSPI (for integrated, Windows authentication) or User id=abc;Password=xxxx for SQL Server authentication You need at least these three pieces of information. So if you want to use integrated security (Windows authentication), use this connection string: <connectionStrings> <add name="ShareManagement" connectionString="server=(local);database=AdventureWorks;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/> </connectionStrings> but if you want to use

Categories : C#

Replacing a string in AndroidManifest.xml for a buildvariant doesn't work for Gradle Android Plugin Version > 0.5.4
I had the same problem as you and read through the release notes for 0.5.5 where I found the answer. "access to the variants container don't force creating the task. This means android.[application|Library|Test]Variants will be empty during the evaluation phase. To use it, use .all instead of .each"

Categories : Android

Write a recursive version of the function reverse(s), which reverses the string s in place.I cant seem to find the error
To start with, when you declare i inside reverse you don't assign a value to it, so its value will be random. So when you use i in the comparison it is undefined behavior.

Categories : C

VBA string variables does not put constant string value in string concatenating
Try below code : Sub mySub() Const strVarA As String = "AA" Const strVarB As String = "BB" Const strVarC As String = "CC" 'Dim myStrArray() As String Dim myString As String myStrArray = Array("strVarA", "strVarB", "strVarC") For i = LBound(myStrArray) To UBound(myStrArray) myURL = "http://www.yahoo.com/news/" & myStrArray(i) & ".html" '//do something. Next i End Sub Updated after comments Sub mySub() Dim myStrArray As Variant myStrArray = Array("AA", "BB", "CC") For i = LBound(myStrArray) To UBound(myStrArray) myurl = "http://www.yahoo.com/news/" & myStrArray(i) & ".html" MsgBox myurl Next End Sub

Categories : String



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