Posts

Showing posts from April, 2011

.net - TLS handshake with a smartcard fails randomly -

i have windows service periodically connects host using .net socket class. it's standard tcp/ip connection using smtp protocol. the connection secured certificate stored on smartcard. i'm using sslstream class handle ssl stuff. this works of time. @ random point of time, authentication fails. error: a call sspi failed, see inner exception. error type: system.security.authentication.authenticationexception server stack trace: @ system.net.security.sslstate.endprocessauthentication(iasyncresult result) @ system.threading.tasks.taskfactory`1.fromasynccorelogic(iasyncresult iar, func`2 endfunction, action`1 endaction, task`1 promise, boolean requiressynchronization) inner exception: system.componentmodel.win32exception local security authority cannot contacted after failed attempt, authenticationexcpetion remains, inner exception changes: a signature operation must performed before user can authenticate at point have restart service , connect flawlessly. ssl ha

ajax - validateLogin is an undefined function.(javascript exception ) -

hi getting error undefined function think code alright can in case? please , suggest me tutorial getting data through webservice via ajax method. <script type="text/javascript" language="javascript" src="scripts/jquery-1.4.1.js"> function validatelogin() { $('input[type=button]').attr('disabled', true); $("#login").html(''); var loginid = $('#txt_id').attr('value'); // username var password = $('#txt_pwd').attr('value'); // password $.ajax({ type: "post", url: "webservice.asmx/validatelogin", data: "lognid=" + loginid + "&password=" + password, contenttype: "application/json; charset=utf-8", success: function (result) { returnval = result.d; alert(returnval); },

c - Determining index from bsearch and lfind? -

i'm trying index of element in array after lfind , bsearch return pointer element found. have far: (char *) (found - cv->baseaddress); where found address of functions found, , base address address of element 0. however, compiler gives me error: cvector.c:150:28: warning: pointer of type ‘void *’ used in subtraction cvector.c:150:4: warning: return makes integer pointer without cast what do? you have typecast returned pointer correct type. need divide offset size of objects in array index.

javascript - Text Masking not working with HTML canvas -

i trying text masking in javascript. below code :- if(this.image!==null) { canvascontext.drawimage(this.image, 0, 0, this.width, this.height); } canvascontext.font = "55px arial"; canvascontext.textalign = "center"; canvascontext.textbaseline = "middle"; canvascontext.globalcompositeoperation = 'destination-out'; canvascontext.filltext("censored", 250, 250); but not working. please me resolve issues. i’m not sure “not working” means, but… there 2 common kinds of text masking in canvas destination-out: text act cookie-cutter , remove drawn underneath text, text not show on transparent pixels. xor: text cut out non-transparent drawings on canvas, text otherwise drawn normally. here code , fiddle: http://jsfiddle.net/m1erickson/n836n/ <style> body{ background-color: purple; } canvas{background-color: white; border:1px solid red;} </style> <script> $(f

asp.net - Require field validator disappear because of auto post of drop down -

here issue require filed validator , here use 1 drop down box select time associated require field validator in drop down there 1-24 hour time , select time first index. in page in drop down time selection necessary if user select time again goes initial value of first index or select time option time require field validator work , disappear because of partial post or auto post of drop down.i have use update panel. want whenever user not select time or choos select time option time require field validator prompt user select time. until user not select time cant process further. <div class="loginbox"> <asp:label id="lbldatetime" text="date & time:" cssclass="jobtitle" associatedcontrolid="txtdate" runat="server"></asp:label> <asp:dropdownlist id="ddltime" runat="server" autopostba

Modulo operation in C#, C and OCaml -

i wanted confirm modulo operation expensive operation tested piece of code checks if given number even: bool is_even(int n) { return (n & 1) == 0; } then one: bool is_even_bis(int n) { return (n % 2) == 0; } i used c# @ first , indeed, code using logical & faster other one, 3 times faster. using ilspy saw there no optimization done when compiled msil, code strictly same. however spotted friend of mine in c, using gcc -o3 code compiled to: is_even: mov eax, dword ptr [esp+4] # tmp63, n , eax, 1 # tmp63, xor eax, 1 # tmp63, ret and: is_even_bis: mov eax, dword ptr [esp+4] # tmp63, n , eax, 1 # tmp63, xor eax, 1 # tmp63, ret so strictly same thing. when using -o0 optimization operation doesn't appear: is_even: push ebp # mov ebp, esp #, mov eax, dword ptr [ebp+8] # tmp63, n , eax, 1 # d.1837, test eax, eax # d.1837 sete

ember.js - Ember Starter Kit with Ember Data -

ember 1.0.0 rc3 ships starter kit quite simplistic demo display 3 colors in list. the model data inserted directly on indexroute this: app.indexroute = ember.route.extend({ model: function() { return ['red', 'yellow', 'blue']; } }); i tried change simple demo use ember-data (models, store, ...). however, no success. console output of demo is: debug: ------------------------------- ember-1.0.0-rc.3.js:349 debug: ember.version : 1.0.0-rc.3 ember-1.0.0-rc.3.js:349 debug: handlebars.version : 1.0.0-rc.3 ember-1.0.0-rc.3.js:349 debug: jquery.version : 1.9.1 ember-1.0.0-rc.3.js:349 debug: ------------------------------- ember-1.0.0-rc.3.js:349 uncaught typeerror: cannot call method 'find' of undefined appdemo.js:8 uncaught error: assertion failed: ember.collectionview's content must implement ember.array. passed <(generated index controller):ember232> ember-1.0.0-rc.3.js:52 my modified script looks this: app = ember.applicatio

android - read and save images into SQLite database -

hey guys working on android retrieve , save images sqlite database . here code ==>> public class mainactivity extends activity implements onclicklistener { protected static textview textview; protected static imageview image1, image2; protected button get_image, save_image, read_image; private string selectedimagepath; private static final int select_picture = 1; string db_name = environment.getexternalstoragedirectory() + "/test.db"; string table_name = "mytable"; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); image1 = (imageview) findviewbyid(r.id.imageview1); image2 = (imageview) findviewbyid(r.id.imageview2); textview = (textview) findviewbyid(r.id.textview1); get_image = (button) findviewbyid(r.id.get_image);

c# - json parsing with xamarin android -

i wrote code parse json string in android xamarin app. var request = httpwebrequest.create(myurl); request.contenttype = "application/json"; request.method = "get"; using (httpwebresponse response = request.getresponse() httpwebresponse) { if (response.statuscode != httpstatuscode.ok) { console.out.writeline("error fetching data. server returned status code: {0}", response.statuscode); } using (streamreader reader = new streamreader(response.getresponsestream())) { string content = reader.readtoend(); if (string.isnullorwhitespace(content)) { console.out.writeline("response contained empty body..."); } else {

c++ - Valgrind results of a "segmentation fault" program -

my program (./a.out) encountered segmentation fault, use valgrind check if can find @ line of code program corrupts. , got following output, cannot understand then. me, suspicious line of output ==17967== address 0x20687cf80 0 bytes inside block of size 16 alloc'd , line means address 0x20687cf80 not propoerly allocated memory block? can resolve problem. i using 64-bit linux 64gb ram. [root@gpu bloomfilterandhashtable]# valgrind --tool=memcheck --leak-check=full ./a.out /mnt/disk2/experiments/two_stage_bloom_filter/test/10_10.txt /mnt/disk2/experiments/10m_worstcase_trace/w_10_10.trace 24 ==17967== memcheck, memory error detector ==17967== copyright (c) 2002-2010, , gnu gpl'd, julian seward et al. ==17967== using valgrind-3.6.1 , libvex; rerun -h copyright info ==17967== command: ./a.out /mnt/disk2/experiments/two_stage_bloom_filter/test/10_10.txt /mnt/disk2/experiments/10m_worstcase_trace/w_10_10.trace 24 ==17967== 9998797 prefixes loaded! //output of program ==17967

ruby on rails - passing parameter in jquery auto complete -

i'm trying implement auto complete in rails application. i'm trying pass ruby parameter via source of jquery. here i'm trying do. $( "#text" ).autocomplete({ appendto: "#searchwrapper1", source: h_url+"product_details/menu_search_auto/" + <%= "'#{params[:deptid]}'" %> , open:function() { $(".ui-autocomplete").mcustomscrollbar1({ set_width : false, set_height : false, horizontalscroll : false, scrollinertia : 550, scrolleasing : "easeoutcirc", mousewheel : "auto", autodraggerlength : true, scrollbuttons : { enable : false, scrolltype : "continuous", scrollspeed : 20, scrollamount : 40 }, } here route.rb file match "/product_details/menu_search_auto/:deptid"=>'

android how to recreate fragment view -

i have android fragment when i'm creating view fill fields layout values model. , @ 1 point want recreate view using same class model other values. public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater .inflate(r.layout.item_view, container, false); edittext = (edittext) v.findviewbyid(r.id.question_text); questiontext.settext(mymodel.getname()); --------------- } i have private function wich call @ on click on view private void recreateview(mymodel model){ mymodel = model; //here want recall oncreateview or somthing don't know if ok, or more simple way }

c# - WPF DataGrid | Hiding Row Validation Column -

i have wpf datagrid has 4 columns, of datagrid template columns. when grid renders there column added automatically on left, understand used displaying row validation errors , it's bound template rowvalidationerrortemplate. my question is, dont want column displayed, , want hidden. how can set on datagrid? please note i'm using .net 3.5. my grid style below: <style x:key="gridstyle" targettype="{x:type controls:datagrid}"> <setter property="verticalgridlinesbrush" value="#7ba0cd"/> <setter property="horizontalgridlinesbrush" value="#7ba0cd"/> <setter property="alternatingrowbackground" value="#d3dfee"/> <setter property="canuserresizerows" value="false"/> <setter property="canuserreordercolumns" value="false"/> <se

python - Globals as function input instead arguments -

i'm learning how python works , after reading while i'm still confused globals , proper function arguments. consider case globals not modified inside functions, referenced. can globals used instead function arguments? i've heard using globals considered bad practice. in case? calling function without arguments: def myfunc() : print myvalue myvalue = 1 myfunc() calling function arguments def myfunc(arg) : print arg myvalue = 1 myfunc(myvalue) i've heard using globals considered bad practice. in case? it depends on you're trying achieve. if myfunc() supposed print value, then... def myfunc(arg): print arg myfunc(1) ...is better, if myfunc() should print same value, then... myvalue = 1 def myfunc(): print myvalue myfunc() ...is better, although example simple, may factor out global, , use... def myfunc(): print 1 myfunc()

unit testing - Why is the xUnit Runner not finding my tests -

i have xunit.net test follows: static class mytestclass { [fact] static void mytestmethod() { } } the xunit plugin vs 2012 says: no tests found run. testdriven.net runs fine but mentions ad hoc : 1 passed, 0 failed, 0 skipped (see 'task list'), took 0.47 seconds (ad hoc) teamcity, xunit.gui.exe , xunit.console.exe , visual studio can't find testmethod (i've got xunit.runner.visualstudio installed , vs seeing tests.) what gives? tl;dr test classes must public (but test methods can private and/or static ) for reasons of efficiency, xunit authors have opted not use bindingflags.nonpublic when searching test classes in runner (the msil metadata tables don't index private (/ internal ) classes same degree hence there significant performance difference in relative efficiency reflection can achieve). as result of above, fact class private means doesn't picked up. the fact test method private , stat

javascript - JQuery, how to append div after selected text in html? -

hi possible add div after selected text? jquery or java-script , rangy js i'm try below code not working.. function pin_surroundrange() { var range = getfirstrange(); //get selected text via rangy js if(range != null) { $( '#content_area ('+range+')' ).replacewith( ''+range+'<div><input type="text" /></div>' );} } the steps i'd use are: get selected range collapse range end call range's insertnode() method code: var div = document.createelement("div"); div.appendchild( document.createelement("input") ); var sel = rangy.getselection(); if (sel.rangecount > 0) { var range = sel.getrangeat(0); range.collapse(false); range.insertnode(div); }

ios - Programmatically check iMessage support of contact -

i developing app loads contacts in uitableview on iphone. works fine, issue want know whether recipient's mobile number or email address supporting imessage or not using objective-c. please tell me if not clear. this not available through public sdk. if have jailbroken device can use chatkit framework.

Form_for in Rails 3 is considering only the first submit button wth Form.serialize(this) in AJAX request -

i'm working on rails 3 app. 1 of view had 1 submit button , i'm supposed add 1 more. have done necessary changes in view file (.html.erb) , in controller.rb. considers first button (whichever is) when either clicked. why taking first button consideration?? , how can make both work?? edited: checked railscast video http://railscasts.com/episodes/38-multibutton-form?autoplay=true it talks multibutton forms n mentions changes done if form has ajax request , form serialization . code has them!! here's code added submit button calls earlier button's function itself can plsss me make necessary changes serialization both buttons considered!! you can add name submit button in view, this: = submit_tag 'done', :class => 'btn', :name => "done" = submit_tag 'save', :class => 'btn', :name => "save" and controller: if params[:done] # done elsif params[:save] # save end if click &qu

java - Display data on a Jtable after excuting a search -

basically code searching first name or surname in table. once search has been done, example 'peter' , occur data placed text boxes. the issue want data displayed onto table, have tried many times not seem work, have tried using line of code. 'table_stats' name of table. table_stats.setmodel(dbutils.resultsettotablemodel(result)); i pretty new this, can 1 please help, appreciated thank you! private void searchkeyreleased(java.awt.event.keyevent evt) { // todo add handling code here: try{ string sql = "select * statistics first_name =? " ; string sql2 = "select * statistics surname =? " ; prepared=conn.preparestatement(sql); prepared=conn.preparestatement(sql2); prepared.setstring (1, search.gettext()); result = prepared.executequery(); if(result.next()){ string add1 = result.getstring("player_id"); player_id.settext(add1);

url marker in google map api using ASP.NET MVC4 -

i have map in page , when marker clicked goes action ballon in rptvendedorcontroller this, public actionresult balloon( int id,string tipopin , bool clientecompleto) for url of marker create url.action("balloon", "rptvendedor", new { id = cliente.clienteid, tipopin = "clientes", clientecompleto = true }) } that give in server side url:/rptvendedor/balloon/4?tipopin=clientes&clientecompleto=true my problem reason url change , when click marker url (is below) add (amp;) not hit action because not have format clientecompleto in query string request url:http://localhost:10657/rptvendedor/balloon/4?tipopin=clientes&amp;clientecompleto=true and dont know reason why add (amp;)? edit i put viewmodel globo = new mostrarmapaglobo { ancho = 400, alto = 200, url = url.action("balloon", "rptvendedor", new { id = cliente.clienteid, tipopin = "clientegeografico" }) } and in partial view @foreach (va

sql - trying to count and join on two mysql tables -

i've got mysql db 2 tables: db.names name | level ------------ bob 4 john 3 andy 2 dave 1 db.data entry | user ------------ dfds bob hdes bob sers john iuid dave yyuy john i'm trying count count how many entrys each user has made , show level. lit looks this: count(*) | user | level ----------------------- 2 bob 4 2 john 3 1 dave 1 i've tried use left join , distinct join, can seem grips logic. greatlly appreciated you need joins tables using inner join since want show record both exist on 2 tables. , count number of instances, need use aggregate function count() , group by clause. select count(*) totalcount, a.name, a.level names inner join data b on a.name = b.user group a.name, a.level sqlfiddle demo to further gain more knowledge joins, kindly visit link below: visual representation of sql joins output ╔════════════╦══════╦═══

How to change the font in windows phone 8? -

Image
i use " lucida handwriting " 1 textblock control @ design time. but run on emulator take font like at design time at run on emulator how possible. how can solve difference. please me. thanks in advance. are including font file in app package? 1) add font file wish use project, , set build action embedded resource. ensure copying file assembly in "copy output directory" property. 2) select textblock, , pull down font selection dropdown in properties. you should see font there, , compiled assembly , available use in app.

asp.net - The FreeTextBox control on network solutions -

i'm using freetextbox control on 2 different network solutions hosted website. control working fine on year on both sites. on april 11,2013 had problem , control stopped working on 1 of sites. error i'm getting when freetextbox tries draw freetextbox has not been correctly installed. install freetextbox either: (1) add reference ftbwebresource.axd in web.config: <system.web> <httphandlers> <add verb="get" path="ftbwebresource.axd" type="freetextboxcontrols.assemblyresourcehandler, freetextbox" /> </httphandlers> </system.web> (2) save freetextbox image , javascript files location on website , set freetextbox follows <ftb:freetextbox id="freetextbox1" supportfolder="ftbfileslocation" javascriptlocation="externalfile" buttonimageslocation="externalfile" toolbarimageslocation="externalfile" buttonimageslocation="externalfile" runat="ser

C# read only Serial port when data comes -

i want read serial port when data comes(i want not polling). this how it. schnittstelle = new serialport("com3"); schnittstelle.baudrate = 115200; schnittstelle.databits = 8; schnittstelle.stopbits = stopbits.two; .... and start thread beginn = new thread(readcom); beginn.start(); and in readcom i'm reading continuous (polling :( ) private void readcom() { try { while (schnittstelle.isopen) { dispatcher.begininvoke(new action(() => { comwindow.txtbcom.text = comwindow.txtbcom.text + environment.newline + schnittstelle.readexisting(); comwindow.txtbcom.scrolltoend(); })); beginn.join(10); } } catch (threadabortexception) { } catch (exception ex)

c# - mvc 4 site back button not working in IE9 -

there has been a similar question asked 2 years ago, never solved, , i'm running seems same exact issue mvc 4 in ie9. have test site set plainly possible. when run it, seems work fine. css loaded, scripts imported, etc. when click button, virtually goes away. now, virtually important note because static layout (with exception of @{ html.renderpartial("_mynavpartial") } , @renderbody() call) returns nothing @ while page has table populated data service call still returns data, css formatting applied no less. navigation partial gone, , of css settings table's alignment on page. when refresh page, comes back. according fiddler, when button hit, nothing @ comes , viewing source shows nothing basic markup no content @ all. page table shows table , css ids although id applied <body> disappears. i've tried disabling caching, changing @url.actionlink() calls @url.action() , static urls see if dynamic content in way, , still have exact same problem. a

java - Reinstalling glassfish into the directory of previous installation? -

i new glassfish , have minor problem don't know how fix. unistalled glassfish 2.1.1 directory , can't install same directory path. unistalled using unistall.exe, deleted files left behind , when try install again, message: existing installation has been detected in directory. please select directory or uninstall existing installation before proceeding. if choose continue without uninstalling previous installation, installation might fail. i checked product registry , couldn't find trace of glassfish. knows might problem , how fix it? thank you! check system variables, these servers make changes on system variables, path , on

sql - Using a current row value into a subquery -

i trying count how many times order_id appears in subquery , present right next average value of each customer orders. here have tried. select person ,avg(ordertotal) avgordersvalue , timesseen ( select customer_id person ,order_id , sum(total)as ordertotal ,(select count(order_id) timesseen orders customer_id=person group order_id ) orders group customer_id order_id order person ) tablealias group person and here message get: " msg 207, level 16, state 1, line 4 invalid column name 'person'. msg 8155, level 16, state 2, line 10 no column name specified column 4 of 'gg'. msg 207, level 16, state 1, line 1 invalid column name 'timesseen'. " based on description, may query want: select person, avg(ordertotal), count(distinct orderid) (select customer_id person, order_id, sum(total) ordertotal orders group customer_id, order_id ) o group person i "may" because expect orderid unique key

Programmatically change the sleep/suspend timeout on Windows and Linux -

i looking way programmatically change sleep/suspend timeout on windows (xp) , linux (debian & ubuntu) operating systems without having reboot system. have spent decent amount if time searching solutions have not found conclusive. point me in right direction?

sql - Android sqlite idimage can not be null -

i have problems when want add in db. error 19 idimage can not null, not understand why error, defined idimage auto increment. thanks import android.content.context; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; import android.database.sqlite.sqlitedatabase.cursorfactory; public class basesqllite extends sqliteopenhelper{ private static final string create_bdd = "create table if not exists `t_image` (`idimage` integer primary key autoincremet,`name` varchar(20) not null ,`description` varchar(45) not null ,`rank` tinyint not null ,`date` varchar(45) not null ,primary key (`idimage`) )"; public basesqllite(context context, string name, cursorfactory factory, int version) { super(context, name, factory, version); } @override public void oncreate(sqlitedatabase db) { db.execsql(create_bdd); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { db.execsql("drop ta

java - Else can't find the If statement even though there is one -

Image
when try compile code error saying else without if. believe have of braces in right place. other errors in picture have attached believe there because of can't use else without if error. problem code: public static boolean gonorth(){ boolean success; if(maze[currcol]currrow - 1] == clear){ maze[currcol][startrow -1] = path; currrow--; success = gonorth(); if(!success){ success = gowest(); if(!success){ success = goeast(); if(!success){ maze[currcol][currrow] = visited; currrow++; } } } return success; } else { return false; } } public static boolean gowest(){ boolean success; if(maze[currcol - 1]currrow] ==

java - what is the best way to pass messages from server to html (GUI) -

i using java , jsp develop web application. there many situations in user input cause exception on server side, in situation user expects error message shown. there several ways (as programmer) can handle transfer of error message server gui(html) , maybe redirect other pages , show message there. 1 way go using session attribute, other can ajax method calls , showing response text. there may other ways don't know. tell me straight forward , standard way (if there standard this)? the problem made me think when trying show response of ajax call in colorbox, , failed, appreciated if give me hint on too, how can pass response text of ajax method in other web page. a way pass messages server html write them in html. html generated server. there other possibilities well, such using query params, cookies, ajax calls etc, if have no special requirements should write message in output html. within server implementation use request attributes, example. that's co

mediaelement.js video by flash fallback do not autostart -

i use mediaelement.js play video fallback option flash. works fine new browsers. video autostart display page, example in ie9 ie10. my problem: in ie7 , ie8 used fallback option play video in flash. video starts press playbutton, there no autoplay. <video id="player2" width="480" height="270" poster="bilder/nnn.jpg" controls="controls" preload="true" autoplay="true"> <source type="video/mp4" src="media/nnn_h264.mp4" /> <source type="video/webm" src="media/nnn_h264.webm" /> <source type="video/ogg" src="media/nnn_h264.ogv" /> <object width="480" height="270" type="application/x-shockwave-flash" data="videoplayer/flashmediaelement.swf"> <param name="movie" value="videoplayer/flashmediaelement.swf" /> <param name="flashvars" value="a

c# - Adding CSS Class to client side hyperlink on code behind -

i have list of links : <ul> <li><a href="#">aktuel</a></li> <li><a href="#">business</a></li> <li><a href="#">common</a></li> <li><a href="#">extras</a></li> </ul> i have add css class 1 of links. have in codebehind c#. result should : .... <li><a href="#" class="active">business</a></li> .... on life cycle event should , how? note : cant change html design. thanx in advance. you can register clientscript.registerstartupscript on codebehind, run jquery script , job. complete solution, including asp.net bit: string jsscript = "$(function () { $(\"a:contains('aktuel')\").addclass(\"active\"); });"; clientscript.registerstartupscript(typeof(page), "anythingyoufancy", jsscript, true); you can check working

Java Swing set color of rows and columns based on index with defaulttablemodel -

i want able 2 things: set colors of rows based on index, first row red, second blue, third green be able set color of columns based on something, index or names etc, whatever possible. i not need detect selection change or anything. tell me how that? methods etc? in case title wasn't read, regarding defaulttablemodel in jtables . set colors of rows based on index, table row rendering might give ideas. be able set color of columns based on something you can provide custom render column. can add logic color column based on something. read jtable api , follow link swing tutorial on how use table , find section on creating custom renderer.

android - How to get a reference to the last backstack popped fragment? -

i add, show , hide fragments. each time add/show fragment, hide previous fragment , add transaction backstack. when user presses button, fragment popped , i have reference it . why need reference? hide when user continues next fragment. so, how reference popped fragment? edit-25-04-2013: here's code explain how add new fragment, while hiding previous one. the question how reference last fragment after popped backstack (using button)? fragmenttransaction fragmenttransaction = getfragmentmanager().begintransaction(); fragmenttransaction.hide(lastfragment); fragmenttransaction.add(newfragment); fragmenttransaction.addtobackstack(null); fragmenttransaction.commit(); lastfragment = newfragment; i use generated tags each fragment, save tags in stack , persist stack. way hold of every fragment out there - last 1 in specific. see code here .

c# - Is there any case in which the Form's Activated event is not raised? -

i don't understand why that, thought activated should raised when form shown. in fact form has toplevel set false , it's added form. when main form shows, it's visible, , can interact controls tested , saw activated not raised. public mainform(){ initializecomponent(); form child = new form(); child.activated += (s,e) => { messagebox.show("activated!"); }; child.size = new size(200,100); child.toplevel = false; child.show(); child.parent = this; } after running mainform child form appeared inside main 1 , there isn't messagebox displayed message "activated!". what additional job make raise? if second form comes screen first time, can use shown event. activate event fired when form gets focus, not contain showing first time. but, if previous form active outside of app, not raise activate event. mean valid when viewing forms of same project.

char - Cannot delete text in UITextField -

i have implemented max character limit on uitextfield. problem when input max number characters, unable backspace characters. can tell me doing wrong? below code: -(bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { if (textfield == pincode) { if ([textfield.text length]<=3) { return yes; } else { return no; } } else { return yes; } return yes; } change condition to: if ([textfield.text length]<=3 || string.length == 0) { ... if content of string control character f.e. backspace, length zero

java - AlarmManager and Service not working on my app -

i want simple timer executes set of commands , needs accurate. must continue if app minimised (hidden) or phone on sleep (cpu sleep). have looked @ posts on these sites: site 1 site 2 i tried understand code , add own new project, app closes on start. have. mainactivity oncreate() intent myalarm = new intent(getapplicationcontext(), alarmreceiver.class); pendingintent recurringalarm = pendingintent.getbroadcast(getapplicationcontext(), 0, myalarm, pendingintent.flag_cancel_current); alarmmanager alarms = (alarmmanager) this.getsystemservice(context.alarm_service); calendar updatetime = calendar.getinstance(); updatetime.settimeinmillis(5000); // first reoccurance int custominterval = 5000; // 5 seconds intervals alarms.setinexactrepeating(alarmmanager.rtc_wakeup, updatetime.gettimeinmillis(), custominterval, recurringalarm); alarmreceiver.class/alarmreceiver.java import android.content.broadcastreceiver; import

Android - How to bring back my last existing activity after call initiated? -

i giving facility call application , listening call end. want user application , same activity same state. i have tried intent.flag_activity_clear_top , flags nothing works. presently checking in nexus 4.1.2 phone. can me achieve this? thanks, saravanakumar

Is it secure when a HTTPS web application transmit data through a wireless devices such as iPAD? -

a https web application encrypts data transport between browser , web server. when https app used on browser in wireless mobile device such ipad, data transmission still encrypted or not? wireless transmission encryption thing if compared https, correct? stock like said data encrypted between browser , web server. encryption hold until web browser receives traffic. after relying on security of web browser , device web browser on (an ipad in case) protect data. and yes wireless transmission encryption layer on top (or below depending on how @ it) of https. these 2 encryption schemes applied @ different protocol layers. wireless transmission encryption applied between access point (ap) , device still need https protect between server , ap.

winforms - VB.NET: In ProcessCmdKey simplest way to determine if a key prints or not? -

what's simplest way identify whether keystroke printable character (one should appear in textbox) or not? want separate keys f1, home, etc. appear in textbox. trying avoid massive if statement identifying non-printable characters myself. using event keyup, keypress etc. not option due design of control. there no simple way. , should never put in spot. translation of virtual keys, observed in processcmdkey or keydown, typing keys, observed keypress event, highly convoluted. depends on keyboard layout user has selected. keyboard layouts vary great deal machine machine across world. chinese keyboard doesn't english keyboard, surely can imagine this. furthermore, languages lot of characters, chinese , japanese, use dedicated program allow user select 1 of tens of thousands of glyphs. ime (input method editor). notably problematic "dead keys", special keys on keyboards used enter letters diacritics. not common in english, common in other parts o

locking database table while deleting records - understanding "Read Committed" transaction isolation in postgresql -

i have web app provide feature delete widget belong user. logic have right delete looks this: local delete_widget = function(widgetid, user) local retval = "" sql = "delete widgets widgetid="..widgetid cur, err = assert(con:execute(sql)) if not err sql = "select * widgets widgetid = ".. widgetid listofwidgets = executesqlandreturntable(sql) if #listofwidgets == 0 retval = "deleted widget" else retval = "unable delete widget" end else retval = "unable delete widget" end return retval end what i'm wondering if should change transaction. right now, if deletion attempt fails whatever reason, i'm not doing anything. select see if still exists , if does, throw error. i'm wondering if should full begin transaction/commit /

xcode - How to decide dynamically which screen to transition to (iOS Game) -

i'm little bit confused how best perform screen transitions in game. need perform following transitions [main menu] -> [character select] -> [stage select] up until using interface builder "click 'n drag" control in [main menu] [character select] , choosing modal segue type. realized that, on second run of game, player doesn't need go [character select] screen again. i'd have following flow [main menu] -> [stage select] so question(s) are: 1) modal transition recommended way of doing this? examples saw using modal transitions popup or similar. don't want use navigation bars because think not design options game. 2) saw somewhere should not use segues here, instead i'd use "presentviewcontroller:animated:completion:" led me set of questions. 3) in order understand presentviewcontroller... ended in apple doc http://developer.apple.com/library/ios/#featuredarticles/viewcontrollerpgforiphoneos/modalviewcontrollers/modalview

C# linq groupby returns incorrect groups -

i trying understand how linq works. wrote test app , not working way expect to. following code, expecting see items "test1" , "test4" grouped together, not getting that. instead getting 4 separate groups. meaning 1 of items getting grouped together. can explain doing wrong? thanks. public class linqtest { public int x1; public int x2; public string x3; public linqtest(int a, int b, string c) { x1 = a; x2 = b; x3 = c; } public bool equals(linqtest other) { if (referenceequals(null, other)) return false; if (referenceequals(this, other)) return true; return x1 == other.x1 && x2 == other.x2; } public override bool equals(object obj) { if (referenceequals(null, obj)) return false; if (referenceequals(this, obj)) return true; if (obj.gettype() != typeof(linqtest)) return false; return equals((linqtest)obj); } }

sql server - Optimize For in CTE or Subquery -

setup: i'm experimenting optimize for clause in sql server 2008 r2. i've put following @ end of query. option (optimize (@usertype= 'm', @date unknown)) issue: however, i'm getting below error. the variable "@usertype" specified in optimize clause, not used in query. this variable used in subquery within query, , used in location. if try moving optimize for subquery, stored proc not compile. likewise, cannot put subquery in cte , optimize within that; doesn't compile either. incorrect syntax near keyword 'option'. question: is there way can use optimize for clause within cte or subquery? i'd prefer use cte since cleaner , more legible. the option keyword must placed @ end of outer select query. for example: declare @var int = 1; cte ( select @var val ) select * cte option (optimize (@var = 2))

How to change a BoundField's control in asp.net -

can change boundfield's control? <asp:boundfield datafield="week1" headertext="week1" sortexpression="begindate" /> you can't change control that's created when use boundfield - that's chosen automatically based on data type of field you're binding (a checkbox gets created boolean fields, label text-type fields). you need use templatefield if want bind data different type of control: <asp:templatefield headertext="week1"> <itemtemplate> <asp:label id="weekonelbl" text= '<%# eval("week1") %>' runat="server"/> </itemtemplate> </asp:templatefield> by default, boundfield use label control (like above). templatefield, change to, say, read-only textbox: <asp:templatefield headertext="week1"> <itemtemplate> <asp:textbox id="weekonelbl" text= '<%# eval("wee

c# - Serializing object to XML -

i have class in c# setup serializes xml, , class has list of objects serializes well. [xmlroot("config")] public class configserializer { [xmlarray("nodes")] public list<node> lstnodes { get; set; } } and here class declaration node. [xmlroot("n")] public class node { // has few different properties } problem: when serialize instance of configserializer xml doesn't serialize xml expect regards node list. looks this... <config> <nodes> <node></node> </nodes> </config> but expect (because of xmlroot declaration node class)... <config> <nodes> <n></n> </nodes> </config> you can use this [xmlroot("config")] public class configserializer { [xmlarray("nodes"),xmlarrayitem("n")] public list<node> lstnodes { get; set; } }

content management system - django-cms 404 errors when not logged in -

i'm running django-cms 2.4.1 , i'm getting 404 not found errors when attempting access page (other root) when not logged in. once log in admin console, pages accessible expected. there no page permissions set , i've double-checked "login required" not set anywhere. ideas on might cause this?

reporting services - Calendar returning duplicate lines per employee -

i have created simple table in ssrs has employees down left hand side , each column number 1 - 31. when employee books holiday puts x in dates on holiday using if function if day between date , date column. this works fine when there more 1 holiday booked in month employee have duplicate lines rather going along same line in table. when adding in group function shows first holiday booked in month. possible show lines in one? here's sql: select * ,firstname + ' ' + lastname 'full' ,datediff(d, holidaystart, holidayend) 'days' ,day(dateadd(s, - 1, dateadd(mm, datediff(m, 0, holidaystart) + 1, 0))) lastday dbo.holdates month(holidaystart) = param1 , holyear = '8' , holidaystat = 'approved' , location = isnull(param2, location) , (holyear = @param3 - 2005) or month(holidayend) = param1 , (holyear = param3 - 2005) , holidaystat = 'approved' , location = isnull(param2, location) order (f

ffmpeg - Mathematically lossless encoding and decoding of RGB24 image sequence -

i trying encode rgb24 image sequence mathematically ( not merely visually ) lossless video. huffyuv suggested on many online forums tried following. ffmpeg -i frames\%06d.png -vcodec huffyuv test.avi the resulting video decoded frames again using ffmpeg ffmpeg -i test.avi outframes\%06d.png however, input , output frames not bit-by-bit identical promised huffyuv here . idea how can accomplish this? eventual goal read video file using opencv willing cross bridge later once obtain losslessly encoded video file. this question mentions attempt obtain lossless h264 avi , summary of responses seems indicate h264 cannot accomplish lossless encoding. once again, emphasize, i interested in bit-by-bit identical encoding, not visually similar . large file sizes acceptable large compression/decompression time.

design patterns - I need to ask about the object class, but it's a bad practice. Alternatives for this case? -

Image
i'm having trouble extending application. attendance record system. each employee records attendance card has qr code. want add fingerprint recognition, , there no problem until asked 2 forms of identification must coexist in system. thus, system must able sense qrs of employee, fingerprint. the way fix in qridstrategy via .equalsto(id) method is: equalsto(id){ if (id == iskindof (qridstrategy)) if (this.getemployeeid () == id.getemployeeid ()) return true; return false; } but understand asking class of object bad practice , don't want that. how can fix it? i thought of visitor pattern, still have same problem of comparing 2 classes not of same type (because system scan of 2 types) maybe first diagram shows i'm going say, comes down polymorphism. create abstract class (e.g. identificationstrategy method equlasto() ). derive 2 classes: qrstrategy , fingerprintstrategy identificationstrategy , implement equlasto() method in each

ios - Cannot tap any UIVIew in MonkeyTalk tests -

we unable tap of our subclassed uiview's have uitapgesturerecognizers on them. know uiviews have correct accessibilitylabels on them, when run tests tests not fail recognize views, see tap occurring on area of view, , we're able record our actions manually , fills out we'd typed out our tests. sadly, none of taps register on our view , our tests end doing nothing. buttons, buttonselects etc work fine. is there we're missing here? appreciated. thanks. by analyzing monkeytalk source code discovered custom view gesture recognizers must first view receive touch. meaning subviews must have userinteractionenabled set no. after made change worked me.

python - Django and Timezones: how to render aware datetime as a naive one in template (with pytz) -

i have models: class timezone(models.model): name = models.charfield(max_length = 40, unique = true, editable = false) def tz(self): return pytz.timezone(str(self.name)) class place(models.model): name = models.charfield(max_length=200) timezone = models.foreignkey(timezone) class placeaction(models.model): action_time = models.datetimefield(blank=true, null=true) place = models.foreignkey(place, related_name='stop place') def save(self, *args, **kwargs): place_tz = self.place.timezone.tz() if self.action_time: self.action_time = place_tz.localize(self.action_time) return super(placeaction, self).save(*args, **kwargs) my users enter place , naive datetime in form. have timezone of place in db already, not require timezone users. convert , save datetime aware datetime in db (i use postgres). data saves correctly correct offset. when want render data (in update form example), django converts naiv