Posts

Showing posts from July, 2013

jsf - CommandLink is not called anymore after click on commandButton -

there list 100 "favs" on it. shows 10 when page loads. when click on "show more favs" shows 10 more favs. what's weird it, it's after click on show more favs, clicking on remove list, it's not calling method in backbean. my backbean viewscoped. <ui:repeat value="#{bean.list}" var="fav"> <h:form> <h:commandlink styleclass="somestyle" title="remove list" action="#{bean.remove(fav.id)}"/> </h:form> </ui:repeat> <h:form> <h:commandbutton value="show more favs" action="#{bean.showmore}" > <f:param name="morefav" value="10" /> <f:ajax event="action" render="@all" /> </h:commandbutton> </h:form> the culprit usage of multiple forms , render="@all" . if re-render another form inside ajax form, viewstate of another form lost. you need change code co...

android - Error when retrieving image url? -

i keep getting error @ @override protected void doinbackground(void... arg0) { ((gallery) findviewbyid(r.id.gallery)) .setadapter(new imageadapter(this)); return null; } } i syntax error @ (new imageadapter(this)); i dont know what. im guessing has context?? but here full code im using. @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mygames = (button)findviewbyid(r.id.mygames); newrelease = (button)findviewbyid(r.id.newrelease); gamenews = (button)findviewbyid(r.id.news); gamenews.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(mainmenu.this, gamenews.class); startactivity(i); } }); mytask mytask = new mytask(); mytask.execut...

php - Best way to SCREEN POP user after POST request to URL -

im looking best approach takle following, have sorted solution post info (?from=078103xxxxx&to=020300xxxxx etc.) using curl url, upon user receiving phone call on phone <- part sorted, need best way screen pop info , other cross-referenced info (using sql) info on users screen, either via web or intranet. basicly, possible, if user logged onto url, thingy.com/index.php?user=12345 request has been posted url (i.e has rung phone) pop-up displayed info on it. if best way??? any ideas? cheers, b. use jquery, , 'lighbox' popup. combined server push (aka reverse ajax). google it. can better having script repeatedly requesting information in loop forever, though has it's drawbacks. some info: http://biese.wordpress.com/2009/03/03/using-server-push-aka-reverse-ajax/

jquery - IE7, slideToggle(), and CSS -

i have complicated chunk of code i'm running problem on ie 7. here's situation: set up we have div expands using jquery's slidetoggle() . top of box has link expands show more content. @ top of collapsed section dropdown menu, hidden default along other content. ie 7 behavior when slidetoggle() triggered, panel expands/collapses properly, 1 important exception. while panel expanding 500ms, see menu starting appear , looks fine. right when panel finishes expanding, menu 'loses' css styling (images, colors, positioning, etc.) , plain white text sticks top of box. when hover on :hover element of menu, goes normal! so, can 'avoid' issue hovering mouse on dropdown panel expands, isn't solution. jsfiddle i've tried replicate page on jsfiddle complicated , i've had no luck far in giving accurate representation. solution? i've read ie 7 glitches slidetoggle() don't know if relevant situation. there should declaring stop ...

c# - Print using epson esc/p2 on TM U325D -

i print text in bold style using epson esc commands, however, when use esc f, lose first letter. serialport.write(new char[] { (char)27, (char)69 }, 0, 2); serialport.write("line in bold"); i got: ine in bold i guess missing send printer. you need use byte[]: serialport.write(new byte[] { 27, 69 }, 0, 2); serialport.write("line in bold"); using char creates unicode characters utf16...

Android SharedPreferences.Editor putStringSet method not available -

i trying update password generator made include ability save passwords, i'm using sharedpreferences. want put saved passwords inside set, when try save set using sharedpreferences.editor's putstringset method, eclipse not recognize it. when hover on putstringset in code, 2 quick fixes available "change putstring(...)" , "add cast editor", don't think either of helps. this have: public void save(view v) { sharedpreferences prefs = getpreferences(mode_private); final sharedpreferences.editor editor = prefs.edit(); savedpasswords = (set<string>) getsharedpreferences("savedpasswordslist", 0); alertdialog.builder dialog = new alertdialog.builder(this); dialog.setitems(passwords, new dialoginterface.onclicklistener(){ public void onclick(dialoginterface face, int num) { savedpasswords.add(passwords[num]); editor.putstringset("savedpasswordslist", savedpasswords); ...

sql - Looping hierarchies in membership, finding out user's permissions -

i'm crazy of problem below. there users , groups, , groups can contain both users , other groups: create table groupmembership (groupmembershipid, groupid, grouptypeid, memberid, membertypeid) fields grouptypeid , mebmertypeid need provide types because have various types of groups , members. let name me jim , have group "jim's friends" contains users bob, jane , group "jerry's friends". @ same time jerry has group "jerry's friends" containing steve, chloe "jim's group". can see there loop reference between me , jerry. says loops in hierarchies error. case? there way avoid loop? now second question. have table permission describes subject's permissions objects: create table permission (permissionid, subjectid, subjecttypeid, objectid, objecttypeid, permissiontypeid, [value]) every subject (user, group or else) has explicit permission object. @ end point, find out rights of user object, must render user's...

c# - How do I properly handle a MAF addin crashing within a windows service host? -

i have windows service uses maf load user created plugins. here how loading each addin: public bool activateplugin() { try { _addin = _token.activate<iaddin>(addinsecuritylevel.host); return true; } catch(exception ex) { addtolog("error activating plugin"); return false; } } all addins load ok without issues. problem having don't have control on quality of addins , crash , cause whole service stop. there way me catch errors come out of addins won't crash service. look @ these articles blog of system.addin team information on exception handling , add-ins: http://blogs.msdn.com/b/clraddins/archive/2007/05/01/using-appdomain-isolation-to-detect-add-in-failures-jesse-kaplan.aspx http://blogs.msdn.com/b/clraddins/archive/2007/05/03/more-on-logging-unhandledexeptions-from-managed-add-ins-jesse-kaplan.aspx basically way safe activate add-in in separate process. easy because maf provides w...

traits - scala auto convert functions / methods? -

i have got class many methods. class c{ def f1(x:string,....):...=.. def f2(..)... . . . } i want every method defined in class decorated trait of choice automatically. create tricky implicit ore decorates every method , perhaps returns instance of class decorated methods. perhaps wrapped or modified or something. can not describe more of way because dont know way. know way that? methods not functions, although automatically lifted when pass them method requires function. see http://jim-mcbeath.blogspot.com/2009/05/scala-functions-vs-methods.html if have functions: class c { val f1 = (x: string, ...) => val f2 = (...) => ... } and want them mix in trait, like: class c { val f1 = new functionn[string, ...] gaga { def apply(s: string, ...) = ... } val f2 = new functionn[...] gaga { ... } ... } the way can think of submit class scala-refactoring: http://scala-refactoring.org/

php - How do you not show the WordPress plugins directory path in the browser? -

let's have plugin shortcode generates form in post/page, , form's action attribute set script located in same plugins directory shortcode generated form. how make wp not expose path plugins directory when submits form? basically, want domain.com/wp-install-dir/wp-content/plugins/plugin-name/process_form.php map domain.com/plugin-name/process_form.php , wp-install-dir/wp-content/plugins part of url path isn't exposed user. is there wordpress way of specifying path script in plugins directory not expose location of plugins directory in browser, or have set .htaccess / mod_rewrite ? hope i'm asking question clearly. http://codex.wordpress.org/class_reference/wp_rewrite working rewrite/routing system advanced gets wordpress plugin developer. should competent programmer , comfortable reading others' code , debugging own.

windows phone 7 - Post ampersand character to HttpWebRequest -

i need pass string server contains 1 or few value. api grammar following: &track=name or &track=name&artist=name however server return blank string. if remove char &, server return thing this: "�\b\0\0\0\0\0\0\0�zi��f��ϯ�� string post = "track=love"; // post = post.replace("&", "%26"); // httputility.urlencode(post); what should do? should have & char included or need read result server? code follow: protected override void onnavigatedto(system.windows.navigation.navigationeventargs e) { s = navigationcontext.querystring["parameter1"]; // string strconnecturl = "http://mp3.rolo.vn/mp3/search"; try { httpwebrequest webrequest = (httpwebrequest)webrequest.create(strconnecturl); webrequest.method = "post"; webrequest.contenttype = "application/x-www-form-urlencoded;charset=utf-...

iphone - Fail to purchase at in app purchase with unknown reason -

i implemented in app purchase in app , released. failed purchase product in app (not time). i have 2 questions. what of case happen?? i test app, haven't occurred. in case happen?? have similar experiences?? how ": transaction: 180000012369078 - 1" mean? this device's log @ organizer. on success, transaction has number "1" , on failure, transaction has number "2". , formats not same between on success , failure. paist log on success jul 21 12:06:05 unknown adhoc[4714] <warning>: transaction: (null) - 0 jul 21 12:06:05 unknown adhoc[4714] <warning>: purchasing jul 21 12:06:18 unknown adhoc[4714] <warning>: transaction: 180000012369078 - 1 jul 21 12:06:18 unknown adhoc[4714] <warning>: purchased on failure jul 20 19:50:41 unknown adhoc[2202] <warning>: transaction: (null) - 0 jul 20 19:50:41 unknown adhoc[2202] <warning>: purchasing jul 20 19:50:41 unknown itunesstored[2273] <notice...

c# - Embedded Resource location within the assembly -

how can discover location of embedded resource within .net assembly? "location", mean beginning , ending byte positions in assembly. there tool or sample code achieve this? thanks in advance. what looking pe file reader/parser. complete specification located on msdn: http://msdn.microsoft.com/en-us/windows/hardware/gg463119 managed resources: this parser looks pretty close after: http://www.codeproject.com/kb/dotnet/asmex.aspx and there several other pe file readers, this 1 looks promising not call out managed resources. might @ kris stanton's exploring pe file headers using managed code . win32 resources: win32 resources easier. many of same pe readers offset file locate resources. once there, there defined set of structures define layout of resources. msdn has defined these , , others have written it . few google searches should there.

osx - Trackpad gesture to switch to header/source -

i used able use 3 finger scroll-up switch between source/header. since upgrading lion, regular scroll. there way feature back? aka, doesn't jump counterpart when scroll / down used to. update apple fixed issue in xcode 4.2. so, upgrade versions. this correct , best answer . works. posted "@buyin" above. individual commented doesn't work. wrong. works, i've confirmed it. restores 3 finger vertical swipe switch between interface , implementation files (.h , .m) in xcode in lion. from terminal: change appropriate directory (note, if library dir hidden, in terminal type following: chflags nohidden ~/library ) 1. cd /users/yourusername/library/preferences/byhost list files can see .globalpreferences.xxxx-xxxx-xxxx-xxxx.plist 2. ls -lah open plist file in xcode 3. open -a /applications/xcode.app ".globalpreferences.xxxx-xxxx-xxxx-xxxx.plist" set value 1 key "com.apple.trackpad.threefingervertswipegesture" save ...

security - MVC 3 Crypto Helper -- Will this add extra shield to make the password more secure? -

a string salt = crypto.generatesalt(); string saltandpwd = string.concat(originalpassword, salt); string hashedpwd = crypto.hashpassword(saltandpwd); b string hashedpwd = crypto.hashpassword(originalpassword); may know method , method b, more secure ? or correct approach ? reflector, found hash password method in core : public static string hashpassword(string password) { if (password == null) { throw new argumentnullexception("password"); } return hashwithsalt(password, generatesaltinternal(0x10)); } as main purpose of using salt defeat rainbow tables, adding additional salt hashpassword doesn't seem gain benefit, , incur additional overhead (as have store salt generate yourself. hashpassword builds returned value). reference, hashpassword does: the password hash generated rfc 2898 algorithm using 128-bit salt, 256-bit subkey, , 1000 iterations. format of generated hash bytestream {0x00, salt, subkey}, base-64 encoded before ret...

asp.net mvc 3 - Problem to run MVC 3.0 application with IIS7 -

i have created application using: default web site >> right click >> add application added following details alias : cafm physical path: path of application application pool: asp.net v4.0 now type following in internet explorer, working fine. http://localhost/cafm/authentication/logon routing code: public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.ignoreroute("favicon.ico"); routes.ignoreroute("default.aspx"); routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "authentication", action = "index", id = urlparameter.optional } // parameter defaults ); } protected void application_start() { arearegistration.registerallareas...

How to validate fields using jquery in asp.net mvc 3 razor -

here code: @using (html.beginform("register", "user", formmethod.post, new { id = "registerform" })) { @html.textboxfor(m => m.emailaddress, new { size = "40", @onchange = "usernameval();", @tabindex = "1" }) } $("#registerform").validate({ rules: { emailaddress: { required: true } }, messages: { emailaddress: { required: "<br/> please enter email address" } } }); why don't use annotation validate fields? it's easier , cleaner, can below: public class mymodel { [required(errormessage = "please enter email address")] public string email { get; set; } }

c# - using Response.Write for redirecting to page -

when use code response.write("redirect=http://mydomain.com/result.aspx") , result page html not getting displayed. instead getting " page not found " error. in url result page has text " result.aspx%3c!doctype%20html%20public ". please me how can redirect result page properly. you have use response.redirect response.redirect("http://mydomain.com/result.aspx");

How to convert Javascript string to octet/character array? -

i know how convert normal javascript string array of octets/characters. classic c unsigned char array. using struct/jspack library , need extract/unpack values data coming in string. thanks! see string.charcodeat . var str = 'abcdefghijklmnopqrstuvwxyz0123456789'; var result = []; for(var = 0, length = str.length; < length; i++) { var code = str.charcodeat(i); // since charcodeat returns between 0~65536, save every character 2-bytes result.push(code & 0xff00, code & 0xff); } alert(result);

Saxon Xslt Processor Error -

in .net application trying process xml using saxon xslt, xslt version 2.0. when data large getting following error. [net.sf.saxon.trans.xpathexception] = {"org.xml.sax.saxparseexception: xml document structures must start , end within same entity."} any ideas is? in advance. the message you've provided suggests me xml document you're attempting transform (or perhaps xslt stylesheet) not well-formed xml. can read xml document (and stylesheet) using xml parser?

multithreading - TThread Doesn't Do It's Job Unless there is a MessageBox in the Middle ! -

i created class of tthread socket operations, thing is, code doesnt work unless add messagebox it, sockets wont work unless put messagebox call before it sleep(2000); //waiting socket come array // messagebox(0, '', '', 0); { wont work unless line uncommented } if server.clientlist[handle] <> nil begin if (server.clientlist[handle].connected) , (appsocket.connected) begin // send data on socket // relay data between server.clientlist[handle] , appsocket; end; assuming using non-blocking sockets, thread needs running message queue , processing loop. why calling messagebox() works - modal dialog pumps calling thread's message queue internally. thread needs call peekmessage() or getmessage() in loop lifetime of connection(s). loop can use msgwaitformultipleobjects() detect when message queue has process, if thread has other things needs do.

Python eval integer in string, and return integer instead of ascii char -

i'm getting data file, looks this: [200, "hello", "world"] now, since file, array inside string; turn array using eval() . works fine integer @ start converted ascii char, instead of integer want (the euro sign). how can fix this? you use simplejson module. e.g. >>> import simplejson >>> = simplejson.loads('[200, "hello", "world"]') >>> print [200, 'hello', 'world'] this way "malicious" data such os.execvp() not evaluated jsondecodeerror would thrown.

iphone - How can I set the titlebar title for a modal view controller? -

self.title = @"my view"; doesn't work when view presented modally. you must write following code presenting modalview controller.. yourmodelcontroller =[[yourmodelcontroller alloc]init]; uinavigationcontroller *controller = [[uinavigationcontroller alloc] initwithrootviewcontroller: yourmodelcontroller]; [[self navigationcontroller] presentmodalviewcontroller:controller animated:yes]; [controller release]; then in viewdidload -method u need write self.title =@"my view"; it work definitely. hope you.

security - Is permanent session / 2nd password a good idea? -

so, idea store each user "password" or auth value, when auth via cookies compare values. way if cookie somehow stolen has nothing real password. for important operations, changing password etc user needs provide password , validated vs original password (salted, encrypted etc). imo there no reason password , session/auto-login-cookie related in way. yes, i'd make them separate. use random value in cookie , associate server side data it. allows me invalidate cookie server side.

java - How to launch a WAR by restricting the environement to JDK 1.5 with Websphere 7? -

i know if possible launch war have run jdk 1.5 (not compliant jdk 1.6) under webpshere 7. it not possible/supported run websphere application server 7.0 process other jdk 1 bundled product.

html - How to calculate number of checkboxs'Id in a table via Javascript -

i wanna total number of checkbox in html. request: (1) javascript (2) checkbox id "id=idcheckbox", (3) each checkbox name reserved back-end using. not javascript. (4) naming each checkbox's name checkbox_1, checkbox_2,... number indicate serial number of checkbox. the table html <table class="form_table" border="0" cellpadding="0" width="750px" id="idroutinelisttable"> <tr> <td style="align:center;" class="routinelistcell"> <input type='checkbox' name='checkbox_1' id='idcheckbox'></input> <!-- may many checkbox here.--> </td> </tr> </table> my js code, function check checkbox selected before deletion. if no checkbox selected, pops warning. function beforedelete() /*{{{*/ { var checked=0; var checkboxall=document.all["idcheckbox"]; //the error here, when there 1 checkbo...

javascript - Text on same line -

existing code cannot modify, here expand class functionality on click helps user expand collapse function. <h3 class="expand"> tree </h3> now have put text(root) smaller font size after tree in same line visibility controlled javascript. <h3 class="expand"> tree <div id="root" style="display:none"><font size="2"> root</font></div></h3> javascript functionality working fine tree , root not coming in 1 proper line! , yes cannot change h3. instead of div use span tag <h3 class="expand"> tree <span id="root" style="display:none"><font size="2"> root</font></span></h3>

apache - .htaccess: Redirect root url to subdirectory, but retain root url -

i in process of cleaning domain's directory structure (woe me setting root url's content in root directory!) , need insight on how use rewriterule correctly. the gist i want domain.tld use domain.tld/subdirectory/ still appear domain.tld in url. my .htaccess far options +followsymlinks rewriteengine on #force removal of wwww subdomain rewritebase / rewritecond %{http_host} ^www.domain.tld rewriterule ^(.*)$ http://domain.tld/$1 [r=301,l] #trailing slash rewriterule ^/*(.+/)?([^.]*[^/])$ http://%{http_host}/$1$2/ [l,r=301] #redirect root url subdirectory redirectmatch 301 ^/subdirectory/$ http://domain.tld/ rewriterule ^/$ /subdirectory/?$ [l] the redirectmatch works great. unfortunately, t seems last rewriterule there should work enough, doesn't. old content setup in root directory still appears. what missing here? update: resolved simple fix not experienced enough .htaccess / apache able explain why. i had: rewriterule ^/$ /subdirectory/?$ [l...

Python get start and end date of the week -

how start date , end date of week, , if following dates below comes under particular range of start , end dates of week how show weeks start , end date.i using python 2.4 2011-03-07 0:27:41 2011-03-06 0:13:41 2011-03-05 0:17:40 2011-03-04 0:55:40 2011-05-16 0:55:40 2011-07-16 0:55:40 from datetime import datetime time import strptime now datetime(*strptime('2011-03-08 0:27:41', '%y-%m-%d %h:%m:%s')[0:6]).weekday() returns day of week first date "as integer, monday 0 , sunday 6", selecting dates weekday() in [0, 6] give start , end dates of weeks (or use 4 instead of 6 work weeks).

ajax - JavaScript datagrid for vertical rows -

is there javascript datagrid can show , edit rows of data vertically? if data provided this: array('firstname':'john','lastname':'doe', 'age':'22') array('firstname':'jack','lastname':'jill', 'age':'78') i want data displayed on webpage datagrid: fields value1 value2 firstname john jack lastname doe jill age 22 78 if new person added list, there new column added, not row. each row have different input methods (for example dateinput, text, number, etc.). i want data in datagrid editable, in order ajax-load , ajax-save data to/from mysql-database. regards, martin

java - cascade save in hibernate, foregin key is saved as null -

i have class follows class a{ set<b> = new hashset<b>(); } class b{ a; } now primary key of autogenerated cant set before in or b.b has inverse mapping of a.and object within b null originally. maps 2 tables , b in db.now if have object set contains 2 records when save object 2 records gets created in b.now code working fine.but when see recods in b find foreign key corresponding blank.how come? table b structure bid aid bname //aid foreign key tablles primary key , aid stored null, why so?i want aid should automatically stored in b you need correctly set both side of relation parenta.getbchilds().add(childb); childb.setparenta(parenta); <-- important see link below working bi you can create link management methods in parent correctly set both sides. public class parenta { ... public void addchildb(b pchild) { this.childsb.add(pchild); pchild.setparenta( ); } ... } set 'inverse' attribute true on collection ...

c++ - Copying a vector of pointers -

i have std::vector<a*> need deep copy vector using a::clone() . instead of using handwritten loops, wondering whether use for_each or standard library algorithm this. the appropriate algorithm std::transform , can turn member function invocation unary functor std::mem_fun example: #include <vector> #include <functional> #include <algorithm> #include <iterator> class x { public: x* clone(); }; int main() { std::vector<x*> vec1, vec2; std::transform(vec1.begin(), vec1.end(), std::back_inserter(vec2), std::mem_fun(&x::clone)); } if target vector same size input range, can pass vec2.begin() third argument. use back_inserter if target empty (or want append it).

javascript - Why can a constructor only return an object? -

if there constructor like function a() {} then (new a) instanceof === true but on other hand, function a() { return {} } results in (new a) instanceof === false so thinking that function a() { return 123 } would result in same thing. however, when returning number, (new a) instanceof === true how possible? why can't make constructor return else object? (i know making constructor returning number rather useless understand 'why' of behaviour) according spec: if calling constructor returns object, object result of new -expression. if constructor doesn't return object (but undefined or other primitive value), result newly created object. if primitives allowed, constructors have explicitly return (typically " this "), otherwise result undefined (because result of function without return undefined ). needless hassle. additionally, makes sense new can relied on return object.

java - What to do to prevent SimpleAdapter from crashing? -

i'm trying populate listview... in main.java have this: ... listviewmain=(listview)findviewbyid(r.id.lv1); popvidlist pvl = new popvidlist(); pvl.populatevideolist(listviewmain); ... and in popvidlist.java this: package rob.youtube.com; import java.util.arraylist; import java.util.hashmap; import android.app.activity; import android.widget.listview; import android.widget.simpleadapter; public class popvidlist extends activity { private arraylist <hashmap<string, object>> vidarray; private static final string listvidtext1 = "mythbusters"; private static final string listvidtext2 = "by jamie"; private static final string listvidtext3 = "3 month ago"; private static final string imgkey = "iconfromraw"; public void populatevideolist( listview listviewmain ) { vidarray = new arraylist<hashmap<string,object>>(); hashmap<string, object> hm; hm = new hashmap...

model view controller - Delete not working in Rails 3 -

i have app in rails 3 , run crud working except delete link.when click it takes me show action , want delete particular record.below codes view index.html.erb: <td><%= link_to 'destroy', member, :confirm => 'are sure?', :method =>:destroy %></td> controller # delete /members/1 # delete /members/1.xml def destroy @member = member.find(params[:id]) @member.destroy respond_to |format| format.html { redirect_to(members_url) } format.xml { head :ok } end end ...any plz.. check javascript libraries. in application had same problem because removed prototype , did not install jquery. this problem occurs because delete method emulated via javascript.

PHP Equivalent of C# ticks -

i converting asp.net c# application php. service uses datetime ticks , wondering if there equivalent in php. if not best way me calculate timespan? use microtime(true) please note following, straight off php manual by default, microtime() returns string in form "msec sec", sec current time measured in number of seconds since unix epoch (0:00:00 january 1, 1970 gmt), , msec number of microseconds have elapsed since sec expressed in seconds. if get_as_float set true, microtime() returns float, represents current time in seconds since unix epoch accurate nearest microsecond.

actionscript 3 - Communication between Flex module and Application -

ok, modules in flex popular have no idea why documentation , examples on different uses of flex modules can scarce. anyway, question, take classic employee/department example. have main.mxml contains mx:tabnavigator. each tab loaded s:moduleloader. tables: employees {empid,empname,deptid}, deparments {deptid,deptname} the tab navigator contains 1 tab (for our example) called employee. have employee.mxml module. in module, have datagrid populated employee details. use getemployees($deptid) function. function, may guess, returns me array of employees work in particular department. outside tabnavigator, have departmentdropdownlist populated departments.deptname. my objective load employee module when select particular department dropdownlist. have changehandler dropdownlist can give me deptid. protected function departmentdropdownlist_changehandler(event:indexchangeevent):void { mydeptid=departmentdropdownlist.selecteditem.deptid; //var ichild:*=employeemodule.child imodul...

How to create a right-click context menu for a button in WPF -

Image
i know how create left-click context menu button, not sure how right click? (i.e. how specify context menu should appear on right-click, not left click). many thanks. here sample: <button content="button" name="btn" width="100"> <button.contextmenu> <contextmenu> <menuitem header="cut"/> <menuitem header="copy"/> <menuitem header="paste"/> </contextmenu> </button.contextmenu> </button>

outlook - "You replied to this message on" title in add-in form region -

is there way can add "you replied message on xxx" title (the current outlook 1 has nice exclamation mark too!) own form region? perhaps define placeholder in form region , fill somehow? i'm using c++. thanks, nili look in xxxfactory class (xxx = region name), in formregioninitializing event handler. there have access e.outlookitem cast mailitem date sent. set mainifest's formregionname like.

ruby - Regex to validate strings having only characters (without special characters but with accented characters), blank spaces and numbers -

i using ruby on rails 3.0.9 , validate string can contain characters (case insensitive characters), blank spaces , numbers. more: special characters are not allowed (eg: !"£$%&/()=?^) except - , _ ; accented characters are allowed (eg: à, è, é, ò, ...); the regex know this question ^[a-za-z\d\s]*$ not validate special characters , accented characters. so, how should improve regex? i wrote ^(?:[^\w_]|\s)*$ answer in question referred to (which have been different if i'd known wanted allow _ , -). not being ruby guy myself, didn't realize ruby defaults not using unicode regex matching. sorry lack of ruby experience. what want use u flag. switches unicode (utf-8), accented characters caught. here's pattern want: ^[\w\s-]*$ and here in action @ rubular. should trick, think. the u flag works on original answer well, though 1 isn't meant allow _ or - characters.

iphone - TimeInterval function setting with UIPicker -

i have following part of code. executing when user select time interval uipicker. if([[arrayno objectatindex:row] isequaltostring:@"1 minutes"]) time=60; if([[arrayno objectatindex:row] isequaltostring:@"5 minutes"]) time=300; [nstimer scheduledtimerwithtimeinterval:60 target:self selector:@selector(updatemethod) userinfo:nil repeats:yes]; i defining 2 time in uipicker "1 minutes" , "5 minutes". suppose once user select "1 minutes" function "updatemethod" call after 1 minutes of time period. let suppose user again change time "5 mnutes" uipicker. happen? timer set "5 minutes" or set "1 minutes" , "5 minutes" both? how design code set function calling 1 time only? me in concept? every time called, schedule new timer, in example, both. i discourage scheduledtimerwithtimeinterval:... reason. have no way cancel timer. should create nstimer* ivar this: @inte...

How to count elements inside array/object on PHP? -

i have array being sent view array ( [0] => stdclass object ( [emg_id] => 2 [fkit] => 1 [door] => ) ) i count how many elements empty, null, or '0'. i tried using count returns '1', instead of counting of elements, can later determine satisfy conditions above. any ideas i'm doing wrong? // number of "null" elements echo count(array_filter((array) $array[0], 'is_null')); there other is_*() -functions built-in, may example count number of strings (and on). to test, if element (e.g.) 0 , suggest use anonymous function echo count(array_filter((array) $array[0], function ($item) { return $item === 0; })); the other cases similar.

vb.net - Question on example on MSDN -

i have been trying use http://msdn.microsoft.com/en-us/library/akfttx8c(v=vs.90).aspx example vb see how virtual function works example used on msdn doesn't have sub main! i tried playing around can't working. have idea on how should setup? thanks! just add following main : module appentrypoint sub main() testpoly() end sub end module and yes, should have been obvious description in msdn article …

c# - View Errors happened in Database (Remote) – SQL Server -

our application using sql server 2005 database. using history database actual database putting values using trigger. i checked db server. set 600 sec remote query timeout. changed 0 , restarted server. still, getting errors during operations if enable above mentioned triggers, after 10 minutes. working fine if don’t use triggers. i use profiler see errors happened in 2 databases. how configure profiler see errors above mentioned 2 databases? otherwise, there query or dmv see errors happened in databases? note: want see errors in profiler; not other details in profiler check box 'show columns', can choose 'databasename' in columns , set filter on show db names. there category in events errors , warnings. here's msdn reference error events.

django - Accessing admin model instance in form -

class productadmin(admin.modeladmin): form = productadminform() class productadminform(forms.modelform): def __init__(self, request, *args, **kwargs): super(productadminform, self).__init__(*args, **kwargs) self.fields['field1'] = forms.charfield(required=false) self.fields['field2'] = forms.integerfield() how can pass product instance productadmin productadminform? want provide different fields depending of products instances. this: class productadminform(forms.modelform): class meta: model = product def __init__(self, *args, **kwargs): super(productadminform, self).__init__(*args, **kwargs) product_instance = self.instance if product_instance.id , product_instance.myfield == "thatvalue": self.fields['field1'] = forms.charfield(required=false) self.fields['field2'] = forms.integerfield()

javascript - How will the stack of this function will look like? -

when following: function makeaddfunction(amount) { function add(number) { return number + amount; } return add; } var addtwo = makeaddfunction(2); var addfive = makeaddfunction(5); alert(addtwo(1) + addfive(1)); will each instance of makeaddfunction have separate stack or of them use same stack? , order of variables entering , leaving stack matter? each function call creates new function (-context). answer quickly, yes have separate "stacks" in terms of ecmascripts execution contexts . i'm not sure mean "the order of variables entering , leaving stack". ecmascript contexts (objects). there stack of execution contexts called in order. after 1 context finished, parent context continues run until it's finished (and forth). principle lasts long there contextes if not, global context gets attention again.

Adding an 'All' option into a codeIgniter form_dropdown -

i have array returns locations database, trying output form drop down using following code: <?php form_dropdown('idlocation', $querylocations, set_value('idlocation'); ?> the $querylocations has locationid , locationname . , above code works fine display locations, need add option called 'all' having idlocation 0 appear @ top of location list. can please me this? just prepend $querylocations array values. here's 1 way: form_dropdown( 'idlocation', array('0' => 'all') + $querylocations, set_value('idlocation') ); you earlier, when create $querylocations array well. $options[0] = 'all'; foreach ($results $r) $options[$r->idlocation] = $r->locationname; something that...

CakePHP - How to get public path to application root -

i'm looking constant or variable provide public path application root. i have got far full_base_url gives me http://www.example.com have added problem of application being in sub directory (e.g. http://www.example.com/myapp/ ). is there way path http://www.example.com/myapp/ in controller? $this->html->url( '/', true ); in general should generate links function, see http://book.cakephp.org/view/1448/url

Deprecated ActionScript Code, new code for linking flash to pdf? -

i'm using flash pro. cs5 actionscript 3, , i've never worked flash before, , i've searched while way , continuously syntax errors code. saw asked similar question, , person said code deprecated, can assume since mine looks similar deprecated. flash i'm trying make button open pdf file. code have right is; on(release){ geturl("index dividers.pdf"); } and syntax error keeps saying 'expecting semicolon before left brace' stupid may sound, added semicolon before left brace, , 1 error turned 3 errors, didnt solve anything. know proper code open pdf file? appreciated! geturl has been replaced navigatetourl , works accepting urlrequest object. in case, looks this: navigatetourl(new urlrequest('index dividers.pdf')); as click handler, can't on(action) notation anymore, event based now. need set listener on target, , assign handler function called when event fires: this.addeventlistener(mouseevent.click,clickhandler);...

c# - Can't Find Microsoft.Office.Server.Search.WebControls in Sharepoint 2010 -

i'm trying create custom search result webpart, , need develop class must inherit microsoft.office.server.search.webcontrols.coreresultswebpart. however, when add reference microsoft.office.server, can use microsoft.office.server.search.portalcrawl. searching solutions on internet, found 1 person had same problem, , nobody answered him. has idea of why can't load correct namespaces , on earth portalcrawl came from? thank time. i faced same issue sometime back... while adding reference listed 'microsoft® search component' under .net components. there 2 dlls same component name (mentioned above). microsoft.office.server.search.dll (this 1 need) microsoft.office.server.search.connector.dll

java - Swing: how do you drag multiple rows from a JTable? -

i have jtable. if selection mode listselectionmodel.single_selection , can drag data table elsewhere , works fine. but if selection mode listselectionmodel.multiple_interval_selection , when go drag data, resets selection single selection. how can drag multiple rows jtable? edit drag , drop of multiple rows should work default, or without setting selection mode. caveat drag enabled on jtable.

c# - Minimizing code impact of migrating to Azure Blob storage -

i'm attempting migrate complex application windows azure. in both worker role , web role there many instances application saves files local file system. here's example: string thumbnailfilename = system.io.path.getdirectoryname(filename) + "\\" + "bthumb_" + system.io.path.getfilename(filename); thumbnail.save(thumbnailfilename); and example: using (system.io.streamwriter file = system.io.file.appendtext(getcurrentlogfilepath())) { string logentry = string.format("\r\n{0} - {1}: {2}", datetime.now.tostring("yyyy.mm.dd@hh.mm.ss"), type.tostring(), message); file.write(logentry); file.close(); } in these examples saving images , log files file locations specified in app.config. here's example: <add key="imagefiledirectory" value="c:\temp\foo\root\auth\inventorypictures"/> i'd make few code changes possible support azure blob storage in case ever decide move more t...

r - Simple working example of ddply() in parallel on Windows -

i've been searching around simple working example of using ddply() in parallel. i've installed "foreach" package, when call ddply( .parallel = true) warning "no parallel backend registered") can provide simple working example of using ddply in parallel? here's simple working example: > df <- data.frame(val=1:10, ind=c(rep(2, 5), rep(3, 5))) > library(dosnow) > registerdosnow(makecluster(2, type = "sock")) > system.time(print(ddply(df, .(ind), function(x) { sys.sleep(2); sum(x) }, .parallel=false))) ind v1 1 2 25 2 3 55 user system elapsed 0.00 0.00 4.01 > system.time(print(ddply(df, .(ind), function(x) { sys.sleep(2); sum(x) }, .parallel=true))) ind v1 1 2 25 2 3 55 user system elapsed 0.02 0.00 2.02

javascript - Use same variable that is defined in another function -

this may seem simple less experienced javascript. have 2 functions. 1 called when upload begins. next called when upload ends. in first function, variable created, unique id used upload. best way go reusing in second function since not global? reason defined within function because every time user clicks upload button, function called , new id created upload, why not want define outside because same id served second upload unless page refreshed. anyone got suggestions? function uploadstart() { function makeid() { var text = ""; var possible = "abcdefghijklmnopqrstuvwxyz0123456789"; for( var i=0; < 32; i++ ) text += possible.charat(math.floor(math.random() * possible.length)); return text; } var rand_id = makeid(); } uploadfinish(){ //rand_id undefined } try declaring rand_id in global scope (before everything) var rand_id; function bla....

delphi - Why the screenshot doesn't work (black screen)? -

service "allow service interact desktop". unit unit1; interface uses windows, messages, sysutils, classes, graphics, controls, svcmgr, dialogs; type tcopydesk = class(tservice) procedure servicecontinue(sender: tservice; var continued: boolean); procedure serviceexecute(sender: tservice); procedure servicepause(sender: tservice; var paused: boolean); procedure serviceshutdown(sender: tservice); procedure servicestart(sender: tservice; var started: boolean); procedure servicestop(sender: tservice; var stopped: boolean); private procedure copyscreen(const index: integer); public function getservicecontroller: tservicecontroller; override; end; var copydesk: tcopydesk; implementation {$r *.dfm} procedure servicecontroller(ctrlcode: dword); stdcall; begin copydesk.controller(ctrlcode); end; procedure tcopydesk.copyscreen(const index: integer); const defaultwindowstation = 'winsta0'; defaultdesktop = 'default'; ca...

python - How to change behavior of dict() for an instance -

so i'm writing class extends dictionary right uses method "dictify" transform dict. instead though change calling dict() on object results in same behavior, don't know method override. not possible, or missing totally obvious? (and yes, know code below doesn't work hope illustrates i'm trying do.) from collections import defaultdict class recursivedict(defaultdict): ''' recursive default dict. >>> = recursivedict() >>> a[1][2][3] = 4 >>> a.dictify() {1: {2: {3: 4}}} ''' def __init__(self): super(recursivedict, self).__init__(recursivedict) def dictify(self): '''get standard dictionary of items in tree.''' return dict([(k, (v.dictify() if isinstance(v, dict) else v)) (k, v) in self.items()]) def __dict__(self): '''get standard dictionary of items in tree.''' ...

Use jQuery/CSS to find the tallest of all elements -

possible duplicate: css - equal height columns? i have 3 divs. like this: <div class="features"></div> <div class="features"></div> <div class="features"></div> they going filled text. i'm not sure how much. thing is, it's imperative equal heights. how can use jquery (or css) find tallest of div's , set other 2 same height, creating 3 equal height div's. is possible? you can't select height or compare in css, jquery , few iterations should take care of problem. we'll loop through each element , track tallest element, we'll loop again , set each element's height of tallest (working jsfiddle ): $(document).ready(function() { var maxheight = -1; $('.features').each(function() { maxheight = maxheight > $(this).height() ? maxheight : $(this).height(); }); $('.features').each(function() { $(this).height(maxheight)...

php - How to safeguard my mysql_connect password (My database server's password)? -

*this question non-local host's. *i using web-host service. not personal server. to use mysql_connect, connect database's server, 1 needs create php file , save in web host's server. file must have (within code) server's address user name , password: **$conn = mysql_connect("server", "username", password);** anyone view's page's code , downloads php file can see password, security risk. how can safeguard database' server' password? you don't have options protecting database password. should make sure user/password combination have access parts of database necessary make web application run. in other words, don't make root password. if have other databases not used web application, should have different login credentials. unless web server misconfigured, not possible download php file view code. should also, if possible, place file containing login credentials outside web server's document root , ...

android - Getting SQLite database and storing it in an array of objects -

i'm looking @ notes app example android sdk. want learn how instead of using cursoradapter pass listadpater/listview sort out, want know how can deal data myself; particularly in arraylist form. in example, note has id, title, , body. want know how can query sqlite database , use cursor returns collect data , create object instances of object i'll call note has parameters id, title, , body. want store these objects arraylist management. i'm not sure how deal cursor. pretty general question need point me in right direction. i might not question need query db add cursor data arraylist? list<string> pointslist = new arraylist<string>(); database = openorcreatedatabase("favorites", sqlitedatabase.open_readwrite, null); if(database!=null) { c= database.rawquery(query, null); c.movetofirst(); while(c.isafterlast()==false) { pointslist.add(c.getint(c.getcolumnindex("id")); //...

c# - MVC Repository - Domain Model vs Entity Model -

i have created repository returning data database using entity framework , need provide data view, before need convert objects domain model. my schema looks this: table project id int primary key name nvarchar(100) table resource id int primary key firstname nvarchar(100) lastname nvarchar(100) table projectresources project_id int primary key -- links project table resource_id int primary key -- links resource table i generated entity model ended looking this: project | ---->projectresources | ---->resource i have repository returns project: public interface iprojectrepository { project getproject(int id); } and controller action: public actionresult edit(int id) { project project = projectrepository.getproject(id); return view(project); } this doesn't seem work when try , post data. getting entitycollection initialized error when trying reconstruct projectresources collection. i think smarter cr...

is there a way to change the behavior of notepad++ auto-indent? -

i have problem notepad++ auto-indent. let's assume ¬ cursor. if text this: my text text¬ and press [enter] turns this: my text mytext ¬ this fine. when text this: my text text ¬ and press [enter], goes like: my text text ¬ note cursor advances itself. behavior doesn't work me. keep actual indentation instead of "playing smart". correct behavior (to me) be: my text text ¬ anyone that? there file edit or plugin that? don't want disable auto-indent, change 1 thing. (: as requested: http://sourceforge.net/projects/npp-plugins/files/nppautoindent/ glad solved problem.

python - Background thread with QThread in PyQt -

i have program interfaces radio using via gui wrote in pyqt. 1 of main functions of radio transmit data, continuously, have loop writes, causes gui hang. since have never dealt threading, tried rid of these hangs using qcoreapplication.processevents(). radio needs sleep between transmissions, though, gui still hangs based on how long these sleeps last. is there simple way fix using qthread? have looked tutorials on how implement multithreading pyqt, of them deal setting servers , more advanced need them be. don't need thread update while running, need start it, have transmit in background, , stop it. i created little example shows 3 different , simple ways of dealing threads. hope find right approach problem. import sys import time pyqt5.qtcore import (qcoreapplication, qobject, qrunnable, qthread, qthreadpool, pyqtsignal) # subclassing qthread # http://qt-project.org/doc/latest/qthread.html class athread(qthread): def run(sel...

rails: set datetime column using value in a text_field -

my question similar another one putting data text_field datetime column. appears need put data text_field in particular order or rails wont accept it. thing is, can't control how user input data. in fact, since added jquery datepicker value user puts in wrong. i thought use date.parse or time.parse or datetime.parse along setter method (mentioned in railscast 32 but doesn't seem working me either. keep getting argument out of range error seems due input being in wrong format. does else use jquery datepicker fill in text field date? magic have add model or controller make work? why difficult? i used timeliness gem overcome problem , submit date in format wanted. along timeliness used validates_timeliness validate date , time, is not in future or anything. to parse string 'mm/dd/yyyy' using timeliness gem do: timeliness.parse(params[:my_date], :format => 'mm/dd/yyyy')

Can i transfer one MySQL database without stoping MySQL server? -

detailed: have mysql databases,for example: create database mydb1; create database mydb2; create database mydb3; create database mydb4; each 1 databased used client. mydb1 started use resources , needs dedicated server. need transfer only one database(its ok if database unavailable(better if available time) other databases should available time. free version of mysql enough? each database size near 5 gb. mysql has tool called myqslhotcopy, desigend dump running database. use lock_table, supposed faster way mysqldump. http://dev.mysql.com/doc/refman/5.0/en/mysqlhotcopy.html my suggestion dump database during non peak hours , use scp/rsync move desired server. another approach use mysqldump bitmap has suggested in answer.

internet explorer - Javascript get scroll amount in IE -

i have div scrollable want conditionally stop scrolling. the code like: if(thediv.scrolltop + thediv.clientheight + thisscrollamount > thediv.scrollheight) stopscrolling(); how can amount scroll scrolled? (i know event.wheeldelta typically +-120, seems amount scrolled when 1 scrolls can quite different that.) edit apologies. seems question unclear. looking how div would scroll if event not canceled it's handler. assuming took on different values, appears take on values +- 120. perhaps should deleted. //works pretty <style type="text/css"> #divtest{width:150px;height:200px;overflow:auto} </style> <script> var amountcanscroll = 400 function maxscroll( ){ if( document.getelementbyid('divtest').scrolltop > amountcanscroll){ document.getelementbyid('divtest').scrolltop = amountcanscroll; } } </script> <body><div id="divtest" onscroll="maxscroll...