Saturday, 15 March 2014

php - Codeigniter random session logouts (Already tried override session class AND raising session_time_to_update -



php - Codeigniter random session logouts (Already tried override session class AND raising session_time_to_update -

i have tried both suggestions at: codeigniter session bugging out ajax calls

but $config['sess_time_to_update'] = php_int_max still seeing random logouts.

i took suggestions of creating class my_session

user's still reporting random logouts , logs seem indicate this.

edit: here session config:

$config['sess_cookie_name'] = 'phppos'; $config['sess_expiration'] = 86400; $config['sess_expire_on_close'] = true; $config['sess_encrypt_cookie'] = false; $config['sess_use_database'] = true; $config['sess_table_name'] = 'sessions'; $config['sess_match_ip'] = false; $config['sess_match_useragent'] = true; $config['sess_time_to_update'] = php_int_max;

i think you're suffering ajax session race condition. had same problem, , solved overriding ci session class. have article here:

http://www.hiretheworld.com/blog/tech-blog/codeigniter-session-race-conditions

the cleanest thing utilize my_session class, in libraries folder, , override methods written in link above. sorry lack of indentation, :p

class my_session extends ci_session { public function __construct() { parent::__construct(); } /********************************************************************* * overrides codeigniter session library * * handle race status during session_id updates. * - maintain old session id around in case have handle race * conditions. * - changes marked string "old_session_id_changes". * * session table changes: * alter table `sessions` add together column `old_session_id` varchar(40) default null comment 'old session id' after `user_data`, * add together index `old_session_id`(`old_session_id`); * delete `sessions`; *********************************************************************/ /** * fetch current session info if exists * * @return bool */ public function sess_read() { // fetch cookie $session = $this->ci->input->cookie($this->sess_cookie_name); // no cookie? goodbye cruel world!... if ($session === null) { log_message('debug', 'a session cookie not found.'); homecoming false; } // decrypt cookie info if ($this->sess_encrypt_cookie === true) { $session = $this->ci->encrypt->decode($session); } else { // encryption not used, need check md5 hash $hash = substr($session, strlen($session)-32); // lastly 32 chars $session = substr($session, 0, strlen($session)-32); // md5 hash match? prevent manipulation of session info in userspace if ($hash !== md5($session.$this->encryption_key)) { log_message('error', 'the session cookie info did not match expected. possible hacking attempt.'); $this->sess_destroy(); homecoming false; } } // unserialize session array $session = $this->_unserialize($session); // session info unserialized array right format? if ( ! is_array($session) or ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity'])) { $this->sess_destroy(); homecoming false; } // session current? if (($session['last_activity'] + $this->sess_expiration) < $this->now) { $this->sess_destroy(); homecoming false; } // ip match? if ($this->sess_match_ip === true && $session['ip_address'] !== $this->ci->input->ip_address()) { $this->sess_destroy(); homecoming false; } // user agent match? if ($this->sess_match_useragent === true && trim($session['user_agent']) !== trim(substr($this->ci->input->user_agent(), 0, 120))) { $this->sess_destroy(); homecoming false; } // there corresponding session in db? if ($this->sess_use_database === true) { /* * begin old_session_id_changes * * search both session_id , old_session_id fields * incoming session id. * * used be: * $this->ci->db->where('session_id', $session['session_id']); * * manually create or status because causes to the lowest degree * disturbance existing code. * * store session id cookie can see if * came in through old session id later. */ $this->ci->db->where( '(session_id = ' . $this->ci->db->escape($session['session_id']) . ' or old_session_id = ' . $this->ci->db->escape($session['session_id']) . ')' ); $this->cookie_session_id = $session['session_id']; /* * end old_session_id_changes */ if ($this->sess_match_ip === true) { $this->ci->db->where('ip_address', $session['ip_address']); } if ($this->sess_match_useragent === true) { $this->ci->db->where('user_agent', $session['user_agent']); } $query = $this->ci->db->limit(1)->get($this->sess_table_name); // no result? kill it! if ($query->num_rows() === 0) { $this->sess_destroy(); homecoming false; } // there custom data? if so, add together main session array $row = $query->row(); if ( ! empty($row->user_data)) { $custom_data = $this->_unserialize($row->user_data); if (is_array($custom_data)) { foreach ($custom_data $key => $val) { $session[$key] = $val; } } } /* * begin old_session_id_changes * * pull session_id database populate curent * session id because old 1 stale. * * pull old_session_id database can * compare current (cookie) session id against later. */ $session['session_id'] = $row->session_id; $session['old_session_id'] = $row->old_session_id; /* * end old_session_id_changes */ } // session valid! $this->userdata = $session; unset($session); homecoming true; } // -------------------------------------------------------------------- /** * write session info * * @return void */ public function sess_write() { // saving custom info db? if not, update cookie if ($this->sess_use_database === false) { $this->_set_cookie(); return; } // set custom userdata, session info set in sec $custom_userdata = $this->userdata; $cookie_userdata = array(); // before continuing, need determine if there custom info deal with. // let's determine removing default indexes see if there's left in array // , set session info while we're @ foreach (array('session_id','ip_address','user_agent','last_activity') $val) { unset($custom_userdata[$val]); $cookie_userdata[$val] = $this->userdata[$val]; } /* * begin old_session_id_changes * * old_session_id has own field, doesn't need go * cookie because we'll retrieve database. */ unset($custom_userdata['old_session_id']); /* * end old_session_id_changes */ // did find custom data? if not, turn empty array string // since there's no reason serialize , store empty array in db if (count($custom_userdata) === 0) { $custom_userdata = ''; } else { // serialize custom info array can store $custom_userdata = $this->_serialize($custom_userdata); } // run update query $this->ci->db->where('session_id', $this->userdata['session_id']); $this->ci->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata)); // write cookie. notice manually pass cookie info array // _set_cookie() function. function store $this->userdata, // in case array contains custom data, not want in cookie. $this->_set_cookie($cookie_userdata); } // -------------------------------------------------------------------- /** * update existing session * * @return void */ public function sess_update() { // update session every 5 minutes default if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now) { return; } // _set_cookie() handle if aren't using database sessions // pushing userdata cookie. $cookie_data = null; /* * begin old_session_id_changes * * don't need regenerate session if came in indexing * old_session_id), send out cookie anyway create sure * client has re-create of new cookie. * * isset check first in case we're not using database * store data. old_session_id field exists in * database. */ if ((isset($this->userdata['old_session_id'])) && ($this->cookie_session_id === $this->userdata['old_session_id'])) { // set cookie explicitly have our session info $cookie_data = array(); foreach (array('session_id','ip_address','user_agent','last_activity') $val) { $cookie_data[$val] = $this->userdata[$val]; } $this->_set_cookie($cookie_data); return; } /* * end old_session_id_changes */ // save old session id know record // update in database if need $old_sessid = $this->userdata['session_id']; $new_sessid = ''; { $new_sessid .= mt_rand(0, mt_getrandmax()); } while (strlen($new_sessid) < 32); // create session id more secure we'll combine user's ip $new_sessid .= $this->ci->input->ip_address(); // turn hash , update session info array $this->userdata['session_id'] = $new_sessid = md5(uniqid($new_sessid, true)); $this->userdata['last_activity'] = $this->now; // update session id , last_activity field in db if needed if ($this->sess_use_database === true) { // set cookie explicitly have our session info $cookie_data = array(); foreach (array('session_id','ip_address','user_agent','last_activity') $val) { $cookie_data[$val] = $this->userdata[$val]; } /* * begin old_session_id_changes * * save old session id old_session_id field * can reference later. * * rewrite cookie's session id if there 0 affected rows * because means request changed database * under current request. in case, want homecoming * value consistent previous request. reread * after update phone call here minimize timing problems. * should in transaction databases back upwards them. * * rewrite userdata future calls sess_write * output right cookie data. * * used be: * $this->ci->db->query($this->ci->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid))); */ $this->ci->db->query($this->ci->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid, 'old_session_id' => $old_sessid), array('session_id' => $old_sessid))); if ($this->ci->db->affected_rows() === 0) { $this->ci->db->where('old_session_id', $this->cookie_session_id); $query = $this->ci->db->get($this->sess_table_name); // we've lost track of session if there no results, // don't set cookie , return. if ($query->num_rows() == 0) { return; } $row = $query->row(); foreach (array('session_id','ip_address','user_agent','last_activity') $val) { $this->userdata[$val] = $row->$val; $cookie_data[$val] = $this->userdata[$val]; } // set request session id old session id // won't seek regenerate cookie 1 time again on request -- // in case sess_update ever called 1 time again (which // shouldn't be). $this->cookie_session_id = $this->userdata['old_session_id']; } /* * end old_session_id_changes */ } // write cookie $this->_set_cookie($cookie_data); } /********************************************************************* * end overrides codeigniter session library *********************************************************************/

php codeigniter session

java - Added new bean.xml and get class path resource [Spring-Mail.xml] cannot be opened because it does not exist] with root cause -



java - Added new bean.xml and get class path resource [Spring-Mail.xml] cannot be opened because it does not exist] with root cause -

i have tried follow illustration at: (http://www.mkyong.com/spring/spring-sending-e-mail-with-attachment/) add together mail service bean project, doesn't seem work. problem think can't add together new beans, 1 year ago worked on project, know might have missed?

jun 19, 2014 11:06:52 fm org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [restservices] in context path [/pyramid] threw exception [request processing failed; nested exception org.springframework.beans.factory.beandefinitionstoreexception: ioexception parsing xml document class path resource [spring-mail.xml]; nested exception java.io.filenotfoundexception: class path resource [spring-mail.xml] cannot opened because not exist] root cause java.io.filenotfoundexception: class path resource [spring-mail.xml] cannot opened because not exist @ org.springframework.core.io.classpathresource.getinputstream(classpathresource.java:172) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:329) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:303) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:180) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:216) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:187) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:251) @ org.springframework.context.support.abstractxmlapplicationcontext.loadbeandefinitions(abstractxmlapplicationcontext.java:127) @ org.springframework.context.support.abstractxmlapplicationcontext.loadbeandefinitions(abstractxmlapplicationcontext.java:93) @ org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:129) @ org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:540) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:454) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:139) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:83) @ se.kth.pyramidstatus.webservices.rest.statuscontroller.loaddata(statuscontroller.java:153) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:215) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:749) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:689) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:83) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:938) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:870) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:961) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:852) @ javax.servlet.http.httpservlet.service(httpservlet.java:621) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:837) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:51) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:100) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:953) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1041) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:603) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:310) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ java.lang.thread.run(thread.java:745)

thanks in forehand

edit 1, bean.xml:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="mailsender" class="org.springframework.mail.javamail.javamailsenderimpl"> <property name="host" value="smtp.gmail.com" /> <property name="port" value="587" /> <property name="username" value="username" /> <property name="password" value="password" /> <property name="javamailproperties"> <props> <prop key="mail.smtp.auth">true</prop> <prop key="mail.smtp.starttls.enable">true</prop> </props> </property> </bean> <bean id="mailmail" class="com.mkyong.common.mailmail"> <property name="mailsender" ref="mailsender" /> <property name="simplemailmessage" ref="customemailmessage" /> </bean> <bean id="customemailmessage" class="org.springframework.mail.simplemailmessage"> <property name="from" value="from@no-spam.com" /> <property name="to" value="to@no-spam.com" /> <property name="subject" value="testing subject" /> <property name="text"> <value> <![cdata[ dear %s, mail service content : %s ]]> </value> </property> </bean> </beans>

edit 2, code of execution:

applicationcontext context = new classpathxmlapplicationcontext("spring-mail.xml"); mailmail mm = (mailmail) context.getbean("mailmail"); mm.sendmail("yong mook kim", "this text content");

add xml file path sub directory of resources :

applicationcontext context = new classpathxmlapplicationcontext("/mailsend/spring-mail.xml"); //here mailsend dir name have taken mailmail mm = (mailmail) context.getbean("mailmail"); mm.sendmail("yong mook kim", "this text content");

java xml spring maven

mysql - Optimise Quesry containing Joins and Sub Queries -



mysql - Optimise Quesry containing Joins and Sub Queries -

i've inherited application client , have been working on next query takes 187 seconds , searches 304m table rows in order send 444 result rows.

am right want rid of sub selects , replace them joins? can't find way correctly. help optimising query hugely appreciated. thanks...

select business.name, business.primary_city, count(click.id) clicks, count(distinct email_leads.parent_message_id) tot_email_leads, count(bc.business_id) county_no, count(br.business_id) region_no, count(reveals.id) reveals_no businesses business left bring together business_clickthroughs click on ( business.id = click.business_id , (click.created between '2014-04-01 00:00:00' , '2014-04-30 23:59:59')) left bring together users u on business.id = u.business_id left bring together messages email_leads on (u.id = email_leads.from_to , (email_leads.parent_message_id null or email_leads.parent_message_id = email_leads.id ) , (email_leads.created between '2014-04-01 00:00:00' , '2014-04-30 23:59:59')) left bring together business_counties bc on business.id = bc.business_id left bring together businesses_business_types bt on business.id = bt.business_id left bring together business_reveals reveals on (reveals.business_id = business.id , (reveals.created between '2014-04-01 00:00:00' , '2014-04-30 23:59:59')) left bring together business_regions br on business.id = br.business_id 1=1 grouping business.id;

judging query writing, subselects right way go. don't show actual original query, speculation.

your query joining info along separate dimensions -- users, messages, counties, "reveals" (whatever is). joins result in cartesian product of these dimensions each business, farther magnifying info , slowing query down.

and, if larger tables have 300+ 1000000 rows, 300 seconds summarize all info in 8 or tables doesn't seem unreasonable. query doesn't have where conditions filtering data. joins left joins, reducing filtering.

if performance issue, inquire another question. include actual query, explain plan query, , layouts of tables (particularly index structures).

mysql sql join subquery

web services - Soap UI to Exchange -



web services - Soap UI to Exchange -

i trying connect soap ui our exchange server maintain getting error in soap ui of

error loading [https://<<our exchange server>>/ews/services.wsdl]: org.apache.xmlbeans.xmlexception: org.apache.xmlbeans.xmlexception: error: unexpected element: string

i using our endpoint have been reading , not wsdl url.

https://<<our exchange server>>/ems/exchange.asmx

anyone know might going on here?

not sure if typo in code or comment, ewsurl should https://mail.contoso.com/ews/exchange.asmx, not /ems/.

web-services soap wsdl exchange-server ews

Matlab Time-varying covariance matrix loop -



Matlab Time-varying covariance matrix loop -

i have portfolio assets , calculate variance of portfolio. calculated weights of assets , covariance matrix. both time-varying. variance need formula below:

wt'*sigma_1*wt = variance portfolio

in matlab used next code calculate weight of each asset:

for t=1:n at_1(:,t) = inv(sigma_1(:,:,t))*fit_1'; wt_1(t,1) = at_1(1,t)/sum(at_1(:,t)); wt_1(t,2) = at_1(2,t)/sum(at_1(:,t)); wt_1(t,3) = at_1(3,t)/sum(at_1(:,t)); wt_1(t,4) = at_1(4,t)/sum(at_1(:,t)); wt_1(t,5) = at_1(5,t)/sum(at_1(:,t)); wt_1(t,6) = at_1(6,t)/sum(at_1(:,t)); wt_1(t,7) = at_1(7,t)/sum(at_1(:,t)); wt_1(t,8) = at_1(8,t)/sum(at_1(:,t)); wt_1(t,9) = at_1(9,t)/sum(at_1(:,t)); wt_1(t,10) = at_1(10,t)/sum(at_1(:,t)); end

where sigma_1 covariance matrix. need loop calculate time-varying variance of portfolio. have 10 time-varying weights, , time-varying covariance sigma_1.i stuck writing loop that. can help me this?

have tried this?

t=1:n at_1(:,t) = inv(sigma_1(:,:,t))*fit_1'; k=1:10 wt_1(t,k) = at_1(k,t)/sum(at_1(:,t)); end end

matlab matrix conditional covariance

java - Graph Node doesnt loop through all neighbouring nodes? -



java - Graph Node doesnt loop through all neighbouring nodes? -

im having troubles graph assignment, i've run issue cant seem find.

system.out.println(plattegrond.getgraph().neighbours("een").tostring()); system.out.println(plattegrond.isroute("een", "drie", new hashset<string>()));

these lines of code print

[twee, drie, vier] false

so seems, "een" has "twee", "drie", , "vier" neighbours. isroute method returns false. method shown below.

public boolean isroute(string nodea, string nodeb, set<string> visited) { visited.add(nodea); if(nodea.equals(nodeb)) { homecoming true; } for(string neighbour : graph.neighbours(nodea)) { if(!visited.contains(neighbour)) { homecoming isroute(neighbour, nodeb, visited); } } homecoming false; }

i've traced steps debugger, , in enhanced loop, "drie" not come neighbour. "twee" , "four" will. same problem happens if seek find path "zes". when inquire "twee" neighbours are,

[een, vier, zes]

the isroute method 1 time again homecoming false when inquire find route "zes". 1 time again "zes" not come in loop neighbour. however, when inquire find route either "twee" or "four" homecoming true.

im lost on one.

there problem there... in have if statement return.. first neighbour twee , not in list visit twee , never go next iteration because of homecoming statement.

try using boolean variable , doing this:

boolean b = false; for(string neighbour : graph.neighbours(nodea)) { if(!visited.contains(neighbour)) { // statement can never alter b false 1 time becomes true // , create sure homecoming after checking whole set of neighbours b = b || isroute(neighbour, nodeb, visited); } } homecoming b;

this might not exact right solution @ to the lowest degree know problem... returning after first item , not iterating on neighbours.

java recursion graph

python - Django template tags forloop -



python - Django template tags forloop -

i have created template tag , trying loop through results template tag don't results

tags.py

from django import template loadprograms import dbcontext register = template.library() @register.simple_tag def get_category(): x = dbcontext.dbcontext() results = x.executequery("select name categories") categories = [each[0] each in results] homecoming categories

template code

{% load category_tags %} {% get_category %} {% each in get_category %} {{ each }} {% endfor %}

the {% get_category %} prints categories without issues loop stmt loop through results not work

what problem?

to create alter in tag, you'll have set variable in context, if objective have list of categories available in templates, have passed in view - need write template context processor, allow views have variable in context.

a template context processor method adds request context, returning dictionary. think of view function, returns context.

from .models import categories def cat_names(request): homecoming {'category_names': category.objects.values_list('name', flat=true)}

to activate context processor, have few things:

add above code file called template_processors.py in same place models.py , views.py.

in settings.py, add together fully-qualified name of method template_context_processors setting, making sure don't override defaults. easily, import default settings first, add together it:

from django.conf.default_settings import template_context_processors tcp template_context_processors = tcp + ('yourapp.template_processors.cat_names',)

use render shortcut, create sure context correctly passed.

in views, can this:

from django.shortcuts import render def home(request): homecoming render(request, 'home.html')

in home.html, can do:

{% name in category_names %} {{ name }} {% endfor %}

python django

api - How To Trap Key Events in Powerpoint Using VBA? -



api - How To Trap Key Events in Powerpoint Using VBA? -

i need identify keyboard press such characters key, esc key, arrow keys, etc... , run action whenever these events happen. possible done in powerpoint?

thanks in advance.

api vba powerpoint-vba

linux - Failing an IO/bio properly -



linux - Failing an IO/bio properly -

i'm developing block driver using the make_request method, effectively bypassing existing scsi or request stack in block layer.  so that means im directly working with bios.  as prescribed in linux documentation , referring to similar drivers in kernel, you close session a bio the bio_endio function.

i invoke bio_endio during successful i/o completion, meaning with error code of zero.  but there cases not fulfilled or there error cases.  my question is, valid error codes can be used it?  my initial impression that other than zero error code, bio_endio will fail.  i've read somewhere -ebusy not recognized, , tried -eio driver crashed.  i got a panic in dio_xxx function leading bio_endio(bio,-eio) , have no thought why happened. i would like block subsequent bios sent me after reaching queue depth , no tags left, and i want utilize bio_endio error code.

what error codes, , will they work for intended function?  or there better way aside bio_endio? thanks!

linux linux-kernel linux-device-driver

python - Getting "error: Unable to find vcvarsall.bat" when running "pip install numpy" on windows7 64bit -



python - Getting "error: Unable to find vcvarsall.bat" when running "pip install numpy" on windows7 64bit -

i'm running pip install numpy on windows7 64bit , i'm getting error: unable find vcvarsall.bat

i've installed packages pip, e.g. pyzmq,pysolr,enum,etc., don't know went wrong.

the thing might different i've install .net framework version 4.5 -> suspect reason because in posts saw might have visual studio (that didn't install)

the total error/traceback:

downloading/unpacking numpy running setup.py (path:c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\setup.py) egg_info bundle numpy running numpy source directory. warning: no files found matching 'tools\py3tool.py' warning: no files found matching '*' under directory 'doc\f2py' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.pyd' found anywhere in distribution installing collected packages: numpy running setup.py install numpy non-existing path in 'numpy\\distutils': 'site.cfg' f2py version 2 blas_opt_info: blas_mkl_info: libraries mkl,vml,guide not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available openblas_info: libraries not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available atlas_blas_threads_info: setting ptatlas=atlas libraries ptf77blas,ptcblas,atlas not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available atlas_blas_info: libraries f77blas,cblas,atlas not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available blas_info: libraries blas not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available blas_src_info: not available not available non-existing path in 'numpy\\lib': 'benchmarks' lapack_opt_info: lapack_mkl_info: mkl_info: libraries mkl,vml,guide not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available not available atlas_threads_info: setting ptatlas=atlas libraries ptf77blas,ptcblas,atlas not found in c:\python27\lib libraries lapack_atlas not found in c:\python27\lib libraries ptf77blas,ptcblas,atlas not found in c:\ libraries lapack_atlas not found in c:\ libraries ptf77blas,ptcblas,atlas not found in c:\python27\libs libraries lapack_atlas not found in c:\python27\libs numpy.distutils.system_info.atlas_threads_info not available atlas_info: libraries f77blas,cblas,atlas not found in c:\python27\lib libraries lapack_atlas not found in c:\python27\lib libraries f77blas,cblas,atlas not found in c:\ libraries lapack_atlas not found in c:\ libraries f77blas,cblas,atlas not found in c:\python27\libs libraries lapack_atlas not found in c:\python27\libs numpy.distutils.system_info.atlas_info not available lapack_info: libraries lapack not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available lapack_src_info: not available not available unifing config_cc, config, build_clib, build_ext, build commands --compiler options unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options build_src building py_modules sources building library "npymath" sources no module named msvccompiler in numpy.distutils; trying distutils running numpy source directory. c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1521: userwarning: atlas (http://math-atlas.sourceforge.net/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [atlas]) or setting atlas environment variable. warnings.warn(atlasnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1530: userwarning: blas (http://www.netlib.org/blas/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [blas]) or setting blas environment variable. warnings.warn(blasnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1533: userwarning: blas (http://www.netlib.org/blas/) sources not found. directories search sources can specified in numpy/distutils/site.cfg file (section [blas_src]) or setting blas_src environment variable. warnings.warn(blassrcnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1427: userwarning: atlas (http://math-atlas.sourceforge.net/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [atlas]) or setting atlas environment variable. warnings.warn(atlasnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1438: userwarning: lapack (http://www.netlib.org/lapack/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [lapack]) or setting lapack environment variable. warnings.warn(lapacknotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1441: userwarning: lapack (http://www.netlib.org/lapack/) sources not found. directories search sources can specified in numpy/distutils/site.cfg file (section [lapack_src]) or setting lapack_src environment variable. warnings.warn(lapacksrcnotfounderror.__doc__) c:\python27\lib\distutils\dist.py:267: userwarning: unknown distribution option: 'define_macros' warnings.warn(msg) error: unable find vcvarsall.bat finish output command c:\python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\zebra\\appdata\\local\\temp\\pip_build_zebra\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\zebra\appdata\local\temp\pip-py_oa_-record\install-record.txt --single-version-externally-managed --compile: non-existing path in 'numpy\\distutils': 'site.cfg' f2py version 2 blas_opt_info: blas_mkl_info: libraries mkl,vml,guide not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available openblas_info: libraries not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available atlas_blas_threads_info: setting ptatlas=atlas libraries ptf77blas,ptcblas,atlas not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available atlas_blas_info: libraries f77blas,cblas,atlas not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available blas_info: libraries blas not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available blas_src_info: not available not available non-existing path in 'numpy\\lib': 'benchmarks' lapack_opt_info: lapack_mkl_info: mkl_info: libraries mkl,vml,guide not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available not available atlas_threads_info: setting ptatlas=atlas libraries ptf77blas,ptcblas,atlas not found in c:\python27\lib libraries lapack_atlas not found in c:\python27\lib libraries ptf77blas,ptcblas,atlas not found in c:\ libraries lapack_atlas not found in c:\ libraries ptf77blas,ptcblas,atlas not found in c:\python27\libs libraries lapack_atlas not found in c:\python27\libs numpy.distutils.system_info.atlas_threads_info not available atlas_info: libraries f77blas,cblas,atlas not found in c:\python27\lib libraries lapack_atlas not found in c:\python27\lib libraries f77blas,cblas,atlas not found in c:\ libraries lapack_atlas not found in c:\ libraries f77blas,cblas,atlas not found in c:\python27\libs libraries lapack_atlas not found in c:\python27\libs numpy.distutils.system_info.atlas_info not available lapack_info: libraries lapack not found in ['c:\\python27\\lib', 'c:\\', 'c:\\python27\\libs'] not available lapack_src_info: not available not available running install running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building py_modules sources creating build creating build\src.win-amd64-2.7 creating build\src.win-amd64-2.7\numpy creating build\src.win-amd64-2.7\numpy\distutils building library "npymath" sources no module named msvccompiler in numpy.distutils; trying distutils running numpy source directory. c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1521: userwarning: atlas (http://math-atlas.sourceforge.net/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [atlas]) or setting atlas environment variable. warnings.warn(atlasnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1530: userwarning: blas (http://www.netlib.org/blas/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [blas]) or setting blas environment variable. warnings.warn(blasnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1533: userwarning: blas (http://www.netlib.org/blas/) sources not found. directories search sources can specified in numpy/distutils/site.cfg file (section [blas_src]) or setting blas_src environment variable. warnings.warn(blassrcnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1427: userwarning: atlas (http://math-atlas.sourceforge.net/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [atlas]) or setting atlas environment variable. warnings.warn(atlasnotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1438: userwarning: lapack (http://www.netlib.org/lapack/) libraries not found. directories search libraries can specified in numpy/distutils/site.cfg file (section [lapack]) or setting lapack environment variable. warnings.warn(lapacknotfounderror.__doc__) c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1441: userwarning: lapack (http://www.netlib.org/lapack/) sources not found. directories search sources can specified in numpy/distutils/site.cfg file (section [lapack_src]) or setting lapack_src environment variable. warnings.warn(lapacksrcnotfounderror.__doc__) c:\python27\lib\distutils\dist.py:267: userwarning: unknown distribution option: 'define_macros' warnings.warn(msg) error: unable find vcvarsall.bat ---------------------------------------- cleaning up... command c:\python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\zebra\\appdata\\local\\temp\\pip_build_zebra\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\zebra\appdata\local\temp\pip-py_oa_-record\install-record.txt --single-version-externally-managed --compile failed error code 1 in c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy storing debug log failure in c:\users\zebra\pip\pip.log

maybe want utilize prebuilt binaries here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy? using pip wont yield results. reason numpy doesn't compile visual studio @ , needs built gcc.

if still want compile numpy, need setup linux machine vagrant , follow official build instructions here: https://github.com/juliantaylor/numpy-vendor

python windows numpy .net-4.5 pip

javascript - Adjust input size according to lenght of text on page load -



javascript - Adjust input size according to lenght of text on page load -

as title says need adjust width of input on page load according text called in php:

<input type="text" name="name" class="contact" value="<?php echo "$name"; ?>">

is there way width of text in , set width of input?

thank you!

you can on page load jquery

$(function(){ $('.contact').attr('size',$('.contact').val().length); })

javascript jquery

c# - Google Dotnet API - Admin SDK Groups - Getting Bad Request Error -



c# - Google Dotnet API - Admin SDK Groups - Getting Bad Request Error -

just trying out peruse google dotnet api admin sdk work.

i having errors when seek retrieve listing of groups. still confused @ documentation (which methods or functions utilize etc.).

the codes have right now:

using system; using system.io; using system.threading; using google.apis.auth.oauth2; using google.apis.services; using google.apis.util.store; using google.apis.admin.directory.directory_v1; using google.apis.admin.directory.directory_v1.data; namespace googleconsoleapp { class programme { static void main(string[] args) { usercredential credential; using (var stream = new filestream("client_secrets.json", filemode.open, fileaccess.read)) { credential = googlewebauthorizationbroker.authorizeasync( googleclientsecrets.load(stream).secrets, new[] { directoryservice.scope.admindirectorygroup, directoryservice.scope.admindirectorygroupreadonly }, "user", cancellationtoken.none, new filedatastore("tasks.auth.store")).result; } var dirsvc = new directoryservice(new baseclientservice.initializer() { httpclientinitializer = credential, applicationname = "groups api sample", }); groups mygroups = dirsvc.groups.list().execute();

pretty much errors out saying:

unhandled exception: google.googleapiexception: google.apis.requests.requesterror bad request [400] errors: [message [bad request] location [ - ] reason[badrequest] domain[global]]

i've enabled necessary apis in developer's console.

any help regarding appreciated.

update: tried method (as per documentation):

google.apis.admin.directory.directory_v1.groupsresource.listrequest lreq = new groupsresource.listrequest(dirsvc); groups grp2 = lreq.execute();

but still same error.

you need explicitly set domain of request. error in assuming search global domain if leave domain blank other types of requests do. in case instead tries search groups of customer, blank. note in api spec.

when retrieving:

all groups sub-domain — utilize domain argument domain's name. all groups business relationship — utilize client argument either my_customer or account's customerid value. business relationship administrator, utilize string my_customer represent account's customerid. if reseller accessing resold customer's account, utilize resold account's customerid. customerid value utilize account's primary domain name in retrieve users in domain operation's request. resulting response has customerid value. using both domain , client arguments — api returns groups domain. not using domain , client arguments — api returns groups business relationship associated my_customer. business relationship customerid of administrator making api request.

example works:

groupsresource.listrequest grouprequest = _service.groups.list(); grouprequest.domain = "yourdomain"; groups domaingroups = grouprequest.execute();

example not work , throw exact same error:

groupsresource.listrequest grouprequest = _service.groups.list(); groups domaingroups = grouprequest.execute();

c# google-api-dotnet-client

junit - (homeworkish) unit test a class with random behavior without being able to mock the RNG -



junit - (homeworkish) unit test a class with random behavior without being able to mock the RNG -

i'm working through coursera's algorithms, part course. have create randomizedqueue next api:

public class randomizedqueue<item> implements iterable<item> { public randomizedqueue() // build empty randomized queue public boolean isempty() // queue empty? public int size() // homecoming number of items on queue public void enqueue(item item) // add together item public item dequeue() // delete , homecoming random item public item sample() // homecoming (but not delete) random item public iterator<item> iterator() // homecoming independent iterator on items in random order public static void main(string[] args) // unit testing }

question: if can't create mock rng pass construction (because i'm not allowed alter api) , don't want test private methods, how test random behavior of structure?

what i've tried

i've tried thinking results i'd expect probabilistic problem. so, example, i'll run next pseudocode test 10,000 times:

create new randomizedqueue enqueue 100 items (e.g. integers 0 - 99) deque 1 item

then can test frequency each of 100 items dequed within confidence interval (based on binomial distribution).

some might phone call cheating, beg differ.

the point of unit testing verify behavior of system. such, if test going useful @ all, must deterministic. otherwise you'll false negatives, deteriorating integrity of test. ("oh, it's ok if test fails. happens sometimes...")

with in mind, what if didn't have restriction couldn't modify api? if had druthers, how implement , test class? create that implementation first. can design class deterministic.

after have working , tested class, implement randomizedqueue<item> as adapter class.

example

consider next setup:

public interface randomnumbergenerator { int getrandomint(); } // identical randomizedqueue<t>, except takes randomnumbergenerator dependency public class myrandomizedqueue<item> implements iterable<item> { public myrandomizedqueue(randomnumbergenerator generator) { ... }

your tests provide sut false randomnumbergenerator , have finish command on expected outcome of method be.

in actual randomizedqueue<t> implementation, instantiate tested class real randomnumbergenerator implementation (e.g., 1 uses java.util.random), store fellow member variable, , forwards method calls along it. like:

public item dequeue() { homecoming innerqueue.dequeue(); }

unit-testing junit junit4

android - ProgressDialog in AsyncTask onPreExecute, but it appears after doInBackground -



android - ProgressDialog in AsyncTask onPreExecute, but it appears after doInBackground -

this part of application. (you can run code below isolated application) on website (url), using php language, parse numbers other website, , create array , encode json array, , show.

but, code below (without dismiss function!) progressdialog appears after doinbackground.

when add together dismiss function onpostexecute below, never appears. when set log checking dialog window, says there dialog.

i heard doinbackground freezes ui, freezes before dialog shown.

other similar questions have found solution, erasing .get() masynctask().execute().get(), don't have get() in code.

boolean variable loadfinish waiting finishing asynctask, show results website after asynctask. if delete while(loadfinish == false) there, automacally appears , disappears well, can't show result immediately...

add) found takes several seconds dialog appear after doinbackground... why?!

add2) i've tried move dialog codes before , after new masynctask().execute(), doesn't work too...

public class mainactivity extends activity { boolean loadfinish; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button start = (button) findviewbyid(r.id.start); //just button starting asynctask start.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { loadfinish = false; new masynctask().execute(); // , create json array java array while (loadfinish == false) ; } }); // add together array custom_list_data, , set custom row_adapter listview. // if delete while(loadfinish == false), array initial info added. } private class masynctask extends asynctask<string, string, string> { progressdialog dialog; @override protected void onpreexecute() { super.onpreexecute(); dialog = new progressdialog(mainactivity.this); dialog.setmessage("asdf"); dialog.setindeterminate(true); dialog.setcancelable(false); dialog.show(); } @override protected string doinbackground(string... params) { string url = "http://songdosiyak.url.ph/mouirate/etoos/3/main/"; string response_str = ""; httpclient client = new defaulthttpclient(); httpget request = new httpget(url); responsehandler<string> responsehandler = new basicresponsehandler(); seek { response_str = client.execute(request, responsehandler); } grab (clientprotocolexception e1) { e1.printstacktrace(); } grab (ioexception e1) { e1.printstacktrace(); } loadfinish = true; homecoming null; } @override protected void onpostexecute(string result) { super.onpostexecute(result); dialog.dismiss(); } } }

sorry poor english language language skill , give thanks reading!

as gabe mentioned don't need loop, need more understanding async methods should do.

you introduced result, because want display result. have homecoming response_str in doinbackground. available param onpostexecute can display it, or whatever need it.

so summarize:

remove loop return value response_str or whatever doinbackground display value in onpostexecute and remove loadfinish variable not needed @ all

hope helps.

android android-asynctask progressdialog

c# - How can I stop my image from resizing when the soft keyboard appears? -



c# - How can I stop my image from resizing when the soft keyboard appears? -

i'm writing windows 8 game have image source direct3d interop acts gameboard. when soft keyboard appears on screen, have next code prevent standard behaviour of view beingness pushed accommodate keyboard (it's desired gameboard stays in place when keyboard appears):

private void keyboardshowing(inputpane sender, inputpanevisibilityeventargs args) { double offsetheight = args.occludedrect.height; containergrid.margin = new thickness(0, offsetheight, 0, 0); }

the code above working other non-gameboard parts of page. however, scheme automatically resizing image fit in visible portion of screen. how can stop happening?

c# windows xaml windows-8 windows-store-apps

python - Pandas Dataframe row by row fill new column -



python - Pandas Dataframe row by row fill new column -

i trying perform row row operation on pandas dataframe such:

df = pd.dataframe(columns=['product', 'price', 'buy', 'sell']) df.loc[len(df.index)] = ["apple", 1.50, 3, 2] df.loc[len(df.index)] = ["banana", 0.75, -8, 4] df.loc[len(df.index)] = ["carrot", 2.00, -6, -3] df.loc[len(df.index)] = ["blueberry", 0.05, 5, 6]

basically want create new column "ratio" divides price/buy or price/sell, depending on abs(buy) or abs(sell) greater. not sure how this...would utilize apply function?

thanks!

you can straight utilize column indexing (http://pandas.pydata.org/pandas-docs/stable/indexing.html) compare , filter ratios.

buy_ratio = (abs(df["buy"]) > abs(df["sell"])) * df["price"] / df["buy"] sell_ratio = (abs(df["buy"]) <= abs(df["sell"])) * df["price"] / df["sell"] df["ratio"] = buy_ratio + sell_ratio

in case,

the status (abs(df["buy"]) > abs(df["sell"])) gives 0/1 valued column depending on whether purchase or sell greater. multiply column price/buy. if sell cost high, multiplication zero. perform symmetric operation sell finally, add together them , straight set column named "ratio" using indexing.

edit

here solution using apply - first define function operating in rows of dataframe.

def f(row): if abs(row["buy"]) > abs(row["sell"]): homecoming row["price"] / row["buy"] else: homecoming row["price"] / row["sell"]

finally, set ratio column appropriately using apply.

df["ratio"] = df.apply(f, axis=1)

python pandas dataframes apply

Syntax error in call statement in Fortran -



Syntax error in call statement in Fortran -

i have written simple test programme seek subroutines , phone call statement in fortran. using gfortran compiler in gnu/linux. have declared 14 parameters numbered accordingly in code. while code works when seek pass 11 of arguments through phone call statement, encounter rather unusual 'syntax error' when seek include 12th argument , seek pass 12 arguments through phone call statement. might problem , how might prepare it? here programme talking

`

programme test implicit real*4(a-b,d-h,o-z) implicit complex(c) complex*16 cqc,cqv parameter k1=2 parameter k2=2 parameter k3=2 parameter k4=2 parameter k5=2 parameter k6=2 parameter k7=2 parameter k8=2 parameter k9=2 parameter k10=2 parameter k11=2 parameter k12=2 parameter k13=2 parameter k14=2 phone call bins(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12) end programme subroutine bins(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12) integer k1, k2, k3, k4, k5 end subroutine `

following error when include k12 in 'call' statement , compile it:

`

siddharth@siddharth-vbox:~/desktop/codes$ gfortran test6.for -o test6.out test6.for:23.72: phone call bins(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12 1 error: syntax error in argument list @ (1) test6.for:29.72: subroutine bins(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k1 1 error: unexpected junk in formal argument list @ (1) test6.for:2.72: programme test 1 test6.for:31.72: integer k1, k2, k3, k4, k5 2 error: 2 main programs @ (1) , (2)

`

i reiterate don't encounter problems in compiling when include arguments k1 k11 in phone call statement, introduction of 12th argument introduces problem. help appreciated.

files .for or .f extension, convention, treated fixed form source. statements on fixed form lines must go in between columns 7 , 72, inclusive. note column position in error message - end of statement beingness chopped off.

fixed form source not sensitive whitespace. parameter kxxx assignment statements before phone call statement don't think.

do not utilize fixed form source unless modifying existing legacy code.

do not utilize implicit typing unless modifying existing legacy code (or perhaps engaging in esoteric application of generic programming). implicit none best friend.

fortran

arm - Getting RSSI of nRF51822 bluetooth -



arm - Getting RSSI of nRF51822 bluetooth -

i using bluetooth low energy (ble) 4.0 nrf51822 nordic semiconductor, , want create project on indoor localization, need rssi (received signal strength indication) of ble.

can 1 help?

i think when kit nordic provide documentation. among documentation found code of app android ( , ios ) parameters, uuid, major, minor , de rssi. should check code in order rssi. luck, , app name nrfbeacon, , think it's in google play also, you'll need source solve problem.

arm bluetooth-lowenergy keil

run multiple classes sequentially in testng.xml -



run multiple classes sequentially in testng.xml -

i trying run multiple classes 1 1 using testng.xml of these running parallel. don't want them run in parallel . testng.xml luks this:

<test name="aia pod" preserve-order="true" annotations="jdk" > <parameter name="url" value="https://abc.com"></parameter> <parameter name="username" value="xaia/user"></parameter> <parameter name="password" value="passwd"></parameter> <classes>

running xml opens 2 browsers @ same time. want class run first , open new browser , run class b 1 time completed. in advance.

you need set parallel=false @ suite level accomplish this.

it might help if refer this understand how parallelism works using xml.

xml testng

Dependency Error in Ruby -



Dependency Error in Ruby -

i trying install gem named spiceweasel (https://github.com/mattray/spiceweasel). when running next error:

$ sudo gem install spiceweasel error: while executing gem ... (gem::dependencyerror) unable resolve dependencies: ridley requires buff-extensions (~> 0.3); buff-config requires buff-extensions (~> 0.3); varia_model requires buff-extensions (~> 1.0)

is there way circumvent this?

looks have conflict in dependencies:

ridley requires buff-extensions (~> 0.3) varia_model requires buff-extensions (~> 1.0)

ie: 2 gems depends on conflicting versions of 3rd 1 ("~>" in bundler means minor version correct, not major one).

what can do:

if project not require both ridley & varia_model, may utilize rvm create specific gemset it. update ridley (the newest version using buff-extension 1.0).

ruby

python - Celery Result backend. DisabledBackend object has no attribute _get_task_meta_for -



python - Celery Result backend. DisabledBackend object has no attribute _get_task_meta_for -

i have configured celery , backend:

cleryapp = celery( 'tasks_app', brocker='amqp://guest@localhost//', backend='db+postgresql://guest@localhost:5432' )

'results' appears disabled when start worker, read on question here that's not issue.

the database getting info correctly,

result = asyncresult(task_id)

raises

attributeerror: 'disabledbackend' object has no attribute '_get_task_meta_for'

try using instead task name of task function:

result = task.asyncresult(task_id)

python celery

sql - How to make a query using repeated WHERE clauses and LEFT JOINS more dynamic (without crostab) -



sql - How to make a query using repeated WHERE clauses and LEFT JOINS more dynamic (without crostab) -

edit: on older version of postgresql not back upwards crostab.

i have query trying improve making easier add together new value table meant roll info single user

i have write new left bring together , clause each time add together value column below called algorithms:

┌───────────────────────────────┐ │ algo │ ├───────────────────────────────┤ │ algorithm1 │ │ algorithm2 │ │ algorithm3 │ └───────────────────────────────┘

here query wrote genearte output:

select a.userid, a.algo, a.algo1_cnt, b.algo, b.algo2t_cnt, c.algo, c.algo3_cnt (select userid, algo, count(*) algo1_cnt test_table (algo = 'algorithm1') grouping 1,2 ) left outer bring together ( select userid, algo, count(*) algo2_cnt test_table (algo = 'algorithm2') grouping 1,2 ) b on (a.userid = b.userid) left outer bring together ( select userid, algo, count(*) algo3_cnt test_table (algo = 'algorithm3') grouping 1,2 ) c on (a.userid = c.userid)

the output of query looks like:

┌──────────────────────┬────────────────┬───────────┬───────┬───────────┬───────────────────────────────┬───────────┐ │ userid │ algo1 │ algo1_cnt │ algo2 │ algo2_cnt │ algo3 │ algo3_cnt │ ├──────────────────────┼────────────────┼───────────┼───────┼───────────┼───────────────────────────────┼───────────┤ │ user1 │ algo1 │ 3 │ │ │ algo3 │ 2 │ │ user2 │ algo1 │ 2 │ │ │ │ │

question: best way modify query able read distinct values algo column in dynamic fashion , generate same outpuy?

what mean if add together new value called algorithm4 algo column can levarage pl/pgsql or other dyanmic recurision generate same output without having utilize (algo = 'algorithm4')?

you can utilize crosstab if can split arrays somewhere else much simpler

select user_id, array_agg(algo) algo, array_agg(algo_count) algo_count ( select userid, algo, count(*) algo_count test_table grouping 1, 2 ) s grouping 1

json aficionados can have it

select user_id, format( '{%s}', string_agg(format('"%s": %s', algo, algo_count), ', ') )::json algo_obj ( select userid, algo, count(*) algo_count test_table grouping 1, 2 ) s grouping 1

sql postgresql

javascript - Jquery click function fire multiple time with Jquery load -



javascript - Jquery click function fire multiple time with Jquery load -

i have 1 custom function

(function($) { $.fn.customcheck = function(options) { this.each(function() { // }); $('span.check').click(function(){ alert('ok'); }); }; }(jquery));

normally function working

function show_conversation(url){ var $container = $('section.load'); $container.html('<span class="loading">loading</span>'); $container.load(url,function(){ //my check box function not working dynamically loaded content //so want phone call function 1 time again //but action fire multiple times (click) $('input[type="checkbox"]').customcheck(); }); } $(document).ready(function(){ $('input[type="checkbox"]').customcheck(); var url = 'test.html'; show_conversation(url); $('a').click(function(){ var url = $(this).attr('href'); show_conversation(url); }); });

but function not working in dynamically loaded content. want phone call function 1 time again within load function. in custom function have 1 click function. thats why click function run multiple times.

you can check total code here http://pastebin.com/6nczuszd . how can avoid error. there alternative without move click event custom function? sorry bad english.

javascript jquery

java - Count the number of “trues” for n booleans -



java - Count the number of “trues” for n booleans -

public static boolean startrack[][][] = { {{true,true,true}, {true,true,true}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}}, {{false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}}, {{false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}}, {{false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}, {false,false,false}} };

i want know how count number of trues in array using java. "i have array , want count number of trues. how can this?"

if understand you, -

int count = 0; (boolean[][] barrarr : startrack) { (boolean[] barr : barrarr) { (boolean b : barr) { if (b) { count++; } } } } system.out.println(count);

given startrack output of

6

java

Find an Object in an array by comparing Object->value to all Object->values in array PHP -



Find an Object in an array by comparing Object->value to all Object->values in array PHP -

so array contains objects this:

$arr = array( new card('10', 'spades'), new card('jack', 'diamonds'), new card('king', 'spades') );

now have function:

function hascard(card $card) { if (in_array($card, $arr)) homecoming true; homecoming false; }

now above not work since need compare ($card->rank == $arr[$x]->rank) each element in $arr without looping. there function on php allows modify compareto method of array_search?

i'd suggest using array_filter here. (note: create sure $arr available within hascard function)

function hascard(card $card) { $inarray = array_filter($arr, function($x) use($card){ homecoming $x->rank === $card->rank; }); homecoming count($inarray) > 0; }

demo: https://eval.in/166460

php arrays object

r - An irregular polygon area as plot on spatstat -



r - An irregular polygon area as plot on spatstat -

it's first time using spatstat package, advice. attempting plot coordinate info irregular polygon area (format .shp), calculate spatial analysis ripley's k. how can add together irregular polygon area plot? how can merge .ppp info coordinates polygon area? have used next codes:

converting coordinate info .ppp format

library(spatstat) library(sp) library(maptools) tree.simu <- read.table("simulation.txt", h=t) tree.simu.ppp <-ppp(x=tree.simu$x,y=tree.simu$y,window=owin(c(min(tree.simu$x),max(tree.simu$x)),c(min(tree.simu$y),max(tree.simu$y)))) plot(tree.simu.ppp)

with function considering plot area max , min valeu of coordinates. set polygon boundary plot.

ploting irregular polygon area

area <- readshapepoly("area/fragment.shp") plot(area) plot(tree.simu.ppp, add=t)

or

points(tree.simu.ppp)

the bundle take lastly function but, when seek plot both files together, seems .shp file fill whole area. can't visualize coordinates data.

thank you, appreciate help!

ps.: if know material question, please happy take look

this indeed due inconsistent bounding boxes conjectured in comment @jlhoward. points in [273663.9, 275091.45] x [7718635, 7719267] while polygon contained in [-41.17483, -41.15588] x [-20.619647, -20.610134].

assuming coordinates indeed consistent window right way way of getting ppp object be:

library(spatstat) library(sp) library(maptools) area <- readshapepoly("area/fragment.shp") area <- as(area, "owin") tree.simu <- read.table("simulation.txt", h=t) tree.simu.ppp <-ppp(x=tree.simu$x,y=tree.simu$y,window=area)

however, warning points beingness rejected since outside window, , object contain no points.

r plot polygon spatial spatstat

javascript - How can I make Qooxdoo virtual list scalable? -



javascript - How can I make Qooxdoo virtual list scalable? -

i need show list of info , @ to the lowest degree 1 1000000 rows (big info , machine learning). not need show @ 1 time , remotetablemodel of qooxdoo table works fine instead of table take list design choice.

below test i've made.

//create model data, 1mil items var rawdata = []; (var = 0; < 1000000; i++) { rawdata[i] = "item no " + i; } var model = new qx.data.array(rawdata); //create list var list = new qx.ui.list.list(model); this.getroot().add(list);

i understand point take long generate rawdata , assign list. problem after assigning list , virtual list non-responsive.

scrolling slow , navigating downwards arrow freezes few secs too. qooxdoo virtual infrastructure suppose render visible items if understand correctly? in above test case slow. expect work remote table model .

tested qooxdoo latest 4.0.0 , 3.5.1 , on chrome 35 stable.

i can reproduce issue source version , not build version. found reason why performance slow. there runtime check in internal method singlevaluebinding has huge performance impact on rendering.

i opened bug study that: http://bugzilla.qooxdoo.org/show_bug.cgi?id=8439

but sad issue occurs developer version. customers not effected.

you can disable check if want. remove check block: https://github.com/qooxdoo/qooxdoo/blob/master/framework/source/class/qx/data/singlevaluebinding.js#l915

you can load model info in parts improve model creation. can maybe load next part when user has scrolled end of list. can utilize illustration have seen: infinite scroll in qooxdoo virtual list

javascript html5 performance scalability qooxdoo

sonarqube - getting error in sonar task while executing build.xml -



sonarqube - getting error in sonar task while executing build.xml -

i have configured sonar in build xml shown below upon execution of build.xml getting error below..can u plas advise how overcome error

target name="sonar"> <echo message="**** thirdparty.lib.dir -- > ${thirdparty.lib.dir}/sonar ****"/> <sonar:sonar workdir="${build.dir}" key="gtr_61.all.rules:dev" version="1.0" xmlns:sonar="antlib:org.sonar.ant"> <!-- source directories (required) --> <sources> <path location="${pps.dir}/src" /> <path location="${pn.dir}/src" /> </sources> <property key="sonar.host.url" value="https://abc/" /> <property key="sonar.jdbc.url" value="jdbc:oracle:thin:abc" /> <property key="sonar.jdbc.driverclassname" value="oracle.jdbc.driver.oracledriver" /> <property key="sonar.jdbc.username" value="=aaa" /> <property key="sonar.jdbc.password" value="bbb" /> <property name="sonar.scm.url" value="https://svn.ats" /> <property name="sonar.java.source" value="1.5" /> <property name="sonar.language" value="java"/> <property name="sonar.projectversion" value="1.0"/> <tstamp prefix="build-info"> <format property="current-date" pattern="dd-mmm-yyyy" locale="en" /> <format property="current-time" pattern="hh:mm:ss z" locale="en" /> <format property="year-month-day" pattern="yyyy-mm-dd" locale="en" /> </tstamp> <!-- cobertura --> <property key="sonar.cobertura.reportpath" value="cobertura-report/coverage.xml" /> <property key="sonar.dynamicanalysis" value="reusereports" /> <!-- binaries directories, contain illustration compiled java bytecode (optional) --> <binaries> <path location="${ps.dir}/build/classes" /> <path location="${omm.dir}/build/classes" /> </binaries> <!-- path libraries (optional). these libraries illustration used java findbugs plugin --> <libraries> <path location="${lib.dir}" /> </libraries> <property key="sonar.profile" value="abc rule" /> <!--property key="sonar.profile" value="custom rules" --> </sonar:sonar>

the error getting ..

onar [06:56:15]echo [06:56:15]**** thirdparty.lib.dir -- > /opt/app//buildagent-8.0.3/work/pla/lib/thirdparty/sonar **** [06:56:15]sonar:sonar [06:56:15]property doesn't back upwards "name" attribute

if feeling right you're using old version of sonarqube ant task. here way configure sonarqube ant task: http://docs.codehaus.org/display/sonar/analyzing+with+sonarqube+ant+task

sonarqube

java ee - JPA ManyToOne with composite key -



java ee - JPA ManyToOne with composite key -

i have model mapping brand entity:

@entity public class brand implements serializable { private static final long serialversionuid = 1l; @embeddedid private brandpk id; //... }

the composite key is:

@embeddable public class brandpk implements serializable { private static final long serialversionuid = 1l; private int id1; private int id2; //... }

now want bring together product entity (one brand, many products):

i have:

@entity public class product implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy=generationtype.auto) private int id; @manytoone // ??? private brand brand; //... }

what need correctly bring together tables-entities?

table_brands has pk composing 2 fields: id1 , id2 table_products has pk id, , field id_brand refering id1.

id2 not used anymore , not of import @ all!

this mapping legacy db unfortunately cannot change, need bring together "ignoring" id2. how can i?

if add together column id_brand2 referring id2, can seek this:

@manytoone @joincolumns({ @joincolumn(name="id_brand", referencedcolumnname="id1"), @joincolumn(name="id_brand2", referencedcolumnname="id2") }) private brand brand;

java-ee jpa orm

Library for using plates in bayesian networks(preferably c++) -



Library for using plates in bayesian networks(preferably c++) -

in bayesian network there plenty of repetitive variables leading utilize of plates(http://en.wikipedia.org/wiki/plate_notation). not want exponential space complexity in implementing bayesian network. way traditional libraries(like dlib on c++) offers bayesian network, exponential. possible utilize plates , cut down space complexity? if yes, please help libraries this(preferably c++)

c++ bayesian bayesian-networks

javascript - Get html value from object within an array -



javascript - Get html value from object within an array -

i have exemplary javascript code snippet. i'm trying accomplish here getting html, , id attribute value object within array

var swatches = $(".swatchcolor"); (var = 0; < swatches.length; i++) { var value = parseint(swatches[i].html()); if (!isnan(value)) { alert(swatches[i].attr("id")); } };

but reason uncaught typeerror: undefined not function error when swatches[i].html() executed. why happen?

the jquery class selector not provide array of node elements iterate through.

from this answer, need next iterate through of nodes:

$(".swatchcolor").each(function(i, obj) { var value = parseint($(obj).html()); //etc... });

javascript jquery dom

c# - Trying to get message alert for empty text box -



c# - Trying to get message alert for empty text box -

i developing steganography program.

the problem is, whenever user not take image, error occurs. decided prompt error message every time user fails take image, did not work.

the error occurs at,

bitmap img = new bitmap(filetext.text);

it says, argument exception unhandled, path not of legal form.

private void encodebtn_click(object sender, eventargs e) { if (!string.isnullorwhitespace(filetext.text)) { messagebox.show("abc"); return; } bitmap img = new bitmap(filetext.text); (int = 0; < img.width; i++) { (int j = 0; j < img.height; j++) { color pixel = img.getpixel(i, j); if (i < 1 && j < msgtext.textlength) { char letter = convert.tochar(msgtext.text.substring(j, 1)); int value = convert.toint32(letter); img.setpixel(i, j, color.fromargb(pixel.r, pixel.g, value)); } if (i == img.width - 1 && j == img.height - 1) { img.setpixel(i, j, color.fromargb(pixel.r, pixel.g, msgtext.textlength)); } } }

you should check whether file name right , whether or not file exist:

string filename = filetext.text; if(string.isnullorwhitespace(filename) || !system.io.file.exists(filename)) { messagebox.show("wrong file name"); return; }

c#

css float - TinyMCE 4 Container not floating under label, but covers label? -



css float - TinyMCE 4 Container not floating under label, but covers label? -

i'm using tinymce cms , have form couple of labels , inputs. inputs , textareas floating under label next css:

label { float: left; clear: left; } input, textarea { float: left; clear: left; }

but when utilize tinymce override textareas, tinymce container overlapping label instead of floating under label. how come , how can prepare this? rather not create utilize of position absolute , relative, because of elements positioned float property.

greetings,

jan

tinymce renders within text areas default , html labels appear outside you're saying doesn't seem possible. please provide html , perchance fiddle can see what's going on.

as blind suggestion seek adding bottom margin or padding label element. if doesn't work seek giving big height.

css-float label textarea css-position tinymce-4

mysql - How to create insert trigger on table? -



mysql - How to create insert trigger on table? -

i have table warehouse:

++++++++++++++ + id + count + ++++++++++++++ + 1 + 10 + ++++++++++++++ + 10 + 100 + ++++++++++++++ + 3 + 200 + ++++++++++++++

i want create trigger, if insert info value, exists in table, count of row updated , new row wouldn't inserted. if there no info in table such id, new row must added.

expected result:

after query:

insert warehouse (id, count) values (1, 15);

warehouse table contents be:

++++++++++++++ + id + count + ++++++++++++++ + 1 + 25 + ++++++++++++++ + 10 + 100 + ++++++++++++++ + 3 + 200 + ++++++++++++++

after query:

insert warehouse (id, count) values (8, 11);

warehouse contents become:

++++++++++++++ + id + count + ++++++++++++++ + 1 + 25 + ++++++++++++++ + 10 + 100 + ++++++++++++++ + 3 + 200 + ++++++++++++++ + 8 + 11 + ++++++++++++++

after this:

insert warehouse (id, count) values (3, 5);

warehouse contents become:

++++++++++++++ + id + count + ++++++++++++++ + 1 + 25 + ++++++++++++++ + 10 + 100 + ++++++++++++++ + 3 + 205 + ++++++++++++++ + 8 + 11 + ++++++++++++++

i using mysql 5.1.

update

what if utilize such approach insert warehouse table?

insert warehouse ( count, id ) select count, id shopordergoods order_id = 1

is possible such behaviour want approach?

mysql not back upwards instead of trigger; is, it's not possible trigger.

assuming id column primary key of table (or @ minimum, unique key on table) can utilize on duplicate key form of insert statement accomplish behavior describe.

for example:

insert warehouse (id, count) values (1, 15) on duplicate key update count = count + values(`count`);

mysql effort insert, , if throws "duplicate key" exception, update action attempted. in illustration above, current value of count column have new value supplied column (in values clause of insert) added it.

(note: if current value of count column null, or value beingness inserted null, null assigned count column. if want handle null value beingness zero, enhance look handle cases:

on duplicate key update `count` = ifnull(`count`,0) + ifnull(values(`count`),0)

n.b. if there column in table has auto_increment property, auto increment table increased each insert attempt, including dupliate key exception thrown.

update

(based on update of question)

the on duplicate key form insert work insert ... select insert ... values.

insert warehouse (count,id) select s.count, s.id shopordergoods s s.order_id = 1 on duplicate key update `warehouse`.`count` = `warehouse`.`count` + values(`count`);

(in first illustration in answer, enclosed column name "count" in backticks, because i'm not sure if count reserved word. looks reserved word, didn't check list. in lastly example, i've not enclosed column name in backticks. don't ever utilize "count" column name or alias.) t utilize never name )

mysql sql triggers

Prevent Android from killing SQLite CLI when executing a long-running query -



Prevent Android from killing SQLite CLI when executing a long-running query -

as part of little benchmarking i'm doing app, i'm opening adb shell, running sqlite command line interface (sqlite3), , executing long-running query see how performs on device's hardware, installed version of sqlite.

however, sqlite keeps exiting, bringing me adb shell. message that's displayed "killed". since i've seen sqlite study sepecific errors "out of memory" before, assume android killing process, opposed sqlite encountering problem. assuming case, there way prevent scheme doing so?

i hoping if watchdog process killing process beingness non-responsive or taking much cpu time long, stop might help didn't.

this i'm doing when process gets killed, shortened bit post:

$ adb shell root@android:/ # cd /database/location/ root@android:/database/location # sqlite3 database.db sqlite> .output /dev/null sqlite> .timer on sqlite> select ... ... ...; killed root@android:/database/location #

android sqlite adb

javascript - What is the proper way to store an expiration date/timestamp? -



javascript - What is the proper way to store an expiration date/timestamp? -

i'm setting scheme needs have posts expire, , need compare 2 determine if it's expired. i'm using meteor can on clientside or serverside (i'm assuming latter preferred).

looking mdn, i'm not quite sure how store timestamps , format use. seems naive way utilize date.now() current time , add together 30 days in ms expired timestamp. there improve way this?

postmodel = { id: string createdon: date.now() expireson: date.now() + 2592000000 // 30days } post = getpost() if (post.expires after now) { // throw expired error }

you should store expiration time span and not actual date in configurable manner. can configuration file or database or other persistence mechanism. business entity need store creation time only. way expiration can calculated on either client or server side. hard coding values expiration not idea.

also, should utilize utc instead of local time. plan success!

javascript datetime

Why can't waf find a path that exists? -



Why can't waf find a path that exists? -

let's have x.y file in /mydir/a/b (on linux) when run waf, not find file.

def configure(context): pass def build(build_context): build_context(source='/mydir/a/b/x.y', rule='echo ${src} > ${tgt}', target='test.out')

result: source not found: '/mydir/a/b/x.y' in bld(features=[], idx=1, meths=['process_rule', 'process_source'] ...

ok, maybe want relative path, waf? , not telling me?

def build(context): path_str = '/mydir/a/b' xy_node = context.path.find_dir(path_str) if xy_node none: exit ("error: failed find path {}".format(path_str)) # refer current script orig_path = context.path.find_resource('wscript') rel_path = xy_node.path_from(orig_path) print "relative path: ", rel_path

result: error: failed find path /mydir/a/b

but directory exists! what's that?

and, way, relative path subdirectory (which can find) 1 off. e.g. a/b under current directory results in relative path "../a/b". i'd expect "a/b"

in general there (at least) 2 node objects in each context: - path: pointing location of wscript - root: pointing filesystem root

so in case solution utilize context.root:

def build(context): print context.path.abspath() print context.root.abspath() print context.root.find_dir('/mydir/a/b')

waf

javascript - When should prefer angular directive over html native tag? -



javascript - When should prefer angular directive over html native tag? -

i'm big fan of angularjs, started lately utilize in of 'coding fun' projects. have big curiosity:

i have 2 inputs, 1 disabled ng-disabled directive , other disabled html tag (a improve illustration in link):

//... <input type="text" disabled value="this html input text disabled" /> <input type="text" ng-disabled="true" value="disabled angular js directive" /> //...

using browser ability can right click on input , remove disabled , ng-disabled tags 1 disabled tag editable, other 1 still tracked angular when ng-disabled directives has been removed.

so, when , why should prefer using ng directives on native html tags? impact of letting angular track these actions? worth utilize everywhere?

use native html 'disabled' if element should disabled. (static, illustration if want provide input text , never allow user alter it) utilize angular if should alter based on variables value in scope.

for example, button should alter state of input.

<input type="button" ng-click="inpdisabled = true" >disable input</input> <input type="text" ng-disabled="inpdisabled" />

live example

no harm come if still utilize ng-disabled="true" it's redundant.

javascript html angularjs angularjs-directive

c# - What control is used as inline listbox on windows phone 8? -



c# - What control is used as inline listbox on windows phone 8? -

cannot find appropriate command in standard set. there 3rd party realization? looks textbox until click it. expands show available options. illustration background color selector in windows phone settings. example img

represents selection command combines non-editable text box , drop-down list box allows users select item list.

how add together combo box (xaml)

c# windows-phone wpf-controls

bash - How do I handle password prompts when calling elisp from the terminal -



bash - How do I handle password prompts when calling elisp from the terminal -

i'm trying utilize elisp shell script language. i'm writing script need access file encrypted gpg. i'm not sure how handle password prompt. in examples below, programme called command line (bash).

first try:

#!/usr/bin/emacs --script (setq passwd-file "~/password.gpg") (save-excursion (let ((passwd-buffer (find-file passwd-file))) (switch-to-buffer passwd-buffer) (princ (buffer-substring 1 30))))

this lets me come in password in terminal, password shown in plaintext.

second try

#!/usr/bin/emacs --script (setq passwd-file "~/password.gpg") (setq pstring (shell-command-to-string (concat "gpg -d " passwd-file))) (princ pstring)

this gives error gpg: cannot open tty /dev/tty: no such device or address

you out of luck. first illustration suggests read-passwd not hide password input in non-interactive session, insert-file calls out epa encrypted files, in turn uses read-passwd gpg password input.

try study emacs maintainers m-x report-emacs-bug, asking them suppress input echo in read-passwd in non-interactive sessions. that'd behaviour i'd expect.

for now, cannot work around limitation, because emacs not expose underlying tty emacs lisp code, have no chance manually disable input echo on underlying tty device.

from experience in writing , contributing quite non-interactive emacs lisp programs, i'd advise against using emacs non-interactive scripts. it's poor platform such programs. api limited, , there lot of implicit behaviour standing in way of non-interactive programs, can't rid of.

for instance, cannot safely pass command line arguments emacs, since emacs automatically visit existing file in command line arguments, triggering sorts of side effects such prompts unsafe local variables, etc.

bash shell emacs elisp

java - google play apk expansion downloader library cause errors -



java - google play apk expansion downloader library cause errors -

i've imported project on workspace (i did't re-create it) , got 12 errors. application build target android 2.3.3. (minsdkversion "9" , maxsdkversion "14") problem have no thought sort of problems. application in google playstore , want editing codes can't build project. don't know reason why. i'm not expert on please give me help. how can prepare this?

problems 12 errors, 25 warnings, 0 others

errors (12 items)

error:error:string types not allowed(at 'configchanges'with value 'orientation|keyboardhidden|screensize'). error:error:string types not allowed(at 'configchanges'with value 'orientation|keyboardhidden|screensize'). network_type_ehrpd cannot resolved or not field network_type_hspap cannot resolved or not field network_type_lte cannot resolved or not field notification.builder cannot resolved type notification.builder cannot resolved type container 'android dependencies' references non existing library'/users/downloads/folder/downloader_library/bin/downloader_library.jar' project cannot built build path errors resolved type_bluetooth cannot resolved or not field type_ethernet cannot resolved or not field

the library not found:

the container 'android dependencies' references non existing library'/users/downloads/folder/downloader_library/bin/downloader_library.jar'

make sure path correct.

java android eclipse importerror android-expansion-files

javascript - Which Element property is connected to the CSS `:checked` selector? -



javascript - Which Element property is connected to the CSS `:checked` selector? -

i'm using css :checked selector, like

.mycheckbox:checked { // style checked state }

but, when set

$('.mycheckbox').each(function() { this.checked = false });

the above css remains matched.

how can above :checked css rule stop matching?

your code works absolutely fine me: http://jsbin.com/xakugemi/1/edit?html,css,output. check checkbox , click uncheck button. notice missing browser back upwards :checked selector in ie<8.: http://caniuse.com/#search=checked.

javascript jquery css dom

angularjs - angular-strap timepicker saves different time -



angularjs - angular-strap timepicker saves different time -

i using angular-strap save date , time project, time beingness displayed not same time beingness saved. can not find info anywhere on fixing issue. has else had problem?! screen shot of data

the value 2015-04-21t09:00:00.000z means talking specific point in time described "the 21. of apr in year 2015, @ 9 o'clock utc". is, includes time zone denoted trailing z. timepicker utilize automatically presents value user, exact same point in time, takes time zone scheme set account.

tl;dr value correct. utilize value calculations , store value in database. whenever nowadays value user, convert time zone.

angularjs twitter-bootstrap datetime timepicker angular-strap

How to add a new field to a model with new django migrations? -



How to add a new field to a model with new django migrations? -

i'm using contribute_to_class method don't know how create field in db new migrations.

to reply question, new migration introduced in django 1.7, in order add together new field model can add together field model , initialize migrations ./manage.py makemigrations , run ./manage.py migrate , new field added db. avoid dealing errors existing models however, can utilize --fake:

initialize migrations existing models:

./manage.py makemigrations myapp

fake migrations existing models:

./manage.py migrate --fake myapp

add new field myapp.models:

from django.db import models class mymodel(models.model): ... #existing fields newfield = models.charfield(max_length=100) #new field

run makemigrations 1 time again (this add together new migration file in migrations folder add together newfield db):

./manage.py makemigrations myapp

run migrate again:

./manage.py migrate myapp

django django-models django-1.7 django-migrations

android - Change the return type in Asynctask -



android - Change the return type in Asynctask -

i want write async task homecoming custom object.

@override protected string doinbackground(string... stations) { path pt= dosearch(source.gettext().tostring(),destination.gettext().tostring()); homecoming pt; } @override protected void onpostexecute(string result) { }

is possible homecoming object of class path doinbackground() function , utilize object in onpostexecute() method?

just alter type of result asynctask

sample:

private class viewasyntask extends asynctask<string, void, path> { @override protected path doinbackground(string... stations) { path pt= dosearch(source.gettext().tostring(),destination.gettext().tostring()); homecoming pt; } @override protected void onpostexecute(path result) { } }

as see asynctask<void, void, path> , path means result value of doinbackground

as documentation of it:

1. params, type of parameters sent task upon execution. 2. progress, type of progress units published during background computation. 3. result, type of result of background computation.

android android-asynctask