Posts

Showing posts from August, 2015

c++ - How to calculate number of workdays between two given date -

ex. if give 2013-7-1 2013-7-7 , there 5 workdays (mon-fri) , output should 5 ps: in problem holidays excepted, consider weekends. does have idea of implementing c++? sorry isn't commented , i'm not professional programmer here go: compiles , when run , type in 1/1/2013/3 , 12/31/2013/3 261 work days year. if multiply 365*(5/7) 260.7 seems work. when 1/1/2013/3 , 12/31/2015/5 783. programmed leap year in less 90 lines. naming conventions might not consistent. know it's bad style use nested if statements whatever quick , dirty thing. edit: decided make more ellaborate practice own c++ skills, i've provided more functionality it. #include <iostream> #include <string> #include <vector> #include <sstream> using namespace std; class date{ public: unsigned days_per_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; unsigned month; unsigned day; int year; unsigned week_day; constexpr static int week_day_callibrator[4...

button - Change Selected Image Bug In Swift -

Image
i have button , want change selected image. after change image of button. there show blue point on button. after selected before selected @ibaction func videoshowbtn(sender: anyobject) { if videoshowoutlet.selected { playervideo.hidden = false videoshowoutlet.selected = !videoshowoutlet.selected } else { playervideo.hidden = true videoshowoutlet.selected = !videoshowoutlet.selected } playervideo.play() } but same code. button won't shows blue point. @ibaction func sharecontentshowbtn(sender: anyobject) { if sharecontentshowoutlet.selected { sharevideourltf.hidden = false sharevideocontenttv.hidden = false sharecontentshowoutlet.selected = !sharecontentshowoutlet.selected } else { sharevideourltf.hidden = true sharevideocontenttv.hidden = true sharecontentshowoutlet.selected = !sharecontentshowoutlet.selected } } can tell me why , how fix it? thanks! ...

node.js - Mongoose find all items with _id from an array that do exist -

i know can search in mongoose like schema.find( { '_id' : { $in: [1,2,3]} }, function(err,data){}); my problem e.g. objects _id 1 , 3 exist no object _id 2. find method fail. there way find possible objects ignoring inavlid id_s? according mongodb documentation , query should not fail no documents exist id of 2. the documentation states: the $in operator selects documents value of field equals value in specified array.

javascript - don't want to submit with prefilled value textarea; I have a required validation for text area but is not caught either -

i have textarea populated text , if click on type nothing when leave default pre-filled text populated again; don't want allow submission pre-filled text form; how can handle issue? my code: jquery(document).ready(function($) { $("textarea").val("please enter email content here..."); $("textarea").focusout(function() { if ($(this).val() === "") { $(this).val("please enter email content here..."); } }); $("textarea").focus(function() { if ($(this).val() === "please enter email content here...") { $(this).val(""); } }); }); by doing: <textarea placeholder="default text here"></textarea> otherwise, if need support oldies try store def. text variable , on submit check submitted value default. http://jsbin.com/unuqes/1/edit jquery(function($) { var $txta = $("textarea"); v...

Protect ranges with google apps script -

i have number of sheets need protect except ranges. is possible script, have several sheets, , many ranges within sheet need unprotected staff can edit sheets. the ranges need leave unprotected repetitive, i'm hoping it's doable. fill ranges want remain unprotected yellow on example sheet i'll give you. an example of 1 of sheets can viewed here . as mentioned, need protect whole sheet, apart these ranges... n4:v26,n30:v52,n56:v78 etc etc. rest of sheet needs protected. unprotected ranges, columns stay same, each unprotected range separated 3 rows protected. if can script i'd grateful save me hours of time manually protecting these ranges on many sheets. regards matt yes, can accomplish using protection class. first protect whole sheet using var protection = sheet.protect() , unprotect ranges want people able edit using protection.setunprotectedranges([ranges]) , [ranges] array of range objects. can read more in google apps script class prote...

javascript - $.post jQuery work only when alert inside post function -

my button : <button type="submit" name="submit" class="btn-primary btn-block" id="submit">login</button> and form : <form action="b.php" method="post" id="formid" onsubmit="return post();"> and js function : function post() { var cvs = $('#client-nbr').val(); var cs = $('#cs').val(); $.post('a.php',{postcvs:cvs,postch1:cs}); alert("post function work"); } my problem is: when remove alert post() function, doesn't post a.php , , when use return false inside post() function, function works on a.php page freezes , can't data b.php ! given want asynchronous $.post complete before submitting form, need to: prevent submit executing immediately, returning false in post function add success callback $.post call, in manually submit form. sure not trigger submit via jquery (using .trigger('subm...

javascript - HTML Canvas ShadowBlur Not Working After Rotating -

the problem having canvas not draw shadowblur effect when drawing image if rotate canvas @ draw it. works fine if set rotation value 0 degrees. i threw jsfiddle real fast, image pixelated , distorted anyhow reproduces issue https://jsfiddle.net/zsw7wkv4/1/ edit: seems chrome issue here code var canvas = document.getelementbyid('gamecanvas'); var ctx = canvas.getcontext("2d"); var asset = card.asset; // set card height based off width var height = width * 2.66; // save canvas before rotating ctx.save(); // hover effect drawn card if (core.information.xoffset >= left && core.information.xoffset <= left + width && core.information.yoffset >= top && core.information.yoffset <= top + height) { ctx.shadowcolor = 'white'; ctx.shadowblur = 15; } // translate center of card ctx.translate(core.information.pwidth * (left + width/2), core.information.pheight * (top + height/2)); // rotate canvas card ctx.rota...

java - NoSuchMethodError Exception with SetLocale -

in xamarin, have created following extension change locale on fly: public static void toenglishlocale(this activity activity) { locale locale = new locale("en-us"); configuration config = new configuration(); config.setlocale(locale); activity.basecontext.resources.updateconfiguration(config, activity.basecontext.resources.displaymetrics); } i targeting api 15 , fails following exception on api 15: unhandled exception: java.lang.nosuchmethoderror: no method name='setlocale' signature='(ljava/util/locale;)v' in class landroid/content/res/configuration; is there other "unified" way change locale on fly? thanks! the method setlocale added in api level 17 that's why getting error. you can use android.os.build.version.sdkint property find api version @ runtime , call method if android.os.build.version_codes.jellybeanmr1 or newer. if isn't should set locale public property instead of calling setlocale ...

python - How to move around items in QtDesigner? -

Image
i have silly problem. i move top layout on right side of mainwindow down ( mean under layouts push buttons). well, in android studio in such case move desired components inside object inspector , arrange order there. in qt desing "frozen" , i'm not able it. what simpliest way move components around in desired hierarchy? you can not move widgets/layouts object inspector, items displayed in alphabetical order. have on graphical elements. you should able drag&drop layout , see blue line going inserted . when have main layout, fills space available can insert widgets/other-layouts between other elements. the easiest way scratch place widgets (and spacers) need, without taking care of sizes , alignment, wrap them layouts inner layout outer.

CSS, Adding additional background on hover -

is there way add additional background div on hover? example add black background 50% opacity on top of existing background image. thanks. it better if post code you're trying achieve, posted simple example. if helps use !important force overriding div{ background: yellow; } div:hover { background:black; opacity:0.5; }

ios - Working to draw boundary around an object and the object is inside the image -

Image
i trying draw boundary around object, in case lesion object inside image plain background not noise. had taken image , read pixel values. and tried calculating xy coordinates along boundary of object using active contour algorithm boundary drew on edges of whole image instead on boundary along object inside, couldn't make better coordinates. can please suggest me if there better way find/draw boundary around object inside image or should go using opencv xcode better make ios app? kindly suggest. i haven't tried using opencv's active contours, fact have near black , near white outline along image edges doesn't help (input image provided in comments section above) (this opencv+python prototype) import cv2 import numpy np matplotlib import pyplot plt img = cv2.imread('skin.png') rgb_img = cv2.cvtcolor(img, cv2.color_bgr2rgb) red = rgb_img[:,:,0] height, width, channels = rgb_img.shape create mask , apply flood-fill mask = np.zeros((height+...

azure webjobssdk - Any Example of WebJob using EventHub? -

i've tried come example in webjobssdk github var eventhubconfig = new eventhubconfiguration(); string eventhubname = "myhubname"; eventhubconfig.addsender(eventhubname,"endpoint=sb://test.servicebus.windows.net/;sharedaccesskeyname=sendrule;sharedaccesskey=xxxxxxxx"); eventhubconfig.addreceiver(eventhubname, "endpoint=sb://test.servicebus.windows.net/;sharedaccesskeyname=receiverule;sharedaccesskey=yyyyyyy"); config.useeventhub(eventhubconfig); jobhost host = new jobhost(config); but i'm afraid that's not far enough of limited "skillset"! i can find no instance of jobhostconfiguration has useeventhub property (using v1.2.0-alpha-10291 version of microsoft.azurewebjobs package), can't pass eventhubconfiguration jobhost. i've used eventhub before, not within webjob context. don't see if eventhostprocessor still required if using webjob triggering...or webjob trigger act eventhostprocessor? anyway, if has more...

Thymeleaf + Spring MVC - selected date field on HTML5 is null on controller -

the following input field date object works, apparently, nicely. when reaches controller, value executiondate null. <form role="form" action="#" th:object="${pojo}" th:action="@{/scheduler/create}" method="post"> <div class="col-lg-5 col-sm-5 col-xs-10" > <div class="well with-header"> <div class="header"> <label th:for="datepicker0">execution date: </label> </div> <div class="form-group input-group"> <input id="datepicker0" type="text" name="executiondate" th:field="*{executiondate}" class="form-control"></input> <span class="input-group-addon"><i class="fa fa-calendar"></i></span> </div> </div> </div> // ...

dependency injection - Spring @PostContruct not waiting for complete bean creation -

while setting service have initialization method using @postconstruct, i'm calling service has been autowired. method calling service in turn uses service method has been autowired it, when service called, npe. indeed, autowired fields in second service null. having original autowired service extend applicationcontextaware proved service had not been initialized (or @ least had not been made context aware). it seems @postconstruct being called after service has been made context aware, it's not waiting until rest of application context aware. how can either have wait on dependencies or change initialization it's called @ later point in spring's initialization path? example: @service public class servicea { @autowired private serviceb serviceb; @postconstruct public void init() { serviceb.somemethod(); } } @service public class serviceb implements applicationcontextaware { @autowired private servicec servicec; // null @ time of @postconstruct pr...

angularjs - How to do a logic operation in Angular Template -

all: i wonder how can set or operator on html string in angualar template, like: <div>{{value || <h6>no header now.</h6>}}</div> the logic if value string not undefined, show value text, otherwise show error "no header now" wrapped <h6> . i not know why expression can not correctly interpreted? thanks this can solved ng-if : <div ng-if="value">value</div> <div ng-if="!value"><h6>no header now.</h6></div> you can add specific attributes (e.g. class ) and/or directives (e.g. ng-click ) on each <div> . the problem using single element have repeat condition several times: <div ng-class="{ value: 'class1', !value: 'class2' }" ng-click="value ? action1() : action2()" ng-bind-html="value || html"> </div>

Azure Batch - Create Nodes from VM Image -

i have selenium test code need run in parallel. in order selenium run effectively, configurations have done on machine (i.e. zone settings, chrome , firefox installs, etc.) , these settings hard (if not impossible) apply via automated approach. i've manually created vm, done setup , created image following directions in microsoft's documentation . now need setup code can specify vm image use when creating nodes. i've searched as can , not found documentation explains how can go doing this. the example in dotnettutorial sample doesn't seem have way specify image. there feedback item here on same topic , shows request started on jun 1st 2015. i'm hoping means it's done , hasn't been documented well. q: how can specify custom vm image source azure batch nodes? updated answer on 2017-03-17: custom images supported through "user subscription" batch accounts. can create these types of accounts in azure portal or through newes...

html - Why is the "display" css property not in the default whitelist for the owasp java library? -

i using owasp java library on backend service in order sanitize html sent client. owasp java library has css whitelist of css rules allow inside of style tag inside of html elements. can find whitelist here . one thing noticed whitelist display property omitted. means if create html code following: <div style="margin-left:0px;display:none;"></div> then html sanitizer default styling whitelist strip out display rule , html saved on server be: <div style="margin-left:0px;"></div> why display property not white-listed default? because other white-listed styles wouldn't work due element not being displayed @ update display has lot of weird edge cases affect layout in weird ways. inline , block , , inline-block safe in contexts. fixed safe in none. table , others dodgy since there may ways break visual containment. even block , inline block can break visual containment exam...

rspec - How to test a rails PORO called from controller -

i have extracted part of foos controller new rails model perform action: foos_controller.rb class fooscontroller < applicationcontroller respond_to :js def create @foo = current_user.do_something(@bar) actioned_bar = actionedbar.new(@bar) actioned_bar.create respond_with @bar end actioned_bar.rb class actionedbar def initialize(bar) @bar = bar end def create if @bar.check? # end end end i got working first i'm trying back-fill rspec controller tests. i'll testing various model methods , doing feature test make sure it's ok point of view add test make sure new actioned_bar model called foos controller @bar. i know in rspec can test receives with arguments i'm struggling work. "calls actionedbar.new(bar)" bar = create(:bar) expect(actionedbar).to receive(:new) xhr :post, :create, bar_id: bar.id end this doesn't work though, console reports: nomethoderr...

Mysql join two tables with counpe oft the different type of records -

Image
i'm having 2 table sendmail , campaign tables in mysql. sendmail table represents both sent , failed status in stats field. , campaign filed having campaign table id reference. i'm trying display how many mails had been sent , failed in each campaign. 2 table structure are, sendmail table campaign table structure , expected result: campaigname totalsent totalunsend aaaa 0 1 supply chain 6 0 development 6 0 design&development 8 3 you can use query this: select campaign.name, sum(status=1) totalsent, sum(status=0) totalunsent campaign inner join sendmail on campaign.campaignid = sendmail.campaignid group campaign.name

Firing Foundation 6 tab from multiple links -

is there way pull tab second link tab? i have 2 tabs, links inside tabs-title work, want include link tab 2 inside tab-panel area of tab 1 - , vise versa. you can use little javascript. add anchor content of tab 1 open tab 2. <a href="#" onclick="$('#example-tabs').foundation('selecttab', '#panel2');">open tab 2</a> here example using tabs docs panel choosers added. <div class="row"> <div class="small-12 columns"> <ul class="tabs" data-tabs id="example-tabs"> <li class="tabs-title is-active"><a href="#panel1" aria-selected="true">tab 1</a></li> <li class="tabs-title"><a href="#panel2">tab 2</a></li> </ul> </div> <div class="tabs-content" data-tabs-conte...

Get list of user sessions using a particular remote app using powershell -

we're putting powershell script deploy new versions of applications onto our servers. need list of rdusersession objects running our application. we're finding get-rdusersession command -collection option return users on system, including administrators logged in remotely, not running remoteapp. what want kick off users running our remote applications can perform update. right list of rdusersessions , send them messaage using send-rdusermessage , we're finding sending message, , booting off, admins trying run script. is there way list of applications running in rdusersession ? #load applications in array $arr = @("a.exe", "b.exe") #get rd user sessions $rdsessions = get-rdusersession #create blank array capture users $usrarr = @() #loop through applications in array foreach($app in $arr) { #loop through each of sessions. foreach($rdsession in $rdsessions) { #check application $proc = get-wmiobject -c...

MIPS jump loop - high order error -

i cannot seem right reason, googled bunch too, not find solution this. getting error:"target of jump differs in high-order 4 bits instruction pc 0x400054". tried jump in increment of 2 jumps reach goal, still not work. doing wrong? trying jump loop: section.. there way can this? .text .globl main main: loop: la $a0, celsius #string celsius li $v0, 4 syscall li $v0, 5 #read int celsius syscall j 1 backone: j loop one: blt $v0, -50, end #tests if in bounds, else out bgt $v0, 50, end jal celsius nop j backone #i getting "target of jump differs in high-order 4 bits instruction pc 0x40004c" end: li $v0, 10 #so inserted 2 jumps. .data ce...

Matlab. User input matrix to a string -

prompt = 'enter ascii codes'; dlg_title = 'input'; num_lines = 5; defaultans = {''}; answer = inputdlg(prompt,dlg_title,num_lines,defaultans); answer = answer{1}; m2=matrixa.'; result=char(m2(:)).'; result what im trying write script when run it, convert matrix of numbers input sentence. doing wrong? your input matrix string, not numeric. change line 7 to: answer = str2num(answer{1}); but since never assign matrixa , might change this: matrixa = str2num(answer{1});

java - Efficient Hibernate criteria for join returning many partial duplicates -

i'm fetching long list of entities refer others refer to... and, @ end, of them refer single user owner . not surprising what's queried entities belonging single user . there more parts duplicated in many rows; actually, small percentage unique data. query seems slow, though gain bit fetching things separately using criteria.setfetchmode(path, fetchmode.select); this works in above case, when querying on many users (as admin), gets terrible, hibernate issues separate query every user , instead of like select * user id in (?, ?, ..., ?) or not fetching them @ (which can't worse 1 query per entity). wonder missing? so instead of fetching lot of redundant data, ran 1+n problem, 1+1 queries do. is there way instruct hibernate use right query? is there way prevent hibernate fetching owners specifying in criteria (rather putting fetch=fetchtype.lazy on field; laziness should query-specific)? i don't think matters, classes like class child { @m...

Javascript: Multiple timers VS single timer -

i have simple question javascript timers , performance bugs me because can't figure out right way it. here problem: have special timing function self corrects itself: function setcorrectinginterval(func, delay) { if (!(this instanceof setcorrectinginterval)) { return new setcorrectinginterval(func, delay); } var target = date.now() + delay; var self = this; function tick() { if (self.stopped) { return; } target += delay; func(); settimeout(tick, target - date.now()); } settimeout(tick, delay); } then, in application use function n times set n different timer variables. if have 2 timer variables use function twice set them. in code bellow execute first task every 1000ms , second task every 2000ms: var firsttimer, secondtimer; function startfirsttimer() { firsttimer = setcorrectinginterval(function() { console.log("first!"); }, 1000); } function startsec...

python - Accessing Apps for Work Gmail via Gmail API from personal account? -

i've been experimenting gmail api on personal google account. simplicity, consider python quickstart example (which works fine). problem i'm unable access work gmail using same approach. if replace personal email address work email address in code... results = service.users().labels().list(userid='myworkemail%40myworkdomain.com').execute() ...i standard delegation denied error: <httperror 403 when requesting https://www.googleapis.com/gmail/v1/users/myworkemail%40myworkdomain.com/labels?alt=json returned "delegation denied mypersonalemail@gmail.com"> following few hints previous stackexchange questions, i've tried working through instructions make service account , authorised api call , service account form personal account's developer console... credentials = serviceaccountcredentials.from_json_keyfile_name('service_account.json', scopes=scopes) delegated_credentials = credentials.create_delegated('myworkemail%40my...

How can I fix formula cells in bulk? Excel -

so have table of cells in excel have loads of formulas referencing cells above it. i want create copy of table below it, , keep formulas , values same. when creating formulas didn't put $ fix each cell. dont want go each cell , add $ cells before pasting. is there way can highlight cells , bulk fix cells being referenced? thanks in advance, let me know if im not being clear. the best way use vba: put in module, select range of cells, , run it. sub abslt() dim rng range each rng in selection if rng.hasformula rng.formula = application.convertformula(rng.formula, xla1, xla1, xlabsolute) end if next rng end sub it convert references absolute references.

php - Android Sign Up Activity not inserting data remote MySQL database from user input -

i've been having trouble updating remote database. signuprrequest class exists extends string request class. package com.example.admin.tripod; import com.android.volley.response; import com.android.volley.toolbox.stringrequest; import java.util.hashmap; import java.util.map; /** * created admin on 4/19/2016. */ public class signuprequest extends stringrequest { private static final string register_request_url = "http://lushandlaceng.com/php/register.php"; private map<string, string> params; public signuprequest(string fullname, string email, string username, string password, string dob, response.listener<string> listener) { super(method.post, register_request_url, listener, null); params = new hashmap<>(); params.put("fullname", fullname); params.put("email", email); params.put("username", username); params.put("password", password); ...

r - pool.compare generates non-comformable arguments error -

alternate title: model matrix , set of coefficients show different numbers of variables i using mice package r analyses. wanted compare 2 models (held in mira objects) using pool.compare() , keep getting following error: error in model.matrix(formula, data) %*% coefs : non-conformable arguments the binary operator %*% indicates matrix multiplication in r . the expression model.matrix(formula, data) produces "the design matrix regression-like model specified formula , data" (from r documentation model.matrix {stats} ). in error message, coefs drawn est1$qbar , est1 mipo object, , qbar element "the average of complete data estimates. multiple imputation estimate." (from documentation mipo-class {mice} ). in case est1$qbar numeric vector of length 36 data data.frame 918 observations of 82 variables formula class 'formula' containing formula model model.matrix(formula, data) matrix dimension 918 x 48. how can resolve/pre...

datetime - Compare Dates in Angular 2 -

this question has answer here: javascript date object comparison 4 answers i'm trying figure out how best compare dates in angular 2 , typescript 1.8.7. given: startdate: date; enddate: date; if(this.startdate.getutcmilliseconds() === this.enddate.getutcmilliseconds()){ //do stuff here } else { // else here } this return error "startdate.getutcmilliseconds not function..." does have best practice? thanks, date object method milliseconds called gettime .

mingw - Code::Blocks MPICH2 Undefined reference in Windows -

i searched on how link mpich2 code::blocks, couldn't find understandable solution. (running windows 7 64x bit) so did far downloaded mpich2 windows market, install both .msi , .exe . the mpi didn't functions, tried using link , tools section inside code::blocks. no go. so copied .h , .lib files mingw path , choose 32x bit files put in lib folder because both mingw in 32x program files , target pc upload code 32x. (i tried 64x later, no difference). so far thats optimal thing did code::blocks complete syntax , tell me whats parameters is. had problem sal.h , downloaded , put in header , give me errors when ever use misodes in example: if use mpi_init(null,null); , console outputs undefined reference to mpi_init@8'|` my problem particular 1 , search results either 1 aspect. don't know next. keep in mind student , have minimum experience in ide, compilers, linkers , programming in general. in care. thanks in advance. thank , edit grammar ...

Outlook 2013 using VBA to Send Drafts -

good morning, using outlook 2010 compiled code send emails saved in drafts folder of given account. i've upgraded office 2013 getting error... .send bit falls on , presents error message: "this method can't used inline response mail item." i there v simple method sending drafts, have scoured web , can't figure yet. public sub senddrafts() dim ldraftitem long dim myoutlook outlook.application dim mynamespace outlook.namespace dim myfolders outlook.folders dim mydraftsfolder outlook.mapifolder 'send items in "drafts" folder have "to" address filled 'setup outlook set myoutlook = outlook.application set mynamespace = myoutlook.getnamespace("mapi") set myfolders = mynamespace.folders 'set draft folder. need modification based on it's set mydraftsfolder = myfolders("accounts@credec.co.uk").folders("drafts") 'loop through draft items ldraftitem = mydraftsfolder.items.count 1 ste...

javascript - Get relative position of view in Appcelerator Titanium -

i'm trying relative position of imageview in view appcelerator titanium. my code : var contentview = ti.ui.createview({width:300,height:300,backgroundcolor:"red"}); var imgview = ti.ui.createimageview({image:'image.png', height:100, width:100, zindex:5}); contentview.add(imgview); win.add(contentview); i want know position of imgview in contentview during touchmove event : var olt = ti.ui.create3dmatrix(), curx, cury; imgview.addeventlistener('touchstart', function(e) { curx = e.x; cury = e.y; }); imgview.addeventlistener('touchmove', function(e) { var deltax = e.x - curx; var deltay = e.y - cury; olt = olt.translate(deltax, deltay, 0); imgview.animate({transform:olt, duration:100}); //-- top/left position of imgview ? }); do have ideas please ? :) imgview.rect.x imgview.rect.y does work you? properties on view object found @ http://docs.appcelerator.com/platform/latest/#!/api/titanium.ui.vi...

javascript - Field only required if certain dropdown is selected in a HTML form -

i wondering how field required if dropdown selected. in form, person select "canada" , 2 fields underneath appear(province , postal code), required before person submits form. , if person selected "united states", state , zip code appear instead. the trouble having if choose either country, fields not associated country still required though hidden. need if choose united states, province nor postal code required, , same other way around. any appreciated:) here form <script type='text/javascript'>//<![cdata[ $('select[name=country]').change(function () { if ($(this).val() == 'canada') { $('#provinceselect').show(); $('#province').prop('required',true); } else { $('#provinceselect').prop('required',false); $('#provinceselect').hide(); $('#province').prop('required',false); } ...

Why we have to get two file descriptors in TCP server socket programming? -

i take tutorial server socket programming link . functionality, have no problem that, , i'm asking more architecture design question. please take in tutorial. see 2 file descriptors, 1 when calling socket() , , 1 when calling accept() . makes sense why file descriptor when creating socket because treat socket file; makes sense have have multiple file descriptors when accepting different connections. why need have both make work? the 1st socket called listening socket. tcp connection oriented stream. each client connection operates on own socket file. if have 1 socket, not able distinguish connection data received on belongs to. way tcp socket designed have listening socket operate in listen mode, , each time client want establish connection server, accept call return new socket, aka client socket, represent new connection, used communication client exclusively. on other hand, udp connectionless datagram-based protocol, in 1 socket used handle data clients.

ios - NEHotspotHelper NetworkExtension -

i trying use new framework can not understand scope. is possible connect wi fi automatically? example, when ios call background service in app can set password , confidence of particular network. [network setconfidence:knehotspothelperconfidencehigh]; [network setpassword:@"qwerty"]; and can see message under ssid user has touch wi fi connect. my question is, possible without user touch it? example, when have known wi fi ios connected automatically. is there way emulate behavior framework? thanks. this framework allows connect selecting network (touching it). can´t emulate behavior because can´t settings app, it´s extension app , work

linked list - Error deleting node from first position in c -

as many previous posts show, making code simulate crazy 8's card game. have delete node function meant delete card deck being played. works cards after first, every time try delete first card (node) list not delete , messes whole program after it. here function: void deletenode(card *head, int coordinate) { card *current = head; card *temp = null; temp = current; int count = 1; while (head != null) { if (coordinate == 0) { current = current->listp; free(temp); break; } else if (count == coordinate) { temp = current->listp; current->listp = current->listp->listp; free(temp); break; } else { count++; current = current->listp; } } } the *head passed top of hand being played. coordinate number of card user wants play. example, if first card in deck q of hearts , that's want play...

database - Deciding the pointing bucket of extendable hashing -

i have extendable hashing. need insert values 23,31,5, 7,11,17, 2,3 . hash function h(x)=x mod 4. , bucket size 2. i have doubt how pointing each bucket need done when directory size grows. is there way how pointing need decided. please help

How to fix CodenameOne build upload error -

i have been running issues when trying submit build server. every time try submit it, fails. here's output of process : ant -f /home/darklord/netbeansprojects/dashboardfaes build-for-android-device no gui entries available init: deps-clean: updating property file: /home/darklord/netbeansprojects/dashboardfaes/build/built-clean.properties deleting directory /home/darklord/netbeansprojects/dashboardfaes/build refresh-libs: deleting directory /home/darklord/netbeansprojects/dashboardfaes/lib/impl clean: copy-android-override: created dir: /home/darklord/netbeansprojects/dashboardfaes/build/classes copy-libs: deps-jar: updating property file: /home/darklord/netbeansprojects/dashboardfaes/build/built-jar.properties compile forcing compliance supported api's/features maximum device compatibility. allows smaller code size , wider device support created dir: /home/darklord/netbeansprojects/dashboardfaes/build/tmp compiling 13 source files /home/darklord/netbeansprojects/...

java - Error connecting to PostgreSQL 9.4 with MIT Kerberos via JDBC vs CLI -

i have set postgresql 9.4 mit kerberos 5 , can connect on cli using psql. after filing off fingerprints principal bgiles/postgres@realm, pg_hba.conf has host 0.0.0.0/0 gss include_realm=1 map=gss krb_realm=realm and pg_ident.conf file has gss /^(.*)/postgres@realm$ \1 i created principal, saved keytab, , if $ kinit -k -t krb5.keytab bgiles/postgres i can connect postgresql server 'kpg'. proves kerberos , keytab set properly. $ psql -h kpg dbname (connection information...) however when use same keytab connect via jdbc gss authentication error due postgresql refusing perform mapping. 2016-04-20 00:13:16 utc [18919-1] bgiles/postgres@bgiles log: no match in usermap "gss" user "bgiles/postgres" authenticated "bgiles/postgres@realm" 2016-04-20 00:13:16 utc [18919-2] bgiles/postgres@bgiles fatal: gssapi authentication failed user "bgiles/postgres" 2016-04-20 00:13:16 utc [18919-3] b...

swift - SKAction repeated forever -

how can limit number of time skaction running? if pointslabel.number > highscorelabel.number{ runaction(bestscore) highscorelabel.setto(pointslabel.number) let defaults = nsuserdefaults.standarduserdefaults() defaults.setinteger(highscorelabel.number, forkey: "highscore") } and var bestscore = skaction.playsoundfilenamed("1up", waitforcompletion: false) help me please to repeat action number of times, rather repeating forever, can use + repeataction:count: method. docs: creates action repeats action specified number of times. when action executes, associated action runs completion , repeats, until count reached.this action reversible; creates new action reverse of specified action , repeats same number of times. important thing keep in mind action repeated must have non-instantaneous duration.

php - preg_replace image tag to other format string -

i have change image tags per php ... here source string ... 'picture number <img src=get_blob.php?id=77 border=0> howto use' the result should this 'picture number #77# howto use' i have tested lot, number of image result ... last test ... $content = 'picture number <img src=get_blob.php?id=77 border=0> howto use'; $content = preg_replace('|\<img src=get_blob.php\?id=(\d+)+( border\=0\>)|e', '$1', $content); now $content 77 i hope can me almost correct. drop e flag: $content = 'picture number <img src=get_blob.php?id=77 border=0> howto use'; $content = preg_replace('/\<img src=get_blob.php\?id=(\d+)+( border\=0\>)/', '#$1#', $content); echo $content; outputs: picture number #77# howto use see documentation more information regular expression modifiers in php.

cloudera - What happens when a query is fired by client in Impala? -

how client contact impalad deamon when query fired ? happens in background when client fires query has executed impala ? take impala-shell example, impalashell python class extends cmd.cmd . user will: 1) connect ip:port in shell, call do_connect(..) , connect impala backend through thrift. , thrift client created self.imp_service = impalaservice.client(protocol) 2) select xxx table... in shell, call do_select(...) , self.imp_service.query(query) called thrfit rpc. 3) rpc query executed on impalad side void impalaserver::query(queryhandle&, const query&) : coordinator parse query , create fragmented ast, , assign each fragment set of hosts execute; rpc calls issued in parallel each host each fragment. parent fragment wait until child fragment done. 4) when fragments done, data shown on screen after fetch() thrift call client side.

bash - Ant executable attribute -

i work bash , ant , want execute command <exec dir="../../../path/to/" executable="./configure"> <arg line="--prefix=$(readlink -f ./../../../applications/common/lg-media-server/rpmbuild/pp)"/> </exec> it not work .can me? the issue ant doesn't interpret command line arguments shell do. must first evaluate $(readlink -f ./../../../applications/common/lg-media-server/rpmbuild/pp) via ant before calling configure. something these 2 steps should work: <exec executable="readlink" outputproperty="pp_path"> <arg line="-f ./../../../applications/common/lg-media-server/rpmbuild/pp"/> </exec> <exec dir="../../../path/to/" executable="./configure"> <arg line="--prefix=${pp_path}"/> </exec>

jsf - jpa bulk insert not inserting properly -

i developing jsf jpa project in problem bulk insert list size more 6000 means should insert more 6000 records in table inserts 215 records. my code here factory = persistence.createentitymanagerfactory(persistence_unit_name); entitymanager em = factory.createentitymanager(); try { em.gettransaction().begin(); (int = 0; < sgmllist.size(); i++) { // getting object list using loop sgml sgml = sgmllist.get(i); em.persist(sgml); } em.gettransaction().commit(); facescontext.getcurrentinstance().addmessage(null, new facesmessage("sgml imported successfully")); } catch (exception ex) { } { if (em != null) { em.close(); } } and persistence xml is <?xml version="1.0" encoding="utf-8"?...

switch case infinite loop bug in c++ -

this question has answer here: infinite loop cin when typing string while number expected 3 answers i working on menu driven program output adjacency matrix homework assignment. when put character in input after call of other 4 cases loop runs infinitely , can't figure out why. this happens regardless if have case 5 active. but if enter character first input closes intended. i stepped through debugger , seems if character entered takes input 4 , never takes input keeps printing array on , over. can explain wrong function? have function here because entire program 300 lines not counting comments. through testing i've narrowed bug down specific function others meant to. void menu(char graph[][8]) { bool run = true; while (run == true) { int menuchoice; cout << "welcome menu" << endl; cout ...