Posts

Showing posts from June, 2011

c# - UoW and DbContext fail in an event -

i have implemented windows service sends emails using sendasync method, every 30 seconds in batches of 20. i'm using ef6 , sql server 2016. here parts of codes emailrepository.cs public class emailrepository : iemailrepository { private bbentities db = null; public emailrepository(bbentities db) { this.db = db; } public ienumerable<tb_email> selectall(int batchage, int batchsize) { datetime tdate = datetime.now.addminutes(batchage); return db.tb_email.where(x => x.readytosend.equals(true) & x.datesent.equals(null) & x.datecreated >= tdate).orderby(x => x.datecreated).take(batchsize); } public tb_email selectbyid(guid id) { return db.tb_email.find(id); } public void update(tb_email obj) { db.entry(obj).state = entitystate.modified; } #region idisposable support private bool disposedvalue = false; protected virtual void dispose(bool disposing) ...

typescript - How can i pass the selected data objects to another page -

Image
hello, how can pass selected object data when want select more 1 , pass page , put list. how can achieve ? how can pass parameter when select more 1 object ? add products array first productlist = [] any[]; productlist.push(product); this.navctrl.push(orderpage,{ productlist: productlist});

Select before aggregate with Pandas, python -

i'm pretty new pandas in python , need see if i'm doing right. have excel file containing data , i'm using pandas play data. question mentions can select 4 ports before aggregating in terms of year , ports. tried this. filterport = porttraffic.port.isin(['adelaide','brisbane','sydney','melbourne']) new = porttraffic[filterport] year_port = new.groupby(['year','port']) i obtain output (if print head) showing me data of 4 ports filtered wonder if i'm doing correctly? note, porttraffic excel file

python - Get local time reflected on PC and not other time zone -

i using python v3.6 current time. import time current_time = time.strftime("%h:%m:%s %y-%m-%d", time.gmtime()) the code works time retrieved other time zones. how retrieve time same reflected on windows 10 clock on pc? try below. expect gmtime gmt(utc more likely), vs local. see https://docs.python.org/2/library/time.html >>> time.strftime("%h:%m:%s %y-%m-%d", time.gmtime()) '03:16:00 2017-08-20' >>> time.strftime("%h:%m:%s %y-%m-%d", time.localtime()) '13:16:08 2017-08-20

xpath - How to locate the dynamic list element using selenium web driver, which comes after entering the string in the search box? -

i want detect item dynamic search result, item element of list eg after visiting https://www.valueresearchonline.com/default.asp?r=r , entering "hdfc balanced", first element matches string needs selected using xpath. enter image description here

javascript - Why is it possible to access 'module.exports' as just 'exports' but not so with 'module.id'? -

this code in file named foo.js . console.log('module.exports:', module.exports) console.log('module.id:', module.id) console.log('exports:', exports) console.log('id:', id) this output get. $ node foo.js module.exports: {} module.id: . exports: {} /home/lone/foo.js:4 console.log('id:', id) ^ referenceerror: id not defined @ object.<anonymous> (/home/lone/foo.js:4:20) @ module._compile (module.js:573:30) @ object.module._extensions..js (module.js:584:10) @ module.load (module.js:507:32) @ trymoduleload (module.js:470:12) @ function.module._load (module.js:462:3) @ function.module.runmain (module.js:609:10) @ startup (bootstrap_node.js:158:16) @ bootstrap_node.js:598:3 here unable understand. both exports , id attributes of module object. able access exports without module. qualifier unable id attribute. why so? concepts @ play here makes possible access module.export...

redux observable - RxJs How to set default request headers? -

not sure there way set default request headers in rxjs axios js as- axios.defaults.headers.common['authorization'] = 'c7b9392955ce63b38cf0901b7e523efbf7613001526117c79376122b7be2a9519d49c5ff5de1e217db93beae2f2033e9'; here epic code want set request headers - export default function epicfetchproducts(action$, store) { return action$.oftype(fetch_products_request) .mergemap(action => ajax.get(`http://localhost/products?${action.q}`) .map(response => dofetchproductsfulfilled(response)) ); } please help. it's not possible set default headers ajax requests using rxjs's ajax utilities. you can provide headers in each call, or create own simple wrapper provides them default. utils/ajax.js const defaultheaders = { authorization: 'c7b9392955ce63b38cf090...etc' }; export const = (url, headers) => ajax.get(url, object.assign({}, defaultheaders, headers)); my-example.js import * ajax ...

python - PyCrypto AES suddenly stops decrypting after several lines of processing input -

i attempting encrypt , decrypt 5-14 mb text files 2 python files, 1 containing encrypt/decrypt methods , being runner methods. here's class file: from crypto.cipher import aes crypto import random import sys import codecs reload(sys) sys.setdefaultencoding('utf8') sys.stdout = codecs.getwriter('utf8')(sys.stdout) class crypt: def __init__(self, encrypted, key): self.message = encrypted self.key = key def encrypt(self): iv = random.new().read(aes.block_size) if len(self.message) % aes.block_size != 0: self.message += " " * (aes.block_size - (len(self.message) % aes.block_size)) lenkey = len(self.key) if lenkey > 32: self.key = self.key[:32] cipher = aes.new(self.key, aes.mode_cfb, iv) return iv + cipher.encrypt(self.message) def decrypt(self): iv, message = (self.message[:aes.block_size], self.message[aes.block_size:]) if len(m...

ERROR 1005 (HY000) errno: 150 -

i having problem, has been addressed in many posts, none of them show going wrong. error 1005 errno 150 when try following; structure of appointments: create table `appointments` ( `appointmentid` int(11) not null auto_increment, `apptnum` tinyint(3) unsigned not null default '1', `cwaid` int(11) not null default '0', `siteid` int(11) default null, `titlecode` varchar(25) not null, `apptpercentage` double default '0', `status` varchar(2) character set utf8 default null, `payrate` double default '0', `ratecode` varchar(5) character set utf8 default null, `locationinfo` varchar(100) character set utf8 default null, `apptstartdate` date default null, `apptenddate` date default null, `isprimaryappointment` varchar(1) character set utf8 not null default 'y', `lastmoddate` timestamp not null default '0000-00-0...

ios - AVPlayer addPeriodicTimeObserver not fired if track ended -

Image
i use uislider display position of track , avplayer playing track. m3u8 file. show current position in track, this: timeobserver = player.addperiodictimeobserver(forinterval: cmtimemake(1, 2), queue: .main) { [weak self] time in if let `self` = self { self.eventlistener?.onevent(playerevent.progressed(time: time), generetedby: self) } } the slider changes position , fine. when track ends slider slider not @ end. result: 0.0 0.500590782 1.001336673 1.501167803 2.001181077 2.501238459 2.564631671 end but, duration: 2.693

How can I display all elements from JSON Document in Mysql -

i have inserted below data column doc. insert tbl_temp (sid, doc) values('m000001', '{"doclist": [{"pid":"f000001","name":"roi","age":"32","city":"oli","occ":"reader"}, {"pid":"f000002","name":"joi","age":"33","city":"lnd","occ":"runner"}, {"pid":"f000003","name":"kloi","age":"34","city":"nyc","occ":"writer"} ] }' ) now wanted display pids, did query below in mysql. select sid, json_extract(doc, '$.doclist[*].pid') pid mat.tbl_temp; but getting result - sid shortlisted m000001 ["f000001", "f000002", "f000003"] but want result below sid ...

javascript - how to add check box in "select 2 dropdown" -

hello new page designing please me current query <javascript> <body> <select id="companyname" class="form-control__" style="width:100%;height: 34px;" onchange="" tabindex="4"> <option value="">select </option> </select> </body> <script> $(document).ready(function(){ $('#companyname').select2('close'); }); </script> try use plugin https://github.com/wasikuss/select2-multi-checkboxes example: $('#companyname').select2multicheckboxes({ placeholder: "choose multiple elements", }) http://jsfiddle.net/wasikuss/gx93rwnk/

mysql - SQL query to display available seats - Java -

i have table called rooms , how table looks like create table rooms ( id int auto_increment, roomnumber varchar(32) not null, availableseats int not null, primary key (id) ) in code below, able fill combo box room numbers in database. want is, when select room number, available seats room number must update. for instance, when select roomnumber 4, available seats 4 roomnumber 3, available seats 2 how can achieve ? query // query fetch room numbers combo box public void findroom() { string query = "select * rooms"; try { statement stmt = conn.createstatement(); resultset rs = stmt.executequery(query); while(rs.next()) { string getroomnumber = rs.getstring("roomnumber"); findroom.additem(getroomnumber); } } catch(exception ex) { ...

JavaScript RegEx How to match only numbers seperetad by non-numeric characters? -

i'm beginner in javascript. , have problem in regex. var string="find mean, median, mode of following data. concatenate 3 averages , data values @ positions 176 , 345." var pos=string.match(). how save "values @ positions 176 , 345 " numbers in text pos using regex? var string="find mean, median, mode of following data. concatenate 3 averages , data values @ positions 176 , 345." var pos=string.match(/\b\d+\b/g); console.log(pos); this store numbers in array pos

node.js - How to run node js even on server restart -

i built nodejs project , runs smoothly. use forever service running file in background if server restarted daemon won't started automatically , should started manually. want run daemon server rebooted you add forever command in .bash_profile every time server restart, command executed. nano ~/.bash_profile forever start app.js # add command file, or whatever command using. source ~/.bash_profile # important, else changes not take effect next time, on server restart, command run, hence creating daemon of node script. note: maybe not best solution, 1 have got. update as @dlmeetei, suggested, can start nodejs app service can use features given linux service. first create file in /etc/systemd/system , like: touch /etc/systemd/system/[your-app-name].service nano /etc/systemd/system/[your-app-name].service then, add , edit following script according relevance. [unit] description=node.js example server #requires=after=mysql.service # requires mysql serv...

mongodb - How to filters arrays in Mongo -

i have 1 post property: ingredients: ['onions', 'carrots'] i'm finding post $in adding 1 of these ingredients. but need find 'onions' or/and 'carrots'. if 'onion' and/or 'carrot' doesn't work. how this? if want check both values exist in array, use $all operator: { ingredients: { $all: ['onions', 'carrots'] }} if want check value use $in operator: { ingredients: { $in: ['onions', 'carrots'] }}

java - Shared WebDriver becomes null on second scenario using PicoContainer -

Image
i have used accepted solution here , came following code: referenced libraries: feature: feature: featurea scenario: scenarioa given when scenario: scenariob given when basestep: public class basestep { protected webdriver driver = null; private static boolean isinitialized = false; @before public void setup() throws exception { if (!isinitialized) { driver = seleniumutil.getwebdriver(configutil.readkey("browser")); isinitialized = true; } } @after public void teardown() { driver.quit(); } } stepa: public class stepa { private basestep basestep = null; private webdriver driver = null; // picocontainer injects basestep class public stepa(basestep basestep) { this.basestep = basestep; } @given("^i @ login page$") public void giveniamattheloginpage() throws exception { driver = basestep.d...

javascript - Angular4 for create UI plugin -

i want create gallery plugin. want use angular 4 or reactjs. i'm testing angular 4. plugin should callable pure js e.g. lazy initialization (e.g. after clicking on custom button). how can open modal or embed gallery in html js? maybe angular 4 not solution these kind of plugins? currently html looks like: <div id="my-app">here gallery</div> <script type="text/javascript"> settimeout(function() { document.getelementbyid('my-app').innerhtml = '<app></app>'; gallery(); }, 5000); </script> where gallery function created during compilation process: export function main(): promise<any> { return platformbrowser() .bootstrapmodulefactory(appmodulengfactory) .then(decoratemoduleref) .catch((err) => console.error(err)); } // declare global initialization function lazy initialize (<any>window).gallery = main;

excel formula - Store column name in an extra cell -

Image
by now, use =function(tablename[[columnname]:[columnname]]) . there (easy) way store columnname in cell x1 , use =function(tablename[[x1]:[x1]]) my table named tablename : columna columnb 1 2 b 3 c 4 d cell a1 = columna <-the string cell b1 = =counta(tablename[[columna]:[columna]]) cell a2 = columnb <-the string cell b2 = =counta(tablename[[columnb]:[columnb]]) my aim formulas in b1 , b2 use values in a1 , a2 . what tried yet like: =counta(tablename[[indirect(a1)]:[indirect(a1)]]) the indirect function converts text string usable cell reference or in case structured (list object) table name. =vlookup(k3, indirect(j3), 3, false) in sample worksheet illustrated above, j3 data validation list source of aa2:aa3. k3 typed value , l3 contains formula. if j3 switched table1 l3 becomes 66.

Wrong Euclidean distance H2O calculations R -

i using h2o r calculate euclidean distance between 2 data.frames: set.seed(121) #create data df1<-data.frame(matrix(rnorm(1000),ncol=10)) df2<-data.frame(matrix(rnorm(300),ncol=10)) #init h2o h2o.init() #transform h2o df1.h<-as.h2o(df1) df2.h<-as.h2o(df2) if use normal calculations, i.e. first row: distance1<-sqrt(sum((df1[1,]-df2[1,])^2)) and if use h2o library: distance.h2o<-h2o.distance(df1.h[1,],df2.h[1,],"l2") print(distance1) print(distance.h2o) the distance1 , distance.h2o not same. knows why? thanks!! it seems if h2o.distance calculates sum of squares, without taking square root: take square root standard result. distance.h2o <- h2o.distance(df1.h[1,],df2.h[1,],"l2") sqrt(distance.h2o)

ruby Screen Scraping Library for formatting times -

i wondering if there library method out there take time string of unknown format , reformat standard format (i.e. hhmm). examples of type of thing getting websites are. 1030 10:30 10pm 10pm 1030pm 10pm 1030pm 1030p.m. 1030pm. 930 930am 9am 8.30 8.30pm and sure there others. i started write method , it's getting there ( https://gist.github.com/funkytwig/b47551e98e8698ebb59310286982a6ce ) wondering if there 1 around. worth mentioning have come across websites times in same list (i.e. event listing) not consistent, think hand typed text field when input. just clarify wondering if there method in library existing, i'm not asking people debug code. i'm sharing show have done try solve problem, , see why hoping there library. try chronic . can parse whole lot of time formats, including ones gave.

key bindings - Emacs: unbind all keys of some-mode-map -

i know, can unbind keys using unbind-key . in case have know key want unbind. don't know key. want unbind keys of some-mode-map . don't want override them, want unbind them , define own keys in some-mode-map . know iterate some-mode-map , apply unbind-key , may there more straightforward solution? , don't know how iterate keymap . update tried (as suggested phils in comments) way , didn't work: (use-package neotree :config (setq neotree-mode-map (make-sparse-keymap)) (define-key neotree-mode-map (kbd "ret") 'neotree-enter) ) (use-package evil :init (setq evil-overriding-maps '((neotree-mode-map))) ) neotree-mode-map remains not cleaned. , depending on package configuration order, evil bindings gets overridden. doesn't unless redefine neotree-mode-map . know obtain desired result evil-define-key , want keep package specific settings in own configuration file. if employ evil-define-key , neotree key binding definitions in s...

Can Intel Fortan be used in Visual Studio in Ubuntu? How can I debug a Fortran program? -

i downloaded vs 2017 run fortran code in ubuntu16.04 pc. in opinion, if win 10 os can use vs edit-run-debug fortran program. vs supporting in ms system? , ubuntu user have face teminal manage "ifort". can use vs ide in ubuntu running fortran intel fortran?

javascript - Do I need the IPFS daemon to upload files from a browser? -

i'm working on project using ipfs , i'm trying create website allows users upload files directly browser ipfs. goal website front-end website whenever add file ipfs , check it's hash on https://gateway.ipfs.io/ipfs/hash-here nothing happens, made me think files not getting uploaded ipfs because i'm not running on local machine. correct? const buffer = require('safe-buffer').buffer; export default function uploadfiles(node, files) { let reader = new filereader(); reader.onloadend = () => { let bytedata = reader.result.split('base64,')[1]; let filedata = buffer.from(bytedata); node.files.add(filedata, (err, res) => { if (err) { throw err } let hash = res[0].hash console.log(hash); ///////prints hash isnt visible on //gateway node.files.cat(hash, (err, res) => { if (err) { ...

javafx - How to add child node without affecting layout of GridPane parent -

Image
i want create app using javafx. looks this: i want add zoom function chart. when click button "zoom in", app become fig2. however, have no idea achieve it. when change size of pane included chart, change grid pane size, looks this: you not want zoom considered gridpane layout. in can achieved applying transforms child of gridpane want modify. the following example demonstrates how zoom node while mouse hovering on it: private static region createregion(string background) { region region = new region(); region.setstyle("-fx-background-color:"+background); region.setprefsize(300, 100); return region; } @override public void start(stage primarystage) { gridpane gp = new gridpane(); // create background gp.add(createregion("green"), 0, 0); gp.add(createregion("dodgerblue"), 0, 1); // create region zoomed region zoomregion = createregion("red"); gridpane.setfillwidth(zoomr...

angular - Cordova camera video -

this code. quality parameter not working in samsung working fine in other mobiles . there plug-in reduce video file size . navigator.device.capture.capturevideo(onsuccess, captureerror, { limit: 1, duration: 60, quality: 0 });

javascript - Firebase functions doesn't return set-cookies header -

i know why when setting set-cookie header in firebase functions, doesn't show on browser's response headers when using firebase tools emulator. exports.test = functions.https.onrequest((req, res) => { res.setheader('authorization', 'bearer token') res.setheader('set-cookie', ['__session=ninja']) res.end() })

monitoring - How to declare a variable and reuse it in icinga2 hosts section? -

Image
for use below config icinga2 host server work: vars.health_check["my_module1"]={ host = "health_check_server_url" module = "my_module1" } vars.health_check["my_module2"]={ host = "health_check_server_url" module = "my_module2" } the problem see have redeclare same host address. when put host address outside of service below, not work , reloading of icinga2 fails: end_url = "health_check_server_url" vars.health_check["my_module1"]={ host = "$end_url$" module = "my_module1" } vars.health_check["my_module2"]={ host = "$end_url$" module = "my_module2" } i tried use vars.end_url again same scenario. how should declare variable in icinga2 . you can use host's address $address$ if host's address url resolves should work like: end_url = "health_check_server_url" ...

sql - Database model with historical data -

firstly, going explain problem using example real life. let’s company , selling different means of transport, e.g. cars, buses, trucks, trains, planes, etc. let's have around 10.000.000 different items daily changes. for each item have unique name (e.g. car audi a8 x or plane boing 747-200b y) x , y unique values. don’t worry naming because works fine. for each item have special data. data depends on type, e.g. car: dimensions (length, width, height …), powertrain, etc. planes have e.g. length, interior width, wingspan, wing area, wing sweep, etc. and problem … put data different excel files , paper database. question 1: database model better? idea #1: going create 1 table, called items going store name of product selling (e.g. car audi a8 x, plane boing 747-200b y, etc.). , in other tables ( car , plane , train …) store data cars / planes / trains. if data of e.g. car have check table car . if data of e.g. train have check table train . idea #2: should create 1 t...

javascript - Playbutton animation -

i have 1 code starts playing audio when click on image. need edit it. make when click on image should start playing audio, change image another. know how it? code: <!doctype html> <html> <head> <script type="text/javascript"> function playsound(el,soundfile) { if (el.mp3) { if(el.mp3.paused) el.mp3.play(); else el.mp3.pause(); } else { el.mp3 = new audio(soundfile); el.mp3.play(); } } </script> </head> <body> <span id="dummy" onclick="playsound(this, 'http://listen.shoutcast.com/newfm128mp3');"> <img src="https://static.wixstatic.com/media/e2aefa_1969d5f605404431bb558b4ff9e60966~mv2.png/v1/crop/x_10,y_33,w_52,h_51/fill/w_52,h_51,al_c/e2aefa_1969d5f605404431bb558b4ff9e60966~mv2.png" name="bottom-1" width="50" height="45" border="0" id=...

javascript - Why does this resource fail to load yet Jquery loads fine -

receiving following error when try add javascript file in directory: failed load resource: server responded status of 404 (not found) the resource it's failing load file called: formlogic.js form.html , in root directory. <!doctype html> <html> <head> <script src="js/jquery-1.11.0.min.js"></script> </head> <body> <p>if click on me, disappear.</p> <script src="js/formlogic.js"></script> </body> </html> both jquery js file , formlogic file in directory js formlogic.js fails load jquery loads fine. loads resource when move formlogic.js root directory , change script tag. <script src="formlogic.js"></script> i don't understand why it's unable load directory yet can load jquery file. formlogic.js contents: $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); maybe it's bec...

javascript - Scroll to position in fixed div on click -

i trying place number of articles in div, sidemenu titles when clicked scroll relative articles within div. div containing articles in fixed position. there anyway this? my html looks this: <ul> <li><a href="#1>article 1</a></li> <li><a href="#2>article 2</a></li> <li><a href="#3>article 3</a></li> <li><a href="#4>article 4</a></li> </ul> <div style="position:fixed; right:0px; bottom:0px; width:200px; height:200px;"> <div id="1">abcdefg</div> <div id="2">hijklmn</div> <div id="3">opqestu</div> <div id="4">vwxyzab</div> </div> you need use scrolltop function in order scroll fixed div. added overflow:scroll fixed div in order give ability scroll, important functionality. we offset parent element of eac...

windows - Run python on Cygwin using batch file -

i know how create batch file execute python on cygwin please tried 2 methods method 1: cd c:\cygwin64\bin bash --login -i python /home/xxxxx/snmptest.py method 2: cd c:\cygwin64\bin bash --login -i /bin/bash.exe /home/xxxxx/snmp.sh the bash file contains #!/bin/bash python /home/xxxxx/snmptest.py both fails run python script i.e. opens cygwin window. in method 2, execute bash file on cygwin , python script running. any thoughts on how accomplish after please? thanks here's batch file run on windows execute shell script named "my_shell_command" runs in cygwin: export home="/cygdrive/c/cygwin64/home/$username" export path="$home/bin:/usr/bin:$path" . .bash_profile dir="$( cd "$( dirname "${bash_source[0]}" )" && pwd )" dir="c:${dir#/cygdrive/c}" my_shell_command if (( $? == 0 )) sleep 2 else echo "" >&2 echo "hit \"enter\...

java - Making WebViews work with Master Details -

this android studio v2.3. want have master detail flow click 1 of items on list , brings me website. after looking @ different recommendations, app still force quits or "doesn't respond" whenever click items on list. please help! webpagedetailfragment.java code: package com.example.jasperzhu.moremorelearning; import android.app.activity; import android.support.design.widget.collapsingtoolbarlayout; import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import com.example.jasperzhu.moremorelearning.dummy.dummycontent; import android.webkit.webview; import android.webkit.webviewclient; /** * fragment representing single webpage detail screen. * fragment either contained in {@link webpagelistactivity} * in two-pane mode (on tablets) or {@link webpagedetailactivity} * on handsets. */ public class webpagedetailfragment extends fragment { /** * fragmen...

java - Dependency Injection And Fluent Design -

say have spring component below dependencies constructor injected (builder singleton) : @component public class housebuilder{ private windowmaker windowmaker; private doormaker doormaker; private roofmaker roofmaker; @autowired public housebuilder(windowsmaker wm, doormaker dm, roofmaker rm){ this.windowmaker = wm; this.doormaker = dm; this.roofmaker = rm; } //other methods omitted brevity } however house requires called "foundation" should passed in through constructor or set before making house begins , foundation not spring bean. i'd use builder pattern below unsure how spring. below after except want use spring: foundation foundation = new foundation(); housebuilder hb = new housebuilder(foundation) .windowmaker(args) .doormaker(args) .roofmaker(args); any advice appreciated. spring dependency injection , fluent builders not designed work together. the first way set dep...

html - Add class with :hover using CSS -

this question has answer here: assigning classes elements through css 3 answers i first cant use javascript. so question this: want able add class element when mouse hovers it. cant add styles :hover cause many. i use animate.css in page. there tons of effects, , example want add class "fadeinup" when user hovers element in page. doing javascript trivial, how css? possible add class when :hover? very simply, no. assuming got correctly, want add class. not possible. if wanted however, copy css code need on animate.css file mentioned, , apply on pseudo-class :hover . there isn't way css manipulate classes , ids directly, other pseudo-classes. hope helped!

c - Why am I getting memory location values after printing prime numbers of a particular range? -

i solving this problem: peter wants generate prime numbers cryptosystem. him! task generate prime numbers between 2 given numbers! input the input begins number t of test cases in single line (t<=10). in each of next t lines there 2 numbers m , n (1 <= m <= n <= 1000000000, n-m<=100000) separated space. output for every test case print prime numbers p such m <= p <= n, 1 number per line, test cases separated empty line. example input: 2 1 10 3 5 output: 2 3 5 7 3 5 i getting memory location values after prime numbers in output. can explain how can terminate after getting final output. here code: #include <stdio.h> int main() { int t, i, m[10], n[10], j, k, l, isprime; // t test case, m[] , n[] lower , upper value of range of prime numbers // isprime check condition true or false. j = 0; scanf(" %d \n", &t); for(i=0; i<t; i++) { scanf("%d%d",&m[i],&n[i]); } whil...

PostgreSQL: function returns multiple recordsets: how to read in c#? -

using link http://www.sqlines.com/postgresql/npgsql_cs_result_sets have created example, not work: there function: create or replace function show_cities_multiple() returns setof refcursor $$ declare ref1 refcursor; ref2 refcursor; begin open ref1 select user_id, user_name users; return next ref1; open ref2 select id, company customers; return next ref2; end; $$ language plpgsql; the 1st loop reads recordsets names , can read function. npgsqlconnection conn = new npgsqlconnection(getconnectionstring()); conn.open(); npgsqltransaction tran = conn.begintransaction(); npgsqlcommand command = new npgsqlcommand("show_cities_multiple", conn); command.commandtype = commandtype.storedprocedure; npgsqldatareader dr = command.executereader(); while (dr.read()) { ...

matplotlib - How to reverse the order of a legend when using stackplot in python? -

i have stackplot using python, , legend @ right show correct order of colours - i.e need reverse it. however, when reverse it, reverses colours, meaning colours in plot no longer correspond colours in legend. the code have follows; import matplotlib.colors colors import matplotlib.cm mplcm mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes mpl_toolkits.axes_grid1.inset_locator import mark_inset # zoom plot start , end start = 408 end = 518 num_colors = 10 cm = plt.get_cmap('gist_ncar') cnorm = colors.normalize(vmin=0, vmax=num_colors-1) scalarmap = mplcm.scalarmappable(norm=cnorm, cmap=cm) fig = plt.figure() ax = fig.add_subplot(111) # old way: ax.set_prop_cycle(color=[cm(1.*i/num_colors) in range(num_colors)]) # new way: # ax.set_prop_cycle([scalarmap.to_rgba(i) in range(num_colors)]) ax.stackplot(range(0, 672), gen_type_summary[0,range1:range2], baseline="zero", linewidth=0.1) ...

android - ShortDynamicLink is not generating short link for dynamic links -

creating dynamic link dynamiclink dynamiclink = firebasedynamiclinks.getinstance().createdynamiclink() .setlink(uri.parse("http://shaharapp.in/")) .setdynamiclinkdomain("https://cuh8g.app.goo.gl/") // open links app on android .setandroidparameters(new dynamiclink.androidparameters.builder().build()) // open links com.example.ios on ios .builddynamiclink(); dynamiclinkuri = dynamiclink.geturi(); after this, long dynamic link. passing dynamiclinkuri shortlinktask task<shortdynamiclink> shortlinktask = firebasedynamiclinks.getinstance().createdynamiclink() .setlonglink(dynamiclinkuri) .buildshortdynamiclink(); shortlinktask.addoncompletelistener(new oncompletelistener<shortdynamiclink>() { @override public void oncomplete(@nonnull task<shortdynamiclink> task) { if (task.issuccessful()) { ...

javascript - How to place Svg Circle into middle of the page -

i'm trying place large svg circle middle of page - horizontally , vertically. not working, tips? here code - using jade , scss: jade: .logo svg.logo__svg circle( r=300 style="fill:none;stroke:white;stroke-width:1;") scss: .logo{ height: 80%; width: 80%; position: relative; top: 50%; left: 50%; transform: translate(-50%, -50%); @include element('svg'){ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 100%; width: 100%; } } you have many offsets , transforms. body { margin: 0; background-color: rebeccapurple; } .logo { width: 100vw; height: 100vh; position: relative; } .logo__svg { width: 402px; height: 402px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } <div class="logo"...

confluence - Form variables inside metadata report -

i'm creating confluence page template uses variables capture data user. once saved, these variables displayed on parent page. so far i've been able create variables: $summary $requester $etc however, in using metadata plugin on new page, find unable define values of variables when creating new page. and unable metadata-report running in such way captures variables... i can have form variables , no report (because i've not added metadata), or can have metadata , no form variables... any idea how both play nice?

javascript - CSS style not reverting using Javacript -

i trying set css property , forth using javascript depending on value @ time. class name 'menu' set hidden on page load. when call set visible successful. however, when call again change doesn't set hidden. seen set visible. let menu = document.queryselector('.menu'); if (menu.style.visibility = 'hidden') { menu.style.visibility = 'visible'; console.log('visible'); // shows this. } else { menu.style.visibility = 'hidden'; console.log('hidden'); // doesn't here when .menu visible. } i confused why can first not second. have tried having specific else: else if (menu.style.visibility = 'visible') tried using setattribute it's same outcome. i need able switch , forth. kindly use below condition if (menu.style.visibility == 'hidden') //change ==

Android Calendar Month/Week view like this -

Image
i'm making android app, needs same example below. i'm stuck @ calendar/date picker, need couple of tips , tricks turn in library, or there one?

How can I dynamically convert integer 16ths of inch to fractional inch using mysql code? -

i have stored values size integers represent 16ths of inch. example: 1 = 1/16" 4 = 1/4" 8 = 1/2" 16 = 1" 24 = 1 1/2" 32 = 2" i use 2 column table lookup of integer value , return calculated fraction of inch. prefer make more dynamic , have mysql select code or mysql function conversion on fly , not need store statically converted values every possible integer value. this solution appears close reverse of need deals decimals vs integers not exact reverse. the goal integer value input string output being division correct representation of fractional inch (i.e. 12 should 3/4", not 12/16" , 28 should 1 3/4", not 28/16") the converted value isn't going used in where clauses or indexed not searchable value. output of results only. expert ideas on how tackle math , conversion or there existing solution somewhere? update solution implemented uses selected answer below: concat( if(sixteenths > 15, /* in...

javascript - How can run my fuction via cron job -

i want run function cron job don't know how can here code <script type="text/javascript"> function start_fetch() { if(i<=21) { link='http://alhyipmonitors.com//admin/fr.php?mid='+linkid[i]; window.open(link, '', 'width=600, height=600, top=0, left=800'); document.getelementbyid('result').innerhtml='<div class="red">please wait<br/>'+i+' / 21</div>'; i++; settimeout('start_fetch()',15000); } else { i--; document.getelementbyid('result').innerhtml='<div class="green">completed<br/>'+i+' / 21</div>'; } }

Windows authentication in C# without password -

i have windows forms project uses principalcontext.validatecredentials method everything works fine, but... first, user logs in windows environment using his/her windows username , password. then, user logs in app using his/her windows username , password. duplicate work isn't ? my goal create ssms's windows authentication (if connect db selecting windows authentication doesn't ask windows password because logged in). want logged-in user's username , (hash, guid, sid etc.) , use info authenticate user. is there way achieve ?

elasticsearch - More like this query across types with different field names? -

can more query used search across types different field names? example, suppose have 2 different types (e.g. type1 , type2), both of have text field, have different names (e.g. type1_text , type2_text). following query not produce results: get /index-name/_search { "query": { "more_like_this" : { "fields" : ["type2_text"], "like" : [ { "_index" : "index-name", "_type" : "type1", "_id" : "1", "fields": ["type1_text"] } ] } } } (it work if change mappings use same field names in both types.) is there way cross-field comparisons in elasticsearch?

php - URI segment can't be saved in database -

i trying insert new record in database table. function insert this: public function comment($id_b,$comment){ $id_u = $this->session->userdata('userid'); $result=$this->db->insert('comments',['id_book'=>$id_b, 'id_user'=>$id_u, 'comment'=>$comment] ); return $result; } the controller function comment called: public function comment() { $this->load->model('model'); $id_b= $this->uri->segment('3'); $comment=$this->input->post('comment'); $this->model->comment($id_b,$comment); } the uri segment i'm trying id . problem can't saved in database, has value null . i tried echo $this->uri->segment('3'); , returns id, don't understand why saved null value in database. when tried this: (int)$this->uri->segment('3'); , got error: error number: 1452 cannot add or update child row: foreign key constraint fails ( db . comments , c...

How to check a specific format of string in C -

i have following code accepts string resembles hours.. want check if string format xx-yy xx resembles hour yy .. code worked fine when input "02-13-" returns true want return false cause it's not correct (cause has - @ end) bool hourisvalid(char * hours) { int openh = 0; int closeh = 0; if ((sscanf(hours, "%d-%d", & openh, & closeh) == 2) && openh >= 0 && openh <= 24 && closeh >= 0 && closeh <= 24) { if (openh >= closeh) { return false; } return true; } else { return false; } } the solution depends on how "pedantic" code has when deciding if input valid or not. example, might expect "2-14" , "02 - 15" , " 2-14 " valid, or might not. depends. if want pedantic version accepts exact format "dd-dd" no leading or trailing characters or white spaces , two-digit format each hour value, check string follows b...

Needing Clarity on SQL Join Query -

having trouble understanding query, particularly in subquery. don't accomplishing. appreciated. thanks # find largest country (by area) in each continent. show continent, # name, , area. select continent, name, area countries area = ( select max(area) countries b a.continent = b.continent ) consider following subset of countries data: continent country area north america usa 3718691 north america canada 3855081 north america mexico 761602 europe france 211208 europe germany 137846 europe uk 94525 europe italy 116305 this correlated query behaves follows: reads first row returned outer query (north america, usa, 3718691) runs subquery correlates a.continent, north america, , returns 3855081 maximum area in north america. does equality checks see if 3855081 matches area on row we're working on. it doesn't match next row in outer query read , start on @ step 1 time working on second ro...

python - How to use a variable as part of url in robot framework -

i trying go url using variables in path. code sample follows: go http://localhost:5000/api/v1/${ind_id_r} when try run it, tries open url , i.e " http://localhost:5000/api/v1/ ${ind_id_r}" instead of replacing variable ${ind_id_r} in url. is there way make robot framework replace variable t value , navigate correct url? thanks in advance well, solution use catenate function , pass value url. ${req} catenate separator= http://localhost:5000/ ${ind_id_r} go ${req}

Email Verification Mailgun, Parse, Swift 3 -

i have mailgun account , xcode project using parse sign users. want implement email verification when user signs up. want simple message says "thank signing up! please press link below verify email address." know how send email message user, i not know how make link verify user's email address , change automatic "emailverified" boolean column in parse equal true. how do this? have copied code send email below: let mailgun = mailgun.client(withdomain: "****.com", apikey: "key-*****") mailgun?.sendmessage(to: "user *email*", from: "*connected email*", subject: "verify email address", body: "thank signing up! please press link below verify email address.")

Oracle SQL - How to get diff between values in same row, no unique ID -

i learning oracle sql. i need determine time between each purchased/return transaction given product. a sample of data shown below. there no unique transaction identifier linking purchase return however, can assume return following purchase (based on transactiontime) same transaction. can please let me know how go solving this? sample sql statement appreciated. product transactiontype transactiontime purchase 18-aug-17 10.15.56.000000 return 18-aug-17 10.30.21.000000 purchase 18-aug-17 11.10.35.000000 return 18-aug-17 11.12.52.000000 b purchase 18-aug-17 10.15.56.000000 b return 18-aug-17 10.22.56.000000 b purchase 18-aug-17 10.30.21.000000 b return 18-aug-17 10.31.21.000000 you can use lead() : select t.*, (next_ttime - transactiontime) time_to_return (select t.*, lead(transactiontype) on (partition product order transactio...

Dictate order that operands are evaluated in c -

the statement puts("a") + puts("b") undefined. because not specified in c standard whether these ought executed left right or right left get a b or b is there clean way dictate order of operations in expression? the thing can think of use compound statement such as ({ int temp = puts("a"); temp += puts("b"); temp; }) though non-portable , little longer hoping. how best achieved? if declare int variable before expression, can force order portably comma operator while computing sum inside expression: int temp; ... (temp = puts("a"), temp + puts("b")) as specified in c standard: 6.5.17 comma operator syntax expression: assignment-expression expression , assignment-expression semantics the left operand of comma operator evaluated void expression; there sequence point between evaluation , of right operand. right operand evaluated; result has type , ...