Posts

hadoop - How to count the different values in a column in Pig and Hive -

i have data file below indicates order valid or invalid. want calculate count of valid orders , count of invalid orders. 1,flipkart,pepsi,invalid 2,flipkart,tshirt,valid 3,flipkart,shirt,valid 4,amazon,shoe,valid 5,amazon,beer,invalid 6,flipkart,jewels,valid 7,flipkart,coke,invalid so final output should how many number of valid , invalid records totally eg : valid : 7 , invalid 3 in flipkart, how many valid , invalid records , in amazon how many valid , invalid records. eg : flipkart : valid 3 , invalid : 2 amazon : valid 1 , invalid : 1 in pig - groupby , foreach assuming column names id,name,pp,state bynamestate = group my_data (name, state); bynamestatecounts = foreach bynamestate generate count(my_data) ccc;

How to read a binary file using Fortran and save to a text file? -

i have binary file following information: ifile.dat big_endian sequential, nx=530, ny= 427, t=1, 4 variables i read fortran program , write text file. trial f90 program is: bin_read.f90: integer,parameter :: nx=530, ny=427 real :: v1(nx,ny),v2(nx,ny),v3(nx,ny),v4(nx,ny) open(10, file= 'ifile.dat', form = 'unformatted', & &access='sequential',convert='big_endian') open(11, file= 'ofile.txt', form = 'formatted', & &status='unknown') j = 1, ny = 1, nx read(10,*)v1(i,j),v2(i,j),v3(i,j),v4(i,j) write(11,1)v1(i,j),v2(i,j),v3(i,j),v4(i,j) 1 format(4(1x,f8.3)) enddo enddo stop end when execute after compilation, getting following message: at line 11 of file bin_read.f90 (unit = 10, file = 'ifile.dat') fortran runtime error: format present unformatted data transfer

get - Servlet and path parameters like /xyz/{value}/test, how to map in web.xml? -

does servlet support urls follows: /xyz/{value}/test where value replaced text or number. how map in web.xml? it's not supported servlet api have url pattern wildcard * in middle of mapping. allows wildcard * in end of mapping /prefix/* or in start of mapping *.suffix . with standard allowed url pattern syntax best bet map on /xyz/* , extract path information using httpservletrequest#getpathinfo() . so, given <url-pattern>/xyz/*</url-pattern> , here's basic kickoff example how extract path information, null checks , array index out of bounds checks omitted: string pathinfo = request.getpathinfo(); // /{value}/test string[] pathparts = pathinfo.split("/"); string part1 = pathparts[1]; // {value} string part2 = pathparts[2]; // test // ... if want more finer grained control possible apache httpd's mod_rewrite , @ tuckey's url rewrite filter .

ASP.NET Hyperlinks asp:HyperLink vs A href -

in asp.net when should use: <asp:hyperlink id="home" runat="server" text="home" navigateurl="./home.aspx"> and when shoudl use <a href="./unsignedvssignedtut.aspx">home</a> ? asp.net server controls give more abilities (e.g. event handling, more properties). html controls on other hand simpler. both controls fine. can start html control , migrate asp:hyperlink if need later. you can @ these discussions: asp control vs html control asp.net control vs html control performance

javascript - Two-dimensional string array creation -

this question has answer here: array.prototype.fill() different fill go 1 answer array.prototype.fill() object passes reference , not new instance 2 answers i'm trying create two-dimensional array of 1-character strings in javascript way: var panel = new array(3).fill(new array(3).fill('*')); result is [ ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'] ] after need replace middle string: panel[1][1] = '#'; and result is [ ['*', '#', '*'], ['*', '#', '*'], ['*', '#', '*'] ] so seems prototype fill function fills array object reference. is possible force fill function fill a...

oracle9i - Oracle select count(*) into n generates ORA-01401 inserted value too large for column -

i have spent hours tracking down source of bug , stumped. managed determine below simple select statement problem (comment , not error.. yes, it's cause). n defined number, tried integer grins. n integer; n := 1; select count(*) n category ( upper(ltrim(rtrim(category_long_name))) = upper(ltrim(rtrim(cat_long_name))) or upper(ltrim(rtrim(category_short_name))) = upper(ltrim(rtrim(cat_short_name))) or upper(ltrim(rtrim(category_description))) = upper(ltrim(rtrim(cat_descr))) ) , (settings_setting_id = sett_id) , (category_id <> cat_id); when code executed, ora-01401: inserted value large column . "insert" n value row count. actual value (used debugger) 0. i don't understand how causing problem. i've seen select count(*) x code snippet in examples. procedure runs fine statement commented out. time 'n' used in next step raise , exception if it's > 0. i've literally commented ...

Android MVP - How to communicate between activity presenter and fragment presenter -

i have activity 3 fragments, use viewpager. want implement mvp , communicate between activity presenter , fragment presenters i.e: passing data activity presenter fragment presenters sending event fragment presenters activity presenter ... but don't know how in official way. can use busevent don't think it's practice. as per understanding, usecase, suppose activitya have viewpager having 3 fragments(fragmenta, fragmentb, fragmentc). activitya have activitypresentera fragmenta have fragmentpresentera as per mvp, fragmentpresentera should responsible logical , business flows of fragmenta , should communicate fragmenta only. therefore, fragmentpresentera can not directly communicate activitypresentera. for communication fragment activity, presenter should not involved , should done communicate in non-mvp architecture, i.e. of interface. same applies activity fragment communication. for communication between activity , fragment read here

lambda - Vectorize Loop with nested lists in Python -

looking vectorizing loop in python: for in range(len(listone)): listtwo.append(listthree[listfour[a]]) i want test potential performance gains not having call append via loop. if not vectorization, perhaps lambda expression might suffice? thoughts or assistance immensely helpful! thank time! there's nothing wrong loop, change comprehension if want avoid append() : listtwo = [listthree[listfour[a]] in range(len(listone))]

php - Setting SQLite as my database in laravel 5 -

Image
i'm creating small mockup social network in laravel 5. want use sqlite database keep things small , local. i'm having trouble, however, getting work. here's code (using blade) use table display row in database: @extends('layouts.master') @section('title') testing2 @stop @section('content') second test <a href="/">back page 1</a> <table> <tr><th>author</th> <th>text</th></tr> @foreach($posts $post) <tr> <td> {{$posts->author}} </td> </tr> <tr> <td> {{$posts->text}} </td> </tr> @endforeach </table> @stop "author" , "text" being 2 columns in database. here route use generate page: route::get('test2', function () { $sql = "select * posts"; ...

JQuery validation rule depends on another rule -

i have form required field depend on form field value. required rule may true or false depend on other field. issue accept rule should there if required true. how can that? ..., fielda: { maxlength: 3, accept: "[0-9]{3}", required: function() { if($('#fieldb').val() == 'abcd') { return false; } else { return true; } } },... thanks in advance. i didn't realize 'accept' rule custom rule. edited code check whether optional field. this.optional(element) jquery.validator.addmethod("accept", function(value, element, param) { return this.optional(element) || value.match(new regexp("^" + param + "$")); }); @barmar help.

python - User Input to mySQL database -

i want simple python program prompt user title , search mysql database. have database constructed can't figure out how query properly. import mysqldb servername = "localhost"; username = "username"; password = "password"; conn = mysqldb.connect(user=username,host=servername, passwd=password, db=db) cursor = conn.cursor() user_input = raw_input("what want watch?:") query= ("select * videos title %s") cursor.execute(query,user_input) if, hardcode query "where title '%hardcode%' ", works fine. figure solution pretty simple life of me can't figure out. appreciated! i've tried every variation find online no avail. others tried: query= ("select * videos title concat('%',%s,'%')") cursor.execute(query,(user_input,)) query= ("select * videos title (search)" "values (%s)", user_input) ... don't work. errors seem revolve around me passing va...

real time - How to make esper epl divide section and compare value -

i new using esper . don't know esper epl , i'm in trouble. problem this. user define value section. for example, level1 : 1~3 level2 : 4~6 level3 : 7~9 so when data come first, check section , make events. previous value , new value same level nothing (ex. prev value=1, next value=2 these in same level1) . in other words, when data come, check previous value , level. if have different level, something. esper epl can this? how can make it? the "prior" , "prev" both give access event before given event. sql standard "case when then" if-then-else of sql standard. this: insert categorizedstream select case when value between 1 , 3 1 when value between 4 , 6 2 when value > 6 3 end level someevent; select * categorizedstream(prior(level) != level); one use prior , case-when in 1 epl statement think becomes more readable using 2 statements.

javascript - How to abort/cancel promise for first call during 2 consecutive angular service calls? -

when 2 consecutive service calls made through $http angular service on dropdown item selection , assume first call took time return , second call return before first call resolve shows data of first call second item selection. so there way abort first promise if service call made again before first call resolves. for demo purpose created sample plunkar has dropdown few items added explicit condition on selection of first item took little longer time other items. select first item , select second item reproduce scenario, check favorite books display on screen. any appreciated! service code: app.factory('bookservice', function($http, $q, $timeout) { return { getbook: function(id) { var promise = $q.defer(); var timeoutspan = id == 1 ? 3000 : 500; $http.get("favouritebooks.json").success(function(data) { $timeout(function() { promise.resolve(data.filter(function(obj) { return obj.id == id }))...

javascript - Non blocking render in ReactJS -

i'm learning reactjs , trying build application on it. when i'm trying modify state , render, page freezing , can't until render finished when components become huge. i found can use shouldcomponentupdate optimize code, question comes me is: can make render procedure non blocking? , can tell user page processing heavy loading executions , please wait or maybe show progress of execution? or if user can cancel render, example, live editor, if user edit content of editor, "preview" section stop rendering old content , trying render new content without blocking editor ui? here's heavy loading example code: <!doctype html> <html> <head> <meta charset="utf-8" /> <title>react tutorial</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.js...

css - Rounded dotted border with gradient -

Image
how make rounded dotted border gradient in css3? found borders gradient , dotted borders separately. have implement: you can set white dotted border on top of gradient image covering border zone. looks request .test { width: 300px; height: 80px; margin: 10px; border: dotted 10px white; border-radius: 50px; background-image: linear-gradient(white, white), linear-gradient(blue, magenta); background-origin: border-box; background-clip: content-box, border-box; } <div class="test"></div>

AngularJS + Jersey POST Bad Request -

i have following api in jersey file upload : @path("/image/upload") @post @consumes(mediatype.multipart_form_data) @produces("application/json") public response imageupload( @queryparam("filename") string filename, @formdataparam("file") inputstream fileinputstring, @context containerrequestcontext crc) throws connectexception, sqlexception, invalidcredentialsexception, ioexception, generalexception { } and using angular js uploading file : _myapp.service('fileupload', ['$rootscope', '$http', function($rootscope, $http) { this.uploadfiletourl = function(file, uploadurl) { var fd = new formdata(); fd.append('file', file); $http.post(uploadurl, fd, { transformrequest: angular.identity, headers: { 'content-type': 'multipart/form-data', ...

How to select text from HTML table using PHP DOM query? -

how can text html table cells using php dom query? html table is: <table> <tr> <th>job location:</th> <td><a href="/#">kabul</a> </td> </tr> <tr> <th>nationality:</th> <td>afghan</td> </tr> <tr> <th>category:</th> <td>program</td> </tr> </table> i have following query doesn't work: $xmlpagedom = new domdocument(); @$xmlpagedom->loadhtml($html); $xmlpagexpath = new domxpath($xmlpagedom); $value = $xmlpagexpath->query('//table td /text()'); get complete table php domdocument , print it the answer this: $html = "<table id='myid'><tr><td>1</td><td>2</td></tr><tr><td>4</td><td>5</td></tr><tr><td>7</td><td>8</td></tr></table>"; $xml =...

javascript - How to loop through all text box elements in a page source and find the names of all those text boxes? -

i writing program output number of gui elements in webpage if source page given input , should output names of text boxes. the code wrote : <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>my app</title> <link rel="icon" type="image/x-icon" href="favicon.ico" /> </head> <body> <textarea id="textarea1"></textarea> <br /> <input id="submit1" type="submit" value="submit" /></div> <script> var $textarea = $('#textarea1'), $submit = $('#submit1'); $submit.click(function (e) { e.preventdefault(); sourcecode = $textarea.val(); var $searchobject = $('<div id="searching"></div>'); $searchobject.append($(sourcecode));...

php - How to load css files, javascript files and images in codeigniter? -

my application structure is application assets -css -images -js system 1- load url helper in controller's constructor, $this->load->helper('url'); 2- use base url function load js, css files in view <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css"> p.s: have put js, css files in root folders. (default)

DocuSign API how to get Integrator Key -

just signed docu sign sandbox following instructions in docs when go admin > api , keys there no option create integrator key. tells me don't have any, no button allowing me create one. has had happen? there bug in system option missing. still available if use top right dropdown , "switch classic." there can go preferences --> api , generate integrator key. detailed instructions can found here.