Posts

Showing posts from April, 2010

javascript - Required field only if condition is met -

Image
i have form with, among other fields, picture user upload , hidden field hold id. need picture required if id empty, otherwise user editing, there picture in there. can done html only? maybe done javascript, how show default popup (shown below) appears when set required ? i've checked this , this questions, don't provide expected result. popup: any ideas? to set 'popup', need call htmlselectelement.setcustomvalidity() on element. var foo = document.getelementbyid("foo"); // check condition foo.setcustomvalidity("a custom message popup"); the code found here helped me figure out.

javascript - N/currentRecord module does not exist when uploading User Event script to NetSuite (SuiteScript 2.0) -

i trying upload below script netsuite in order currency conversion purchase order currency usd. i custom field updated usd amount whenever user keys in items purchase order. when upload script, receive following error message: fail evaluate script: {"type":"error.suitescriptmoduleloadererror","name":"module_does_not_exist","message":"module not exist: n/currentrecord.js","stack":[]}** would appreciate guidance. thank you. /** *@napiversion 2.x *@nmodulescope public *@nscripttype usereventscript */ define(['n/currency', 'n/currentrecord'],function(currency, currentrecord) { function pocurrencyconversion() { var fixed_currency = 'usd'; var transaction_currency = currentrecord.getvalue('currency'); var tx_currency_total = currentrecord.getvalue('total'); var rate = currency.exchangerate({ ...

Python email checker script shows only unread messages, but not ones received since the program was opened -

i'm writing program, , part of check new emails every 10 seconds. fine , shows me unread messages when start program, on next loop doesn't show newly sent messages since program opened. there particular reason, or doing wrong? in advanced! edit: yes, i've sent messages account in question after program has started, , let sit few minutes, , still nothing while(1): time.sleep(10) print("\n\nrefreshing....") rv, data = m.search(none, 'unseen') #check new messages, works fine first run print(rv) print(data) if rv != 'ok': print("no messages found!") return num in data[0].split(): print("num: " + str(num)) rv, data = m.fetch(num, '(rfc822)') if rv != 'ok': print("error getting message", num) return msg = email.message_from_bytes(data[0][1...

VBA Excel - Solver in the loop returns error on the reference to changing cells and conditions -

i trying loop solver command vba excel, , getting error message regarding variables , conditions in model. idea of model find range of debt , equity financing cash balance zero, , debt , equity components meet covenants (that work bounds in solver run). here code: sub debt_capital_balancing() application.screenupdating = false dim early_repmnt string, cashbeforesolver variant, ced variant, _ dr variant, cc variant, tw single, nde single, de single, w single k = range("forecast_periods").count range("debt_received, debt_early_repayment, re_distribution, _ cc_apic_change").clearcontents = 1 k cashbeforesolver = abs(range("cash_excess_deficit").cells(1, i).value) ced = range("cash_excess_deficit").cells(1, i).value dr = range("debt_received").cells(1, i).value cc = range("cc_apic_change").cells(1, i).value tw = range("target_wacc").cells(1, i).value nde = range("net_...

How to display data from a SQL Server database on an ASP.NET web page? -

so, here's sql query: select [gender], count(*) [usersdb].[dbo].[vwuser] gender='m' group gender in smss, returns m 5298 i want print out value (5298) in div or header on webpage. so, in index.cshtml tried @using webmatrix.data; @{ var db = database.open("usersdbconnectionstring"); var selectquerystring = "select [gender], count(*) [usersdb].[dbo].[vwuser] gender='m' group gender"; } i ripped off example on w3c schools , worked printing out table not this. this didn't work either: @webmatrix.data @{ var db = database.open("usersdbconnectionstring"); var selecteddata = db.query("select [gender], count(*) [usersdb].[dbo].[vwuser] gender='m' group gender"); var grid = new webgrid(source: selecteddata); } <div> @grid.gethtml() </div> any ideas on how work? ...

node.js - Node Express App debugging with calls from separate client app using WebStorm -

Image
i've looked around , had lot of trouble figuring out. i'm hoping might able point me post or have information on how this. my problem have 2 projects i've made using webstorm: i have 1 application server-side code running on port 3000. it's simple node express app. the second application angular 4 / ionic 3 application running client side on port 8100. i want run server application in debug mode, hits breakpoints data being sent client side app. for example: angular / ionic app sends request clients given customer. customer sent via url parameter. want server code pause when receives request , can see url parameter. simple. the server using grunt build project, , nodemon watch it. i'm using npm scripts make life easy. here scripts: "scripts": { "dev": "set node_env=development && nodemon ./bin/www", "grunt": "grunt", "start": "node ./bin/www" }, nothing fancy. ...

algorithm - Traversing exactly n edges, from source node to destination node, find longest path -

suppose have weighted graph, directed , cyclic . every node has edge directed toward every other node. there no edges connect node itself. now have source node, , destination node. have start @ source node , traverse n edges , end @ destination node. n arbitrary positive integer (possibly greater number of nodes in graph). when traverse edge, add our sum (edge weights positive ). path take reach our destination node can have cycles. how can maximise our sum ? if not allowed cycles problem np-complete - see https://en.wikipedia.org/wiki/longest_path_problem assuming allowed paths can include cycles e.g. a,b,c,b,c for = 1..n compute, each node, length of longest path of length terminates @ node. save length , identity of node before n. case i=0 path of length 0 previous node null every node. work out case i+1 case considering, each node, every edge terminating in node. at end chose node step n longest path terminating @ , use records of previous nodes trac...

php - Is it possible to create a video chat site without JavaScript? -

i want create video chat site hidden services. in order preserve anonymity, has javascript-free , plugin-free. languages can think of python , php, , want implement in html5 video. you can video chat using webrtc , html5 video without javascript.

Get response of action as a promise (like redux-thunk) -

i moving redux-thunk redux-saga finding 1 deficiency. with redux-thunk had typical way of doing "add requests": try { downloadid = await dispatch(requestdownload('some_url')); } catch(ex) { console.log('download existed, request denied'); } that action return promise, wait on. request function ( requestdownload above) either grant request, , resolve downloadid or reject, if download some_url existed. how can in redux-saga? seems actions cannot return anything. thanks in redux-saga not using await yield in combination effects instead. your code this: // saga.js import { call, put } 'redux-saga/effects' import { requestdownloadsucceeded, requestdownloadfailed } './reducer.js' function* downloadrequestedflow() { try { const downloadid = yield call(requestdownload, 'some_url') yield put(requestdownloadsucceeded(downloadid)) } catch(error) { yield put(requestdownloadfailed(error))...

Reduce div height from top using jQuery or javascript -

what trying when event called div #target 's height reduced/increased top or top content hidden/visible specific size. can't think of way that. the following code reduces/adds height bottom want reduce top. $(function() { $("button:first").on("click", function() { $("#target").css("height", "+=50px"); }); $("button:last").on("click", function() { $("#target").css("height", "-=50px"); }); }); #target { background: purple; color: white; height: 300px; width: 200px; } div { float: left; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <button>plus</button> <button>minus</button> </div> <div id="target"> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor i...

jsp - How to insert Image in PDF using iText and download to client machine? -

i'm using jdbc fetch data database , using itext create pdf file can downloaded on client machine. application coded in html/jsp , runs on apache tomcat. i use response.getoutputstream create output pdf file immediately. the problem now, cannot insert image in document gives me , error getoutputstream() has been called response i understand i'm calling outputstream again while inserting image , therefore error how can insert image in document , still generate dynamic pdf file can downloaded client machine? the relevant code: response.setcontenttype("application/pdf"); response.setheader("content-disposition","attachment; filename=\"licenseinfo.pdf\""); // code 1 document document = new document(); pdfwriter.getinstance(document, response.getoutputstream()); // code 2 image image = image.getinstance("logo.jpg"); document.open(); document.add(image); i'm sorry, aren't showing relevant ...

python - View on numpy array -

i have matrix m = np.zeros((5,5)) and have view on last row row = m[-1] however if add column m: m = np.c_[m[:,:2],[0,0,1,1,1],m[:,2:]] and print out row don't new column. is there way change without use line row = m[-1] again? what want achieve here isn't possible within bounds of numpy library. see answer on numpy arrays occupying contiguous block of memory . you can use rx library around making subject of last row. import numpy np rx import observable, observer rx.subjects import subject m = np.zeros((5,5)) m_stream = subject() last_row_stream = subject() last_row = none def update_last(v): global last_row last_row = v last_row_stream.subscribe(on_next=update_last) last_row_stream.on_next(m[-1]) print(last_row) m_stream.map( lambda v: np.insert(v, 2, [0, 0, 1, 1, 1], axis=1) ).subscribe(lambda v: last_row_stream.on_next(v[-1])) m_stream.on_next(m) print(last_row)

python 3.x - Writing cp1252/uft-8/latin-1 ??? from python3 -

i have data special accent characters i'm reading in fine, , processing fine. if print them, , can , copy/paste results console output -- i'd rather write results file read later. example: data = ''' <imdb> lego movie (2014) - pg <imdb> [lemony snicket's] series of unfortunate events (2004) - pg <imdb> les misérables (1998) - pg-13 <imdb> les misérables (2012) - pg-13 <imdb> les misérables in concert (1995) - nr <imdb> license wed (2007) - pg-13 <imdb> life know (2010) - pg-13 <imdb> life of pi (2012) - pg ''' tgt = open('output.txt','w',encoding='utf-8') x in data.split('\n'): res = lookupimdbindex(x) print(res) tgt.write(res) tgt.write('\n') the console output looks like: <tt1490017> lego movie (2014) - pg <tt0339291> [lemony snicket's] series of unfortunate events (2004) - pg <tt0119683> les misérables (1998) - pg...

python - Multiple inheritance with different argument size -

i know if possible... currently, have single inheritance... , it's working fine... in ciscoplatform class, not have init method it's expecting 6 arguments when create object (as i'm using baseplatform init method)... i create object , works fine: ntw_device = [] device = ciscoplatform(list[0],list[1],list[2],list[3],list[4],list[5]) ntw_device.append(device) class baseplatform(object): def __init__(self,ip,hostname,username,password,vendor,type): self.ip = ip self.hostname = hostname self.username = username self.password = password self.vendor = vendor self.type = type class cisco(baseplatform,interface): pass i introduce new base class called interface class interface(object): def __init__(self,host,interface,vlan): self.host = host self.interface = interface self.vlan = vlan how able inherit both parent classes different number of arguments? this? *assuming...

asp.net - Doesn't show Bangla in aspx page but html page shows -

Image
i have invoice type page have bengali words. if page format *.aspx shows result but same code. if page format *.aspx shows result this, want. it's bengali.

java - mysql contains search in Lucene -

i trying implement contains search in lucene. example, consider 2 documents apple mango (say 1st document) apple orange mango (say 2nd document) if search " *ple man* ", want 1st document alone , not second document. achieved indexing field values not_analysed. public class test { public static void main(string[] args) throws exception { analyzer analyzer = new classicanalyzer(version.lucene_30, new stringreader("")); directory dir = new niofsdirectory(new file("/home/test")); indexwriterconfig config = new indexwriterconfig(version.latest, analyzer); indexwriter indexwriter = new indexwriter(dir, config); string names[]=new string[]{"apple mango", "apple orange mango"}; document doc; for(int i=0;i<names.length;i++){ doc = new document(); doc.add(new field("name",names[i], field.store.yes, field.index.not_analyzed)); ...

can i make several scripts work on a request in Fiddler? -

Image
suppose there url, " http://test.com/cgi-bin/static/index.html ",i want both scripts work.is possible pass through request on several fiddler scripts? as noted in fiddler book : *script-specified functions names contain word filter cause rule treated non-final, allowing subsequent rules apply. so if wanted savelogin function not prevent host81 rule being evaluated, rename savelogin savelogin_filter .

How do I iterate through elements in Selenium and Python? -

i trying texts inside span tags iterating through li list of html: <ol class="kambibc-event-result__score-list"> <li class="kambibc-event-result__match"> <span class="kambibc-event-result__points">1</span> <span class="kambibc-event-result__points">1</span> </li> </ol> but getting error attributeerror: 'list' object has no attribute 'find_element_by_class_name' on code: meci = driver.find_elements_by_class_name('kambibc-event-result__match') items in meci: scor = meci.find_element_by_class_name('kambibc-event-result__points') print (scor.text) you not using items inside loop. loop should be meci = driver.find_elements_by_class_name('kambibc-event-result__match') items in meci: scor = items.find_element_by_class_name('kambibc-event-result__points') print (scor.text) meci.find_elem...

android - The same background music playing in all activities -

i use services play background music in activities , works. problem music continues playing if app in background (when user exit home button or button). how can solve this? services class backgroundsoundservice public class backgroundsoundservice extends service { private static final string tag = null; mediaplayer player; public ibinder onbind(intent arg0) { return null; } @override public void oncreate() { super.oncreate(); player = mediaplayer.create(this, r.raw.slow_shock); player.setlooping(true); // set looping player.setvolume(100,100); } public int onstartcommand(intent intent, int flags, int startid) { player.start(); return start_not_sticky; } public void onstart(intent intent, int startid) { // } public ibinder onunbind(intent arg0) { // auto-generated method return null; } public void onstop() { } public void onpause() ...

c - OpenCL buffers and data calculation -

if want format code opencl should consider when doing so? buffers should using? , if want know how data kernel use doing this, how able calculate it? int a[100000] int b[100000] for(int i=1; i<100000 -1); i++) { b[i] = a[i-1] + a[i+1] - 2*a[i] } all appreciated you need 2 buffers , b. example: cl_int error = cl_success; cl_mem a_buffer = clcreatebuffer(context, cl_mem_read_only | cl_mem_copy_host_ptr, sizeof(int)*100000, a, &error); cl_mem b_buffer = clcreatebuffer(context, cl_mem_read_write | cl_mem_copy_host_ptr, sizeof(int)*100000, b, &error); if want each kernel work 1 element of b, global work size equal 99999. your kernel might somehow (in case 1 thread works 1 value, might not need such parallelism, it's example): kernel void your_kernel(global int* a, global int* b) { int = get_global_id(0); b[i] = a[i-1] + a[i+1] - 2*a[i]; }

python - error trying to use GridSearhCV with XGBClassifier -

i trying use gridsearchcv xgboost in order train , fit using best prams quite large dataset (> 500mb). i'm getting error unable resolve. have laptop 32gb ram , python memory consumption did not exceed 10gb once left running don't think memory-related issue although not sure. i not know if can through these kinds of errors using different model or else. maybe problem grid search not sure how on without using it. here code: parameters = {'learning_rate': [0.03,0.04,0.05,0.06,0.07], 'max_depth': [3,5,7,9,11], 'min_child_weight': [2,4,6,8,10], 'subsample': [0.9,0.8,0.7,0.6,0.5], 'colsample_bytree': [0.9,0.8,0.7,0.6,0.5]} xgb_model = xgbclassifier(objective = 'multi:softprob', nthread = 4, n_estimators= 1000, seed = 1337, silent = 0) clf = gridsearchcv(estimator=xgb_model,param_grid=parameters,n_jobs=-1,verbose = 5) clf.fit(orders_prior1[['user_id','orde...

excel - Vlookup/transpose with range -

i trying vlookup transpose ranges. these stock coverage report of mobile spare parts. whatever have covered stock buffer updated status against corresponding ranges ascending order. (how many mobile stock covered-like 1,2,10,20) anyone appreciated. data description modle status apricot 11 done avocado 10 done banana 8 done bilberry 7 done blackberry 16 done blackcurrant 20 done blueberry 2 done desired result area 7320 5520 5510 3320 1102 1100 950 940 930 920 919 918 917 916 915 914 913 912 911 910 blueberry done done blackcurrant done done done done done done done done done done done done done done done done done done done done blackberry done done done done done done done done done done done done done done done done bilberry done done done done done done done banana done done done done done done done done avocado done done done done done done done done done done apricot ...

How to get purchase values from Dynamic ads in python via Facebook MAPI? -

i'm trying complete purchase value of ads running @ date account. however, dynamic ads conversions (purchase) don't seem included. limit = 1000 fields = [ 'campaign_name', 'adset_name', 'date_start', 'date_stop', 'campaign_id', 'unique_clicks', 'unique_ctr', 'unique_link_clicks_ctr', 'spend', 'reach', 'total_actions', 'actions', 'cost_per_unique_click', 'objective', 'relevance_score', 'actions', 'action_values' ] params = { 'time_range': { 'since': report_date, 'until': report_date }, 'action_attribution_windows': ['28d_click'], 'level': 'ad', 'limit': limit if l...

Does CMake has a "find-or-download-and-run-build-command" mechanism? -

cmake has find_package() backed bunch of findxyz scripts (which can add to). what mechanism, if any, available me tell cmake: "find package, , if haven't found it, download , trigger build" - downloading , building part backed per-package scripts or settings (so downloading wget or git clone , building cmake or maven or package-specific command, etc.) ? yeah, bitten friday. so, cmake has externalproject directive, meant that, get/update if necessary, configure, build , install , external project. awesome! sadly, cmake isn't awesome. you can't use target defined externalproject library in target_link_libraries . i've tried to. the basic problem updating, building , installation of external project happens @ build time , whereas cmake insists on using libraries found during pre-build (i.e. during cmake run); can't re-detect stuff while running make/ninja/msvc… . you can define custom target, tell .so you'd want link agains...

python 2.7 - Open link using Selenium on new page -

i clicking link "images" on new page (after searching 'bugs bunny') on google. not retrieving images of search, rather opening link 'images' on old page. my code: import time selenium import webdriver selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec selenium.webdriver.common.keys import keys browser = webdriver.firefox() browser.get('http://www.google.com') search = browser.find_element_by_name('q') search.send_keys("bugs bunny") search.send_keys(keys.return) # hit return after enter search text browser.current_window_handle print(browser.current_url) browser.find_element_by_link_text("images").click() your problem using send_keys, perform action , don't wait search.send_keys(keys.return) # hit return after enter search text so after if use click doing on current page when results not loaded. need add de...

Color Python output given #RRGGBB hex value -

i've got color user in #rrggbb hex format ( #d3d3d3 light grey) , i'd color output it. imagine write print("some text", color="#0000ff") , blue colored output. possible (ideally without 3rd party software)? you can use following escape sequences on true-color aware terminal : esc[ … 38;2;<r>;<g>;<b> … m select rgb foreground color esc[ … 48;2;<r>;<g>;<b> … m select rgb background color thus can write function: reset = '\033[0m' def get_color_escape(r, g, b, background=false): return '\033[{};2;{};{};{}m'.format(48 if background else 38, r, g, b) and use like: print(get_color_escape(255, 128, 0) + get_color_escape(80, 30, 60, true) + 'fancy colors!' + reset) you can doubled horizontal or vertical resolution using example ▀ , both background , foreground colour.

H2O running slower than data.table R -

how possible storing data h2o matrix slower in data.table? #packages used "h2o" , "data.table" library(h2o) library(data.table) #create matrix matrix1<-data.table(matrix(rnorm(1000*1000),ncol=1000,nrow=1000)) matrix2<-h2o.createframe(1000,1000) h2o.init(nthreads=-1) #data.table variable store for(i in 1:1000){ matrix1[i,1]<-3 } #h2o matrix frame store for(i in 1:1000){ matrix2[i,1]<-3 } thanks! h2o client/server architecture. (see http://docs.h2o.ai/h2o/latest-stable/h2o-docs/architecture.html ) so you've shown inefficient way specify h2o frame in h2o memory. every write going turning network call. don't want this. for example, since data isn't large, reasonable thing initial assignment local data frame (or datatable) , use push method of as.h2o(). h2o_frame = as.h2o(matrix1) head(h2o_frame) this pushes r data frame r client h2o frame in h2o server memory. (and can as.data.table() opposite.) data.table tip...

C++ array causes crash if member of class -

i'm working particular library not built stl containers. in refactoring functions classes encountered stack overflow based on following pattern. class base { float values[1920 * 1080]; // causes overflow public: base() {} }; int main() { float values[1920 * 1080]; // not base t; } i know may allocate dynamic memory base::values , why not cause stack overflow in main , in base , why stack space seem smaller base ? perhaps it's obvious i'm missing. (above example compiled using visual studio 2017, default flags) 1920 * 1080 * sizeof(float) sufficent blow stack. (8 mb) ensure compiler not remove values array setting elements. change base follows. class base { float * values; base() { values = new float[1920*1080]; } ~base(){ delete [] values; } } also fix copy , assignment operators.

Loading relational data in GraphQL & MongoDB -

Image
this schema: type user { _id: id! username: string email: string! firstname: string lastname: string avatar: string createdat: date! updatedat: date! } type tweet { _id: id! text: string! user: user! favoritecount: int! createdat: date! updatedat: date! } and here's tweet model: import mongoose, { schema } 'mongoose'; const tweetschema = new schema({ text: { type: string, minlength: [5, 'your tweet short.'], maxlength: [144, 'your tweet long.'] }, user: { type: schema.types.objectid, ref: 'user' }, favoritecount: { type: number, default: 0 } }, { timestamps: true }); export default mongoose.model('tweet', tweetschema); the above graphql schema served express this: import { graphqlexpress } 'apollo-server-express'; import { makeexecutableschema } 'graphql-tools'; import typed...

arduino - Subscribe in the Nodemcu -

i able publish topic in nodemcu , mqtt dashboard (app android), see: #include <pubsubclient.h> const char* mqtt_broker = "iot.eclipse.org"; const char* mqtt_clientid = "tccguilf"; pubsubclient client(nodemcuclient); const char* topicotemperatura = "tccguilf/temperatura"; const char* topicoumidade = "tccguilf/umidade"; ... client.publish(topicotemperatura, string(temperatura).c_str(), true); ... now, subscribe topic in nodemcu, published mqttdashboard. perhaps: teste = client.subscribe(topicoteste); so not work, i've tried callback functions found on web, no success far.

angular - CORS error on only one .Net Core 2.0 Web API controller -

i have several .net core 2.0 wep api controllers work fine, 1 gives client invalid cross origin error though cors initialized globally. i've looked @ controller on , on , see no difference between , others work fine. client angular4 app , information provides request isn't allowed because of cors violation. i kept thinking bug in client code or bug in .net core 2.0 because it's new. reason never tried typing actual url browser on web api server, had done on have seen there exception. come find out, 1 of poco data model classes had field spelled wrong. advice don't depend on client application when troubleshooting errors web api.

algorithm - Smoothing Digitised Convex 2D polygon within Boundary polygons -

i looking smoothing algorithm 2d convex polygons. the polygons generated digitiser tracing template. template hand cut , has anomalies, need smoothed out. the polygon has constraint, described follows. 2 concentric polygons generated around initial polygon. outer polygon xmm larger initial polygon, , inner polygon xmm smaller. calculation assumes line drawn polygon cg (centre of gravity) through each point, either adding xmm or deducting xmm. this generates corridor, , smoothing has stay inside corridor. corridor represents polygon accuracy. assumed smoothing process can , reduce total number of points. lines , arcs can substituted. i have seen algorithm number of years ago, , efforts find have been unsuccessful. hopefully, on forum can point me in rigfht direction.

osx - Mac application update from dmg -

currently developing macosx app. can launch @ startup. has launchitem installed. however, when need update app, drag app ./applications dmg dialog window replace current app updated one. click updated one, reboot mac. mac still show previous app. seems don't replace or overwrite old app. does know how clean previous launch item , files when users drag new app dmg ./applications ? thanks the root cause there 1 deprecated app archive folder in user/developer/xcode/archive/, first triggered launchitem. update app in applications not called.

multithreading - Python socket multiple connections -

i'm trying python application connected java program , raspebrry pi. program should listen java , raspberry , able response. don't know how that. i'm using couple of threads , can send message raspberry , listen java in same time can't listen 2 connections , it's necessary me. def startprogram(sock): try: sock.setblocking(false) sock.settimeout(10) sock.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) sock.connect((java_host, java_port)) data = sock.recv(1024) if (data == "abc\r\n"): sock.sendall("abc otrzymane!!!\n") global robot_ip_address robot_ip_address = sys.argv[0] + "." + sys.argv[1] + "." + sys.argv[2] + "." + sys.argv[3] threading.thread(target=steering, args=[order]).start() threading.thread(target=getdistance, args=[sock]).start() except: sock.close() finally: return sock //program starts here! sock = socket.socket(...

python - Getting the wrong answer when dividing two integers, one large and one small -

i attempting use prime sieve find prime factors of numbers. in code, end having divide large number small number find prime factor out of range of sieve i'm using. shouldn't problem, in fact, method works every number checked except one. the problem have run divide large number 51 find prime factor , when multiply 51 check if equals original number... doesn't!! it not work regardless of if convert int or if leave float in scientific notation. i understand floats not perfect, don't know how around weird error. plugged numbers calculator , got correct answer, code gives me wrong answer. what going on here? if run code see checks return false when should true both. as said before, method works 1 of numbers testing has factor outside range of sieve using, specific large number having issues with. the correct answer should 1,176,462,117,668,023,508,828,242,241 , answer im getting 1,176,462,117,668,023,481,334,235,136 l_number = 59999568001069198950240354291...

ios - Objective-c: Making NSArray all lowercased -

Image
i having strange problem when tryin catch data on plist.. so, here plist so okay, getting data fine, used code know data nsstring *path = [[nsbundle mainbundle] pathforresource:@"kurdiebg" oftype:@"plist"]; nsarray *plistdata = [nsarray arraywithcontentsoffile:path]; nspredicate *filter = [nspredicate predicatewithformat:@"english = %@", self.searchqwery.text]; nsarray *filtered = [plistdata filteredarrayusingpredicate:filter]; nslog(@"found matches: %@ : %@", filtered,[filtered valueforkey:@"kurdi"]); if (filtered.count>0) { nsdictionary *dic = filtered[0]; self.ss.text = dic[@"kurdi"]; } but here strange part-- when try search abbey (lowercased)it returns right result, problem has twenty 2 thousand records they're not lowercased, okay, when make first a capital, returns nothing thanks visiting you can case insensitive search adding [c] . try this. nspredicate *filter = [nspred...

openid connect - How to call Azure AD Graph API in case of web application that uses WS-Federation to sign-in users from a single Azure Active Directory tenant -

based on code sample mentioned @ url: https://github.com/azure-samples/active-directory-dotnet-webapp-wsfederation , implemented application uses ws-federation (asp.net ws-federation owin middleware) authenticate users azure ad tenant. looking approach query graph api later in application fetch additional claims information required application point of view. here in scenario, know whether possible query graph api or not. need update existing ws-federation protocol openid connect. can me provide guidance here. the ideal move openid connect, allow take care of both sign in , api in single setup , flow. if want stick current ws-fed setup, can layer oauth2 on top of implementation , retrieve access token need time after sign in. have sample showing that, see https://azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-webapp-webapi-oauth2-useridentity/

operating system - Does greater decimal value mean higher priority or low priority for a process? -

for example p1 has priority 2 , p2 has priority 5. process has higher priority? process executed first? this depends on underlying operating system. see here windows or there linux or this mac os ... and on. in other words: answer research operating system intend work with.

How to plot bar chart in Python using matplotlib.pyplot ? Argument height must be 'xxxx' or scalar -

i have data frame named 'train' has number of variables. 1 such variable 'industry'. first 10 elements of column 'industry' follows: train['industry'][:10] 0 office supplies 1 unknown 2 misc services 3 social services 4 unknown 5 manufacturing 6 social services 7 office supplies 8 entertainment 9 construction name: industry, dtype: object i trying plot bar chart using matplotlib.pyplot plt library industry type on x-axis , frequency on y-axis. not sure should value of 'height' argument? plt.bar(train['industry'], height = ) height frequency. here's example make array of length len(train.index) make bar chart without industry names - plt.bar(array, frequency) . frequency/height cannot string. needs numerical. if isn't, convert using pd.to_numeric put industry names array use set_xticklabels(industries) change la...

c# - UrlEncode in dotnet-core with TextEncoding -

i have text retrieved web , saved file encoding 1252. text has url's in emoji's. unless result method1 below, can not able retrieve pages. since don't have system.web in dotnet-core , no support system.net.webutility textencoding , wonder, if there easy way handle issue? var text = $"hello-world 🖤ðŸ’--œðŸ’œðŸ–"; encoding sourceencoding = encoding.getencoding(1252); // method 1 // hello-world+%f0%9f%96%a4%f0%9f%92--%9c%f0%9f%92%9c%f0%9f%96 // <----- result, system.web.httputility.urlencode(text, sourceencoding).dump(); // method 2 // hello-world+%c3%b0%c5%b8%e2%80%93%c2%a4%c3%b0%c5%b8%e2%80%99--%c5%93%c3%b0%c5%b8%e2%80%99%c5%93%c3%b0%c5%b8%e2%80%93 system.web.httputility.urlencode(text).dump(); // method 3 // hello-world+%c3%b0%c5%b8%e2%80%93%c2%a4%c3%b0%c5%b8%e2%80%99--%c5%93%c3%b0%c5%b8%e2%80%99%c5%93%c3%b0%c5%b8%e2%80%93 system.net.webutility.urlencode(text).dump(); // method 4 // hello-world%20%c3%b0%c5%b8%e2%80%93%c2%a4%c3%b0%c5%b8%e2%...

asp.net - .Net Core 2 Spa Template with Angular Material -

struggling trying angular material , or 3rd party control set really, work new template. in new template, webpack broken treeshakable , nontreeshakable. in addition app.module app.module.shared, app.module.browser, app.module.server. as have attempted work, app run modules configured in app.module.browser, material tags not getting processed. trying simple , trying button. don't errors not work. went example in plunker, copied generated, , displays right telling me got css in right, @ least. including webpack vendor configuration starting point, seems key because how bundles css , js. tia webpack.vendor const path = require('path'); const webpack = require('webpack'); const extracttextplugin = require('extract-text-webpack-plugin'); const merge = require('webpack-merge'); const treeshakablemodules = [ '@angular/animations', '@angular/common', '@angular/compiler', '@angular/core', ...

Passing Object from One Controller to Another AngularJS -

i need pass object 1 controller , have used this solution not working. here code: angular.module("customerapp", []) .controller('mainctrl', function ($scope, myservice, $http, $location) { var vm = this; vm.pinformcheck = function () { vm.count++; if (vm.pinform.$valid && vm.details.pin === vm.pin && vm.count <= 2) { location.href = "http://localhost:51701/home/mainmenu"; $scope.obj = { 'cid': 'vm.details.cid', 'name': 'vm.details.name', 'pin': 'vm.details.pin', 'bal': 'vm.details.bal', 'status': 'vm.details.cardstatus' }; console.log(vm.details.bal);//the correct balance displayed in console } else { vm.failpin = true; } }; }) .controller('checkctrl', function ...

javascript - How do you sum two values containing the dollar sign "$"? I have been trying to figure out the methods and properties, still no clue -

//for example allinputs[22].value //equals $45 , allinputs[4].value // equals $70 allinputs[22].value + allinputs[4].value = "$45$70" it equals "$45$70". want sum value. how sum both values final value ignoring dollar sign? you can use "$" + (parseint(allinputs[22].value.substring(1)) + parseint(allinputs[22].value.substring(1))) the substring method, rid of $ sign, , parseint convert number. need that, because if not use concatenate values strings. note put set of brackets sum numbers. because, when interpreter sees "$" thinks should concatenate strings. want sum numbers , concatenate sum "$" string.

amazon ec2 - how to add a godaddy ssl certificate to a site hosted on aws ec2 -

how add godaddy ssl certificate site hosted on aws ec2 (linux - apache) domain purchased on bigrock , and a-record pointing bigrock console elastic ip of ec2-instance you can include pem encoded ssl certificate(if certificate in different encoding, can convert pem encoded format) godaddy aws load balancer. if don't use load balancer, can install ssl certificate apache server(you can download certificate apache format godaddy) running in ec2 instance.

excel - program a button to stop infinite loop -

i want display excel sheets in workbook 1 continuously use infinite loop. questions when need update data in sheets must stop infinite loop, how can using vba code? example want press button in workbook 2 stop infinite loop in workbook 1 (btw cant put button in workbook 1 because sheets changed continuously or have better idea how display sheets continuously? here code : **so sheet macrokeys contains word in cell a1 =yes trigger display each sheet 2 seconds (sheet1,sheet2,sheet3 sheet 1 again & repeat process infinitely sub show_sheet1() dim macrokeys worksheet: set macrokeys = sheets("macrokeys") dim sh1 worksheet: set sh1 = sheets("sheet1") dim sh2 worksheet: set sh2 = sheets("sheet2") dim sh3 worksheet: set sh3 = sheets("sheet3") macrokeys.range("a1") = "yes" ' [...] sh1.visible = true sh1.select sh2.visible = false sh3.visible = false ' [...] if macrokeys.range("a1") = "yes" a...

dart - Error Application Layout Component of angular components in AngularDart -

trying implement new released application layout component of angular components in project. after importing import'package:angular_components/angular_components.dart'; dart throws error materialiconcomponent, materialpersistentdrawerdirective, materialtemporarydrawercomponent, [info dart2js]: compiling my_app|web/main.dart... [error dart2js on my_app|web/main.dart]: web\main.template.dart:16:1: can't read 'package:my_app/views/app_component/app_component.template.dart' (could not find asset my_app|lib/views/app_component/app_component.template.dart.). import 'package:my_app/views/app_component/app_component.template.dart' i1; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [error dart2js on my_app|web/main.dart]: web\packages\my_app\views\app_component\app_component.dart:25:5: not compile-time constant. materialiconcomponent, ^^^^^^^^^^^^^^^^^^^^^ [dart2js on my_app|web/main.dart]: 3 warning(s) suppre...

c++ - When we call function and pass the character array, Why we call it by using character array name? -

i mean when define integer array this- int main() { int a[100]={0,1,2,3}; cout<<a<<endl; return 0; } it prints address of 0x69fe74 if pass array function this- void fun(int *a) ///getting argument in integer pointer. right. { } int main() { int a[100]={0,1,2,3}; cout<<a<<endl; fun(a); ///function call putting name argument- return 0; } but in character array when this- int main() { char a[100]={'a','b'}; cout<<a<<endl; return 0; } it prints elements of character array. output=ab question is- how can pass value function same thing character array how possible? void fun(char *a) ///getting argument in character pointer. right. { } int main() { char a[100]={'a','b'}; cout<<a<<endl; fun(a); ///function call putting array name argument- return 0; } you this char s[100] = {'a', 'b'}; std:: cou...

sql server - Retrieve all set row from stored procedure in codeigniter using sqlsrv -

function sp_home() { $query = $this->sqlsrvr->query("sp_home"); $a=0; foreach($query->result() $row) { $data['latestnews'][$a] = $row; $a++; } sqlsrv_next_result(); $b=0; foreach($query->result() $row) { $data['allnews'][$b] = $row; $b++; } } both foreach return first row set, sqlsrv_next_result() not working in codeigniter. please

jquery - OWL Carousel no function -

i want use owl carousel. have dreated test.php where mistakes? <script> $('.owl-carousel').owlcarousel({ loop:true, margin:10, nav:true, responsive:{ 0:{ items:1 }, 600:{ items:3 }, 1000:{ items:5 } } }) </script> <div class="owl-carousel owl-theme"> <div class="item"><h4>1</h4></div> <div class="item"><h4>2</h4></div> <div class="item"><h4>3</h4></div> <div class="item"><h4>4</h4></div> <div class="item"><h4>5</h4></div> <div class="item"><h4>6</h4></div> <div class="item"><h4>7</h4></div> <div class="item"><h4>8</h4></div> <div cl...

python - Comparing two dictionaries Key values and return a new dictionary with the differences -

what want compare 2 dictionaries: predict = {'eggs': [1,2],'ham': [1,2,3], 'sausage': [1,2,3]} actual = {'eggs': [2], 'ham': [1,2]} and return new dictionary of difference: difference = {'eggs': [1],'ham': [3], 'sausage': [1,2,3]} what efficient way (for large amount of data) this? thanks. you can combine set.difference() , dict comprehension: >>> predict = {'eggs': [1,2],'ham': [1,2,3]} >>> actual = {'eggs': [2], 'ham': [1,2]} >>> difference = {k: list(set(v).difference(actual[k])) if k in actual else v k, v in predict.items()} {'eggs': [1], 'ham': [3]} explanation: you iterate on predict key-value pairs the new difference dictionary have same keys predict , actual but values set difference of current lists set(v).difference(actual[k]) - keys same, can access actual[k] , find difference current 1 (which v ) f...

javascript - Span overflow when value set programmatically not typed -

Image
i have created span on top of input field, manipulate styling of input text ( fiddle ). it works great long don't type past input box border, or happens: now, learned have same scrolling effect input span, this: white-space: nowrap; overflow: hidden; but, since not typing in span directly, updating innerhtml, has no effect. is there way can update span, treat updates typing? you can simulate same effect setting scrollleft high property on span type on it. need explicitly set same width on both input , span. you can see working fiddle here . i make "fake" span, hidden , variable width, can use set scrollleft property width text have if behave normally. to handle "cursor moving" events, check cursor position ( via @renatoprado ), , set scrollleft percentage of width of text. it's working real input field, it's still not perfect. triggers on keyup (keydown not working well), has "lag". , can't see blin...

angular - Ionic Deep Linking -

Image
i've created first ionic app deep linking. had give on lazy-loading deep links now... i'm confused way urls stay around when navigate elsewhere, home page. how people working round this? doing kind of url rewriting? or doing to, break else? seems can't wipe out url either, comes again. i've seen ionic blog , , heated discussions in github issues behaviour. it seems @ionicpage gives control on customising stuff, lazy-loading/modules right? or can use annotation without lazy loading? any advise on how best work appreciated. i noticed other weird behaviour, in data structure used hold reference homepage, became undefined, though exported constant. initial rootnav when app launches. had kludgy hack work around it, conditioning it if (page.home != undefined) { //bug in ionic perhaps this.nav.setroot(homepage, params) .catch((err: any) => { console.log(`didn't set home root: ${err}`); }); } else { this.nav.setroot(page.component...

c++ - Incompatible Types (vec4 and vec3) in assignment -

i've been learning opengl, along "glsl". i'm getting error trying compile fragment shader: incompatible types (vec4 , vec3) in assignment (and no available implicit conversion) can please me understand , resolve error? code below: #version 330 core in vec3 ourcolor; in vec2 texcoord; out vec4 color; // texture samplers uniform sampler2d ourtexture1; void main() { // linearly interpolate between both textures (second texture combined) color = texture(ourtexture1, texcoord); } thank you. edit: here shader compiler: class shaders_shader { public: gluint program; // constructor generates shader on fly shaders_shader( const glchar *vertexpath, const glchar *fragmentpath ) { // 1. retrieve vertex/fragment source code filepath std::string vertexcode; std::string fragmentcode; std::ifstream vshaderfile; std::ifstream fshaderfile; // ensures ifstream objects can throw exceptions: vshaderfile.exceptions...

ios - Adding a UIButton to an array -

i relatively new coding in swift , i'm updating app in app store. creating array contents in cell tableview made in xib file. here looks like: `struct calldata { let cell : int? let hotlinename : string? let phonenumber : string? let callbtn : uibutton? let iconimg : uiimage? init(cell:int,hotlinename:string,phonenumber:string, callbtn:uibutton, iconimg:uiimage) { self.cell = cell self.hotlinename = hotlinename self.phonenumber = phonenumber self.callbtn = callbtn self.iconimg = iconimg } } class _viewcontroller: uiviewcontroller, uitableviewdelegate,uitableviewdatasource { @iboutlet weak var tableview: uitableview! var arrayofcalldata = [calldata( cell: 0, hotlinename:"", phonenumber:"", callbtn:"", iconimg: #imageliteral(resourcename: "smartphone") )] ` i'm not sure how insert but...