Posts

Showing posts from March, 2010

javascript - How to print directly in IE 11 with ActiveX -

on page show pdf document in iframe , try print directly. @ end of search, situation suitable ie 11 reason security etc. how can that? don't know. please save me situation :/ i use these dom element , function <button type="button" onclick="printdoc()" class="btn success">print it</button> <script type="text/javascript"> function printdoc() { $(document).ready(function () { document.getelementbyid("mydiv").contentwindow.print({ bui: false, bsilent: true, bshrinktofit: true }); }); }; </script> activex control not work on ie11 microsoft no longer allows activex plugins run in browser space.however if having 54 bit operating system can try forcing ie run in 32-bit m

swift - Getting run time error when adding constraints -

i'm trying center image view i'm getting error..this code: let markerimage = #imageliteral(resourcename: "ic_new_mark_icon") let size = cgsize(width: 60, height: 60) var newimage = imagewithimage(image: markerimage, scaledtosize: size) var imageview = uiimageview(image: newimage) self.view.addsubview(imageview) let xconstraint = nslayoutconstraint(item: imageview, attribute: .centerx, relatedby: .equal, toitem: self.view, attribute: .centerx, multiplier: 1, constant: 0) let yconstraint = nslayoutconstraint(item: imageview, attribute: .centery, relatedby: .equal, toitem: self.view, attribute: .centery, multiplier: 1, constant: 0) imageview.addconstraint(xconstraint) imageview.addconstraint(yconstraint) and error is 2016-12-22 16:29:11.305417 googlemappractice[21426:362773] [layoutconstraints] view hierarchy not prepared constraint: <nslayoutconstraint:0x600000285f00 uiimageview:0x7ff772f15560.centerx == uiview:0x7ff7

c# - Email not sending ASP.NET MVC 4 Using SMTPClient -

i add more functionalities method, such email sent once user has edited data. debugged code no errors generated not know going wrong. [httppost] public actionresult edit(editptg eptg) { try { using (managegrade gradelogic = new managegrade(ref uow)) { foreach (var ptg in eptg.ptgforgrade) { ptg.overwritten = true; ptg.active = true; producttogradelogic.update(ptg); } //need investigate why need recalculate grade @ point of time - sri mark?? //eptg.grade = gradehelpers.recalculategradestringfromproductassignment(eptg.ptgforgrade, eptg.grade); smtpclient smtpclient = new smtpclient("www.hotmail.com", 25); // smtpclient.credentials = new system.net.networkcredential("username", "password"); smtpclient.usedefaultcredenti

python - Using Mocks inside Doctests? -

i using doctests. wondering correct way doctest function performs external action (e.g. sends email, connects server, etc)? using mock seems answer muddy doc string of function. for example: class sshconnection(baseconnection): """provides basic ssh functions. >>> host = '127.0.0.1' >>> port = 22 >>> username = 'user' >>> password = 'password' >>> ssh = sshconnection(host, username, password, port) >>> ssh.execute('uname -a') """ ...

preferencefragment - Increasing Items in a list view based on condition -

i want add listprefernce initailly ex:a,depending on condition same list want add other ex:b, how can achieve using list preferences . i able add listview, listview rather list adding more entries... here code: preferences.xml: <preferencecategory android:key="custom_frag" android:title="some options"> addpreferencesfromresource(r.xml.preferences); preferencecategory targetcategory = (preferencecategory) findpreference("custom_frag"); listpreference checkboxpref1 = new listpreference(context); charsequence[] entries1 = { "googlemaps"}; charsequence[] entryvalues = { "1" }; checkboxpref1.setentries(entries1); checkboxpref1.setentryvalues(entryvalues); checkboxpref1.settitle("number of blahs"); targetcategory.addpreference(checkboxpref1); targetcategory.addpreference(checkboxpref1);

windows - How to openfile in special program using autoit? -

i need open file in special program. example, need open *.docx file if office word. i have figured out how run office example() func example() ; run notepad window maximized. local $ipid = run("c:\program files (x86)\microsoft office\office15\winword.exe", "", @sw_showmaximized) ; wait 10 seconds notepad window appear. winwait("[class:winword]", "", 5) ; wait 2 seconds. sleep(2000) ; close notepad process using pid returned run. processclose($ipid) endfunc ;==> how open file? for word documents, pass name of document command line argument example() func example() ; run notepad window maximized. local $ipid = run("c:\program files (x86)\microsoft office\office15\winword.exe" & " " & "path_to_document", "", @sw_showmaximized) ; wait 10 seconds notepad window appear. winwait("[class:winword]", "", 5)

assembly - MASM: Using Current Location Counter ($) in .data declaration -

i met problem current location counter in masm. here assembly code, , used visual studio 2013 express assembling .386 .model flat,stdcall .stack 8192 exitprocess proto,dwexitcode:dword .data ptr1 dword $ ptr2 dword $ ptr5 dword $ .code main proc mov eax, $ mov eax, $ invoke exitprocess,0 main endp end main in opinion, think ptr1, ptr2, , ptr5 should have own location value. but it's not correct in fact. when in debugging mode, variables show same result. ptr1, ptr2, ptr5 have same address , there no offset between them. what's problem when using $ declaration ? your problem seems bug in masm (or microsoft put it, "feature"). problem isn't dword directives aren't generating object code or aren't advancing assembler's location counter. if former true wouldn't show in executable @ all, , if later true have same address. the problem masm incorrectly uses offset of start of current segment (in generated obje

Ruby multiple inheritance needed for rails models -

first off, let me know multiple inheritance not possible in ruby, when think it, that's way can see resolution. i have 3 separate user classes share single-table inheritance. here are class user < activerecord::base has_many :notifications def notify #code notify user end end class student < user has_many :charges def charge_user #code charge user end end class teacher < student has_many :students has_many :courses def create_course #code create course end end i want able use each has_many method once, , teacher must inherit student methods the problem if if run teacher.find(1) i error activerecord::subclassnotfound: single-table inheritance mechanism failed locate subclass: 'teacher'. error raised because column 'type' reserved storing class in case of inheritance. please rename column if didn't intend used storing inheritance class or overwrite user.inheritance_column use column information. if cha

performance - apache phoenix, slow write speed when change currentSCN -

have old hbase table (billion records) , need use data create new phoenix table. want preserve record modtime old record. based on phoenix suggestion. give property currentscn when connect. seems slow. while doc keep in mind creating new connection not expensive operation. same underlying hconnection used connections same cluster, it’s more or less instantiating few objects. i test using simple program. class.forname("org.apache.phoenix.jdbc.phoenixdriver"); int x = 0; for(int i=1000000 ;i< 2000000;i++ ) { properties prop = new properties(); prop.setproperty("currentscn",string.valueof(i)); connection con = drivermanager.getconnection("jdbc:phoenix:a1.cluster",prop); con.setautocommit(false); preparedstatement stmt2 = con.preparestatement("upsert fff values (?,?,?,?,?)"); stmt2.setstring(1,string.valueof(i)); stmt2.settim

css - Scale HTML Mixin -

i'm looking way scale html mixin. i've gotten far adjusting position, width, , height. i'm trying figure out though how can accommodate 100vh elements scales relative html. @mixin htmlscaler_scale($scale: 1) { html { transform: scale($scale); width: calc((100% / (#{$scale} * 10)) * 10); height: calc((100% / (#{$scale} * 10)) * 10); position: absolute; left: calc(((-100% / (#{$scale} * 10) * 10) + 100%) / 2); top: calc(((-100% / (#{$scale} * 10) * 10) + 100%) / 2); } @if html * style === 100vh { //need here... //update 100vh match scale } } i'm open suggestions on this. thanks! : )

PdfName.NM in iText TextField not Visible after calling setName() -

this how create textfield in itext 5. import com.itextpdf.text.pdf.textfield; textfield tf = new textfield(stamper.getwriter(), rect, "fieldname"); tf.settext("fieldvalue"); tf.setbackgroundcolor(basecolor.white); tf.setbordercolor(basecolor.black); tf.gettextfield().setname("name_here"); stamper.addannotation(tf.gettextfield(), 1); this works. however, when check in rups. pdfname.nm not exist. setname() correct method, right? you assuming methods can chained in itext 5, assumption wrong. introduced chained methods in itext 7. in itext 5, need split things up: pdfformfield ff = tf.gettextfield(); ff.setname("name_here"); stamper.addannotation(ff, 1); the pdfformfield isn't member-variable of textfield class, , gettextfield() isn't real getter. when trigger gettextfield() , new pdfformfield instance created (itext open source, check if you're not sure). itext 5 grew organically. don't have degree in co

pop3 - OS ticket not fetching emails from gmail inbox -

using version osticket (v1.9.14) . having issue os ticket. i have 2 emails addresses, a@mail.com (inbox messages - around 3k) b@mail.com (inbox messages - around 90k) i have configured b@mail.com in os ticket configuration. cannot seem fetch emails inbox. whereas if configure a@mail.com , fetches emails inbox , converts them tickets in os ticket immediately. i not sure wrong here. these have checked/tried. i have checked pop3 settings. i have enabled 'allow less secured apps' on both accounts. enabled pop3/imap on both accounts. could because of large inbox size? guess not, keeping options open. if guys me this, appreciate it. if think if missing information, please let me know, edit question.

rust - How to convert a Option<Result<T, Error>> to an Option<T> without unwrapping it? -

i trying find way convert option<string> option<i8> . for example, use std::str::fromstr; fn main() { let some_option: option<string> = some("too".to_owned()); let new_option: option<i8> = some_option.map(|x| i8::from_str(x.as_str())); } i thought use turbo fish explicitly cast type this: use std::str::fromstr; fn main() { let some_option: option<string> = some("too".to_owned()); let new_option: option<i8> = some_option.map::<option<i8>>(|x| i8::from_str(x.as_str())); } however, compiler points out isn't correct amount of parameters, thought might work, doesn't: use std::str::fromstr; fn main() { let some_option: option<string> = some("too".to_owned()); let new_option: option<i8> = some_option.map::<option<i8>,i8::from_str>(); } you can use ok() , unwrap_or() functions: fn test() -> option<result<u32, ()>

Track or log calls to a user-defined function in SQL Server -

understanding side-effecting operators (like "insert") disallowed in user-defined functions, how 1 log (or otherwise track) calls specific user-defined function? i'd capture parameters passed udf. ideally, log table information (time stamp , parameter values) each call udf inserted. reports , usage metrics derived table. i can't rewrite udf stored procedure, of same name, without breaking many downstream systems out in wild expect udf , have no control over. nor willing enable type of command shell features on our server diminish sql server's best-practice security defaults. i found solution of problem. it’s little bit tricky , looks hack, seems it’s impossible solve in way. the idea create .net sql function logs data need (file, windows eventlog, db , on), next create sql udf calls .net function , call sql function functions passing parameters needed logged. sql server doesn't check inside .net function , can write there logic need. t

javascript - How to bypass zone.js in Angular 2 when using external script? -

i have angular 1 application ngupgrade. application pulls in external script file (a 3rd party service's lib), polls server via settimeout.. now, application works perfectly, except if want test protractor, not able that, since: scripttimeouterror: asynchronous script timeout: result not received in 30 seconds is there way tell angular 2 run contents of script tag outside of angulars context? try increase allscriptstimeout: timeout_in_millis stated in protractor timeouts page, under timeouts webdriver section.

jquery - Overlapping issue within gallery website -

i'm having issue image overlapping footer , navbar when inspecting webpage's responsiveness. attempted use jquery haven't been able make work , feel though solution isn't complicated, can't it. i'm not sure of effective way provide .png file i'm working here's imgur link: http://imgur.com/a/pejrv css, html, , js here: function myfunction() { var x = document.getelementbyid("mytopnav"); if (x.classname === "topnav") { x.classname += " responsive"; } else { x.classname = "topnav"; } } *{ margin: 0; } html { position: relative; min-height: 100%; } body { background: #232526; background: -webkit-linear-gradient(to right, #232526 , #414345); background: linear-gradient(to right, #232526 , #414345); margin: 0em; font-family: 'titillium web', sans-serif;

android - Notification is slowing down -

in application download files using intent service. while download starts download progress notification created. works fine, problem notification slows down phone: following code: note: have removed non related part of code make simple , clear: public void startdownload(string name, string packagename, string path, boolean obb, boolean data) { try { notificationid = generatenoficationid(packagename); intent = new intent(getapplicationcontext(), downloadlistview.class); pendingintent pi = pendingintent.getactivity(getapplicationcontext(), 0, i, 0); mbuilder = new notificationcompat.builder(this); mbuilder.setcontenttitle(name) .setcontenttext("downloading...") .setsmallicon(r.drawable.newiconpurple) .setcontentinfo("0%") .setprogress(100, 0, true) .setcontentintent(pi) .setongoing(true)

c - Can I do what I want with allocated memory -

are there limits on can allocated memory?(standard-wise) for example #include <stdio.h> #include <stdlib.h> struct str{ long long a; long b; }; int main(void) { long *x = calloc(4,sizeof(long)); x[0] = 2; x[3] = 7; //is beyond here legal( if exclude possible illegal operations) long long *y = x; printf("%lld\n",y[0]); y[0] = 2; memset (x,0,16); struct str *bar = x; bar->b = 4; printf("%lld\n",bar->a); return 0; } to summarize: can recast pointer other datatypes , structs, long size fits? can read before write, then? if not can read after wrote? can use struct smaller allocated memory? reading y[0] violates strict aliasing rule. use lvalue of type long long read objects of effective type long . assuming omit line; next troublesome part memset(x,0,16); . this answer argues memset not update effective type. standard not clear. assuming memset leaves effectiv

php - getting a query output to be a link(to another page) -

i trying create query suck data database , return them(rows of user names) links pages(respectively). the query seeems work having hard time echoing link (i missing '.' or alog line). i greatful if point me problem , why error browser doesn't expect: </a><br> . here code of php page(on html page stick expected results no need show logic there unless ask me to): <?php include('connectdb.php'); if( isset( $_post['user_name'] ) ) { $name = $_post['user_name']; $query = $conn->query("select u.firstname,u.lastname tblfriendswith fw inner join tbluser u on u.username=fw.username2 username1 '$name%' "); while($row = $query->fetch_row()) { echo '<a href=\'userpage.php?fullname='. $row[0] .' '. $row[1].'>'.$row[0] .' '. $row[1].'\'>' '</a>''<br>'; } } ?> i tried add '.' between , '&

jquery - Load a JSON document and sort it on one or more values in key:value pairs with JavaScript -

i want load external json object , sort based on 1 or more key:value pairs. example using json below might need sort on category1 , type. i've tried array.sort() no matter throw @ data never sorted; it's output in same order in json file. { "books": [ { "sku": "{1234}", "title": "moby dick", "type": "paperback", "category1": "fiction", "category2": "classic", "category3": "", "image": "", "ctalabel": "learn more" }, { "sku": "{5678}", "title": "1984", "type": "hardcover", "category1": "fiction", "category2": "", "category3": "", "image": "", "ctalabel&

Combining binary files python 3.4 -

i treating every file sequence of bytes , doing break them chunks , combine them later when file needed. when number of chunks created out of file grows, file recreated chunks loses integrity when checked sha512. using python 3.4. do please?

Android webview browser edit text automatically change with webview change -

i make webview in android . there webview , edit text , go button . want when webview change edit text automatically change current url . example: when type url "www.google.com" go google if go youtube google edit text stands "www.google.com". want edit text automaticlly change current webview java code package com.example.ashraful.userinterface; import android.app.activity; import android.graphics.bitmap; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.keyevent; import android.view.view; import android.view.window; import android.webkit.websettings; import android.webkit.webview; import android.widget.button; import android.widget.edittext; import android.widget.progressbar; public class main2activity extends activity { webview web1; edittext ed1; button bt1; string address; string add; progressbar pbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate);

javascript - order in triggering events and functions -

is there way perform in order? html: <button type="button">click!</button> js: window.addeventlistener("hashchange", function() { eventfunction(); }, false); document.queryselector('button').addeventlistener('click', function() { location.hash = "changed"; otherfunction(); }); function eventfunction() { console.log('first'); } function otherfunction() { console.log('second'); } here jsfiddle: https://jsfiddle.net/texzj2uv/1/ just call otherfunction asynchronously: window.addeventlistener("hashchange", function() { eventfunction(); }, false); document.queryselector('button').addeventlistener('click', function() { location.hash = "changed"; settimeout(otherfunction, 0); }); function eventfunction() { console.log('first'); } function otherfunction() { console.log('second'); } <but

Interpreter with Ocaml -

i write interpreter ocaml when try : sem(let("somma",fun("x",sum(den "x",eint(5))),let("pipa",pipe(seq(den "somma",nil)),apply(den "pipa",eint(42)))),(emptyenv unbound));; the resault error : "exception: match_failure ("",1,41) i think error in applypipe don't understand , why there did wrong? this code : type exp = . . . | fun of ide * exp | apply of exp * exp | letrec of ide * ide * exp * exp | etup of tuple (*tupla come espressione*) | pipe of tuple (*concatenazione di funzioni*) | manytimes of int * exp (*esecuzione iterata di una funzione*) , tuple = | nil (*tupla vuota*) | seq of exp * tuple (*tupla di espressioni*) ;; type eval= | int of int | bool of bool | unbound | recfunval of ide * ide * exp * eval env | funval of efun | valtup of etuple , efun = ide * exp * eval env , etuple = | nil | seq of eval *

excel - VBA : Performance on 24-deep nested IF statement -

original question i have sub 24-deep nested if statement l=2 while l <= lmax 'lmax = 15000 if condition1 if condition2a or condition2b ... if condition24 redim preserve propositions(ubound(propositions) + 1) propositions(ubound(propositions)) = l since sub called 250 times, if statement called 250 * 15000, performance big issue. (the macro run in 23 seconds.) when write if condition2a or condition2b then , vba check condition 2b if condition 2a true ? (ie, should ordrer a , b a less true b ?) ps : of course, condition 1 vs 2 ordered. short answer as stated @idevlop, short answer seems vba doesn't allow " short-circuit evaluation " ( see post ) solution performance problem my problem vba reading/accessing data sheet (rather vba computing if statement.). the solution loading data in 2d-array . single modification make sub run more 10 times quicker (less 2s vs

angularjs - Validate autocomplete field required -

i have mandatory autocomplete field in form , need validate, in validation $ invalid works partially, after filling field , delete value not identify invalid , value $ error.required blank. here code: <form name="editform" role="form" novalidate ng-submit="vm.save()" show-validation> <div class="form-group"> <label data-translate="coreapp.costcenter.company" >company</label> <angucomplete-alt id="field_company" pause="300" placeholder="{{'coreapp.crud.autocomplete' | translate}}" match-class="text-blue" ng-model="vm.costcenter.company_complete" input-name="company_complete" field-required="true" remote-api-handler="vm.searchcompany" remote-url-response-formatter="vm.searchformatter" remote-url-data-field="data&

ios - Multiple UNUserNotifications not firing -

i'm setting multiple unusernotifications below, - (void)viewdidload { [super viewdidload]; notifcount = 0; unusernotificationcenter *center = [unusernotificationcenter currentnotificationcenter]; [center requestauthorizationwithoptions:(unauthorizationoptionbadge | unauthorizationoptionsound | unauthorizationoptionalert) completionhandler:^(bool granted, nserror * _nullable error) { if (!error) { nslog(@"request succeeded!"); [self set10notif]; } }]; } in set10notif method, i'm setting multiple(8 testing) notifications time 10 seconds current time. -(void) set10notif { notifcount = notifcount+1; if (system_version_greater_than_or_equal_to(@"10.0") && notifcount < 10) { // create actions nscalendar *calendar = [[nscal

bash - How to use flag with 'sed' on mac? -

i dont find way use flag sed , matching pattern. i'm trying flag. don't understand how works. $ sed -i '' -n '/xxx.xxx@xxx.fr/i d' res.txt sed: 1: "/xxx.xxx@xxx.fr/i d": command expects \ followed text so want match xxx.xxx@xxx.fr , xxx.xxx@xxx.fr the -i '' --in-file (without cache) d delete. so how can use flag , multiple of them ? in documentation i've found way seems not work @ all. i use perl - regexes , options far more orthogonal , consistent sed versions across platforms: perl -i -ne '/xxx.xxx.fr/i || print' res.txt -i means "in-place" editing -n means execute loop around input lines awk or sed -e means execute following script

html - Android blurry screen sometimes -

Image
this device: https://www.amazon.de/sony-tablet-pc-touchscreen-ghz-quad-core-prozessor-interner/dp/b00in1n66i sony xperia tablet z2 sgp511 (10,1") tablet-pc (touchscreen, 2,3 ghz-quad-core-prozessor, 3gb ram, 16gb) android version 5.1.1 (lollipop) i'm developing app cordova (hybrid) , screen gets blurry no appearant reason. this goes away when tap screen in random place inside div or element blurry. blurry: ============================================= clear: application got blurry while remotely debugging android device.so isn't issue or error .when tap on application blur finish or discounting device computer blur goes away.

c# - Combine the results of a sql query together in one result -

i have application(c#) manages stock level every storage unit. want complete overview of stock level of every product every stock unit together. for example have 50 apples (productid 1) in unit 1 , 25 in unit 2 , use query: select stocklevel supply productid = '1' and put result in textbox gives me first stocklevel of 50 apples , not 75 . is there way can combine these results in easy way? if want combine , want aggregate function , sum in case: select sum(stocklevel) supply productid = '1' and apples being summed up: 75 50 + 25

maven - java.lang.NoClassDefFoundError: org/mule/streaming/ProviderAwarePagingDelegate when trying to use Dynamic Ax connector -

i using dynamicax in mule esb , servlet , creating war file , deploying in tomcat , when run gives me following error : exception javax.servlet.servletexception: servlet execution threw exception org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) root cause java.lang.noclassdeffounderror: org/mule/streaming/providerawarepagingdelegate org.mule.modules.msdynamicsax.generated.connectivity.msdynamicsaxconnectorgatewayconnectionconfigconnectionmanagementconnectionmanager.newconnector(msdynamicsaxconnectorgatewayconnectionconfigconnectionmanagementconnectionmanager.java:393) org.mule.devkit.3.8.1.internal.connection.management.connectionmanagementconnectorfactory.makeobject(connectionmanagementconnectorfactory.java:50) org.mule.devkit.3.8.1.internal.connection.management.connectionmanagementconnectorfactory.makeobject(connectionmanagementconnectorfactory.java:19) org.apache.commons.pool.impl.generickeyedobjectpool.borrowobject(generickeyedo

authentication - sshd Authorized key command not authenticating user -

i'm using simple ad authenticate ssh users on rhel 7.2 server. i've modified schema on ad include ldap parameter sshpublickey , ldappublickey , imported public key ad user. i can authenticate against ad fine using password login. can return ssh key ad using following command /usr/bin/sss_ssh_authorizedkeys user@domain.example.com i can manually copy returned key /home/user@domain.example.com/.ssh/authorized_keys , can log in absolutely fine. however when add following sshd_config , restart sshd can't authenticate (just permssion denied) authorizedkeyscommand /usr/bin/sss_ssh_authorizedkeys authorizedkeyscommanduser root to summarise, can authenticate against ad fine using passowrd, can return public key ad fine (and authenticate against key when manaually copy authorized_keys) can't work using sshd's authorizedkeyscommand turns out there spaces in after authorizedkeyscommand file. noticed starting sshd debug: systemctl stop sshd /usr/sbin/

sql - Hibernate: data truncated at primary key column -

i know question "data truncated" in sql many in stack overflow. question has little different , can't find answer that. it's truncated in primary key when i'm doing update statement. my function update sql: public void updatelistdata(string newid, string oldid) { stringbuilder sql = new stringbuilder("update card_info c "); sql.append("set c.xxx_id = :newid "); sql.append("where c.xxx_id <> '' , c.status = 1 , c.is_private = 1 , c.delete = 0 , c.xxx_id = :oldid "); query query = getentitymanager().createnativequery(sql.tostring()); query.setparameter("newid", newid); query.setparameter("oldid", oldid); query.executeupdate(); } my log: warn : org.hibernate.engine.jdbc.spi.sqlexceptionhelper - sql error: 1265, sqlstate: 01000 error: org.hibernate.engine.jdbc.spi.sqlexceptionhelper - data truncated primary key column: <card_

How to use boost asio for multiple udp connections? -

in application working on, hundreds of clients connect server via udp. socket connection remains open each client until client decides quit. i downloaded boost's sample code asynchronous udp server @ http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tutorial/tutdaytime6/src.html . from code, couple of things not clear: as each connection made client, save ip of incoming client. however, code, not obvious can put logic. it seems code can serve 1 client @ time. in case, there many concurrent connections , socket must kept alive each connection. how extend code? regards. as each connection made client, save ip of incoming client. however, code, not obvious can put logic. this code has no notion of connection. if you're writing code knows connection is, someplace decide whether or not each incoming datagram part of existing connection or establishing new one. that's put logic. it seems code can serve 1 client @ time. in case, there many c

cuda - What's the difference between cuDeviceCanAccessPeer(...) and cuDeviceGetP2PAttribute(..., CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED, ...)? -

i don't have access multi-gpu system test this, in cuda.h found 2 things seems quite similar. first function curesult cudaapi cudevicecanaccesspeer(int *canaccesspeer, cudevice dev, cudevice peerdev); described as returns in *canaccesspeer value of 1 if contexts on dev capable of directly accessing memory contexts on peerdev , 0 otherwise. if direct access of peerdev dev possible, access may enabled on 2 specific contexts calling ::cuctxenablepeeraccess() . and second 1 curesult cudaapi cudevicegetp2pattribute(int* value, cudevice_p2pattribute attrib, cudevice srcdevice, cudevice dstdevice); described as returns in *value the value of requested attribute attrib of link between srcdevice , dstdevice . supported attributes are: ::cu_device_p2p_attribute_performance_rank : relative value indicating performance of link between 2 devices. ::cu_device_p2p_attribute_access_supported p2 : 1` if p2p access enable. ::cu_device_p2p

php - SilverStripe adding announcements / warnings to CMS pages -

Image
is there way add announcement messages on top of admin pages, similar warning message on deleting install files after fresh silverstripe install? yes - https://packagist.org/packages/sheadawson/silverstripe-timednotices though they'll appear where-ever in cms, not on specific pages. can choose duration, , users targeted though.

MySQL Connection on Node.JS -

i have problem when try connect mysql database hosted ovh on nodejs server. here code : var mysql = require('mysql'); var connection = mysql.createconnection({ host : 'my_ip', port : '3306', user : 'my_user', password : 'my_pass', connecttimeout : 10000 }); connection.connect(function(err) { if (err) { console.error('error connecting: ' + err.stack); return; } console.log('connected'); }); but : error connecting: error: connect etimedout everytime, not matter do, changing timeout, remove port or else. idea ? i'm running on archlinux x86_64 i found answer : ovh doesn't allow customers use mysql database out of services means if want run code using mysql ovh database, have run code ovh server.

django rest swagger 2.0.7, I can't use the Post method -

Image
the display swagger ui: and parameters settings.py swagger_settings: swagger_settings = { 'security_definitions':{ 'basic':{ 'type':'basic' } }, 'apis_sorter': 'alpha', 'doc_expansion': none, 'json_editor':'true', 'operations_sorter':'alpha', 'show_request_headers':false, 'supported_submit_methods':['get','post','put','delete','patch'], 'validator_url':'0.0.0.0:8080', } have me solve problem?

java - Add Spring Actuator's healthcheck without Boot and @EnableAutoConfiguration -

i want add actuator spring application (not spring boot). precise, need use actuators healthcheck, i'll able create beans of different health indicators , create complete healthcheck on /health. at first tried add @endpointautoconfiguration @configuration class, there beans conflicts, because have customs beans, need, there's no need in other configurations other healthindicatorautoconfiguration

objective c - Can I use a key with 33-bytes in AES256 -

my friend wrote 2 methods aes256 objective-c . length of key kcckeysizeaes256+1 = 33 bytes now need port 2 methods language such java , php , go . other languages don't accept 33-byte key i can not change objective-c code because ios app online users. please me port these 2 methods languages!!! (i hate friend) objective-c methods: nsdata * aes256encryptwith(nsdata *data, nsstring *key){ // 'key' should 32 bytes aes256, null-padded otherwise char keyptr[kcckeysizeaes256+1]; // room terminator (unused) bzero(keyptr, sizeof(keyptr)); // fill zeroes (for padding) // fetch key data [key getcstring:keyptr maxlength:sizeof(keyptr) encoding:nsutf8stringencoding]; nsuinteger datalength = [data length]; //see doc: block ciphers, output size less or //equal input size plus size of 1 block. //that's why need add size of 1 block here size_t buffersize = datalength + kccblocksizeaes128; void *buffer = malloc(buffersize)

Runtime error while implementing vector in c++ -

i trying implement own version of vector in c++. far have done this.. #include<iostream> #include<string> using namespace std; template<class t> class vec { public: t *a; int i,n; vec(int n=0):n(n) { i=-1; a=(t *)malloc(n*sizeof(t)); } void push_back(const t& t); t at(const int& index) const; }; template<class t> void vec<t>::push_back(const t& t) { if(++i==n) { a=(t *)realloc(a,(++n)*sizeof(t)); } a[i]=t; } template<class t> t vec<t>::at(const int& index) const { return a[index]; } int main() { vec<string> v; v.push_back("2"); v.push_back("1"); v.push_back("3"); cout<<v.at(0)<<endl; return 0; } but getting run time error when run error in above code? using c++ , visual studio run. in case need use placement new. something this: // allocate memory void* mem =

javascript - JS Drag and Drop (Match) with letters -

i'm working drag , drop option , cannot make work letters (match works numbers). give hint how letters? thank you. © matt doylle http://codepen.io/anon/pen/zpkqjo <script type="text/javascript"> var correctcards = 0; $( init ); function init() { // hide success message $('#successmessage').hide(); $('#successmessage').css( { left: '580px', top: '250px', width: 0, height: 0 } ); // reset game correctcards = 0; $('#cardpile').html( '' ); $('#cardslots').html( '' ); // create pile of shuffled cards var numbers = [ 'a', 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; numbers.sort( function() { return math.random() - .5 } ); ( var i=0; i<10; i++ ) { $('<div>' + numbers[i] + '</div>').data( 'string', numbers[i] ).attr( 'id', 'card'+numbers[i] ).appendto( '#cardpile' ).draggable( { cont