Posts

Showing posts from January, 2011

java - Move the file to other location -

i need move file other location giving differnt name. tried : files.move(oldname, newname, options); i exception: java.nio.file.nosuchfileexception: /media/sf_vboxshared/data/csv/res20150201/xx/part-r-00000-f8ed41a5-e0e1-4534-a1d9-e4d6082691db.gz.parquet -> /media/sf_vboxshared/data/csv/res20150201/res/xx.parquet the oldname file exists. newname dosn`t exist. (only /media/sf_vboxshared/data/csv/res20150201 part of path exist) you /media/sf_vboxshared/data/csv/res20150201 , parent directory of directory want move file to, /media/sf_vboxshared/data/csv/res20150201/xx , doesn't exist. so have create first before moving: path newname = ...; files.createdirectories(newname.getparent());

Ruby - logging in time-critical multithreading application -

i have log activity of application runs in many threads. best approach that? not possible threads log 1 file, because lock each other? best use separate file each thread then? i use within method called threads @ moment: f=file.open(...) f.puts "log message" f.close all threads calling method. append thread number file name every thread creates own file. method called when thread calls , gives new information log. method opens file, writes information , closes again. opening , closing of file time-consuming in time-critical application? or not concerned of?

memory dump - Open PDF found with volatility -

my task analyze memory dump. i've found location of pdf-file , want analyze virustotal. can't figure out how "download" memory dump. i've tried command: python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -d dumpfiles/ but in dumpfile-directory there .vacb file not valid pdf. i think may have missed command line argumenet command: python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -d dumpfiles/ if not getting .dat file in output folder can add -u : -u, --unsafe relax safety constraints more data can't test out access dump should able rename .dat file created .pdf . so should this: python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -d dumpfiles/ -u you can check out documentation on commands here

objective c - UILabel.text doesn't change from NSString (iOS) -

i'm trying change name ( uilabel ).text namestring ( nsstring ) not present on screen (it change - value when debug , correct value). code: nsstring *namesstring = [self.names objectatindex:i]; infowindow.storeaddresslabel.text = namesstring; note: if type: infowindow.storeaddresslabel.text=@"sometext"; it works does know why it? thanks! you're referencing 2 different variables. on 1st line define namestring , , on next line set using namesstring s

active passive in memory object redundancy .NET -

i have following requirement don't know way begin with. have application when started creates object in memory. have start same application on other machine , other machine should create same object in memory. now, if can or set data to/from object third machine (client). 2 machines must keep in-memory object in sync such if client updates object in 1 machine should updated in second machine well. client should able register notifications such if important happens, server should notify client. if 1 machine gets down client's request should start going other machine. client should not have register notifications second time. in short want active/passive kind of redundancy @ in memory object level notification features. in c++, used applibus (a customized corba middleware), in .net have no clue. need use middle ware or cluster/nlb configuration or hardware redundancy of server. please help

php - change codeigniter default url format -

the default url format of codeigniter controller/function/params . can change params/controller/function or controller/params/function you should add routes uri scheme wish have: http://ellislab.com/codeigniter/user-guide/general/routing.html

javascript - How to use server-sent-events in express.js -

i setup rest server express.js . want add sse server. after implemented this sse package, error. know error, when try use res.send twice, not. error: error: can't set headers after sent. @ serverresponse.outgoingmessage.setheader (http.js:690:11) @ serverresponse.header (/home/root/node_modules/express/lib/response.js:718:10) @ serverresponse.send (/home/root/node_modules/express/lib/response.js:163:12) @ app.get.str (/home/root/.node_app_slot/main.js:1330:25) @ layer.handle [as handle_request] (/home/root/node_modules/express/lib/router/layer.js:95:5) @ next (/home/root/node_modules/express/lib/router/route.js:131:13) @ sse (/home/root/node_modules/server-sent-events/index.js:35:2) @ layer.handle [as handle_request] (/home/root/node_modules/express/lib/router/layer....

google analytics users flow graph for mobile? -

on ga web console left navigation area there's handy audience report named "users flow". seems present web application , missing mobile app analytics. not supported or missing something? it takes 24 hours section of reports show after initial submission of events. after 24 hours section appears.

scala - How to access lookup(broadcast) RDD(or dataset) into other RDD map function -

i new spark , scala , started learning ... using spark 1.0.0 on cdh 5.1.3 i got broadcasted rdd named dbtablekeyvaluemap: rdd[(string, string)], want use dbtablekeyvaluemap deal filerdd( each row has 300+ columns). code: val = filerdd.map({x => val tmp = dbtablekeyvaluemap.lookup(x) tmp }) running locally hangs and/or after sometime gives error : scala.matcherror: null @ org.apache.spark.rdd.pairrddfunctions.lookup(pairrddfunctions.scala:571) i can understand accessing 1 rdd inside other have issues, if locality , size of collection come picture.. me taking cartesian product not option records in file rdd huge(each row 300+ columns) ... used distributed cache load dbtablekeyvaluemap in setup method , use in map of hadoop java mapreduce code, want use similar way in spark map... not able find simple example refer similar usecase... 1 one want iterate on filerdd rows , transformation, beatifications, lookups etc. on "each column" further processing... o...

Im trying to find a css hack for just safari NOT chrome -

this question has answer here: is there css hack safari not chrome? 10 answers im trying find css hack safari not chrome, know these both webkit browsers im having problems div alignments in chrome , safari, each displays differently. i have been trying use affects chrome well, @media screen , (-webkit-min-device-pixel-ratio:0) { #safari { } } know of 1 apply safari please? you can use media-query hack select safari 7+ other browsers. @media \\0 screen {} disclaimer: hack targets old chrome versions (before july 2013). tips: found on browserhacks website.

php - Validating looped checkboxes using -

how validate checkboxes. 1 or more of them must checked before user can proceed next page using javascript , form this? echo "<form method="post" action="confirm.php">"; $query = mysqli_query($conn, "select data details;"); if(mysqli_num_rows($query)){ while($row = mysqli_fetch_assoc($query)){ echo "<h5><input type='checkbox' name='data[]' value='".$row['data']."'>apple"; } } echo "</form>"; validate them what? like: $("form").on("click", "input[type=submit]", function (e) { e.preventdefault(); // check inputs here .. if whatever }

Android Volley: how to make json request without returned object? -

now i'm doing jsonobjectrequest jsonobjectrequest = new jsonobjectrequest( request.method.post, uri, json, new response.listener<jsonobject>() { @override public void onresponse(jsonobject jsonobject) { // action } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror volleyerror) { //manage error } } ); my servlet uses jersey jax-rs. resource called uri passed parameter not produce json object. if way, error callback called if json object sent post correctly used on server. if return json fake data response callback called, don't need send object (wasting user's data bandwidth). i'd normale response action if code of response ok or 200. how should do? you can overr...

python - Pygame convert surface into sprite -

i want make game cards, heartstone, lot simplier (coz not pro programmer). part of program import pygame class card: def adcard(self, adcard): self.adcard = adcard def hpcard(self, hpcard): self.hpcard = hpcard def picture(self, picture): self.picture = picture def special(self, special): if special == "heal": pass pygame.init() display = pygame.display.set_mode((0, 0), pygame.fullscreen) swordsman = card() swordsman_picture = pygame.image.load("swordsman.png").convert() swordsman.picture(swordsman_picture) print(type(swordsman.picture)) now problem prints type of picture class 'pygame.surface' want picture sprite. how that. tnx. sprite class use surface keep image , rect keep positon , size. class card(pygame.sprite.sprite): def __init__(self, surface): pygame.sprite.sprite.__init__(self) self.image = surface self.rect = self.image.get_rect() # size , position # , one_card = ...

ontology - How to add an individual to a class using OWL API? -

i wand add individual class, , referenced doc in owl api official site. here code. public void addindividualstoclass(string classname, string indname) throws owlontologystorageexception{ /* * add individual input class */ owlclass tclass = fac.getowlclass(iri.create(ns + classname)); owlnamedindividual tindividual = fac.getowlnamedindividual(iri.create(ns + indname)); owlclassassertionaxiom classassertion = fac.getowlclassassertionaxiom(tclass, tindividual); manager.addaxiom(ont, classassertion); manager.saveontology(ont, new streamdocumenttarget(new bytearrayoutputstream())); } then, eclipse throws exception. exception in thread "main" java.lang.illegalargumentexception: comparison method violates general contract! @ java.util.comparabletimsort.mergelo(comparabletimsort.java:714) @ java.util.comparabletimsort.mergeat(comparabletimsort.java:451) @ java.util.comparabletimsort.mergecollapse(comparabletimsort.java:376) @ java.util.co...

Can't transfer files using FTP script and batch on Windows -

Image
i have folder pdf files locally on hard disk , want upload files folder ftp server. so created batch file should upload pdf files ftp server. seems work fine , console window displays file transferred , no file uploaded. the ftp script content: open 000.000.000.000 -- not real ftp server ip lol bla@nirlatpro.com password mput c:\batch\*.pdf quit command window output on running script: it looks works, no file uploaded. what more strange if connect ftp using gui application , drag files, work , files uploaded server. summary: - it's works fine if i'm using windows explore , dragg files. - it's not uploading files if i'm using cmd commands or batch script ftp file, if console window displays 'file transferred' it permissions problem apparently ftp server not allowing copy files in root directory / console window display "current restricted directory / "

c# - Crystal report not opening in client machine -

i'm not able open crystal reports on client machine. crystal report runtime installed , .net framework well. error code below see end of message details on invoking just-in-time (jit) debugging instead of dialog box. ************** exception text ************** system.typeinitializationexception: type initializer &#39;crystaldecisions.crystalreports.engine.reportdocument&#39; threw exception. ---&gt; system.io.filenotfoundexception: not load file or assembly &#39;crystaldecisions.reportappserver.commlayer, version=13.0.2000.0, culture=neutral, publickeytoken=692fbea5521e1304&#39; or 1 of dependencies. system cannot find file specified. @ crystaldecisions.crystalreports.engine.reportdocument..cctor() --- end of inner exception stack trace --- @ crystaldecisions.crystalreports.engine.reportdocument..ctor() @ hw_management.report..ctor() @ hw...

python - Recursion in function causing return variable to equal 'None' -

this question has answer here: recursive function returning none? 1 answer i making caesar cipher in python. had created function return message user want encrypt. wanted same cipher key. wanted function return key if between 1 , 26 because size of alphabet. works when purposefully enter number bigger 26 enter number in between 1 , 26; apparently returns 'none'. first time using recursion. def getkey(): print("enter key want use decrypt/encrypt message") key = int(input()) # key input while true: if key >= 1 , key <= 26: #checking if key in between range return key #giving key else: # should run whenever input invalid print ("the key must inbetween 1 , 26") break # stop loop getkey() # recursion, restart function key = getkey() print(key) # prints 'none' ...

jquery - How to achieve https://www.gogoro.com/smartscooter/smarter/ iphone like screenshots -

anybody knows if there plugin doing iphone screenshots effects 1 in page https://www.gogoro.com/smartscooter/smarter/ i've been searching around couldn't find it.. thanks! i think looking called parallax scrolling . here 2 nice plugin can use: scrollmagic skrollr here examples awwwards website. 30 great websites parallax scrolling

Owncloud 8 with Docker behind nginx available through subdirectory -

i want run severel services/pages behind nginx. each service shall available through subdirectory instead of subdomain. i'am using jwilder/nginx-proxy proxy container: nginx_proxy: image: jwilder/nginx-proxy container_name: nginx-proxy ports: - 80:80 volumes: - /var/run/docker.sock:/tmp/docker.sock and owncloud container: web: image: owncloud:8.1 container_name: my_owncloud environment: - virtual_host=www.example.com ports: - 8081:80 the modified nginx config: # if receive x-forwarded-proto, pass through; otherwise, pass along # scheme used connect server map $http_x_forwarded_proto $proxy_x_forwarded_proto { default $http_x_forwarded_proto; '' $scheme; } # if receive upgrade, set connection "upgrade"; otherwise, delete # connection header may have been passed server map $http_upgrade $proxy_connection { default upgrade; '' close; } gzip_types text/plain text/css application/javascript applicatio...

ios - Unable to get audio file header with AV Foundation -

for application, on 1 side, need audio file itunes library store on disk. that, have callback stream each audio buffer client. on other side, have callback audio buffer , build playable audio file in original format store on ios device. i've tried days thing works without success. in deed, on client side have audio file original size without audio header. result in unplayable audio file. for use piece of code : 1) open audio file nsurl* url = [ nsurl fileurlwithpath : [ [ nsbundle mainbundle ] pathforresource : @"test" oftype : @"m4a" ] ]; audiofileopenurl( ( __bridge cfurlref ) url, permission, 0, & _audiofileid ); nsdictionary* options = @{ avurlassetpreferprecisedurationandtimingkey : @yes }; _asset = [ avurlasset urlassetwithurl : url options: options ]; 2) create avasset ns...

Java Calculator (1 error) -

this teachers java calculator program. compiler jcreator , keeps saying 1 error , don't know mistakes , should do. need run , i'm running out of time. public class calculator { static double number1; static double number2; static string y; public static void main(string[] args); { { system.out.println("this calculator . . . not sure if expecting cool intro"); system.out.println(""); system.out.println("this possible in head ... "); system.out.println(""); system.out.println("enter thee first number press enter key"); double number1 = expo.enterdouble(); system.out.println(""); system.out.println("enter second number press enter key "); double number2 = expo.enterdouble(); system.out.println(""); system.out.println("would add, subtract, multiply, or divide?"); system.out.println(""); string calc = expo.enterstring(); .toup...

java - Tomcat 8 converts hyphens to %2D in the URL -

how prevent tomcat encoding hyphens (-) %2d in urls. behaviour causes session related issues when requests made safari browser. deployed war file: my-app.war generated url: /my%2dapp desired url: /my-app if referring links generated tomcat manger: issue experience rooted not in context configuration in htmlmanagerservlet . servlet includes following line : "<a href=\"" + url_encoder.encode(contextpath + "/") which custom encoder: org.apache.catalina.util.urlencoder . static instance employed in code not use default singleton marks following chars safe: public static final urlencoder default = new urlencoder(); static { default.addsafecharacter('~'); default.addsafecharacter('-'); default.addsafecharacter('_'); default.addsafecharacter('.'); default.addsafecharacter('*'); default.addsafecharacter('/'); } but rather this : static { url_encoder = new urle...

jQuery dynamic form submit twice -

i have tried create form dynamically , submit on server, data list of $(<checkbox>) . $('<form>').attr("method", "post") .attr('action', '/proceed') .append(data) .submit(); the problem on server comes 2 requests: post data , without data -just empty form. submit happens once, have tried unbind submit before. the default action of <button /> submit form when it's clicked. as mentioned in comment, need cancel submission before create own; $('.activateeventbutton').on('click', function (e) { activateevents(); e.preventdefault(); // prevent submission. });

node.js - Can a Schema use it's own model to validate? -

for example, have user schema, , want validate username unique before attempting save user database. ... userschema.path('username') .validate(function (value, respond) { user.findone({ username: this.username }) // isn't valid. .lean() .select('_id') .exec(function (err, user) { if (err) { winston.warn('user_username: error looking duplicate users'); respond(false); } // if user returned, user non-unique! if (user) { respond(false); } respond(true); }); }); ... var user = mongoose.model('user', userschema); i know use mongoose.model('user').findone(...) seems bit silly, there no better way it? you can create unique index in schema setting unique: true . make use of unique index option available in mongodb. here example snippet 1 of models using option: // (generated) uniform resource locator url: { // .....

Amazon web service Data pipeline -

can use existing ec2 instance details while configuring data pipeline? if possible ec2 details need provide while creating pipe line? yes, possible. according aws support. "you can install task runner on computational resources manage, such amazon ec2 instance, or physical server or workstation. task runner can installed anywhere, on compatible hardware or operating system, provided can communicate aws data pipeline web service. this approach can useful when, example, want use aws data pipeline process data stored inside organization’s firewall. installing task runner on server in local network, can access local database securely , poll aws data pipeline next task run. when aws data pipeline ends processing or deletes pipeline, task runner instance remains running on computational resource until manually shut down. task runner logs persist after pipeline execution complete." i did myself takes while pipeline start up, start time 10-15 minutes depending on u...

How to restart a Wix Managed Bootstrapper Application after a reboot? -

i have managed bootstrapper application written in wix , having trouble handling reboots. far have exe package exitcode also, in run method have if (this.command.resume == resumetype.reboot) { model.setwindowhandle(view); this.engine.detect(); //view.show(); dispatcher.run(); //this.engine.quit(model.finalresult); } this applycomplete event handler protected void applycomplete(object sender, applycompleteeventargs e) { this.model.finalresult = e.status; if (model.bootstrapperapplication.command.action == launchaction.uninstall) { model.bootstrapperapplication.engine.quit(0); } else { bootstrapperapplication.dispatcher.begininvoke((action)delegate () { bootstrapperapplication.view.close(); }); bootstrapperapplication.dispatcher.invokeshutdown(); e.result = ...

cx oracle - Python - Usefulness of threads with cx_oracle -

based on following context: open connection oracle database execute 1 select query close connection is useful use threads handle database connection , query execution? library cx_oracle manage enough trust execution? for example, in case of database being on loaded (by other connections), keep connection open undefinetly? other scenario case: query has conditions, limit number of rows. if number of rows increase drastically, query take more time execute. useful thread query execution, following post . i have seen cx_oracle can combine threads multiple insertions, or more complex software. in simpler case, wonder... thanks lot.

javascript - TypeError: $element.epoch is not a function -

i'm using angularjs , epoch ng-epoch directive wrapper. here module file angular.module('rdash', ['ui.bootstrap', 'ui.router', 'ngcookies','ng-oboe','ng.epoch']) .config(function (oboeprovider) { /* if inclined, change oboe defaults here - headers, etc. */ // oboeprovider.defaults = {}; }); i didn't make changes in controller. because want show chart outline without data @ page. here template file: <div class="row" ng-controller="statsctrl"> <div class="col-lg-12"> <rd-widget> <rd-widget-header icon="fa fa-line-chart" title="cpu"> </rd-widget-header> <rd-widget-body classes="medium no-padding"> <epoch-live-line chart-height="200" chart-data="" chart-stream=""> </epoch-live-line> </rd-widget-body> </rd-widget> ...

tsql - SQL Server 2012 - Break apart a running total -

in sql server 2012 database have following table running total (runamount) <table><tbody> <tr> <th>budataid</th> <th>bu</th> <th>accountnum</th> <th>category</th> <th>curramt</th> <th>bumonth</th> <th>buyear</th></tr> <tr> <td>1</td> <td>12</td> <td>aa</td> <td>n91</td> <td> $9,700.00 </td> <td>1</td> <td>2015</td></tr> <tr> <td>2</td> <td>12</td> <td>aa</td> <td>n91</td> <td> $19,437.00 </td> <td>2</td> <td>2015</td></tr> <tr> <td>3</td> <td>12</td> <td>aa</td> <td>n91</td> <td> $29,560.00 </td> <td>3</td> <td>2015</td></tr> <tr> <td>4</t...

How to merge two data frames in r by a common column with mismatched date/time values -

i wish merge 2 datasets using ‘date time’ columns present in both (posixct format: dd/mm/yyyy hh:mm). below example data 2 datasets: # dataset 1 (dts1) datetime count period 1 30/03/2011 02:32 27 561 2 30/03/2011 02:42 3 600 3 30/03/2011 02:52 0 574 4 30/03/2011 03:02 1 550 5 30/03/2011 03:12 15 600 6 30/03/2011 03:22 0 597 # dateset 2 (dts2) datetime dist car satd alt 1 30/03/2011 01:59 23.9 1 3 1.76 2 30/03/2011 02:58 14.7 1 7 6.36 3 30/03/2011 03:55 10.4 2 9 -0.34 4 30/03/2011 04:53 35.4 1 3 3.55 5 30/03/2011 05:52 56.1 1 7 -0.91 6 30/03/2011 06:48 12.3 1 4 6.58 7 30/03/2011 07:48 10.7 1 5 4.18 if simple case of merging matching rows 2 frames basic merge(data1, data2, by="datetime") or rbind() function used. however, problem more...

Mandelbrot Set through shaders in GLSL with LOVE2d renders a circle, not a fractal -

Image
i'm trying render mandelbrot set using glsl, full circle... have checked maths lot, , cannot find error, thought maybe problem semantic. is able see what's wrong? also, give me insights on organization, structure, etc? i'm trying learn proper coding, it's hard find material on styling. obs.: shader can applied on image the idea simple (you may skip this): checkconvergence returns true if z has not diverged (i.e., abs(z) < 4 sumsquare returns complex multiplication (z.r, z.i)*(z.r, z.i) - (c.r, c.i), k.r = re(k) , k.i = im(k) iterate actual algorithm: keeps squaring z until diverges or reaches maximum number of iterations (tol) clr parameterized function returns rgb array depends on n finally, effect magic should happen, doing 2 things: it takes coordinates of pixel (glsl normalizes interval(0, 1) , normalizes mandelbrot set size (-2 it calls clr on iterate on coordinates. glslshader = love.graphics.newshader[...

c# - Zipping multiple excel files -

i need multiple excel files (ssrs reports), put them in folder , zip it. how tried, it's not working: public actionresult pricingreports( list<int> productids ) { memorystream memstream = new memorystream(); using ( ziparchive archive = new ziparchive( memstream, ziparchivemode.update ) ) { foreach ( int id in productids ) { //preparing single excel file reportmodel model = preparereportmodel( values ); _ssrs.getreport( model, "excel" ); ziparchiveentry singlereport = archive.createentry( "pricingreport" + " - " + id ); using ( binarywriter binwriter = new binarywriter( singlereport.open() ) ) { binwriter.write( model.reportbits ); } } } return file( memstream.toarray(), system.net.mime.mediatypenames.application.octet, "pricing reports" ); }

css - menu test spread and wrapper correction -

please see this: http://i.imgfst.com/z6bsbf.jpg can see have problem nav menu. dont know how centre navigation wrapper shorter on right side (to match left side) how make more space between text menu looks bit squished @ moment.. <div id="nav-wrapper"> <div id="nav">{menu}</div> </div> #nav-wrapper { position: fixed; width: 100%; left: 0 20; padding: 0 4px 10px; top: 0px; z-index: 5 ; opacity: 0.9; background: #b31717; text-align:center; } #nav { vertical-align:center; } #nav > ul li { display: inline-block; list-style: none; padding: 0; z-index: 2; } .wsite-menu-default { display: block; padding: 8px; color: rgba(255, 255, 255, .90); font-weight: bold; position: fixed; top: 0; left: 0; z-index: 999; } .wsite-menu-default { display: block; padding: 8px; color: rgba(255, 255, 255, .90); font-weight: bold; position: ...

cell - Why these space are in my table? -

Image
can me please how remove these spaces? this image shows problem: can solve problem? use valign attribute 1st , 3 rd td. <tr><td valign="top"></td><td></td><td valign="top"></td></tr>

c# - Why doesn't Ajax calendar extender work until I click button? -

i have ajaxcalendarextender applied on text box. doesn't work until click button within page (any asp button doesn't post back). after clicking button starts working charm. why ? <asp:textbox id="txtboxdateofbirth" runat="server" cssclass="form-control"></asp:textbox> <asp:calendarextender id="calext1" runat="server" format="dd/mmm/yyyy" targetcontrolid="txtboxdateofbirth"> button: <asp:button id="btnshowviewpersonalinfo" runat="server" onclick="btnshowviewpersonalinfo_click"/> this button doesn't nothing big, changes views in webform. please me can't figure out since man days. update: code behind button click event. btnshowviewpersonalinfo.backcolor = colortranslator.fromhtml("#106e5b"); btnshowviewpersonalinfo.forecolor = color.whitesmoke; btnshowviewpersonalinfo.font.bold = true; multiviewhr.activeviewindex = 0; ...

ios - To change the background color of the cells with the earlier date -

each cell contains date , information(text). default, sorting in reverse order. sorted in reverse order of time. want change background color of cells in cell prior current date. tableview cellforrowatindexpath : let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! tableviewcell cell.datelabel.text = stores.date cell.contentlabel.text = stores.content let today = nsdate() if today == (stores.date) { cell.backgroundcolor = uicolor.bluecolor() } else { cell.backgroundcolor = uicolor.clearcolor() } return cell your date comparison wrong. use nscalendar compare nsdate day. nsdate extension described here getting difference between 2 nsdates in (months/days/hours/minutes/seconds) extension nsdate { // ... func daysfrom(date:nsdate) -> int{ return nscalendar.currentcalendar().components(.day, fromdate: date, todate: self, options: []).day } //... } using extension in cod...

php - Laravel 5.1 Eloquent distant relationship with many to many models -

i have 3 models , many-to-many relationships. environments have many services. services have many serviceroles. return applicable serviceroles of given environment, unsure of may need define in environment model. in controller have: public function getserviceroles($id) { $environment = environment::find($id); $serviceroles = $environment->serviceroles; } my mysql tables , fields follows: environments [id | name] services [id | name] service_roles [id | name] environment_service [id | environment_id | service_id] service_service_roles [id | service_id | service_role_id] environment model class environment extends model { public function services() { return $this->belongstomany('app\service'); } } service model class service extends model { public function environments() { return $this->belongstomany('app\environment'); } public function serviceroles() { return $this...

matlab - Squared euclidean calculation with cell arrays -

i start university project in few months , planned write in java tutor recommended me pick matlab lot easier , efficient, i'm writing few proof of concept prototypes 'test waters'. right have cell array , want find total sum of squares elements in (cell) array. in other words, need go through each element, find mean, calculate distance each point in element mean, total each element , return single figure entire array. this how approached it: function squared_sum = sumsquares(c_array) squared_sum = 0 = 1:size(c_array,2) c_element = cell2mat(c_array(1,i)); j = 1:size(c_element,1) square_distance = pdist2(c_element(j,:), mean(c_array{1,i})).^2; % sum of squares = euclidean distance squared squared_sum = squared_sum + square_distance; end end end the issue how write in java. i'm aware functional paradigm supposed more elegant , less reliant on loops i'm curious if there nicer way write this? edit: cell structure (1x4) [28x3] ...

javascript - mgcrea.ngStrap datepicker issue -

i've got issue datepicker mgcrea.ngstrap library. layout file: <html lang="en-us" ng-app="ftc"> <head> <script src="/assets/2db3448a/components/angular.js/angular.min.js"></script> <script src="https://code.angularjs.org/1.4.8/angular-animate.min.js"></script> <script src="/assets/2db3448a/components/angular-route/angular-route.min.js"></script> <script src="/assets/2db3448a/mgcrea/angular-strap/dist/angular-strap.min.js"></script> <script src="/assets/2db3448a/mgcrea/angular-strap/dist/angular-strap.tpl.min.js"></script> <!-- i'm including rest of js libs (anguvideo, googlemaps dependencies, etc. i'm including stylesheets (bootstrap too) --> </head> <body ng-controller="applicationcontroller appctrl"> <!-- navbar here --> <div class="container"> <div ng-view>...

c - Reading a Tx from a barcode scanner with a Arduino Mega 2560 - RS232 -

for past couple of days have been trying create program reads tx of barcode scanner. have tried bunch of different things such different programs different scanners. sample program wrote example: #include <softwareserial.h> softwareserial myserial (50, 51); unsigned char incomingbyte; void setup () { serial.begin (9600); myserial.begin (9600); serial.println ("begin initial serial!\n"); } void loop () { while(myserial.available () > 0) { incomingbyte=myserial.read (); serial.print (incomingbyte,hex); } serial.println (); } at time can not provide proper connection diagram (will when have chance), arduino mega 2560 connected 3 wires barcode scanner, tx (pin 50), rx (pin 51) , gnd background info on transmitted data: startbit: 0x02 stopbit: 0x03 ultimate goal: scanner scans barcode, arduino reads datastream , sends output when recognizes code. how achieve ultimate goal? thanks in advance! arduino...