Posts

Showing posts from April, 2014

java - Stateful session beans vs. persistent entities -

stateful session beans illustrated implementing shopping cart. coming outside java ee, inclination handle kind of state persistent model entity: shoppingcart object products , quantities. way, state being maintained database along other state rather application server. what technical advantages stateful session bean design on "ordinary" persistence? shopping carts in java ee-based web applications indeed written sfsbs, or in other systems more elaborate domain modeling? there several ways implement shopping cart. main difference between sfsb , db persistence is, well, persistence :) a stateful session bean "persist" data during session time. if user session becomes inactive (for exemple after 30 minutes of inactivity), shopping cart reset with database persistence, shopping cart stored permenantly, if user have filled shopping cart, don't visit webshop during 6 months, , visit again, cart still filled i think first solution used, involving non in-memory...

asyncfileupload - Seam ajax file upload -

Image
i have looked several components ajax file uploads , aware richfaces has one, i'm looking simpler. should rendered similar basic input of type file. guess if figure out how style richfaces 1 fine, take ton of tweaking basic. basically, want 1 file @ time on modal panel, don't want kill conversation submitting form. have looked @ jquery stuff, don't know how wire end. examples use php. seems me going have write servlet handle upload. correct, or there easier i'm overlooking allow me bind seam backing entity? asyncfileupload - seam ajax file upload - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta disc...

stop python subprocess after n bytes or lines in proc.stdout.read() -

i'd run subprocess in python until subprocess has outputted number of bytes or lines. after point, i'd terminate it. possible subprocess? here's have far: proc = subprocess.popen(cmd, stdout=subprocess.pipe, stdin=subprocess.pipe, stderr=subprocess.pipe, shell=true) #kill after reaching n bytes of output, proc.terminate() out, errors = proc.communicate() thanks! one straightforward way redirect output program byte/line counting you, example: proc = subprocess.popen(cmd, stdout=subprocess.pipe, stdin=subprocess.pipe, stderr=subprocess.stdout, shell=true) head = subprocess.popen(['head', '-n', '20'], stdin=proc.stdout, stdout=subprocess.pipe, stderr=subprocess.pipe) proc.stdout.close() out, errors = head.communicate() i'm not sure how portable method is, able test on linux on windows should able use more command similar behavior. closing proc.stdout necessary proc receives sigpipe when head exits.

php - Zend_Validate::is() Static Check, get validation message work around -

does know of way validation messages using zend_validate in static scope? zend_validate::is($value, $validator[0], $validator[2]) the docs explicitly getting messages isn't option: http://framework.zend.com/manual/en/zend.validate.introduction.html#zend.validate.introduction.static slightly discouraging, wondering if knew of other methods inside zend getting messages validation string? i'm following great article validating @ model level if interested: http://www.cambraca.com/2011/03/validation-in-zend-framework-model.html thanks help, -seth i'm afraid cannot done. see, messages attached each validator object - cannot attach them class (unless make own implementation of validation logic static message properties , static setter/getter , use instead).

jquery ui - Error Message Style For a Panel -

i using primefaces, in turn uses jquery ui not functionality css styling framework. question arises ignorance css framework, , have been unable find examples or documentation guide me. what want use theme's style error messages own panel. this: <p:panel rendered="#{bean.someerror}" styleclass="?? goes here ??"> <h:outputtext styleclass="?? goes here ??" value="error! parameter page wrong can't rendered. because used stale bookmark." /> </p:panel> i want looks similar error message when using . pointers appreciated. the easiest way @ primefaces showcase , , use firebug @ css classes. i think should use p:outputpanel layout="block" instead of p:panel , because panel has own styles. instead, outputpanel block layouts renders div no styles. anyway, how code should like <p:outputpanel rendered="#{bean.someerror}" layout="block" styleclass="ui-messages ui-widget"> <...

r - Indexing a row and then finding all values following it within a specified time-frame from a different column -

i want use 1 column indicates start point each sample , flag points (rows) follow start point until maximum amount of time reached. for example - data (d) looks like: > head(d) sample seconds value flag 1 356 1 1 2 357 1 na 3 358 9 na 4 359 4 na 5 400 1 na 6 401 3 na a reproducible copy here: d <- structure(list(sample = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l ), .label = c("a", "b", "c"), class = "factor"), seconds = c(356l, 357l, 358l, 359l, 400l, 401l, 402l, 403l, 2955l, 2957l, 2959l, 3001l, 3002l, 3004l, 2548l, 2549l, 2552l, 2553l, 2554l, 2555l, 2556l, 2557l, 2558l), value = c(1l, 1l, 9l, 4l, 1l, 3l, 7l, 2l, 25l, 17l, 23l, 47l, 34l, 15l, 30l, 16l, 17l, 12l, 6l, 8l, 6l, 6l, 5l), flag = c(1l, na, na, na, na, na, na, na, 1l, na, na, na, na, na, 1l, na, na, na, na, na, na, na, na)), .names = c("sample", "seconds", "value", "flag"), cl...

creating a wordpress dev enviornment and uploading to production -

i old school java developer considering using wordpress. i'm used developing locally on pc (yeah yeah not mac) , ftping files production environment on remote server. high level review of wordpress gives me impression typically there no concept of lower environments , updates occur directly in production. case? if not, can explain how 1 goes uploading files web site? thanks, jeff wordpress database driven, doesn't rely on cumulative process of building new html pages every addition or revision, in dreaweaver or similar. core files in wp deployment merely shell content database "hooked" in display. you can, however, setup local environment development purposes using wamp or mamp (mac). process of transferring site production matter of ftp-ing whole shebang, , modifying local database in says "http://localhost/testsite" changed "http://foamfrogs.com" or whatever. upload hosting service's db server. it's bit tricky, once few times, bec...

asp.net mvc 3 - How to display bool values in a view and save the value to DB -

i have table has bit values (true/false) table definition: characterid int isactive bit userid uniqueidentifier i have 2 problems: how display existing selected option in edit view in dropdown i need save value (yes/no) true , false in database. here have attempted far: <div class="editor-label"> @html.labelfor(model => model.isactive) </div> <div class="editor-field"> @html.dropdownlist("", new selectlistitem[] { new selectlistitem() { text = "yes", value = "true", selected = model.isactive }, new selectlistitem() { text = "no", value = "false", selected = !model.isactive }}) </div> assuming model.isactive declared bool : wouldn't using checkbox bit more intuitive user , require less clicks? in case use: @html.editorfor(model => model.isactive) if want dropdowns, might provide working implementation: https://stackoverflow.com/a/4036922/1373170 applied context, beli...

sql - Default value with two sets of parentheses instead of one -

let's have int field, , set default value (0) , works, i've seen people doing instead ((0)) ,why? ((0)) how appear within catalog views or if generate script in ssms. think when see it's generated script , not hand-written way scratch. that said, there nothing different between (0) , ((0)) or (((((((((((((0))))))))))))) ... assuming counted right, parentheses don't change meaning, readability.

SMACSS based CSS Frameworks -

the smacss framework introduces consistent way manage css code reusable , maintainable, more of guideline of how organize css rather actual framework. nice if there other frameworks based off of philosophy, haven't come across any. does know of css frameworks based off of smacss method of organizing css code? pure newer css framework based on smacss. seems related yui project. from extend page ... based on smacss pure broken set of responsive modules. beginning, adopted smacss convention writing our css. new smacss, should give quick read, section on module rules.

c++ - Unsigned vs signed range guarantees -

i've spent time poring on standard references, i've not been able find answer following: is technically guaranteed c/c++ standard that, given signed integral type s , unsigned counterpart u, absolute value of each possible s less or equal maximum value of u? the closest i've gotten section 6.2.6.2 of c99 standard (the wording of c++ more arcane me, assume equivalent on this): for signed integer types, bits of object representation shall divided 3 groups: value bits, padding bits, , sign bit. (...) each bit value bit shall have same value same bit in object representation of corresponding unsigned type (if there m value bits in signed type , nin unsigned type, m≤n). so, in hypothetical 4-bit signed/unsigned integer types, preventing unsigned type have 1 padding bit , 3 value bits, , signed type having 3 value bits , 1 sign bit? in such case range of unsigned [0,7] , signed [-8,7] (assuming two's complement). in case curious, i'm relying @ moment on techn...

Discussion about whether or not respect OOP/MVC Data Model Design when working with SQL-Based Database -

i'd peoples opinion concept on data modeling vs sql (oop vs select statement) on following matter: when studying mvc , oop concepts, it's easy see natural form of things in follow: <php? | <% | <# class country{ _name:string; _language:string; } class estate{ _name:string; _country:country; } ?> | % | #> the point i'm trying simple parent-child relation. now, i've seen working on extjs + php , jsf 2.0 (java using converter), it's quite common see dao (data access object) being defined sort of this: abstract class countrydao{ public function getcountry();//this function returns arraylist. public function getcountrybyid(countryid:integer);//this function returns country object; ... } class estatedao{ public function getestate(){ $sql = "select * tbl_estate"; //[your favorite way comunicate database here] //declare arraylist or store result: $arraylist; while($result = $resultset.next()){ $obj = new estate(); $obj->name = $result['na...

c# - requiredfieldvalidator clashing with formview -

can me out ? when put requiredfieldvalidator on create event's tabcontainer, cannot update formview on tab >>> edit event's tab. have totally no idea happen, , trial , error, found requiredfieldvalidator 1 cause formview stop updating database. , requiredfieldvalidator on tab, how did affect ?!?!? please specified or show e.g really new , bad ! here code create tab >>> <asp:textbox id="tb_eventname" runat="server" validationgroup="vg"></asp:textbox> <asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" controltovalidate="tb_eventname" errormessage="enter event" forecolor="red" validationgroup="vg" setfocusonerror="true" >* </asp:requiredfieldvalidator> <asp:button id="bn_createevent" runat="server" text="create event" onclick="bn_createevent_click" validationgroup="vg...

What is the benefit of security images, like on bank website logins? -

several sites (i remember yahoo did too, when used yahoo account) such bank of america show sitekey or similar image user chooses after enter username, before enter password. ostensibly, ensures login page unique each user, , therefore phisher can't show static login page looks bank's site, what's stopping them hitting bank's site in background , forwarding image (or other security challenge) right user? i'll grant, makes phisher's job harder, doesn't seem valuable me. what's rationale behavior? if single server keeps hitting site requesting images different userids (especially 1 users haven't logged in before), pretty suspicious, it's harder phisher hide.