Posts

Showing posts from May, 2010

javascript - FabricJS - Better solution to centering object on cursor when selected? -

i selectable objects snap center mouse cursor on click. modification allowed user in case moving object, no scaling, rotating, etc. updating position of object on mousedown or selected update position until moving event fired, object snap original position , begin following mouse. rect.on('moving', movehandler); function movehandler(evt) { var mousepnt = $canvas.getpointer(evt.e); rect.set({ left:mousepnt.x - rect.width*0.5 , top:mousepnt.y - rect.height*0.5}); this.setcoords(); } this i've come center selectable rectangle on cursor, i'm it's firing 2 movement events. there way override original positioning. or should instead write own mousedown , mouseup , , moving listeners mimic default dragging behavior? you solution fine if no rotating or scaling involved. you not executing more necessary if not .setcoords during movement optional since called on mouseup when translation finished. if want take mousedown approach, changing position

getline(cin, string) not giving expected output -

using c++14. have read many posts regarding problem. if run code below, jumps on getline lines. #include <iostream> #include "main_menu.h" void mainmenu::addtest() { std::string coursename = ""; std::string testname = ""; std::string date = ""; std::cout << "enter course name: " << std::endl; std::getline(std::cin, coursename); std::cout << "enter test name: " << std::endl; std::getline(std::cin, testname); std::cout << "enter test date: " << std::endl; std::getline(std::cin, date); test test(coursename, testname, date); tests.add(test); std::cout << "test registered : " << std::endl; tests.print(test.id); } if add cin ignore after each getline lines (example below how implement it), deletes characters input strings , uses wrong variables store them. note have strings whitespaces. std:

php - Magento swatches still show up even after simple product for that color is disabled -

example if follow link can see in preview card there 4 colors can choose from, once click on product, 2 of them disappeared. that's because we've disabled color red/royal particular product. how can make when disable particular color product go away in preview well?

csv - How to use XQuery to extract specific XML records and output in comma delimited format? -

i'm trying extract <xref> data along book ids using xquery (i'm new this). here input data: <book id="6636551"> <master_information> <book_xref> <xref type="fiction" type_id="1">72771kam3</xref> <xref type="non_fiction" type_id="2">us72771kam36</xref> </book_xref> </master_information> <book_details> <price>24.95</price> <publish_date>2000-10-01</publish_date> <description>an in-depth @ creating applications xml.</description> </book_details> </book> <book id="119818569"> <master_information> <book_xref> <xref type="fiction" type_id="1">070185ul5</xref> <xref type="non_fiction" type_id="2">us070185ul50&l

swift - Cannot retrieve Twitter email if authenticating using system account on iOS -

Image
i using parseui implement facebook , twitter login in ios app. if user has setup more 1 twitter system accounts app asks account choose when authenticating. on successful login retreiving user details twitter using call https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true issue in above scenario, twitter api doesn't return email address. email address when system account not setup ie user logis in via web login. not want user enter email address manually. i have whitelisted app in twitter app setting. i tried below code. however, error : error - optional(error domain=twtrerrordomain code=3 "this user not have email address." userinfo={nslocalizeddescription=this user not have email address.}) let client = twtrapiclient.withcurrentuser() client.requestemail { email, error in if (email != nil) { print("email address - \(string(describing: email))"); } else {

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -

i have python app hosting on heroku. use apscheduler call function every day @ time. strange thing 1 time function runs after while have following error log: exception in thread apscheduler (most raised during interpreter shutdown): 2017-09-06t15:03:28.347848+00:00 app[web.1]: traceback (most recent call last): 2017-09-06t15:03:28.347858+00:00 app[web.1]: file "/app/.heroku/python/lib/python2.7/threading.py", line 810, in __bootstrap_inner 2017-09-06t15:03:28.347859+00:00 app[web.1]: file "/app/.heroku/python/lib/python2.7/threading.py", line 763, in run 2017-09-06t15:03:28.347861+00:00 app[web.1]: file "/app/.heroku/python/lib/python2.7/site-packages/apscheduler/schedulers/blocking.py", line 27, in _main_loop 2017-09-06t15:03:28.348167+00:00 app[web.1]: <type 'exceptions.attributeerror'>: 'nonetype' object has no attribute 'now' any guesses? the full code long here key parts: def startdayauto(): global

javascript - no color change after 10 seconds -

i have fiddle in after every second changing background color different color. i wondering changes need make in javascript code below present in fiddle there no color change after 10 seconds. js code using is: var = 0; function change() { var doc = document.getelementbyid("background"); var color = ["black", "blue", "brown", "green", "red", "yellow", "white", "pink", "purple", "orange"]; doc.style.backgroundcolor = color[i]; = (i + 1) % color.length; } myvar = setinterval(change, 1000); html, body { border: 0; margin: 0; height: 100%; min-height: 100%; } .container { width: 100% !important; } #background { width: 100%; height: 100%; } <div id="background"> </div> clear interval after 10 seconds timeout try this: var = 0; function change() { var doc = document.get

angular - How to restrict number of API calls per interval with RxJs? -

i'm developing angular application. , use api provided 1 of social networks , has restriction of 5 api calls per second only. the direct solution write custom logic count requests , queue them restrictions. if i'm sending 6th request api within 1 second, sent in second after 1st request sent. but want find elegant solution if it's possible using rxjs. for instance, can set debounsetime observable in following example. cannot make few requests in row smaller interval 200ms between them. this.searchcontrol.valuechanges .debouncetime(200) // 200ms ~ 5 requests per second .switchmap(search => this.api.searchpeople(search)) has rxjs techniques can restrict number of emits per interval , queue them in case requests being sent frequently? you can keep track how many times called api recently. if can make 5 call per second, thant means have 5 tokens, , if token consumed, renewed after second. i've made following operator need: observab

c++ - Basic Algorithm Optimization -

my current assignment create basic algorithm finds magic number (which 1). magic number can found either dividing number 2 until it's magic, or multiplying odd number 3, adding 1, dividing 2 until 1. must each positive integer 3 until 5 billion. magic = 1; div = 2; start = 3; max = 5000000000; bool isodd(int x); void ismagic(int x); int main () { clock_t starttime = clock(); cout << "beginning loop" << endl; (int = start; < max; i++) { if ( isodd(i) == false ) ismagic(i); else if ( isodd(i) == true ) ismagic(i); } clock_t finishtime = clock(); cout << "looping took " << double(finishtime - starttime) / clocks_per_sec << " seconds" << endl; return 0; } bool isodd(int x) { if( x % div == 0 ) return false; else return true; } void ismagic(int x) { if( isodd(x) == false ) //is { while( x > magic ) { x /= div; };

Changing the size of a shape in PowerPoint VBA Macros -

i'm trying resize shape (square) using vba in powerpoint when clicking on 1 of 4 circles in each vertex of square. when resize position of mouse works in right bottom vertex of square. i want size in upper vertexes , left in left side vertexes. because sizes lower right. tried messing top property of shape , many codes, non of them worked. edit: can use scaleheight , scalewidth property that? if yes, can me that, because property confusing, beacause have use factor... here last code tried: sub resizeshp_topright3() dim llcoord pointapi getcursorpos llcoord shapes("a").textframe.textrange.text = shapes("shp").height shapes("shp").width = (llcoord.xcoord / 1.417323) - val(replace(shapes("shp").left, ",", ".")) shapes("shp").top = (llcoord.ycoord / 1.417323) shapes("shp").height = (llcoord.ycoord / 1.417323) - val(replace(shapes("shp").top, ",", ".")) end sub

debugging - r - Project Euler 40: getting the final digit wrong -

an irrational decimal fraction created concatenating positive integers: 0.12345678910 1 112131415161718192021... it can seen 12th digit of fractional part 1. if dn represents nth digit of fractional part, find value of following expression. d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000 problem source here . i wrote following code calculate digits: ans = data.frame(matrix(ncol = 6, nrow=2)) colnames(ans) = c(10,100,1000,10000,100000,1000000) rownames(ans) = c("length","number") counter = 1 for(i in c(10,100,1000,10000,100000,1000000)) { c = 0 num = 0 while (c<i) { num = num + 1 c = c + nchar(as.character(num)) } ans[1, counter] = c ans[2, counter] = num counter = counter + 1 } the output, is: > ans 10 100 1000 10000 1e+05 1e+06 length 11 101 1002 10001 100004 1000004 number 10 55 370 2777 22222 185185 in other words, when irrational number 11 digit long, final 2

android - Hide/unhide toolbar menu -

i want can able hide/unhide programmatically toolbar menu. because couldn't find information on net use next code remove menu toolbar: toolbar mtoolbar = (toolbar) findviewbyid(r.id.toolbar); mtoolbar.getmenu().clear(); how can put programmatically? i figure out next code hide menu: toolbar mtoolbar = (toolbar) findviewbyid(r.id.toolbar); mtoolbar.getmenu().clear(); and next unhide: toolbar mtoolbar = (toolbar) findviewbyid(r.id.toolbar); if (!mtoolbar.getmenu().hasvisibleitems()) { getmenuinflater().inflate(r.menu.menu_activity, mtoolbar.getmenu()); }

c# - EF inheritance with table splitting -

i'm trying map 2 different ef models same table sharedtable, let call them entitya , entityb. made them both extend base entity called baseentity. entitya defined sharedtable fields, entityb has fields in sharedtable , entitybtable. modelbuilder.entity<baseentity>() .map<entitya>(m => m.requires("isentitya").hasvalue<bool>(true)) .map<entityb>(m => m.requires("isentitya").hasvalue<false>(true)); modelbuilder.configurations.add(new entitybmap()); modelbuilder.configurations.add(new entityamap()); modelbuilder.configurations.add(new baseentitymap()); the models this public class baseentity { [required] public int id { get; set; } public int sharedtablefield1 { get; set; } } public class entitya : baseentity { public int sharedtablefield2 { get; set; } } public class entityb : baseentity { public int entitybtablefield1 { get; set; } } the

sql - In a nonclustered index, how are the second, third, fourth ... columns sorted? -

i have question sql server indexes has been bugging me of late. imagine table this: create table telephonebook ( firstname nvarchar(50), lastname nvarchar(50), phonenumber nvarchar(50) ) with index this: create nonclustered index ix_lastname on telephonebook ( lastname, firstname, phonenumber ) and imagine table has hundreds of thousands of rows. let's want select last name starts b , firstname 'john'. write following query: select * telephonebook lastname 'b%' , firstname='john' since index can reduce number of rows need scan because groups of lastnames start b anyway, firstname? or database scan every row starts b find ones first name 'john'? in other words, how second, third, fourth, ... columns sorted in index? alphabetical in case well, it's pretty easy find johanna? or in sort of random or different order? edit: why ask, because have read in above select statement, index used narro

mysql schedule query date table and user table -

i trying make schedule in 1 simple query i not have slightest idea how this. i have tried left join , count figured maybe there more efficient way doing this. so came on here. any appreciated, thank you. one table has dates - 04-01-2017 04-02-2017 04-03-2017 then next table has names john ben matt billy bob susan what want try query out - date - p1 p2 04-01-2017 john ben 04-01-2017 billy matt 04-01-2017 susan bob 04-02-2017 john matt 04-02-2017 billy bob 04-02-2017 susan matt 04-03-17 etc... users can not repeat each other create table `name` ( `id` int(11) not null auto_increment, `names` varchar(45) default null, primary key (`id`) ) engine=innodb auto_increment=7 default charset=utf8; insert `name` values (1,'john'),(2,'ben'),(3,'matt'),(4,'billy'), (5,'bob'),(6,'susan'); create table `schedule_dates` ( `id` int(11) not null auto_increment, `date` varchar(255) de

regex how to define that the rule must be the same -

i searching number in format. [0-9]{3,6}[\-\/]{1}[0-9]{1,3}[\-\/]{1}[0-9]{1,2} is there way how define there should slash/ or colom- ? in other words, option first 1 - , second 1 / should omitted. yes, can use \1 back-reference. matches same character (or group) first matching group. in case, ([-\/]) first matching group , \1 requires same character. [0-9]{3,6}([-\/])[0-9]{1,3}\1[0-9]{1,2} here example: https://regex101.com/r/mkxnun/1

javascript - WebSocket connection established, onopen never runs -

i'm trying learn websockets , i've created websocket server in node , working on browser implementation. have tested server works , responds how want using chrome extension called smart websocket client. the console in browser says button pressed! when press button , connection lost! (1000) when end node process never has said connection established! . edit: client code running on site secured https , serves hsts header while server code (currently, won't continue be) running on localhost on normal http, if it's concern. server code: const websock = require('./node_modules/ws'); const hashmap = require('./node_modules/hashmap'); const jsonparse = require('./node_modules/jsonparse'); const randomstring = require('./node_modules/randomstring'); class session { constructor(server) { this.server = server; this.clients = []; } } var connections = new hashmap(); const json = new jsonparse(); const wss =

javascript - my ajax dont work at all? -

i have ajax function (below). trying pass input 1 page another. it redirects me other page not pass required value. i not understand why doesn't work expected. i looking way this. appreciated. //second page <?php $cuit = $_post['cuit']; ?> <input id="act" type="text" class="form-control" value="<?php echo $cuit ?>"> function mod(id, origen) { swal({ title: 'are sure?', text: "you won't able revert this!", type: 'warning', showcancelbutton: true, confirmbuttoncolor: '#3085d6', cancelbuttoncolor: '#d33', confirmbuttontext: 'yes, delete it!', cancelbuttontext: 'no, cancel!', confirmbuttonclass: 'btn btn-success', cancelbuttonclass: 'btn btn-danger', buttonsstyling: false }).then(function() { if (origen == "perfiles") {

asynchronous - Xamarin SQLite: What is different SQLiteAsyncConnection and SQLiteConnection -

there 2 type of constructors can call initialise sqlite connection. know sqliteasyncconnection create async method when execute sql statement whereas sqliteconnection normal method. if have method below: public object insertveggie(string name) { lock (locker) { var sql = "some query ?"; var result = database.query<model>(sql, name); return result; } } if have async method: public async task<model> getmodel (string name) { var data = insertveggie(name); await processveggie(data); return data; } calling method : task.run (async () => { var result1 = await getmodel("124"); }); task.run (async () => { var result2 = await getmodel("335"); }); if use sqliteconnection instead of sqliteasyncconnection, there issue or have change insertveggie async method well. as say, sqliteasyncconnection exposes asynchronous methods typically consume them own async methods.

python class output about defaultdict(set) -

i new learner on python , built class solve permutation problem : from collections import defaultdict class permutation: def __init__(self, *args, length = none): self.args = args def __str__(self): p = defaultdict(set) return f'{p}' p = permutation(3,5,1,4,2) p print(p) when print(p) output like: defaultdict(<class 'set'>, {3: {1}, 5: {2}, 4: {4}}) but output expected values grouped it's key , sorted,just like: (3 1)(4)(5 2) could use str() or sth else?i tried convert list still can not value set:( thanks!

css - bootstrap 4 horizontal alignment of toggle fails -

Image
i using toggle element of material design lite in bootstrap 4 framework , unable align element right side of column. note "float-right" class works fine bootstrap element (button). tried applying "text-right" class container, justify-content-end, justify-content: flex-end, pull-right, etc... nothing works. <script src="https://code.getmdl.io/1.3.0/material.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" /> <link href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css" rel="stylesheet" /> <body> <div class="container"> <div class="row"> <div class="col-8">text row 1</div> <div class="col-4 float-right"> <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect float-right" for

c++ - imwrite in OpenCV3.1 doesn't work -

Image
when trying save image using imwrite following error: files describe problem: c:\users\jalal\appdata\local\temp\wer64ce.tmp.werinternalmetadata.xml c:\users\jalal\appdata\local\temp\wer7092.tmp.appcompat.txt c:\users\jalal\appdata\local\temp\wer70c2.tmp.mdmp read our privacy statement online: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409 if online privacy statement not available, please read our privacy statement offline: c:\windows\system32\en-us\erofflps.txt here's entire code (the code works --imshow shows blurred image): #include <opencv2/core/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <string> using namespace cv; using namespace std; //void tintimageblue(mat& image); int main() { mat image; mat channels[3]; image = imread("mona1.jpg", imread_grayscale); split(image, channels); //image = 0.2*channels[0] +

How to control the file dates in git? -

this question has answer here: how create git commit date in past? 2 answers see repository, https://github.com/steeve/france.code-civil/tree/master/livre%20iii/titre%20vii there files of 48 years ago... how it? can preserve old dates after commit? no conflicts in git when changing dates? ps: aim in example simulate document time , reproduce sequence of changes in real world. you can --date argument git commit . example: git commit --date="wed feb 16 14:00 2037 +0100" you can edit existing date, too: use git commit --amend . for more information, check out working dates in git .

java - an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax -

java.sql.sqlexception: syntax error or access violation, message server: you have error in sql syntax; check manual corresponds mysql server version right syntax use near ''list' (fname1,lname1,email1,email,'dob1',str,city,state,zip,order,qua,rate,comm' @ line 1" string k="insert `list` (fname1,lname1,email1,email,'dob1',str,city,state,zip,order,qua,rate,comment,amt) values ('"+fname1+"','"+lname1+"','"+email1+"','"+email+"','"+dob1+"','"+str+"','"+city+"','"+state+"',"+zip+",'"+ord+"',"+qua+","+rating+",'"+comment+"',"+amt+")"; here table desc the error message point 2 single quotes on string, check if double quote not writen 2 single quotes. but, solve efficiently, recomended use peparedstatement

nginx won't restart, and reports "Unit entered failed state" -

i trying restart nginx. type in terminal (ubuntu). see issue here? sudo systemctl restart nginx.service i error message: job nginx.service failed because control process exited error code. see "systemctl status nginx.service" , "journalctl -xe" details. this error message. **sudo journalctl -xe** *-- unit unit has finished starting up. -- unit unit has finished starting up. -- -- start-up result done. sep 13 22:36:08 vultr.guest systemd[7806]: reached target basic system. -- subject: unit unit has finished start-up -- defined-by: systemd -- support: -- -- unit unit has finished starting up. -- -- start-up result done. sep 13 22:36:08 vultr.guest systemd[7806]: reached target default. -- subject: unit unit has finished start-up -- defined-by: systemd -- support: -- -- unit unit has finished starting up. -- -- start-up result done. sep 13 22:36:08 vultr.guest systemd[7806]: startup finished in 29ms. -- subject: system start-up complete --

github - fetch git repo at specific commit without cloning -

i trying git repo @ specific commit hash without cloning ! every example wants clone whole repo. makes sense repo have in mind huge , need leave small footprint going docker image. the commit hash in url - either wget or curl could/should recursively fetch have feeling github blocking ever robots.txt the repo , commit: https://github.com/phalcon/cphalcon/tree/1d6d21c98026b5de79ba5e75a3930ce7d1ebcd2e my best attempt error: git fetch https://github.com/phalcon/cphalcon/ 1d6d21c98026b5de79ba5e75a3930ce7d1ebcd2e error: server not allow request unadvertised object 1d6d21c98026b5de79ba5e75a3930ce7d1ebcd2e update suggestions of answers use clone aren't answering question. can clone/checkout no problem. trying without having whole repo locally you need git repository, reason shown in error message: error: server not allow request unadvertised object ... an "unadvertised object" 1 not have name directly attached it. (if object had name, ask

Python throwing an indented block error. not seeing it -

my python code throwing expected indented block error right after elif . i having trouble seeing indenting mistake is. what indentation mistake have made? def expandprocedure(node, queue): successors = [] n = 4 while (n > 0): parent = node depth = node[2] + 1 pathcost = node[3] + 1 newstate = teststate(node[0], n) if newstate == 0: ## nothing elif inqueue(newstate[0], queue): #do nothing else: s = makenode(newstate, parent, depth, pathcost) successors.insert(0, s) n = n - 1 return successors you can't have null block. use pass (non-)command: if newstate == 0: pass elif inqueue(newstate[0], queue): pass

javascript - AJAX mvc web api: create div with images -

Image
i working restful api, mvc , ajax. trying data backend , display images inside divs. result should following: this backend code: /*route:api/images*/ [httpget] public ienumerable<dto> getdata(string id) { /*do something*/ return dto;/*the dto has imgurl property*/ } in front end <div id="mydiv></div> <script> $(document).ready(function () { $.ajax({ url: "http://localhost:59245/api/api/images", type: "get", success: function (data) { (var = 0; < data.length - 1; i++) { $('<div class="col-lg-4 col-sm-6"><div class="thumbnail">'+ '<h3 class="centrar">' + data[i].titulo + '</h3><a href="'+ data[i].imagenurl+'</a><p>'+data[i].paragraph+'</p></div&

Django Many-to-one relationships -

for question, i´ll using examples of django documentation. my problem click reporter name , change webpage list of articles. this models.py from django.db import models class reporter(models.model): first_name = models.charfield(max_length=30) last_name = models.charfield(max_length=30) email = models.emailfield() def __str__(self): # __unicode__ on python 2 return "%s %s" % (self.first_name, self.last_name) class article(models.model): headline = models.charfield(max_length=100) pub_date = models.datefield() reporter = models.foreignkey(reporter, on_delete=models.cascade) def __str__(self): # __unicode__ on python 2 return self.headline class meta: ordering = ('headline',) how can change 1 model other useing many-to-one relationship class-based views. https://docs.djangoproject.com/en/1.11/topics/db/examples/many_to_one/ thanks in adva

arrays - PHP using preg_replace to highlight string that is part of a word -

so have following code highlights word/s entered search bar in search results: $sk = explode(" ",$searchval); foreach ($searchpostresults $pageposts) echo '<li><span class="searchresult"><a href="' . get_the_permalink($pageposts->id) . '" title="">' . preg_replace('/\b(' . implode('|', $sk) . ')\b/iu', '<strong class="searchhighlight">\0</strong>', get_the_title($pageposts->id)) . '</a></span></li>'; now works part. lets enter search term "how to" in search bar, word how highlighted. if word how inside word shower, highlight how so: s<strong class="searchhighlight">how</strong>er anyone know how might adjust code this. cheers the behavior describing opposite of peoples intentions, , why rege

Can't upload image by POST method from url. Python -

i can't send image object in multipart/form-data format without writing , reading on disk. method not work: response = requests.get(offer['picture']) if not response.ok: print('error!', response) continue image = response.content response = requests.post(upload_url, files={'file': image}) api thinks image small. method works: response = requests.get(offer['picture']) if not response.ok: print('error!', response) continue image = response.content open('test.jpg', 'wb') file: file.write(image) response = requests.post(upload_url, files={'file': open('test.jpg', 'rb')}) how can upload image without writing on disk? working code: response = requests.get(offer['picture']) if not response.ok: print('error!', response) continue image = response.content response = requests.post(upload_url,

html - jQuery .css not changing element css -

i trying make chart changes size relative amount of variable. variable increase , decrease according checkbox user ticks. graphs display fine have set height in css see how look, though when click button "#submit" nothing occurs. point out issue in code? code: //vote count variables var ag = 2; var nag = 0; //make 1 checkbox tickable. $('input[type="checkbox"]').on('change', function() { $('input[type="checkbox"]').not(this).prop('checked', false); }); //function refresh charts new vote amounts. function refreshchart() { $(".for").css({ 'height': ag * 60 + 'px;' }); $(".for not").css({ 'height': nag * 60 + 'px;' }); } //refresh charts user on submit click. $('#submit').click(function() { if ($('#c1').prop('checked') == true) { ag += 1; } if ($('#c2').prop('checked') =

oracle - ORA-02065: illegal option for ALTER SYSTEM -

i'm new oracle. learning backup , recovery. that, did $ sqlplus system/password sql> alter system set db_recovery_file_dest_size=8gb scope=both; but got error error:- enter image description here can tell me exact solution? please tell me specific solution steps do. $ sqlplus system/password sql> alter system set db_recovery_file_dest_size= 8g scope=both;

c# - Handling nulls in RadioButtonList in Repeater control -

we have following radiobuttonlist in our repeater control: <asp:radiobuttonlist id="rdlmhorseptype" text='<%#string.isnullorempty((string)eval("rdlmhorseptype")) ? "electric start" : eval("rdlmhorseptype") %>' runat="server" validationgroup ="stype" repeatdirection="horizontal" textalign="right" style="display:inline;" autopostback="true" onselectedindexchanged="rblpurchasetype_selectedindexchanged"> <asp:listitem text="electric start" /> <asp:listitem text="recoil" /> </asp:radiobuttonlist><br /> our normal business process requires user enter account number check existence of records associated account number. if records exist, repeater control form populated records. users can make whatever modifications wish make. this part works great. if no record exists, user required enter his/her inf

isbn - how to not give any output in python -

i working on school problem give equation identifying if isbn number valid , give ten inputs(numbers) , stop input @ end. this code: a=str(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) f=int(input()) g=int(input()) h=int(input()) i=int(input()) j=int(input()) u=input() #this stop @ if j==int((int(a)+(2*b)+(3*c)+(4*d)+(5*e)+(6*f)+(7*g)+(8*h)+(9*i))%11): print("ok") elif j!=int((int(a)+(2*b)+(3*c)+(4*d)+(5*e)+(6*f)+(7*g)+(8*h)+(9*i))%11): print("wrong") elif a=="stop": print("") the last 2 lines there because 1 of answers 1 line input: "stop". in case, code shouldn't give output code doesn't work , since there 1 input, gives out eof on second line of code. how can make work? j either equal int((int(a)+(2*b)+(3*c)+(4*d)+(5*e)+(6*f)+(7*g)+(8*h)+(9*i))%11) (which btw don't have compute twice...), or not. elif a=="stop": never reached. test a=="stop" fir

Bash IFS not splitting string correctly -

i having trouble getting ifs split string correctly based on colon delimiter. seems -e inside string being considered option instead of being considered literal string. #!/bin/bash string_val="-e:sqa" ifs=: read -a items <<< "$string_val" echo "${items[0]}" # prints empty value echo "${items[1]}" # prints sqa how can fixed? the string being split correctly; -e in ${items[0]} treated option echo . $ string_val="-e:sqa" $ ifs=: read -a items <<< "$string_val" $ printf '%s\n' "${items[0]}" -e

python - reshape while converting Pandas Dataframe to numpy array -

i have pandas dataframe, has 4 rows , n columns, out taking 1 column using feature classifier. shown below 0 [1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0] 1 [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1] 2 [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0] 3 [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0] this column list of 16 binary encoded features. but when feed classifier, below error comes up traceback (most recent call last): clf.fit(x,y) x, y = check_x_y(x, y, 'csr') ensure_min_features, warn_on_dtype, estimator) array = np.array(array, dtype=dtype, order=order, copy=copy) valueerror: setting array element sequence. i suppose error because fit method wants nxm matrix, while shape gets is (4,) so basically, i want try convert shape(4,) shape(4,16) i tried below functions: x = np.asarray(train_data['presence_vector']) x.reshape((4,16)) x = train_data['presence_vector'].values x.reshape((4,16)

python - Pandas rolling window with custom look back length based on column sum -

given pandas dataframe 2 columns, "atbats" , "hits", indexed date, possible recent historical batting average (average number of hits per atbat)? example, historical batting average fewest atbats greater 10. sort of rolling window conditional number of look-back periods. example, given: date, atbats, hits, 2017-01-01, 5, 2, 2017-01-02, 6, 3, 2017-01-03, 1, 1, 2017-01-04, 12, 3, 2017-01-04, 1, 0, on first day, there have been no historical atbats. on second day, 6. since both less 10, can nan or 0. on third day, on last 2 days , see 5+6 atbats average of (2+3)/(5+6) = 0.45 hits/atbat. on third day, on last 3 days , (2+3+1)/(5+6+1) = 0.5 hits/atbat. on fourth day, on last day , 4/16 = 0.25 hits/atbat. since last day has more 10 (16), don't need further. the final dataframe like: date, atbats, hits, pastatbats, pasthits, avg, 2017-01-01, 5, 2, 0, 0, 0, 2017-01-02,

Java - write string to file line by line vs one-liner / cannot convert String to String[] -

relatively new programming. want read url, modify text string, write line-separated csv textfile. the read & modify parts run. also, outputting string terminal (using eclipse) looks fine (csv, line line), this; data_a,data_b,data_c,... data_a1,data_b1,datac1... data_a2,data_b2,datac2... . . . but i'm unable write same string file - becomes one-liner (see below for-loops, attempts no. 1 & 2); data_a,data_b,data_c,data_a1,data_b1,datac1,data_a2,data_b2,datac2... i guess i'm looking way to, in filewriter or bufferedwriter loops, convert string finaldataa array string (i.e. include string suffix "[0]") have not yet found such approach not give errors of type "cannot convert string string[]". suggestions? string data = ""; string datahelper = ""; try { url myurl = new url(url); httpurlconnection myconnection = (httpurlconnection) myurl.openconnection(); if (myconnection.getresponsecod

osx - TMainMenu - managing Help and Search menu items -

running firemonkey app in osx, search box automatically appears on last menu item, have labeled "help." far good, because menu search box standard osx. next, needed add file. purchased impressive utility help crafter , made apple helpbook. placed helpbook bundle resources folder of main app. used project|options|version info in ide edit info.plist file. added 2 keys cfbundlehelpbookfolder , cfbundlehelpbookname info.plist point helpbook. running app, found had 2 menu items -- item had programmed , apparently automatically created mac os, complete submenu item brings helpbook. amazement, had working without coding whatsoever. next, wanted remove menu item had created in order eliminate duplication. search box still located under menu item, not on menu item created os. , when deleted menu item, search box relocated last menu item created me. how can specify search box should located on os-created menu item? alternatively, can specify os should not automatically c

sql - How to use group by without using an aggregation function -

i trying find row number of price while grouping them respect productid . productid = 1 , rank of price (where price = 1000) should smt. productid=3 , rank of price (= 1000) should sth. how can find row number of price different productid in same table? how can achieve using group without aggregation row_number . productid price ----------------- 1 2000 1 1600 1 1000 2 2200 2 1000 2 3250 3 1000 3 2500 3 1750 so result should be productid price pricerank ------------------------------ 1 1000 3 2 1000 2 3 1000 1 this code: select productid, row_number() on (order price asc) pricerank product price = 1000 group productid this give correct result: select * (select productid,price,row_number() on (partition productid order productid ) pricerank products) price =1000

Any idea on how to launch Google Duo app from an android application? What permissions are required? -

looks google going replace hangouts google duo app mobile devices: http://www.androidauthority.com/best-meditation-apps-android-800029/ please share if 1 have tried launching google duo app programmatically android app? thanks

ios - How do I get the text to align to the top in UITextView? -

Image
running xcode 8.3.3 have uitextview fills entire view. however, text not align top has more 80 points padding @ top - see attached screenshot. i have worked constraints, alignment , searched documentation cannot see how resolve issue. any pointers appreciated. okay based on query had tried 1 solution please have @ 1) here first output space getting default i used following code show happening there, using textview covers full screen top bottom storyboard //outlet @iboutlet weak var mytextview: uitextview! //call function , assign textview override func viewwillappear(_ animated: bool) { adjustcontentsize(tv: mytextview) } //this add respected boundaries textview content func adjustcontentsize(tv: uitextview){ let deadspace = tv.bounds.size.height - tv.contentsize.height let inset = max(0, deadspace/2.0) tv.contentinset = uiedgeinsetsmake(inset, tv.contentinset.left, inset, tv.contentinset.right) } //w

Dronekit python vehicle connection timeout -

Image
we having bit of trouble getting dronekit working our copter. far have tested using sitl , works fine, success has not transferred across real thing well. our setup is: windows gcs running mavproxy (master via com9, udp outputs dronekit script , mission planner) , basic dronekit script (takeoff , land). please see diagram clearer explanation. we use following command when running mavproxy: mavproxy.exe --master=com9,57600 --out=udp:127.0.0.1:14550 --out=udp:127.0.0.1:14551 --console the issue having connecting vehicle ( http://python.dronekit.io/guide/connecting_vehicle.html ), able connect drone , board information. not receive heartbeat message 30 seconds, leading timeout. >>> apm:copter v3.5.2 (4322ffda) >>> px4: 1d6bf64c nuttx: 1a99ba58 >>> frame: quad >>> px4v3 0020002e 30365110 35323931 traceback (most recent call last): file "c:/users/simon/pycharmprojects/uas_lol/test_mission.py", line 32, in <module> ve