Posts

Showing posts from January, 2010

c# - Readonly properties -

hi here try make method can loop on form , convert text box enter image description here read only=true read = false not working public static void unread only(form frm) { foreach (control item in frm.controls) { if (item textbox) { // item.readonly = false; } } } primarily problem not casting control textbox have access property want set. foreach (control item in frm.controls) { if (item textbox) { var textbox = item textbox; textbox.readonly = false; } } that said, controls can contain child control, need crawl entire form looking embedded text boxes. this check form , controls text boxes , set them read only public static void setreadonly(control frm) { var controls = new queue<control>(); controls.enqueue(frm); while (controls.count > 0) { var control = controls.dequeue(); if (control textbox) { ...

extract email addresses from Mailgun using python -

i trying extract email subscribers mailgun using this: members = requests.get('https://api.mailgun.net/v3/lists/<address>/members', auth=auth ) this works limits number of subscribers 100. have 600 people on list , need access them perform logic. understand there way over-ride 100 record limit have not found anything. thoughts? i'm stuck. mailgun documentation: click here! from documentation, looks api take limit parameter. should able subscribers via like: members = requests.get('https://api.mailgun.net/v3/lists/<address>/members', auth=auth, params={'limit':100, 'skip': 100} )

python - smf.ols summary and metrics for three-class classification -

i use scikit-learn modelling purposes, , have no experience in r. however, had specific request forward selective logistic regression , trying use statsmodels.formula.api.ols three-class classification. i found , modified function think working can't sure because can't interpret output. advice appreciated familiar statsmodels, particularly using statsmodels pandas. i have 2 main issues: i can't print summary table seems basis of results formatting class. error: valueerror: shapes (18,3) , (18,3) not aligned: 3 (dim 1) != 18 (dim 0) this related using ols classifier, doesn't work when restricting 2 classes. other methods , attributes, pvalues , rsquared, return similar errors. can't dig structure of summary() , can't find examples in documentation. examples appreciated. interestingly, params attribute contains meaningful output. however, can't interpret it, it's organized in columns 0, 1, 2. obviously, there 3 resultant equations , the...

visual studio code - In VSCode turn off the following warning Accessors are only available when targeting ECMAScript 5 and higher -

Image
the type script code writing compiles fine. issue in visual studio code see following warning. there similar question on compiling tyepscript works . see above warning , cannot figure out how turn off. i read update tsconfig.json far can tell mine correct. my tsconfig.json { "compileonsave": false, "compileroptions": { "outdir": "./dist/out-tsc", "sourcemap": true, "declaration": false, "moduleresolution": "node", "emitdecoratormetadata": true, "experimentaldecorators": true, "target": "es2017", "typeroots": [ "node_modules/@types" ], "lib": [ "es2016", "dom" ] } } if create application via angular cli, ng new project, create 2 tsconfig.json 1 in root folder of project , 1 in src folder. web pack when calling ng serve uses tsconf...

Image from a database that links it to another page using php mysql -

please help. created db mysql, , php page images taken db displayed. need these images, linked page. can me? here code <?php require_once 'dbconfig.php'; <body> <div class="container"><br /> <div class="row"> <?php $stmt = $db_con->prepare('select userid, userlink, userprice, useraddress, userpic tbl_users order userid desc'); $stmt->execute(); if($stmt->rowcount() > 0) { while($row=$stmt->fetch(pdo::fetch_assoc)) { extract($row); ?> <div class="col-xs-4"> <p><img src="user_images/<?php echo $row['userpic']; ?>" class="img-rounded" width="280px" height="200px" /> </p> <p><span class="page-header" style="width: 10px"><?php echo $userprice;?></span></p> <?php echo $useraddress...

python - SyntaxError: can't assign to function call (For Loop) -

hi trying create new array previous array. such in new array first element mean of first 20 elements existing array. here code. not sure why not working. #averages rpma=[] in range(9580): j in range (0,191600): a=rpm.iloc[j:j+20] rpma(i)= a.mean() looks me you're using wrong kind of brackets. line: rpma(i)= a.mean() ...should this: rpma[i]= a.mean() but i'm no python expert. guessing thinks rpma(i) function because use parentheses, in case trying assign value function call, error says. however trying assign new value past end of array result in indexerror because array element doesn't exist, , need added. can instead this: rpma.append(a.mean()) ...which append data end of array (i.e. adding new element).

single sign on - Azure configuration for seperate web site for pre authentication -

azure @ stackoverflow: have 1 mobile application web view launch 1 web site.web site have separate login mechanism.my mobile app use azure adfs auth.requirement bypass web site login screen or authenticate web site mobile web view. how need configure web site on azure have authentication mobile app?

javascript - Is there an easy way of running a program from a Firefox addon? -

i found runtime.connectnative , read overly complex (it requires os specific configuration of target executable, permissions addond , other over-engineered things). looking trivial solution on few lines like: const exec = require('child_process').exec; exec('pwd', (error, stdout, stderr) => { console.log(`stdout: ${stdout}`); }); from documentation (and others, jaromanda x, wrote) seems it's not possible without lot of boilerplate around native messaging. depending on trying achieve, might @ custom protocols. if program run initiated user, use link, e.g. "myschema://somearguments" run external program. more info there - http://kb.mozillazine.org/register_protocol#firefox_3.5_and_above .

vuejs2 - VueJS Watch not working -

i trying watch particular property of component. property array gets's updated every time checkbox selected. https://github.com/ratiw/vuetable-2/wiki/special-fields#-__checkbox this code trying this watch: { selectedto: function(val){ console.log(val); } }, neither did below code work watch : { selectedto: { handler(val, oldval) { console.log('item changed'); }, deep: true } }, vue console: http://prntscr.com/gb1gew you can watch $refs.<name>.<data> not $refs.<name> itself. reference on this: https://jsfiddle.net/kenberkeley/9pn1uqam/ still, though don't know how code works, try this.$watch(() => this.$refs.vuetable.selectedto, (val) => {...})

Sync Between Firebase and Onedrive -

i want move data in firebase database specific cells in myexcelsheets in onedrive folder. if changed ff:qq "2017excel" : "50kg" @ firebase database find filename "2017excel" , input data "50kg" @ cell (a1). maybe loooks macro. and programmer(beginner), want work above things firebase functions if not use tool. sorry poor english level. but please me problem. i'll looking forward response.

ios - How do get dimensions of elements in Xcode simulator -

Image
i'm running react native application in xcode simulator. check dimensions of elements , if possible change things temporarily see, have change in code. developer tools in chrome browser. possible? you can use react-devtools (see guide in official documentation ). when developer tools installed , running, can use regular element inspector debug tool react native developer menu ( cmd + d , show inspector ). now, instead of limited in-simulator inspector, have access chrome devtools experience, can inspect , edit element styles , props.

ecmascript 6 - How to communicate current item in a v-for loop to sibling component -

i building image gallery app using vuejs , 1 component of gallery scrolling carousel have taken vuetify library. carousel looks - <v-carousel :cycle="false" icon="none"> <v-carousel-item v-for="(image,index) in imagelist" :src="image" :key="index"> </v-carousel-item> </v-carousel> when scroll through carousel, want current image being displayed, i.e. current src binding v-carousel-item communicated sibling component. i having problems extracting current src javascript variable - once can figure out how other component. please help.

Difference in arithmetic and geometric mean to combine two images -

Image
i want know mean (arithmetic or geometric) better combine 2 grayscale images , why? know difference in arithmetic , geometric mean mathematically, combining 2 digital images, mean use , logic behind it...i unable understand. empirical answer... if start top-to-bottom , left-to-right gradient images, this: you arithmetic mean: and geometric mean:

reflection - Mirroring method in C# -

is there ways use, mirror method class? i.e. public class mymethods { public static double func_1 { } public static double func_2 .... .... .... } public class reflector { // call class, should redirected mymethods public something_autoloader_or_like_that{ ... } } as dynamically call reflector.func_888(); , , if method not found there, should search in mymethods , execute .

python - executemany is not working -

i want copy dataframe sql table, to_sql not working in machine due sqlalchemy issue. so, tried executemany option. but, getting error while execution. import pyodbc import pandas connstring = 'driver={microsoft odbc oracle};server=servername;uid=user;pwd=password;' cnxn = pyodbc.connect(connstring) cur=cnxn.cursor() df = pandas.read_sql_query(sql="select * users",con=cnxn) tbl_name = "users_new" wildcards = ','.join(['?'] * len(df.columns)) data = [tuple(x) x in df.values] print(data) [(u'p', u'poonam'), (u'm', u'mani'), (u'p', u'poonam'), (u'm', u'mani'), (u'p', u'poonam'), (u'm', u'mani')] dbcur = cnxn.cursor() #dbcur.execute("create table %s(id char(1), name char(9))" %(tbl_name)) dbcur.executemany("insert %s values(%s)" %(tbl_name,wildcards), [('1','11'),('2','22')]) #working cnxn.c...

recursion - Coding a recurrence relation in Java -

i writing code calculates recursive mathematical problem, called foo. the condition should be, if n < 4 : foo(n) = n if n >= 4 : foo(n) = n + foo(n - 1) + 2*foo(n-2) . public class foo { public static int foo(n) { if(n < 4) { return n; } else if(n >= 4) { } } public static void main(string[] args) { } } i stuck here... final purpose state values of foo(1), foo(2), foo(3), foo(4), foo(5), foo(6), foo(7). also, allowed put main method in foo class? the following function 1 you're looking for: public static int bar(int n){ if(n < 4){ return n; } return n + bar(n - 1) + 2*bar(n-2); } first of all, if want function call main directly, must static , because you're not allowed call non-static method static context. static functions (methods) called on classes, not on objects. therefor, there no need create object - execute foo.bar(anyint) . then, need check...

Python 3 Post JSON Requests to API -

i'm new @ python , have been reading how post json query requests module. reason following script doesn't work. have specified python3 version i'm using , version of requests module. output is: out[31]: <response [200]> what mean? missing? need use params? import sys print (sys.version) #3.6.1 |anaconda 4.4.0 (x86_64)| (default, may 11 2017, 13:04:09) #[gcc 4.2.1 compatible apple llvm 6.0 (clang-600.0.57)] import requests import json requests.__version__ #out[27]: '2.14.2' headers = {'content-type': 'application/json'} url = 'http://api.scb.se/ov0104/v1/doris/sv/ssd/start/be/be0101/be0101a/befolkningny' data = { "query": [ { "code": "region", "selection": { "filter": "vs:regionkommun07", "values": [ "0115", "0117", "0120" ] } }, { ...

javascript - How to close sign in poppup window? I selenium webDriver -

driver.get("https://www.redbus.in"); driver.findelement(by.xpath("//*[@class='icon-down icon ich dib icon-down_wo_bal']")).click(); driver.manage().timeouts().implicitlywait(30,timeunit.seconds); driver.findelement(by.id("signinlink")).click(); webelement sign=driver.findelement(by.classname("modaliframe")); driver.switchto().frame(sign); driver.findelement(by.classname("icon-close")).click(); i used code in eclips , try close redbus site in sign in popup window didn't closed.

haml - Rails form keep sending old values after error -

i have form reason keep same values after error. example, if enter name exists, me error , @ same time keep sending old value if change (so have refresh page , lose changes resolve error). = provide(:title, t(:create_task)) .center = form_for :task, url: tasks_path |f| = render 'shared/big_flash' = render 'task_error_messages' .row.text-center .col-lg-10.col-lg-offset-1.col-md-12.col-sm-12.col-xs-12 .jumbotron %h2= t(:create_task) .row .col-lg-6.col-md-6.col-sm-6.col-xs-12 = f.label t(:par_task_name) %i{class: 'material-icons text-muted', rel: 'tooltip', title: t(:tt_task_new_name)} info_outline = f.text_field 'name', maxlength: 255, class: 'form-control' = f.label t(:par_category) = f.collection_select 'category', category.order(:name), :name, :name, {}, {class: 'form-control'} ...

java - Running scanner while getting input from other sources -

currently i'm working on console application in java. i'm trying handle commands scanner while console gets input outside (netty information). my scanner looks this: public class commandhandler implements runnable { private scanner scanner = null; public void newscanner(){ if(scanner != null) { scanner.close(); scanner = null; } scanner = new scanner(system.in); system.out.println(scanner.next()); scanner.close(); scanner = null; newscanner(); } @override public void run() { newscanner(); } } i'm running scanner in new thread executorservice: thread commandhandler = new thread(new commandhandler()); executorservice.execute(commandhandler); (1) works fine. input netty , can type in commands. if @ same time, console puts input , input me so: this test[11:31:52/information] >> client 'lobby-01' connected. [127.0.0.1:8001] how can prevent that? inp...

c# - Make a Playlist Dynamically -

private queue<uri> playlist = new queue<uri>(); playlist.enqueue(new uri(@"d:\media1")); playlist.enqueue(new uri(@"d:\media2")); playlist.enqueue(new uri(@"d:\media3")); here making playlist hard coded. want populate playlist string array. how possible? my string array string[] mylist=new string[3]; mylist[0]=@"d:\media1; mylist[1]=@"d:\media2; mylist[2]=@"d:\media3; i have done this: for (int = 0; < mylist.length; i++) { playlist.enqueue(new uri(mylist[i])); mediaelement.play(); } but playing last media..... the problem mediaelement doesn't have playlist feature, can implement yourself. implement mediaendedevent mediaelement , play next element in string array. xaml code: <window x:class="wpfapp.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.co...

ios - XCode - Making ordered names imageView array? -

i made array of type uiimageview, , button add new imageview array want name each new image order image1, image2, image3 .. etc var array = [uiimageview]() @ibaction func addimage(_ sender: any) let newimage = uiimageview() self.view.addsubview(newimage) array.append(newimage) instead using name can work tag newimage.tag = array.count array.append(newimage)

reactjs - React Router DOM — How to include a navigation bar on every page? -

i have code in app.js component: render() { return ( <div> <navbar/> <browserrouter> <switch> <route exact path="/" component={home}/> <route path="/about" component={about} /> <route path="*" render={() => <redirect to="/" />} /> </switch> </browserrouter> </div> ); } now tried include link component in 1 of other components, figured out browserrouter has root element of app.js component, in order work. wonder how go making route element, if still want include navigation bar on every page. you should able place outside <switch> component. <browserrouter> <div> <navbar/> <switch> ...

html - Menu items order on mobile version (float problems) -

when menu go hamburger menu items display:block value. items don't right order because of float:right property on last 3 items. i stuck ideas, can make 2 menus think not right way. codepen preview here if want different order without creating 2 menus take @ using flexbox , order property: https://www.w3schools.com/cssref/css3_pr_order.asp in mobile view along lines of: header ul { display: flex; flex-direction: column; } header ul li:nth-child(5) { order: 7; } header ul li:nth-child(6) { order: 6; }

r - return number of specific element of vector based of its name -

this question has answer here: convert letters numbers 5 answers i need return number of element in vector based on vector element name. lets have vector of letters: myletters=letters[1:26] > myletters [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" and intent create/find function returns me number of element when called example: myfunction(myletters["b"]) [1] 2 myfunction(myletters["z"]) [1]26 in summary need way refer excel columns writing letters of column (a,b,c later maybe aa or further) , number. if want r...

winforms - Send Data Grid View data to other form in C# Windows Form Application -

i have 2 forms form1 , form2 . in form1 data database , fill `datagridview' data. customer customer = new customer(); var allcustomers = c in dc.gettable<customer>() select new getcustomers { firstname = c.firstname, lastname = c.lastname, mobile = c.mobile , customerid = c.customerid}; customerbindingsource.datasource = allcustomers; datagridview1.datasource = customerbindingsource; then, create event handler method customerid clicking on grid private void datagridview1_celldoubleclick(object sender, datagridviewcelleventargs e) { int customer_id = list_customers[e.rowindex].customerid; messagebox.show((customer_id).tostring()); } now, need send customer_id form2 information , display. any idea how achieve this? please help you can pass customer_id while creating instance of second form private void datagridview1_celldoubleclick(object sender, datagridviewcelleventargs e) { int customer_id = list_custo...

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot...

vb.net - Error 502 when sending base64_encode to the web -

i'm encoding text base64 encode, when send request server 502 error. example server follows: domain .com/?data=data encode looking forward helping problem, how fix it? tried post still made form unresponsive. code encode private sub base64en() dim bytestoencode byte() bytestoencode = encoding.utf8.getbytes(reend) dim encodedtext string encodedtext = convert.tobase64string(bytestoencode) reend = encodedtext end sub

c# - long polling api program doesn't make multi threads to make difference between users -

i have telegram bot api program using long polling run bot put function (that enable telegram bot) in global.asax , call in application_start() when start project telegram bot works until has 1 user, when 2nd user start work bot user 2nd user update doesn't make thread , works in following of 1st user progress! for example: user #1 send message (update) "answerform" bot pass first condition , wait user enter form id in long polling cycle, in time when user start bot , send message him bot receive user 1 form id! guessed make thread him don't know doesn't happen. how can solve this? static async void testapiasync() { try { var bot = new telegram.bot.telegrambotclient("my_token"); var me = await bot.getmeasync(); int offset = 0; while (true) { var updates = await bot.getupdatesasync(offset); foreach (var update in updates) { offset = update.id + 1;...

excel - Macro to add up values stored in variables in a row -

i have excel file shift details employees afternoon(a), night (n) , morning (m). values filled in row. every shift, there different shift allowances different level peoples. example: a=200, m=200 , n=400 i need sum shift allowances @ go. off course need define values of a, m , n manually before running macro. please help.

c++ - Send vector<int> through serial in json format -

for json parsing use https://github.com/nlohmann/json my code: ... #include <algorithm> #include <vector> #include <sstream> #include "json.hpp" using namespace std; using json = nlohmann::json; int main(int argc, char *argv[]) { // read json file std::stringstream ss; std::ifstream i("filee.json"); json j_complete = json::parse(i); std::vector < int > data_send_to_led; (int =0; i<j_complete["tablica"].size(); i++){ data_send_to_led.push_back(j_complete["tablica"][i].get<int>()); } (int =0; i<data_send_to_led.size(); i++){ cout <<"data send: "<< data_send_to_led[i]<<endl; } json j_vec(data_send_to_led); int* pv = &data_send_to_led[0]; ... n = write(sockfd,pv, data_send_to_led.size()); } how can send vector data_send_to_led json through serial? without knowing details of code json j_vec...

clang++ - Boost.Python Error when use class -

i got error typeerror: __init__() should return none, not 'nonetype' when use class in boost.python (i run simple "hello, world"). environment macos sierra i use pyenv-virtualenv python 3.6.0 $ source activate py36 i installed boost-python via homebrew $pyenv global py36 $brew install boost $brew install boost-python --with-python3 code this simple code tried ( test.cpp ). #include <boost/python.hpp> using namespace boost::python; int main(){ } class accumulator { public: int operator()(int v) { v_ += v; return v_; } int value() const { return v_; } private: int v_; }; boost_python_module(test) { class_<accumulator>("accumulator") .def("__call__", &accumulator::operator()) .add_property("value", &accumulator::value) ; } makefile cc = clang++ -std=c++11 -stdlib=libc++ python_root = /usr/local/...

node.js - Mysql Connection Lost When I Open A Http Proxy -

there code module.exports = { host: '127.0.0.1', user: 'root', password: '1236', database: 'netease' } const pool = mysql.createpool(database); const query = (sql, options, callback) => { pool.getconnection((err, conn) => { if (err) { callback(err, null, null); } else { conn.query(sql, options, (err, results, fields) => { callback(err, results, fields); conn.release(); }); } }); } // test query('select * singer singer=1', [], (err, res) => { console.log(err,res); }) if open vpn proxy such shodowsocks , error callback error: connection lost: server closed connection.(…) if close vpn mysql run normal without error. so confused if forget set mysql config when open vpn or other reasons?

laravel - how whereBetween handle to this query -

i want use wherebetween handle query select * schedules now() between start , end thank attentions you can this $schedules = db::table('schedule')->select('id', 'name') ->wherebetween( db::raw('now()'), [$startdate, $enddate]) ->get();

php - update immediately inserted rows without updating the older ones -

if inserted rows , want update 1 column value of rows inserted in process without update 1 column value of older rows inserted in previous process can see code , understand more clearly: <?php session_start(); ?> <form action="" method="post" name="data_table"> <tbody > <?php require_once("dbconfig.php"); error_reporting(0); $id=$_post['id']; $class=$_post['class']; $d = new datetime('now', new datetimezone('asia/baghdad')); $date=$d->format('y-m-d h:i:s'); $q="select * students class='$class'"; $qq=mysql_query($q) or die(mysql_error()); echo "<table border='2'> <tr> <th>الأسم</th> <th>الحضور</th> </tr><tr>"; while($row=mysql_fetch_array($qq)){ ?> <input type="hidden" name="class" value="<?php echo $row['class']; ?>" > <td><inpu...

android - i am working on media player i want to chnage the brightness of the screen when user slide on the left sideof the screen -

i use following code detect side user slide user not working @ suppose work relay.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent touchevent) { switch (touchevent.getaction()) { // when user first touches screen x , y coordinate case motionevent.action_down: { x1 = touchevent.getx(); y1 = touchevent.gety(); toast.maketext(videoplay.this, x1+""+x2, toast.length_short).show(); break; } case motionevent.action_up: { x2 = touchevent.getx(); y2 = touchevent.gety(); //if left right sweep event on screen if (x1 < x2) { toast.maketext(videoplay.this, "le...

c# - Telegram API (not Bot!): How to get chat/channel ID by link to it? -

i'm using library tlsharp on c# , writing telegram client, , @ moment got stuck. i have link chat/channel, instance, https://t.me/joinchat/some-string , , i'd info chat/channel or join it. can having chat_id, don't know how get. firstly thought contacts.resolveusername , passing "some-string" link. doesn't work, saying username invalid. is there way id of group? , on purpose make complicated info groups? thanks well, i've found solution (partial, see end). i'm using this schema, let know. first of need send rpc messages.checkchatinvite parameter hash set last part of link ("some-string" in case). a response of type tlchatinvite arrives. contain primary info group: it's type (chat or channel?), participant count and, if you're lucky, vector. (this point below problem of mine) call rpc messages.importchatinvite same parameter hash. returns tlupdates or tlupdatescombined object, contain vector of tl...

sql mysql Max() -

i need display query max statement don't know how. explain 2 simples tables understand better. 1 table family family ------ id int(1) - pk name varchar(255) 1 table person person ------ id int(1) - pk fk_id_family - fk family(id) first_name varchar(255) age int(1) content of tables family ------ 1 - dupont 2 - martin 3 - petit 4 - dupres person ------ 1 - 1 - jean - 70 (family dupont) 2 - 1 - jeannette - 65 (family dupont) 3 - 1 - pierre - 35 (family dupont) 4 - 1 - nicolas - 29 (family dupont) 5 - 2 - andre - 69 (family martin) 6 - 2 - ginette - 58 (family martin) 7 - 2 - benjamin - 25 (family martin) i need have query display family.name, person.first_name, person.age person older in family , family name there not person linked to. result one. dupont - jean - 70 martin - andre - 69 petit - null - null dupres - null - null thank help first need maximum age grouping fk_id_family in person table , join family . way, name , highest age to...

java - MessageSource getMessage method not working in Spring mvc -

i have developed spring mvc application want read property value properties file located inside of weblogic server. have performed following steps: created project specific folder appconfig in following path: oracle/middleware/oracle_home/user_projects/domains/wl_server/config/rmsconfig placed properties file named commonconfig.properties inside of it. have edited setdomainenv.cmd following entry, if not "%ext_post_classpath%"=="" ( set ext_post_classpath=%ext_post_classpath%;%domain_home%\config\appconfig if not "%post_classpath%"=="" ( set post_classpath=%post_classpath%;%ext_post_classpath% ) else ( set post_classpath=%ext_post_classpath% ) ) please find below spring bean configuration file this: <?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...

multithreading - Why Python multiprocessing slowed down my function execution? -

i writing code mincut graph problem in python on ubuntu, after proving correctness single thread implementation trying speed things using multithreading/multiprocessing code slows down. noticed strange behavior , when use 2 threads time taken algorithm function execution doubles compared single thread implementation canceling out gain of having 2 threads , resulting in slow down due multiprocessing overhead , can't know why , possible explanation had have single core processor not case laptop has intel® core™ i5-6200u cpu @ 2.30ghz × 4 numbers single thread : iteration time (mostly run time of randomcontraction function) on average 200 ms time allocation, rand sel time 0.00 collapse time 0.12 self loops time 0.08 iteration # 6882 of 211931 took time 0.20 graph creation time 0.00 alg run time 0.20 elasped time 1439.17 total time 42797.71 progress 3.36 cut = 9 using 2 threads from multithreading import thread : 2 parallel iteration times on average 470 ms function speed...

How to calculate the energy of the function tri(2t+5/6) using matlab? -

how calculate energy of function tri(2t+5/6) using matlab?[where tri triangular pulse function] define trisqr square function , integrate on it: trisqr=@(x) tri(x).*tri(x); xmin=-2; xmax=2; energy=integral(trisqr,xmin,xmax)

arrays - IOUArray to ByteSring, as quickly as possible -

i need mutate elements in fixed size array of word8 quickly. purpose using iouarray . need send array on websocket connection. function sendbinarydata websockets package requires bytestring . need convert 1 representation other. using function currently: arraytobs :: iouarray int word8 -> io (bs.bytestring) arraytobs = (fmap bs.pack) . getelems this function converts elements of array [word8] before packing list bytestring, , profiling can see quite slow. wondering if there way speed function, or possibly send array on websocket connection directly? the array using is: size = 1000; numbytes = size * size * 4 newbuffer :: io (iouarray int word8) newbuffer = newarray (0, numbytes) 200 :: io (iouarray int word8) and except performance report: cost centre module src %time %alloc arraytobs lib src/lib.hs:28:1-37 88.1 99.0 newbuffer lib src/lib.hs:(23,1)-(25,12) 9.9 0.8 ideally arraytobs faster creating array. if c...

python - Django - Create a custom id -

i know django auto generates id model primary_key and know if want generate custom id should do: id = models.uuidfield(primary_key=true, default=uuid.uuid4, editable=false) but how can change id yyyymmddxxxxxx ? where: yyyy = year mm = month dd = day xxxxxx = random number i don't see reason why should make id yeah can it. create small function generate id , pass field. import datetime uuid import uuid4 def create_id(): = datetime.datetime.now() return str(now.year)+str(now.month)+str(now.day)+str(uuid4())[:7] then in model field id = models.charfield(primary_key=true, default=create_id, editable=false) remember pass function object parameter not callable.

mysql - C# how to insert data in SQL table and setting an empty string into 0 -

i'm using sql code insert data table "insert electric values('" + date.text + "', '" + h1.text + "', '" + h2.text + "', '" + h22.text + "', '" + h3.text + "', '" + h4.text + "', '" + h5.text + "', '" + h6.text + "', '" + h7.text + "', '" + h8.text + "', '" + h9.text + "', '" + h10.text + "');" sometimes leave textboxes empty , int. won't insert table. the error set column default 0 still wont insert. default please me solve problem. thanks try : using(sqlconnection connection = new sqlconnection(yourconnectionstring)) { string query = "insert electric (h1, h2, h3, h4) values (@h1, @h2, @h3, @h4)"; using(sqlcommand command = new sqlcommand(query, connection)) { int h1data = 0; int32.tryparse(h1textb...

reactjs - Redux Observable, React, componentDidMount fetch from API cannot get properties from objects -

Image
import { fetchposts } '../actions'; import react, {component} 'react'; import {bindactioncreators, dispatch} 'redux'; import {connect} 'react-redux'; import proptypes 'prop-types'; import map 'lodash/fp/map'; import flatten 'lodash/fp/flatten'; import sortby 'lodash/fp/sortby'; import compose 'lodash/fp/compose'; import take 'lodash/fp/take'; import _ 'lodash'; class postsindex extends component { state = { posts: [] }; componentdidmount() { this.props.fetchposts(); } displayposts () { //console.log(post) works, console.log(post.title) returns undefined. return _.map(this.props.posts, (post)=>{debugger;console.log(post.title);}); } render() { if(this.props.posts.length === 0) { return (<div>loading...</div>); } return (<ul>{this.displayposts()}</ul>); } } function mapst...

Azure Search synonyms not reflecting in results -

the synonyms don't seem function in azure search i updated synonyms map following payload { "name" : "synonymmap1", "format" : "solr", "synonyms" : "bob, bobby,bobby\n bill, william, billy\n harold, harry\n elizabeth, beth\n michael,mike\n robert, rob\n" } then when examined synonymmap, see this { "@odata.context": "https://athenasearchdev.search.windows.net/$metadata#synonymmaps", "value": [ { "@odata.etag": "\"0x8d4e7f3c1a9404d\"", "name": "synonymmap1", "format": "solr", "synonyms": "bob, bobby,bobby\n\r\n bill, william, billy\n\r\n harold, harry\n\r\n elizabeth, beth,liza, elize\n\r\n michael,mike\n\r\n robert, rob\n\r\n" } ] } however, synonyms don't seem function. e.g results search on mike , michael not i...

Sending Data From C# to Matlab M File and Back -

i have interface made in ms visual studio using c# on windows form project. have matlab m file lot of calculations inside. want data entered user interface sent m-file, compiled in matlab in background , results returned c# interface. how should this? or suggest alternative ways? happy if guide me thoroughly, not understand how communications work between these programs. thanks in advance!

Bootstrap & DataTables: Table is rendered twice -

please read below "update: 2017-aug-23 (20hs)", discovered effect experimenting flask seems related between datatables , bootstrap. implementing flask application have rendered table reading data means of pandas directly csv file, no problem. then decided use datatables in order make of features scroll-bar/search/ordering first , later other more advanced features when implementing database. # file structure # # /testapp # +--- /app # | +------ /templates # | | +------ events.html # | +------ __init__.py # | | # | +------ events.csv # | # +---- run.py # my __ init __ .py (where render events table) looks like: # file: __init__.py import pandas pd flask import flask, render_template flask_bootstrap import bootstrap app = flask(__name__, static_path = '/static', static_url_path = '/static') bootstrap = bootstrap(app) @app.route('/') @app.route('/events') def events(): retu...

php - API Facebook Post in album user -

i use graph v2.10 , php sdk 5.5 try post on user album if founded, script display error: graph return error. permission error. when user try login website, user give permissions publish_actions, email, user_photos app. graph permission error. $albums = $fb->get('/me/albums', $_session['facebook_access_token'])->getgraphedge()->asarray(); $album = array(); foreach($albums $k=>$v) { if($fetch_api['album_name'] == $v['name']) { $album[$fetch_api['album_name']] = $v['id'] ; } } if(count($album > 0)) { $data = [ 'message' => $_post['msg'], 'source' => $fb->filetoupload('images/gallery-img1.jpg'), ]; try { // returns `facebook\facebookresponse` object $response = $fb->post('/'.$album[$fetch_api['a...

r - Head and tail by group -

i'm re-posting question again after confusion caused on part, apologies that. believe example correct. sample data: df <- data.frame(group=rep(c("a","b","c"),c(8,10,8)), size=c(rep(1000,5),rep(0,3),rep(2000,7),rep(0,3),rep(5000,5),rep(0,3)), out=c(rep(0,5),rnorm(3,5,1),rep(0,7),rnorm(3,5,1),rep(0,5),rnorm(3,5,1)), g1=rbinom(26,1,.5),g2=rbinom(26,1,.5),g3=rbinom(26,1,.5)) group size out g1 g2 g3 1 1000 0.000000 0 0 1 2 1000 0.000000 0 1 0 3 1000 0.000000 0 1 0 4 1000 0.000000 0 1 0 5 1000 0.000000 0 0 1 6 0 3.997360 1 1 0 7 0 4.992823 1 0 1 8 0 5.644386 1 1 1 9 b 2000 0.000000 1 1 0 10 b 2000 0.000000 0 1 1 11 b 2000 0.000000 0 0 0 12 b 2000 0.000000 1 0 1 13 b 2000 0.000000 1 1 0 14 b 2000 0.000000 1 0 1 15 b 2000 0.000000 1 1 1 16 b 0 5.247895 1 0 0 17 b 0 5.248148 0 0 1 1...

sql server 2008 - SQL Average By Column Name -

i have following t-sql , having struggle trying find out average beginning of year (january) current month. example, should show average january august column. don't know how avg column names until specific month (current month): select [customer], category, [1] january, [2] febrary, [3] march, [4] april, [5] may, [6] june, [7] july, [8] august, [9] september, [10] october, [11] november, [12] december (select month(received) my_month, [customer], category data year(received) = '2017') t pivot (count(my_month) my_month in([1], [2], [3], [4], [5],[6],[7],[8],[9],[10],[11],[12])) p just use conditional aggregation: select customer, category, sum(case when month(received) = 1 1 else 0 end) jan, sum(case when month(received) = 2 1 else 0 end) feb, . . ., sum(case when month(received) <= 1 1 else 0 end) thru_jan, sum(case when month(received) <= 2 1 els...

xml serialization - C# Exception when trying to serialize a dynamic derived object -

i have following classes: [xmlinclude(typeof(cat))] [xmlinclude(typeof(dog))] [xmlinclude(typeof(cow))] [serializable] public abstract class animal { public string name { get; set; } } public class cow : animal { public cow(string name) { name = name; } public cow() { } } public class dog : animal { public dog(string name) { name = name; } public dog() { } } public class cat : animal { public cat(string name) { name = name; } public cat() {} } , following code snippet: var animallist = new list<animal>(); type type = animaltypebuilder.compileresulttype("elephant", propertieslist); var elephant = activator.createinstance(type); animallist.add(new dog()); animallist.add(new cat()); animallist.add(new cow()); animallist.add((animal)elephant); using (var writer = new system.io.streamwriter(filename)) { var serializer = new xmlserializer(animallist.gettype()); serializer.serialize(writer, animallist); writer.flush(); }...

condtional computation based on two dataframes in R -

i performing computation involves 2 data frames.i created 2 reproducible examples of 2 data frames example > df1 day1 day2 day3 day4 day5 day6 day7 day8 day9 day10 time1 0.03 0.43 0.39 0.41 0.94 0.70 0.18 0.65 0.72 0.72 time2 0.42 0.63 0.93 0.53 0.19 0.55 0.22 0.16 0.56 0.04 and > df2 day time x3 x4 x5 1 1 1 9.252042 19.512621 11.601671 2 1 2 5.021522 17.712484 5.044728 3 2 1 9.603795 19.404302 17.206771 4 2 2 19.686793 18.791541 12.655874 5 3 1 7.546551 18.810526 19.865979 6 3 2 18.233872 19.596584 11.653980 7 4 1 17.499680 14.014276 15.553013 8 4 2 8.115352 17.898786 12.841630 9 5 1 10.719540 8.518823 19.126440 10 5 2 12.853401 6.026599 14.041490 11 6 1 19.984946 10.693528 6.890835 12 6 2 16.360035 15.778092 18.087471 13 7 1 15.498714 15.039444 5.259257 14 7 2 13.179111 17.533358 7.382507 15 8 1 5.124188 15.507194 12.547365 16 8 2 8.00...

angular - How to extract Data from AngularFire2 Function -

i attempting instantiate variable using angularfire2 function. function authorizeuser() , when attempt assigning result of function this.user returned 'undefined' in console window. import { component, oninit } '@angular/core'; import { angularfire } 'angularfire2'; import { signupservice } '../../../services/signup/signup.service'; @component({ selector: 'console', templateurl: './console.component.html', styleurls: ['./console.component.css'] }) export class consolecomponent implements oninit { signups: any; user : any; constructor( public af: angularfire, private signupservice: signupservice ) {} getsignupslist() { this.signupservice.getsignups().subscribe(signups => { this.signups = signups; }); } authorizeuser() { this.af.auth.subscribe( afdata => { this.user = afdata.auth.email; }); } ngoninit() { this.getsignupslist(); this.authoriz...