Posts

Showing posts from February, 2012

c# - Adding to a table using MVC 5, and reset Id after deleting records -

i have 2 questions: first wrote code add doctors database, @ beginning code worked fine after adding validation doctor information not added table.. when press add button url goes to: /doctors/save why data not saved in database? , why after pressed add button program not redirect me add view? in controller there add() action add view contains adding form.. save() action html.beginform("save","doctors") inside add view.. here code: public actionresult add() { return view(); } [httppost] [validateantiforgerytoken] public actionresult save(doctor doctor) { if (!modelstate.isvalid) { var viewmodel = new doctorviewmodel { doctor = doctor }; return view("add", viewmodel); } if(doctor.id == 0) { _context.doctors.add(doctor); _context.savechanges(); return redirect("add"); } else ...

algorithm - List Occurence wise read c# -

i have class this public class roomdetails { public int roomindexid {get;set;} --(this no of rooms) public int roomcategoryid {get;set;} -- (this no of category room have) public decimal roomprice{get;set;} public string roomcategory{get;set;} } so have roomdetails list this(data) 1,1,200,single bed 2,1,250,double bed 2,2,400,double bed view 2,4,530,tripple bed 3,1,530,tripple bed 3,2,600,triple large bed so want read list following procedure. 1,1,200,single bed 2,1,250,double bed 3,1,530,tripple bed 1,1,200,single bed 2,1,250,double bed 3,2,600,triple large bed 1,1,200,single bed 2,2,400,double bed view 3,1,530,tripple bed 1,1,200,single bed 2,2,400,double bed view 3,2,600,triple large bed 1,1,200,single bed 2,4,530,tripple bed 3,1,530,tripple bed 1,1,200,single bed 2,4,530,tripple bed 3,2,600,triple large bed please ask if have problem regrading question. this example my data list this ...

In Spring data rest how to allow user to set value but ignore it in get request -

Image
in scenario i'm exposing following entity in spring data rest: public class user implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.auto) @column(name = "user_id") private long userid; @notnull @size(min = 1, max = 50) @column(length = 50, unique = true, nullable = false) private string username; @jsonignore @notnull @size(min = 60, max = 60) @column(name = "password",length = 60) private string password; .... i password not exposed in response when performing on ../users/1 allowing hal browser know when performing post request needs set password. when i'm using @jsonignore hal browser not know needs set password field: how can it? possible? have tried adding @jsonignore in getter method instead of private string password property? ... @notnull @size(min = 60, max = 60) @column(name = "password",length = 60) private string password; ... @jsonigno...

ios - What is the use of Error, throws and catch? -

i'm trying head around use of errors in swift example have code: import uikit class viewcontroller: uiviewcontroller { enum someerror: error { case badword } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. { try checkword() } catch someerror.badword { print("error!") } catch { //this defualt statement print("something weird happened") } } func checkword() throws { let word = "crap" guard word != "crap" else { throw someerror.badword } print("continuing function") } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } } the checkword function terminate if word bad. same behaviour can achieved with: ...

java - Coordinate multiple threads after N executions -

i have java/groovy multi threaded process want "synchronize" after n executions: - shared counter decremented after each thread execution - goal reset counter once reaches 0 while no other thread accessing it. i tried readwritereentrantlock looks have race condition decrement phase. here test code public static void main(string[] args) { atomicinteger counter = new atomicinteger(decrementer.max_size) readwritelock lock = new reentrantreadwritelock() (int = 1; <= 10; i++) { decrementer d = new decrementer(counter, lock) new thread(d).start() } } public class decrementer implements runnable { public final static int max_size = 5 private readwritelock lock private atomicinteger counter public decrementer(atomicinteger counter, readwritelock lock) { this.counter = counter this.lock = lock } public void run() { while (true) { try{ lock.readlock().lock() ...

UWP (C#): Adding 3D object to app (Library Suggestion) -

i add 3d representation of imu app, i'm new uwp/app development , i'm not sure fastest/easiest way implement in image below. which 3d libraries recommend in order kind of output? 3d representation of imu i add 3d representation of imu app, i'm new uwp/app development , i'm not sure fastest/easiest way implement in image below. as far know, there no available library now. if want add 3d representation of imu app, can leverage direct3d api (it requires c++ coding). , there helper class library use: directxtk . also,if beginning build app. unity choice you. details using unity in uwp, please refer this case .

javascript - Resolve promises one after another (i.e. in sequence)? -

consider following code reads array of files in serial/sequential manner. readfiles returns promise, resolved once files have been read in sequence. var q = require("q"); var readfile = function(file) { ... // returns promise. }; var readfiles = function(files) { var deferred = q.defer(); var readsequential = function(index) { if (index >= files.length) { deferred.resolve(); } else { readfile(files[index]).then(function() { readsequential(index + 1); }); } }; readsequential(0); // start! return deferred.promise; }; the code above code works, don't having recursion things occur sequentially. there simpler way code can re-written don't have use weird readsequential function? originally tried use q.all , caused of readfile calls happen concurrently, not want: var readfiles = function(files) { return q.all(files.map(function(file) { return readfile(file); })); }; update 2017 : use a...

python - How to access the release date or year from an mp3 file with eyed3 and python2.7 -

i'm trying access mp3 tags release year mp3 file's album, stored in id3v2 tags under tyer. i found out attributes track_num located in class eyed3.core.tag then python command looks this: audiofile = eyed3.load(mp3_file) track_num = audiofile.tag.track_num[0] now year located in class eyed3.core.date(year,...) so thougt be: year = audiofile.date.year but i'm unfortunately wrong... msg: attributeerror: 'mp3audiofile' object has no attribute 'date' does know how works? or, more generic question: how can of available attributs? my plattform windows 10 pro. thanks it's quite strange had post first before find information myself:-) it's in class eyed3.id3.tag.tag and named: getbestdate() the whole necessary code then: import eyed3 mp3_file = "the_file_path" audiofile = eyed3.load(mp3_file) year = audiofile.tag.getbestdate() for more information see eyed3.pdf file https://media.readthedocs.org...

xml - How to store temenos t24 data -

we have masking data project @ temenos t24 banking system oracle database. we didn't start read data until now.we had informed temenos t24 store data xml columns in database or xml files . these informations correct ? t24 stores data xml 2 columns each table recid - primary key xmlrecord - data

html - grouping product by php -

Image
i beginning php developer , have found error internet doesn't have resource me reference. doing online shopping project multiple vendors ebay or others. need create shopping cart grouped vendors, pictures shown . products should show in table grouped different vendors. have no idea how that, after have done simple shopping cart coding..... sample shopping cart <div id="product_box"> <form action="" method="post" enctype="multiple/form-data"> <table align="center" width="700" bgcolor="white"> </tr> <tr align="center"> <th>delete</th> <th>product(s)</th> <th>shop</th> <th>single price</th> ...

c# - EF Core returns only first record of a list unless FK entities are reset -

i facing same issue described in question . problem: method getallconferences() returns correctly conferences db, when return result view controller return ok(triplistvm) inly first collection item returned client. on otehr side, setting null fk references (as pointed out in question above) can return correctly entities client, not seem me proper way of proceeding. edit: solution simpler though. in code below (i leave in original form others see it) not mapping fk entities inside viewmodel dto objects, returning model entity itself. reason why needed null inner references make work. by returning dtos objects, works properly. have 3 entities involved 1-many relationships: public class conference { public int id { get; set; } [required] [maxlength(50)] public string name { get; set; } public icollection<venue> venues { get; set; } public int? locationid { get; set; } public location location { get; set; } } public class venue { pu...

android - RenderScript: Assertion failed in rsObjectBase.cpp -

i saw lot of following error messages in logcat output of app: e/renderscript: rsassert failed: msysrefcount > 0, in frameworks/rs/rsobjectbase.cpp @ 147 despite of app did work crash sigsegv after starting renderscript code couple of times. i able track down problem (well, think). had function in renderscript code returned rs_allocation , defined , used this: rs_allocation gtmp1; rs_allocation gtmp2; static rs_allocation blur(float size) { if (some_criterion()) return gtmp1; else return gtmp2; } ... rs_allocation tmp = blur(size); after changing function definition following error message went away , app has not crashed since: static bool blur(float size) { if (some_criterion()) return false; else return true; } ... bool blurred = blur(size); rs_allocation tmp = blurred ? gtmp2 : gtmp1; now question is, why make difference? after rs_allocation defined int pointer in rs_types.rsh . nothing fancy should happening...

pdf generation - Wkhtmltopdf Snappy - Set Page Borders for all Pages -

i using laravel-snappy generating pdfs wkhtmltpdf. want add border in pages created in pdf file. @ moment, have added css: body.pdf { border: 1px solid #000; } my pdf html this: <html> <head> <title>{{ $title }}</title> </head> <body class="pdf"> ..... </body> </html> with above css, border shows fine if single page pdf. however, when has multiple pages, border breaks @ bottom of first page , no more border shows page 2 onwards after page-break. read documentation , dont think there feature add borders using setoption() . is there way resolve border appears in pages when pdf generated? please take @ here , can find available options available including border. you didn't mentioned how used page break. i using way div.page { page-break-after: always; page-break-inside: avoid; } working fine me

java - How to output one element of an Array List? -

for assignment have demonstrate removing user array list (done) , going through array list using iterator , instead of removing user list, must output 1 specific user list. question similar other question removing element different in way i'm asking how iterate through list , output 1 user opposed removing user form list. have tried using while loop includes if statement , uses .next() function doesn't seem outputting 1 user still outputs users. share relevant code reproducing part of program: main class (used call method) package main; public class main{ public static void main(string[] args) { system.out.println("***********iteration of administrators***********"); usergroup2 usergroupobject2 = new usergroup2(); (user secondusergroup : usergroupobject2.getusergroup()) { usergroupobject2.getuseriterator(); system.out.println(secondusergroup.tostring()); } } } } usergroup2 class (where array list has been created) package main; impo...

java - Using int[] arrays to manipulate each other through nested loops -

what trying use 1 method generate 30 random numbers 0-15 , method count how many times each number prints , put in second array. each position in second array corresponds number in array is. if = [0] , 0 shows 3 times, should 3 , on. so far, have gotten this. seems happening counts number of times 15 shows (the last number of array). though wrong. don't see i'm doing wrong. there must wrong logic. import java.util.arrays; public class frequencyofnumbers { public static void main(string[]args){ system.out.println(arrays.tostring(randomnums())); system.out.println(arrays.tostring(sortednums(randomnums()))); } public static int[] randomnums (){ int[] random = new int[30]; for(int i=0;i<random.length;i++){ double randnum = math.random() * 16; random[i] = (int)randnum; } return random; } public static int[] sortednums(int[] sort){ int[] numvals = new int[15]; for...

swift - iOS: GooglePlaces API error -

i getting error when trying use sample code google places getting started link error: current place error: operation couldn’t completed. internal error occurred in places api library. i calling function on viewdidload. created ibaction code make sure wasn't timing issue. got same error way well. placesclient.currentplace { (placelikelihoods, error) in guard error == nil else { print("current place error: \(error!.localizeddescription)") return } if let placelikelihoods = placelikelihoods { likelihood in placelikelihoods.likelihoods { let place = likelihood.place print(place.name) } } } i have created new project in firebase, created new project in google dev console. created new api key, enabled google maps , google places api. added corelocation framework, pods date. should not hitting limits me learning. have location when in use set plist ...

java - Generically-typed interface for which lambdas can be used? -

i'm still new lambda expressions, , i've been trying practice them in order better understand how work. came across pdf online few exercises practice: http://www.java-programming.info/tutorial/pdf/java/exercises/exercises-lambdas-1.pdf . on last problem, , having difficulty understanding needed accomplish it. here code have: interface twoelementpredicate <e> { boolean bettercheck(e e1, e e2); } public class lambdapractice4 <e> { public static void main(string[] args) { car car1 = new car(50); car car2 = new car(100); employee worker1 = new employee(500, "john"); employee worker2 = new employee(1000, "tom"); string str1 = "string"; string str2 = "secondstring"; //these 3 lines not work, due duplicate variables. thought lambdas functions though? twoelementpredicate<string> betterelement = (s1, s2) -> { return s1.length() > s2...

swift - CoreImage - how to isolate one color -

Image
i'm wondering if there's way isolate given color coreimage? given input image 1 below, color #d61915 , threshold 10% : desaturating image easy ciphotoeffectmono or ciphotoeffectnoir removing non-red parts might not trivial. can point me right filter/combination of filters use?

javascript - Can't append a link element to an iframe with jQuery -

i'm building web app make business more automated html/css/jquery in front end , python in backend . i wrote easy script jquery call route ajax , recieve data json , after parse , return list of iframes depending on it's length : if have 20 items in list , want 5 items per page, create 4 pages , put 5 iframes in each link . here's code responsible feature : $('.pagecontent').empty() (var = 0; < vidpagelist.length; i++){ var videourl = vidpagelist[i].videolink var posturl = vidpagelist[i].postlink console.log(posturl) $('<iframe src ="'+videourl+'" class = "videoentry" width = "360" height = "250"></iframe>').appendto( ".pagecontent" ) $('<a class = "postlink" href = "'+posturl+'...

If docker uses the underlying linux os, why specify the OS in the FROM line of a Dockerfile -

i've read on linux, docker uses underlying linux kernal create containers. advantage because resources aren't wasted on creating virtual machines each contain os. i'm confused, though, why dockerfiles specify os in line of dockerfile. thought using underlying os, os wouldn't have defined. i know happens if os specified doesn't match os flavour of machine it's running on. if machine centos dockerfile has from debian:latest in first line, virtual machine containing debian os created. in other words, result in performance reduction because needs create virtual machine containing specified os? i'm confused, though, why dockerfiles specify os in line of dockerfile. thought using underlying os, os wouldn't have defined. i think terminology may little confused. docker indeed uses host kernel , because docker nothing way of isolating processes running on host (that is, it's not sort of virtualization, , can't run different...

button - Android Menu not Showing -

i'd make menu delete option. actual delete functionality isn't made yet because @ moment can't see top bar in app. main layout (activity_main.xml): <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="billy.cs436.placebadgesapp.mainactivity"> <button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/newplace...

RPostgreSQL insert rows without all columns into db -

i'm trying insert rows representing not columns of postgres database. in particular, seeking insert columns except timestamp column has default set current timestamp. i tried following: dbwritetable(con, 'raw_results', df, append = true) however, returned error indicated 1 of columns (not timestamp) not appropriate format timestamp. i tried writing out insert statement: query_string = "insert raw_results (col1, col2) values...." dbgetquery(con, query_string) this returns warning message: warning message: in postgresqlquicksql(conn, statement, ...) : not create executeinsert how can simple insert postgres db via r?

r - data.table filter list column for empty values -

can filter list-column in data.table rows empty lists? library(data.table) dt = data.table(a = c(1, 2, 3), b = list(c("a", "b"), character(0), c("c", "d", "e"))) > dt b 1: 1 1,2 2: 2 3: 3 1,2,3 i.e. expected result > dt[filter(b)] b 1: 2 the obvious filtering doesn't work > dt[length(b) == 0] empty data.table (0 rows) of 2 cols: a,b > dt[length(b[[1]]) == 0] empty data.table (0 rows) of 2 cols: a,b i thought might able define function result in right boolean value, have use group make work, doesn't work in filter argument is_null_list = function(l) is.list(l) & length(l[[1]]) == 0 > dt[, is_null_list(b), a] v1 1: 1 false 2: 2 true 3: 3 false > dt[is_null_list(b)] empty data.table (0 rows) of 2 cols: a,b i guess more general question also, can filtering done on data.table list columns? suspect answer no can't key list, thought worth asking. thanks ...

How to run Python Spark code on Amazon Aws? -

i have written python code in spark , want run on amazon's elastic map reduce. my code works great on local machine, confused on how run on amazon's aws? more specifically, how should transfer python code on master node? need copy python code s3 bucket , execute there? or, should ssh master , scp python code spark folder in master? for now, tried running code locally on terminal , connecting cluster address ( did reading output of --help flag of spark, might missing few steps here) ./bin/spark-submit --packages org.apache.hadoop:hadoop-aws:2.7.1 \ --master spark://hadoop@ec2-public-dns-of-my-cluster.compute-1.amazonaws.com \ mypythoncode.py i tried , without permissions file i.e. -i permissionsfile.pem however, fails , stack trace shows on lines of exception in thread "main" java.lang.illegalargumentexception: aws access key id , secret access key must specified username or password (respectively) of s3n url, or setting fs.s3n.awsaccesskeyid or fs...

What is the most appropriate type of variable to use when coding a game's location? Boolean/String/Some other? (java) -

first post hope appropriate type question site. if not i'd appreciate if direct me more appropriate place. i'm extremely new @ programming. did bit in high school , have decided relearn starting making text-based survival game in java7 using eclipse. right i'm coding location superclass. particular function need this: needs able keep track of of 9 regions user "is in" (which used in large number of other classes many various purposes. location class includes functionality accepting user input move new region, among various other things.) way started making boolean variable each region , whenever transition should occur variable set true. i'm wondering if efficient way this. have take string inputs, run method standardize various acceptable answers one, , run through switch statement makes corresponding boolean variable true? would simpler keep track of location single string variable gets set whatever region player in? or more cause errors or complicat...

r - How to specify global chunk option in a rmarkdown website? -

it possible create website several rmarkdown files. each rmarkdown file, can specify global options like: ```{r setup, include=false} knitr::opts_chunk$set(echo = false, message=false, warning=false) ``` if want apply these options rmd files, can put same code in each file. i know if possible put code somewhere can shared every rmd files. in fact, sometimes, want make change (for example set echo = true), , want once entire website. you can include child document ```{r, child="_setup.rmd"} ``` at beginning of each rmd file.

angularjs - Angular ui-router bound state to URL -

i'm struggling counfiguration of $stateprovider , $urlrouterprovider days now. my problem is, in fact, after use $state.go() , state changes normally, url in browser stays same ( #/ ). additionaly, when set $urlrouterprovider.otherwise('home'); option, after every $state.go() router redirects /home , no matter state picked. my configuration: stateconfiguration.$inject = ['$stateprovider', '$urlrouterprovider']; function stateconfiguration($stateprovider, $urlrouterprovider){ $urlrouterprovider.otherwise('home'); addstate("state1", "/state1", "<example-page></example-page>"); addstate("state2", "/state2", "<example-page2></example-page2>"); addstate("register", "/register", "<register-page></register-page>"); addstate("error", "/error", "<error-page></erro...

javascript - An infinite loop caused because of two getters? -

the following code executes infinite loop (prints getter1 once, , getter2 until stopped): var person1 = { _age: 42, age() { console.log("getter1"); return this._age; } }; object.defineproperty(person1, "_age", { get: function() { console.log("getter2"); return this._age; } }); console.log(person1.age); // true what causes it? (note: i'm aware fact declared 2 different getters). it's not infinite loop, infinite recursion. you're return this._age inside getter _age , accessing this._age implicitly calls getter again. note once you've defined getter called _age old value of _age (42) overwritten. there no property value 42 anymore. if want create getter returns value of property can't getter same property, name getter other _age : var person1 = { _age: 42, age() { console.log("getter1"); return this._age; } }; object.defineproperty(per...

C# WebClient not posting data correctly to PHP script -

c#: using (webclient client = new webclient()) { byte[] response = client.uploadvalues("http://example.com/api/server/key", new namevaluecollection() { { "key", key } }); string result = encoding.utf8.getstring(response); console.writeline(result); } php: $key = $_post["key"]; echo($key); when runs, php $_post array never has value posted it. meaning echo line has no output. also, yes, 'key' have value, cropped out in example. i not sure, expression new namevaluecollection() { ... } think should do. you should explicit , namevaluecollection values = new namevaluecollection(); values.add("key", key); byte[] response = client.uploadvalues("http://example.com/api/server/key", values); searching object initializers reveals ...

python - Telnet session to ESG Signal Generator -

i trying control signal generator using python. need change amplitude , frequency.`my code below: import telnetlib host = "169.145.1.1" timeout = 5 port = 5023 tn = telnetlib.telnet(host, port , timeout) tn.read_until("scpi>", timeout) tn.write('freq 3ghz\r\n') tn.read_until("scpi>", timeout) tn.write('ampl 10dbm\r\n') tn.read_until("scpi>", timeout) tn.close()` when open telnet session directly on port 5023 able change freq , amp not using script above. debug session shows telnet connection successful , did send commands nothing changes on sig gen. thank you i figure out. need add \r\n after each command , not \n. sig gen values changed once implemented change. updated script. thanks

non meaningful operation for fractor error when storing new value in data frame: R -

i trying update a value in data frame getting--what seems me--a weird error operation don't think using. here's summary of data: > str(us.cty2015@data) 'data.frame': 3108 obs. of 15 variables: $ statefp : factor w/ 52 levels "01","02","04",..: 17 25 33 46 4 14 16 24 36 42 ... $ countyfp : factor w/ 325 levels "001","003","005",..: 112 91 67 9 43 81 7 103 72 49 ... $ countyns : factor w/ 3220 levels "00023901","00025441",..: 867 1253 1600 2465 38 577 690 1179 1821 2104 ... $ affgeoid : factor w/ 3220 levels "0500000us01001",..: 976 1472 1879 2813 144 657 795 1395 2098 2398 ... $ geoid : factor w/ 3220 levels "01001","01003",..: 976 1472 1879 2813 144 657 795 1395 2098 2398 ... $ name : factor w/ 1910 levels "abbeville","acadia",..: 1558 1703 1621 688 856 1075 148 1807 1132 868 ... $ lsad : factor w/ 9 levels ...

recursion - Appending list in lisp -

in lisp, appending lists as: (setq newlist (append (side b)(this b) (that b) )) this appends required list as: (1 0 0 0 2 0 4 0 6 0) want this: ((1 0)(0 0)(2 0)(4 0)(6 0)) what should required format. please post code examples in lisp. so in fact need restructure elements after have appended it: (loop :for (e1 e2) :on '(1 0 0 0 2 0 4 0 6 0) :by #'cddr :collect (list e1 e2)) ; ==> ((1 0) (0 0) (2 0) (4 0) (6 0)) suggested reading loop black belts , section should pay attention i've used here "looping on collections , packages" , "destructuring variables". chapter practical common lisp read most. whole book every lisper should know it.

Haskell: How to change algorithm to work on any size of list? -

i have code: project= [ [(a,b),(c,d),(e,f)] | a<-[1..5], b<-[1..3], c<-[1..5], d<-[1..3], e<-[1..5], f<-[1..3] , a*b + c*d + e*f <6 , + c + e == 5 , b == 3 || d==3 || f==3 ] x=take 1 project main = print $ x it return list of 3 pairs [(x,y),(x,y),(x,y)] . there 3 conditions: if sum x must 5. if sum x*y less 6. there @ least 1 y equal 3. now, want same algorithm work longer list example 10 pairs. how should that? here: project n = [ x | x <- replicatem n $ lifta2 (,) [1..5] [1..3] , sum (map (uncurry (*)) x) < 6 , sum (map fst x) == 5 , ((==3) . snd) x ] main = print $ take 1 $ project 3 or so: project n = filter (any ((==3) . snd)) $ filter ((==5) . sum . map fst) $ filter ((<6) . sum . map (uncurry (*))) $ replicatem n $ lifta2 (,) [1..5] [1..3]

Cordova geolocation plugin not working on android device -

i'm using cordova geolocation plugin. when run index.html on browser can see location on map. when run project on android device cant anything. see white page. i'm using android version kitkat. instruction https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/index.html link. tried way questions. doesnt work. how can solve problem? <!doctype html> <html> <head> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <script src="https://maps.googleapis.com/maps/api/js?key=aizasyc-id_zlczqktymwi2xrrmulxygozcuyhk"></script> </head> <body> <div id="map" style="width:500px;height:500px;"> </div> ...

Why does the for-loop break when iterating through a multidimensional array? -

what i'm trying create editable calendar made of arrays. first create variables: import uikit ///////////////////////////////////////////////////////////////////// // variables var username = "string" var bedtime: int = 0 var waketime: int = 7 var sleepmonth = "string" var quantifiedmonth: int = 1 then calendar via multidimensional arrays: var day0: [int] = [0] var day1: [int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] var day2: [int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] var day3: [int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] var day4: [int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] var month0 = [[0]] var january = [day0, day1, day2, day3, day4] var february = [day0, day1, day2, day3, day4] var march = [day0, day1, day2, day3, day4] var apr...

c++ - Does the compiler avoid a copy when returning a string that is taken as const reference? -

i wander if compiler optimize away copy in following situation. have class resource member string may few kb large. want have public member of class access string , not sure if should have member returning reference or value. suppose choose return value so class { public: a(); ~a(); std::string getstring() { return str; } private: std::string str; } int main() { *a = new a; const std::string& str = a->getstring(); std::cout << str; } will compiler optimize , avoid copy if take result const std::string& in main ? it's remotely possible, highly unlikely compiler optimize away copy in use case. observe if copy gets optimized away, caller's temporary gets bound const reference object's class member. , const means referenced value cannot changed. with code shown in question, it's possible compiler can prove nothing can possibly change contents of class member while const reference remains in scope, , s...

excel - Pivot table and Dates -

i newbie, , sort of enthusiastic learner, beginner making many mistakes. on pivot table picking 2 years worth of dates, keen choose first 2 recent dates, rather using slicer. have tried make little bit dynamic, getting error messages, i trying have cells in spreadsheet date , 2 date, or code picks first 2 recent dates. want code work , pulling hair out, have few other pivot tables. every time put cell reference in between, dates keep getting coding errors. i want pivot items more dynamic before, try add validation on date , date make lot more dynamic. i want pivot items x first date , y second date referring 2 cells on sheet, can amend on sheet, , code picks first 2 recent dates. sub dateslection () activesheet .pivottables("pivottable4").pivotfields("date") .pivotitems("11/2/2016").visible = true .pivotitems("10/26/2016").visible = true end end sub kind regards ali for dynamic filter this: su...

java - Read a string file as ints into an array? -

i need write program takes input file name, age, , score information of golfer (practice.txt). file should compare scores par scores specific age group. example: manny 14, follows par scores 12-15 age group. manny shot 5 on hole one, made par. i'm having trouble understanding how compare between file , array? code or ideas me on way great. input file practice.txt: jay 57 4 3 2 3 5 3 2 3 4 gloria 39 4 4 3 4 3 4 3 3 5 manny 14 5 6 4 6 5 6 4 4 6 joe 3 9 8 8 7 6 6 7 5 7 par scores chart: holes age 1 2 3 4 5 6 7 8 9 4 , under 8 8 9 7 5 7 8 5 8 5 – 7 7 7 8 6 5 6 7 5 6 8 – 11 6 5 6 5 4 5 5 4 5 12 – 15 5 4 4 4 3 4 3 3 4 16 , on 4 3 3 3 2 3 2 3 3 what have: import java.io.file; import java.util.scanner; import java.util.list; import java.io.filenotfoundexception; import java.util.arraylist; public ...

c - how to get input char from user? -

so i'm supposed use while loop read 2 strings , operations strings. user should able enter multiple string pairs until enters exit. how accept string instead of hard copying function.? int main(int argc, const char *argv[]) { char string[3], stringsec[2]; string[0] = 'c'; string[1] = 'a'; string[2] = 't'; stringsec[0] = 'c'; stringsec[1] = 's'; int array[3][4]; // functions... return 0; } use fgets read string , strcmp check if equals "exit": while (strcmp(string, "exit")) { fgets(string, sizeof(string), stdin); fgets(secstring, sizeof(secstring), stdin); // perform operations on strings } explanation: strcmp returns 0 if 2 strings match. in example above loop continue long doesn't return 0. fgets reads amount of bytes (2nd argument) file (3rd argument) string (1st argument). notes: fgets not remove trailing newline string read. ca...