Posts

Showing posts from September, 2013

asp.net - checkboxlist styling doesnt works -

i have tried possible ways replace default checkbox input button interactive gif image , dont know missing , or tutorial highly appreciated, below css snippet m using apply checkbox list: #left_columnforsale .accordcontent span.chkbox input[type="checkbox"] { /*background: url('../images/checkbox.gif') no-repeat;*/ background-color: #800000; } sorcecode : <span id="contentplaceholder1_checkboxlist1" class="chkbox"> <input id="contentplaceholder1_checkboxlist1_0" type="checkbox" name="ctl00$contentplaceholder1$_content$checkboxlist1$0" onclick="javascript:settimeout(&#39;__dopostback(\&#39;ctl00$contentplaceholder1$_content$checkboxlist1$0\&#39;,\&#39;\&#39;)&#39;, 0)" value="0 , 1000" /> <label for="contentplaceholder1_checkboxlist1_0">0 - £1,000</label> <br /> <input id="contentplaceholder1_checkboxlis...

javascript - Test if URL is accessible from web browser i.e. make sure not blocked by Proxy server -

i serving website mywebsite.com. host images on flickr images loaded in user's browser via requests flickr. many of websites users access mywebsite.com corporate networks, block access flickr.com. means users annoying blank placeholders instead of images. same problem facebook button. makes site unattractive such users. is there way can run client side script check if flickr.com, facebook.com, etc. accessible. if not change href attribute of image load alternate source, or replace standard image explaining network blocking access. remove facebook button. i thought xml http request trick, i'd hit cross domain issues think. guess set proxy serve images, don't want that; idea of flickr takes bandwidth hit. tldr: how determine if flickr.com accessible user's browser, using client side technology. you try this... var image = new image(); image.onerror = function() { var images = document .getelementbyid('flicker-images...

c# - Date comparison within timer -

i have timer runs every second, code bellow: public mainwindow() { initializecomponent(); dispatchertimer timer = new dispatchertimer(); timer.interval = timespan.frommilliseconds(1000); timer.tick += new eventhandler(someeventhandler); timer.start(); } private void someeventhandler(object sender, eventargs args) { tvmonitor tvmonitor = new tvmonitor(); if (tvmonitor.needsturningon()) { console.writeline("on"); tvcom.sendcommand(settingmanager.gettvcode("on") + environment.newline); } } in function needsturningon() have following: public bool needsturningon() { var turnon = (from settings in context.systemsettings settings.systemsettingname == "tvontime" select settings).first(); if (turnon.systemsettingvalue == string.empty) { return fals...

wordpress security and xmlrpc.php -

looking through site stats i'm noticing bunch of hits on wordpress/xmlrpc.php file. it's not me afaik, need worry here, there anyway secure this? i'm running multiple wordpress sites on same apache2, , it's 1 of them happening to. if don't use xmlrpc interface (pingbacks or blogging external sources android/iphone), can turn off feature. settings -> writing -> xml-rpc

google app engine - Appengine: can't delete deployed version -

Image
i've deployed couple of app versions can't delete now. i tried delete using " appengine  〉administration 〉versions" when press "delete" delete version 99: an attempt delete version causes 500 error: i've tried overwrite them new ones, didn't helped. i've tried delete them week ago , yesterday fails. i'm afraid after time versions became undeletable (now have 2 undeletable versions , deployed versions limit &approx;11). how supposed delete versions? there alternative ways delete deployed versions (appcfg wouldn't help)? appears filed bug .... star if not own report give more weight

testing - selenium management tool -

i wondering best management tool selenium. handles automated running of tests rc. saves screenshots selenium rc takes, connectivity database. of tools guys use. thank you i think looking continuous integration server. want.

jquery - Ajax passing cookies with ie7 -

i using jquery on facebook application. logged-in user has cookie containing facebook id, , how authenticated on server side. the problem occurs on ie7 when initiating ajax request server. browsers works fine, , when check user's cookie on server side works great. however, seems when using ie7, cookie not sent along ajax request (when issuing non ajax request cookies passed fine). are there workarounds issue? strange thing problem occurred on 1 computer using ie7, on different 1 operating same browser version did manage work :/ thanks! joel maybe use jquery $.ajax caches ajax request default. prevent use: $.ajax({cache:false, ....})

htmlpurifier - Webmail: HTML headers -

html e-mails complex beast. deciding send (as sender) , display (as recipient) tricky , potentially dangerous. on recipient side of things, have webmail , have regular e-mail clients . purposes, consider 'webmail' displays html e-mail part of in html, , regular e-mail clients displays html e-mail in different context (e.g. os- , program-specific gui). what should webmail html headers ( <head> , <title> , <meta> , ...) in e-mail? there spec somewhere, actual standard or de-facto-standard? my motivation asking use html purifier sanitise our html , if core.collecterrors feature reports changes, they're reported. 'reported' both necessary... , frustrating. strip out of reported errors insignificant our purposes, html headers mark massive hurdle: someone potentially use <link> in e-mail, strip out. (html purifier intended html fragments , not full documents) the desire use things <link> in html e-mails seems exist , , th...

performance - Objective-C: Function-Like Macro Vs. Method -

in objective-c, when recommend using function-like macros on class or instance methods? they're different things. function or method exists once in code; macro inserts entire definition code every time use it. some people take advantage of fact short macro can expand chunk of code, rather cheap substitute c++ style templates. matt gallagher's singleton macro 1 example. , templates, overuse of large macros can lead surprisingly large code , big debugging headaches. aside constants , tiny expressions, if can use function or method in place of macro, should.

.net - singleton implementation problem in C# -

--consoleapplication 1 using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication2 { public class msgservice { private static createconnectiontoa _instancea; private static createconnectiontob _instanceb; protected msgservice() { } public static msgservice getinstancea(string parama, string paramb) { if (_instancea != null) { return _instancea; } return _instancea = new createconnectiontoa("p1","p2"); } public static msgservice getinstanceb(string parama, string paramb) { if (_instanceb != null) { return _instanceb; } return _instanceb = new createconnectiontob("p1", "p2"); } } } using system; using system.collections.generic; using system.linq...

c# - Making LinkedIn API request using Hammock .net web library -

i'm doing integration linkedin apis using c# , hammock libray. i'm stuck trying use messaging api... error saying "couldn't parse mailbox-item document: error: unexpected end of file after null". it seams post content going empty don't know... here's code: restclient client = new restclient(); client.authority = "http://api.linkedin.com/v1"; client.credentials = credentials; //client.method = webmethod.post; byte[] msg = encoding.default.getbytes(doc.outerxml); client.addpostcontent(msg); restrequest request = new restrequest(); request.path = "/people/~/mailbox"; request.method = webmethod.post; //request.addpostcontent(msg); restresponse response = client.request(request); my xml (that goes in msg variable) is: <?xml version="1.0" encoding="utf-8"?> <mailbox-item> <recipients> <recipient> <person path="/people/~" /> </recipient> </recip...

An Alternative to the Android-Emulator? -

i know use desire z test phone, if want develop 3.0 honeycomb? what's alternative emulator since it's slow? http://www.bluestacks.com/ this site has been getting press recently. seems going launch windows runnable version of android later year. alternative using devices or emulators testing imagine.

html - How to set table cell value using jquery -

i set value of cells of table iterating through them. ideally access html table array i.e. $("#tbl")[row][col]="5" this not work. $(document).ready(function() { (var row = 0; row < 3; row++) { (var col = 0; col < 3; col++) { $("#tbl").children().children()[row].children()[col].append("sdfasdf"); } } }); this works dont know why!!! i dont understand $("#tbl").children() .children() why need 2nd children why 3rd children not function i.e. children() 1st 2. why is'nt innerhtml not function i.e. innerhtml() $(document).ready(function() { (var row = 0; row < 3; row++) { (var col = 0; col < 3; col++) { $("#tbl").children().children()[row].children[col].innerhtml = "h!"; } } }); if want iterate on each cell in table, either of following work: $('#tbl td').each(function () { var $cell = $(this); ...

winforms - Searching for Microsoft Access records in a C# Windows Forms application? -

how search microsoft access record in c# windows forms application? code: private void btnsearch_click(object sender, eventargs e) { dataadapter = new oledbdataadapter("select * tblstudents studid='" + txtstudid.text + "' ", conn); dataset = new dataset(); dataadapter.fill(dataset); datagridview1.datasource = dataset.tables[0]; } //bindingsource sync datatable , datagridview bindingsource bsource = new bindingsource(); //set bindingsource datasource bsource.datasource = ds.tables[0]; //set datagridview datasource datagridview1.datasource = bsource; to changes database, have call update() of oledbdataadapter datatable argument accomplish this. da.update(ds.tables[0]);

Silverlight Combobox - Setting the SelectedItem MVVM -

i have viewmodel sets value "userstructure" property. problem combobox wont bind value. public class owneroccupieraccountviewmodel : viewmodelbase { /// <summary> /// load combobox structures /// </summary> private readonly loadoperation<structure> _loadstructures; private readonly loadoperation<unitoccupierdetail> _loadunitoccupierdetails; //public icommand saveaccountsettingscommand { get; set; } #region properties private observablecollection<structure> _structures; public observablecollection<structure> structures { { return _structures; } set { _structures = value; raisepropertychanged("structures"); } } private structure _userstructure; public structure userstructure { { return _userstructure; } set { _userstructure = value; raisepropertychanged("sele...

jQuery Tooltip Custom implementation -

i working application generating html forms, , including custom attributes used client side validation. error message used validation, included in error attribute, , expression validate input against, included in expression attribute. i have following javascript block, $(document).ready(function() { $("input[expression]").blur(function() { var inputs = $(":input[expression]"); inputs.each(function(index){ var input = inputs[index]; var expression = $(this).attr('expression'); if(!$(this).val().match(expression)) { var error = $(this).attr("error"); $(this).attr("title",error); $(this).tooltip({ position: "center right", opacity: 0.7}); $(this).tooltip().show(); } else { } }); }); }); what attempting setup fields expression attribute validate expression value against current value when input box, loses focus. ...

android - How to create a file in an SDCARD directory -

i want create file(not created) in directory(not created) in sdcard. how doing ? thank you. try following example: if (!environment.getexternalstoragestate().equals(environment.media_mounted)){ //handle case of no sdcard present } else { string dir = environment.getexternalstoragedirectory()+file.separator+"mydirectory"; //create folder file folder = new file(dir); //folder name folder.mkdirs(); //create file file file = new file(dir, "filename.extension"); } don't forget add permission androidmanifest: <uses-permission android:name="android.permission.write_external_storage" />

C# recursion stack allocation -

void factorial(int n) { if(n ==0) return 1; int value = n*factorial(n-1); printf("the value %d", value) } assume input function 4. so number of calls made 5. i wanted know each time function called, how stack allocation happens. thing below happens void factorial(4) { if(4 == 0) return 1; int value = 4*factorial(3) printf ("the value %d",value); } void factorial(3) { if(3 ==0) return 1; int value = 3* factorial (2); } my question each call, code generated above mentioned in stack } } no doesn't generate code, uses same code each call. read here more information: http://en.wikipedia.org/wiki/call_stack so there stack pointer points highest point in stack , each function pointer increased on number of bytes needed local variables , system information allocation. , decreases after function call finished.

actionscript 3 - FLEX: How to reference a MXML class from an AS3 external class file? -

i have mxml class place list , couple of buttons. i'd 2 things: to access list class external file. to add as3 class child (visual element) since need "stage" (global property). i woudnt't embed code mxml through <![cdata[]]> . so, example of mxml <?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="800" minheight="600" width="800" visible="true"> <fx:style source="main.css"/> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> <fx:script> <![cdata[ private var menucontroller:cmenucontroller= new ...

Android Calendar. -

i have problem adding entry calendar.i tried lot of tests without success. source code: string calname; string calid = null; string[] projection = new string[] { "_id", "name" }; uri calendars = uri.parse("content://com.android.calendar/calendars"); cursor managedcursor = managedquery(calendars, projection, "selected=1", null, null); contentvalues event = new contentvalues(); dateformat date = new simpledateformat("dd/mm/yyyy hh:mm"); long time = system.currenttimemillis(); string starttime = date.format(time); string endtime = "13/4/2011 15:30"; log.d(tag, "value of timestr: " + starttime); if (managedcursor.movetofirst()) { int namecolumn = managedcursor.getcolumnindex("name"); int idcolumn = managedcursor.getcolumnindex("_id"); do{ calnam...

c++ - Conversion of std::wstring to QString throws linker error -

hi need convert std::wstring qstring , tried obvious way of std::wstring widestring; qstring qtstring = qstring::fromstdwstring(widestring); i got error: error 2 error lnk2019: unresolved external symbol "__declspec(dllimport) public: static class qstring __cdecl qstring::fromstdwstring(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (__imp_?fromstdwstring@qstring@@sa?av1@abv?$basic_string@_wu?$char_traits@_w@std@@v?$allocator@_w@2@@std@@@z) referenced in function "public: void __thiscall filehandler::deletedir(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >&,int,unsigned int,bool,bool)" (?deletedir@filehandler@@qaexaav?$basic_string@_wu?$char_traits@_w@std@@v?$allocator@_w@2@@std@@hi_n1@z) filehandler.obj error 3 fatal error lnk1120: 1 unresolved externals c:\users\documents\visua...

twitter and facebook connect in rails -

excuse need tutorial twitter , facebook connect. the user can register in site or enter through twitter or facebook login access data how implement functionality if using rails 2.3.8 , restful authentication? i need model database (how save information , relationships) , implement in page. example: http://www.myntmarket.com/ i find tutorial restful authentication , facebooker facebooker deprecated. find facebooker2. explain me how can use plugin. thanks in advance , excuse me syntax in english. i not sure twitter facebooker. what database model? if connect facebook don't need models. store user credentials if not against facebook api tos , don't need models so.

Getting 'Address already in use' when I try to bind a socket to localhost in php -

i'm trying create socket connection php script local server (qt, qlocalserver) i'm having trouble creating connection on php side. <?php error_reporting(e_all); ini_set('display_errors', 'on'); set_time_limit(0); ob_implicit_flush(); echo 'usr='. get_current_user().'<br/>'; $address = 'localhost'; $port = 4444; //different port numbers produce same result if (($sock = socket_create(af_unix, sock_stream, 0)) === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; exit(); } if (socket_bind($sock, $address, $port) === false) { echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; exit(); } ... this results in usr=root warning: socket_bind(): unable bind address [98]: address in use in /var/www/nbr/socket.php on line 28 socket_bind() failed: reason: address in use i've...

how to use my version of zend framework included with project instead of installed version on server -

how make project use zend framework included in library folder instead of using installed version on server . because version on server lower 1 used in development!! there way force use library in library directory?? just put in before server's path in include_path . set_include_path(implode(path_separator, array( '/my/path/to/zf', get_include_path(), );

informix - ISQL 7.3 (SuSE): Ace report output to more than one file or stdout -

does know how trick ace outputing more 1 file or file , display simultaneously without having write external script?.. i.e. in ace spec output report pipe or output report "filename.out" > /dev/tty01a for piping multiple files, can use: output report pipe "tee file2 >file1" you can more 2 files if want to, courtesy of abilities of tee program. clearly, if want output go standard output file, pipe tee without ' > ' redirection. you can output pager if use: output report pipe "tee file1 file2 | less"

winapi - Win32 How to flush I/O buffers of another process? -

i have application executes process , performs activity if hosted process crashes. unfortunately, looks final log buffers not getting flushed. have been searching windows api docs, can't find function can used flush process' disk io buffers. want able call _flushall() hosted process. before resort stack tweaking @ crash-time, wanted check , see if has knowledge of api function need? or perhaps less invasive way accomplish same thing? i'd avoid calling fflush after each log write if possible.

python - where does a django file upload is stored? -

if create django form permits user upload file, file stored or configure from. using development server porvided django. please me this? all answers can found in the documentation . if file small enough, it's stored in memory . if not, it's saved under file_upload_temp_dir directory ( /tmp default on unix systems). you can customize upload process writing your own upload handlers (once again, it's in link above). i don't believe there real differences between dev server , prod environment on topic.

asp.net mvc - Jquery UI Autocomplete how to send multiple values to serverside? -

i using jquery ui autocomplete , wondering how send multiple values back. i tried $('#id').autocomplete ({ source: 'myurl', minlength: 2, extraparams: { id: 1 } }); this not seem work. option auto complete edit i have this $('#id').autocomplete({ source: function (request, response) { $.ajax({ url: 'url', data: { term: request.term, id: 1 }, success: function (data) { response(data); } }); }, minlength: 2 }); my controller return json("test",jsonrequestbehavior.allowget); i tried return content("t...

c# Web Browser simulate button press -

i'm using webbrowser control , want bypass button press on web page. i'm not familiar html , web pages, i'm wondering if has solution. the button i'm talking on web page: http://www.movshare.net/video/ut55cfdvg5wgj/ ? the button appearing @ random might not there always. edit: thinking this, can of c#. updated. get reference button , invoke it's click() javascript method: htmlelement btn = mybrowsercontrol.document.getelementbyid("mybutton"); /* alternatively, take @ these other methods retrieving htmlelement: htmldocument.getelementfrompoint(point point) htmldocument.getelementsbytagname(string tagname) htmldocument.all.getelementsbyname(string name) */ btn.invokemember("click"); this work in browsers if ... since webbrowser control, don't need worry cross browser issues.

c# - Disable Context Menu in WebBrowser .NET CF 3.5 -

i'm using webbrowser control in .net cf 3.5 windows ce device application, , security reasons need disable context menu. i've tried variety of things, none of seem work mobile devices .net cf 3.5: i've tried placing picturebox on webbrowser, , setting transparent. unfortunately, transparency doesn't work , ends being white box on browser. i've tried implementing new custom transparent control place on web browser, similar this . i've tried editing oncontextmenu element in html, no luck. i've tried overriding createparams make transparent picturebox on browser, noted 1 of solutions here . there seems many solutions online, none of them seem work windows ce .net cf 3.5. believe because webbrowser has simpler implementation full .net 3.5. question thus: there way disable context menu webbrowser control? i've not tried specific control, don't know if work, have tried subclassing browser control , intercepting , discarding messa...

c - What's the use of defining ARGS in a different header file? -

so i've been going through code, , there's things can't understand. have 2 header files. 1 called 'args.h' , in there these statements, amongst others: #if (defined(__cplusplus) || defined(__stdc__) || defined(c_plusplus)) #define new_style 1 #define void void #define args(parenthesized_list) parenthesized_list #else #define new_style 0 #define void #define args(parenthesized_list) () #define const #endif #if !defined(exit_success) #define exit_success 0 #define exit_failure 1 #endif in other header file, function prototypes declared this: #if defined(__cplusplus) extern "c" { #endif extern void yyerror args((const char *s_)); extern int yylex args((void)); extern int yyparse args((void)); extern int yywrap args((void)); #if defined(__cplusplus) } #endif and bunch of other stuff. so questions are: 1> #define const do? 2> why arg declared in other header file? couldn't declare functions normal exter...

android - Perform an action on spinner opening -

my problem following : @ moment have spinner called "projects" populating in code, reasons need add title using adapter : adapter.add("choose project"); now remove (via adapter.remove, not problem) when spinner in activity clicked (when it's opening), method able find onitemselected, not i'm looking for. is there such thing onopenlistener or onclicklistener spinner execute code when spinner opened, , not when item selected ?? thank this because trying call inside listener probably anonymous class. assuming activity's class name myactivity use myactivity.this.someactivitymethod someactivitymethod method want execute.

sql - Using a CASE result in a LEFT JOIN statement (MySQL) -

i'm trying left join table based on case result. basically, want check if i'm sender, , if i'm not want retrieve sender's name users database. if sender, want retrieve recipients name users table. here's current database query, correctly pulls information users.username sendername display senders name: select distinct case when $userid != senderid senderid else recipients end someid, users.username sendername, messages.body, messages.time messages left join users on users.id = messages.senderid messages.recipients = $userid or messages.senderid = $userid order messages.time i'd change equivalent of following: left join users on users.id = someid someid defined in above case. thanks! select distinct case when $userid != senderid senderid else recipients end someid, case when $userid != senderid senders.senderid else receivers.recipients end somename ...

authentication - Is there a Cloud Based User Credential Service out There? -

anyone know of service oriented membership provider / service? i’m looking hosted solution provides user registration , authentication services. don’t want deal managing user credentials applications. i’d rather leave service specializes in that. out there? well, can use openid: http://openid.net/

javascript - Use jQuery set .css RIGHT if #foo + offset left is greater than page width -

ok, trying use jquery innerwidth() of element #preview . want create conditional says if x offset left + #preview width greater page width, give style right: z z = #preview width + xoffset. i apologize code below mess , syntax .css ("right", (rightfloat + xoffset) + "px") (line 125) off, that's part of problem. <script> $(document).ready(function(){ //append "gallery" class items "popup" class imagepreview(); $(".popup").addclass("gallery"); }); //the overlay or pop-up effect this.imagepreview = function() { /* config */ xoffset = 40; yoffset = 40; // these 2 variable determine popup's distance cursor // might want adjust right result /* end config */ $("a.preview").click(function(e) { return false; }); $("a.preview").hover(function(e) { this.t = this.title; this.title = ""; var c = (...

rubygems - How do you use a Rails 3 gem method to update a database model? -

i using thumb_up gem ruby on rails. https://github.com/brady8/thumbs_up i want users able vote on posts. however, unable figure out how can allow user click button next each post , add vote database. i can happen in rails console through doing following: u=user.first m=micropost.first u.vote_for(m) however, how can happen when button clicked in view. assuming have use ajax, how know url need post to make action occur? any appreciated. update: thanks help! still having problem code below. here routes.rb resources :microposts post :vote, :on => :member end view: <%= link_to('vote post!', vote_micropost_path(@micropost), :method => :post) %> controller: def vote @micropost = micropost.find(params[:id]) current_user.vote_for @micropost # assumes you'll call via ajax. # if ajax call doesn't return "ok", know went wrong render :text => 'ok', :layout => false end however, i'm still getti...

controller - Multiple partial views on one main asp.net -

trying put typed partial view on homepage in asp.net wont seem work it, here code new asp.net , partial views. controller : public actionresult venuepartial() { viewdata["message"] = _entities.venuepartiallist(); return view(); } repository : public ienumerable<venue> venuepartiallist() { var list = s in _entities.venue orderby s.name ascending select s; return list.tolist(); } irepository : ienumerable<venue> venuepartiallist(); index page : <%html.renderpartial("~/views/venue/venuepartial.ascx");%> any grateful asap please regards t maybe need pass model partial: <% html.renderpartial("~/views/venue/venuepartial.ascx", viewdata["message"]); %> and way wtf using viewdata["message"] pass model instead of using model , typed view: public actionresult venuepartial() { retu...

javascript - How can alter text in a loop in a DIV -

i have text inside div tag. possible change text content 5 different text contents in cycle never ends? sounds simple, i'm trying find easiest approach jquery or related. many thanks, erik really simple approach: use setinterval() . var text = ['foo', 'bar', 'baz']; = 0, $div = $('#mydiv'); setinterval(function () { $div.text(text[i++ % text.length]); }, 1000); http://jsfiddle.net/mattball/tjv3k/ edit if want fancier effects: http://jsfiddle.net/mattball/tjv3k/1/ edit 2 re op comments (below) fix #1 : use distinct variable names each rotator, because variable scoping unaffected <script> tags. fix #2 : don't change variable names, use closures global scope isn't polluted. other fixes needed (shown in both fiddles): actually load jquery somewhere, otherwise none of code work. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script...

Could you suggest me a pattern to log exceptions during java application lifecycle? -

i want use simple java.util.logging.* package log exceptions. suggestions, links, articles in basic elegant way? should implement in java ee application. i thinking singleton class... think? the following doesn't handle case of logging exceptions automatically might closer. @ current company extended exception companyexception supported list of callbacks. like: public abstract class companyexception extends exception { private static final list<exceptioncallback> callbacks = new arraylist<exceptioncallback>(); public companyexception(string message) { super(message); invokecallbacks(); } // register class called whenever exception constructed public static void registercallback(exceptioncallback callback) { // expect registers done long before first exception thrown list<exceptioncallback> newcallbacks = new arraylist<exceptioncallback>(); newcallbacks.addall(call...

python - How to modify lxml autolink to be more liberal? -

i using autolink function of great lxml library documented here: http://lxml.de/api/lxml.html.clean-module.html my problem detects urls start http:// . use broader url detection regex one: http://daringfireball.net/2010/07/improved_regex_for_matching_urls i tried make regex work lxml autolink function without success. end a: lxml\html\clean.py", line 571, in _link_text host = match.group('host') indexerror: no such group any python/regex gurus out there know how make work? there 2 things in order adapt regexp lxml's autolink. first wrap entire url pattern match in group (?p<body> .. ) - lets lxml know goes inside href="" attribute. next, wrap host part in (?<host> .. ) group , pass avoid_hosts=[] parameter when call autolink function. reason regexp pattern you're using doesn't find host (sometimes host part none ) since matches partial urls , ambiguous url-like patterns. i've modified regexp include abo...

jquery - Change a buttons id on click -

i need change id attribute of div on click. <div class="xtra" id="id1"><a href="#"><span>next</span></a></div> how that? i've tried: $j("#id1").attr('id', 'id2'); but didn't work. try this: $j("#id1").live('click',function(){ $(this).attr('id', 'id2'); //use 1 this.id = 'id2'; //or 1 <-- both same thing }) i not sure why ever want this, how it. ids not meant change, meant unique specific element. classes used when changing css , forth.

java - Is this KMP implementation based on a DFA more efficient than a standard implementation? -

what complexity of deterministic finite state automaton based kmp algorithm? more efficient standard,non-automaton version of kmp algorithm? class kmp { private final int r; private int[][] dfa; private string pat; public kmp(string pat) { this.r = 256; this.pat = pat; int m = pat.length(); dfa = new int[r][m]; dfa[pat.charat(0)][0] = 1; (int x = 0, j = 1; j < m; j++) { (int c = 0; c < r; c++) dfa[c][j] = dfa[c][x]; dfa[pat.charat(j)][j] = j+1; x = dfa[pat.charat(j)][x]; } } public int search(string txt) { int m = pat.length(); int n = txt.length(); int i, j; (i = 0, j = 0; < n && j < m; i++) { j = dfa[txt.charat(i)][j]; } if (j == m) return - m; return -1; } } test: // test kmp dfa kmp p = new kmp("abacab"); system.out.println("kmpdfa: " + p.search("ababba...

binary - CFLAGS is not taken into account, why? -

i'm compiling apache 2.2.17 mac os x 10.5.8 intel 64bit computer , prefer 64bit compilation give necessary flags before ./configure so: cflags="-arch x86_64" but newly compiled binary isn't 64bit: file /usr/local/apache/bin/httpd /usr/local/apache/bin/httpd: mach-o executable i386 i'm confused. i've tried variations such as: cflags="-arch x86_64" cxxflags="-arch x86_64" ldflags="-arch x86_64" all or without "export" or "env" command @ start (e.g. export cflags="-arch x86_64") , result's unchanged. what wrong?

java - Does Flying Saucer accept HTML not XHTML -

my original source html not formed xhtml. @ worse have clean , convert html xhtml , feed flying saucer. flying saucer not support html; noted on website : "no support legacy html (although there several open source java html cleaners of varying quality available)." might try 1 of html cleaners suggest, though. 1 of best is, not surprisingly, htmlcleaner .

iPhone Bluetooth SDK - discover Android / Windows phone 7 devices and background discovery -

i android developer , .net developer , not yet have acquired needed knowledge regarding ios . did search on-line couldnt conclusive answers several questions have following : 1.ios bluetooth , have use bonjour or game kit or can access lower level api. 2.do have option perform pairing between iphone device , android device ? 3.can application access iphones mac id , friendly id bluetooth slots , change them while in background ? or while device sleeping ? 4.can application set if iphone discoverable or not discoverable other devices - not iphone ? can perform while in background ? regards ! jessy85 this might helpful you: how can iphone access non-iphone device on wireless or bluetooth? generally, there no option communicate non-ios device via bluetooth in regular ios api. gamekit intended using between ios devices. don't know lower level api open licensed accessory hardware developer except acquiring license incredibly hard differently software license....

Python script to generate words -

i'm looking write short script allow me generate possible letter combinations parameters set. for example: __ _ _ n o parameters: word = 5 letters 4th, 5th letter = n, o 1st letter = vowel (aeiouy) 2nd, 3rd letter = letter (abcde...) in other words, i'm looking write script return me 26*26*6 results. not matter if actual word (i.e., "zzzno" fine). , generalize can parameters. thank you. import itertools import string letter = string.lowercase vowel = "aeiouy" def all_words(*args): return (''.join(letters) letters in itertools.product(*args)) wordlist = list(all_words(vowel, letter, letter, "n", "o")) returns 4056 entries: ['aaano', 'aabno', 'aacno', 'aadno', 'aaeno', 'aafno' ... ]

java - Get heapsort to print in ascending order -

this program takes array of n length, , uses heapsort pull smallest k elements out. have gotten k number smallest elements out of array, have been trying several hours them print in ascending order. complete binary tree building correctly, based upon father > son. if me figure out need appreciate it. also, homework assignment , i'm not asking code fix it. legitimately stumped, , set on correct path working correctly. in advance input. edit - kind of have output in ascending order, basic test getting: 5,6,31,34,29, import java.lang.*; import java.util.*; public class heap { /* * definitions of parameters * 1) tree: array sweeping window implemented * 2) newele: new element insert * 3) pos: insert new element initially. * note not mean newele going * stay @ pos after function * 4) increment * a) true: insert newele, * b) false: insert newele , remove root */ static void insertheaptreeat(int[] tree, int newele, ...

Insert statement from php script to mysql: Database not reading insert statement -

so insert statement works perfectly. know database connecting because can select information database first 2 statements. know execute_statment3 works because no errors being printed off , when put sql statement inserted way should be. therefore problem lies somewhere communication between script , phpmyadmin. please have been staring @ problem 2 days , going rather crazy. <?php session_start(); $hostname = 'localhost'; $username = '####'; $password = '####'; $connection = mysql_connect($hostname, $username, $password) or die ('connection error!!!'); $database = '####'; mysql_select_db($database); $uid = $_session['id']; $album = $_post['albumname']; $description = $_post['description']; $filename = $_files["upload_file"]["name"]; $filetype = $_files["upload_file"]["type"]; $filesize = $_files["upload_file"]["size"]; $file_on_server = $...

How to force a syntax-highlighting refresh in emacs? -

in emacs, when ssh'ed remote machine, there's delay between when type closing quotation mark , when emacs updates syntax-highlighting reflect change. few seconds, of text after quotation highlighted if part of quotation. fine, i'd rather not wait. there way tell emacs "re-highlight right now"? yes. emacs command m-x font-lock-fontify-buffer if recall right. can bind key sequence if it's not bound in mode.

How can I get and set Cookies using JavaScript? -

this question has answer here: what “best” way , set single cookie value using javascript 3 answers i trying implement cookies on page; having trouble getting function properly. wanting store value of variables well. realize broad, know little nothing jscript cookies , working off w3schools examples. if has helpful insight push me along great. have far: var days=365; function setcookie(child,user,days) { var exdate=new date(); exdate.setdate(exdate.getdate() + days); var child=escape(user) + ((365==null) ? "" : "; expires="+exdate.toutcstring()); document.cookie=child + "=" + child; } function getcookie(child) { var i,x,y,arrcookies=document.cookie.split(";"); (i=0;i<arrcookies.length;i++) { x=arrcookies[i].substr(0,arrcookies[i].indexof("=")); y=arrcookies[i].substr(arrcookies[i].indexof("=")+...

graphics - Algorithm to find the coordinates of a corner in a simple image -

Image
i have bitmap 2 large blocks of colors intersect, , find intersection of these 2 blocks. note not know actual geometry of 2 shapes, because raw pixel data. is there algorithm use this? if have pixel data in memory (which i'd assume do, major sticking point) , there 2 distinct colours, should need run horizontal scanline find point rgb changes colour x colour y (note may need run scanline few times, in case it's no worse o(height)). simple graph traversal (bfs or dfs) continue walk down line (you should need 3 points , you'll able form geometric line equation a*x + b*y + c = 0 (assuming it's not curve)). repeat scanline vertically (again, worst case it's o(width)). find 3 points , you'll have 2 lines d*x + e*y + f = 0. using little bit of comp. geom, intersection of these 2 lines give point.

iphone - How to send Push Notification to multiple devices? -

this first time using push notification in app.i have gone through sample applications along books , got how send push notification single device.but not getting changes should in program send push notification multiple devices.i using 'pushmebaby' application server side coding. please,help me out. in advance. try example code , modify environment. $apnshost = '<apns host>'; $apnsport = <port num>; $apnscert = '<cert>'; $streamcontext = stream_context_create(); stream_context_set_option($streamcontext, 'ssl', 'local_cert', $apnscert); $apns = stream_socket_client('ssl://' . $apnshost . ':' . $apnsport, $error, $errorstring, 60, stream_client_connect, $streamcontext); $payload['aps'] = array('alert' => 'some notification', 'badge' => 0, 'sound' => 'none'); $payload = json_encode($payload); // note: $device_...

Java hashCode doubt -

i have program: import java.util.*; public class test { private string s; public test(string s) { this.s = s; } public static void main(string[] args) { hashset<object> hs = new hashset<object>(); test ws1 = new test("foo"); test ws2 = new test("foo"); string s1 = new string("foo"); string s2 = new string("foo"); hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2); // removing line gives same output. system.out.println(hs.size()); } } note not homework. asked question on our quiz earlier today. know answers trying understand why so. the above program gives 3 output. can please explain why is? i think (not sure): the java.lang.string class overrides hashcode method java.lang.object . string objects value "foo" treated duplicates. test class not override hashcode method , ends using java.lang.object version , ...

iphone - Objective-C , array initialization -

int num1, num2,num3,num4, i=0; nsmutablearray *chararray = [[nsmutablearray alloc] init]; while(num1 != 0 && num2 != 0) { num3 = num1 & 1; num4 = num2 & 1; if(num3 != num4) { if(num3 == 0) { chararray[i++]= '0'; chararray[i++]= '1'; } else { chararray[i++]='1'; chararray[i++]='0'; } } num1 = num1 > 1; num2 = num2 > 1; } } i kinda new objective-c, can tell me whats wrong this? you can't use regular array-like subscripts nsarrays (and nsmutablearrays). add item, need call addobject method.. i.e. [chararray addobject:obj] . the other caveat can't add bare char nsarray, needs objective-c type. can use nsnumber class wrap it. code be: [chararray addobject:[nsnumber numberwithchar:'0']]; [chararray addobject:[nsnumber numberwithchar:'1']]; but can still use regular c array , leave code unmodified, better solution in case. i.e. char c...

c++ - Using asynchronous method vs thread wait -

i have 2 versions of function available in c++ library same task. 1 synchronous function, , of asynchronous type allows callback function registered. which of below strategies preferable giving better memory , performance optimization? call synchronous function in worker thread, , use mutex synchronization wait until result do not create thread, call asynchronous version , result in callback i aware worker thread creation in option 1 cause more overhead. wanting know issues related overhead caused thread synchronization objects, , how compares overhead caused asynchronous call. asynchronous version of function internally spin off thread , use synchronization object, or uses other technique directly talk kernel? "profile, don't speculate." (djb) the answer question depends on many things, , there no general answer. role of developer able make these decisions. if don't know, try options , measure. in many cases, difference won't matter , non...

javascript - How to insert ellipsis into a large dataset in HTML with the least latency -

insert ellipsis (...) html tag if content wide mentions how insert ellipsis html content. solution works, find when applied large dataset (imagine 1,000 div's) tends pretty slow. my jsfiddle demonstrates issue. changing variable set (numberofdivs) 10 100 dramatically increases time takes output results. changing number 100 1000, causes chrome want kill page. it seems jquery's solution, , others have seen, involve either populating element in dom text (i believe jquery plugin used of sort, seems expensive large datasets) or using feature not supported ie7 , other older browsers (text-wrap:ellipsis). it seems calls element.offsetwidth or element.clientwidth expensive when dealing large sets of data. has found optimizations or robust server-side solutions? when robust server-side solution, mean 1 takes account text's size , size of containing div (or other element). doing substring of text 1 solution, not consider robust. nobody have found robust ...

jquery - Well designed Registration form -

i developing .net application.i need looking registraion form using jquery. please me. to build looking form need know: html, css, asp.net ( in case ), javascript (jquery), usability , accessibility. cannot learn in 1 question. if want jquery validation hard make work asp.net better use asp.ner build-in validation validate on client , server side per control

jQuery 1.5.X Cross domain -

i know if jquery 1.5.x has cross-domain. unable find sufficient documentation on site , own cross-domain tests did not work either. not talking jsonp regular call (xml, html, json). i not see how jquery can circumvent browser restrictions without use of adobe flash/proxy etc. if browser supports cors can directly use jquery's ajax methods send cross-domain ajax request. unfortunately ie uses different method not supported jquery (yet?).

c# - dependency inversion in top class (main) -

i want create app in have these 2 classes, mainapp , model (in reality more, base , core of problem). mainapp starting class. want apply dependency inversion mainapp doesn't have rebuild each time model changes (well, because practice). can't this: mainapp - - - > imodel ^ | | model because i'd have create model in mainapp anyway because it's start of app, redundant. i thinking shifting contents of mainapp class , use mainapp factory mainappcontents , model, this: mainapp -------------> model | | | | v v mainappcontents - - - > imodel is correct approach , mean start of designed app factory? it sounds asking way enable late binding . programming interface first step, , doing that. the next step map interface concrete class . easiest way di container . main method might this: static void main() {...