Posts

Showing posts from August, 2013

octave - Saving image in plot window after placing points in plot -

Image
using octave, able show image , plot red circles on it, follow: tux = imread('tux.png'); imshow(tux); hold on; plot(100,100,'r','markersize', 10); plot(150,200,'r','markersize', 10); the above code display window: my question is: how can save image being showed inside window? thank much! pretty simple. use: print -djpg image.jpg print command in octave allows capture what's seen in current figure window. -d specifies output device want write to. there multiple "devices" can use save file... eps, ps, tex, etc. device can image writer, , here chose jpeg. can choose other valid image formats supported octave. take @ link provided above more details. after, specify file name want save plot to. in case, chose image.jpg . you can take @ saveas . make sure handle current figure first before doing so: h = gcf; saveas(h, "image.jpg"); also... more point-and-click approach go file -> s...

functional programming - Scala combine Seq of Timestamps -

hello i'm learning scala , have seq of object of following case class: case class historycounter(time: datetime, counter:int) now combine value of counter based on timestamp time . sum of counters time on same day or same week. how can this? 1 of collection functions fold or map capable of doing this? if had list of these case classes called list , 1 way so: val counts = list.groupby(_.time).map{ case (k, v) => (k, v.map(_.counter).sum) } or more succinctly: list.groupby(_.time).mapvalues(_.map(_.counter).sum)

php - Laravel homestead laravel-elfinder install error -

i'm using homestead @ localhost. have followed instructions install did: composer require barryvdh/laravel-elfinder , run composer update , throws me error: your requirements not resolved installable set of packages. problem 1 - intervention/image 2.1.3 requires ext-fileinfo * -> requested php extension fileinfo mi ssing system. - intervention/image 2.1.2 requires ext-fileinfo * -> requested php extension fileinfo missing system. .. - intervention/image 2.0.11 requires ext-fileinfo * -> requested php extension fileinfo missing system. - intervention/image 2.0.10 requires ext-fileinfo * -> requested php extension fileinfo missing system. - intervention/image 2.0.1 requires ext-fileinfo * -> requested php extension fileinfo missing system. - intervention/image 2.0.0-beta.2 requires ext-fileinfo * -> requested php extension fileinf o missing system. - intervention/image 2.0.0-beta requires ext-fileinfo * -> requested php e...

jquery - Using cropper.js before Dropzone.js send image to server -

what want here before dropzone.js send dropped image server, modal appears cropper.js (fengyuanchen script) user can crop image, , when image cropped, send dropzone.js server. so when change image src of #cropbox function filetobase64 , replace image of cropper function cropper('replace'), keeps showing default.jpg image, instead of new 1 uploaded user html <div class="wrapper-crop-box"> <div class="crop-box"> <img src="default.jpg" alt="cropbox" id="cropbox"> </div> </div> js: function filetobase64(file) { var preview = document.queryselector('.crop-box img'); var reader = new filereader(); reader.onloadend = function () { preview.src = reader.result; } if (file) { reader.readasdataurl(file); } else { preview.src = ""; } } $(function() { dropzone.options.avtdropzone = { acceptedfiles: 'image/*', ...

c++ - Is it possible to use operator new to allocate from elsewhere than the heap? -

here context of application : i'm working on embedded system uses ram different devices. 1 part in internal ram of microcontroller (128kb) , other part external ram (1mb). these memories mapped address space of microcontroller, in non contiguous regions. the internal ram used system stack, tasks stacks , heap. external ram used statically allocated data (pools, buffers, , " static ... " stuff) i trying implement simple memory management structure, , part of able create allocator use allocation algorithm of operator new using memory source, not system heap memory region elsewhere. know if possible ? an example of use reserve 100kb of external ram , create allocator manage it, , give specified task need memory. static const uint8_t* rambase = reinterpret_cast<uint8_t*>(0x80000000); static const uint32_t ramareasize = 0x19000; //100kb bufferallocator allocator(rambase, ramareasize); //... //assuming operator new overloaded use bufferallocator myobject * o...

Working with Aliased Columns in SQL Server 2012 -

Image
okay, know this question why cannot reference aliased column where , group by , or having statements. my problem have query being moved teradata database sql server 2012. in teradata, referencing aliased column in where, group by, having, , join statements valid. my question is, how can perform query, , others it, in sql server, without having resort populating temporary table select first. (this example single part of large tsql script containing 10 separate transactions, many of or more complex example provided) select max(case when field_name = 'parent brand cd' , datalength(field_val)>1 substring(field_val, 1, datalength(field_val) - 1) else null end ) parent_brand_cd, max(case when field_name = 'brand id' , datalength(field_val)>1 substring(field_val, 1, datalength(field_val) - 1) else null end ) hotel_cd, @src_s...

How to subset from a 4 dimensional array in R, based on value -

basically have 4 dimensional array of various radar variables named pol has dim (5,1191,360,11) for part of analysis want subset analysis pixels below height, note pol[2,,,] contains height information ideally this newpol<-pol[pol[2,,,]<5,] the issue construct not 4 dimensional features, have tried newpol[,,,]<-pol[,,,][pol[2,,,]<5,,,] but results in error "logical subscript long" my goal obtain 4 dimensional array consisting of elements of pol pol[2,,,]<5. thanks in advance assistance. two things here: adding ,drop=false indexing, , which(..., arr.ind=true) . some data: set.seed(42) pol <- array(sample(20, size=3*4*5*6, replace=true), dim=c(3,4,5,6)) this simple subsetting, lose dimensionality c(3,4,5,6) c(4,5,6) , not good: pol[2,,,] < 5 ## , , 1 ## [,1] [,2] [,3] [,4] [,5] ## [1,] false false false false false ## [2,] false false false false false ## [3,] true false false false false ## [4,] false false ...

css - How do I keep a mediawiki div element centered horizontally? -

#searchinput { width: 50%; height: 40px; display: block; text-align: center; margin-left: auto; margin-right: auto; top: -12em !important; left: 1em !important; } i can't div stay centered in mediawiki wiki. there way this? code above doesn't anything. stays in place. have applied know in previous post, , still doesn't work divs.

shell - Create a command line script -

i'm using web tool has inbound webhooks. provide me url, can post string , logs system. i create script me , team can use terminal this: ~: appname ~: webhook url? here can copy , paste url gives me, , stores it. can this: ~: appname message want send... and sends post webhook string. ideally can share non-techies , that's easy set up. , have no idea how start this. i assuming want strictly shell. in end want use curl (bash) curl --data "msg=$2" $url the $url variable come flat file(app.txt) key value key=appname you first script need append file(app.txt) echo $1 $2 >> app.txt

Apache CXF add namespace in XML response -

i trying return namespace information in xml response of rest service. using apache cxf 2.7.11. have configured </bean> <!-- cxf jaxb provider --> <bean id="jaxbxmlprovider" class="org.apache.cxf.jaxrs.provider.jaxbelementprovider"> <property name="namespaceprefixes" ref="xmlnamespacemap"></property> </bean> <util:map id="xmlnamespacemap" map-class="java.util.hashmap"> <entry value="li" key="http://www.abc.xom/xyz"/> </util:map> but not return namespace information in xml response. tried debug cxf code , found in org.apache.cxf.jaxrs.provider.abstractjaxbprovider class in setnamespacemapper, code checks "namespacemapperpropertyname", not sure property means. also if suggest other way return custom namespace in apache-cxf, helpful. thanks

java ee - Can't invoke EJB/CDI bean -

i don't know application websocket (tyrus 1.1) can't invoke cdi or ejb bean. i'm running on glassfish 4.1 server-sent event, websocket 1.1, etc when called jsf managed bean (cdi) websocket app, showed "error: weld-001303: no active contexts scope type org.omnifaces.cdi.viewscoped". if called ejb stateless bean websocket app, showed messages follows: warning: system exception occurred during invocation on ejb chatsessionbean, method: public com.mnik.chat.entity.chatinfo com.mnik.chat.ejb.chatsessionbean.findroomid(java.lang.string) warning: javax.ejb.ejbexception @ com.sun.ejb.containers.ejbcontainertransactionmanager.processsystemexception(ejbcontainertransactionmanager.java:750) @ com.sun.ejb.containers.ejbcontainertransactionmanager.checkexceptionnotx(ejbcontainertransactionmanager.java:640) @ com.sun.ejb.containers.ejbcontainertransactionmanager.postinvoketx(ejbcontainertransactionmanager.java:482) @ com.sun.ejb.containers.basecont...

Ability to set JavaScript breakpoints in browser pointed at local environment -

unfortunately, while javascript breakpoints can set in production, cannot set in local. in local, on refresh, javascript execution proceeds unimpeded, if no breakpoint had ever been set. (this has been tested in chrome, safari , ff on mac os x.) the current local environment differs in headers javascript files. the headers pasted, below. there difference in headers being set, cause undesirable behavior in local. thanks! production general remote address:23.235.33.207:80 request url:http://www.example.com/wp-content/themes/example/js/header.top.min.js?ver=1427752599 request method:get status code:200 ok (from cache) response headers accept-ranges:bytes access-control-allow-origin:* age:149381 cache-control:max-age=31536000 connection:keep-alive content-encoding:gzip content-length:56250 content-type:application/javascript date:wed, 01 apr 2015 15:28:14 gmt etag:"2a5ce-5128893ad1780-gzip" last-modified:mon, 30 mar 2015 21:58:06 gmt server:apache varnish-x-cache:h...

Linux shell script, checking input from user -

so i'm making simple bash shell script calculator , ran snag. i can't seem find out see if user has inputted + or - or / or * i'm not sure should try write. know echo "enter + or - " read input2 if [ $input2 = "+" ] echo "you entered $input2" doesn't work. should put read basic operators? edit: bash shell being used in bash, semicolon or newline needed before then . double quotes variables prevent expansion might lead syntax errors: if [ "$input" = '+' ] ; you can switch [[ ... ]] conditionals don't require quoting of arguments: if [[ $input = + ]] ; echo entered + fi you have quote * on right hand side, though, otherwise it's interpreted wildcard pattern, meaning "anything".

host - Dataset (Sysout) read error after COBOL program execution -

in rexx program, cobol program invoked , it's sysout captured using temporary dataset allocation (tso alloc) , using execio read. works without issues. one of our users (using different machine) reported issue @ execio read. irx0562e abnormal completion of data management macro. irx0565e sg0 ,$logon ,3420,d,sysout ,get ,wrng.len.record,0000003500000 0,qsam. iec020i 001-4,sg0,$logon,sysout,3420,bws858, iec020i sys15089.t170858.ra000.sg0.r0278041 iec020i dcb eropt=abe or invalid code, and/or no synad exit specified irx0250e system abend code 001, reason code 00000004. irx0255e abend in host command execio or address environment routine mvs. i found issue occured when cobol program has outputs on sysout. recreate similar situation in z/os system specifying 'vb' attribute in tso allocation. in case, allocated dataset not viewable in ispf. following error message shown, when trying view in ispf. 'i/o er...

sql - Detecting if data exists for OleDB COUNT query -

i'm trying pull data access database. as is, code works, , gives no errors... however, can't seem able display messagebox if record doesn't exist. returns empty string. using dbcon = new oledbconnection("provider=microsoft.ace.oledb.12.0;" & "data source = '" & application.startuppath & "\res\t500g.accdb'") dbcon.open() dim query1 string = "select sum(total) [t500] pro=@pro" dim cmd1 oledb.oledbcommand = new oledbcommand(query1, dbcon) cmd1.parameters.addwithvalue("@pro", comboboxbp.selecteditem.tostring) dim reader oledb.oledbdatareader reader = cmd1.executereader while reader.read() textbox1.text = reader.getvalue(0).tostring end while reader.close() dbcon.close() end using i've tried using if reader.hasrows then display result in textbox, else show messagebox etc, doesn'...

java - JRadioButton and component changes -

Image
i created jdialog box has 2 radio button change jlabel whenever clicked other button(for example: monthly salary when click full time button , hourly pay when click part time button) so questions how do that? create actionlistener radiobutton , create jpanel inside the actionperformed class? i think best way go create action listener button. when 1 selected change text monthlabel.settext("monthly salary");

How to play videos in android from raw folder and htm file -

how can play videos raw folder in .htm file on android? neither of these code snippets work me: <video id="video" controls> <source src="android.resource://tutorials.bodybuilding/raw/smit.mp4" type="video/mp4"> </video> or <video id="video" controls> <source src="url('android.resource://tutorials.bodybuilding/raw/smit.mp4')" type="video/mp4"> </video> according reading file in assets or raw folder in android guess addresses wrong. should consider uri.parse("android.resource://tutorials.bodybuilding/" + r.raw.csgsmit); returns every of videos , place html or @ runtime load html string , replace every address using such method , load modified html using webview.loaddata() or webview.loaddatawithbaseurl() passing modified html (a resluting string ).

c++ - 3 errors: error: 'Entry' was not declared in this scope. error: template argument 1 is invalid. error: invalid type in declaration before '(' token -

noob here, sorry error filled title. i'm trying compile segment of code bjarne stroustrup's 'the c++ programming language' codeblocks keeps throwing me error. the code range checking array held in vector function. #include <iostream> #include <vector> #include <array> using namespace std; int = 1000; template<class t> class vec : public vector<t> { public: vec() : vector<t>() { } t& operator[] (int i) {return vector<t>::at(i); } const t& operator[] (int i) const {return vector<t>::at(i); } //the at() operation vector subscript operation //that throws exception of type out_of_range //if argument out of vector's range. }; vec<entry> phone_book(1000); //this line giving me trouble int main() { return 0; } it's giving me these errors: error: 'entry' not declared in scope. error: template argument 1 invalid. error: invalid type in declaration bef...

oracle - Invalid number error - [Error Code: 1722, SQL State: 42000] ORA-01722: invalid number -

the 1st query below 2 queries giving me [error code: 1722, sql state: 42000] ora-01722: invalid number error. when limit no of records in 2nd query running fine. other limiting rows in 2nd query, both queries identical. select b.first_name, b.last_name, b.device_derived, b.ios_version_group, b.add_date, first_value (b.add_date) on (partition b.first_name, b.last_name, b.ios_version_group) first_date, last_value (b.add_date) on (partition b.first_name, b.last_name, b.ios_version_group) last_date (select a.first_name, a.last_name, a.os_version, a.device_type, a.device, a.add_date, a.device_derived, case when ( ( upper (a.device_derived) = 'iphone' or upper (a.device_derived) = 'ipad') , to_number (substr (a.os_ve...

Numeric for loop in Django templates -

how write numeric for loop in django template? mean like for = 1 n i've used simple technique works nicely small cases no special tags , no additional context. comes in handy {% in "xxxxxxxxxxxxxxxxxxxx" %} {{ forloop.counter0 }} {% endfor %} adjust length of "xxxxxxxxxxxxxxxxxxxx" according needs. "xxx" 3 iterations, etc.

html - Aligning a div with 2 divs inside it in Center -

Image
currently im trying 2 divs align in center, not quite sure how it. go left side default. i had margin-left:14 % , align in center, when re-sized window weird because aligned right side. tried with marign-left/right:auto, no result. html <div id="panels"> <div id="panel-left"> </div> <div id="panel-right"> </div> css #panels{ padding-top:15px; margin-left: auto; margin-right: auto; } #panel-left{ width:32%; min-width:209px; overflow:hidden; background-color:white; float:left; padding-left:25px; height:473px; } #panel-right{ width:32%; min-width:209px; height:473px; background-color:white; float:left; padding-left:25px; } try this: css #panels{ padding-top:15px; text-align:center; display: block; } #panel-left{ width:32%; min-width:209px; overflow:hidden; background-color:black; height:473px; display: inline-...

javascript - Making my own filter not working -

i trying make own filter in angularjs , way wrong guess. not able left here , need update. any 1 me fix this?, guess need convert filter service? if correct way this? my js : angular.module('myapp', []) angular.module('myapp.filters', []) .filter('capitalize', function(capitalize) { return function(input) { if (input) return input[0].touppercase() + input.slice(1); } }); html: <div ng-app="myapp"> {{ "san francisco cloudy" | lowercase | capitalize }} </div> demo your filter has 1 issue, not sure if that's meant - in function have function(capitalize) makes angular believe have service/factory of name. if that's have somewhere fine, doesn't seem you're using it. you can open dev console , see if see errors - guess will. removing makes work: myapp.filter('capitalize', function() { return function(input) { if (input) return input[0...

eclipse - Cannot access MSSQL using web service(Exception: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver) -

i have created basic web service using eclipse access 1 of databases , run simple query. when create web service in eclipse , test client, returns me exception exception: java.lang.classnotfoundexception: com.microsoft.sqlserver.jdbc.sqlserverdriver i have done following: use same code in different independent java class , runs fine. database return results. no exceptions. i have added classpath in eclipse runtime when creating web service (as did when tested step 1 above). this sample code in eclipse wrote , generate webservice from: package testservice; import java.sql.*; import javax.jws.webservice; @webservice public class testserv { public string testsql() throws sqlexception, classnotfoundexception{ string answer = "ok"; class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver"); connection conn = drivermanager.getconnection ("jdbc:sqlserver://192.168.69.207;...

javascript - How to disable and enable jquery validations in a same view -

i have view consists 3 blocks of code. each block contains 'required' java script validation fields. requirement user can submit form after filling 1 block. if press submit validations in second block , third block validations should disabled in mvc. can give me idea?

mongodb - Mongo Data not expiring -

i'm trying insert record in mongo expires in sometime. getmessagescollection().ensureindex(new basicdbobject("createdat", 1), new basicdbobject("expireafterseconds", 10)); i insert data this map map = new hashmap(); map.put("_id", mongomessage.getobjectid()); // other code map.put("createdat", new date()); getmessagescollection().insert(converttodbobject(map)) the field createdat date , before inserting object looks this { "_id" : "551bf9b72bea951ecf53fc5f" , "createdat" : { "$date" : "2015-04-01t09:59:19.723z"} , ...} but record not getting deleted. can tell me i'm doing wrong? looks you're incorrectly creating date. check out how it's done here date = new date(); basicdbobject time = new basicdbobject("ts", now);

.net - How to call generic methods with generic type parameter -

its more generics ninject, curious. the following is working fine . kernel.bind(typeof(ientityrepository<,>)).to(typeof(loggerrepository<,>)); but if want use generics? following gives me compile time error . kernel.bind<ientityrepository<,>>().to<loggerrepository<ientity<>,int>(); or kernel.bind<ientityrepository<,>>().to<loggerrepository<,>(); i sure missing pretty simple, , must have got answered in st. can kindly direct me answer please? edit: following works fine . kernel.bind<ientityrepository<appuser, int>>().to<entityrepository<appuser, int>>(); but guess there should way without specifying types(appuse , int). when not type arguments of generic specified, cannot used in expression other typeof(). article helpful you: unbound generics: open , closed case i'm referring part in particular, discusses use of unbound generics in conjunction dependency injection...

.net - NuGet automatic package restore poses problems for libraries -

when using nuget automatic package restore added in version 2.7, nuget automatically downloads missing packages packages\ folder located @ solution level. when solution includes libraries (i.e. git subtree or git submodules) causes problems library projects expect packages downloaded packages folder located in respective solution folder (which typically nested subfolder inside primary code's solution folder) , not know packages in primary code's solution folder. example: primary_code_folder\ ->primary_code.sln ->packages\ [various packages downloaded nuget] ->primary_code_project\ ->library_solution_folder\ --->library_code.sln --->packages\ [where library project expects packages reside] --->library_code_project\ potential solutions this: manually open each library project .sln file , build project ensure latest packages restored within each library package folder. undesirable requires each developer remember every time updates/install...

ios - Showing Full Image in UIImageView -

i using uiimageview show image. when image populates in imageview shows part of image (upper part ) not full image, image large. wondering if there way show full image in imageview without using scroll view user can have view of full image @ once without scrolling. you can change content mode of uiimageview. in attributes inspector can change it, example "scale fill". you can code too, example, in objective-c: imageview.contentmode = uiviewcontentmodescaletofill; if want keep aspect set uiviewcontentmodescaleaspectfit .

Implement Java annotations for validation -

i want call validator org.hibernate.validator.internal.constraintvalidators. manually on value because can't annotate class. i've done : lengthvalidator validator = new lengthvalidator(); validator.initialize(new length() { @override public class<? extends annotation> annotationtype() { return null; } @override public class<? extends payload>[] payload() { return null; } @override public int min() { return min == null ? defaultmin : min; } @override public string message() { return null; } @override public int max() { return max == null ? defaultmax : max; } @override public class<?>[] groups() { return null; } }); boolean valid = validator.isvalid(myvalue.astext(), null)); but sonar not happy : lambdas , anonymous classes should not have many lines so tried refactor code implementing @length in custom class : public c...

r - Post-processing of rules from arules -

is there way how more 1 level of single variable gets used in single rule generated apriori in arules package? consider following example: df <- read.table(header = true, text = ' v1 v2 v3 d x d x d y b d x b d x b d y e y e y e x b e y b e y b e x c d y ') library(arules) rules <- apriori(df, parameter = list(support= 0.001, confidence = 0.5, target = "rules"), appearance = list(rhs=c("v3=x"), default = 'lhs')) inspect(sort(rules, decreasing = true, = "confidence")) output> lhs rhs support confidence lift 1 {v1=a, v2=d} => {v3=x} 0.1538462 0.6666667 1.444444 2 {v1=b, v2=d} => {v3=x} 0.1538462 0.6666667 1.444444 3 {v2=d} => {v3=x} 0.3076923 0.5714286 1.238095 4 {v1=a} => {v3=x} 0.2307692 0.5000000 1.083333 5 {v1=b} => {v3=x} 0...

android - Container, Image and Text: How to get it working together? -

well, have container, image , texts (inside container), way: <relativelayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dp" android:layout_margin="10dp" android:id="@+id/btn"> <imageview android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/background" android:src="@drawable/background" android:scaletype="centercrop"/> <linearlayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon_left" android:layout_gravity...

java - Use of the Service method in Servlet while there is already doGet and other 6 methods present -

i coding simple servlet . prints values passed user , or in respective url parameters. when implementing doget method , saw same function can performed service method . code below : protected void service(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { printwriter o = resp.getwriter(); string user = req.getparameter("username"); httpsession session = req.getsession(); servletcontext context = req.getservletcontext(); if (user != "" && user != null) { session.setattribute("myhuzu", user); context.setattribute("myhuzu", user); } o.println("request parameter has value " + user); o.println("session parameter has user name " + session.getattribute("myhuzu")); o.println("context parameter has user name " + context.getattribute("myhuzu")); o.println(...

jpa - Error associating dependecies betwen EJB and PersistenceUnity on JBoss 7 -

i having problems while starting ejb application on jboss 7 or on eap 6.1 jboss 7.2 while associating dependencies between ejb , persistenceunit. line log error: 10:07:04,857 error [org.jboss.as.deployment] (deploymentscanner-threads - 1) {"composite operation failed , rolled back. steps failed:" => {"operation step-2" => {"services missing/unavailable dependencies" => ["jboss.deployment.unit.\"crm.war\".component.clientedaobean.start missing [ jboss.naming.context.java.module.crm.crm.\"env/br.com.crm.model.dao.clientedaobean/em\" ]","jboss.persistenceunit.\"crm.war#crmunity\" missing [ jboss.naming.context.java.jboss.datasources/crmds ]","jboss.deployment.unit.\"crm.war\".jndidependencyservice missing [ jboss.naming.context.java.module.crm.crm.\"env/br.com.crm.model.dao.clientedaobean/em\", jboss.naming.context.java.module.crm.crm.\"env/br.com.crm.model.dao...