Posts

Python unicode equal comparison failed -

this question linked searching unicode characters in python i read unicode text file using python codecs codecs.open('story.txt', 'rb', 'utf-8-sig') and trying search strings in it. i'm getting following warning. unicodewarning: unicode equal comparison failed convert both arguments unicode - interpreting them being unequal is there special way of unicode string comparison ? you may use == operator compare unicode objects equality. >>> s1 = u'hello' >>> s2 = unicode("hello") >>> type(s1), type(s2) (<type 'unicode'>, <type 'unicode'>) >>> s1==s2 true >>> >>> s3='hello'.decode('utf-8') >>> type(s3) <type 'unicode'> >>> s1==s3 true >>> but, error message indicates aren't comparing unicode objects. comparing unicode object str object, so: >>> u'hello' =...

sorting - How to sort a file in unix both alphabetically and numerically on different fields? -

please don't think repeat of "sorting alphanumeric data in unix" question... looked @ other answers, , think case bit different! i have data this: a 192 d 112 d 188 c 091 281 b 919 ...and want sort first column 1 (alphabetically), , column 2 (numerically). tried using: sort -n -k1,2 ...but gave me correctly sorted first field, wrong sorting second field (1000,1002,1003,10,1 ... instead of 1,10,1000,1002,1003). can please suggest how sort these 2 columns way i'd like? try using this:- sort -k1,1 -k4,4n -n : makes program sort according numerical value -k opts: sort data / fields using given column number. example, option -k 2 made program sort using second column of data. option -k 3,3n -k 4,4n sorts each column. first sort 3rd column , 4th column.

php - Show different image depending on value in variable -

just want make sure i'm going in right direction this. have image want replaced/changed if value of variable either 0/1. here code guy doing server side stuff. <?php //requires mysql_connect create connection $link_state = 0; //if wish don't have check connection, may idea leave in. if ($mysql_connection['connected'] == true) { $result = mysql_query("select * link"); //the bit looking should first row, , should 1 row $count = mysql_num_rows($result); if ($count <= 0) { //interesting... $mysql_error['error'] = true; $mysql_error['description'] = "error: no rows returned table 'link'"; } else { //we should ok continue if ($count > 1) { $mysql_error['error'] = true; $mysql_error['description'] = "warning: found more 1 row in 'link' table!"; } $row = mysql_fetch_...

String as Indexer in C# -

let me start showing code: using system; namespace tutorialadvanced { class collection { object[] values; public collection(int size) { values = new object[size]; } public object this[string index] { { return values[index]; } set { values[index] = (object)value; } } } class program { static void main() { collection collection = new collection(3); collection["integer"] = 123; collection["decimal"] = 456.78; collection["text"] = "hello world!"; double total = (double)(int)collection["integer"] + (double)collection["decimal"]; console.writeline("total {0}", total); console.writeline(); collection collection...

python - Can I My Program be Under the GPL if I Use PySide? -

i making program , want put under gpl using pyside in under lgpl. can still put program under gpl or have under lgpl. both of these licenses program? thanks yes, can. gpl doing program? read license. :-) the lgpl not program. lgpl makes static linking more difficult, doubt matters python.

Can't display the output result in browser returned from htmlentities() function in php -

i tried display output returned htmlentities() function. but, display nothing in browser. here code.. $advertisement = "coffee @ 'cafè française' costs $2.25."; echo htmlentities($advertisement); the result should this: coffee @ 'cafè française' costs $2.25. but, there nothing displaying in browser. when assign output in variable, it's value not null. testing code is: $temp = htmlentities($advertisement); if($temp === null) echo "null"; else echo "not null"; then, result "not null"; i try code testing: $str = "a 'quote' `<b>`bold`</b>`"; //outputs: 'quote' &lt;b&gt;bold&lt;/b&gt; echo htmlentities($str); but, output in browser not expected. mean in browser it's not replaced <b> &lt;b&gt; what missing? need change setting in php.ini file? that htmlentities supposed do. echo string out , should implement html auto...

Why is my android receiver dropping 10-60% of UDP broadcast packets? -

i have 802.3 wired transmitter application on computer i've written broadcast udp packets every 10ms. each broadcast packet contains 4-byte integer value unique particular packet, allows me figure out on receiver end how many packets have been dropped. i have verified transmitter works wireshark. set 4 802.11 receivers (2 android phones , 2 laptop computers) on same network. laptops received 95% of udp broadcast packets; 1 phone received 89%; other phone received 40%. why? here part of android receiver code: public class netthread extends thread { int[] pkt_nums; int p; netthread(int[] pkt_nums) { this.pkt_nums = pkt_nums; (int i=0; i<pkt_nums.length; i++) { pkt_nums[i]=0; } p = 0; } @override public void run() { receivedata(); } public void receivedata() { // request permission network operations in manifest file...done // start n...