Posts

Featured post

python - Diffing two files while ignoring any missed lines -

i diffing 2 unsorted files , problem moment 1 of files gets line not present in other file, diff goes off. want write/print line not present , continue on. import re f1=open("file1","r") f2=open("file2","r") f=open("output","w") test_lines=f1.readlines() correct_lines=f2.readlines() test, correct in zip(sorted(test_lines), sorted(correct_lines)): if test.strip().split("(")[0].replace(" ","").strip() != correct.strip().split("(")[0].replace(" ","").strip() , test!="\n": print "oh no! expected %r; got %r." % (correct, test) else: towrite=correct + test f.write(towrite) else: len_diff = len(test_lines) - len(correct_lines) if len_diff > 0: print "test file had data." elif len_diff < 0: print "test file had little data." else: print "everythin

Python How to get Scrapy Xpath data from Basic Table? -

<table> <br> <tr> <td width = 270><p align="left" style="margin-left: 0;"><b>info</b></p></td> <td><p> </p></td> </tr> <tr> <td width = 270><p align="left" style="margin-left: 10;">page&nbsp;count</p></td> <td><p> = 4 </p></td> </tr> ... trying response.xpath = 4 value table above. when inspecting element in chrome , pulling xpath way sill end [] value. tried: /html/body/table[1]/tr[2]/td[2] //table[2]/tr[2]/td[2] both fails. i'd td count text instead , following-sibling : //td[contains(p, "count")]/following-sibling::td/p/text() demo: $ scrapy shell index.html in [1]: response.xpath('//td[contains(p, "count")]/following-sibling::td/p/text()').extract() out[1]: [u' = 4 '] and if want extract

shader - How to create a texture alpha, with white and black colors only, in GLSL? -

Image
i looking reproduce glow effect tutorial , if understand well, convert first image "alpha texture" (black , white), , blur (rgb * a) texture. how possible create alpha texture, colors go white, , other go black? found : how render texture alpha? don't know how use these answers. thanks it appears misunderstanding diagram showing you. 1 texture, (a) shows rgb color , (b) shows alpha channel. (c) shows happens when multiply rgb a. alpha not "black , white", abstract concept , amounts range of values between 0.0 , 1.0 . human brain make sense out of it, interprets black ( 0.0 ) , white ( 1.0 ). in reality, alpha whatever want , unrelated color (though can used color). typically alpha channel generated post-process image filter, looks areas of texture above average luminance. in modern graphics engines hdr used , part of scene color bright displayed on monitor candidate glowing. intensity of glow derived how brighter lighting @ point mo

sql server - best way to get iso into usa format -

trying convert date string usa format '20150316 16:28' '3/16/2015 4:28 pm' (note: 24hr format fine too) http://sqlfiddle.com/#!6/9eecb/862 the predefined format "g" give date time in format: select format(cast('20150316 16:20' datetime), 'g') update: select format( cast('20150316 16:20' datetime), 'd') + ' ' + format( cast('20150316 16:20' datetime), 'hh:mm') produces 3/16/2015 16:20 see these articles predefined , custom date time formats: https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx note these vary culture.

c++ - Hook function call linux mint -

some days ago wrote simple hook/detour patching single call instruction. worked on ubuntu 12.xyz (32bit), updated linux mint 17.1(32bit) , segmentation fault. i have 2 projects target project calls function named goodguy library project loaded dlopen() overwrites offset call instruction in target application before overwriting call instruction offset, modify protection of page by: mprotect(pageof(address),pagesize,prot_write|prot_exec|prot_read) this works fine (returns 0). when debug programm, crashs while trying write address of call: memcpy((void*)(address + 1),(void*)&calloffset,4); looks not allowed overwrite instructions, why ? i diabled alsr , used -z execstack -fno-stack-protector flags g++. do know how allow application write instructions ? thank you, alex edit sorry guys, here code: target application: #include <dlfcn.h> #include <stdio.h> #include <stdio.h> #include <iostream> void goodguy(); //full lib path

javascript - <button> JQuery onclick works only once -

i have button onclick event works fine here: // create function remove "popup-open" classes // function used in onclick attribute (function( $ ){ $.fn.popupclose = function() { $( "body" ).removeclass( "popup-open" ) $( ".overlay_btn" ).removeclass("popup-open"); return this; }; })( jquery ); // if <button> exists // onclick read button id value // add "popup-open" class span idvalue class, fadein effect if ( $( "button.popup" ).length ) { $("button.popup").click( function() { var btnid = $(this).attr('id'); $( "body" ).hide().addclass( "popup-open" ).fadein(100); $( "."+ btnid ).hide().addclass( "popup-open" ).fadein(200); } ); } if ( $( "button.link" ).length ) { $("button.link").click( function() { var btnformaction = $(this).attr(&#

PHP - What Host name should we provide in websocket server file -

hello trying implemented chat application website. have uploaded files online server check chatting.the code works fine in localhost problem server.php don't run. running file through ssh terminal. think might have problem here $server = new phpwebsocket(); $server->bind('message', 'wsonmessage'); $server->bind('open', 'wsonopen'); $server->bind('close', 'wsonclose'); // other computers connect, need change lan ip or external ip, // alternatively use: gethostbyaddr(gethostbyname($_server['server_name'])) $server->wsstartserver('127.0.0.1', 9300); my server.php file residing in directory public_html/domain.com/websocket/server.php