Posts

Showing posts from July, 2012

java - Digest auth with Spring Security using javaconfig -

so i'm trying create digest authentication spring following documentation trying translate xml "requirements" in java requirements. let's have xml in docs: <bean id="digestfilter" class= "org.springframework.security.web.authentication.www.digestauthenticationfilter"> <property name="userdetailsservice" ref="jdbcdaoimpl"/> <property name="authenticationentrypoint" ref="digestentrypoint"/> <property name="usercache" ref="usercache"/> </bean> <bean id="digestentrypoint" class= "org.springframework.security.web.authentication.www.digestauthenticationentrypoint"> <property name="realmname" value="contacts realm via digest authentication"/> <property name="key" value="acegi"/> <property name="noncevalidityseconds" value="10"/> </b...

java - OncePerRequestFilter doesn't include last character from response body -

i trying implement content digest header in rest api. when creating digest response omits last character. public class contentdigestfilter extends onceperrequestfilter { @override protected boolean shouldnotfilterasyncdispatch() { return false; } @override protected void dofilterinternal(httpservletrequest request, httpservletresponse response, filterchain filterchain) throws servletexception, ioexception { httpservletresponse responsetouse = response; if (!isasyncdispatch(request) && !(response instanceof contentcachingresponsewrapper)) { responsetouse = new httpstreamingawarecontentcachingresponsewrapper(response, request); } filterchain.dofilter(request, responsetouse); updateresponse(request, responsetouse); } private void updateresponse(httpservletrequest request, httpservletresponse response) throws ioexception { contentcachingresponsewrapper responsewrapper = webutils.getnativeresponse(response, content...

Karabiner: Change double quote to single -

is possible replace double quote key single quote karabiner (keyboard customizer os x)? https://pqrs.org/osx/karabiner/ yes, think so. how private.xml works, can open via misc & uninstall tab. however, think changing actual key codes need seil, can karabiner alone remapping shift_l + quote . you might end w/ s.th. this: <?xml version="1.0"?> <root> <item> <name>double quote single quote</name> <identifier>private.double_quote_to_single_quote</identifier> <autogen> __keytokey__ keycode::quote, modifierkey::shift_l, keycode::quote </autogen> </item> </root> this guess though, brings in right direction.

mysql - sql query for product taging to get product having 3 specific tag -

i have database design having 3 table below: products pid pname pprice tags tag_id tag_name products_tag ==> unique(pid,tag_id) pid tag_id 65 1 65 3 66 2 88 2 88 4 88 3 i have requirement pid have tagid = 2 , 3 , 4. result in case 88(pid). sql query problem statement? select pid products_tag tagid in (2,3,4) group pid having count(tagid) = 3

dependency injection - StructureMap on Xamarin: System.Reflection.TypeExtensions not found -

it seems cannot use structuremap: [mono] class system.reflection.typeextensions not loaded, used in system.reflection.typeextensions, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a i added system.reflection.typeextensions : <package id="system.reflection.typeextensions" version="4.0.0" targetframework="monoandroid60" /> i can see dll in references. still same error. any hints? i need structuremap because couldn't pass constructor parameters when used simpleinjector. in strcuturemap it's easy: _container.with(offer).getinstance<offerdetailsviewmodel>(); // "offer" passed ctor of offerdetailsviewmodel

c# - Find Strings with certain Hamming distance LINQ -

if run following ( thanks @octavioccl help ) linq query: var result = stringslist .groupby(s => s) .where(g => g.count() > 1) .orderbydescending(g => g.count()) .select(g => g.key); it gives strings occur in list atleast twice ( but matched i.e. hamming distance =0 ). i wondering if there elegant solution ( all solutions have tried far either use loops , counter ugly or regex ) possible can specify hamming distance in where clause strings lie within specified hamming distance range? p.s: strings of equal length update really krontogiannis detailed answer. mentioned earlier, want list of strings hamming distance below given threshold. code working fine ( thanks again ). only thing remaining take strings out of 'resultset' , insert/add `list' basically want: list<string> outputlist = new list<string>(); foreach (string str in patternslist) { var rs = wordslist .groupby(w => hamm...

php - Symfony 3 : DateTime null even if it is specified in the Entity constructor -

i'm under symfony 3.0.6 use loadfixtures entity : <?php namespace appbundle\entity; use doctrine\orm\mapping orm; /** * categorie * * @orm\table(name="categorie") * @orm\entity(repositoryclass="appbundle\repository\categorierepository") */ class categorie { /** * @var int * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ private $id; /** * @var string * * @orm\column(name="libelle", type="string", length=100) */ private $libelle; /** * @var datetime * * @orm\column(name="created_at", type="datetime") */ private $created_at; /** * @orm\manytoone(targetentity="\appbundle\entity\user", inversedby="categories") * @orm\joincolumn(name="user_id", referencedcolumnname="id", ondelete="ca...

html - Php Post Action -

i want post action according select entries. however, code not work. how can do? thank you. <form action=<?php echo $filename; ?> method="post"> <br/> <input type="submit" name="select" value="a" onclick="selecta()" /> <br/> <input type="submit" name="select" value="b" onclick="selectb()" /> <br/> <input type="submit" name="select" value="c" onclick="selectc()" /> </form> <?php function selecta(){ $filename = "a.php"; } function selectb(){ $filename = "b.php"; } function selectc(){ $filename = "c.php"; } ?> you cannot use php dynamically change html. use javascript: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2...

c++ - Why Allow ADL lookup for template name binding? -

i know dependent names, binding must deferred point of instantiation. think following code: #include <iostream> using namespace std; template <class t> void g(t a) { f(a); } namespace mynamespace { class x{}; void f(x) { cout << "f(x)\n"; } } void f(int i) { cout << "f(int)\n"; } int main() { g(mynamespace::x{}); //1. print f(x) //g(1); //2. not compile return 0; } for 1, compilers tested(vc++, gcc, clang) find mynamespace::f(x) adl. that's fine, in accordance standard. however, gcc , clang cannot compile 2. because standard not allow directly searching functions in instantiation context. that's standard requires (fine, vc++ violates standard in respect). i know standard not allow searching functions in template instantiation context safeguard odr. however, why allow adl examines function declarations visible template instantiation context? cause violation of odr well? conside...

project Euler #13 c++ -

this question has answer here: why iostream::eof inside loop condition considered wrong? 4 answers https://projecteuler.net/problem=13 work out first ten digits of sum of following one-hundred 50-digit numbers. i try solve using c++ in xcode. saved numbers in file , built got wrong answer. here code: #include <fstream> #include <iostream> using namespace std; int main(void) { double sum = 1; double num; ifstream fin("/users/pwd/programs/projecteuler13/num.txt"); while (fin) { fin >> num; sum += num; } fin.close(); cout.precision(12); cout << sum << endl; return 0; } i got result: 5.59087976462e+51 so first 10 digits of sum: 5590879764. wrong. wrong code? several issues can see: starting sum 1, although highly unlikely change result. using floating-point introduces inaccur...

playframework - IOExceptions with H2 database -

recentently ioexceptions play app uses h2 database. this: caused by: java.io.ioexception: block not found in id [1, -68, 2, 2] [1.4.187/50] @ org.h2.mvstore.streamstore$stream.read(streamstore.java:466) ~[com.h2database.h2-1.4.187.jar:1.4.187] @ sun.nio.cs.streamdecoder.readbytes(streamdecoder.java:284) ~[na:1.8.0_40] @ sun.nio.cs.streamdecoder.implread(streamdecoder.java:326) ~[na:1.8.0_40] @ sun.nio.cs.streamdecoder.read(streamdecoder.java:178) ~[na:1.8.0_40] @ java.io.inputstreamreader.read(inputstreamreader.java:184) ~[na:1.8.0_40] @ java.io.bufferedreader.fill(bufferedreader.java:161) ~[na:1.8.0_40] @ java.io.bufferedreader.read1(bufferedreader.java:212) ~[na:1.8.0_40] @ java.io.bufferedreader.read(bufferedreader.java:286) ~[na:1.8.0_40] @ org.hibernate.type.descriptor.java.datahelper.extractstring(datahelper.java:88) ~[org.hibernate.hibernate-core-4.3.11.final.jar:4.3.11.final] it might issue talking in https://groups.google.com/forum/#!topic/h2-database...

excel - how to sum first 5 values in column B corresponding to a particular text in column C? -

i want add first "n" number of values of 1 column b when corresponding values of column c in same row equals "text" to non-array formula suggest in d1: =if((c1="text")*(countif(c$1:c1,"text")=5),sumif(c$1:c1,"text",b$1:b1),"") and copy down. a different approach using array formula like: {=sumif(c1:index(c1:c100,small(if(c1:c100="text",row(c1:c100)),5)),"text",b:b)} which whole work in 1 step ;)

python - How can I send a image by using mosquitto? -

i'm student studying mqtt , i'm trying send jpg image using mqtt mosquitto broker(pub , sub) in raspberry pi2. i've solved many error, however, doesn't work. this python code pub.py(modified) import paho.mqtt.client mqtt def on_publish(mosq, userdata, mid): mosq.disconnect() client = mqtt.client() client.connect("test.mosquitto.org", 1883, 60) client.on_publish = on_publish f=open("b.jpg", "rb") #3.7kib in same folder filecontent = f.read() bytearr = bytearray(filecontent) client.publish("image",bytearr,0) client.loop_forever() and it's sub.py(modified) import paho.mqtt.client mqtt def on_connect(client, userdata, rc): print("connect" + str(rc)) client.subscribe("image") def on_message(client, userdata, msg): print "topic : ", msg.topic f = open("/tmp/output.jpg", "w") #there output.jpg different f.write(msg.payload) f.close() ...

php - How set option value selected for select tag with existing values -

the $output array return option vlaues select tag print <?php print_r($store);?> , when tried update form need show store selected value , select list must have other existing values same before come $output . model: public function getstore() { $this->db->select('*'); $store = $this->db->get('tbl_store_info'); $data = $store->result(); $output = array(); $output[]='<option value="" disabled selected>select store</option>'; foreach ($data $row) { $output[]= '<option value="' . $row->store_id . '">' . $row->store . '</option>'; } return $output; } controller: public function editemployee($id='') { $empdata= $this->commonmodel->getemployee_by_id($id); $data['emp_list'] = $empdata[0]; $data['store']= $this->commonmodel...

vb.net - LINQ to SQL Order By fails -

im having little problem trying order row.timestamp sql datetime. believe picture says more thousand words, here one! :) picture as can see mixes other hours in it, have googled allot before asking question here. appreciated. thanks. using db new basecontrollerentities dim query list(of tbllog) = (from row in db.tbllogs select row order row.timestamp ascending).tolist each item tbllog in query addtolistview(item) next end using private sub addtolistview(byval row tbllog) dim lvitem new listviewitem(row.timestamp) lvitem.subitems.add(row.logmessage) listview1.items.add(lvitem) end sub

cmusphinx - Is it possible in sphinx 4 to recognize all possible words -

though having problems make sphinx 4 work working great. since grammar finite whether jsgf or n-gram, not able make sphinx recognize every possible word or sentence. want build voice based google search. since search may have possible word or combination of words. troublesome add dictionary words in grammar. kindly help. no, it's not possible. every speech recognizer including 1 google uses limited vocabulary. google uses large 1 of 1.5 million words still limited. cmusphinx. can verify trying recognize rare proper names, it's impossible google. the practical solution use large language model large vocabulary. it's open research question detect new words in audio stream , add them recognizer spoken or other type of feedback.

java - Loading a local html file on jar into web engine -

i'm having problem in loading html file application onto web engine. currently, if run application throw intellij ide. html page being loaded correctly! when make project , run application terminal. html file isn't being loaded @ all. my code loading html page web engine. webengine = wv.getengine(); we.setjavascriptenabled(true); string htmlfile = getclass().getresource("/html/index.html").toexternalform(); system.out.println(">>>"+htmlfile); we.load(htmlfile); why have println ? check path of html page. seems when run on project intellij. application runs correctly. shown under: >>>file:/developer/liss-sde/out/production/liss/html/index.html but when on terminal. prints me don't understand. >>>jar:file:/users/damien/desktop/liss%7csde/liss.jar!/html/index.html why put jar: @ beginning? why putting ! program .jar ? , if compare other print, totally different! i extracted .jar file check if directory , h...

ios - UITableView stops updating content while scrolling through view? -

i have uitableview works fine , updates fine. have timer updates each uitableview label , progress view, when user scrolling table view stops updating/refreshing content (labels , progress view) in uitableview until done scrolling. in addition content not updating have found when user scrolling entire app hangs. have 2 timers , put print statement in both, neither prints when user scrolling. have not been able find swift or swift 2 solution this. this unrelated swift whatsoever. you scheduled nstimer using default method, results in adding runloop in way it's not triggered while scrolling. need add main runloop nsrunloopcommonmodes mode instead. e.g. let timer = nstimer(timeinterval: 1.0, target: self, selector: #selector(update), userinfo: nil, repeats: false) nsrunloop.mainrunloop().addtimer(timer, formode: nsrunloopcommonmodes)

android - How do i add actionbar sherlock to my project on BitBucket? -

i have project using actionbarsherlock. set , works. however wanted add actionbarsherlock project repository of project on bitbucket. no 1 else has set actionbarsherlock application can fork , have no problems. i added actionbarsherlock folder, used when importing project , creating initial actionbarsherlock project, git folder. has many classes , resources figured there better way add bitbucket instead of committing of things individually. actionbarsherlock available on central maven repository, need add builder maven or gradle project, , add correct dependency. this best solution, if later add libraries project, going add them in repository ?

javascript - Is calling a method of `unsafeWindow` in GM script with privileges a vulnerable practice? -

i have script like // ==userscript== // @grant gm_getvalue // @grant gm_setvalue // @include * // @run-at document-start // ==/userscript== var foo = gm_getvalue('foo'); var _open = unsafewindow.open; unsafewindow.open = function(){ if( /* */ ){ _open(); } settimeout(function() { gm_setvalue('bar', 'bar'); }, 0); } maybe malicious site could add getter window.open execute malicious code when var _open = unsafewindow.open add setter window.open execute malicious code when unsafewindow.open = /*...*/ replace window.open malicious function, execute when use _open() could way malicious site gain privileges use gm_getvalue or gm_setvalue , or variables defined in script (like foo )?

Where and how to save SQL Server authentication in C#? -

i developing c# windows forms application connects sql server 2008. , allowing user configure connection sql server when running app first time using form created, allow user chose between windows or sql authentication. in windows authentication save connection string in appconfig, when using sql authentication cannot save username , password of sql server there because exposed using computer because it's xml file, , don't want encrypt password key because heard it's easy decrypt , can't use hash because not able connect server hashed password. i searched lot online , didn't find related should ? thanks encrypt password before storing in app.config. you can find info on how encrypt string in answer(s) stackoverflow question: encrypt/decrypt string in .net

scripting - AutoIT send() commands not working properly -

so have game client 2 input fields: id pass , 1 button: login. login credentials are: $id=1234 , $pass=a_bcd . i'm using autoit scripting automate login process (my script automatically inputs id , pass in login fields) , autologin() function looks like: send($id + "{tab}") sleep(10) send($pass + "{enter}") sometimes works fine, script introduces 1234a- or 1234a_ in id field , rest of characters in pass field. tried many solutions controlsend("game","","","1234{tab}a_bcd{enter}") , or changing sleep() values, etc. input still goes wrong sometimes. figured send delay or sleep have problem, still don't know do. manually inserting id , pass works properly. solving of problem? 2 solutions: you add strings &: send($id & "{tab}") send($pass & "{enter}") if not work separate it: send($id) send("{tab}") send($pass) send("{enter}") and don...

drop down menu - bootstrap3 - caret reverse on click in navbar-nav -

i'm using bootstrap 3, , found few lines of css, work great, making caret reverse (upside-down) on click. .navbar-nav .open > > b.caret { border-top: none; border-bottom: 4px solid; } for reference, (pretty standard) dropdown: <ul class="nav navbar-nav navbar-right"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> title text <b class="caret"></b> </a> <ul class="dropdown-menu"> <li>some submenu text</li> <li>some submenu text</li> </ul> </li> </ul> why happening? understand it. thank you! bootstrap caret uses popular trick draw triangle in css. you can see here css code top , bottom arrows (triangles): .arrow-up { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; bord...

shinyapps - Shiny app issue - Reading data into a server.R function -

i have list of 4 large dataframes (size 5.9mb compressed) in rdata file (dtall.rdata) trying read server.r function using code provided below, "error: [on_request_read] connection reset peer" error message" , file read single character "dtall" when separately load dtall.rdata r global environment app runs locally. clear dtall.rddata file global environment , try app load , run error message above. i have tried using readrds, not work either, error message: "error in readrds("data/dtall.rdata") : unknown input format the file dtall.rdata loads correctly outside shiny scripts using function load("data/dtall.rdata" below code of server.r function server.r predictor <-source("predictor.r") dtall <- load("data/dtall.rdata") shinyserver(function(input, output) { wordprediction <- reactive({ text <- input$input wordprediction <- predictor(text)}) output$pre...

c++ - Huge performance difference query mysql database with same golang snippet -

i reimplement project golang recently. project implemented c++. when finished code , have performance test. i'm shocked result. when query database c++, can 130 million rows result in 5 mins. golang, it's 45 mins. when separate code project , build code snippet, it's finished in 2mins. why have huge difference performance result? my code snippet : https://gist.github.com/pyanfield/2651d23311901b33c5723b7de2364148 package main import ( "database/sql" "fmt" "runtime" "strconv" "time" _ "github.com/go-sql-driver/mysql" ) func main() { runtime.gomaxprocs(runtime.numcpu()) // defer profile.start(profile.cpuprofile, profile.profilepath(".")).stop() dbread, err := connectdb("test:test@tcp(127.0.0.1:3306)/test_oltp?charset=utf8&readtimeout=600s&writetimeout=600s") if err != nil { fmt.printf("error happend when connecting db. %s\n...

PHP heredoc assignment to a variable error -

i have following code display form variable using heredoc. following error; parse error: syntax error, unexpected '' (t_encapsed_and_whitespace), expecting identifier (t_string) or variable (t_variable) or number (t_num_string) in c:\xampp\htdocs\php\2000.php on line 38 line 38 is: <form method="post" action="$_server['php_self']"> <?php if ( !$_post ){ $display_block = <<<eob <form method="post" action="$_server['php_self']"> <p> <label for="email"> e-mail address: </label> <br/> <input type="email" id="email" name="email" size="40" maxlength="150"/> </p> <fieldset> <legend> action: </legend> ...

Ruby on Rails: Call controller method on specific model from view -

i new ruby , rails. have view displays list of course offerings. <% if defined?@offerings %> ..... <% @offerings.each |offering| %> <tr> <td><%=offering.semester %></td> <td><%=offering.location %></td> </tr> <%end %> i need add enroll button associated each offering. enroll button should call offerings controller method decrements specific offerings capacity attribute. how can bind each button respective offering? or alternatively how can pass correct offering parameter controller method? add <td> , : <td><%= link_to "enroll", your_method_path(offering) %></td>

ios - How to draw a circle of dots that are individual nodes in swift (SpriteKit) -

Image
hi new swift , spritekit have been working on game. in game, want have circle of dot objects. have looked cannot seem figure out. what wanted circle of dots each individual node use able add animations each individual node. is there way draw multiple shapes in circular pattern this? i want kind of this. i appreciate , help. continue research , try , figure stuff out. thanks! you can draw circle of dots few lines of code: spritekit: p.s. change pattern parameters obtain want exactly.. func circleofdots() { let circlepath = uibezierpath(arccenter: cgpoint(x: 200,y: 200), radius: cgfloat(100), startangle: cgfloat(0), endangle:cgfloat(m_pi * 2), clockwise: true) let shapenode = skshapenode() shapenode.path = circlepath.cgpath shapenode.position = cgpoint(x:cgrectgetmidx(self.frame)-200, y:cgrectgetmidy(self.frame)-200) //change fill color shapenode.fillcolor = uicolor.clearcolor() //you can change str...

django - how to pass template variables to javascript -

friends, trying pass template variable javascript in order create chart. not getting it. django considers js files static files. dynamic template variables aren't available javascripts. i tried this: passing template variables javascript but didn't either. 1 variable passed. rest didn't. def profile(request,username): try: u = user.objects.get(username=username) questions = question.objects.filter(user=u) answers = answer.objects.filter(user=u) docs = document.objects.filter(user=u) except user.doesnotexist: pass return render(request,"auths/profile.html",locals()) also, described in above link, profile.html is <input type="hidden" value="{{ u.username }}" id="username" /> <input type="hidden" value="{{ docs.count }}" id="docs" /> <input type="hidden" value="{{ questions.count }}" id="questions...

image processing - Matlab - create a line mask -

Image
i have mask of size mxn. i add line mask, such points passes through set true. the line defined 2 points: (x1,y1),(x2,y2). what best way achieve result? please notice have image processing toolbox. example possible input, , desired output: %generates mask m = 152; n=131; mask = false(m,n); %example possible input points y1 = 68; x1 = 69; y2 = 28; x2 = 75; % code adding line mask% imshow(mask); desired result: thanks! we can first determine how many pixels there between 2 points computing distance (in pixels) between points. can use linspace create linear spacing of points between 2 end points specifying number of points. can round result pixel coordinates. then can use sub2ind set these values within mask 1 . % distance (in pixels) between 2 endpoints npoints = ceil(sqrt((x2 - x1).^2 + (y2 - y1).^2)) + 1; % determine x , y locations along line xvalues = round(linspace(x1, x2, npoints)); yvalues = round(linspace(y1, y2, npoints)); % replace rele...

php - SQL query doesn't get values -

the sql query returns array in browser if there values in database. have tried query in phpmyadmin , works not in php document. require_once('connect.php'); $query = "select `id` `questions` round='1' , year='2016'"; $sql = mysqli_query($dbconnect, $query); $row = mysqli_fetch_array($sql, mysqli_assoc); almost same query works in different php documents. suggestions wrong? should query should return integers. $query = "select `id` `questions` round='1' , year='2016'"; you're selecting id column. if wish echo more columns, need add them in query. i.e.: $query = "select `id`, `col2`, `col3` `questions` round=1 , year=2016"; then loop on results: while ($row = mysqli_fetch_array($sql, mysqli_assoc)) { echo $row['id']; // echo "<br>"; // echo $row['col2'] . "<br>"; // echo $row['col3']; } check errors on query ,...

sql - Use command button to open selected record on a form without filtering? -

i have continuous form displays small amount of data each record in table projectt (i.e. project name, status) , command button in footer open selected record in expanded single form (where of relevant info displayed). at first set button using access's wizard, realized access opens selected record filtering data on form. problem once expanded form opened, want user able move other records without having select unfilter results. if change button on continuous form open expanded single form, there code can run make form open selected record without putting filter on? initially thought set expanded form's (named projectf) default value forms!projectlistf!projectid (where projectlistf continuous form , projectid autonumber primary key projectt), not successful, think because there more 1 projectid displayed on projectlistf. another thing consider have button on main menu form opens projectf form in data entry mode prevent user inadvertently changing/deleting existing...

php - Jquery Ajax error handling fail -

i'm trying handle errors sent php script. here code: <script> $(document).ready(function() { $('#signupform').submit(function() { $.ajax({ type: 'post', url: "process.php", data: $("#signupform").serialize(), success: function(data) { if ((data == "incorect email format.") || (data == "username must between 6-32 signs , include 0-9, a-z characters.") || (data == "password must between 8-32 signs , include 0-9, a-z characters.") || (data == "passwords not match.") || (data == "username taken, please try one.")) { $('#errors').show(); $('#errors').html(data); } else { window.location.href = "http://localhost:8888"; } } }); return false; }); }); </script> ...

ios - TableView cell not resizing after changing imageView height constraint based on Image height downloaded using SDWebImage (AUTOLAYOUT) -

i'm using autolayout.this code using under cellforrowatindexpath : cell.chatimage.sd_setimagewithurl(nsurl(string: newsfeed.postimage!), placeholderimage: uiimage(named: "default_profile"), completed: { (image, error, cachetype, imageurl) -> void in let height = ((image?.size.height)! / (image?.size.width)!) * (tableview.bounds.width - 16) cell.chatimageheight.constant = height self.view.layoutifneeded() }) the cell doesn't resize. resizes after scrolling. should do? since i'm using autolayout, i'm not implementing heightforrowatindexpath . i've mentioned uitableviewautomaticdimension , estimatedrowheight . i think have call self.view.setneedslayout() make whole view layout fixing constraints cell.chatimage.sd_setimagewithurl(nsurl(string: newsfeed.postimage!), placeholderimage: uiimage(named: "default_profile"), completed: { (image, error, cachetype, imageurl) -...

java - Autocomplete with generic types in concrete class of implementation -

when coding java in ecipse (kepler), having problem when making new variable of generic interface type , autocomplete concrete implementation when initializing variable. i'm talking generic interfaces/concrete implementations list/arraylist , map/hashmap. example: type ide: list<string> stringlist = new arrayl then, use autocomplete (ctrl+space) fill code arraylist() , ide puts code: list<string> stringlist = arraylist<>() so ignoring string generic type parameterization. ideas on how can eclipse ide detect generic type parameter in variable declaration , place type parameter of implementation's constructor? used work me automatically in eclipse, stopped working on last couple of months. not sure configuration change did workspace cause happen...besides upgrading eclipse juno eclipse kepler. eclipse ignore generic type if auto-completed new arraylist() , instance of raw type. but auto-completes new arraylist<>() , uses diamond o...

java ee - Using .BINDING File with MDB in Jboss EAP6.4 -

i writing standard java ee 5 application , need consume jms messages (hornetq) mq serverv8. mq admin has provided .bindings file mq configuration. after searching web, not able find way use .bidings file mdbs. have tried using standard activation spec. works fine. that, jms properties need in jboss or ee specific configuration files. can please tell way use .bindings file mdb? how decide jndi , initial context factory name ? while possible use .bindings file mdb activation specification, turns out impractical. can specify destination in both .bindings file , mdb activation spec, not connection factory. attributes configure connection factory (i.e. host, port, channel, etc.) configured individually in activation spec. what can use .bindings file configure jms messaging bridge mq jboss. then, mdb listens on local hornetq destination. in order working, need to: 1) create ibm mq client module. messaging bridge not using ibm jca. on unix mq server, find client jars ...

Ruby on Rails, Enum user conditions from a different table -

i have enums declared follows in table separate main users table (user.rb). sign users , give them role table: school_user.rb class schooluser < activerecord::base belongs_to :user belongs_to :school enum user_type: [:school, :student, :parent, :teacher] def school? end def teacher? end def student? end def parent? end end i don't think have define each role here tried it. i using boolean method separate users before switched enum. used use method type restrict views based on role: ...unless current_user.teacher?... this worked fine have enums declared in different model users table not work. a user has role through relationship between user.rb , school_user.rb. works. i'm looking way set access based on user role/type in views above. i hope not presume have change conditions throughout application? i tried: ...unless current_user.school_user.teacher?... and other variations. would appreciate help. thanks. edit: user.rb clas...

javascript - how would i append dropdown html/css to jquery 1 line body -

i want append dropdown box using html/css. problem have 1 id in body, therefore don't know how this. if can post example following code posted, appreciated. i foudn i'm not sure how set id's in code , not sure if ok. var someelement = $('<div/>', {id: 'someid'); $('canvas').after(someelement); $('#someid').domorestuff here code: <head> <title>jtournament</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="jtournament.js"></script> <script> var matchinfo = { "rounds": [{ "name": "round1", "matches": [{ "p1": "bill", "p2": "bob", "winner": 1 }, { "p1": "sam", "p2": "dud...

Django Toolbar gives different times when same template is loaded -

when using django debug toolbar, says page might load in 4000 ms. when reload page (with ctrl+f5 clear cache) says loads in 4400 ms -- or 3600 ms. there more accurate way benchmark load time? reason want optimize page load times , want make sure can see cause , effect clearly. there variation in amount of time takes program anything--on typical computer there tens hundreds of processes simultaneously competing resources, exact load time vary depending on how else going on @ exact moment. the best way benchmark not @ time take single page load, rather average time on bunch of loads. there many tools that-- apache jmeter one. you may want profiling app rather measuring overall load time--that identify bits of code called , contribute total time taken. guess-and-check optimizations more time consuming. see django docs or google "profiling django" many more resources.

c - How do loops with incrementing global variables work without volatile modifier? -

i have been working on msp430g2553 using using mspgcc compiler , introductory program have begun blinking led. code have used follows: #include <msp430.h> unsigned int i; void main(void) { wdtctl = wdtpw | wdthold; // stop watchdog timer p1dir |= 0x01; //set p1.0 output for(;;) { p1out ^= 0x01; i=0; while(i<50000) { i++; } } } where while loop work of providing delay. i thought since above while loop in i increments 0 value, why can't use decrementing loop. tried following code. #include <msp430.h> unsigned int i; void main(void) { wdtctl = wdtpw | wdthold; // stop watchdog timer p1dir |= 0x01; //set p1.0 output for(;;) { p1out ^= 0x01; i=50000 while(i>0) { i--; } } } this code didn't work , on finding reason, came know global variable i needs provided "volatile" prevent optimization o...

mysql - Using Redis to cache data that is in use in a Real TIme Single Page App -

i've got web application, has normal feature, user settings etc these stored in mysql user etc..... a particular part of application table of data user edit. i make table real time, across multiple users. ie multiple users can open page edit data , see changes in real time done other users editing table. my thinking cache data table in redis, preform actions in redis keeping clients date. once connection have closed particular table save data mysql persistence, know redis can used persistent nosql database ram limited , other data stored in mysql, mysql seems better option. is correct use case redis? thinking correct? it depends on scalability. number of records going deal , structure going use saving it. i discuss pros , crons of using redis. decision you. advantages of using redis: 1) can handle heavy writes , reads in comparison mysql 2) has flexible structures (hashmap, sorted set etc) can localise writes instead of blocking whole table. ...

javascript - Why can my code not access user that was just created? -

i'm using following code creating users: firebase.auth().createuserwithemailandpassword($scope.data.mail, $scope.data.pwd) .catch(function(error) { }); var user; while (!user) { user = firebase.auth().currentuser; } however don't know why time user variable gets null value: , loop never finished. i'm unable solve issue. you can't use while loop wait asynchronous result, because javascript runs on single thread. the loop execute indefinitely, meaning javascript runtime never chance handle promise, if it's completed. you need use then clause of promise instead. firebase.auth().createuserwithemailandpassword($scope.data.mail, $scope.data.pwd) .then(function() { var user = firebase.auth().currentuser; // carry on executing code here }) .catch(function(error) { });

javascript - Knockout observableArray item property change doesn't update UI -

when change property observablearray not update ui see example below , in jsfiddle . clicking on header should update sorting property , show/hide appropriate span javascript: var basemodel = [{ key: 'name', type: 'string' }, { key: 'surname', type: 'string' }, { key: 'age', type: 'integer' }] var data = [{ name: "john", surname: "smith", age: 12 }, { name: "peter", surname: "klark", age: 3 }, { name: "steve", surname: "heisenberg", age: 43 }] var vm = function () { var counter = 1; var people = ko.observablearray(data); var keys = ko.observablearray([]); var init = function () { var temparray = []; _.each(basemodel, function (item, key) { temparray.push({ key: item.key, type: item.type, sorting: false, ...

python - How can I write tests to make sure celery tasks go into the right queue -

due complicated callback/chaining setup tasks in our infrastructure seem going queues not assigned to. want write automated tests make sure celery task sent queue specified handled by. setup example: from celery import celery celery = celery() @celery.task(base=mytask, queue='mytasks.add') def add(x, y): = x + y return @celery.task(base=mytask, queue='mytasks.dadd') def double_add(a, y): b = + y def caller(x, y): add.apply_async(args=(2, 1), kwargs={''callback': double_add.subtask(args=(3)) }) so here "add" should handled queue='mytasks.add', , "double_add" should handled queue='mytasks.dadd' i understand basic result based testing celery such shown here: how unit test celery task? but appreciate insight testing process above scenario.

mysql - How do I check if a password has at least one number in it using PHP -

i learning @ moment php & mysql please excuse me if question silly. trying create simple login/registration system based on php , mysql. my idea check if password has number in , if doesn't give error message. problem if include number in password still gives error. if can me grateful. thank in advance. my code is: if(!preg_match('/^[0-9]*$/',$_post['password'])){ die('password must contain @ least 1 number.'); } best regards, george stoqnov the * means 0 or more need + '/[0-9]+/' and remove ^$ because means has start , end expression

java - JPA connecting to wrong table -

i trying learn jpa here entity file. passenger.java @entity public class passenger implements serializable{ public passenger() { super(); } public int getid() { return id; } public void setid(int id) { this.id = id; } public string getfirstname() { return firstname; } public void setfirstname(string firstname) { this.firstname = firstname; } public string getlastname() { return lastname; } public void setlastname(string lastname) { this.lastname = lastname; } @id @generatedvalue(strategy = generationtype.auto) private int id; private string firstname; private string lastname; } my persistence.xml below. <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1"> <persistence-unit name="jpa_pojo"> <provider>org.eclipse.persistence.jpa.persistenceprovider</provider> <jta-data-source>java:/airlines</jta-data-source> <class>com.airline.model....