Posts

Showing posts from August, 2013

java - Error ClassNotFoundException org.springframework.web.servlet.DispatcherServlet -

i have problem running project in eclipse java ee. i'm using apache tomcat 7.0 , when run program gives me following errors: java.lang.classnotfoundexception: org.springframework.web.servlet.dispatcherservlet @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1702) @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1547) @ org.apache.catalina.core.defaultinstancemanager.loadclass(defaultinstancemanager.java:532) @ org.apache.catalina.core.defaultinstancemanager.loadclassmaybeprivileged(defaultinstancemanager.java:514) @ org.apache.catalina.core.defaultinstancemanager.newinstance(defaultinstancemanager.java:142) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1144) @ org.apache.catalina.core.standardwrapper.load(standardwrapper.java:1088) @ org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:5176) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext

tomcat - Reason for sudden JVM crash -

background : have spring boot app running on tomcat,and running fine past couple of months. last week,i added feature update , wherein parsing considerably large csv file(about 90 mb) ,and storing csv data in couple of hashmaps. takes 20 sec or parse , 600 mb of space in jvm once loaded. parsing , loading happens on startup, i.e when spring boot app deployed. problem is,ever since i've added feature app,the jvm crashes sporadically. app runs fine few hours,then crashes. or jvm crashes app deployed.this happens atleast 3-4 times in day , , suffering downtime because of it. also,i can't seem find in tomcat logs. appreciate if can point me out in direction debug damn crash. thank you. it linux oom killer kills application, because of wrong xmx setup. can try @ dmesg log. dmesg -t | grep kill , find line killing app.

numpy - Python.. image processing -

i need store histograms of images database can later used compare histogram of image given user. problem: how can store histograms & how can compare histograms? import numpy np import cv2 matplotlib import pyplot plt def thresholded(center, pixels): out = [] in pixels: if >= center: out.append(1) else: out.append(0) return out def get_pixel_else_0(l, idx, idy, default=0): try: return l[idx,idy] except indexerror: return default img = cv2.imread('006a61.jpg', 0) transformed_img = cv2.imread('006a61.jpg', 0) x in range(0, len(img)): y in range(0, len(img[0])): center = img[x,y] top_left = get_pixel_else_0(img, x-1, y-1) top_up = get_pixel_else_0(img, x, y-1) top_right = get_pixel_else_0(img, x+1, y-1) right = get_pixel_else_0(img, x+1, y ) left = get_pixel_else_0(img, x-1, y ) botto

algorithm - Radix/LSD sort queue c++ -

i wrote radix sort using queue myself, because use theoretically during class , appeared interesting me . got familiar algorith , read this article radix sort , followed instructions ylc i tested using pseudo random numbers , looks doing job - array sorted @ end . have doubts proper memory management. exacly removing form queue , inserting array. there first question: are there leaks of memory ? i tought complexity of algorithm. read this artticle efficiency. n - size of array w - number of positions in our max number c1 = comparison in max function - done n times c2 = insertion @ queue - done n*w times c3 = remove queue - done n*w times c4 = insertion @ array - done n*w times t(n) = n c1 + n w*(c2+c3+c4) = o(w*n) memory complexity t(n) = n * sizeof(node) secound question: is reasoning logically? radix-sort #include <iostream> #include <cstdlib> #include <ctime> using namespace std; struct list {

android - Get file name from package folder in the External Storage -

in app download different extensions of file android download manager class . this download manager code (in onbindviewholder) : //=============btn download click listener ========================= holder.btndownload.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { downloadmanager downloadmanager = (downloadmanager) context.getsystemservice(context.download_service); downloadmanager.request request = new downloadmanager.request(uri.parse(questionha.get(position).getquestiondownlink())); request.settitle(questionha.get(position).getquestiontitle()); request.setdescription("downloading ..."); request.setdestinationinexternalfilesdir(v.getcontext(), "downloaded", questionha.get(position).getquestiondownfilename()); long enqueueid = downloadmanager.enqueue(request); } })

java - 404 Requested Resource is not Available Eclipse/Tomcat -

Image
this question has answer here: servlet returns “http status 404 requested resource (/servlet) not available” 1 answer i think i've read every question on topic far , tried lot of solutions, sorry if overlooked anything. i'm using eclipse tomcat 8. tomcat configured server , mysql-connector....jar in web-inf/lib folder, web.xml in /web-inf 1 , index in /webcontent index.html: <!doctype html> <html> <form action="servlets/start" method="post"> <font face="verdana" size="2"> enter table name :<input type="text" name="table"> <input type="submit" value="display"> </font> </form> </html start.java: import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.annotation.webserv

asp.net - asp button on click inside item template not firing -

not able make work. <asp:templatefield> <itemtemplate> <asp:button id="btnapprove" runat="server" text="approve" onclick ="btnapprove_click" /> </itemtemplate> </asp:templatefield> code behind: protected void btnapprove_click(object sender, eventargs e) { response.redirect("viewprofile.aspx"); } not firing when button clicked. tricks on this? set enableeventvalidation="false" right @ top in page directive: <%@ page enableeventvalidation="false" language="c#" ... just beware setting value false can expose website security vulnerabilities.as alternative, instead of setting enableeventvalidation="false" can handle grid views onrowcommand : .aspx: <asp:gridview id="gridview1" runat="server" onrowcommand="gridview1_rowcommand"> <columns> <asp:templatefield>

amazon web services - AccessDeniedException: User is not authorized to perform: lambda:InvokeFunction -

i'm trying invoke lambda function node. var aws = require('aws-sdk'); var lambda = new aws.lambda({ accesskeyid: 'id', secretaccesskey: 'key', region: 'us-west-2' }); lambda.invoke({ functionname: 'test1', payload: json.stringify({ key1: 'arjun', key2: 'kom', key3: 'ath' }) }, function(err, data) { if (err) console.log(err, err.stack); else console.log(data); }); the keys iam user. user has awslambdaexecute , awslambdabasicexecutionrole policies attached. i permission error: accessdeniedexception: user: arn:aws:iam::1221321312:user/cli not authorized perform: lambda:invokefunction on resource: arn:aws:lambda:us-west-2:1221321312:function:test1 i read docs , several blogs, i'm unable authorise user invoke lambda function. how user invoke lambda? thanks. the awslambdaexecute , awslambdabasicexecutionrole not provide permissions be

python - Construct an example where the KMP algorithm has to backtrack multiple times -

i'm trying construct example kmp algorithm computelpsarray phase have backtrack (see comment below) multiple times (cell in lps array). e.g. 'aaacaaa' visits backtrack section twice i = 3 , once i = 7 can me construct string visit backtrack section 3-4 times i ? def computelpsarray(pat, m, lps): len = 0 # length of previous longest prefix suffix lps[0]=0 # lps[0] 0 = 1 while < m: if pat[i]==pat[len]: len+=1 lps[i] = len i+=1 else: if len!=0: # backtrack section - when here 3-4 times same i??? len = lps[len-1] else: lps[i] = 0 i+=1 with 'aaaacaa' visits backtrack section 3 times i = 4 . with 'aaaaaca' visits backtrack section 4 times i = 5 .

Ubuntu install IntelliJIDEA (running environment of Spark) -

ubuntu install intellijidea @ command line. problem is: startup error:unable detect graphics environment. you need setup java_home. via terminal, set java_home install java: in case below yours different export java_home=/library/java/javavirtualmachines/jdk1.8.0_60.jdk/contents/home and set path addition provided java_home: export path=$java_home/bin:$path if not case mentioned in comments because no display var set correctly... nothing graphics card. just correct display settings the display setting may missing because you're perhaps trying execute root instead of normal userid

Visual Studio 2015 Update 2 package failed - Blocking setup error 0x80044000 -

i trying install visual studio 2015 update 2 on windows 10. first not install nuget , other packages due insufficient write acces programdata folder (even though ran installer admin). solved taking ownership of programdata folders. however, 1 error remains when installing update 2: [19e0:19d0][2016-05-28t13:32:45]i301: applying execute package: vsupdate_kb3022398, action: install, path: c:\programdata\package cache\0c0ba25532b60992e90c3255d09e004746c9cb2e\packages\vsupdate_kb3022398\vsupdate_kb3022398.exe, arguments: '"c:\programdata\package cache\0c0ba25532b60992e90c3255d09e004746c9cb2e\packages\vsupdate_kb3022398\vsupdate_kb3022398.exe" /q /norestart /disablesystemrestore /chainingpackage vs_community_enu_slip /ceipconsent /log "d:\temp_files\tmp\dd_vs_community_20160528132255_129_vsupdate_kb3022398.log" /originalsource "d:\temp_files\tmp\{b95f54cf-62f8-4668-ac15-16509eac5129}\vs_community.exe" /originaldisplaymode "full" -burn

javascript - Group by java-script Array object -

i have below array object in javascript [ ["english", 52], ["hindi", 154], ["hindi", 241], ["spanish", 10], ["french", 65], ["german", 98], ["russian", 10] ] what best way group array item based on language , average values in java-script. i using below code grouping. function (scores) { var map = {}; (var = 0; < scores.length; i++) { var score = map[scores[i][0]]; if (score) { score = { 'sum': score.sum + scores[i][1], 'count': score.match + 1, 'language': scores[i][0] }; score.avg = math.round(score.sum / score.count); map[scores[i][0]] = score; } else { map[scores[i][0]] = { 'sum': scores[i][1], 'count': 1, 'language': scores[i][0], 'avg': scores[i][1] }; } }

sql - PHP - Show Image From Database -

first of all, i've known there similiar questions in stackoverflow show images in php. but, code simple, & not complicated others, hope can answer in simple way. in database, have mahasiswa table. has these fields: nrp | nama | pass | jatah_sks | foto_profil i want program show foto_profil image. images saved in folder propic . code: $sql4 = "select foto_profil mahasiswa" . " nrp=".$nrp; $result4 = mysqli_query($link, $sql4); if (!$result4) { die("<h3>sql error</h3>" . $sql4); } $row4 = mysqli_fetch_array($result4); <img src="propic/<?php echo $row4['foto_profil'] ?>"/> the code shows no errors, foto_profil won't showed up. shows break-image icon. how right code? please explain answer. thanks you mixing php , html here.. want this: $sql4 = "select foto_profil mahasiswa" . " nrp=".$nrp; $result4 = mysqli_query($link, $sql4); if (!$res

javascript - State routes back to previous page even after login -

after refreshing page, state changes login . using $sessionstorage store data , able print them after login, when refresh page, page should stay on dashboard.html routes login state. angular.module('app', [ 'nganimate', 'ngcookies', 'ngresource', 'ngsanitize', 'nganimate', 'ngtouch', 'ui.bootstrap', 'ui.router', 'toaster', 'ngstorage' ]) .config(function ($stateprovider, $urlrouterprovider) { $stateprovider .state('login', { url: '/login', templateurl: "views/login.html" }) .state('dashboard', { url: '/dashboard', templateurl: "views/dashboard.html", required: true }); $urlrouterprovider.otherwise('/login'); }) .run(["$rootscope", "$state&quo

remove the zeros from an array with a function Python -

here's deal, have array of multiples elements half of being zeros. want remove these zeros using function instead of traditional x=x[x!=0] . i tried: def funct(x,y): x=x[x!=0] y=y[y!=0] but output same variable had before execute function. array multiple zeros. i'm new python sorry if question sound ridiculous. thank much! x[x!=0] returns new array, , assigned new array local variable x . you can do: def funct(x, y): x = x[x!=0] y = y[y!=0] # here return x,y a, b = funct(a, b) #assign returned value global variables

Calculate Height of a 2D Array of 0's and 1's in C -

i'm trying write program finds height of pixels of "image". "image" 2d array of 0's , 1's, 0's being white space, 1's being black pixels. the nested loop goes through array left right, first through x-axis, y-axis. i'm trying find highest value of y-value. plan store y values on 0 in new array, , find highest y-value. however, below code has stored y=5 array reason. i'm thinking order wrong maybe? #include <stdio.h> #define max_x 20 #define max_y 20 void printimage(int image[max_x][max_y]); int countblackpixels(int image[max_x][max_y]); int findypixel(int image[max_x][max_y]); //function prototypes void processimage(int image[max_x][max_y]) { int ypixel; ypixel = findypixel(image); printf("height: %d\n", ypixel); } //height //calculates height of image int findypixel(int image[max_x][max_y]) { int x, y, ypixel, i; int new_array[max_y-1]; x = 0; ypixel=-1; whi

visual studio code - Typescript: Argument of type 'RegExpMatchArray' is not assignable to parameter of type 'string' -

i have following expression: import { persiststate } 'redux-devtools'; const enhancer = compose( applymiddleware(thunk, router, logger), devtools.instrument(), persiststate( window.location.href.match(/[?&]debug_session=([^&]+)\b/) ) ); i swiggly on argument match function following error argument of type 'regexpmatcharray' not assignable parameter of type 'string'. matches string regular expression, , returns array containing results of search. (method) string.match(regexp: regexp): regexpmatcharray (+1 overload) the peek definition in vscode shows: match(regexp: string): regexpmatcharray; /** * matches string regular expression, , returns array containing results of search. * @param regexp regular expression object contains regular expression pattern , applicable flags. */ match(regexp: regexp): regexpmatcharray; /** * replaces text in string, using regular expression or search string. * @param searchvalu

java - How to restore JSON stored in database to <MyClass> object -

i've got sqlite database in current android project text columns represent json objects converted own java classes. this: string myclassinjsonstring = gson.tojson(myjavaclass.class) gson class allows me use .fromjson(string, objecttype) method convert json string stored in database original class getters , setters. my question: there way save class database original class type use getters , concrete value of object? i can use this, don't want (long) json strings loaded xml textviews or views. i'd load original class type, use getter , value want show in textview. string[] = {provider.myclass.first_colum, provider.myclass.second_column }; int[] = {r.id.textid_1, r.id.textid_2}; this.simplecursoradapter = new simplecursoradapter(this, r.layout.list_layout, null, from, to, defaults.no_flags); should use (own) adapter, not simplecursoradapter? thanks. i decided change column type text blob , used code list of entity. public list<entity>

python - My scapy ipv6 route list is empty. How can i fix it. -

i coding in python , working ipv6. program wrote says sending packets upon closer inspection wireshark realized not send them out. source of problem scapy not innately find ipv6 route list, i.e. interfaces used in order send packet out. list empty. moreover, when printing dnet.intf() prints possible interfaces there no ipv6 interface in there. how can add new ipv6 interface? here ip config: ethernet adapter local area connection 4: connection-specific dns suffix . : ecs.soton.ac.uk ipv6 address. . . . . . . . . . . : 2001:630:d0:f105:5cfe:e988:421a:a7b7 temporary ipv6 address. . . . . . : 2001:630:d0:f105:e8bc:7c26:9a40:31b8 link-local ipv6 address . . . . . : fe80::5cfe:e988:421a:a7b7%17 ipv4 address. . . . . . . . . . . : 152.78.61.39 subnet mask . . . . . . . . . . . : 255.255.255.0 default gateway . . . . . . . . . : fe80::210:18ff:fee5:5bfa%17 152.78.61.254 tunnel adapter 6to4 adapter: media state . . . .

rest - Stock Quantity of ProductVariant not decreased in shopify shop when placing order via API -

i posting following order shopify api order endpoint. order shows in shop , works should, except stock quantity of variants in orders placed via api not decreased automatically shopify. when place order within admin console, decreased automatically. shopify inventory tracking turned on products. ideas appreciated. { "order": { "email": "somename@yahoo.com", "financial_status": "paid", "fulfillment_status": null, "send_receipt": true, "send_fulfillment_receipt": true, "note": "created somename", "line_items": [ { "variant_id": 21718275463, "quantity": 1, "price": 99, "requires_shipping": true, "product_id": 6820646151 }, { "variant_id": 21717700871, "quantity": 1, "price": 1000,

php - “Get product X for free on orders over $100” coupon code in WooCommerce -

Image
is there simple way or plugin around allows create coupon code following kind of offer: "get product x free on orders on $100"? yes possible additional plugin: commercial version of woocommerce extended coupon features . in woocommerce coupons settings have minimum field orders amount: the free version of plugin has auto coupons functionality, allow coupons automatically added users cart if it's restrictions met. above with inexpensive commercial version of plugin have missing functionality need: adding free products customer's cart based on coupon rules. so 3 functionalities, conditions met auto add coupon code "get product x free on orders on $100". additional tricks woocommerce coupons 1) woothemes snippet: create coupon programmatically 2) auto apply discount coupon customer’s purchase: function order_price_is_greater_than_100() { global $woocommerce, $total_qty; if ( $woocommerce->cart->has_discou

PHP socket server that uses ADH. How? -

i'm trying create socket server using stream_socket_server() . normal connections work fine, want make server encrypts connection without certificate. know can accomplished adh cipher, , yes, know it's theoretically less secure certificate... the reason i'm making server in first place mock different server client connects (over this protocol , if you're wondering). the client configured ask certificate first, , fallback adh - i've tested real thing, , connects without problems, problem socket server. everything i've tried far has resulted in "handshake failure" error. some of configurations i've tried: <?php $server = stream_socket_server( "tls://127.0.0.1:6667", $errorno, $errstr, stream_server_bind | stream_server_listen, stream_context_create( array('ssl' => array('ciphers' => 'adh')) ) ); ?> <?php $server = stream_s

database - Phonegab Data retrieval -

i new phonegap development , question how display data database phonegap application? there many similar questions none of them pointing correct solution. you can check data using web services. or local, can use sqlite

angularjs - Iterate through an array of objects Angular 2 -

i have array of objects received in service file json file. when subscribe in component , try iterate through it, getting following error: exception: error in app/dashboard/features/fleet/fleetcontrolpanel/fleetcontrolpaneltemplate.html:38:14browserdomadapter.logerror @ browser_adapter.ts:78browserdomadapter.loggroup @ browser_adapter.ts:89exceptionhandler.call @ exception_handler.ts:53(anonymous function) @ application_ref.ts:304schedulerfn @ async.ts:131safesubscriber.__tryorunsub @ subscriber.ts:240safesubscriber.next @ subscriber.ts:192subscriber._next @ subscriber.ts:133subscriber.next @ subscriber.ts:93subject._finalnext @ subject.ts:154subject._next @ subject.ts:144subject.next @ subject.ts:90eventemitter.emit @ async.ts:117ngzone._zoneimpl.ng_zone_impl_1.ngzoneimpl.onerror @ ng_zone.ts:138ngzoneimpl.inner.inner.fork.onhandleerror @ ng_zone_impl.ts:90zonedelegate.handleerror @ zone.js:327zone.runguarded @ zone.js:233ngzoneimpl.runinnerguarded @ ng_zone_impl.ts:100ngzone.ru

AngularJS and jQuery conflict resolution -

i have built angularjs single page application in asp.net. added jquery in order send uploaded files server. code in jquery short , sweet , solutions saw in angularjs seemed lot more complex. website stops working when include jquery cdn script tag. in developer tools console see error; error: k undefined n.event.remove@ https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js:3:6618 when take out jquery script links error goes away. links include jquery these, placed before angularjs links: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <script>var jq = jquery.noconflict();</script> the noconflict method doesn't seem solve problem. how correct conflict? there solution keep jquery in application, or should again way upload files using angularjs? edit: i'm loading these angular scripts , else homegrown script: <script src="https://ajax.googleapis.com/ajax/libs/ang

php - Search by product color - WooCommerce -

i've been trying time figure out correct $args-array making custom search form, allowing user search products name, description , custom woocommerce attributes (as color). is possible using wp_query @ or need alter built in search function? , if - how? here's $args-options i've been trying now: $args = array( 'posts_per_page' => 20, 'no_found_rows' => true, 'post_type' => array('product'), 'tax_query' => array( array( 'taxonomy' => 'oct-search', 'field' => 'slug', 'terms' => array($_post["search_string"]), ), ), ); okay, solved on own hand, using code: $attributes = 'oct-shade'; $attributes = 'pa_'.$attributes; $filters = explode(',', $_post["search_string"]); $args = array( 'posts_per_page' => 20, 'no_found_rows

javascript - how to get pixel color from image using x and y coordinates? -

what tryting take "pixel.jpg" , cosole.log rgb value of pixel @ x , y values determined variable. im assuming need create canvas , scan entire thing using loop.. ?? <meta charset="utf-8"> title>pixel</title> <link href="pixel.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="pixel.js"></script> <pre id="output"></pre> draw pixel on canvas. use getimagedata . var getpixelcolor = function(img,x,y){ var canvas = document.createelement('canvas'); canvas.width = 1; canvas.height = 1; var ctx = canvas.getcontext('2d'); ctx.drawimage(img,x,y,1,1,0,0,1,1); return ctx.getimagedata(0,0,1,1); }

r - Install a specific release of bioconductor package -

i had bioconductor package version 1.2.14, , i've updated version 1.4.2 , unfortunately different results. i want make sure because of package update. there way revert old version, or alternatively remove current version , specify installation of old one? alternatively, can see branches on github , wonder whether correspond different version bioconductor. so, can install github branch release? step1 in object browser (of revo r ent), right-click bioconductor package under "packages loaded", , click unload package. step2 in object browser (of revo r ent), right-click bioconductor package under "packages installed", , click unload package. step3 close r's gui (in example:revo r ent). step4 (for revo r ent users) delete .xml file: c:\users\user\documents\revolution\32_7.3\packagexmls\bioconductor.xml the file bioconductor.xml (related v1.4.2) has duty of functions of bioconductor 1.4.2 processed in r's gui. step5 libra

why do I need to make sumproduct an array formula to make it work -

lets keep example simple. trying figure out why count coming correct when enter formula cse wrong when don't when whole formula sumproduct. example 1 b | c | d | e | f condtion 1 | condition 2 | strings jan 2016 | strings feb 2016 | strings mar 2016 15/06/01 | 17/06/01 | 2 | 4 | 6 example 2 condtion 1 | condition 2 | strings jan 2016 | strings | strings mar 2016 15/06/01 | 17/06/01 | 2 | 4 | 6 i tinkering formula add values if date in first row between dates in condition 1 , condition 2 excel date serials. came with: =sumproduct((date(right($d$1:$f$1,4),month(mid($d$1:$f$1,9,3)&"-1"),1)>=$b2)*(date(right($d$1:$f$1,4),month(mid($d$1:$f$1,9,3)&"-1"),1)<$c2)*(left($d$1:$f$1,7)="strings")*$d$2:$f$2) and works fine example 1. example 2 when make date not in string, formula produces

Unable to connect Javafx controller event with FXML shape. (Java) -

i'm having trouble understanding why super, super simple method isn't working. i've got standard mvc setup - have controller controls layout (the fxml file). in fxml, i've created various shapes see if issue shapes in particular (it wasn't...). want attach method in controller shape in fxml causes counter increase 1 per click of shape, , outputs current count console. it's not working! here's relevant code: (controller class) @fxml sphere asteroid; private int counter = 0; @fxml void addrandomresource(actionevent event) { asteroid.setonmousepressed(new eventhandler<mouseevent>(){ public void handle(mouseevent event){ counter += 1; system.out.println(counter); } }); } (fxml) <sphere fx:id="asteroid" layoutx="250.0" layouty="300.0" radius="125.0" /> i know controller connected because other buttons on page work... that's not issue. , c

java - Brick Breaker Random Color -

the problem i'm having when run game, instead of staying 1 random color, bricks keep changing color while i'm in game. how fix each brick stay 1 color? public class game extends joeapplet implements keylistener { string status; int ballx = 294; // ball spawn x coordinate int bally = 640; // ball spawn y coordinate int batx = 294; int baty = 654; int brickx = 32; int bricky = 50; double movex = -16; // x speed of ball double movey = -16; //y speed of ball int count = 0; int currentlevel=0; int score=0; //starts score @ 0 int lives=3; //lives start @ 3 static boolean right = false; static boolean left = false; boolean ballfalldown = false; boolean bricksover = false; rectangle ball = new rectangle(ballx, bally, 12, 12); //creates ball rectangle bat = new rectangle(batx, baty, 100, 12); //creates bat(paddle) rectangle[] brick = new rectangle[49]; //creates desired number of