Posts

Showing posts from May, 2014

javascript - Removing a div class with JS or JQuery on page load -

Image
unsure if familiar typeform. testing forms limited options regards optional items such incremental question numbers, bullet points & * required questions.. ive attached screenshot of exact item shown in dev window wish remove, how possible on page load using js or jquery? i.e. document.getelementsbyclassname("item"); edit way typeform embedded shown in snippet below: much appreciated !! <div class="typeform-widget" data-url="https://12837r8yhe.typeform.com/to/skcd9c" style="width: 100%; height: 500px;" > </div> <script> (function() { var qs,js,q,s,d=document, gi=d.getelementbyid, ce=d.createelement, gt=d.getelementsbytagname, id="typef_orm", b="https://embed.typeform.com/"; if(!gi.call(d,id)) { js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentnode.insertbefore(js,q) } })() </script> on page load can

Java 8 compare map by value bean's field -

how can create sorted map compares value's bean's field. map key integer , value car. i'd compare car's name it's can contains no letters. something this: (it's not work, bad example) comparator<car> carnamecomparator = new comparator<car>() { @override public int compare(car c1, car c2) { return c1.getname().comparetoignorecase(c2.getname()); } }; sortedmap<integer,car> carmap = new treemap<>(carnamecomparator); second try: map<integer, car> carmap = new hashmap<>(); carmap.put(1, car1); carmap.put(2, car2); map<integer, car> sortedbyvalue = carmap.entryset().stream() .sorted(map.entry.<integer, car> comparingbyvalue(carnamecomparator)) .collect(collectors.tomap(map.entry::getkey, map.entry::getvalue, (e1, e2) -> e1, linkedhashmap::new)); sortedbyvalue.foreach((k,c)->system.out.println("key : " + k + " value : " + c.getname())); m

html - How to redirect a webpage using an array of urls in Javascript? -

what if have array urls want webpage redirect to, how can loop array forever, unless close browser? let’s have var urls = ['/news/1', 'news/2', 'news/3', '/update/1', '/news4', 'news/5', 'news/6', 'update/2'] etc…. i have single html template changes content of elements inside based database records. want redirect page (same html template) following urls every 10 minutes. i have: <script> var timer = settimeout(function() { window.location=‘/news/1' }, 10000); // redirect once news/1 after 10seconds. </script> how can proper loop here on url array? thank reading! you can check on url are, update index, , start timeout. put in every page: var urls = ['/news/1', '/news/2', '/news/3', '/update/1', '/news4', '/news/5', '/news/6', '/update/2'], currentpath = window.location.pathname, curre

office365 - Sending a notification email using Exchange rule or Microsoft Flow or Logic App -

our company has 5000 users. each user has office 365 corporate email account , majority of these users use outlook web access (owa) read/send emails. out of 5000 users have 2000 users grouped category called sp (sales people). unfortunately, these 2000 users not computer savvy , reluctant use corporate email account. they reluctant because not accustomed using owa. instead, use own personal email accounts such gmail, yahoo, hotmail, etc... the problem send them important corporate messages emails since open owa, these emails never read or acknowledge. a company policy not allow send corporate messages directly personal email accounts. information must stay in house. we came following solution: each time receive email in corporate account, email notification automatically sent personal email account quick message saying hey...you’ve got new corporate email, please come , check out. exchange admin center (office 365) our initial goal create new rule inside m

c# - Autofac in console applications (convention) -

i use autofac in console application. first usage. before using in asp.net mvc only. in mvc project can setup autofac in global.asax, inject iservice controller , can more , less works. in console application below: internal class program { private static icontainer container { get; set;} private static void main(string[] args) { container = container.configure(); // here have necessary objects set // can use in main method as: using (var scope = container.beginlifetimescope()) { scope.resolve<isomething>(); } } } as can see usage of simple in main method. how using in external class? let create class cat, , inside use autofac. should pass contructor object container class program? e.g.: cat cat = new cat(program.container, "molly"); or maybe should create icontainer inside cat class? what best solution? only console application needs know autofac, otherwise you're fall

xcode - Custom shortcut with alt key not working -

as of xcode 9 gm, custom shortcut had configured " structure > add documentation " stopped working. instead of regular behavior, it's printing ÷ instead. i've read several questions on how deal special shortcuts using ukelele example wondering if there way use "old behavior". steps: open xcode > preferences > key bindings search add documentation set shortcut ⌥ alt 7 , press ↵ enter add new function, place cursor above it. function foo(bar: string) {} press ⌥ alt 7 expected: new documentation header should inserted xcode /// insert function documentation here !!! /// /// - parameter bar: parameter doc function foo(bar: string) {} result: ÷ inserted ÷ function foo(bar: string) {}

linux - 3 common problems i want to solve using unrar bash -

i have common problem using unrar bash i have bash #!/bin/bash rar in ls *.rar echo extrayendo $rar en pwd unrar x $rar done this bash allows me unrar every .rar file have in directory, have 3 problems its every time need write .rar password, files use same password, think if add -p password should work right? #!/bin/bash rar in ls *.rar echo extrayendo $rar en pwd unrar x -p password $rar done this annoying problem have, when im unrar files .url,.html, .txt , .srt files appears, no problems .srt files do, because need them, movie, need tell unrar delete .url, .txt , .html files or unrar file movie .mkv , .srt the last problems in every .rar files has .srt files named latino, español, spa,esp, etc. , want auto rename .srt files name of movie file, movie files videofile.mkv i know may asking cant make work i've been trying 2 days , no luck :c

yo - How can NPM scripts use my current working directory (when in nested subfolder) -

it's can run npm scripts not project root subfolders. however, constraint can't tell current working path ($pwd). let's there's command this: "scripts": { ... "pwd": "echo $pwd" } if run npm run pwd within subfolder of project root (e.g, $project_root/src/nested/dir ), instead of printing out current path $project_root/src/nested/dir , gives $project_root back. there way tell npm scripts use current working directory instead of resolving package.json resides? want pull yeoman generator existing project , use through npm scripts can use shared knowledge (e.g, npm run generator ) instead of learning yeoman specific (e.g npm yo -g; yo generator ). generator generates files based on current working path, while npm scripts resolves project root, can't use generator intend used. one known solution through env variable injection. for example: declare variable in command line: cwd="$(pwd)" npm run pw

image - CSS Vertical Align Objects in Col -

i cannot seem work , spending many hours on this. assuming should simple. looking desired effect of having image on top of text , have them both centered horizontally, have them vertically centered in middle. any appreciated! a = row, b = column, c = image, d = of text @to15108, can accomplished using flexbox. create one, set display property value flex . from there, can leverage justify-content , align-items properties vertical , horizontal centering trying accomplish. i've included code snippet see how works. make sure expand it's full size. .d-flex { display: flex; height: 100vh; justify-content: center; align-items: center; } .col { flex: 0 0; max-width: 50%; padding: 0px; margin-right: 5px; text-align: center; } <div class="d-flex"> <div class="col"> <img src="http://via.placeholder.com/350x150"> <div>some text&

asp.net - Created a MVC app, turned on Google Login.. want to strip out the local Registration stuff using ApplicationDbContext -

created mvc app, in vs2013, following this: https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on turned on google login.. got app ssoing google login (so can use google edu) want strip out local registration stuff using applicationdbcontext we have our own local user stuff in our db, our legacy code, want google login stuff work "ad" login stuff i'm replacing... can this? best approach? there walkthrough/working example of this? basically after login google first time want skip whole registration in local db in app_data step.. no registration, no local db. if can't scrape out or turn off, how can connect sybase 12 db via ddtek driver, , create local tables (letting c# it, entity first against our policies)

ios - MKAnnotationView layer is not of expected type: MKLayer -

Image
so code works fine logger riddled message. there way rid of or suppress it? postannotation.swift class postannotation: mkpointannotation { //mark: properties let post: post //mark: initialization init(post: post) { self.post = post super.init() self.coordinate = cllocationcoordinate2d(latitude: post.latitude, longitude: post.longitude) self.title = post.title self.subtitle = post.timestring() } } adding annotation let annotation = postannotation(post: post) self.map.addannotation(annotation) func mapview func mapview(_ mapview: mkmapview, viewfor annotation: mkannotation) -> mkannotationview? { if annotation mkuserlocation { return nil } var annotationview = mapview.dequeuereusableannotationview(withidentifier: "pin") as? mkpinannotationview if annotationview == nil { annotationview = mkpinannotationview(annotation: annotation, reuseidentifier: "pin")

python - Calculate the tangent of an angle for multiple angles in a pandas dataframe -

i have following dataframe: date time b 0 2016-01-01 00:00:00.000 443.30 469.80 1 2016-01-01 00:01:00.000 145.80 470.00 2 2016-01-01 00:03:00.000 452.20 471.00 3 2016-01-01 00:04:00.000 174.20 461.30 4 2016-01-01 00:05:00.000 345.30 471.90 i'm trying calculate tangent of angles (a/b) rows of dataframe. my code: import numpy np import math m df['i']=np.(m.degrees(m.atan(df['a']/df['b']))) the error produced: file "<ipython-input-70-0abce3902356>", line 3 df['i']=np.(m.degrees(m.atan(df['a']/df['b']))) ^ syntaxerror: invalid syntax taking () out produces error: df['i']=np.m.degrees(m.atan(df['a']/df['b'])) attributeerror traceback (most recent call last) <ipython-input-71-7cfc6387d664> in <module>() 1 2 ----> 3 df['i']=np.m.degrees(m.at

google chrome - WebRTC screen sharing more than once without reloading page -

hi i´m developing webrtc app. "video adviser", clients make video call sellers, , want sellers share screen (without losing video call). managed make work together, when client finishes call, , new client arrives, when seller tries share screen again (with new client) error occurs. the error following one: enter image description here i think problem screen sharing api not support ending , reopening screen share without refreshing window (this want, keep seller online , listening once finishes calls without refreshing entire page). this code cancel screen sharing once client leaves call: if(yourconn.getlocalstreams()[1] != null){ var screenstreaming = yourconn.getlocalstreams()[1]; yourconn.removestream(screenstreaming); screenstreaming.gettracks().foreach(track => track.stop()); } i know code stops succesfully screen sharing dont understand why when create new screen sharing stream, error posted appears. need help. by way, im using chro

Iterating over sub items in a JSON array in Angular 2 -

i know there's many answers regarding how iterate on json items in angular 2, i'm having field day (no pun intended) on trying figure 1 out: { "datesofinterest": [ { "name": "holidays", "year": "2017", "version": "3.0", "dataitems": [{ "langauage": "english", "listvalues": [{ "id": "bac34a", "name": "new year's day", "value": "new year's day", "startdatetime": "02/01/2017 00:00:00 am", "enddatetime": "02/01/2017 11:59:59 pm", "description":"the first day of year", "type":"statutory" },

Mongodb - convert the datetime to ISOdate format -

i want convert existing string date new iso date format. used scripts not enough convert time associated date. ex: 2013-01-10 12:22:22 converted isodate("2013-01-10t06:00:00z"). here time not converting. please help. var cursor = db.customer.find({"created_at": {"$exists": true, "$type": 2 }}); while (cursor.hasnext()) { var doc = cursor.next(); var parts = doc.created_at.split("-"); var dt = new date( parseint(parts[0], 10), // year parseint(parts[1], 10) - 1, // month parseint(parts[2], 10)// day ); db.customer.update( {"_id": doc._id}, {"$set": {"created_at": dt}} ) } simply use new isodate() : new isodate("2013-01-10 12:22:22 ") isodate("2013-01-10t12:22:22z") in full example : var cursor = db.customer.find({"created_at": {"$exists": true, "$type": 2 }}

java - How to save textfield response without clearing -

i trying create simple list style app. have saved string using sharedpreferences, able refer in logs, make string stays attached textfield instead of being cleared every time app reopened (until changed or deleted user). other suggestions appreciated. (mainactivity) public void go(view view) { intent intent1 = new intent(secondactivity.this, mypreferences.class); string passgoal1 = goal1.gettext().tostring(); intent1.putextra("goal1", passgoal1); startactivity(intent1); } also implemented mypreferences class referenced in first answer. public class mypreferences { private sharedpreferences pref; private sharedpreferences.editor editor; private context context; int private_mode = 0; private static final string pref_name = "mypreferencesname"; public final static string key_name = "key_value"; public mypreferences(context context) { this.context = context; pref = context.get

php - url returns XML on browser, but doesn't when using cURL -

i'm sending few parameters, via post url using curl, url supposed return results in xml, instead returns string result. if copy url , variables , paste in browser, returns desired xml. $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $variables); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_header, false); $result = curl_exec($ch); $error = curl_error($ch); curl_close($ch); print_r($result); that's piece of code i'm using. missing something? thanks in advance. take string curl returns , turn xml object $xml = simplexml_load_string($result); simplexml documentation here

Angular/Typescript call a class method in an event -

i totals new ts , angular , trying build simple drawing component on canvas. have far worked way point totally don't know doing. different "this" in ts big issue me, think now. here code: import { component, oninit } '@angular/core'; @component({ selector: 'track-creator', templateurl: 'track-creator.component.html', styleurls: ['track-creator.component.css'] }) export class trackcreatorcomponent implements oninit { public canvas; public context; ngoninit(): void { this.canvas = document.getelementbyid('trackcreatorcanvas'); this.context = this.canvas.getcontext("2d"); this.canvas.addeventlistener("mousedown", function (e) { this.draw(e); }, false); } draw(e): void{ this.context.beginpath(); this.context.arc(e.clientx,e.clienty,5,0,2*math.pi); this.context.stroke(); } } the error here is: erro

Configure json on Play framework (scala) -

checking play documentation found can automate json de/serizalization following code: implicit val addresswrites = json.writes[address] implicit val addressreads = json.reads[address] a friend told me add on companion object, should add 1 companion obj each class add json config? couldn't add models in 1 place or use annotations on each class in java? and general config like: implicit val config = jsonconfiguration(snakecase) where add that? regarding put serializer/deserializer implicits, have few suggestions: declare everytime need use it add companion object , implicit available when import data class declare in single jsonserializers object , import whenever need use it. using companion object makes easy remember import make implicits available when needed (typically in controller class) , "encapsulates" code related model in single file. having single jsonserializers object has advantage of making possible have serializers availabl

How to use Google Cloud Speech v1 on Android? -

i updated android google cloud speech code v1beta1 v1. there couple of changes in api, 1 of them new method called getwordslist(). i want use getwordslist() in android project, method doesn't seem visible code: import com.google.cloud.speech.v1.speechgrpc; import com.google.cloud.speech.v1.speechrecognitionalternative; import com.google.cloud.speech.v1.streamingrecognizeresponse; import com.google.cloud.speech.v1.wordinfo; ... public void onnext(streamingrecognizeresponse response) { int numofresults = response.getresultscount(); if( numofresults > 0 ){ (int i=0;i<numofresults;i++){ streamingrecognitionresult result = response.getresultslist().get(i); speechrecognitionalternative alternative = result.getalternativeslist().get(0); (wordinfo wordinfo: alternative.getwordslist()) { //-->>cannot resolve 'method' system.out.println(wordinfo.getword()); system.out.println(wordinfo.getstarttime().getseconds() + "

node.js - how to create next condition in same value in node js -

i have problems in code value in json [ { "title": "a", "detail": { "descript": "test" } }, { "title": "b", "detail": { "descript": "test1" } }, { "title": "c", "detail": { "descript": "test2" } } ] my model api router.post('/newscreate', function(req, res){ var queryng = req.body || req.body.query; if (queryng){ (i=0; i<queryng.length; i++){ var loop = queryng[i]; if (loop){ if (loop.title != 'a'){ console.log('true', loop.title); }else{ console.log('false', loop.title); //event if value same 'a' post title b , title c } } } } }); i have tired 1 day condition, can correct code? thanks

r - Does this actually return the total return of a portfolio? -

i've ran bit of trouble of late trying calculate returns of investment portfolio. here's 1 way has been recommended on rstudio blog. this way uses return.portfolio function performanceanalytics , shows 'dollar growth' of portfolio. if has experience i'd keen hear thoughts on whether or not accurate method. library(performanceanalytics) library(quantmod) library(dygraphs) symbols <- c("goog", "amzn", "ba", "fb", "aapl") stock.weights <- c(.15, .20, .25, .225, .175) getsymbols(symbols, src = 'google', from="2017-01-01") #merge closing port.closing <- merge.xts(goog[,4], amzn[,4], ba[,4], fb[,4], aapl[,4]) #change closings returns port.return <- na.omit(return.calculate(port.closing)) #portfolio returns wealth.index = true apply $1 invested - no rebalance port.norebal = return.portfolio(port.return, weights = stock.weights, wealth.index = true) #visualise dollar growth dygra

Ramp up/down missing time-series data in R -

i have set of time-series data (gps speed data, specifically), includes gaps of missing values signal lost. missing periods of short durations fill using na.spline, inappropriate longer time periods. ramp values last true value down zero, based on predefined acceleration limits. #create sample data frame test <- as.data.frame(c(6,5.7,5.4,5.14,4.89,4.64,4.41,4.19,na,na,na,na,na,na,na,na,na,na,na,na,na,na,na,5,5.1,5.3,5.4,5.5)) names(test)[1] <- "speed" #set rate of acceleration ramp ramp <- 6 #set sampling rate of receiver hz <- 1/10 so missing data ramp use previous value , rate of acceleration next data point, until speed reached 0 (i.e. last speed [4.19] + (hz * ramp)), yielding following values: 3.59 2.99 2.39 1.79 1.19 0.59 0 lastly, need in reverse fashion, ramp 0 when signal picks again. hope clear. cheers it's not elegant, can in loop. na.pos <- which(is.na(test$speed)) acc = false (i in na.pos) { if (acc) {

graph databases - Gremlin - select a vertex, create new vertices and edges in single query -

i have user vertex created. g.v().has('user','username','vipul').as('user') i want create new 'group' vertex properties , new 'options' vertex other properties. g.addv(label,'group','group_name','dc11').as('group') g.addv(label,'options','command_line_arguments','-d -n').as('options') now want create edge user group , edge group options. user ---> group, group ---> options can these queries combined, selecting vertex, creating new vertices , creating new edges? you can chain steps together: g.v().has('user','username','vipul').as('user'). addv('group').property('group_name','dc11').as('group'). adde('memberofgroup').from('user'). addv('options').property('command_line_arguments','-d -n'). adde('hasoptions').from('group&

visual studio 2015 - How can I add Azure Active Directory group to role in SSDT tabular project? -

i have ssdt tabular project needs deployed azure analysis services. i created new role in tabular model explorer, when i'm trying add group created in azure active directory member of role i'm getting errors @ deploy time. if try add group using add , finding in organization ad, i'm getting error: cannot deploy metadata. reason: failed save modifications server. error returned: 'the identity 'myorganization\mygroup' has invalid identity provider ''. azure active directory users or groups supported. use 'azuread' value of identity provider. if use add external (i've tried several spellings - mygroup , mygroup@myorganization.com , mygroup@myorganization.onmicrosoft.com , mygroupid ), i'm getting this: failed save modifications server. error returned: 'the identity 'mygroup' not found in azure active directory. details: unable resolve user or group 'mygroup' technical details: rootact

parallel processing - Python producer and consumer system design -

if i'm writing python program execute other 2 executables(c++) in producer , consumer manner, right lib do? asyncio? multiprocessing? the main execution thread or process is: monitoring status of producer , consumer processes. if 1 of them fails, terminate other. if ctrl-c received, terminate both of them if both of them finishes, exit , report success. the producer: keep generating data temp file. (that temp file might fifo os.mkfifo()?) the consumer: keep consuming temp file both producer , consumer cpu intensive, , need run in parallel. ideally intermediate temp file doesn't need touch real storage , stay in memory. otherwise performance big concern since temp file of size 10gb or so.

c# - Web Development using Razor vs Web Forms - when to use one over the other? -

i'm learning ins , outs of asp.net (previously coded in c#, differnt flavors of vb, etc). i'm noticing in when creating kind of website have option of using plain old web forms or razor v3. i've come across multiple tutorials/documentation part developers using web forms, @ time notice razor v3 used. what limitations of razor v3? to me seems razor v3 easier code since parses server side code html should used more powerful applications? when should use 1 on other? it helps not confuse stacks syntax. can use razor syntax @ asp.net mvc, asp.net web pages - , can use aspx syntax <%= asp.net web forms , asp.net mvc. there other third-party syntax providers asp.net mvc, known viewengines . mention t4 syntax ( <#= #> ) example of third-party viewengine can use. asp.net web forms not directly support third-party view-engines. stack aspx <%= razor @ t4 <#= ----------------------------------------------------- asp.net

osx - nvram doesn't remember my boot-args settings. How to fix it? -

i'm working on kernel extension - device driver - , rely heavily on diagnostic messages come kprintf(). $ fwkpfv on host machine display log messages kprintf() on target, needs "debug=0x8" in boot-args. # nvram boot-args="debug=0x14e kdp_match_name=firewire" # nvram -p | grep boot-args boot-args "debug=0x14e kdp_match_name=firewire" (i don't remember whether quotes included.) if boot after setting boot-args: # nvram -p | grep boot-args # i eternally in debt. some folks on darwin-drivers mailing list pointed out me nvram command holds settings in ram until clean shutdown performed. i've been in habit of forcibly powering mac pro off driver panics when it's been installed. it worked boot recovery mode, set boot-args, shutdown apple menu. this got firewire logging back.

javascript - Call parent method with component -

i have component , want add click listener runs method in parent template in vue. possible? <template> <custom-element @click="somemethod"></custom-element> </template> <script> export default { name: 'template', methods: { somemethod: function() { console.log(true); } } </script> directly vue documentation ( https://vuejs.org/v2/guide/components.html#composing-components ): in vue, parent-child component relationship can summarized props down, events up. parent passes data down child via props, , child sends messages parent via events... so need emit click event child component when happens, can used call method in parent template. if don't want explicitly emit event child (using this.$emit('click') child component), can try use native click event, @click.native="somemethod" (docs: https://vuejs.org/v2/guide/components.htm

Azure recovery services not allowing me to select VM -

Image
i trying migrate vm in southeast asia western europe after defining source in enable replication section, not able select virtual machine. source details select virtual machine section shows vm grayed out. my account has owner, site recovery contributor, site recovery operator, site recovery reader , virtual machine contributor roles. currently, native replication of azure vms using managed disks not supported . you can use "physical azure" option in this document migrate vms managed disks. more details bout migrate azure iaas virtual machines between azure regions azure site recovery , can refer this document .

java - How to get static final variables using JNA -

i using glew library glew32.dll (standard download glew website) , trying load variable glew_ok. variable defined in glew.h file (as uint of 0), assuming included in glew32.dll file. however, when use java jna code : nativelibrary glew = nativelibrary.getinstance("glew.dll"); pointer p = glew.getglobalvariableaddress("glew_ok"); system.out.println(p.getint(0)); i given error of exception in thread "main" java.lang.unsatisfiedlinkerror: error looking 'glew_ok': specified procedure not found. at com.sun.jna.nativelibrary.getglobalvariableaddress(nativelibrary.java:587) @ mcclean.opengl.glew.glewutils.init(glewutils.java:22) the library loaded fine, appears static variable not found. why static variable not being loaded? looking @ header file glew.h , glew_ok found such: /* error codes */ #define glew_ok 0 this preprocessor definition . not "static final variable " conceive in java world. when c++ project compiled,

c++ - function or type already defined in persontype -

after compile code,i keep getting error saying severity code description project file line suppression state error lnk2005 "public: void __thiscall membershiptype::print(void)" (?print@membershiptype@@qaexxz) defined in persontype.obj project1 c:\users\okpal\source\repos\project1\project1\source.obj , severity code description project file line suppression state error lnk1169 1 or more multiply defined symbols found project1 c:\users\okpal\source\repos\project1\debug\project1.exe 1 have no idea how fix these errors in class have nothing defined twice have no idea error mean or how fix it. include <iostream> #include <string> using namespace std; class addresstype { //class defintions , prototypes member variables public: addresstype(); string streetaddressnum, streetname, streettype, city, stateinitials; int zipcode; }; class persontype { public: persontype(); string firstname; string lastname; in

getopt - C Using isdigit to check if optarg is a digit -

if optarg (the argument after flag -s, getop library) isn't digit, want error message printed , program terminated, , if digit, size needs set optarg. problem have while command -s r hit error message, -s 2 also, meaning it's interpreting 2 string. debugging -s 2 #1 printf("%d",atoi(optarg)); #2 printf("%d",isdigit(atoi(optarg))); i int value 2 line #1, , int value of 0 line #2. so wondering why isdigit(atoi(optarg))) gives me 0, when atoi(optarg) gives me int. there better way check if optarg int? int main (int argc, char *argv[]){ int size; char option; size = 0; const char *optstring; optstring = "rs:pih"; while ((option = getopt(argc, argv, optstring)) != eof) { switch (option) { case 'r': type_set = 1; break; **case 's': capacity_set = 1; if(isdigit(atoi(optarg))==0){ fprintf(stderr,"argument after -s needs int\n");

java - SQLException: No suitable driver found for jdbc:derby://localhost:1527 -

i error in netbeans: java.sql.sqlexception: no suitable driver found jdbc:derby://localhost:1527/ how caused , how can solve it? java.sql.sqlexception: no suitable driver found jdbc:derby://localhost:1527/ this exception has 2 causes: the driver not loaded. the jdbc url malformed. in case, i'd expect see database name @ end of connection string. example (use create=true if want database created if doesn't exist): jdbc:derby://localhost:1527/dbname;create=true databases created default in directory network server started up. can specify absolute path database location: jdbc:derby://localhost:1527//home/pascal/derbydbs/dbname;create=true and in case, check derbyclient.jar on class path , loading appropriate driver org.apache.derby.jdbc.clientdriver when working in server mode.

spring boot - Springboot devtools can't endup the java process in Idea? -

Image
i used spring developer tools in project automatic reload, hold 1 (two sometimes) process in windows after click stop button in idea, should kill them every time in windows manually. it seems idea stop button can't end java processes actually.i want restart project under tomcat in cases, cause port bind error. how end java processes when stop button clicked ?

google chrome - How to access the webpage DOM rather than the extension page DOM? -

i'm writing chrome extension , trying overlay <div> on current webpage button clicked in popup.html file. when access document.body.insertbefore method within popup.html overlays <div> on popup, rather current webpage. do have use messaging between background.html , popup.html in order access web page's dom? in popup.html, , use jquery too, if possible. as stated in chrome extensions overview: architecture (which must-read): if extension needs interact web pages, needs content script. content script javascript executes in context of page that's been loaded browser. think of content script part of loaded page, not part of extension packaged (its parent extension). a popup ( browseraction icon in main google chrome toolbar right of address bar) html page chrome-extension:// url, if access dom, you're affecting page. same applies background/options page. to access/manipulate webpage dom have 2 ways: either declare content

XML prefix doesn't show up when no defined URI in ASP.Net -

basically trying generate xml following format: <m:messageheader> <m:date>2017-09-14></m:date> <m:source>web</m:source> </m:messageheader> below code: dim msgheader xmlnode msgheader = xml.createelement("m", "messageheader", "") however, prefix 'm' doesn't appear in messsageheader. below output of above code: <messageheader /> what should expected output? because must specify namespaceuri. if leave namespaceuri parameter empty or null, prefix omitted. try: msgheader = xml.createelement("m", "messageheader", "https://stackoverflow.com/")

python 3.x - Converting a for loop into a while loop -

i've done loop returns true if there 2 next 2 , i'm trying using while loop. can't seem make while loop work. here's loop i've done def has22(nums): "return true if array contains 2 next 2 somewhere""" in range(0, len(nums)-1): if nums[i] == 2 , nums[i+1] == 2: return true return false i tried running while loop doesn't work. def has22(nums): """while loop version""" = 0 while < len(nums) - 1: if nums[i] == 2 , nums[i+1] == 2: return true += 1 can please tell me what's wrong it? the return true not indented, it's returned (ie. not body of if statement) the function never returns `false try: def has22(nums): """while loop version""" = 0 while < len(nums) - 1: if nums[i] == 2 , nums[i+1] == 2: return true += 1 return false

node.js - using regex in nodejs filtering multiple delimiters -

i have multiple emails in string multiple delimiters ,;:/|\"" . im trying slip , add in array. im there small issue coming know wrong in regex. node js code: var x = "mmmm lll\"kkkk\jjj/iiii,hhhh:gggg+ffff-eee+dddd;cccc|bbbb:aaaa"; var separators = [' ', '\\\+', '-', ';', '"', '\\|','//', '\\|', '\\\(', '\\\)', '\\*', '/', ':', '\\\?']; console.log(separators.join('|')); var tokens = x.split(new regexp(separators.join('|'), 'g')); console.log(tokens); here output: |\+|-|;|"|\||//|\||\(|\)|\*|/|:|\? [ 'mmmm@gmail.com', 'lll@gmail.com', 'kkkk@gmail.comjjj@gmail.com', 'iiii@gmail.com,hhhh@gmail.com', 'gggg@gmail.com', 'ffff@gmail.com', 'eee@gmail.com', 'dddd@gmail.com', 'cccc@gmail.com', 'bb

php - Using a front end editor with static pages plugin -

im new ocms, have installed static pages , working good. want edit fields front page (in context editing) 1 of plugins, example: https://octobercms.com/plugin/netsti-editor have dragged layout page, can't edit in front page. example how use static page plugin: <img src="{mediafinder name="logo" label="logo" tab="general" mode="image"}{/mediafinder}" /> {repeater name="side_logos" tab="general" prompt="add content section"} {text name="my_title" label="my title"}{/text} {/repeater} thanks we discussed exact problem op in chat. turned out there's better option use other plugins needs - this 1 static pages , this 1 inline editing . the other thing is, once page becomes more or less dynamic (e.g. scripts can change/alter type of content) automatically stops being "static page".

Use the name of last month in PowerShell output file -

at moment i'm using powershell run sql query on sql server database , output results excel spreadsheet. it outputs via invoke-sqlcmd -inputfile "c:\scripts-and-reports\all_new-matters-since-last-run.sql" -serverinstance "pe-server\practiceevolve" -database "practiceevolve_c1" | select-object * -excludeproperty "rowerror","rowstate","table","itemarray","haserrors" | export-xlsx -worksheetname "15-05-2017 $(get-date -f dd-mm-yyyy)" -path "c:\scripts-and-reports\15-05-2017 $(get-date -f yyyy-mm-dd) taree pe new clients.xlsx" -force -verbose which working fine because i'm manually specifying date filter in sql query, in worksheetname, , in file name. i aim automate entire process runs on 1st of each month , reports on entire previous month. i've since modified sql query filter previous month, i'd have output file's worksheet , filename include pre

encryption - Install Arch Linux SSD LUKS -

i know there tutorials out there , have tried every time think it's done end errors, failing boot, can't find drive. had 1 system booted painfully slow. can offer guidance on how decent install of arch? my specs 256gb ssd root 4tb hdd home - encrypted nvidia geforce 1080 ti gpu 64gb ram uefi any appreciated.

javascript - Cannot replace data with modal -

Image
when want change input using modal, changed data last input...not corresponding button clicked on. here code (): dashboard.php <div id="modalpartid" class="modal fade" role="dialog"> <div class="modal-dialog" style="width:70%;overflow-y: initial !important;"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">browse partid</h4> <br/> <input type="text" class="form-control" id="searchpartid" placeholder="partid"/> </div> <div class="modal-body" style="height: 300px; overflow-y: auto;"> <table class="table table-striped"> <thead> <t

model - How can I change this GPU code in CPU code? -

all. this simple gpu code in pytorch. how can change in cpu code? filename=r’./test/bees/1.jpg’ img = skimage.io.imread(filename) x = v(centre_crop(img).unsqueeze(0), volatile=true).cuda() model = models.dict(’resnet18’) model = torch.nn.dataparallel(model).cuda() model = torch.load(‘model5.pth’) logit = model(x) print(logit) thanks in advance .

store procedure parameter SAP Crystal Report jsp -

i have 2 kind of parameter, static parameter , parameter store procedure, done show static parameter in report. when send parameter jsp crystal report, in case store procedure parameter, failed. i send parameter with: parameterfieldcontroller.setcurrentvalue("", "v_pangkat", v_pangkat); v_pangkat store procedure parameter. posible set value parameter jsp , show dynamic reports based on parameter input? how fix problem? thanks declare variable in procedure "v_pangkat" value. send value of v_pangkat through procedure generate crystal report , use ui select value of v_pangkat user.

javascript - IndexDB Uncaught Failed to execute 'transaction' on 'IDBDatabase' -

i'm working in login/sigup sistem, have take value of inputs register them, have problem. the error is: uncaught domexception: failed execute 'transaction' on 'idbdatabase': 1 of specified object stores not found. and occur in code line: "var data = active.transaction(["usuarios"], "readwrite");" can me this? here code: var indexeddb = window.indexeddb || window.mozindexeddb || window.webkitindexeddb || window.msindexeddb; var database = null; function startdb(){ database = indexeddb.open("objectdb", 1); database.onupgradeneeded = function (e) { var active = database.result; var objectdb = active.createobjectstore("usuarios", {keypath: 'id', autoincrement : true }); objectdb.createindex('index_nombre','nombre', {unique : false}); objectdb.createindex('index_user','usuario', {unique : true}); objectdb.createindex('index_correo'

Email Validation in Registrraion Form in javascript -

this question has answer here: how validate email address in javascript? 65 answers i have 1 register-form creating account.in email field how can check enter email real email id or fake email id without sent email.and when user leave field validation start.any idea please share me.... you can't work js (without sedn email): i recommend send code user rmail , verify that. this way valid email , register user. note : if want know email in email pattern can html , js : html way : <input type="email" name="email" placeholder="your email"> js way : how validate email address in javascript?

python - Any way to determine no of text lines in image? -

Image
actually, have find no of text lines in given image e.g. if having 2 images from pil import imagegrab img1=imagegrab.grab([0,0,200,80]) img2=imagegrab.grab([300,0,500,80]) first 1 img1 , second 1 img2 how can input img1 , output 5 , if input img2 output 4 i.e. no of text lines in image if want without ocr-ing text, typical approach, determine each line in image if has 1 or more 1 color. the lines 1 color can assumed background transition more 1 color single color "bottom" line of text row. count transitions , you'll have number of lines of text in image. this assumes: characters of 1 line no extend bottom of cell drawn in (that mean there might never empty line if top line has g , bottom 1 f - or similar configurations) there text , not pictures (as in samples).

php - How to aggregate query on related table's field in Laravel? -

i have 1 many (inverse) relation on laravel 5.4 application. there 2 models sale , vehicle related , associated scene. the relation on sale model : public function vehicle() { return $this->belongsto('app\models\vehicle','vehicle_id'); } table sales has following fields : id , vehicle_id , date_time , status etc. table vehicles has following fields : id , reg_number , volume , status etc. what want is, sum of field 'vehicles.volume' of sale records within search conditions. i have tried methods following one: $query = sale::where('status', 1); $query = $query->where('date_time', '<', "2017-05-10 10:10:05"); $totalvolume = $query->wherehas('vehicle')->sum('vehicles.volume'); and resulted in following error: sqlstate[42s22]: column not found: 1054 unknown column 'vehicles.volume' in 'field list' (sql: select sum( vehicles . volume

spring mvc - Can not convert from object to list exception -

list<myjavaclass> smalllistnew = (list<myjavaclass>) i1.next(); above line causing error says object can not type casted type list<myjavaclass> . below description code: list<myjavaclass> i1=biglist.iterator(); big list contains many small list in following way: //here unique list contains long values without duplicates being compared refreshjobcountlist. iterator<long> i=uniquerefjobid.iterator(); while (i.hasnext()) { long refreshjobid = i.next(); list<myjavaclass> smalllist = new arraylist<>(); (myjavaclass details : refreshjobcountlist) { if (refreshjobid.equals(details.getrefreshjobid())) { myjavaclass new_obj=new myjavaclass(); new_obj.setcount(details.getcount()); new_obj.setjobrunid(details.getjobrunid()); new_obj.setrefreshjobid(details.getrefreshjobid()); smalllist.add(new_obj); } } biglist.addall(smalllist); }

asp.net - cannot find installable isam even -

string filepath = configurationmanager.appsettings["filepath"].tostring(); string filename = string.empty; if (testupload.hasfile) { try { string[] allowedfile = { ".xlsx" }; string fileext = system.io.path.getextension(testupload.postedfile.filename); bool validfile = allowedfile.contains(fileext); if (!validfile) { page.clientscript.registerstartupscript(this.gettype(), "scripts", "<script>alert('upload excel file');</script>"); } else { int filelen = testupload.postedfile.contentlength; if (filelen < 1048567) { filename = path.getfilename(server.mappath(testupload.filena

javascript - Append Multiple objects into single array -

i have array of objects of structure coming server response of iterated array object sample array[1] ={ "id": "123", "name": "john", "age": "15" } array[2] ={ "id": "456", "name": "sue", "age": "18" } array[n] ={ } but want append array values if condition age below 18 in following structure of iterated values of above array expected output: { "stud": [{ "id": "123", "name": "john", "age": "15" }, { "id": "456", "name": "sue", "age": "18" },{n........ }] } simply var output = { "stud" : array }; //existing 'array'

asp.net mvc 4 - Access a viewbag property in reactjs -

i developing web application , using reactjs , mvc c#. i want know if jsx included in cshtml , possible access viewbag property in jsx? have object or id passed jsx rendered in ui? viewbag rendered , execute in server side, react invoked on browser (client). main options are: global variable - in razor ( .cshtml ) can set global object window.param = viewbag.param . , access react. const x = window.param pass value (primitives only) root element of react via data-attribute , grab before call render: example: // razor (.cshtml) <div id="root" data-param="@viewbag.param"></div> // react const root = document.getelementbyid('root'); const param = root.getattribute('data-param'); render(<app myparam={param}/>, root)

Graphical/Pictorial representation of communication(request/response) between the server and the client during Cookies mechanism in PHP -

i've read , studied 1 of important concept of 'cookies' in php i'm still not able understand how actual communication takes place between server , client(i.e. browser) in 'cookies' mechanism, right start end. if possible, can please explain/elaborate/help me graphical/pictorial representation of actual communication takes place between client , server(i.e. browser) during 'cookies' mechanism in php? it great, great me , other members of php community understand important concept of 'cookies' mechanism in better way. thank you.

shopping cart - OctoberCMS - Unresolvable dependency resolving -

somebody have idea of error: unresolvable dependency resolving [parameter #0 [ $app ]] in class illuminate\database\databasemanager i installed -composer require: gloudemans/shoppingcart#dev-dev-laravel55 and ^2.4 -dev-master had same error. i setup plugin with: public function boot() { app::register('\gloudemans\shoppingcart\shoppingcartserviceprovider'); $alias = aliasloader::getinstance(); $alias->alias('cart', 'gloudemans\shoppingcart\facades\cart'); } this working on localhost running on windows. on ubuntu on digitalocean track error on: \\vendor\gloudemans\shoppincart\src\cart.php when follow function called. private function getconnection() { $connectionname = $this->getconnectionname(); return app(databasemanager::class)->connection($connectionname); } this part "app(databasemanager::class)" show error. i looking information bindings , give sub-folder permissi

command line - Constantly checking if display is working on Linux -

is there possibility check if display(monitor) working or not , import data code? assume there command-line tricks or devices 'leak' info it. using linux. you can use x11 extension xrandr ( x resolution , rotation or that). you can see status of output displays command xrandr . in pc example get: $ xrandr | grep connected dvi-i-0 disconnected (normal left inverted right x axis y axis) dvi-i-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm .... the names of outputs device specific, of course. if want access data c program, xrandr extension easy enough program. sample code print connection status of outputs (error checking omitted): #include <x11/xlib.h> #include <x11/extensions/xrandr.h> #include <stdio.h> int main() { display *dsp = xopendisplay(null); window root = xrootwindow(dsp, 0); xrrscreenresources *sres = xrrgetscreenresources(dsp, root); printf("n outputs %d\n&qu