Wednesday, April 11, 2012

Google Map Bug, Dragend Event also trigger Click Event in IE

I have found that dragend event in Google Map also trigger the click event in IE. It is OK in Firefox and Chrome. Open IE/FF/Chrome console and see the result of this fiddle. Any workaround will be appreciated.

Bug Submitted at here.


here is a quick workaround
var map; var elevator; var dragged = false; var myOptions = { 
    zoom: 6, 
    center: new google.maps.LatLng(46.87916, -3.32910), 
    mapTypeId: 'terrain' }; 
map = new google.maps.Map($('#map')[0], myOptions); var marker = new google.maps.Marker({ 
            map: map, 
    position: new google.maps.LatLng(46.87916, -3.32910), 
    draggable: true }); 
google.maps.event.addListener(marker, 'dragend', function () { 
    dragged = true; 
    setTimeout(function(){ dragged = false; }, 200); 
google.maps.event.addListener(map, 'click', function (evt) { if (dragged) return; 
console.log('click') }); 

How to represent directed cyclic graph in Prolog with direct access to neighbour verticies

I need to construct directed graph (at runtime) with cycles in Prolog and don't know how to represent it, so i can get from one vertex to his neigbour in a constant time.
Is it possible to do it somehow like in a tree representation, something like: t(left_son,V,right_son), but how to solve the cycles?
I can make a list of edges like: graph([a,b,c,d],
[e(a,b),e(b,c),e(c,a),e(c,d)]), OR just [a->[b],b->[c],c->[a,d],d->[]], but how to avoid calling function 'member' on list while searching for neighbours, which cost linear time?
Thanks for ur help

fprintf not writing to the pipe

I am successfully opening the pipe i.e gnuplot window using _popen. But not able to write to the stream using fprintf. I have checked the file pointer value and it is not null. I searched many sources and used fflush and it is not working. I could not find a solution.

Actually I have asked a similar question before here gnuplot c++ interface through pipes -cannot open wgnuplot reposting with some modifications.

Any suggestions would be helpful..

FILE* gp;
string command = "set style data lines\n" ;
char *path = "\"C:\\Program Files\\gnuplot\\bin\\wgnuplot\" -persist";

gp = _popen(path , "wt");

if (gp == NULL)
return -1;

fprintf(gp,command );

I used this code without using pipes and it uses createprocess. Here also the same situation,The gnuplot.exe opens but with no output plot.

int _tmain (int argc, LPTSTR argv [])

HANDLE hReadPipe, hWritePipe;

/* Init for inheritable handles. */
TCHAR outBuf[ ] = TEXT("a=2; plot sin(a*x)/x; pause mouse; plot exp(-a*x); pause mouse") ;
TCHAR inBuf[80];
DWORD dwWritten, dwRead ;
BOOL bSuccess = FALSE;

/* Startup info for the Gnuplot process. */

GetStartupInfo (&StartInfoCh2);

/* Create an anonymous pipe with default size.
The handles are inheritable. */

bSuccess = CreatePipe (&hReadPipe, &hWritePipe, &PipeSA, 0);
if (bSuccess == TRUE) printf("pipe created\n");

WriteFile(hWritePipe, outBuf, sizeof(outBuf), &dwWritten, NULL) ;
printf("Wrote %d bytes to Gnuplot\n", dwWritten) ;

CloseHandle (hWritePipe);

/* Repeat (symmetrically) for the child process. */

StartInfoCh2.hStdInput = hReadPipe;
StartInfoCh2.hStdError = GetStdHandle (STD_ERROR_HANDLE);
StartInfoCh2.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
bSuccess = FALSE ;
bSuccess = CreateProcess ("C:\\Program Files\\gnuplot\\bin\\wgnuplot.exe", NULL, NULL, NULL,
TRUE,0, NULL, NULL, &StartInfoCh2, &ProcInfo2);
if (bSuccess == TRUE)
printf("Created Gnuplot Process\n" ) ;

WaitForSingleObject (ProcInfo2.hProcess, INFINITE);
CloseHandle (ProcInfo2.hThread);
CloseHandle (hReadPipe);

/* Wait for Gnuplot process to complete.*/

CloseHandle (ProcInfo2.hProcess);
return 0;

How do you allocate object

How do you allocate object in objective C:-1:-MyClass *obj=malloc(sizeOf(MyClass));
2:-MyClass *obj=[MyClass alloc];3:-MyClass *obj=[MyClass new];4:-None of the above

Disable saving history

Is it possible to disable saving command history / session in R by default ? I really hate those .RData and .RHistory files !!

vim on ubuntu - cut to system clipboard

I am using Ubuntu 12.04 Beta and Vim that has come with it. I am trying to use Vim to copy the content of a text file to Chrome browser.
I have tried +, * y and all its variants. I have tried to :set clipboard=unnamed and : set clipboard=unnamedplus. Not working.
I am not trying to use xclip, or gvim or any. I tried with xclip (not a standard package in Ubuntu 12.04), but that too does not work, also too much effort.

How do I copy the text to the clipboard and then paste anywhere, like Chrome.

Search on KeyPress on Table/ TreeTable

I want to search the items on keypress event. like JTree give search on key press using following statement

Does any method for JTable, JXTable, JXTreeTable ?

I do not want to add myself written code for this.


LINQ concatenating elements in two string arryas

I have two string arrays

Array1 = {"Paul","John","Mary"}
Array2 = {"12","13","15"}

I would like to know whether it is possible to join these arrays so that the resultant arrays have something like


Implementing drag and drop in NSTableView

Can anyone help me to implement drag and drop in an NSTableView? I used this code below, but these methods are not getting called during execution.

- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard
// Copy the row numbers to the pasteboard.
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:@".gif"] owner:self];
[pboard setData:data forType:@".gif"];
return YES;

- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op
// Add code here to validate the drop

if (row > [ m_imageArray count])
return NSDragOperationNone;

if (nil == [info draggingSource]) // From other application
return NSDragOperationNone;
else if (self == [info draggingSource]) // From self
return NSDragOperationNone;
else // From other documents
[tv setDropRow: row dropOperation: NSTableViewDropAbove];
return NSDragOperationCopy;

NSLog(@"validate Drop");
return NSDragOperationCopy;

- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
NSPasteboard* pboard = [info draggingPasteboard];
NSData* rowData = [pboard dataForType:@".gif"];
NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData];
NSInteger dragRow = [rowIndexes firstIndex];

// Move the specified row to its new location...

how to send game score after ending the game via bluetooth

i implemented Trivia game for both iphone/iPad when user completes the game i am sending score to the opponent.i am not getting correct result won/loose .if i am playing the game simultaneously both users i am getting correct result who won/loose the game .
how to resolve this issue can any one suggest me .i implemented bluetooth option via Gamekit API

 - (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context
//Convert received NSData to NSString to display
NSString *whatDidIget = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

//Dsiplay the fart as a UIAlertView

int abc=[whatDidIget integerValue];

UIAlertView *alert55 = [[UIAlertView alloc] initWithTitle:@"Apponent Score:looser" message:whatDidIget delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert55 show];
[alert55 release];
[whatDidIget release];
else {
UIAlertView *alert55 = [[UIAlertView alloc] initWithTitle:@"Apponent Score:Win" message:whatDidIget delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert55 show];
[alert55 release];
[whatDidIget release];

button clicking code

- (void) sendASilentAssassin{
// Making up the Silent Assassin :P
NSString *silentAssassin = @"Puuuuuuuusssssssssssssssss";

// Send the fart to Peers using teh current sessions
[triviaSession sendData:[displayLiveScore.text dataUsingEncoding: NSASCIIStringEncoding] toPeers:triviaPeers withDataMode:GKSendDataReliable error:nil];


Creating an animated list via use of jquery

I have a list of text separated by <br/>, I would like to animate each of them using random shuffle after each click event, the post-top-position after each click is randomly determined.

<span id="text1">Text1</span>
<span id="text2">Text2</span>
<span id="text3">Text3</span>

Selenium File upload

How to automate Uploading a file using selenium.

How to give file Path ??

My TextBox is Readonly. I cant type the file path directly in the textbox.

Also, how to stop the selinum server until that file completely uploaded.??

Please Help.

Delete statement was very slow in Oracle

I have a table had about 100k records and I want to delete some rows, the problem is the DELETE statement is very slow which didn't finish in 30 minutes. but the select statement was return in 1s.

the SELECT statement and DELETE statement is as below:

select * from daily_au_by_service_summary where summary_ts >= to_date('09-04-2012','dd-mm-yyyy') order by summary_ts desc;

delete from daily_au_by_service_summary where summary_ts > to_date('09-04-2012','dd-mm-yyyy');

This table have the only index at summery_ts.

What could be the reason? thanks.

Autocomplete with multiple valuess

I have tried out the jquery autocomplete for multiple values. It works fine but the only problem is that if i enter a word in the textarea then go to the begining of the textarea and enter another word it appends to the end of the text area and not at the CARET position.COuld you please help?

Than You

This is the Code:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "     

<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
// document.domain = "";
// alert(document.domain);
<title>Form Field Clear</title>
<link href="

rel="stylesheet" type="text/css"/>
<script type="text/javascript" src='../../../../libuser/toitldocumentdomain.js'>

<script src=""></script>
<script src=""></script>
<meta charset="utf-8">
$(function() {
var availableTags = [
function split( val ) {
return val.split( / \s*/ );
function extractLast( term ) {
return split( term ).pop();

$( "#tags" )
// don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete"

) ) {
minLength: 0,
source: function( request, response ) {

response( $.ui.autocomplete.filter(
availableTags, extractLast( request.term )

) );
focus: function() {
// prevent value inserted on focus
return false;
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
// add the selected item
terms.push( ui.item.value );

terms.push( "" );
this.value = terms.join( " " );
return false;

<div class="demo">

<div class="ui-widget">
<label for="tags">Tag programming languages: </label>
<textarea id="tags" cols="50" ></textarea>


Facebook not able to scrape my url

I have the HTML structure for my page as given below. I have added all the meta og tags, but still facebook is not able to scrape any info from my site.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "">
<html xmlns="" xmlns:fb="">
<meta http-equiv="Content-Type" content="text/html;" charset=utf-8"></meta>
<title>My Site</title>
<meta content="This is my title" property="og:title">
<meta content="This is my description" property="og:description">
<meta content="" property="og:image">
<meta content="<MYPAGEID>" property="fb:page_id">

When I input the URL in facebook debugger(, I get the following messages:

Scrape Information
Response Code 404

Critical Errors That Must Be Fixed
Bad Response Code URL returned a bad HTTP response code.

Errors that must be fixed

Missing Required Property The 'og:url' property is required, but not present.
Missing Required Property The 'og:type' property is required, but not present.
Missing Required Property The 'og:title' property is required, but not present.

Open Graph Warnings That Should Be Fixed
Inferred Property The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.

Why is facebook not reading the meta tags info? The page is accessible and not hidden behind login etc.


Ok I did bit of debugging and this is what I found. I have htaccess rule set in my directory- I am using PHP Codeigniter framework and have htaccess rule to remove index.php from the url.

So, when I feed the url to facebook debugger( without index.php, facebook shows a 404, but when I feed url with index.php, it is able to parse my page.

Now how do I make facebook scrape content when the url doesn't have index.php?

This is my htaccess rule:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

Is Objective-C converted to C code before compilation?

I know objective C is strict superset of C and we are writing the same thing.
But when i write
@interface Myintf {} @end
Does it get converted to a C struct or is it that the memory layout for the data structure Myintf prepared by Objective c compiler is same as that of a C struct defined in runtime.h?

and same question about objc_msgsend

Apple document says

In Objective-C, messages aren't bound to method implementations until runtime. The compiler converts a message expression,
into a call on a messaging function, objc_msgSend.
This function takes the receiver and the name of the method mentioned in the message—that is, the method selector—as its two principal parameters:

Return SCOPE_IDENTITY() without using CreateParam

I'm trying this but getting an error ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed. on the line with this code If ScopeID.EOF Then

Please do not answer to use the CreateParam method, Looking for a solution without this method. Thanks.

set Cmd = Server.CreateObject("ADODB.Command")
Cmd.ActiveConnection = conn

Cmd.CommandType = 1
Cmd.CommandTimeout = 0
Cmd.Prepared = true

Set ScopeID = Cmd.Execute()

If ScopeID.EOF Then
Response.Write "There was an Error in your request, Please try again"
ID= ScopeID(0).Value
End IF

Set ScopeID = Nothing
Set Cmd = Nothing

Response.Write ID


Mscrypto.dll PPCrypt class equivalen managed class in .NET

We have a project in which we are using a interop of MSCrypto because we are using the PPCrypt class, is there are any equivalent managed class available in .NET framework?

Breadcrumbs for wxWidgets treeCtrl

I would like to add breadcrumbs navigation to a treeCtrl in wxWidgets C++ - similar to IE Explorer. Does anyone know if that exists somewhere? Or at least something similar to use as a starting point? Ideally I would like the breadcrumb to look and act natively on mac/unix/windows.


Replace only up to N matches on a line

In Perl, how to write a regular expression that replaces only up to N matches per string?

I.e., I'm looking for a middle ground between s/aa/bb/; and s/aa/bb/g;. I want to allow multiple substitutions, but only up to N times.

Javascript/Jquery simple user experience functions

I am starting to write some javascript for my site to create a better user experience but i am getting a little confused on what exactly is happening, and maybe it is clearly evident to someone else what I am doing wrong or missing. I have two javascript functions that work perfect after the first time of use and if you use it slowly (sometimes it skips the next item and selects nothing if you press a key too fast). I feel that I am missing some sort of $(document).ready(function() {}); implementation to make sure that each process has finished before it moves on. I have two textboxes that the user puts in two numbers then it moves on to the next tab element (the next textbox). The textboxes are also in an update panel if that has any impact.

    function selectall(item) {

function selectNext(textBox) {
if ($(textBox).val().length == 2) {

<asp:TextBox ID="Text1" runat="server" Width="30px" AutoPostBack="True" onkeyup="selectNext(this);" onclick="selectall(this);"
<asp:TextBox ID="Text2" runat="server" Width="30px" AutoPostBack="True" onkeyup="selectNext(this);" onclick="selectall(this);"
<asp:DropDownList ID="Text2" runat="server"

Using Dates from Cell or named Range in Sql Query

I have created a sheet to extract data from a Microsoft SQL database to produce a customer report between 2 date StartDate and EndDate.

I have been playing with a few things but have not been successful in anyway. I have searched but have not been able to find anything that was what I was after or able to understand.

The problem I believe is data type of the date I am using in Excel and trying to pass it to the SQL query. I understand I need to convert this in some way to make this possible and correct.

If I manually enter dates into the query it works fine. But not practical for customer use
I am not experience with this and am just! stubbing my way through it. If someone would be so kind to me with this would be much appreciated.

Below is the code I am trying to use

Sub DataExtract()
DataExtract Macro

' Create a connection object.
Dim cni96X As ADODB.Connection
Set cni96X = New ADODB.Connection

' Set Database Range

' Provide the connection string.
Dim strConn As String
Dim Lan As Integer
Dim OS As Integer
Dim PointID As String

' Set Variables
Lan = Range("Lan").Value
OS = Range("OS").Value
PointID = Range("PointID").Value
StartDate = Range("StartDate").Value
EndDate = Range("EndDate").Value

'Use the SQL Server OLE DB Provider.

'Connect to 963 database on the local server.
strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=i96X;"

'Use an integrated login.
strConn = strConn & " INTEGRATED SECURITY=sspi;"

'Now open the connection.
cni96X.Open strConn

' Create a recordset object.
Dim rsi96X As ADODB.Recordset
Dim rsi96X1 As ADODB.Recordset
Set rsi96X = New ADODB.Recordset
Set rsi96X1 = New ADODB.Recordset

With rsi96X
' Assign the Connection object.
.ActiveConnection = cni96X
' Extract the required records1.
.Open "SELECT ModuleLabel, originalAlarmTime FROM LastAlarmDetailsByTime WHERE (os = " & OS & " And theModule = N'" & PointID & "'AND AlarmCode = N'DI=1' And lan = " & Lan & " And originalAlarmTime BETWEEN N'" & StartDate & "' AND N'" & EndDate & "') ORDER BY originalAlarmTime DESC"
' Copy the records into sheet.
Range("PointLabel, TimeCallInitiated").CopyFromRecordset rsi96X

With rsi96X1
.ActiveConnection = cni96X
' Assign the Connection object.
.Open "SELECT originalAlarmTime FROM LastAlarmDetailsByTime WHERE (os = " & OS & " And theModule = N'" & PointID & "'AND AlarmCode = N'CDI1' And lan = " & Lan & " And originalAlarmTime BETWEEN N'" & StartDate & "' AND N'" & EndDate & "')ORDER BY originalAlarmTime DESC"
' Copy the records into sheet.
Sheet1.Range("TimeCallEnded").CopyFromRecordset rsi96X1
' Tidy up

I hope this makes sense.

Parsing BIG XML in PHP

I need to parse an XML that is big. f.ex 100mb (it can be even more).

For Example:
Xml looks like this:

<body>Don't forget me this weekend!</body>

x 1000000 different notes(or even more)


Each note has un unique ID. When I Parse an XML, I need to first find if note by specific ID exists in DB if no than INSERT it.

The problem is in Performance(it takes 2 hours). I try to take all ids from the DB (but is also big) with one SELECT, so I dont ask DB each time and I have them in PHP Array (Memory).

$sql = "SELECT id FROM 'notes'";
$ids = Array with all ids

I 've also parsed an XML with xml_parser in a loop:

while($data = fread($Xml, '512')) {
xml_parse($xmlParser, $data);

I think that parse an XML with simple_xml_parser may generate a too big variable for PHP to handle it.

And than when I have a note ID I check if it exists in $ids:

if (!array_search($note->id, $ids)) {
//than insert it

But it takes too long. So I found that PHP comes with special Arrays called Juddy Arrays but I don't know exactly if they are for this - I mean for quick parse BIG Arrays.

I think also with Memcached, to store the ids from DB in many variables, but I want to find a proper solution.

In DB table there are also indexes, to speed up the process. The XML grows every week :) and it conatins every time all notes from the last XML plus new notes.

How to fast parse BIG ARRAYS in PHP? Are Judy Arrays for this?

How can i show panel when i click second time on link

Below works fine to me when click on left side links, right side panel animating like slideUp. But When i click again on the same link, panel hides. But i dont want hide the panel. Please let me know, what i need to correct on above code.

Is there any difference about thread safety strategy between accessing member directly and accessing by

I have the code below.
I'm wondering that does the self.value and _value have some difference about thread safety strategy?

@interface Temp:NSObject

@property(nonatomic, strong) NSInteger *value;


@implementation Temp

@synthesize value = _value;

- (void)someMethod:(NSInteger)someValue {
self.value = someValue;

- (void)someOtherMethod:(NSObject *)someValue {
_value = someValue;


Django-like templates system for Java?

I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists?

The target is to have same templates files for different languages.

{{ var|escape }}

can be rendered from python (Django) code as well as from PHP, using Twig. I'm looking for Java solution.

Any other templates system available in Java, PHP and python is suitable.

MySQL "default" result

I have a MySQL table like

id    |  text   |  category   |   active

I select a random line with

SELECT id, text 
FROM table
WHERE category = [category id] AND active = 1

Some times this would return no results (e.g. if there is no active row in a specific category). What I need to do in that case is to return a "default" row.

My question is: what is the most efficient way to do this? Should I just create an identical table but just with the default rows, which I would query if the above query gives no results? Or should I add the default rows in the same table? And how would you query it?

Note that I am excluding the possibility of generating the default text in PHP, as I want it to be customizable, without having to go and change the code.

Any suggestion is welcome!

Error: Cannot convert lambda expression to type 'int' because it is not a delegate type

This is the source code( I am using CodeSmith Tools):
public static int Delete(this System.Data.Linq.Table table, int pKProgramID)
return table.Delete(p => p.PKProgramID == pKProgramID);

I am getting this error:
Cannot convert lambda expression to type 'int' because it is not a delegate type C:\Projects\New\EAccreditation.Data\Queries\ProgramsExtensions.Generated.cs

Please, advised
Thank you

Python - SQLite to CSV Writer Error - ASCII values not parsed


I am having some trouble with a SQLite to CSV python script. I have searched high and I have searched low for an answer but none have worked for me, or I am having a problem with my syntax.

I want to replace characters within the SQLite database which fall outside of the ASCII table (larger than 128).

Here is the script I have been using:

import sqlite3
import csv, codecs, cStringIO

class UnicodeWriter:
A CSV writer which will write rows to CSV file "f",
which is encoded in the given encoding.

def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
# Redirect output to a queue
self.queue = cStringIO.StringIO()
self.writer = csv.writer(self.queue, dialect=dialect, **kwds) = f
self.encoder = codecs.getincrementalencoder(encoding)()

def writerow(self, row):
self.writer.writerow([unicode(s).encode("utf-8") for s in row])
# Fetch UTF-8 output from the queue ...
data = self.queue.getvalue()
data = data.decode("utf-8")
# ... and reencode it into the target encoding
data = self.encoder.encode(data)
# write to the target stream
# empty queue

def writerows(self, rows):
for row in rows:

conn = sqlite3.connect('test.db')

c = conn.cursor()

# Select whichever rows you want in whatever order you like
c.execute('select ROWID, Name, Type, PID from PID')

writer = UnicodeWriter(open("ProductListing.csv", "wb"))

# Make sure the list of column headers you pass in are in the same order as your SELECT
writer.writerow(["ROWID", "Product Name", "Product Type", "PID", ])

I have tried to add the 'replace' as indicated here but have got the same error. Python: Convert Unicode to ASCII without errors for CSV file

The error is the UnicodeDecodeError.

Traceback (most recent call last):
File "", line 53, in <module>
File "", line 32, in writerows
File "", line 19, in writerow
self.writer.writerow([unicode(s).encode("utf-8") for s in row])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 65: ordinal not in range(128)

Obviously I want the code to be robust enough that if it encounters characters outside of these bounds that it replaces it with a character such as '?' (\x3f).

Is there a way to do this within the UnicodeWriter class? And a way I can make the code robust that it won't produce these errors.

Your help is greatly appreciated.

Object not set to an instance of an object - Recycling App Pool fixes the issue

My ASP.NET MVC 3 app uses an web service which passes an custom user object to the app. Sometimes, without reason, this user object just doesn't instantiate when I call a method to return an user object from my web service, so I get an Object not set to an instance of an object error. The only way I'm able to fix this is by recycling my App Pool of my web service in IIS, I have no idea what could be causing this so was wondering if this is a common problem and if so, is their a way to fix it?

This is the line which returns no data:

PZServicesClient client = new PZServicesClient();
var user = client.GetUser(HttpContext.User.Identity.Name);

As soon as I recycle the App Pool it instantly starts working again.