Posts

java - Draw random circles, coloring in red any circle not intersecting another circle -

i have java swing assignment following objectives: when program starts, draws 20 unfilled circles, radius , location of each determined @ random. if perimeter line of circle not intersect other circle, draw outline of circle in red. if intersect @ least 1 other circle, draw in black. add jbutton that, each time pressed, creates new set of circles described above. i've completed objectives #1 , #3 above, i'm stumped on objective #2. before present code, let me give understanding of math behind it. there 2 ways circle can not intersect circle: the circles far apart share perimeter point, i.e. distance between centers greater sum of radii (d > r1 + r2). example . one circle inside circle, , perimeters not touch, i.e. distance between centers less difference between radii (d < |r1 - r2|). example . what i've got far: to compare circles, must specified before drawn, used for-loop store 20 values in arrays center coordinates (int[] x, int[] y) , radi...

node.js - Send Nodemailer e-mail with Namecheap email -

i have been successful connecting gmail account xoauth, acquired namecheap privateemail account , can't life of me figure out how set up. code have: var smtp = nodemailer.createtransport({ host: 'mail.privateemail.com', port: 25, auth: { user: 'contact@myemail.com', pass: 'mypassword' } }); i saw this question , tried other port numbers. it may secured connection in case port should 465 465 port ssl, 25 or 26 tls/starttls

multithreading - Powershell multithread and oracle procedure -

i have list of files increase 5 within 1 minutes never end. inserting data database using oracle procedure. (method external table) then calling procedure powershell below. foreach ($file in $files) { #executing calculate procedure executestoredprocedure -value sp_load_table_crm -filename $file.name -conn } this works okay. takes long time , wanted speed up. better use multithreading or multiprocessing ? planning set powershell script on windows task scheduler. you use runspaces. try this: $files = @('file1','file2','file3') #list of files $throttle = 10 #number of threads $runspacepool = [runspacefactory]::createrunspacepool(1, $throttle) $runspacepool.open() $jobs = @() $scriptblock = { param($file) #place executestoredprocedure function inside script block or make sure loaded appropriate module via profile executestoredprocedure -value sp_load_table_crm -filename ($file.name) -conn #heres function , pa...

ios - Play keyboard click sound in a collection view controller -

i created subclass of uicollectionviewcontroller used custom inputaccessoryviewcontroller in uitextview . https://developer.apple.com/reference/uikit/uiresponder/1621124-inputaccessoryviewcontroller i want play keyboard click sound when tap cell in collection view using playinputclick. https://developer.apple.com/reference/uikit/uidevice/1620050-playinputclick i cannot figure out how work in collection view. works simple view using inputaccessoryview property of uitextview i'm not sure view subclass in collection view controller hierarchy keyboard click sound play. @interface keyboardclickview : uiview <uiinputviewaudiofeedback> @end @implementation keyboardclickview - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if(self) { uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(tap:)]; [self addgesturerecognizer:tap]; } return self; } - (void)tap:(id)sender...

C++ for loop outputs different results with one array than multiple arrays -

i can't understand why outputs different when put 1 array simple loop , when put 2 arrays it. int arrr[100]; int arrn[100]; //function run simulation void runsim(){ for(int i=1;i<=100;i++){ arrn[i] = i; arrr[i] = i; } } //function print array void printarr(int x[100]){ for(int i=0;i <= 100;i++){ cout << x[i] << ", "; } cout << endl; } int main(){ runsim(); printarr(arrr); printarr(arrn); return 0; } this outputs arrr as: 0,1,2,3,4,5,6,...,100 want, outputs arrn as: 100,1,2,3,4,5,6,...,100 not understand. if remove arrr loop arrn prints how want int arrr[100]; int arrn[100]; //function run simulation void runsim(){ for(int i=1;i<=100;i++){ arrn[i] = i; } } //function print array void printarr(int x[100]){ for(int i=0;i <= 100;i++){ cout << x[i] << ", "; } cout << endl; } int main(){ runsim(); printarr(arrn); return 0;...

c# - Does broadcasting to a ASP.NET SignalR group that is empty waste resources? -

Image
if have many client connections part of hub hub_x , not part of specific group group_y , bad practice broadcast() group_y ? should keep track of whether or not inside group_y , , check accordingly before broadcasting it? or signalr no work when detects there no 1 in group_y , , therefore use negligible amount of resources (compared say, having track who's in group myself). ? broadcasting empty groups describe have overhead, negligible depending on use case. let's have 100,000 messages process in queue. processing of messages may require send signalr message clients watching data, vast majority of messages have no watchers. you use message/entity id name of group , execute code every 1 of 100,000 messages: var hub = globalhost.connectionmanager.gethubcontext(hubname); var group = hub.clients.group(groupname) groupproxy; if (group != null) { group.invoke(actionname, messagedata); } alternatively, if somehow able manage hashset of groups have clients ...

Generic function return List C# -

i new in c# , reading generics functions. can*t understand wrong? have, example, function: public list<t> cuttext (list<t> list) { foreach (var in list) { a.text = "yes"; } return list; } your function not generic. invalid non-compilable function returns list of unknown type t. either function or class should have <t> in declaration in order make generic. for example, this: public list<t> cuttext<t>(list<t> list) { foreach (var in list) { a.text = "yes"; } return list; } even if mark generic, type t not have text property until t specified more precisely class or interface having text property: public list<t> cuttext<t>(list<t> list) t : textbox or public list<t> cuttext<t>(list<t> list) t : ianyinterfacehavingtextproperty