Posts

Showing posts from April, 2013

javascript - Replacing comma with dot Char -

i have made calculation app in appjs. basicly bunch of: <input type=number> fields. to make more user friendly thought should replace commas dots, javascript can use actual values calculate. i've tried doing this following pice of code: $("input[type=number]").keyup(function(e){ var key = e.which ? e.which : event.keycode; if(key == 110 || key == 188){ e.preventdefault(); var value = $(this).val(); $(this).val(value.replace(",",".")); } }); in explorer 9, works expected: see fiddle but since app.js uses chromium guess thats happens in chromium. how can work around this? this happens in app: when enter number containing comma char. comma char moved right , when input box loses focus, comma removed (probably since comma char isn't allowed in type=number) when value of <input type=number> isn't valid, blank string returned. check doing

xpages - Access Control with a multi database application -

i have maindb.nsf contains of xpages design, agents, script libraries etc. database user selects application. there may 1 or more application databases. each of applications databases contain actual data application, plus views of data accessed in custom controls in maindb. when person authenticates against maindb security rights , assume there role in maindb called [finance]. there no real data documents in maindb in purchasereq.nsf there , [finance] role gets editor rights documents in purchasereq.nsf. have defined role in both maindb.nsf , purchasereq.nsf. however, not want person role [finance] have editor rights in maindb.nsf in purchasereq.nsf. if assign role person in maindb.nsf reader rights , duplicate acl entry in purchasereq.nsf editor rights user opens document in purchasereq.nsf have reader or editor rights. seccondly, have have role [finance] in maindb.nsf. i read somewhere sort of setup design database , multiple data repositories can't find reference.

c# - Using Cache in Collatz Sequence implementing issues -

i have created 2 lists, 1 number , 1 chain count. if number in number list, take it's chain count , add current chain count. issue right here program stucks , it's not returning me anything. problem it's solved, takes me 4.7 seconds find number under 1 million has longest sequence , chain count want optimize using cache memory. static list<long> cache_number = new list<long>(); static list<long> cache_chains = new list<long>(); static long collatzchain(long num) { int chain = 1; while (num != 1) { if(cache_number.contains(num)){ long x = chain + cache_chains[cache_number.indexof(num)]; return x; } if (num % 2 == 0) { num = num / 2; } else { num = 3 * num + 1; } chain++; } cache_number.add(num); cache_chains.add(chain); return chain; }

c# - How to access RadGridView row programmatically? -

how access row in radgridview ? want set row opacity programmatically, possible ? can't find document it. <telerik:radgridview x:name="radgridstoppedcars" showgrouppanel="false" isfilteringallowed="false" selectionchanged="radgridstoppedcars_selectionchanged" background="transparent" itemssource="{binding perworkz}" width="550" height="500" margin="800, 90,432,-53" rowheight="45" issynchronizedwithcurrentitem="true" rowindicatorvisibility="collapsed" canusersortcolumns="false " isreadonly="true" showcolumnsortindexes="false" au

c# - Redirect to another page in different project of same solution -

so made wp8 app , split them separate projects, , put button redirects app's page other page on separate project have added. how program when tap button, redirects me page of different project same solution? the code used is: app.rootframe.navigate(new uri("/mainpage.xaml", urikind.relativeorabsolute)); try this: navigationservice.navigate(new uri("/targetprojectname;/targetpage.xaml", urikind.relative));

java - How to hide action bar on HTC one using Holo.NoActionBar theme -

my app uses android them holo.noactionbar theme hide action bar , display activity . this works fine on emulator , nexus 4 ,device actionbar hidden. however when run on htc 1 , ignores android theme settings , displays action bar. might displayed on other samsung or sony devices have custom oem skins. have made sure there no references action bar or menu options in activity java file or android manifest file. so googled how hide action bar , tried how hide action bar before activity created, , show again? and wrote code public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().requestfeature(window.feature_action_bar); getactionbar().hide(); setcontentview(r.layout.activity_my); and http://developer.android.com/guide/topics/ui/actionbar.html public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); actionbar actionbar = getsupportactionbar(); actionbar.hide(); setcontentview(r.layout.activity_my);

vb.net - How to generate a 26-character hex string that equals to 106 bits and ((53 Ones - 53 Zeros) in binary) -

i looking way generate hexadecimal string equals out 106 bits, more fifty 3 1's , fifty 3 0's after each hex char converted binary , added together. i'd keep random possible considering parameters of request. how go keeping eye on construction of string equals out way want? for example: (a8c05779f8934b14ce96f8aa93) = (1010 1000 1100 0000 0101 0111 0111 1001 1111 1000 1001 0011 0100 1011 0001 0100 1100 1110 1001 0110 1111 1000 1010 1010 1001 0011) you can place 52 ones randomly in 104 bit number keeping track of how many ones has been placed , calculate probability next digit should one. first digit has 1/2 probability (52/104), second digit has 51/103 or 52/103 probability depending on first digit was, , on. put bits in buffer, , when full (four bits), makes hexadecimal digit can add string: dim rnd new random() dim bin new stringbuilder() dim buf integer = 0, buflen integer = 0, left integer = 52 integer = 104 1 step -1 buf <<= 1 if rnd.next

python - add a 'now' timestamp column to a pandas df -

i have following code: s1 = pd.dataframe(np.random.uniform(-1,1,size=10)) s2 = pd.dataframe(np.random.normal(-1,1, size=10)) s3 = pd.concat([s1, s2], axis=1) s3.columns = ['s1','s2'] which generates df looks this: s1 s2 0 -0.841204 -1.857014 1 0.961539 -1.417853 2 0.382173 -1.332674 3 -0.535656 -2.226776 4 -0.854898 -0.644856 5 -0.538241 -2.178466 6 -0.761268 -0.662137 7 0.935139 0.475334 8 -0.622293 -0.612169 9 0.872111 -0.880220 how can add column (or replace index 0-9), timestamp time? np array not have size 10 you can use datetime's now method create time stamp , either assign new column like: s3['new_col'] = dt.datetime.now() or assign direct index: in [9]: import datetime dt s3.index = pd.series([dt.datetime.now()] * len(s3)) s3 out[9]: s1 s2 2014-08-17 23:59:35.766968 0.916588 -1.868320 2014-08-17 23:59:35.766968 0.139161 -0.9

Setting up a graph database to query common properties across different types of nodes -

i looking @ using graph database data relational database. way database setup, information related single item spread across multiple tables. have read, seems way go have node type corresponds each table, , each entry in table node. setting edges between nodes gets tricky. for example, have table of car parts: | part number | price | quantity in inventory | cars: | make | model | price | and table of car uses part: | model number | part number | quantity | i create node each car part, , node each car model. there :uses relationship car model each part uses. makes easy parts used in particular car, or cars contain specific part. what if wanted find cars , car parts have price? (ignoring in example car parts tend not cost as car) i.e. querying shared properties? query goes through, examining each node, , accepting or rejecting node if price not match seems not scale well. if had millions of parts in database, wouldn't slow? the way around can think of create pri

css - HTML Elements Moving on Page Reload - Chrome Only? -

i experiencing trouble floated elements displayed improperly on page refresh. behavior has been recorded in chrome (36.0.1985.143m) , steam browser. behavior occurs on mac os x 10.9.4, mac os x 10.7, mac os x 10.6.8, , windows 7. tested include safari 7.0.6 on mac os x 10.9.4, safari 7.0.6 on mac os x 10.7, firefox 3.6.10 on mac os x 10.6.8, safari 5.1.10 mac os x 10.6.8, firefox 31 on windows 7, ie11 on windows 7, ie9 on windows 7. i running coldfusion 9.0.2 on iis 7.5 on windows server 2008 r2. however, there 0 server-side scripting being done on page (or other related resources). update: using server-side scripting show or hide divs based on section parameter in query string. all. here link demo. prefer source, below. http://craftdeck.com/mockup2/profile.cfm?section=store here rendered html. <!doctype html> <html> <head> <title>craft deck</title> <script type="text/javascript" src="scripts/jquery-1.10.0.min.js

javascript - Reset button for each preview image -

i don't want create remove button; each images previewed before going uploaded. reason because each image has unique id, if uses remove button mess id arrangement when 1 of images removed. i know little complicated. how create reset button each images? so, when user click reset button, open window of user computer pick new image, , id of new picked image still same before. here code: var ftype = new array(), count1 = 0; $("#imginput").change(function () { readurl(this); }); function readurl(input) { var files = input.files; var output = document.getelementbyid("result"); (var = 0; < files.length; i++) { var file = files[i]; var picreader = new filereader(); var divid = 'div_' + i; var spanid = 'span_' + i; var count = 0; picreader.addeventlistener("load", function (event) { var picfile

java - Why doesn't add method accept my inputs? -

so far problematic code, assume else made , done: public gamerecord[] updatehighscorerecords(gamerecord[] highscorerecords, string name, int level, int score) { // write code after line int = 0; (gamerecord gr : highscorerecords){ if (gr.getscore() >= gr.getscore()){ highscorerecords.add(i+(gr.getlevel()-level),(object) new gamerecord(name, level, score)); /* *adds new gamerecord in @ (i+gr's level - level)th iteration. *note because of assumtion highscorerecords ordered becuase of using function */ break; //no more need continue loop } += 1; } return highscorerecords; } as may have noticed, code part of course, why i'm assuming other implementations perfect. you passing in gamerecord[] highscorerecords array, but calling list method add - not exist on array . should getting compile error. if sure array has capacity insertion do highscorerecords

Java IO readers - how do they work? -

i'm working on project need read several files server. wondering if can read output , connect somewhere else same instance. apparently can (see below). tried pseudocode: c.connect(google) bufferedreader r1 = ... c.getinputstream(); c.connect(somewhereelse) bufferedreader r2 = ... c.getinputstream(); print(r1) print(r2) and output correct. i don't know how io streams works or conn function returns (i'll check during winter evenings :-)) real question: can rely on fact i'll correct data? i.e. buffered reader keep reference data object not anymore bound connection itself? no, think can't trust code. inputstream needs connection fetch data. example, if open java.net.socketinputstream (url connections use stream) , see read method, see such code: // connection reset if (impl.isconnectionreset()) { throw new socketexception("connection reset"); } a bit lower can see, stream tries fetch buffered data if exists:

performance - Is there a linear solution to determining whether a postorder sequence is a valid BST? -

problem: given array of integers, determine if can postorder traversal sequence of bst. ex: [5, 7, 6, 9, 11, 10, 8] returns true, [7, 4, 6, 5] returns false. i'm wondering if can in linear time. here solutions n^2 , nlgn came with. n^2 solution : scan through array , check root's left , right subtree values smaller , larger root's value respectively. repeat each subtree. nlgn solution : build bst going right left of input array. keep track of max number can encounter @ point. max number updates parent node every time insert left child. if ever try insert node greater tracked max number, can return false. here's linear-time algorithm that's simpler last revision of answer. def checkbst(lst): # stack contains values of nodes current path departs right stack = [float('-inf')] # upperbound value of leafmost node path departs left upperbound = float('inf') x in reversed(lst): # pop stack elements greate

java - when using the arrow keys my image disappears -

the problem when press down button, image (blueboy) disappears, , doesn't move can move side side, cant understand why? please help. (i'm using realj). if there website can me on 2d side scrolling games me well. import java.applet.applet; import java.awt.event.*; import java.awt.*; public class projectblue extends applet implements actionlistener,keylistener,mouselistener { image blueboy,trees; //image variable int size = 4,jump = 50, cx = 1, cy = 1; public void init() { blueboy = getimage(getdocumentbase(),"png.png"); trees= getimage(getdocumentbase(),"background.jpg"); addkeylistener( ); addmouselistener( ); } public void paint(graphics g) { int width = trees.getwidth(this); int height = trees.getheight(this); //system.out.println("" + cx +","+ cy); //the later images drawn on top of earlier ones. g.drawimage(trees, 1 ,1, width*size,height*7,this); g.drawimage(blueboy,

jsf - CommandLink doesn't work. Tried everything -

it's first question on site :) first, sorry bad english, i'm learning :) plz, need help. i'm blocked application in jsf. i have <?xml version='1.0' encoding='utf-8' ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> <body> <ui:composition template="./defaulttemplate.xhtml"> <ui:define name="content"> <h1 style="margin-bottom: 0px">#{msg.default_2}</h1> <br/> <ul style="padding-left: 0px"> <ui:repeat value="#{catego

r - plotting hurdle regression output -

i attempting plot hurdle regression output interaction term in r, having trouble doing count portion of model. model <- hurdle(suicide. ~ age + gender + bullying*support, dist = "negbin", link = "logit") since unaware of approaches allow me plot these data without estimating each portion separately (binomial logit , negative binomial count), attempting plot each using estimates using mass package. far, have had best luck using visreg package plotting, open other suggestions. have been able reproduce , plot original logistic output hurdle model, not negative binomial count data (i.e., parameter estimates mass not same in hurdle regression output). i appreciate insight regarding how others have plotted hurdle regression results in past, or how might able reproduce negative binomial coefficients obtained hurdle model using glm.nb in mass. here using plot data: ##logistic logistic<-glm(suicidebinary ~ age + gender + bullying*support, data = sx, fam

How to edit PayPal referral code (BN code) in magento? -

how can change paypal referral code (bn code)in maganeto paypal standard module. file need edit ? don't see place edit on admin side. try in following file app/code/core/project/paypal/model/config.php make following structure app/code/local/project/paypal/model/config.php or override config.php in custom module. please reply if works you.

Android VideoView Http Live Streaming Memory Leak -

i'm trying create application can stream http live streaming (hls) source. so far, working expected. however, i'm experiencing problem memory leaking issue. as of point, i'm losing 6mb/hour while videoview streaming hls server. currently, must set videoview = null , reinitialize videoview memory back. however, means there's interruption on live streaming. is there better way clear memory of videoview without interrupting video? any suggestions , feedback appreciated!

c - Distribute .so file on linux? -

i have shared library application needs (a .so) , wondering best way distribute it? it's not can apt-get installed , need in ld path's in order run application. in past i've needed include separate "launcher script" user click on instead of clicking on linux executable directly. launcher script set ld_library_path include directory shared library stored, , launch executable. here's script, reference (it assumes executable , shared library hidden away in sub-folder named "bin", , executable's name same script's name except without ".sh" suffix): #!/bin/bash appname=$(basename "$0" .sh) dirname=$(dirname "$0") cd "$dirname/bin" export ld_library_path=$(pwd):$ld_library_path ./$appname "$@"

javascript - Difference between string.indexOf() and string.lastIndexOf()? -

what's difference between string.indexof() , string.lastindexof() in javascript? var temp = state.indexof("tmp"); var temp = state.lastindexof("tmp"); from mdn : the indexof() method returns index within calling string object of first occurrence of specified value, lastindexof() method returns index within calling string object of last occurrence of specified value so indexof return first occurrence of value , lastindexof return last occurence of value. example (copied mdn): var anystring = "brave new world"; var = anystring.indexof("w")); // result = 8 var b = anystring.lastindexof("w")); // result 10 both of method return -1 if value not found more : indexof lastindexof

python - PyQt4 ---- I want to use closeEvent() in my code -

i python newbie. developing pr-room management program. think if user presses x button , want give warning message . so, want use closeevent() in first code. in other words, first code + second code please # -*- coding: utf-8 -*- # form implementation generated reading ui file 'c:\users\pjh11\desktop\dia3.ui' # # created: sun aug 17 16:23:08 2014 # by: pyqt4 ui code generator 4.11.1 # # warning! changes made in file lost! pyqt4 import qtcore, qtgui try: _fromutf8 = qtcore.qstring.fromutf8 except attributeerror: def _fromutf8(s): return s try: _encoding = qtgui.qapplication.unicodeutf8 def _translate(context, text, disambig): return qtgui.qapplication.translate(context, text, disambig, _encoding) except attributeerror: def _translate(context, text, disambig): return qtgui.qapplication.translate(context, text, disambig) class ui_dialog(object): def setupui(self, dialog): dialog.setobjectname(_fromutf8(&quo

c++ - Should i make a class instead of the repetitive get/set statements? -

consider following code (which simplified version of original one): #include <string> namespace { class ctype; } class my::ctype { private: std::string simple_name; public: explicit ctype(std::string simple_name) : simple_name{std::move(requireidentifier(simple_name))} // duplicate code { } std::string get_simple_name() const { return simple_name; } void set_simple_name(std::string value) { simple_name = std::move(requireidentifier(value)); // duplicate code } }; the requireidentifier function returns reference value value not empty otherwise throw std::invalid_argument exception. i have many classes similar ctype class definition, of them have private member variable of type std::string , subsequently check value not empty following expression: std::move(requireidentifier(value)) here problem, repeated in of classes! suppose have 10 classes similar ctype , there should 20=2*10 expressions ab

node.js - Extract data from variables inside multiple callbacks in javascript -

i'm ok javascript , callbacks, i'm getting annoyed @ , need call on the world of stackoverflow help. i have written function, used in following way: var meth = lib.function(a,b); // meth should hold array of properties { c, d } once executed so inside lib.js, have structure like: exports.function = function (a,b) { database.connect(params, function(err,get){ get.query(querylang, function(err, results){ var varsiwanttoreturn = { var1: results[i].foo, var2: results[i].bar }; }); }); // how return 'varsiwanttoreturn'? }; i have seen things incorporating callback() function, i'm not sure how works. i've seen people use exec() - again, im not sure on how or why use it. please :) in advance. well, it's asynchronous if attempt return - it'll return undefined. in javascript (sans new yield keyword) functions execute top bottom synchronously. when make io call database call - still executes sy

java - Grails error validating on existing input -

i got error when tried modify controller (generated scaffolding). want do, add current user capture springsecurity service. payment class has user property inside. tried inject user value springsecurityservice.getcurrentuser() ; when tried this, produce error : property [user] of class [class kks.payment] cannot null i tried debug, looks fine still producing error .... this work if put user.id inside form hidden value .. didn't want ... how solve problem ? here code: class paymentcontroller { def springsecurityservice; @transactional def save(payment paymentinstance) { println("1..... payment"); paymentinstance.user = springsecurityservice.getcurrentuser(); if (paymentinstance == null) { notfound() return } println("2..... payment"+springsecurityservice.getcurrentuser().class); println(paymentinstance.user.id); // still okay !!! if (paymentinstanc

android - custom font (unicode) in Custom ListView Adapter doesn't show -

i want create custom list adapter unicode. code , compiles without errors unicode characters didn't show. please me rectify problem. you. customlistviewadapter package com.theopentutorials.android.beans; import java.util.list; import com.theopentutorials.android.r; import com.theopentutorials.android.beans.rowitem; import android.app.activity; import android.content.context; import android.graphics.typeface; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.textview; public class customlistviewadapter extends arrayadapter<rowitem> { context context; public customlistviewadapter(context context, int resourceid, list<rowitem> items) { super(context, resourceid, items); this.context = context; } /* private view holder class */ private class viewholder { imageview imagevi

c# - Passing reader object from aspx.cs file to View (.aspx) -

this not duplicate of other question. if there similar , didn't worked me. have searched lot unable solve issue. kindly guide me. i have made query database records in aspx.cs file. records in reader object. want access object in view file (.aspx file). here small part of code. in .aspx.cs file string qry = "select * `enduser` `firstname` @key limit 0 , 30"; cmd = new mysql.data.mysqlclient.mysqlcommand(qry, connection.getconnection().open()); cmd.parameters.addwithvalue("@key", keyword); mysqldatareader reader = cmd.executereader(); in .aspx file can tell me how access here in aspx file. 1- have tried sessions not worked. 2- have tried other way <% =myvariable; %>   // not worked i want reader object in view file , iterate displat each record. thanks you should use 1 of controls available in asp .net, example repeater . need bind repeater datasource. rest done automatically. see example here: http://www.tutorialspoint.

sql - Increasing the Max Pool Size and performance -

in asp.net website have connection sql server express database. , lot of errors like system.invalidoperationexception: timeout expired. timeout period elapsed prior obtaining connection pool. may have occurred because pooled connections in use , max pool size reached. after searching error found may due unclosed sql server connections. have used sql server connections , have disposed properly.i have used using-statement dispose connection. in application lot of requests (connections sql server database) @ peak time of day. so planning increase max pool size. have not specified in connection string. 100 (default). planning increase 20000 won't error. so increasing max pool size number cause problem? increasing max pool cause performance problem? edit: below sample of how used using in code using con1 new sqlconnection con1.connectionstring = "" //conn string here con1.open() dosomething() end using using con2 new sqlconnection

c# - Unable to access user control public properties from generic handler -

following generic handler's code. code compiles , converts user control named navigationmenu.ascx html , sends calling page: <%@ webhandler language="c#" class="getmenu" %> using system; using system.web; using system.web.script.serialization; public class getmenu : ihttphandler { public void processrequest(httpcontext context) { //--some other code string markup = getusercontrolmarkup(0); context.response.write(markup); } public string getusercontrolmarkup(int menutype) { system.io.stringwriter writer = new system.io.stringwriter(); using (system.web.ui.page page = new system.web.ui.page()) { system.web.ui.usercontrol usercontrol = null; usercontrol = (system.web.ui.usercontrol)page.loadcontrol("~/user controls/navigationmenu.ascx"); type type = usercontrol.gettype(); page.controls.add(usercontrol); httpcontext.current.server.execute(page, writer, false); return

c# - Redirect in a Sitecore solution Noob -

here trying do, employer want able able 301 redirect regex expression alias in sitecore way trying implement this! a singleline text field checkbox tell sitecore regex expression noob in .net , sitecore how can implement ? here exemple http://postimg.org/image/lwr524hkn/ i need exemple of redirect want handle this, exemple of redirect want product @ place of solution. exemple.com/en/solution/platform-features to exemple.com/en/platform-features i base code http://www.cmssource.co.uk/blog/2011/december/modifying-sitecore-alias-to-append-custom-query-strings-via-301-redirect query string want use regex expression. namespace helloworld.website.sc.common { public class aliasresolver : sitecore.pipelines.httprequest.aliasresolver { // beginning of methods public new void process(httprequestargs args) { assert.argumentnotnull(args, "args"); if (!settings.aliasesactive) { tracer

symfony - link in body of Email Symfony2 -

i want send in body of email link, have in controller . $message = \swift_message::newinstance() ->setsubject('demande de conge ') ->setfrom($col->getemailcollaborateur()) ->setto($form->get("emailcdp")->getdata()) ->setbody($this->render('mytestbundle:conge:demandecongenormal.html.twig', array('conge' => $conge))) ; $this->get('mailer')->send($message); in demandecongenormal.html.twig: <a href={{ conge.justificatif}}>confirmer</a> in email receive have : <a href=lllllllll>confirmer</a> i'm new in symfony please help! you should use url function in twig template. example: <a href="{{ url('_your_route_name_to_active', {'r

javascript - how can i get value from tfoot datatable jquery? -

plz want value of first tr in tfoot can't , here how set values : <script type="text/javascript" charset="utf-8"> $(document).ready(function() { // init datatables var otable = $('#datatable').datatable({ "fnfootercallback": function( nrow, aadata, istart, iend, aidisplay ) { var solde = 20.35; nrow.getelementsbytagname('th')[4].innerhtml = solde.tofixed(2)+" $"; } }); }); </script> how value ?? in advance. try using eq() function $('tfoot').find('tr').eq(0).html()

delphi - Are there exceptions that aren't caught by general E : Exception? -

i wondering if there exceptions/errors, make code jump except block aren't handled e : exception. try := strtoint(s); {...do lot more...} except on e : econverterror begin showmessage('you need input valid number.'); end; on e : exception begin showmessage('something went wrong.'); raise; end; end; is there way program have error ignore both statements in except block? or should : try := strtoint(s); {...do lot more...} except on e : econverterror begin showmessage('you need input valid number.'); end; else begin // swapped on e : exception else showmessage('something went wrong.'); raise; end; end; you can throw derives tobject . in order catch every such class you'd need specify tobject in on statement. from documentation : exception types declared other classes. in fact, possible use instance of class exception, recommended exceptions derive