Posts

Showing posts from February, 2015

code coverage - how to change the path of source file which was referred gcda? -

when build project coverage testing "--coverage -fprofile-arcs -ftest-coverage", , move build , source other user directory execute testing. many problems such "xxx/cc/cc/getopt_log.c:cannot open source file" the details below: processing cs/cmakefiles/cfa/__/src/base/fault_injection.c.gcda /home/cov/build/xfcq/src/base/fault_injection.c:cannot open source file the path of "/home/cov/build/xfcq/src/base/fault_injection.c" path of build environment, how change relative path or path specified. i tried use gcov_prefix , gcov_prefix_strip, these can't work me. i tried add -b option lcov, not work me. e.g., lcov --gcov-tool=/bin/gcov -d . -b xx/src -t "xfcq" -o test_cov.info do have idea resolve it? well using gcov coverage process should never move files after building project, instead should modify automated build scripts build desired location. when compile project specified options generates *.gcno files each source

postgresql - Performance and index usage for function based queries and function calls inside functions -

i'm trying improve performance of postgresql functions , function calls inside functions. in our application, postgresql (9.6) queries totally based on functions. example, in order fetch lot of "items" code lines below might used: create or replace function public.item_read_one( "itemid" integer) returns jsonb $body$ declare outputvariable jsonb; begin select row_to_json (my_subquery) ( select id, "simplefield1", "simplefield2", item_status(id,"crucialfield") status item_table id = $1 , deleted not true) my_subquery outputvariable ; return outputvariable; end; $body$ language plpgsql volatile cost 100; alter function public.item_read_one(integer) owner some_user; you see, inside inner select there - beside simple fields - function call. these inner functions plv8 based , contain lot of javascript logic, including database queries. example might such: create or replace function pub

configuration - Apache Reponse timeout -

i have configure apache2 ubuntu 14.04 odoo.db has on 100000 records partners. loading them background. same way products loading. products loading fine, partner not loading. can 1 me this. apache proxy configuration. ` servername odoo-bhaviraj.com serveralias odoo-bhaviraj.com loglevel warn errorlog /var/log/apache2/odoo-bhaviraj.com.error.log customlog /var/log/apache2/odoo-bhaviraj.com.access.log combined proxyrequests off proxypreservehost on proxyvia full proxytimeout 18000 keepalive on proxypass / http://localhost:8069/ proxypassreverse / http://localhost:8069/ proxypass / http://127.0.0.1:8069/ proxypassreverse / http://127.0.0.1:8069/ </virtualhost> odoo.conf file [options] ; password allows database operations: admin_passwd = admin db_host = localhost db_port = 5432 db_user = acespritech db_password = 123456 addons_path = /home/bhaviraj/project/erp/odoo/odoo_8/addons ## logging group - logging configuration logfile = /var/log/odoo/odoo-server.log lo

Facebook login like Pinterest style -

i want integrate pinterest style facebook login website. there way this? pinterest facebook login style i have solution, it's not optimal. found pinterest uses endpoint generate it's nice button: facebook.com/v2.7/plugins/login_button.php ; however, generated output seems tied pinterest facebook application id (i tried inputting id received standard login button per facebook documentation here ). so hacky solution presented comes combining scottyg's answer this question iframe taken pinterest site following: <div style="position:relative;"> <iframe name="f34219de7beb196" width="268px" height="50px" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="fb:login_button facebook social plugin" src="https://www.facebook.com/v2.7/plugins/login_button.php?app_id=274266067164&channel=https%3a%2f%2fstaticxx.facebook.com%

url - Add a domain prefix to a $relativepath string in a Moodle PHP file -

this php snippet in moodle:- require_once(dirname(dirname(__file__)) . '/config.php'); require_once($cfg->libdir . '/filelib.php'); require_once($cfg->dirroot . '/webservice/lib.php'); // allow cors requests. header('access-control-allow-origin: *'); //authenticate user $token = required_param('token', param_alphanum); $webservicelib = new webservice(); $authenticationinfo = $webservicelib->authenticate_user($token); //check service allows file download $enabledfiledownload = (int) ($authenticationinfo['service']->downloadfiles); if (empty($enabledfiledownload)) { throw new webservice_access_exception('web service file downloading must enabled in external service settings'); } //finally can serve file :) $relativepath = get_file_argument(); file_pluginfile($relativepath, 0); this made relevant file resolved index.html without direct path. what trying modify line $relativepath = get_file_argument();

Troubles with pdf.js promises -

i'm trying implement pdf word count in javascript. came across pdf.js uses promises. there way wait till script done before returning count? know goes against idea of promises, other js pdf readers out there either produce bunch of gibberish or return nothing. in current form function return word count of 0. function countwords(pdfurl){ var pdf = pdfjs.getdocument(pdfurl); var count = 0; pdf.then(function(pdf) { var maxpages = pdf.pdfinfo.numpages; (var j = 1; j <= maxpages; j++) { var page = pdf.getpage(j); var txt = ""; page.then(function(page) { var textcontent = page.gettextcontent(); textcontent.then(function(page){ for(var i=0;i<page.items.length;i++){ txtadd = page.items[i].str txt += txtadd.replace(/[^a-za-z0-9:;,.?!-() ]/g,''); } count = count + txt.split(" ").length; }) }) }

Read data from file and sum over specific columns after hitting specific line (string) using C++ -

i decided open new thread if problem solved partially problem 1 right ( read data file 2d array , sum on specific arrays using c++ ). nevertheless, here want read in: calculation number of points: 200 # atoms: 4 point 1 : 0.00000000 0.00000000 0.00000000 weighting = 0.00500000 energy 1 # weighting 1.00000000 atom b c d 1 0.476 0.000 0.000 0.100 2 0.476 0.000 0.000 0.100 1 0.000 -0.000 -0.000 0.200 2 -0.000 -0.000 0.000 0.200 energy 2 # weighting 1.00000000 atom b c d 1 0.476 0.000 0.000 0.300 2 0.476 0.000 0.000 0.300 1 0.000 -0.000 -0.000 0.400 2 -0.000 -0.000 0.000 0.400 energy 2 # weighting 1.00000000 atom b c d 1 0.476 0.000 0.000 0.500 2 0.476 0.000 0.000 0.500 1 0.000 -0.000 -0.000 0.600 2 -0.000 -0.000 0.000 0.600 .... .... #include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> using namespace std; int main() { int rows = 0; int columns = 0; string line; int firstnum

c# - StreamReader code raises exception after converting it to DesktopBridge APP -

i have small wpf application uses below code. reads said file display content. using (streamreader streamreader = new streamreader(@"terms\license.txt", encoding.utf8)) { .... } this code works correctly in wpf application. when ... use desktopbridge convert wpf appx , installed .appx. same code throws exception. exception info: system.io.directorynotfoundexception. any clue ? assistance ? regards please see preparation guide desktop bridge apps on msdn , make appropriate compatible code change app: https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-prepare your app uses current working directory. @ runtime, converted app won't same working directory specified in desktop .lnk shortcut. need change cwd @ runtime if having correct directory important app function correctly. thanks, stefan wick - windows developer platform

c preprocessor - How to process C++ file to remove ifdef'd out code -

i have inherited piece of c++ code has many #ifdef branches adjust behaviour depending on platform ( #ifdef __win32 , #ifdef __apple__ , etc.). code unreadable in current form because these preprocessor directives nested, occur in middle of functions , in middle of multi-line statements. i'm looking way of somehow specifying preprocessor tags , getting out copy of code if code had been pre-processed flags. i'd headers left untouched, though. example: #include <iostream> #ifdef __apple__ std::cout << "this apple!" << std::endl; #elif __win32 std::cout << "this windows" << std::endl; #endif would turn into: #include <iostream> std::cout << "this apple!" << std::endl; after being processed by: tool_i_want example.cpp __apple__ . i've hacked quick script similar, i'd know of better tested , more thorough tools. running linux distribution. i have decided against running c-prepr

linux - Docker DNS settings -

i try create docker container custom network , dos settings. docker network create --driver=bridge --opt "com.docker.network.bridge.enable_ip_masquerade"="true" --opt "com.docker.network.bridge.enable_icc"="true" --opt="com.docker.network.driver.mtu"="1500" --opt="com.docker.network.bridge.host_binding_ipv4"="0.0.0.0" net -- docker run --dns 10.0.0.2 --network=net busybox cat /etc/resolv.conf nameserver 127.0.0.11 options ndots:0 else if use standard network work fine docker run --dns 10.0.0.2 --network=bridge busybox cat /etc/resolv.conf nameserver 10.0.0.2 as of docker 1.10, dns managed differently user-defined networks. dns default bridge network unchanged backwards compatibility. in user-defined network, docker daemon uses embedded dns server. according documentation found here: https://docs.docker.com/engine/userguide/networking/c

c# - Nhibernate envers, use dependency injection to add user into revision entity -

after reading this , this come near solution not end since miss how apply implementation. i have custon revision entity , revision listner: public class _nhreventity : defaultrevisionentity { public virtual int idutente { get; set; } } public class enversrevisionlistener : irevisionlistener { private int _username = 0; public enversrevisionlistener(iusermanagement um) : base() { _username = um.utentecorrente.id; } public void newrevision(object revisionentity) { var casted = revisionentity _nhreventity; if (casted != null) { casted.idutente = _username; } } } and sessionfactory public class sessionfactory : idisposable { private static isessionfactory _sessionfactory; private static nhibernate.cfg.configuration cfg = new nhibernate.cfg.configuration(); static readonly object factorylock = new object(); private static void initializesessionfactory() { _sessionfactory = fluently.

scala - What does '&' and '%' mean in operators -&, -%, +&, +% in Chisel3? -

i'm trying learn chisel3 gcd example given in official web page . example use operator named -%, mean ? it's not explained on wiki operator page . , cheatsheet says "substraction" normal substraction symbol '-'. then difference between simple substraction '-' , percent substraction '-%' ? [edit] ok, found definitions of these functions under chisel3 code : // todo: refactor share documentation num or add independent scaladoc def unary_- : uint = uint(0) - def unary_-% : uint = uint(0) -% def +& (other: uint): uint = binop(uint((this.width max other.width) + 1), addop, other) def + (other: uint): uint = +% other def +% (other: uint): uint = (this +& other) tail 1 def -& (other: uint): uint = binop(uint((this.width max other.width) + 1), subop, other) def - (other: uint): uint = -% other def -% (other: uint): uint = (this -& other) tail 1 def * (other: uint): uint = binop(uint(this.width + other.wi

email integration - Deferred: Connection timed out with mail.example.com (With Sendmail) -

i have configured sendmail on ubuntu server. mail going other emails , domains perfectly. 1 domain getting following error, please suggest: nov 8 09:24:24 abcweb02 sm-mta[471]: ua894lay000402: to=, ctladdr= (33/33), delay=00:19:25, xdelay=00:09:06, mailer=esmtp, pri=210473, relay=mail.example.com. [44.44.444.44], dsn=4.0.0, stat=deferred: connection timed out mail.example.com. the issue resolved following check telnet connection on 25 port (telnet not getting connected firewall rules modified 25 port) i using wrong smtp credentials.

mongodb performance issue when fetching facet count and data -

i'm new using mongodb. have collection of documents this: { "_id" : objectid("58204f60536d1a27736d512b"), "last_name" : "vinaykumar", "university_name" : "osmania university", "job_483" : 1, "xiith_mark" : 0, "id" : "3305775", "first_name" : "v", "course_name" : "diploma", "institute_name_string" : "govt.polytechnic,kothagudem", "profile_percentage" : 60, "xiith_mark_type" : "percentage", "xth_mark_type" : "percentage", "date_of_birth" : "11-march-1995", "xth_mark" : 0, "last_login" : 1379565790, "percentage" : 76, "job_details" : [ { "status" : numberlong(0), "applied_date" : numberlong(1476703354),

c# - Losing application Name from URL -

i using iis host internal site. have used visual studio express web. the problem having when try go part of web site drops application name have given in iis example: www.name.com/applicationname/home (this whats working) after trying move part of site url becomes www.name.com/home/showdevice?sendmsg=192.168.0.1 (this not work) if add /applicationname/ above url works correctly. is , iis issue need configure or there in code need fix.

phpmyadmin won't change MySQL TINYINT(1) to BOOLEAN data type -

i'm running mysql 5.5.47 , have number of database tables have columns data type of tinyint(1) . i'm attempting change these boolean won't change them. using phpmyadmin 4.6.0 going structure i'm using dropdown set columns boolean . executes following query: alter table `feedback` change `tick_receive_updates` `tick_receive_updates` boolean not null; the query runs successfully. when view structure not update: columns still marked being tinyint(1) at first thought phpmyadmin bug ran describe feedback; unfortunately problem remains - columns have not changed tinyint(1) why this? this normal behavior boolean synonym of tinyint(1) mysql 5.7 reference manual - 12.1.1 numeric type overview bool, boolean these types synonyms tinyint(1). value of 0 considered false. nonzero values considered true:

python pptx - check if object is a table, textbox or image -

i use python 2.7 python pptx, i need build general function center objects in slide. i know how center individual object type (textbox, table, image etc.) , need build function tell type of object given object , allign properley. i need similar to: if foo bar condition. i found table general object here enter link description here , used following code: if table pptx.shapes.graphfrm.graphicframe.table: print "what" it not work, how can check if object type of pptx object thanks! the actual objects can appear on slide shapes. visually, there might items "show through" slide master or layout, logo instance, object standpoint, slide contains shapes , that's it. so objects "on" slide in slide.shapes , , can identify type of each 1 using shape.shape_type . 1 of values in mso_shape_type enumeration , of table one. this code enumerate shape types on given slide: for shape in slide.shapes: print(shape.s

r - Rotate switched facet labels in ggplot2 facet_grid -

i plot barplots on top of each other using facet_grid: library(ggplot2) df <- group_by(mpg, manufacturer) %>% summarise(cty = mean(cty), hwy = mean(hwy)) %>% ungroup() df <- melt(df, id.vars = "manufacturer") ggplot() + geom_bar(data =df, aes(x = variable, y = value), stat = "identity") + facet_grid(manufacturer ~ ., switch = "y") i use switch argument of ggplot2::facet_grid() to let facet labels displayed on y-axis instead of on top of each facet. problem facet labels plotted vertically , therefore cropped. there way plot facet -labels horizontally? questions found far related rotating x-axis labels only, not facet labels. you need add theme() , specify angle in strip.text.y library(ggplot2) df <- group_by(mpg, manufacturer) %>% summarise(cty = mean(cty), hwy = mean(hwy)) %>% ungroup() df <- melt(df, id.vars = "manufacturer") ggplot() + geom_bar(data =df, aes(x = variable, y = value),

Customer layer solutions in perforce or in eclipse -

i have question regarding customer layer solutions in perforce or in eclipse this problem in general. our source control (perforce) set include one folder generic code second folder customer layer code (same folder tree , same file names) in same p4 workspace development environment problem now having problem create development environment overweight core code,with customer code , allow developer see changes in perforce if copy files , try use perforce reconcile p4v cannot tell if need change code in customer section or in core section may ask add new file incorrect location , on i have 1 solution in mind form perforce side bit complicated run on customer folder , create perforce symlink in relevant core folder add trigger add , delete file in customer folder , add or remove link in core folder so developer have 1 tree work on , p4 see changes in correct place my questions are 1. there better way in p4? is there way config eclipse @ folders , bui

html - Getting innerHTML from an [object, HTMLUnknownElement] with JavaScript (No JQuery) -

so, i'm writing script finds elements tagname of ui , , prints console content inside of tags: <ui>content_here</ui> i using following code perform action. var e = document.getelementsbytagname('ui'); (var = 0; < e.length; i++) { if (e[i].tagname.tolowercase() === 'ui') { console.log(e[i].innerhtml()); } } for code, given error: e[i].innerhtml not function(...) on printing out e[i] on own, given <ui>content_here</ui> output. what take content inside of tags , print screen? note - have tried using .html() , .value() also. no jquery please. thanks. just remove parenthesis access property. console.log(e[i].innerhtml); // ^^ var e = document.getelementsbytagname('ui'); (var = 0; < e.length; i++) { if (e[i].tagname.tolowercase() === 'ui') { console.log(e[i].innerhtml); } } <ui>content_here</ui>

javascript - CKEDITOR EqnEditor(Math plugin) not working on multiple instances on same page -

i using ckeditor (anuglar-ckeditor) , added eqneditor plugin write mathematical expression. working fine single instance of ckeditor on 1 page. if add multiple instance of ckeditor on same page, eqneditor's hover not working. in case, if have 2 instance on single page, , open eqneditor first instance working, when go second instance editor's eqneditor, hover icon not showing. same thing happening when reverse it. if open second instance first eqneditor work fine second instance, not first. found solution here not working me. have same problem link. here plugin in config.js file :- config.extraplugins = 'eqneditor', i don't know if topic still open discussion, felt @ same problem week, , i've developed solution. https://github.com/ygorlazaro/eqneditorfix it's .js file need add @ project, , i'll fix error. this code removes , adds from/to dom eqneditor. @ case, if eqneditor binded event @ ckeditor, give 'reload'. working

passing python data to javascript in web2py -

here problem. have following function def index(): rows=db(db.mylist).select() return dict(rows=rows) so whenever reload the front view index want retrieve rows database , display data user in list {{for(r in rows)}} li.innerhtml={{=rows.task}} {{pass}} obviously, not right way it. think have use json , xml. this table using db.define_table( 'mylist', field('task', 'string') ) <div class="col-sm-6"> <div class="panel panel-default"> <div class="panel-heading center " style="color: black; font-style: inherit"> <form> task: <input name="name" id="task" /> <button type="button" class="btn btn-success btn-sm" onclick=add(),ajax('{{=url('default','insert_task')}}',['name']) >add</button>

objective c - How to bring IOS app from background to foreground without using local notification? -

is there way bring app foreground running in background without sending local notification? there no way programatically foreground app. if think it, allowing developers have significant consequences user experience.

mysql - My SQL Script erro 1071 - Does Not Work ADD UNIQUE or Change ENGINE -

`create table if not exists `odin`.`usuario` ( `codusuario` int not null auto_increment, `codtipousuario` int not null, `codconsultortecnico` int null, `codprodutor` int null, `login` varchar(255) character set 'utf8mb4' not null, `senha` varchar(32) character set 'utf8mb4' not null, `ativo` tinyint(1) not null, `maiordataregistrada` datetime not null, `datalimite` datetime not null default '01/01/2014', `maxfazendas` int not null default 0, `maxfemeas` int not null default 0, `coduserweb` int not null default 0, `codestudante` int null, `ultimobackup` datetime null, primary key (`codusuario`), unique index `uq__usuario__00000000000006d8` (`login` asc), constraint `fk_usu_ref_est` foreign key (`codestudante`) references `odin`.`estudante` (`codestudante`) on delete no action on update no action, constraint `fk_usuario_ref_consultor` foreign key (`codconsultortecnico`) references `odin`.`consultort

php - Can't access stdObject array using [] or -> operators -

this question has answer here: how can access array/object? 4 answers i have stdobject , var_dump result below: var_dump($name) array(1) { [0]=> object(stdclass)#853 (2) { ["firstname"]=> string(2) "john" ["lastname"]=> string(8) "smith" } } i trying make new variable $fullname using $name['firstname].$name['lastname'] . doesn't work, gives error undefined index then tried using -> operator on $name->firstname + $name->lastname . gives error: trying property of non-object how go this? $name[0]->firstname . $name[0]->lastname; basically trying access array object. can see var_dump variable contains array. array contains object 2 properties. $name[0] gives object, , ->firstname accesses firstname property of object.

Calculate duration of project in Dynamics CRM 365 -

Image
in our dynamics 365, each project - we're showing created on date field. field represents date on project created. however, we're supposed show duration of project. like @ many places, have these on stackoverflow: asked n minute ago asked n day ago asked n week ago asked n month ago and on... we wanted show: created n minute ago created n day ago created n week ago created n month ago and on... how calculate duration of project in dynamics crm 365? running jobs not option us if need fields calculated display purposes this create new fields register new plugin on post retrieve , retrievemultiple of project entity copy logic code below, swapping entity/field names needed. what code doing intercepting contact records whenever they're displayed in crm. means in grids, forms, dashboards etc. it'll calculate time difference on spot , populate fields result. populating entity object in outputparameters, front end receives value

java - How To display Admob interstitial every time a button is clicked -

i know how display admob interstitial ad every time button pressed. have managed display interstitial ad, on first time button pressed. here code: package com.mycash.borgjake.mycash; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.widget.button; import android.widget.textview; import android.view.view; import com.google.android.gms.ads.adlistener; import com.google.android.gms.ads.adrequest; import com.google.android.gms.ads.adview; import com.google.android.gms.ads.interstitialad; import static com.mycash.borgjake.mycash.r.styleable.view; public class mainactivity extends appcompatactivity { private interstitialad minterstitial; button btnclick; button btnwithdraw; textview txtbalance; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); adview adview = (adview)findviewbyid(r.id.adview); adrequ

linux kernel - get_user_pages() to pin memory across syscall -

according the kernel inline comment gup api: "this not guarantee page exists in user mappings when get_user_pages returns, , there may different page there in cases (eg. if mmapped pagecache has been invalidated , subsequently re faulted). guarantee page won't freed completely. , callers care page contains data valid at point in time . typically, io or similar operation cannot guarantee stronger anyway because locks can't held on syscall boundary." i assume have put_page() before return user space. find ib_umem.c get_user_pages() in syscall , put_page() in syscall. want same in driver. same? thanks. update on nov 10, 2016: ok, know reason. gup can pin page not freed. cannot lock vma point same page. ib_umem not solve problem, ib_umem_get() , ib_umem_release() should remain in same syscall scope. i found solution such http://lwn.net/articles/600502/ . tried introduce vm_pinped flags pin vma. seams nobody interested in. why?

java - Spring UnexpectedRollbackException in nested @Transactional method -

i have dao class ( mydao ) marked @transactional annotaion (on class level) no additional parameters. in dao class have method in case needs throw checked exception , perform transaction rollback. this: @transactional public class mydao { public void daomethod() throws mycheckedexception() { if (somethingwrong) { transactionaspectsupport.currenttransactionstatus().setrollbackonly(); throw new mycheckedexception("something wrong"); } } this works fine. however, dao method called service method, marked @transactional: public class myservice { @autowired private mydao mydao; @transactional public void servicemethod() throws mycheckedexception { mydao.daomethod(); } } the problem when daomethod() called servicemethod() , marks transaction rollback only, unexpectedrollbackexception . under hood, spring creates 2 transactional interceptors: 1 mydao , 1 myservice . when daomethod() marks

ggplot2 - italicize suffix of a plot label in R -

Image
i have heatmap 1 label sting of 2 words separated ", ". italicize suffix of label while retaining unchanged font prefix. realize there questions addressing similar issues , apologize if repeated question i've been unable apply of solutions questions particular problem. i have following code generates plot: ggplot(mockdata, aes(variable, measurement)) + geom_tile(aes(fill = mockdata$plotval), colour = "dark red") + facet_grid(category~type, scales='free', space='free') + scale_fill_gradient2(limits=c(-20, 20),high = "firebrick3", low = "dodgerblue4") + theme_minimal() + theme(axis.text.x=element_text(size=28, angle=90), axis.text.y=element_text(size=28)) + labs(title="", x="", y="", fill="") + theme(strip.text.x=element_blank(),strip.text.y=element_text(size=20, angle=0)) i prefix (here number 23:42 string) remain unchanged whilst setting suffix in italics. how

python - Why is ShuffleSplit more/less random than train_test_split (with random_state=None)? -

consider following 2 options presented: #!/usr/bin/env python3 # -*- coding: utf-8 -*- #sklearn.__version__ 17.1 #python --version 3.5.2, anaconda 4.1.1 (64-bit) #ipdb> typeerror: __init__() got unexpected keyword argument 'n_splits' #none #> <string>(1)<module>() import numpy np sklearn.datasets import load_boston #from sklearn.model_selection import train_test_split, cross_val_score #from sklearn.model_selection import shufflesplit sklearn.cross_validation import train_test_split, cross_val_score sklearn.cross_validation import shufflesplit sklearn.ensemble import gradientboostingregressor # define feature matrix , target variable x, y = load_boston().data, load_boston().target # create algorithm object (gradient boosting) gbr = gradientboostingregressor(n_estimators=100, random_state=0) #==================================================== # option b #==================================================== #shuffle = shufflesplit(n_splits=10, train

node.js - Unable to ltrim when Redis list is having only one record -

i try trim records in redis queue using following command. unfortunately, unable trim if there 1 item in list. ltrim key, -1, 0; for ltrim key start_index stop_index command, index 0 based. 0 index of first element, , -1 index of last element. if start_index larger stop_index , redis clears list, i.e. deletes key . base on above definition, let's take @ command: ltrim key -1 0 the start_index -1 , i.e. index of last element, , stop_index 0, i.e. index of first element. if list has more 1 elements, start_index larger stop_index . in case, list / key deleted. however, if there's 1 element in list, both start_index , stop_index index of first (also last) element of list. command has same effect as: ltrim key 0 0 . command, redis keeps first element (also element) of list, , list won't trimmed . by way, want delete list? if do, call del key .

unit testing - What are the advantage of using RequestsClient() over APIClient()? -

i writing unittest django-rest-framework api endpoints. in version 3.5 , have added requestsclient(). documentation says - rather sending http requests network, interface coerce outgoing requests wsgi, , call application directly. from understanding, think requestsclient() useful network request different servers. not sure if has advantage in same server? there advantage of using requestsclient() on apiclient() ? if you're not sure, use standard apiclient . requestsclient useful if either: you intend interacting api python service , want tests work @ same level. you want write tests in way allows run them against live or staging environment.

numpy - Interpolate NaN values in a big matrix (not just a list) in python -

i'm searching simple method interpolate matrix 10% values nan. instance: matrix = np.array([[ np.nan, np.nan, 2. , 3. , 4. ], [ np.nan, 6. , 7. , 8. , 9. ], [ 10. , 11. , 12. , 13., 14. ], [ 15. , 16. , 17. , 18., 19. ], [ np.nan, np.nan, 22. , 23., np.nan]]) i found solution uses griddata scipy.interpolate, solution take time. (my matrix have 50 columns , 200,000 rows , rate of nan values not higher 10%)

java - Spring boot and Hibernate Transaction not working as desired -

i have spring boot application hibernate on mysql, , need use pessimistic locking logic services. i have scheduled job should update objects, happens following iteration doesn't take previous account, want put pessimistic logic service. so, scheduled task @scheduled(fixeddelay=3000, initialdelay=5000) public void checkswitchtoshutdown(){ // logger.debug("scheduled partito :"+ dateformat.format(new date())); list<interruttore> interruttori = interruttoreservice.findallswitches(); (int = 0; < interruttori.size(); i++){ interruttore interruttore = interruttori.get(i); interruttoreservice.toggleswitchnew(interruttore); } } interruttoreservice.toggleswitchnew on concrete implementation of service layer. implementation annotated @transactional the service method is: @override @transactional(isolation = isolation.serializable, readonly = false) public void toggleswitchnew(interruttore interruttore) { date nextti

visual studio - Task for a Bamboo Build plan fails when trying to get information from packages -

Image
i trying run msbuild task in atlassian bamboo test run of bamboo plan on local device. have created plan , retrieve code github successfully, being running default scoure control checkout. the first problem have system fail because msbuild task cannot referenced files. when looked manage nuget packages, says of packages missing, , when click restore of them restore of them have errors. i think main reason because of package microsoft.codedom.providers.dotnetcompilerplatform -version 1.0.0 not being installed correctly. error message says because path, file name or both long, have not named project build , running github. have tried install using package manager console same result. tried creating folders said file meant located not working either. i think problem package not found during package restore tried add nuget.config file. <?xml version="1.0" encoding="utf-8"?> <configuration>   <activepackagesource>    

CSS paint the table row when selected in a different color, (2 colored table) -

tr:first-child {background: green } tr {background: blue } tr:nth-child(even) { background-color: red} i got this, table different colored rows, blue , odd red. now have select part: .selected { background-color:black; color:white; } and in table problem, once press on red part, nothing happens, except change of text color...but when press on blue ones, works fine... any suggestions? here whole html: <!doctype html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <head> <link rel="stylesheet" type="text/css" href="css/selected.css" /> </head> <body ng-app="appstud"> <div ng-controller="ctrlstud"> <h2>students</h2> <form> <p>id</p> <input ng-model="student.id"> <p>name</p> <input ng-model="

jquery - How to augment JQueryStatic with SignalR methods -

i using typescript 2.0 , typed declaration file jquery. using signalr. signalr depends on jquery , adds properties it. example can write "$.connection.hub.logging = true;" signalr has added "connection" jquery. the typed declaration file jquery defines interface jquerystatic not export jquerystatic because $ being exported. $ of type jquerystatic. my question is, how write code using typescript 2.0 augments interface jquerystatic definition new property p1, "connection" example of? here couple ways: make sure using latest version of signalr type definition . looks if signalr definition augmenting jquerystatic . use typescript's declaration merging augment jquerystatic adding snippet below top of typescript file. declare global { interface jquerystatic { signalr: signalr; connection: signalr; hubconnection: signalr.hub.hubcreator; } }

javascript - Get Angular 2 .ts files instead of .d.ts files -

when work angular2 code need see implementation of class, let's router class. if click on router type in ide webstorm, e. g. inside constructor of class export class myclass { constructor(private router: router) {} // ... } my ide takes me typescript definition file router.d.ts inside node_modules folder. want take me original router.ts file implementation of router class, not definition . the original .ts file not included in node_modules folder structure when angular2 github via standard package.json suggested in angular2 quickstart. currently, have original code in the official github repo . any ideas how .ts files node_modules/@angular folder instead of .d.ts files? sadly, it's not possible since no ts files exist. if add them still not possible since import real angular paths point definition files. on top of file structure of project not correlate structure of import string literals. some background , more information the np

c# - Collection <T> class location in the .net framework -

the collection <t> class exists under system.collections.objectmodel namespace. why not exist under system.collections.generic instead? it's because: the system.collections.objectmodel namespace contains classes can used collections in object model of reusable library. use these classes when properties or methods return collections. and collection<t> can used collection in object model of reusable library. see https://msdn.microsoft.com/en-us/library/system.collections.objectmodel(v=vs.110).aspx the full explanation here: https://blogs.msdn.microsoft.com/kcwalina/2005/03/15/the-reason-why-collection-readonlycollection-and-keyedcollection-were-moved-to-system-collections-objectmodel-namespace/ (that appears explain real reason, if ask me...)

sendkeys - C#: Unable to send Ctrl+m -

i have bho form installed on ie, has capability send key strokes. i trying send key strokes is: "^m" using sendkeys . here code trying. sendkeys.send("^m"); this code works on windows 7 doesn't work on windows 2008 r2. i have tried "^(m)" , "^{m}". can 1 please suggest me in how can send ctrl+m.? for trouble shooting have tried sending ^a. worked expected in both os. not sure, why ^m not working. any appreciated.

r - Set axis limits for plot.PCA - strange behaviour (FactoMineR) -

Image
i want plot result of pca package factominer. when 1 plots pca practice resize graph h/l ratio in proportion %variance explained each axis. so tried first resize graph stretching window: fails , keep points in middle instead of stretching them too. library(factominer) out <- pca(mtcars) then try force xlim , ylim arguments fixed ( ?plot.pca ) plot.pca(out, choix="ind", xlim=c(-6,6), ylim=c(-4, 4)) same problem, xlim limits not respected... can explain behaviour , knows how fix it? what you're seeing result of call plot inside plot.pca : plot(0, 0, main = titre, xlab = lab.x, ylab = lab.y, xlim = xlim, ylim = ylim, col = "white", asp = 1, ...) plot called parameter asp set 1 , guarantees y/x ratio stays same, when try resize window, xlim recomputed. in plot.window can find "meaning" of asp : if asp finite positive value window set 1 data unit in x direction equal in length asp * 1 data unit in y d

mysql - Fetch records of parent table depending on count of children -

i have 2 tables, a , b , b has foreign keys a (i.e. a can have 0 or many children in b whereas each b record belongs 1 a record). now want fetch records a the number of children in b lower x (including zero ). how can achieve comparison of aggregate function? select a.*, count(b.id) child_cnt left join b on a.id = b.foreign_id group a.id however, cannot add where condition child_cnt of course. pointers how desired result can achieved? you can use having filter result select a.*, ifnull(count(b.id), 0) child_cnt left join b on a.id = b.foreign_id group a.id having count(b.id) < x

c# - iOS Fit Image to Screen -

i have image 646x289 trying fit in screen respect aspect ratio. here current approach: controller: public override void viewdidlayoutsubviews() { base.viewdidlayoutsubviews(); _imnlogo.contentmode = uiviewcontentmode.scaleaspectfit; _imnlogo.sizetofit(); _imnlogo.frame = new cgrect( view.bounds.left + 2 * globals.margingrid, view.bounds.top + globals.margingrid, _scaledimage.size.width, _scaledimage.size.height); } public override void loadview() { base.loadview(); _scaledimage = maxresizeimage( uiimage.fromfile("imn_logo.png"), (float) view.bounds.width, (float) view.bounds.height); _imnlogo = new uiimageview(_scaledimage); view.addsubview(_imnlogo); } public uiimage maxresizeimage(uiimage sourceimage, float maxwidth, float maxheight) { var sourcesize = sourceimage.size; var maxresizefactor = math.max(maxwidth / sourcesize.width, maxheight / sourcesize.height); if (maxresizefactor >