Posts

'ascii' codec can't decode byte 0xe2 in position 50: ordinal not in range(128)

Image
Disclaimer: I'm not a python developer :) Yesterday I've found a tool that I needed, it was written in python. Nothing special, get a list of links from a csv, login to a page, and access a link from the opened page by match. The script was old(2 years), and it needed some refinement, but I managed to make it work to start griding my over 7000 links, after 30 minutes later I saw it crashed with a strange error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 50: ordinal not in range(128) I've started to investigate the issue, found some information on stackoverflow, but I was confused, I don't really know python that well. What I've found is to make some changes in the config files from python, which I don't really know how to do and it was not recommended, or to use decode('utf-8') function on the string variable and usage that caused the issue. As you can see in the full error log, listed down below, I tra

DataTable to TreeView in C#, Displaying Hierarchies

In this article I will show you how to display hierarchies in a TreeView control, when your data is in a DataTable. In this example we have an Employee table with 3 columns: ID, ParentID and Name. ParentID is the ID of the boss for the current Employee. The first step is to sort the table by the ParentID . This step is really important because we cannot insert a node in the tree until it's parent is not inserted. Notice the root of the tree having a ParentID of -1. Here is the code for this: The second step is to use a XmlDocument. The TreeView control does not have the functionality to find an arbitrary node given a node ID. A recursive find function seems to be too much hassle, not to mention the performance, so I decided to take advantage of the XPath search capabilities of XmlDocument to find a given Parent node. Here is the code for this: The third step is to hook up our data to the TreeView. If you try to bind the TreeView control to an XmlDocument you w

Sanitizer provider is not configured in the web.config file. Ajax Control Toolkit and HtmlEditorExtender problems.

Image
The Problem Today I had a hard 2 hours, and if you have found this blog post, I bet we are in the same shoes. I was working on a ASP .NET + windows azure project, and I needed the HtmlEditorExtender   control from the Ajax Control Toolkit . I was lucky to find a control for my needs. So far so good. I've installed the toolkit with NuGet Package manager, it added a reference to the assembly to my web.config. I've used the following code where I needed the HtmlEditorExtender: < ajaxToolkit:ToolkitScriptManager runat ="Server" /> < asp:TextBox ID ="txtComments" TextMode ="MultiLine" Columns ="60" Rows ="8" runat ="server" /> < ajaxToolkit:HtmlEditorExtender TargetControlID ="txtComments" runat ="server" /> </ asp:Content > Just to see how this control works. As you can bet ajaxToolkit is the refe

My android phone keeps restarting

Image
Some days ago my android phone kept restarting, and heating up. I have a Samsung Galaxy S2 GT-I9100, kernel: XWLP7 OS: ICS 4.0.3 Ok, I said, probably the latest apps that I've installed on it have to do something with this, I tried to uninstall them, but no luck. Then I thought I have a virus, but how can I scan my phone if it keeps restarting. As a last resort I tried to move my apps from my SD memory card to the phones internal memory, guess what ? the restarting stopped and the heat up too. After some google-ing I've found this:  http://code.google.com/p/android/issues/detail?id=25563 . They say that this is a bug in ANDROID OS 2.3.5 (and higher), and happens if you have too many apps transferred to your SD card. Huge bug my ass, this is lame. How come that it was not fixed in the further updates? This is not a small bug that happens once a year, this can be recreated over 1000 times, with the same result. It's a shame. So, if you have the same issue as me,

SEO pentru Blogger, Adaugare de meta tag-uri

Image
Cele mai des folosite meta tag -uri pentru SEO , pentru un blog pe platforma Blogger sunt: description si keywords . Blogger nu foloseste in mod implicit aceste meta tag-uri. Inainte sa faci vre-o modificare la template-ul tau, fa un backup ca sa nu ai dureri de cap. Pentru implementarea metodelor de mai jos, cauta in codul template-ului tau urmatoarea secventa de cod: < b:include data ="blog" name ="all-head-content" > Sub el adauga meta tag-urile cu una dintre metodele descrise mai jos. Metoda 1 Adaugi meta tag-urile ca si pentru o pagina web normala. < meta content ='Cuvinte cheie separate prin virgula' name ='keywords' /> ; < meta content ='Descrierea blogului' name ='description' /> Pro :- din doua linii de cod ai meta description si keyword pentru tot blogul - o solutie mai comoda Contra : - description si keyword duplicat pe toate paginile blogului - Google si alte motoare de

14 Sfaturi pentru programatori incepatori

Image
Am petrecut foarte mult timp cu depanarea codurilor scrise de mine sau de altii. Nu conteaza despre ce limbaj de programare este vorba: C, C++, C#, Java, PHP, HTML, CSS, ASP, etc. Pana la urma cel mai mult timp il vei pentrece cu depanarea codului pe care il scrii, sau scris de altii.          In aceasta ordine de idei am elaborat 14 sfaturi pentru programatori incepatori: Rabdare.  Depanarea necesita foarte multa rabdare. Trebuie sa ai o gandire calma si rationala, cu cat te enervezi mai mult cu atat scade sansa de a reusi sa-ti repari codul.  Google este prietenul tau.  Foarte multi oameni care au invatat sa programeze au avut aceleasi probleme ca si tine. Poti gasi solutia la problema pe care o ai, sau alte solutii pe care trebuie sa le adaptezi pentru problema ta, si cum se foloseste functia sau clasa de care ai nevoie. Pe internet sunt foarte multe detalii despre functia sau clasa pe care vrei s-o folosesti, doar trebuie sa cauti. Citeste mesajele de eroare  Foarte multi ince

Tutorial C# - Cum sa faci un program care citeste text cu voce

Image
In acest tutorial C# o sa va arat cum sa folositi Speech API -ul de la Microsoft. Pasul 1 Adaugati o referinta la obiectul SAPI COM . In Solution Explorer din Visual Studio da-ti click dreapta pe folderul References si selectati Add Reference. In fereastra ce apare, selectati tab-ul COM si dati click pe Microsoft Speech Object Library si apasati pe OK. In imaginea mai jos puteti vedea cum arata interfata, contine 1 TextBox cu proprietatea MultiLine - True si un Button. Dati dubliclick pe buton pentru a crea un event petru acesta. SpeechLib.SpVoiceClass voice = new SpVoiceClass(); private void button1_Click( object sender, EventArgs e) { voice.Speak(textBox1.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } Jucati-va putin cu obiectul voice, se poate schimba volumul, vocea etc.Daca apar probleme cu codul, sau ati facut ceva intreasant cu API-ul, nu ezitati sa