Posts

Showing posts from September, 2012

hibernate - Spring validator - The request sent by the client was syntactically incorrect -

my friend helped me set first spring/hibernate project , trying implement custom validator. have registrationform model uses anotations validate. however, need implement password validator - check if password , confirmpassword equal. problem: when post, if passwords match, data saved. if dont match, @ validators following line, error title. errors.rejectvalue("confirmpassword", "valid.passwordconfdiff"); the request sent client syntactically incorrect. tutorial followed: http://examples.javacodegeeks.com/enterprise-java/spring/mvc/spring-mvc-password-example/ this have: controller: @controller @requestmapping("/") //@sessionattributes(value = {"registerform"}) @componentscan("ba.codecentric.movienight") public class frontcontroller { @autowired private userservice userservice; @autowired @qualifier("passwordvalidator") private passwordvalidator validator; @initbinder("passwor

html - Place caret below anchor text -

<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none"> <span class="criteria">any</span> <span class="caret" style="margin-top:6px;"></span> </a> the above piece of code giving me following output any ▼ how place caret below anchor close anchor text. approx : any ▼ edit : have text following anchor , caret, want on same line. before anchor text text following anchor ▼ the drop down in middle of sentence. want caret close anchor text, below , not next line edit 2 : code before , after <div class="control-group"> <div class="controls dropdown"> create backup if <a href="#" class="dropdown-toggle" data-toggle="dropdown" style="text-decoration: none"> <div cla

cmd - Batch - Right String in foor Loop with variable -

i've little problem right string manipulation in loop. code in question: set filename=!filename:~0,%lengthtoclip%! if try without loop or replace variable %lengthtoclip% fix number works fine. need for-loop. processed text file line line, cut out unimportant information (the code fragment) on right side , write in new text file. my first idea need ist stronger exclamation mark stronger %. i'm newbie batch have no idea how resolve problem. grateful help. greetings for %%z in ("!lengthtoclip!") set "filename=!filename:~0,%%~z!"

Multi line comments in SBT -

is possible comment out entire block of text in sbt, similar /* java style block comment */ syntax? i'm getting build errors , can use multiple single line comments instead. the build error see error parsing expression. ensure there no blank lines within setting illegal start of simple expression line number indicating closing */ try /*** comment */ note: settings allowed in there too.

c# - WinForms: Simplest way to change listbox text color on the fly? -

Image
looking simple way add color text (or bold text) listbox item (the solutions i've seen in stackoverflow have seemed overly complicated needs). i've been adding comments listbox via code: listbox1.items.add("test complete!"); this line peppered throughout code. i'd love able modify occasional text color such line "test complete!" shows in green. is there simple, on-the-fly solution this? you can takes little bit of work setup, not complicated if looking setup font color or font. you have add handler drawitem event. this.listbox1.drawitem += new drawitemeventhandler(listbox1_drawitem); and here pretty simple handler looking for. void listbox1_drawitem(object sender, drawitemeventargs e) { graphics g = e.graphics; dictionary<string, object> props = (this.listbox1.items[e.index] dictionary<string, object>); solidbrush backgroundbrush = new solidbrush(props.containskey("backcolor") ? (color)prop

maven - Error in running spark program "java.lang.IllegalArgumentException: Unsupported type: com.spark.example.main.App$Product" -

i trying run sample spark-cassandra program in java trying create tables, join , compute , store stores results in table program fails error: java.lang.illegalargumentexception: unsupported type: com.spark.example.main.app$product here program: package com.spark.example.main; import com.datastax.driver.core.session; import com.datastax.spark.connector.cql.cassandraconnector; import com.google.common.base.optional; import org.apache.spark.sparkconf; import org.apache.spark.api.java.javapairrdd; import org.apache.spark.api.java.javardd; import org.apache.spark.api.java.javasparkcontext; import org.apache.spark.api.java.function.flatmapfunction; import org.apache.spark.api.java.function.function; import org.apache.spark.api.java.function.function2; import org.apache.spark.api.java.function.pairflatmapfunction; import scala.tuple2; import static com.datastax.spark.connector.japi.cassandrajavautil.*; import java.io.serializable; import java.math.bigdecimal; import java.text.m

R - Different approach to speed up 3 dimension array/matrix creation -

my question 1 of approach. using iterated through methods create 3 dimension array in r (this first question; r constraint). use case final array needs updated 2 input arrays updated @ different periods. goal minimize final array creation time, intermediary steps if possible. i know can reach out rcpp, , assign more need readability, wondering is: is there better approach completing operation ? if (!require("geosphere")) install.packages("geosphere") #simulate real data dimlength <- 418 latlong <- cbind(rep(40,418),rep(2,418)) potentialchurn <- as.matrix(rep(500,418)) #create 2d matrix valuemat <- matrix(0,dimlength,dimlength) value <- potentialchurn valuetranspose <- t(value) (s in 1:dimlength){valuemat[s,] <- value + valuetranspose[s]} diag(valuemat) <- 0 #create 3d matrix copying 2d matrix bigvalmat <- array(0,dim=c(dimlength,dimlength,dimlength)) (d in 1:dimlength){bigvalmat[,d,] <- valuemat} #get crow fly distance bet

vba to set up a dynamic range based on two column -

i trying set dynamic range based on 2 column, criteria is... i have 2 columns called "name" , "phone" column "name" in left side of "phone" range wish is, find column "phone" set range in column "phone" 1st non-empty row , last row in column "name" so far able find column "phone" , remaining stuff not able relate range column "name", please see below macro , suggest how should able it. hey in advance... option explicit sub rulepicker() dim ws worksheet dim acell range, rng range dim col long, lrow long dim colname string '~~> change relevant sheet set ws = thisworkbook.sheets("sepy build") ws set acell = .range("a1:zz1").find(what:="phone", lookin:=xlvalues, lookat:=xlwhole, _ matchcase:=false, searchformat:=false) '~~> if found if not acell nothing

Trying to replicate IBM Mainframe SFTP upload with JSch ChannelSftp -

i trying use jsch sftp channel upload file ibm mainframe, , directory has "//", mainframe automatically route file needs go. in sftp command session on ibm mainframe, can this: sftp myuser@1.2.3.4 connecting 1.2.3.4... myuser@1.2.3.4's password: sftp> pwd remote working directory: /users/home/myuser sftp> cd // sftp> pwd remote working directory: // sftp> put "#12345.abcdef.xxx.xxx" uploading #12345.abcdef.xxx.xxx //#12345.abcdef.xxx.xxx #12345.abcdef.xxx.xxx 100% 403 0.4kb/s 00:00 so created jsch sftp session (version 0.1.5.1) attempt same upload, not work: jsch jsch = new jsch(); session session = jsch.getsession("myuser", "1.2.3.4"); session.setpassword("mypass"); session.connect(); channel channel = session.openchannel("sftp"); channel.connect(); channelsftp sftp = (channelsftp)channel; log.info(" user home pwd " + sftp.pwd()); //prints /users/home/myuser sftp.cd(&qu

php - Multiple mysql tables with where ... AND -

can somehow compare 3 tables this? i error: mysql_free_result() expects parameter 1 resource $duom=mysql_query("select * pazymiai, mokinys, mokymo_dalykas pazymiai.mokinio_nr = mokinys.nr , pazymiai.dalyko_nr = mokymo_dalykas.nr;"); while ($result = mysql_fetch_array ($duom)) { echo(" <tr> <td>$result[6]</td> ... </tr>"); } mysql_free_result($duom); mysql_close(); here sql using join . work? select * pazymiai p join mokinys m on p.mokinio_nr = m.nr join mokymo_dalykas md on p.dalyko_nr = md.nr documentation link: http://dev.mysql.com/doc/refman/5.0/en/join.html

javascript - How to redirect user to a page by an ajax call? -

i have login page user enters email , password. so, able make ajax call page configuration of data. now, if email , password correct must redirect user new page called, "home". tried, but, redirected div page. solutions? in advance, everyone! <script type="text/javascript"> $(document).ready(function (e) { $(".login-form").on('submit',(function(e) { e.preventdefault(); $.ajax({ url: "verify/login.php", type: "post", data: new formdata(this), contenttype: false, cache: false, processdata:false, success: function(data) { $(".login-result").html(data); }, error: function() { } }); })); }); </script> this simple re

When reading files in Python (on mac) the printed out text is incorrect -

i trying out simple command, open , read file. have created text edit file , saved test.txt (this file has irrelevant text on it). when run program there no errors , print commands executed, except wrong information printed.this code: f = open("test2.docx","r") line1 = f.readline() line2 = f.readline() line3 = f.readline() print line1, line2, line3 this written in text file: cof180;10;40 cof181;10;90 phf110;15;73 phf210;15;81 this printed out program: {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720 {\fonttbl\f0\fswiss\fcharset0 helvetica;} {\colortbl;\red255\green255\blue255;} this seems sort of hidden code text itself? please have no idea why happening. how make print actual text file? if using textedit, menu bar select format -> make plain text.

sort associate array in PHP -

function mysort($arr) { ($i = 0; $i < count($arr); $i++) { $j = $i; while ($j > 0 && $arr[$j] < $arr[$j-1]) { $tmp = $arr[$j-1]; $arr[$j-1] = $arr[$j]; $arr[$j] = $tmp; $j--; } } return $arr; } $array = array( 'a' => '1', 'f' => '3', 'g' => '5', 's' => '2', 'r' => '8' ); $values = array_values($array); $sorted = array(); foreach (mysort($values) $key=> $value) { $sorted[$value] = $array[$value]; } print_r($sorted); i lost here. i'd sort array $array according values output a = 1 s = 2 f = 3 g = 5 r = 8 however trying without using sort methods such asort, usort or ksort. own function. this should work you: here simple loop through elements of $array , save them sorted in $sorted . in first if statement check if either $sorted array empty or current element of $array bigger last element o

Adding two binary arrays in C++ -

how can add 2 binary arrays(8 bits) , store result in third binary array in visual studio 2010 - c++ . example : a=00100011 b=11011100 result_array=11111111 i tried doing using convert b (have decimal value) binary: std::string binary2 = std::bitset<8>(b).to_string(); but when added 2 binary array , storing them third integer array ,the third array didn't take value results adding operation , still having default value (which 00000000) thanks in advance! call binary arrays boolean arrays , work back: #include <iostream> int main(int argc, char* argv[]) { bool a[8]={0,0,1,0,0,0,1,1}; bool b[8]={1,1,0,1,1,1,0,0}; bool c[8]; bool remainder=false; for(int x=7;x>=0;x--) { unsigned sum=0; if(remainder)++sum; if(a[x])++sum; if(b[x])++sum; if(sum%2==1)c[x]=true; else c[x]=false; if(sum>1)remainder=true;

r - Using name full name and maiden name strings (and birthdays) to match individuals across time -

i've got set of 20 or consecutive individual-level cross-sectional data sets link together. unfortunately, there's no time-stable id number; there are, however, fields first, last, , maiden names, year of birth--this should allow pretty high (90-95%) match rate, presume. ideally, create time-independent id each unique individual. i can marital status (maiden name) not change pretty in r--stack data sets long panel, effect of: unique(dt,by=c("first_name","last_name","birth_year"))[,id:=.i] (i'm of course using r data.table ), merging full data. however, i'm stuck on how incorporate maiden name procedure. suggestions? here's preview of data: first_name last_name nee birth_year year 1: eileen aaldxxxx dxxxx 1977 2002 2: eileen aaldxxxx dxxxx 1977 2003 3: sarah aaxxxx gexxxx 1974 2003 4: kelly aaxxxx nxxxx 19

Why advanced languages like C# and Java does not enforce File Closing? -

most of times students gets console based management system assignments i.e. library or point of sale system etc. have store data using traditional file system. and 80-90 percent times make mistake of forgetting close file after opening or creating it. somefile.close(); (they have debug code find error, why data not being stored in file. being mentor have faced problem myself many times too.) so real thing is, way these advanced languages java enforces exception handling why there isn't enforce file closure? resources released whenever deallocated (by being garbage collected, not expected deterministic). if want dispose them in deterministic manner (and not @ moment of deallocation), in java there try -with-resources block , in c# there using block. why don't enforce case types encapsulate autoclosable/disposable resources? well, because pattern in use cases. if enforced it, troublesome in other cases.

scala - How do I include ScalaDoc options in Maven -

i can generate class hierarchy diagram manually use "scaladoc -diagrams ..." i can generate basic scaladoc maven "mvn scala:doc" but how can put "-diagrams" in when run scaladoc maven? in general, how put in of options listed in "scaladoc -help". i have in pom.xml, doesn't work. <plugin> <groupid>org.scala-tools</groupid> <artifactid>maven-scala-plugin</artifactid> <version>2.14-snapshot</version> <configuration> <args> <arg>-diagrams</arg> </args> </configuration> </plugin> update this doesn't work either: <plugin> <groupid>org.scala-tools</groupid> <artifactid>maven-scala-plugin</artifactid> <executions> <execu

google api - Webmaster API v3: getting servingLimitExceeded using batch requests -

i'm getting servinglimitexceeded error message results within batch not entire batch. example, may 100 records responding error , starts returning more results. within single batch. if batches handled internally google api, how can adjust them not hit rate limit? tried adding 1-second delay between batches doesn't change this. set retries = 3 on ruby client, don't know if means retries failed batch. don't think it's retrying individual api calls within batch, because back-off should resolve this. do have record failed results , create new batch recover separately? incidentally, documented quota limit errors confusing. there dailylimitexceeded , ratelimitexceeded messages isn't returning 1 of those. servinglimitexceeded description of "the overall rate limit specified api has been reached" not helpful i'm assuming rate limit hit. update looking @ code, see retries in ruby google-api-client apply transmission , authorization (

shiny - Terminating (graciously) MonetDB process in R -

i'm using monetdb on variety of platform (e.g. os x , linux centos) shiny application. it difficult disconnect db times, approach terminate shiny app without disconnecting db. this means shiny app before accessing data tries stop "old" process with: monetdb.server.stop(pid) from source of command understand kills process associated pid provided (which means among other things user running app must have access kill function). this works ok of times, when try start monetdb again, get !fatal: gdklockhome: database lock '.gdk_lock' denied warning in socketconnection(host = host, port = port, blocking = true, open = "r+b", : localhost:50000 cannot opened error in socketconnection(host = host, port = port, blocking = true, open = "r+b", : cannot open connection is there way avoid error (without forcibly disconnecting database time use in shiny)? it can indeed take couple of seconds monetdb shut down. if new proce

python - Resetting class to default state -

in python, standard/commonly used way reset class "default state"? example, before loading class might want reset existing data. for example, check out self.clear() method below: class conlanguage: serializable_attributes = \ ["roots", "prefixes", "suffixes"...] #list of "important" fields def __init__(self): self.roots = [] self.prefixes = [] self.suffixes = [] ..... def clear(self): # <<--- method tmp = conlanguage() attr in self.serializeable_attributes: setattr(self, attr, getattr(tmp)) def loadfromdict(self, indict): defaultvalues = conlanguage() attr in self.serializable_attributes: setattr(self, attr, indict.get(attr, getattr(defaultvalues.attr))) def loads(self, s): self.loadfromdict(json.loads(s)) this approach seems job, wonder if there way it. the other question (which not have

c++ - Trouble Implementing Array Based Queue -

i working on homework class. have implement array based circular queue. having trouble figuring out algorithm determining if queue full , empty. below c++ source file working in: #include <iostream> #include <assert.h> #include "circularqueue.h" using namespace std; template <class type> circularqueue<type>::circularqueue(const int & capacity) { assert (capacity >= 0); this-> capacity = capacity; front = 0; rear = capacity-1; array = new type[capacity]; } template <class type> circularqueue<type>::~circularqueue() { delete [] array; } template <class type> void circularqueue<type>::add(type value){ if (!isfull()) { rear = (rear + 1) % capacity; array[rear] = value; } else { cout << "the queue full, cannot add value." << endl; } } template <class type> void circularqueue<type>::remove(){ if(!isempty()) { fron

Can't figure out why form won't save to database ruby on rails -

i trying save "product" aka pair of glasses database following data fields-- name, lens, frame, temple, accent, quantity, photo. app/controllers/product_controller.rb def create @product = product.create(product_params) end # each pair of glasses has name, lens, frame, accent, quantity, , picture def product_params params.require(:product).permit(:name, :lens_id, :frame_id, :temple_id, :accent_id, :quantity, :photo) end app/views/products/_form.html.erb <div class="field"> .... <%= f.label :quantity %> <%= number_field_tag :quantity, nil, class: 'form-control', min: 1 </div> i can save record , saves database except quantity saves 'nil'. can go rails console, select record, , manually add quantity via console though... missing? thanks in advance! the error result of helper tag using :quantity . should using form builder helper number_field , not generic number_field_tag . it shoul

swing - Logging out a user properly in java -

i'm using eclipse ide i have code login -check if user , pass match -check if account's session column in db "logged in". if false log in user, else prompt user when logging out, have log out button when clicked changes 'logged in' 'logged out'. problem when user didnt click log out button , instead closes application. tried making window listener when frame 'closing' redirecting log out button, kinda solves problem assigned every frame redirect log out button action when 'window closing'. my app works this: app has multiple frames. after logging in there homepage, 4 more buttons direct other modules. in homepage, when click on module_a, homepage disposes , module_a frame pops up, if click 'back' button module_a disposes , homepage pop ups again, clicking module_b disposes homepage , pops module_b frame , on... scenerio 1: ~logged in - changes user status 'logged out' 'logged in' redirects user log

java - Stream radio is not working with Media Player in Android -

i'm working in android application. have problem trying playback radio stream. url is: http://2583.live.streamtheworld.com/xhmfmaac?type=.flv i try with: http://2583.live.streamtheworld.com/xhmfmaac and with: http://2583.live.streamtheworld.com/xhmfmaac?type=.mp3 also tried find url .mp3 format didn't find it. idea how can work? edit i'm going try library. https://code.google.com/p/android-openmxplayer/ . have tested above urls , works great.

java - Troubles with splitting and parsing arguments to the main() method -

i'm having difficulties output main method. if used enters bunch of random strings, program should integers , group them pair. example, if user enters 3 2 54 -5 , output should be: (3,2) (54,-5) or, example: if input 1 2 3 , program should output (1,2) because there not other pair found number 3 . main point of program gather numbers pairs. exception thrown if program cannot convert string int. smb please me out? public static void main(string [] args) throws exception { int [] number = new int [args.length]; try { (int = 0; < args.length; i++) { number[i] = integer.parseint(args[i]); system.out.println("("+i+",")); } } catch (numberformatexception e) { system.out.println(e.getmessage()); } } i think can use split method string class if know user use format, cannot parse them because user en

github - How to get git to display the most recent n commits from all online branches -

i new git. have repository on git hub.com. committed new file github repository. when check last commit changes using log command shows commits on local repository. github repository collaborative repository. question have check recent commits if others commits file. thanks. once fetch remote repository, have commits in local repo. have branches of remote repo: they're prefixed origin/ (if remote called origin). can list them git branch -r so can this: git fetch origin n=3 #say want see last 3 commits of each remote branches remote_branch in $(git branch -r | grep origin); echo "showing branch $remote_branch" git log -$n $remote_branch done that if want stick command line. otherwise might easier use gitk: sudo apt-get install gitk #or other way install depending on platform git fetch gitk --all # flag --all implies "show every branches"

html - make class start on bottom of div problems -

trying make span start @ bottom of div found answer here. not working way want it, don't want them layer each other. https://jsfiddle.net/j96s0pn6/ #wrap { height: 200px; position: relative; } .msg { bottom: 0; position: absolute; } <div id="thewwrap"> <div id="wrap"> <span class="msg"><b>nickname: </b>text</span><br> <span class="msg"><b>nickname: </b>text</span><br> </div> <form id="theinput"> <input size="35" id="message"> <input type="submit"> </form> </div> you can rearrange html #wrap , wraps around form well. give #thewwrap relative position, , second wrap absolute position instead of individual classes: js fiddle html <

gcc - How to convert a .o file back to a .c file in C? -

i'm sure there's way. i'm new c , research on led me nowhere. there command can convert .o file .c? usually can determine assembly language object file, using disassembler . here few links discussion on topic, e.g., objdump : objdump - gnu binary utilities disassembling binary in linux using gcc produce readable assembly? linux interactive disassembler reverse-compiling (decompiling) harder. here few links help: what's c decompiler? reverse engineering resources - decompilers

php - How to escape asterisk and question mark using RLIKE in PDO? -

i have query search posts content. i'm still using mysql 5.5 innodb rlike seems 1 of choices: $sql = "select title,content table1 content rlike ?"; $i = 1; $users = $dbh->prepare($sql); $users->bindvalue($i++, $purifier->purify($_get['content']), pdo::param_str); $users->execute(); but found when enter asterisk or question mark parameter value (e.g www.site.com?content=*), i'm getting sqlstate[42000]: syntax error or access violation: 1139 got error 'repetition-operator operand invalid' regexp. how can avoid error? * , ? 2 special characters cause error? rlike requires valid regular expression operand. means 'yes, there other characters * , ? cause error.' how avoid? depends on want achieve exactly. easiest avoid regular expressions altogether. if need user can enter regular expression, best way validate use in query , catch error if malformed. if want find content contains string, using like more re

assembly - C code snippets explanation -

i'm trying convert following c code snippets assembly, problem can't understand these simple c code. written in abnormal way think. can't transfer assembly. please me a = (a >= c); b = (c < d) || (b > d); = (a != d) && (b != c) look if a>=c return true. a=1 otherwise a=0. in second case if c<d (c less d ) or b>d (b greater d) 1 of them true b=1. if both false b=0. if not equal d , b not equal c a=1 otherwise false(0). && b = 1 if a!=0 , b!=0 = 0 if a=0 or b=0 or (a=0 , b=0) || b = 1 if a!=0 or b!=0 = 0 if a=0 , b=0 note: if (a && b) , found 0 b not checked. if (a || b) , found 1 b not checked. if b expression not executed per information stated above. called short circuit evaluation .

c++ - What motivates Stroustrup's order of preference for resource management techniques? -

Image
the following slide bjarne stroustrups talk "the essence of c++": do understand techniques following simple examples (values, raw pointers, smart pointer resource members/subobjects)?: 1. class foo{ std::vector<bar> subobj; int n; pubic: foo(int n) : n(n) { subobj.push_back(bar("snickers")); } }; 2. class foo{ std::vector<bar>* subobj; int n; public: foo(int n) : n(n){ subobj = new std::vector<bar>(); subobj->push_back(bar("snickers")); } ~foo() { delete subobj; } }; 3. class foo{ std::unique_ptr<std::vector<bar> > subobj; int n; public: foo(int n) : n(n){ subobj(new std::vector<bar>()); subobj->push_back(bar("snickers")); } }; why 1. preferable on 2.? if instantiate foo object , dereference in order value of small n member, vector member loaded m

javascript - remove all Decimals and single numbers from array / string -

so script generates big blob of "piano notes" similar to... var songnotes = "..."; the large piano notes content and problem between piano notes need [also in fiddle] there empty ",," , decimal numbers.. cant figure out how remove empty ,, , decimals big "1.0416666666642413,0.625,0,g3,1498.9583333333358,,0,c3,1.0416666666642413,0.625,0,c3" , want them removed except the needed words are var therightones = "s2,as2,cs3,ds3,fs3,gs3,as3,gs3,cs4,ds4,fs4,cs3,as4,gs4,ds5,a2,cs4,b2,c3,a3,ds4,b3,c4,as3,gs2,e3,c3,c4,cs3,ds3,a4,fs3,gs3,as3,g3,f3,b4,c5,a3,d4,as2,e4,g4,d3,b3,b2,f4,a2,d4,e4,cs5,gs1,e2,c2,c3,cs2,ds2,a3,fs2,gs2,as2,g2,f2,b3,c4,a2,d3,as1,e3,g3,d2,b2,b1,f3,a1,d5,e5"; so can give me clue on how can accomplished? if needs more info ready oblige so.. regards - adarsh hegde var notesarr = songnotes.split(","); var len = notesarr.length; while(len--) { if(!notesarr[len] || !isnan(parseint(notesarr[l

javascript - Print: Background colors missing in FullCalendar -

Image
i using fullcalendar in application. issue facing while doing print of calendar: orignal view: http://fullcalendar.io/ on printing page (just ctrl+p), colors lost: has else faced issue? there fix it? if using bootstrap 3, print.css file causes issue *:after { // background: transparent !important; note: removed fullcalendar printing color: #000 !important; // black prints faster: h5bp.com/s box-shadow: none !important; text-shadow: none !important; }

sql - Use a join or a subquery to select a single column -

i'm writing app has chat function , using postgres db. there 4 tables involved- users (holds user data, including id), groups (holds list of groups, including groupid), group_users (holds mapping of groupids userids, 1 many), , groupchats (holds mapping of groupid userid entered chat , text itself). tables have obvious foreign keys between them. i want rows in groupchats belong given groupid. wish if person requesting in group. want name of person talking each row (remember row stores user ids). the following i've come with. i'm curious if there's better way? i'm using subquery name of user in current row. should using join instead? also, believe second subquery (for exists clause) should run once, correct in that? or better off in client side logic (making 2nd round trip db)? expext db can optimize this. select userid, chat, time, (select firstname users id=groupchat.userid) groupchat groupid=$1 , exists (select userid

HTML and Javascript code issue -

i have created 2 html pages, 1 called username.html , other -- resume.html. what want is, no matter page open, i'll redirected login page. if open username.html , opened , fill in username , password fields, resume.html opens. here code of login page: <html> <head> <title>login page</title> </head> <body> <h1 style="font-family:comic sans ms;text-align:center;font-size:50pt;color:#ff00ba;"> need login :) </h1> <div style="text-align:center;"> <form style="font-family:comic sans ms;"> username<br> <input type="text" name="userid"/><br> password<br> <input type="password" name="pswrd"/> <br><br> <input style="font-family:comic

scala - Play framework: how to monitor number of active sessions with standard session API? -

in play framework there api create session, put data session , discard session. have insight things how many active sessions in installation, how many data in volume bound them, etc. there means deal this? play stateless nature, no session exists on server tracked or monitored. when use session api create cookie sent every request / response from/to browser. this cookie doesn't have timeout or expiration date, hence persist long browser open. can implement own session timeout mechanism setting last access time on session cookie , compare desired timeout on every request.

python - XORing list of binary values -

i make simple function encodes string. idea follows: change string list of corresponding binary values. change chosen number corresponding binary value. xor each other. change string. so code: def encode (text, key): textbit=[] encoded=[] keybit=bin(key) in text: textbit.append(bin(ord(a))) x in xrange (0, len(textbit)): encoded.append(textbit[x])^(keybit) return 0 word='abcdef' encode(word, 243) while i'm trying run it, error returned: typeerror: unsupported operand type(s) ^: 'nonetype' , 'str'. could tell me how fix that? your error because of parenthesis: want add result of xor instead try xor encoded.append(...) returns. but many other problems, have fixed of them not (you want add return , convert string too): def encode(text, key): textbit = [] encoded = [] in text: textbit.append(ord(a)) x in textbit: encoded.append(x ^ key) word = 'abcdef' encode(word, 243)

GlassFish Metro: Dependency injection in JAX-WS -

i require stateful web service , got working far using @httpsessionscope . service runs in servlet provided osgi httpservice. servlet created builder service in osgi environment. builder has services need injected web service when gets instantiated. know have @inject , @resource annotations purpose, cannot find way add external object glassfish metro objects injected services. have example: @httpsessionscope @webservice public class aimpl implements { @inject private adelegated delegated; ... } how can declare object of adelegated injected web service? there sort of resourceinjector in glassfish metro allows me register object injection?

scala - Slick 3.0 many-to-many query with the join as an iterable -

i've created many-to-many collection using slick 3.0, i'm struggling retrieve data in way want. there many-to-many relationship between events , interests. here tables: case class eventdao(title: string, id: option[int] = none) class eventstable(tag: tag) extends table[eventdao](tag, "events") { def id = column[int]("event_id", o.primarykey, o.autoinc) def title = column[string]("title") def * = ( title, id.?) <> (eventdao.tupled, eventdao.unapply) def interests = eventinterestqueries.query.filter(_.eventid === id) .flatmap(_.interestfk) } object eventqueries { lazy val query = tablequery[eventstable] val findbyid = compiled { k: rep[int] => query.filter(_.id === k) } } here's eventsinterests: case class eventinterestdao(event: int, interest: int) class eventsintereststable(tag: tag) extends table[eventinterestdao](tag, "events_interests") { def e

How to chain together jQuery animations slideUp and slideDown for two different elements -

how modify rendercalculator function slideup recipes , slidedown results of recipe calculation? both animation functions should chained together. saw answers slideup , slidedown, i'm not sure place code in function. var rendercalculator = function(base) { var costhtml = $("<button>calculate weekly total</button>"); var resultshtml = $("<div id='results'></div>"); costhtml.on("click", function(event) { //total //grab inputs on page $(".recipeselector").each(function(i,input) { if (input.value > 0) { //figure out how many recipes made a1.bakedrecipes.push({recipe:a1.recipes[input.id],amount:input.value}); } }); //print out required total information resultshtml.empty(); //delete old info calculateandprinttotals(resultshtml); }); base.append(costhtml);

android - Google Maps Not showing Navigation option -

i have google maps in android application. problem after have intialized marker specific location, , when try click on marker, navigation option not come instead, zoom view options. happened when imported maps code working project(in getting navigation option). how change zoom view controls navigation controls. here code. maps.java public class maps extends activity { static final latlng college = new latlng(13.1172245 , 77.6341758); private googlemap googlemap; float lat,lon; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mapsshow); try { if (googlemap == null) { googlemap = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); googlemap.movecamera(cameraupdatefactory.newlatlngzoom(college, 15)); } googlemap.setmaptype(googlemap.map_type_normal); @suppresswarnings(&quo