w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
python-requests returning unicode Exception message (or how to set requests locale)
You can try os.strerror, but it would probably return nothing or the same non-English string. This hard-coded English was scraped from here: http://support.microsoft.com/kb/819124 ENGLISH_WINDOWS_SOCKET_MESSAGES = { 10004: "Interrupted function call.", 10013: "Permission denied.", 10014: "Bad address.", 10022: "Invalid argument.", 10024: "Too many open files.", 10035: "Resource temporarily unavailable.", 10036: "Operation now in progress.", 10037: "Operation already in progress.", 10038: "Socket operation on nonsocket.", 10039: "Destination address required.", 10040: "Message too long.", 10041: "Protocol wrong type for socket.", 10042: "Bad protocol option.", 10043: "Protocol not supported.", 10044: "Socket type not supported.",

Categories : Python

Using Apache mod_rewrite to send all requests to a file
Given that /var/www/ is the root folder then this would work: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /sites/urlprocessor.php [L] Basically this will redirect any non-existent folder and file to the urlprocessor.php For more information on how to handle the redirect with your PHP you can refer yourself to this answer.

Categories : Apache

How do I send unicode data to nvarchar field in stored proc with ado/vbscript?
Make sure your ASP script (in notepad or whatever) is saved as UTF-8 format. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Response.ContentType = "text/html" Response.CodePage = 65001 Response.CharSet = "UTF-8" %> This is the first include on all my ASP, since IIS7 you MUST put this for UTF-8 pages to display or save, it used to be optional in IIS6 (at least in Japanese versions of IIS I used)

Categories : Sql Server

iOS - Can't send Facebook requests
NSString *query2 = [NSString stringWithFormat:@"SELECT uid, name, pic_square,is_app_user FROM user WHERE is_app_user = 1 AND uid IN " @"(SELECT uid2 FROM friend WHERE uid1 = me())"]; // Set up the query parameter NSDictionary *queryParam2 = @{ @"q": query2 }; // Make the API request that uses FQL [FBRequestConnection startWithGraphPath:@"/fql" parameters:queryParam2 HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (error) { } else {

Categories : IOS

How to Send N number of Requests at Same Time in IOS
There are a few ways to do this. Grand Central Dispatch dispatch_async(dispatch_queue_create("com.myApp.uploadXml", DISPATCH_QUEUE_CONCURRENT), ^(void) { //Upload here . . }); You can set the number of concurrent requests as follows: https://developer.apple.com/library/mac/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html BBHTTP The BBHTTP and other network libraries support this. For example the executor below has 10 concurrent requests. BBHTTPExecutor* xmlUploadExecutor = [BBHTTPExecutor initWithId:@"myApp.xmlUploder"]; xmlUploadExecutor.maxParallelRequests = 10; BBHTTPRequest* request = [[BBHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://upload.url"] andVerb:@"PUT

Categories : IOS

$http doesn't send cookie in Requests
In your config, DI $httpProvider and then set withCredentials to true: .config(function ($routeProvider, $httpProvider) { $httpProvider.defaults.withCredentials = true; //rest of route code Info on angularjs withCredentials: http://docs.angularjs.org/api/ng.$http Which links to the mozilla article: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS?redirectlocale=en-US&redirectslug=HTTP_access_control#section_5

Categories : HTML

when and how does Google Anayltics send tracking requests
Their Javascript reads the cookies, then requests a GIF during the request, where they pass the parameters back to their system for tracking. When you look in Firebug, look at either ALL or Images. You should see a GIF that's been transfered from Google Analytics in your history. When they request the GIF they're also passing a long string of GET vars to the URL. They should also be providing you with a tracking cookie. Which is also set with the Javascript. Here's more about how Google Analytics works. How the Tracking Code Works In general, the Google Analytics Tracking Code (GATC) retrieves web page data as follows: 1. A browser requests a web page that contains the tracking code. 2. A JavaScript Array named _gaq is created and tracking commands are pushed onto the array

Categories : Google Analytics

"Can only send requests to friends or users of this application"
I figured out that actually the people I was inviting weren't "my friends". The access token provided to fetch the friends and the one that the SDK logged in, and used to do the FB.ui request weren't the same. Sorry for your time...

Categories : Javascript

Best way to send HTTP GET requests ansynchronously in Android?
You could do your own async HTTP GET calls using AsyncTask but I would recommend against it unless you're doing it from a learning point of view. If you want a nice, clean and stable solution I'd suggest that you use the well known Android Asynchronous Http Client 3rd party library. From the site: "An asynchronous callback-based Http client for Android built on top of Apache’s HttpClient libraries. All requests are made outside of your app’s main UI thread, but any callback logic will be executed on the same thread as the callback was created using Android’s Handler message passing." Making a GET is as easy as: AsyncHttpClient client = new AsyncHttpClient(); client.get("http://www.google.com", new AsyncHttpResponseHandler() { @Override public void onSuccess(String response

Categories : Android

How can you use threading to send multiple web requests at a time in c#?
In a WPF app, you should use both threads and Dispatcher, because only the UI thread can write to a label. More specifically, you should use the dispatcher as a callback to update anything in the UI when a task is complete: protected void SearchButtonClick(object sender, EventArgs e) { new Thread(() => MakeRequest(SearchForm.Text)).Start(); } protected void MakeRequest(string text) { int resultCount = search.MakeRequests(text); // tell UI thread to update label Dispatcher.BeginInvoke(new Action(() => { resultsLabel.Text += text + ": " + resultCount + " occurances"; })); } Edit1: use Dispatcher not just threads Edit2: use both Dispatcher and threads

Categories : C#

How to send different web services requests to different destinations at the same time using Java?
You would need to multi-thread your application. Some helpful tutorials are available here and here. Essentially, you would need to have 4 classes which extend the Thread class or implement the Runnable interface. The purpose of these classes would be to execute a request and eventually process the response from your services. In your main class, you would simply need to create new instances of these 4 classes and spawn them off.

Categories : Java

Posting many AJAX requests from one page -- how to send all necessary data
You have stumbled on encoding types. No matter what, you are going to recieve your form elements using $_POST. The format you recieve them is totally up to you. You could recieve each form input as indevidual $_POST paramaters or the entire form as a single object using JSON. //pagePostedToo.php $thing1 = $_POST['thing1']; //im a string! $thing2 = $_POST['thing2']; //im a string! //pagePostedToo.php $things = json_decode($_POST['things']); //im an array of things!

Categories : PHP

java send GET/POST requests while maintaining cookies
HttpClient automatically handles cookies as long as you use the same DefaultHttpClient object.

Categories : Java

How to send parallel GET requests and wait for result responses?
Just in general, you need to encapsulate your units of work in a Runnable or java.util.concurrent.Callable and execute them via java.util.concurrent.Executor (or org.springframework.core.task.TaskExecutor). This allows each unit of work to be executed separately, typically in an asynchronous fashion (depending on the implementation of the Executor). So for your specific problem, you could do something like this: import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.FutureTask; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.DefaultHttpClient; import org.springframework.ste

Categories : Java

AngularJS - Does $resource requests send cookies automatically?
No. But if you want to send cookies, then you can try $cookies service to get the cookie and send with API either in the payload or included in the header. You can also set the cookie in a default header (with $cookies service injected) so you don't have to specify it in all API calls. var cookie = $cookies.myCookie; // suppose you already set $cookies.myCookie= 'xxx'; $http.defaults.headers.post.Cookies = cookie;

Categories : Angularjs

PHP send multiple event requests to Outlook/vcalendar
After trying multiple approaches, I was able to come up with a working solution. You need to send the event as a recurring event. 1st inner event should be the default event. This should include the RRULE specifying the recurring frequency & count. This should contain the same DTSTART, DTEND, DTSTAMP values of the 1st day event. All events including the default event should contain the same UID & SEQUENCE. Other than the default event, all other events should contain unique RECURRENCE-IDs. For further details refer to the blog post I have written regarding the solution: http://hasarangi.blogspot.com/2015/02/php-send-multiple-events-to-ms-outlook.html

Categories : PHP

python, send many HTTP requests through one network connection
The fact that both solutions shared some code like Lukasa said, and the fact that both results were equivalent whenever querying Apache or Tomcat made me first think it was related to the Python code. But in fact it was related to the servers configurations. The trick is that both Apache and Tomcat share a setting which indicates how many HTTP requests can be made within the same TCP connection. And both have a default value of 100. Tomcat: maxKeepAliveRequests: The maximum number of HTTP requests which can be pipelined until the connection is closed by the server. If not specified, this attribute is set to 100. See http://tomcat.apache.org/tomcat-7.0-doc/config/http.html#Standard_Implementation Apache: MaxKeepAliveRequests: The MaxKeepAliveRequests directive limits th

Categories : Python

How can you hold a TCP connection open for multiple send/receive requests?
Finally figured it out, @Idle_Mind definitely had the right suggestion, the using{} block was causing the connection to be held. The problem when I first removed the using was that the client was accidentally closing the connection after the first loop. I remedied the issue on the client end and now just loop and hang on a wait, was still wondering if there was a way to time out eventually (if the client does nothing for say 1 minute), but I'm okay with having the client end the connection.

Categories : C#

JMeter: How to send HTTP requests with different request body for each thread count?
You will have to parametrized your test plan and use CSV data set config to use the data from csv file. I have created a beginners screen cast to explain how to use csv data set config . As you mentioned you cannot reuse the same data, you will have to either create a big enough csv to match or your concurrent user needs, or use once only controller to not replay those request again, which will create duplicate users.

Categories : Http

Weird race conditions when I send high-frequency requests to my datacontext using EF (and WebAPI)
Yes, you need a separate DbContext per call. From the docs; Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. What you could do (for example, depending on how you're using transactions) is to use the Unit of Work pattern, which if EF's case basically means wrapping your DbContext in a class (you don't want it exposing EF specific classes like DbContext to your business classes) so that you in your application code (or, depending on layering, business code) can write something like; [HttpDelete] public HttpResponseMessage DeleteFolder(int id) { using(var uow = new UnitOfWork()) { // Creates a new DbContext _service.DeleteFolder(uow, id); uow.Commit(); retur

Categories : Ajax

Unable to send data multiple requests in a single connection — socket error
The connection was closed because you called conn.getresponse() and the server closed it. There isn't much that you can do about it from your side of the connection aside from passing a Connection: keep-alive header and hope that the server will comply. If you want to send another HTTP request, you have to start with conn.putrequest("POST", path) or something similar.

Categories : Python

SSIS Package: convert between unicode and non-unicode string data types
The Oracle data type VARCHAR2 appears to be equivalent to NCVARCHAR in SQL Server, or DT_WSTR in SSIS. Reference You will have to convert using the Data Conversion Transformation, or CAST or CONVERT functions in SQL Server.

Categories : Sql Server

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode
You're passing the value returned by the FileField image directly into the response as if it were a string or iterable. Checking the source code for the exception path given, we see that the object returned by the field has the offending line in its __iter__ method - the wrapper class is looking for line terminators. It's certainly plausible that the raw image file could contain bytes that can't be converted to something that can be compared against the line terminator characters. The HttpResponse just needs something it can treat as a string - if you give it an iterator it reads it all in at once and creates a string, so there are no memory savings available: HttpResponse will consume the iterator immediately, store its content as a string, and discard it. https://docs.djangoproj

Categories : Python

Android send xml file doesn't send attachment
I've seen several exemples but still don't get why, when I'm editing the mail I see the .xml attached but when I receive ther's no attachment! First, third-party apps cannot read internal storage of your app. Second, that might not be the right path to internal storage of your app. Never hardcode paths. Your app will fail for secondary accounts and restricted profiles on Android 4.2 tablets, for example. Always use a method, like getFilesDir(), to get at your portion of internal storage. You will need to either copy your file to external storage, or better yet, use FileProvider to serve up your file from internal storage via a content:// Uri.

Categories : Android

Accessing the original value of the unicode string when subclassing unicode
Since you a subclassing unicode, instances of SufficComparingUnicodeString can usually be used just like any other Unicode string. So you can just use other.endswith(self) in your __eq__() implementation: class SuffixComparingUnicodeString(unicode): def __eq__(self, other): return isinstance(other, unicode) and other.endswith(self)

Categories : Python

How to deal with a mix of unicode- and non-unicode projects in Visual Studio
From your description it seems like you own those libraries. I would change them to use "Using Generic-Text Mappings" http://msdn.microsoft.com/en-us/library/7dzey6h6.aspx That way you can compiled them with UNICODE and _UNICODE defined for Windows, and without that on other systems. You will have to write something like your own tchar.h though (but pretty trivial, just a bunch of ifdefs to map _tprintf to wprintf/printf, for instance).

Categories : C++

Getting error while reading unicode file in C
Your file contains the 3-byte UTF8 BOM of (EF BB BF). byte-order-mark. Your code defaults to UTF8, but does not consume the BOM. channel, 0, G_SEEK_CUR, &err s/b channel, 3, G_SEEK_CUR, &err Further, I would recommend extending your magic code to read 4 bytes and affirmatively discern the BOM. If you do not find a BOM, you could assume encoding NULL which I think is binary. Or throw an error Or fix the wayward text file Or, if your are pedantic, sequentially try all known encoding types. UTF32BE "x00x00xFExFF" UTF32LE "xFFxFEx00x00" UTF8 "xEFxBBxBF" UTF16BE "xFExFF" UTF16LE "xFFxFE" NULL for binary

Categories : C

Qt. How to send multiple simultaneous requests from multiple proxy servers
QNetworkAccessManager supports multiple concurrent requests, there's no need for you to use multithreading directly unless that makes things easier on your end. To track multiple subsequent requests belonging to each other, I'd suggest to use the Command Pattern to group them: Each flow of communication to one of the proxies would be managed by a job object. See this other answer where I describe why I find the command pattern useful, in a very similar context.

Categories : Qt

Decode Unicode chars in PHP by the unicode number
The behaviour you've found is exactly what's documented: This function is the opposite of htmlspecialchars(). It converts special HTML entities back to characters. The converted entities are: &amp;, &quot; (when ENT_NOQUOTES is not set), &#039; (when ENT_QUOTES is set), &lt; and &gt; You want some other related function, so we scroll down the documentation to the See Also section and find html_entity_decode(): Convert all HTML entities to their applicable characters var_dump( htmlspecialchars_decode('&#45;&#32;') ); var_dump( html_entity_decode('&#45;&#32;') ); string(10) "&#45;&#32;" string(2) "- "

Categories : PHP

Python reading unicode file names
Use a Unicode path and make sure to specify the encoding the source file is saved in: #python2 #coding: utf8 import os path = u'Показатели естественного и миграционного прироста до 2030г.doc' with open(path,'w') as f: f.write('hello') print os.path.getsize(path) Result: 5 Check that the file was created correctly: C:>dir *.doc Volume in drive C has no label. Volume Serial Number is CE8B-D448 Directory of C: 07/02/2013 09:51 PM 5 Показатели естественного и миграционного прироста до 2030г.doc 1 File(s) 5 bytes 0 Dir(s) 83,018,432,512 bytes free Edit in response to comment If you need to process a number of files, us

Categories : Python

open file in folder with unicode name on Windows
Use Win32::Unicode::Native or Path::Class::Unicode.

Categories : Perl

runcommand (haskell) with unicode file paths
Data.ByteString.Char8 is almost never the right choice if you want to deal with non-ASCII text. It will mangle your data. In your case you probably should use Data.ByteString.UTF8 instead (provided you use a UTF-8 locale, which is the case for most modern desktop Unix-y OSes). Example of Data.ByteString.Char8 mangling data: Prelude Data.ByteString.Char8> "été" "e769te769" Prelude Data.ByteString.Char8> unpack $ pack "été" "eSOHteSOH" Prelude Data.ByteString.Char8> Prelude.putStrLn "été" été Prelude Data.ByteString.Char8> Prelude.putStrLn $ unpack $ pack "été" ete Use Data.ByteString.UTF8.toString and not Data.ByteString.Char8.unpack. These invocations let s = toString $ bytes $ bash $ fromString "мама.sh" runCommand s runCommand $ "ls -l " ++ s

Categories : Bash

php creating zip file for files with unicode names
ZIP files don't have a specified encoding for filenames*. Consequently any use of non-ASCII characters is completely unreliable. *: Not completely true: there is an extension to the format that allows UTF-8 filenames to be used, and the zip command will use it. But Windows's ZIP interface (“Compressed Folders”) doesn't support it, and always uses the default (“ANSI”) code page to interpret the filename bytes. If you know that your target audience all have Windows boxes with a particular locale then you can target that locale... otherwise, best stick to ASCII.

Categories : PHP

Write a unicode character to a file in a binary way
You are confusing Unicode with encodings. An encoding is a standard that represents text as within the confines of individual values in the range of 0-255 (bytes), while Unicode is a standard that describes codepoints representing textual glyphs. The two are related but not the same thing. The Unicode standard includes several encodings. UTF-16 is one such encoding that uses 2 bytes per codepoint, but it is not the only encoding included in the standard. UTF-8 is another such encoding, and it uses a variable number of bytes per codepoint. Your file, however, is written using ASCII, the default codec used by Python 2 when you do not specify an explicit encoding. If you expected to see 2 bytes per codepoint, encode to UTF-16 explicitly: fin.write(u'x40'.encode('utf16-le') This writes UT

Categories : Python

unicode normalizing the file input string
There is no normalization function in JavaScript itself. There is generally very little Unicode support in JavaScript except for the character concept itself and case conversions (which are Unicode-aware). So you would need to use a library. A simple one is http://git.io/unorm which is primarily for server-side JavaScript with Node.js but can be used client-side, too. For example, using it, you would normalize the value of s to Normalization form C using UNorm.normalize('NFC',s).

Categories : Javascript

Why do I get a SyntaxError for a Unicode escape in my file path?
You need to use a raw string, double your slashes or use forward slashes instead: r'C:UsersexpoperialedDesktopPython' 'C:\Users\expoperialed\Desktop\Python' 'C:/Users/expoperialed/Desktop/Python' In regular python strings, the U character combination signals a extended Unicode codepoint escape.

Categories : Python

Python open file unicode error
One obvious problem is that you're using a normal string, not a raw string. In open ("C:UsersRajrishiDocumentsMyJava ext.txt") ^^ the is interpreted as a tab character, not a literal backslash, followed by t. Use one of the following: open("C:\Users\Rajrishi\Documents\MyJava\text.txt") # meh open(r"C:UsersRajrishiDocumentsMyJava ext.txt") # better open("C:/Users/Rajrishi/Documents/MyJava/text.txt") # also possible

Categories : Python

How to read a Unicode G-Clef (U+1D11E) from a file?
Full Unicode can be represented in both UTF-8 and UTF-16, by sequences of bytes resp. byte pairs ("java chars"). From String a full Unicode code point can be extracted with: int[] codePoints = { 0x1d11e }; String s = new String(codePoints, 0, codePoints.length); for (int i = 0; i < s.length(); ) { int cp = s.codePointAt(i); i += Character.charCount(cp); } For a file with basically latin characters, UTF-8 would seem fine. Tho following reads a full standard Unicode file (in UTF-8): try (BufferedReader in = new BufferedReader( new InputStreamReader(new FileInputStream(file), "UTF-8"))) { for (;;) { String line = in.readLine(); if (line == null) { break; } ... do some thing with a Unicode line ... } } catch (FileNotF

Categories : Java

How do I read a text file having Unicode codes?
Off the top of my head (completely untested) std::string convert_string(const std::string& in) { std::string out; for (size_t i = 0; i < in.size(); ) { if (i + 5 < in.size() && in[i] == '\' && in[i+1] == 'u' && in[i+2] == '0' && in[i+3] == '0' && isxdigit(in[i+4]) && isxdigit(in[i+5])) { out += (unsigned char)16*in[i+4] + (unsigned char)in[i+5]; i += 6; } else { out += in[i]; ++i; } } return out; } But this won't work with any unicode values above 255, (e.g. u1234) because you have the fundamental problem that your string stores 8 bit characters, and Unicode characters can have up to 20 bit

Categories : C++

Printing file names with unicode characters in Python 2.7
First, make you file a right encoding, like utf-8. http://www.python.org/dev/peps/pep-0263/ Then, use some_string.decode('the encoding') where you error occur.

Categories : Python



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