Posts

Showing posts from March, 2010

javascript - Asynchronous data input in highcharts -

i loading data mysql database using $.getjson method. data displayed in highcharts. there different buttons user can click in order change between datasets. problem when page first loaded, chart load empty. found out because $.getjson method using retrieving data asynchronous. not sure whether can resolved switching getjson method ajax method. have tried did not succeed. or whether javascript function switching chart data upon button-clicks problem. below code. fragments of code think responsible problem showed below. know might want jsfiddle since using database data know how display problem. <script> var d = new date(); var pointstart = d.gettime(); //------------------------------------------------------- //set 'line' marker type use in bullet charts highcharts.renderer.prototype.symbols.vline = function(x, y, width, height) { return ['m', x, y + width / 2, 'l', x + height, y + width / 2]; }; highcharts.renderer.prototype.symbol...

Change version of .net core in Azure App Service -

i have asp.net core app works correctly on computer not on azure app service: in 1 of api, return dynamic type. api runed on computer got (with .net core version : 1.0.1): {"id":2,"color":"#3da1e8 ","logo":"","name":"...","companysecurities":[]} from api runed on azure app service got (with .net core version : 1.1.0-preview1-001100-00): {"id":2,"color":"#3da1e8 ","logo":"","name":"...","companysecurities":[] you can see the last bracket disapear on azure app service. i want know if there way change .net core version of azure app service 1.0.1 .

c# - Web Api Response Standards -

i have 2 development paths regarding return value should restful architecture standpoint. pros , cons of each method below? first method. the client submit post of item hologram . here model in method one. public class hologram { public double holowidth { get; set; } public double holoheight { get; set; } public double holodepth { get; set; } public string hologuid { get; private set; } public hologram() { this.hologuid = new guid().tostring(); } } the idea is, method able provide faster response client, because return guid associated hologram . here repository method one, don't have database connection set yet _holos database. public string add(hologram hg) { hologram hig = new hologram(); hig = hg; asynccode(_holos.values.add(hig)); /// adds database via injection, running asynchronously. return hig.hologuid; } ...

dictionary - Scala - map function - Only returned last element of a Map -

i new scala , trying out map function on map. here map: scala> val map1 = map ("abc" -> 1, "efg" -> 2, "hij" -> 3) map1: scala.collection.immutable.map[string,int] = map(abc -> 1, efg -> 2, hij -> 3) here map function , result: scala> val result1 = map1.map(kv => (kv._1.touppercase, kv._2)) result1: scala.collection.immutable.map[string,int] = map(abc -> 1, efg -> 2, hij -> 3) here map function , result: scala> val result1 = map1.map(kv => (kv._1.length, kv._2)) result1: scala.collection.immutable.map[int,int] = map(3 -> 3) the first map function returns members expected second map function returns last member of map. can explain why happening? thanks in advance! in scala, map cannot have duplicate keys. when add new key -> value pair map , if key exists, overwrite previous value. if you're creating maps functional operations ...

python - Unknown label type sklearn -

i 'm new in sklearn. 'm trying code data = pandas.read_csv('titanic.csv') data= data[data['pclass'].notnull() & data['sex'].notnull() & data['age'].notnull() & data['fare'].notnull()] test = data.loc[:,['pclass','sex','age','fare']] target = data.loc[:,['survived']] test = test.replace(to_replace=['male','female'],value=[1,0]) clf=decisiontreeclassifier(random_state=241) clf.fit(target,test) and saw error valueerror: unknown label type: array([[ 22. , 3. , 7.25 , 1. ], [ 38. , 1. , 71.2833, 0. ], [ 26. , 3. , 7.925 , 0. ], ..., [ 19. , 1. , 30. , 0. ], [ 26. , 1. , 30. , 1. ], [ 32. , 3. , 7.75 , 1. ]]) what problem? you providing dataframe , not it's numpy array representation training input fit method. instead: c...

python - function returns previous value -

i want users input number, check validity , return it. if number invalid, wish repeat input process. if type: "5b" "50.4" the function doesn't return 50.4 . instead returns 5.0 , remainder of first function call executed. how can fix above issue, 50.4 ? def inputgoal (): goalfiltered = "" print ('1: ' + str(goalfiltered)) goal = input("input number: ") char in goal: matched = false sign in comparator: if (sign == char): matched = true if (char != ','): goalfiltered += sign elif (char == ','): goalfiltered += '.' if (matched == false): print ("please repeat input, valid characters are: 0 1 2 3 4 5 6 7 8 9 , .") inputgoal() #return goalfiltered = float(goalfiltered) return (goalfiltered) the comparator var...

javascript - jQuery - Have to press button twice or more to make the function stick -

i attempting make "etch-a-sketch" style block of divs. when "erase()" or "draw()" functions called via button press, work few seconds or increase or decrease opacity .1 until double press button. trying make can pressed once , continue increase/decrease opacity on hovered elements continually until other function stopped. missing here? function erase(){ $('.erase').toggleclass('draw').toggleclass('erase'); $('.box').hover(lighten); } function draw(){ $('.erase').toggleclass('erase').toggleclass('draw'); $('.box').hover(darken); } function darken(){ var currentdarkness = +$(this).css('opacity'); if (currentdarkness <= 1) currentdarkness += .10; $(this).css({"opacity": currentdarkness}); } function lighten(){ var currentdarkness = +$(this).css('opacity'); if (currentdarkness >= 0) currentdarkness -= .10; $(this).css...

java - iReport plugin doesn't find FBDriver class -

i'm trying connect application firebird database, , need generate report in ireport plugin, i'm using jdk 1.8. when set firebird jdbc driver ( org.firebirdsql.jdbc.fbdriver ) in ireport returns classnotfound exception. i tried import jaybird-full2.2.11.jar classpath no success.

Browser Sync with php files only works when phpinfo() is in the file -

i'm using browser sync automatically refresh page when php file changes. trouble shooting why wasn't working had phpinfo() in file. opcache enabled, disabled , refreshing began work. but after deleted phpinfo() file browser refreshing doesn't happen. if add in works again. i'm using laravel homestead vm. any idea might going on? weird.

javascript - Is there a way to 'bake' the variable? -

i'm creating dynamic scroll page, decided use wheel event detect user's scrolling. may know event has deltay parameter updates dynamically(several times 1 scroll). want script return true once deltay bigger 100. updates on , on again causing function shoot several times. there way 'bake'(be able change once) true value? window.addeventlistener('wheel', func) function func(event){ if(event.deltay>100){ var p = document.createelement('p'); var text = document.createtextnode("you scrolled on 100"); p.appendchild(text); document.body.insertbefore(p, document.getelementsbytagname('p')[0]); } } <p>scroll page down \/ , keep scrolling</p> you remove listener once element has been added. way function not continue fire. window.addeventlistener('wheel', func) function func(event){ if(event.deltay>100){ var p = document.createelement('p'); ...

typescript - Type inference success depends on naming a value -

i'm still new typescript , find things find odd. take code: interface myinterface<t> { [i: string]: t; } function myfunc<t>(arg: myinterface<t>) { } var o = { 'val1': 42, 'val2': 43 }; myfunc(o); the call fails complaint "index signature missing". interestingly, it's not missing when write myfunc({ 'val1': 42, 'val2': 43 }); that mean expression { 'val1': 42, 'val2': 43 } 's type inferred backwards call (which expected), not when bound name (which weird , not how know backward inference work f#, example). but gets stranger. if change interface to interface myinterface<t> { [i: number]: t; } then corresponding var o = [42, 43]; myfunc(o); also works (in addition passing array directly). is design? rules explain this? the reason you're seeing inconsistency because you're using typescript 1.8. if try either out in typescript playground, y...

Get php function value from javascript -

allow me preface saying did on other answers, still uncertain how execute it. here problem: i have .txt file reading , parsing meaning of name (i know, db better, given). wish fetch return value of php function javascript function. how go doing this? php code: function populatemeaning() { $meanings = fopen("meanings.txt", "r") or die("unable open file"); $meaning = ""; $selectoption = $_post['allnames']; while(!feof($meanings)) { $selectoption = strtoupper($selectoption); $line = fgets($meanings); if(strpos($line,$selectoption ) !== false) { $meaning = substr($line, strpos(0, ' '), strlen($line)); } } return $meaning; } javascript function in question: function meaning(){ document.getelementbyid("meaning").innerhtml = "hello"; } so have div element titled "meaning" , replace it's inner html value. string...

liquid - Exclude current post from recent posts query in Jekyll? -

so heres recent posts query last 5 posts. {% post in site.posts limit:5 %} <li> < href="{{ post.url }}">{{ post.title }}</a> </li> {% endfor %} however, shows current 1 too, if 1 of 5 latest posts. tried include if statement check url, how can add +1 limit variable? p.s.: included space in anchor tag readable code checking url should work. loop on 6 items , hide last 1 when not find match. {% post in site.posts limit:6 %} {% if post.url != page.url %} {% if forloop.index < 6 or found %} <li> <a href="{{ post.url }}">{{ post.title }}</a> </li> {% endif %} {% else %} {% assign found = true %} {% endif %} {% endfor %}

postgresql - Unable to install gem pg for ruby on rails -

this question has answer here: can't find postgresql client library (libpq) 14 answers after trying couple of ways install homebrew , rvm still cannot install gem pg i used stackoverflow answered questions, did not me @ all. i using postgresql app my question doing wrong? did not created user pg because main problem cannot install pg on mac $ sudo gem install pg -v '0.19.0' building native extensions. take while... error: error installing pg: error: failed build gem native extension. /system/library/frameworks/ruby.framework/versions/2.0/usr/bin/ruby extconf.rb checking pg_config... yes using config values /usr/local/bin/pg_config checking libpq-fe.h... yes checking libpq/libpq-fs.h... yes checking pg_config_manual.h... yes checking pqconnectdb() in -lpq... no checking pqconnectdb() in -llibpq... no checking pqconnectdb() in -lms/libpq....

c++ - Linked list with Template -

i need build linked list template, have no idea why not working, i've built linked lists before, never templates. right problem that, if create list ok, when try insert it, following errors: error c2664 'nodo<d>::nodo(nodo<d> &&)': cannot convert argument 1 'const int' 'const nodo<d> &' datos2 d:\google drive\visual studio 2015\projects\datos2\datos2\listasimple.h 69 error c2664 'nodo<d>::nodo(nodo<d> &&)': cannot convert argument 1 'const int' 'const nodo<d> &' datos2 d:\google drive\visual studio 2015\projects\datos2\datos2\listasimple.h 73 with following code: //linkedlist.h #pragma once #ifndef _listasimple_h #define _listasimple_h template<class d> struct nodo { int carga; int binario; d caracter; nodo<d> *siguiente;//means next }; template<class d> class listasimple { public: listasimple(); ...

mysql - SQL Statement with Join - missing record ... (simple noob request) -

Image
this noob-question, know. have 2 tables: the data looks ... products_services: product_service_categories: my sql-statement looks this: select product_service_id, product_service_name, product_service_category_name products_services join product_service_categories on products_services.product_service_category_id = product_service_categories.product_service_category_id products_services.company_id = '7' order product_service_category_name, product_service_name the result looks this: i missing entry "id 2 - ernährungsberatung". entry missing because "product_service_category_id" "0". please me correct sql-statement record too. thank you! replace join left join join returns matching rows. left join returns rows left table possible matches right table.

java - Prime factorization in a program for class -

import java.util.scanner; public class javaapplication1 { public static void main(string[] args) { scanner kboard = new scanner(system.in); int n = 0; int = 1; system.out.println("enter positive number"); n = kboard.nextint(); system.out.print("the prime factors of " + n + " : "); value = 2; while (n > 1) { = 1; if (n % != 0){ = 1; i=i+1; if(n % == 0){ system.out.println(" "+ i); } } else { system.out.print("1 , " + n); break; } } } } this program , started coding month or ago, program giving 1 , number output rather prime factors. the program gives 1 output because of this: i = 1; if (n % != 0) { // ... } else { system.out.print("1 , " + n); break; } since i = 1 , n % != 0 false, because n module 1 0. else block gets execute...

Python + OpenCV: OCR Image Segmentation -

Image
i trying ocr toy example of receipts. using python 2.7 , opencv 3.1. grayscale + blur + external edge detection + segmentation of each area in receipts (for example "category" see later 1 marked -in case cash-). i find complicated when image "skewed" able transform , "automatically" segment each segment of receipts. example: any suggestion? the code below example until edge detection, when receipt first image. issue not image text. pre-processing of image. any more appreciated! :) import os; os.chdir() # put own directory import cv2 import numpy np image = cv2.imread("rent-receipt.jpg", cv2.imread_grayscale) blurred = cv2.gaussianblur(image, (5, 5), 0) #blurred = cv2.bilateralfilter(gray,9,75,75) # apply canny edge detection edged = cv2.canny(blurred, 0, 20) #find external contour (_,contours, _) = cv2.findcontours(edged, cv2.retr_external, cv2.chain_approx_none) a great tutorial on first step described ava...

android - FirebaseRecyclerAdapter blinks my row when it's updated -

Image
i'm using firebase create chat app. i'm using recycleview , firebaserecycleradapter firebase-ui display messages. problem when message (as can see below) entire layout blinks. happens if change message on firebase console well. in view holder update heart image view according model. i'm using version 0.6.2 still happens on 1.0.0. about adapter, extend firebaserecycleradapter , because i'm using viewtypes i've overridden following methods: getitemviewtype populateviewholder oncreateviewholder class chatmessageoutviewholder extends recyclerview.viewholder { @bindview(r.id.message_out_content) textview messengerview; @bindview(r.id.message_out_heart) imageview heartview; @bindview(r.id.message_out_heart_likes) textview likesview; @bindview(r.id.message_out_time) textview timeview; chatmessageoutviewholder(view v) { super(v); butterknife.bind(this, v); } void apply(final chatmessage mo...

Why isn't my Polymer app working on Firebase? -

this first post here , have say, stack overflow such amazing community devs. have visited many times on years , big thank joining , sharing knowledge! so... love web development , experimenting polymer. i use poylmer cli , have developed basic boilerplate polymer works when run locally on polyserve / polymer cli. when deploy firebase or open native browser (rather launching polyserve or polymer serve) app shows blank. can't see console errors either? could please explain why web app not working? here link firebase deployment: https://vapoursnake-91c13.firebaseapp.com/ it turns out using cli run polymer build did not include directories /src , /bower_components i copied them root folder.

List of List in for loops Java -

i have problem. try develop program ask me numbers few times. give list of numbers. try save them in list>. numbers can split space. have code : import java.util.arraylist; import java.util.list; import java.util.scanner; public class timeseries { public static void main(string[] args) { // todo auto-generated method stub system.out.println("numbers of rows:"); scanner in = new scanner(system.in); int numberlines = in.nextint(); in.nextline(); string ciag; list<list<integer>> ll = new arraylist<list<integer>>(); list<integer> list = new arraylist<integer>(); (int = 0; < numberlines; i++) { list.clear(); system.out.println("add row " +(i+1)); ciag = in.nextline(); (int t=0; t<ciag.length(); t++) { if(character.iswhitespace(ciag.charat(t))) { } else {list.add(character.getnumericvalue(c...

javascript - Code is not displaying JSON data -

hey guys trying make request json page, grabbing data, displaying console giving me "undefined". why that? here code , json page posted under it: (function apod() { var api_key = 'nnkojkoul8n1ch1noufo', url = 'https://api.nasa.gov/planetary/apod' + "?api_key=" + api_key, data; var apodrequest = new xmlhttprequest(); apodrequest.onreadystatechange = function() { if (apodrequest.readystate === 4 && apodrequest.status === 200) { var response = apodrequest.responsetext; var parsedapod = json.parse(response); data += parsedapod; (i = 0; < parsedapod.length; i++) { data += parsedapod[i]; console.log("parsing lines: <br>" + parsedapod[i]); } } apodrequest.open("get", url, true); apodrequest.send(null); } }()); json page parsing: { "date": ...

bash - sudo with -S still asks for password on the console and clears out whiptail box -

i'm doing homework operative systems class have make login flow using bash scripting, i'm having problems want gui started using whiptail when check validity of password entered user on etc/shadow folder, sudo still asks password on console, if pass password using -s argument. here's example of i'm doing realuser=$(whoami) user=$(whiptail --title "change password" --inputbox "please enter password" 10 60 3>&1 1>&2 2>&3) exitstatus=$? if [ $exitstatus = 0 ]; if [ "$user" == "$realuser" ] currentpass=$(whiptail --title "current password" --passwordbox "please enter current password" 10 60 3>&1 1>&2 2>&3) exitstatus=$? if [ $exitstatus = 0 ]; password=$( sudo -s <<< $currentpass grep -w $realuser /etc/shadow | cut -d: -f2) userid=$(echo "$password" | cut -f2 -d$) usersalt=$(echo "$password" | cut -f3 -d$) ...

Getting Wikipedia page view statistics -

i'm trying collect time series data on last 5 years on wikipedia page view statistics particular webpage ("bitcoin"). found site useful: http://stats.grok.se getting data. 2 issues: the website triggers "internal server error" error whenever 2016 selected year obtain data. is there existing tool can put output in more usable form, such .csv? i don't know stats.grok.se doesn't appear live on wikimedia production or labs server. there's api provided page view statistics starting july 2015: https://wikimedia.org/api/rest_v1/#!/pageviews_data/get_metrics_pageviews_per_article_project_access_agent_article_granularity_start_end e.g., daily page views https://en.wikipedia.org/wiki/bitcoin on past year: https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia.org/all-access/all-agents/bitcoin/daily/20151105/20161105 all-access = desktop+mobile-web+mobile-app all-agents = user+spider+bot historical data can...

typescript - How to declare iterable object of another interface type? -

so, here i'm trying make interface type of object contain specific interfaces in it. example: export interface iuser { name: string; last: string; }; export interface iroom { users: object<iuser>; // wrong. } i'm expecting, users like: users: { 'user_id_goes_here': { name: 'john', last: 'doe' }, 'user_id_goes_here': { name: 'albert', last: 'einstein' }, ... } is there way define interface member type this? i think want this: export interface room { users: usermap; } export interface usermap { [userid: string]: user; } export interface user { name: string; last: string; } that [userid: string]: iuser; what's called string index signature . means whenever use string index usermap , iuser .

react native - Set an immutable whose value is empty list to an empty list -

if set immutable value empty list empty list, seems immutable considered changed. can explain why happening? thought both mean null , should not considered changed. this question raised when using react native. when state [] set [] again, associated events triggered. import react, { proptypes } 'react'; import meteor, { createcontainer } 'react-native-meteor'; import chatlistview './chatlistview'; import {connect} 'react-redux'; import { addroomlist, addroom, updatelastmsg } './chatliststate'; const chatlistviewcontainer = (props) => { const { listready, rooms, messages, userid, authtoken, addroomlist, addroom, updatelastmsg } = props; console.log('container', rooms); console.log('container', messages); return ( <chatlistview listready={listready} rooms={rooms} messages={messages} userid={userid} authtoken={authtoken} addroomlist={addroomlist} addro...

javafx - Using a Timeline to display animation when a button is pressed. -

i making small game user can make character walk around screen , make preform attack motion. of images create animation saved in arrays. game loop using animationtimer , working way want far user being able control character , character being abel move around screen. however, problem having animationtimer runs fast when want display character attacking , runs through array of attack images fast able see ending image. tried set when space bar pressed attack start timeline , timeline through array of attack images @ slower rate. want timeline run 15 time(size of attack array), display images in attack array, return game. not sure if using timeline correctly because seems timeline not consistently running same number of times every time called. question how able solve problem of being able display , array of images @ slower rate still able use original game loop? arrays same size attackdown.length size of arrays. method attack() gets called main class every time space bar pressed. con...

swing - Random Image in Java -

how make random image appear when click button? need add view images change when click button class buttonlistener : public class buttonlistener implements actionlistener { private model mod; public buttonlistener(model _m){ mod = _m; } @override public void actionperformed(actionevent e) { int x = mod.random(); if (x == 1) { jlabel l1 = new jlabel(); jlabel l2 = new jlabel(); jlabel l3 = new jlabel(); l1.seticon(new imageicon ("images/green.png")); system.out.println("1"); } else if (x == 2) { jlabel l1 = new jlabel(); l1.seticon(new imageicon("images/purple.png")); system.out.println("2"); } else { jlabel l1 = new jlabel(); l1.seticon(new imageicon("images/red.png")); system.out.println("3"); } } } ...

c++ - Changing an element within a vector of structures -

i'm iterating through set of elements within vector of structures , want change element in 1 of structures. when write element change value, update isn't retained. here have: first, in header file: std::vector<sched::scheduledevent_t> v_schedevents; typedef std::vector<sched::scheduledevent_t>::const_iterator event_iter; then later in .cpp module... for (event_iter = v_schedevents.begin(); != v_schedevents.end(); ++i) { scheduledevent_t event = *i; if(event.member == true) { event.member = false; } } the value of event.member given structure in vector isn't staying false. when returning loop, conditional statement run again. could have typedef iterator? two problems here. 1) you're making copy: scheduledevent_t event = *i; event copy of element in vector. modifing event won't affect it. 2) using const_iterator allows reading value, not changing it. use iterator instead typedef std::vector...

java - Using methods across all activities in android -

i know there questions on global methods , variables in android i'm running problems static methods due less experience objectoriented programming. here want have: i writing app counts points user can earn things does. because of want call method addpoints different activities , services. method should set points textview in main activity , other things. i realized adding static variable static int spoints; in mainactivity, use "global" variable in each activity. however, addpoints method have problems. if use non-static method, have create instance of mainactivity in other activities, not nice , changing values of instance not have effect on actual mainactivity. if use static function works fine long don't want use non-static methods in example: public static void addpoints(context context, int points){ int levelbefore, levelafter; levelbefore = getlevelfrompoints(spoints); spoints = spoints + points; levelafter = getlevelfrompoints...

php - my sandbox paypal error when make a purchase -

Image
please help, i'm getting error when want test purchase.how resolve error? have read few thing , option said have verify email address check in developer account, there no way verify test account.help me.

arduino - Servo not maintaining desire "zero" position controlling it with a PCA9685 driver -

i building arm in each finger controlled servo. using adafruit pca9685 servo driver interface servos. control script running on arduino. trying figure out proper way control each servo move 0 180 degrees close hand , 180 0 open. servos using towar pro mg946r. when have servo under no tension @ tendons or string pull on fingers, move ok 0 180 degrees, when attach strings 1 servo , close , open hand few times servo losses 0 position (it goes passed 0 position or doesn't there , 180 degrees there messing whole system up). important me servo no matter goes 0 position. please ask me many questions want if need me explained myself better. take @ code , recommend see convenient. thanks!! #include <wire.h> #include <adafruit_pwmservodriver.h> #define servomin 130 #define servomax 520 adafruit_pwmservodriver pwm = adafruit_pwmservodriver(); uint8_t thumb = 0; uint8_t ring = 1; void setup() { serial.begin(9600); serial.begin...

javascript - How to throw custom exception in AngularJS? -

i have exception.js script following service: app.service('exception', function() { this.argumentundefinedexception = function (message) { if (!message) { message = "one or more of arguments undefined!"; } return { name: 'argumentundefinedexception', message: message }; } }); now use in service: app.service('joins', ['exception', function(exception) { this.leftjoin = function(leftarray, rightarray, joinonleft, joinonright, columnfromrightarray) { if (!leftarray) { throw new exception.argumentundefinedexception("left array not defined leftjoin!"); } else if (!rightarray) { throw new exception.argumentundefinedexception("right array not defined leftjoin!"); } else if (!joinonleft) { throw new exception.argumentundefinedexception("join on left not defined leftjoin!"); } else { // code left join. } } }]) the...

node.js - API design - splitting into different sub-domains (micro-services) -

our application based on api first architecture , based on single domain / service: api.todos.com consumers of api : our web-frontend our mobile-apps other business / public we building new micro-services written in different languages same application. example might develop api services for: statistics blog / content rss feed search my question around dealing domains. best split each service different subdomain e.g. api.todos.com stats.todos.com content.todos.com rss.todos.com search.todos.com or better have single unified api domain http (layer 7) routing reach our endpoints. e.g. api.todos.com/todos api.todos.com/stats api.todos.com/content api.todos.com/rss api.todos.com/search not sure preferable public api? easier have multiple sub-domains , not have deal intermediate routing layer / proxy. as system architect think it better have single unified api domain http (layer 7) routing reach our endpoints . can make system more flex...

c++ - Can a unique_ptr<>() initialization fail? -

from documentation of std::unique_ptr<>() , may happen when initializing pointer not clear me. when allocating std::shared_ptr<>() , allocates memory buffer handle reference counter. may std::bad_alloc exception. could similar happen when initializing unique pointer? i asking question because if does, may lose attempting have delete through unique pointer. example: void deleter(file * f) { fclose(f); } void func() { ... file * f(fopen("/tmp/random", o_creat | ...)); if(f == nullptr) ...handle error... std::unique_ptr<file, decltype(&deleter)> raii_file(f, deleter); ... } so, if initialization of unique_ptr<>() can throw, may end keeping file f open forever. (i use file * example, similar resource affected.) opposed this answer , cannot use std::make_unique<>() since i'm not allocating memory. would safer initialize std::unique_ptr<>() before fopen() , , save value in there after? ... std::u...

c# - Tab index handling - ASP.NET MVC form controls -

i have web page has basic registration field name, dob, address etc. page has controls (text box, dob etc) shown or hidden based on radio button selection. currently, when end user fills page using tab key hidden controls getting focus , tab out not working expected (current implementation not have tab indexes set). i tried manually setting tab indexes in incremental order controls. moving , forth or after switching between radio button selections, tab out scenario not working properly. is there work around handle scenario? appreciated. you need set display: none instead of opacity: 0 controls removed flow. opacity: 0 means controls still there, invisible, can still receive focus , input, on code snippet below, can still click in invisible control between 2 visible controls. display: none means controls not there anymore can't receive focus , input. you can refer code snippet below see comparison. .opacity .hidden { opacity: 0; } .display .h...

amazon web services - AWS IAM -- Using conditionals -

Image
i new iam in aws. and, desire restrict query various users table entries primary key matches cognito id. achieve this, created policy: { "version": "2012-10-17", "statement": [ { "sid": "allowaccesstoonlyitemsmatchinguserid", "effect": "allow", "action": [ "dynamodb:getitem", "dynamodb:batchgetitem", "dynamodb:query", "dynamodb:putitem", "dynamodb:updateitem", "dynamodb:deleteitem", "dynamodb:batchwriteitem" ], "resource": [ "arn:aws:dynamodb:us-east-1:xxxxxxxxxxx:table/user" ], "condition": { "forallvalues:stringequals": { "dynamodb:leadingkeys": [ "${cognito-identity.amazona...

.net - Regex to get content in the last occurrence of brackets in the most outer level -

i have string: example(123) ( example (123) ) i'm trying string in bold. have regex: (?<=().+?(?=)) the regex works of time text in brackets, not when there's more 1 occurrences nested brackets. please advise how can fix this. thanks! you need recursive regex proper matching. 1 work: \(\w+\s*(?r)*[^()]*\) regex101 test issues: with 1 pattern matching outer parentheses. it not anchored end of string. don't know how can achieve it. need grab last match.

WPF application database connect with remote database -

i creating wpf application , there 2 databases, 1 on client computer , other 1 on remote server. , client asks me sync these 2 databases. asked me when wpf application connects internet, should sync local data remote server, , if not connected internet, should save data locally. tell me there way connect local , remote server, can wpf access 2 different databases on 2 different computers via internet this boils down using 2 different connection strings need them (either via ado or ef or you're accessing data). void dostuff() { using (sqlconnection conn = new sqlconnection("your first connection string here")) using (sqlcommand cmd = new sqlcommand) { cmd.connection = conn; // stuff command } using (sqlconnection conn = new sqlconnection("your second connection string here")) using (sqlcommand cmd = new sqlcommand) { cmd.connection = conn; // stuff command } ...

python - Sklearn: improve algorithm and improve quality -

for customers have sex unknown (that not in training set customers_gender_train.csv , in transactions.csv ) need predict probability male(value 1), using file transactions. part of train looks like customer_id,gender 75562265 10928546,1 69348468,1 84816985,1 61009479 74045822 27979606,1 54129921 23160845 44160317,1 45646491 36008593 48111232,1 37245184 82609845 60046355,1 the part of transactions looks like customer_id,tr_datetime,mcc_code,tr_type,amount,term_id 39026145,0 10:23:26,4814,1030,-2245.92, 39026145,1 10:19:29,6011,7010,56147.89, 39026145,1 10:20:56,4829,2330,-56147.89, 39026145,1 10:39:54,5499,1010,-1392.47, 39026145,2 15:33:42,5499,1010,-920.83, 39026145,2 15:53:49,5541,1010,-14643.37, 39026145,3 15:29:08,5499,1010,-1010.66, 39026145,4 12:11:57,5200,1010,-2829.85, 39026145,5 15:19:19,5499,1010,-628.86, 39026145,6 07:08:31,4814,1030,-5614.79, 39026145,7 14:23:17,5541,1010,-14643.37, 39026145,7 14:40:02,5499,1010,-3458.71, 39026145,8 06:49:35,5732,1010,-21897.68, ...

objective c - iOS moving cursor from keyboard extension -

we can update cursor position of uitextfield this. [textfield setselectedrange:beginningrange]; is possible update cursor position keyboard extension? checking textdocumentproxy , inputview though. simply set length of selection zero. one possible implementation: + (void)setcursorintextfield:(uitextfield *)textfield atindex:(nsinteger)index { uitextposition *start = [textfield positionfromposition:[textfield beginningofdocument] offset:index]; uitextposition *end = [textfield positionfromposition:start offset:0]; [textfield setselectedtextrange:[textfield textrangefromposition:start toposition:end]]; }

vb.net - Correct way to get an interface / object from an interface pointer? -

having known nothing interfaces until now, having remarkably hard time trying implement solution given this question . i think correctly getting pointer ishellfolder interface, don't seem able use pointer. how usable interface when having pointer? the code below shows doing , suspect problems. first, interface delarations : ' have wrapped interfaces in own namespace, "binarusshell". ' have declared every interface's functions / subs in same order in .idl files of windows platform sdk 7.1. ' every function / sub has <preservesig()> attribute can see native return values when debugging. ' i'd keep question lean possible, showing few functions per interface. ' of course, have implemented of them (as in respective .idl file). namespace binarusshell <comimport()> _ <interfacetype(cominterfacetype.interfaceisiunknown)> _ <guid("000214fa-0000-0000-c000-000000000046")> _ public interface iextracti...