Posts

Showing posts from January, 2012

apache pig - pig latin FILTER and GENERATE -

i have simple tuple (userid, country, amount, transactionid, date, crap1, crap2,crap3) i using filter filter out data , @ same time want drop elements tuple. reason exist in tuple cause need them @ earlier point not after filter. currently doing b = filter date == 'xxxx'; c = foreach b generate name, country, tranactionid; is possible in 1 statement (to speed query), because understand foreach + filter + generate work on nested bags. not possible.. filter alias expression; and foreach { gen_blk | nested_gen_blk } [as schema];

jquery - How to make an ajax request in login form with spring security? -

i read several articles , followed them didn't work in case. login form follows:- <div style="text-align: center; padding: 30px; border: 1px solid; width: 300px;"> <form method="post" action='j_spring_security_check' id="login_form" > <table> <tr> <td colspan="2" style="color: red">${message}</td> </tr> <tr> <td>user name:</td> <td><input type="text" name="j_username" id="uname" value='<c:if test="${not empty param.login_error}"> <c:out value="${spring_security_last_username}"/> </c:if>' /></td> </tr> <tr> <td>password:</td> ...

android - how can telephony manager conditionally listen to multiple PhoneStateListener's events? -

i'm having telephony manager listening call_state. now want additionally listen data_connection_state , service_state using same telephony manager under different conditions (plz refer following code snippet) how can it? my current code seems not work properly telephonymanager = (telephonymanager) getsystemservice(context.telephony_service); phonestatelistener = new phonestatelistener() { public void oncallstatechanged(int state, string incomingnumber) { switch (state) { case telephonymanager.call_state_idle: case telephonymanager.call_state_offhook: // break; case telephonymanager.call_state_ringing: break; } super.oncallstatechanged(state, incomingnumber); } public void onservicestatechanged(servicestate servicestate) { switch (servicestate.getstate()) { case servicestate.state_emergency_only: case servicestate.state_out_of_service: // ...

osx - Path autocomplete does not work in PhpStorm -

i have clean install of latest phpstorm 2016.1.2 version running on os x el capitan. while code completion works perfectly, can not use path completion @ all. if type ../ expect files/folders suggestion parent folder, message "no suggestion". same thing happens if try relative or absolute paths or file names without path. also if type path hand, can not click on cmd , mouse. path not resolved. the same code works webstorm on same computer. works on other identical computers same os x , phpstorm versions. i tried clearing cache, creating new project, reinstalling phpstorm, flushing phpstorm preferences (deleting files) nothing helped. i found path autocomplete not work when use common.js require syntax. installing node.js plugin phpstorm solved problem.

i am trying to replace each column values which contain 1's in an array with alphabets using c#, doesn't seem to work -

my array looks this: c1 c2 c3 c4 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 so in above need replace c1 column values a, c2 column values b, c3 column values c code have used still displays entire file changes not being implemented: var lines = file.readalllines(@"d:\as.csv"); (var = 1; < lines.length; i++) { var linesplit = lines[i].split(new[] { ' ' }, stringsplitoptions.removeemptyentries); linesplit[0] = linesplit[0].equals("1") ? "a" : linesplit[0]; linesplit[1] = linesplit[1].equals("1") ? "b" : linesplit[1]; linesplit[2] = linesplit[2].equals("1") ? "c" : linesplit[2]; console.writeline(linesplit[0]); } console.readline(); this can you. foreach (var item in list) { item.c1 = item.c1.equals("1") ? "...

Hibernate Search query searches all tables instead of only the specified class' table -

i have abstract class product subclassed producta , productb , productc . , classes producta , productb , productc mapped database tables products_a , products_b , products_c respectively. now want perform full-text search on producta entities hibernate search. wrote code expected producta entities database, found in log ( as follows ) executed hibernate search query searched tables products_a , products_b , products_c instead of table products_a expected. i want producta entities, why productb , products_c tables searched? there way fix this? log you can see following working log outputted hibernate besides products_a table, products_b , products_c tables searched. hibernate: select this_.id id1_2_0_, this_.name name2_2_0_, this_.feature feature3_2_0_, this_.created_date created_4_2_0_, this_.modified_date modified5_2_0_, this_.feature_a1 feature_1_3_0_, this_.feature_a2 feature_2_3_0_, this_.feature_b1 feature_1_4_0_, this_.feature_b2 feature_2_4_0_...

Hbase REST API /status/cluster : difference between "text/plain" and "application/json" -

first, result regions. text/plain : % curl http://localhost:8000/status/cluster application/json : % curl -h "accept: application/json" http://localhost:8000/status/cluster but, second, region name did not match. which is, "text/plain" this: "*content,601292a839b95e50200d8f8767859864,1244869158156*" "application/json" :"*dxjscyxodhrwfhdlyxrozxiuym9zdg9ulmnvbxw4mhxmwu5yl mpzldeyndq4nte5ota4ntk*" how can transfer " dxjscyxodhrwfhdlyxrozxiuym9zdg9ulmnvbxw4mhxmwu5ylmpzldeyndq4nte5ota4ntk " to " content,601292a839b95e50200d8f8767859864,1244869158156 "

Entity Framework does not add / save to database -

i searched alot problem, hadn't found anything! i created database , table , connect form entityframework those.. when type data informations , click on add button, database doesn't add new row ... (these codes) main code: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.data.entity.validation; using system.diagnostics; namespace windowsformsapplication6 { public partial class buyform : form { public buyform() { initializecomponent(); } private void buyform_load(object sender, eventargs e) { } notebookentities database = new notebookentities(); private void buygridview_cellcontentclick(object sender, datagridviewcelleventargs e) { } private void buyform_load_1(object sen...

graph - How to rotate a function and get coordinates in python? -

https://postimg.org/image/uzdalt4s1/ the script below give coordinates of point going through sine function (figure in url image) similar figure a, how coordinates of rotated function? (figure b) from time import sleep import math x = 100 y = 500 f = 0 while 1: print('x: '+str(x)) print('y: '+str(math.sin(f)*100+y)) f += math.pi/50 x += 1 sleep(0.01) this should work: from time import sleep import math def get_rotated_coordinates(x, y, fi, angle = 'deg'): ''' function rotates coordinates x , y angle fi, variable angle tells if angle fi in degrees or radians, default value 'deg' degrees, can use 'rad' radians''' if angle == 'deg': fi = math.radians(fi) elif angle != 'rad': raise valueerror('{} unsuported type angle.\nyou can use "deg" degrees , "rad" radians.'.format(angle)) k = math.tan(fi) ...

visual studio - Ignore unit tests part of an ordered test -

i've got vs2015 update 2 solution includes unit test project. part of test project, i've got bunch of unit tests , integration tests. the integration tests ordered tests fire off bunch of test method in correct sequence, along initialization code injects actual dependencies instead of mocks. when run tests vs, it's hitting unit tests in ordered tests twice. guess once because they're in ordered tests file, , once because methods labeled [testmethod] (but otherwise can't add them ordered test file). not intended; need these methods run part of ordered test, should not fire off individually (in wrong sequence). in end decided go 1 testmethod calls several methods integration scenario. eliminates need 'hide' tests part of ordered test, in fact eliminates entire need ordered test. word of caution: should not calling other tests within test, create seperate class sets integration test scenario , runs of tests want perform.

c - How to debug a preprocessor macro -

i came across this project . code largely written in c , api consists of few c functions. unfortunately project seems contain bugs, in particular keep getting "double free or corruption" errors. trying use valgrind , gdb find out wrong. problem seems in memory allocator. unfortunately first valgrind error occurs in ~400 line long preprocessor macro defined in header. unfortunately gdb can't break on generated code. stack trace not useful either. there technique can used deal these kind of errors? the online compiler wandbox.org has "cpp" mode useful experiment c preprocessor. see example here: https://wandbox.org/permlink/tfuskmixaqj8hhte you can same thing offline, gcc -p or cl.exe /e

php - include country code as array & store view as switch cases -

we assigning 5 store views 200 countries using below code. now following below code in, at, ir, au country codes. usa, canada store views. like need assign each country code 1 store view 200+ countries. there way can use array , use 5 switch cases & include many country codes in 1 switch case. switch ($cncode) { case "in": { mage::app()->setcurrentstore('usa'); break; } case "at": { mage::app()->setcurrentstore('usa'); break; } case "ir": { mage::app()->setcurrentstore('usa'); break; } case "au": { mage::app()->setcurrentstore('canada'); break; } } also fine other way less code. ...

How to add an Alias to Android (Java) Keystore -

it easy create new java keystore in android-studio. i'd add second alias keystore. second app same client. how do that? or, if not-so-good idea, better way? edit: not intend use different keystores same project. first project done in android studio, second in intel xdk. not share process or need accesses data in other. you can in android studio, go "build > generate signed apk", skip next step, click "3 dots gray button" @ right of "key alias" field, , type new alias , password other app.

c# - Performance of IQueryable -

i needed write dynamic query on customer database obtaining few fields of customer. following code [route("api/getbasiccustlist/{argtype}/{argvalue}")] [httpget] [authorize] public dynamic getcustomerdatausername(string argtype, string argvalue) { iqueryable<customerdto> query = (from recordset in db.customers select new customerdto { companyid = recordset.company.id, contactnum = recordset.contactnum, username = recordset.username, emailaddress = recordset.email, fullname = recordset.fullname, accountnumber = recordset.rcustid } ); switch (argtype) { case ...

ios - why my imageview is shrinking while im scrolling my tabelview cells? -

im dynamically resizing label, in tabelview cell.the number of cells appearing in view fine.but while im scrolling new cells having big size of image view.please let me know.why? - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; tvcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; if (cell == nil) cell = [[tvcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; cell.titlelabel.text = [[[arraydata objectatindex:indexpath.row]valueforkey:@"title"]stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; cell.txtlabel.text = [[[arraydata objectatindex:indexpath.row] valueforkey:@"description"]stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; cell.imglabel.contentmode = uiviewcontentmodescaleaspectfi...

Collision detection in javascript -

i implementing custom space invader in html/javascript. far works fine collision detection seems problem. after looking couple of solutions online, here have far. my enemies represented in array this: function logo(i){ = || {}; i.sprite = new image(); i.active = true; i.width = 25; i.height = 25; i.explode = function(){ this.active = false; } i.draw = function(){ context.drawimage(i.sprite,this.x,this.y); } i.setres = function(name){ this.sprite.src = name; } return i; } which populated this: var logoarray = []; for(i=0;i<logodata.length;i++){ logoarray.push(logo({ x: logodata[i].x, y: logodata[i].y })); logoarray[i].setres("./graphics/logo_slices/logo_" + logodata[i].name + ".png"); console.log(logoarray[i].sprite.src); } the collision handled (enemy.explode this.active = false): function handlecollision(){ ...

unit testing - Mocking a side_effect with Python unittest -

i'm trying mock out requests.get have status code of 200 , make history[0].status_code trigger indexerror (since there no redirects). i'm able status_code return 200 , when mock out history desired side effect, indexerror not triggered. @patch('requests.get') def test_no_redirect(self, mock_requests): mock_requests.return_value.status_code = 200 mock_requests.history[0].status_code.side_effect = indexerror() response = requests.get('example.com') self.assertraises(indexerror, response.history[0].status_code) self.asserttrue(200, response.status_code) ok, checked code , i'd mention few things. first of assertrises method receives callable second parameter ;) definition looks def assertraises(self, excclass, callableobj=none, *args, **kwargs): the second thing, if mocking status_code using mock_requests.return_value.status_code = 200 why not try same history: mock_requests.return_value.histor...

ios - Thread 1: signal SIGABRT error on Obj C -

Image
i searched problem on site not solve problem. want ask how can solve this? i have navigation controller , view controller. add elements on navigation controller, it's working when add viewcontroller , connect navigation controller, see problem. connected them segue , want pass view controller navigation controller's elements. build failed , take error code; 2016-07-11 14:35:38.243 seg[4175:594378] *** terminating app due uncaught exception 'nsgenericexception', reason: 'push segues can used when source controller managed instance of uinavigationcontroller.' *** first throw call stack: ( 0 corefoundation 0x000000010cd73d85 __exceptionpreprocess + 165 1 libobjc.a.dylib 0x000000010c7e7deb objc_exception_throw + 48 2 uikit 0x000000010d8f7ca9 __copy_helper_block_ + 0 3 uikit 0x000000010d871630 -[uistoryboardseguetemplate _performwit...

c# - How to sort list of class object -

i have list of model class object. class scoreboard have total score 1 property. scoreboard scoreboard = new scoreboard(); i sorting list data= data.orderbydescending(x => x.totalscore).tolist() but wont work. please should list of object of class. if understood sorting issue correctly, might list<class1> scores = new list<class1>(); scores.add(new class1 { score = 1, totalscore = 2, user = "a" }); scores.add(new class1 { score = 1, totalscore = 5, user = "b" }); scores.add(new class1 { score = 1, totalscore = 3, user = "c" }); scores = scores.orderbydescending(x => x.totalscore).tolist(); this sort total score.

sql - Create a Cursor and loop all users data -

Image
i have stored procedure gives me records below. now want is. want create cursor sp loops every user , fetch records. below sp. alter procedure get_inward_reminder_report begin select distinct u.first_name + ' ' + u.last_name username, th.*, case when tl.u_datetime < dateadd(d, -5, getdate()) m.reporting_to else null end reporting_1 inward_doc_tracking_trl tl inner join inward_doc_tracking_hdr th on th.mkey = tl.ref_mkey inner join user_mst u on th.user_id = u.mkey inner join emp_mst m on m.mkey = u.employee_mkey tl.nstatus_flag not in (5,14) ...

authentication - Only exposing certain auth routes in Laravel -

in laravel 5.2 authentication made dead simple , 1 of ways makes authentication simpler adding routes necessary authentication through 1 method, method route::auth() . which great, best way of exposing ones necessary login , logout actions , not registration ones, because want have 1 master login, can make other accounts admin website. don't want 'users' in normal sense. you can add routes.php without registration route of course. // authentication routes... //login routes... route::get('login','adminauth\authcontroller@showloginform'); route::post('login','adminauth\authcontroller@login'); route::get('logout','adminauth\authcontroller@logout'); // registration routes... route::get('register', 'auth\authcontroller@showregistrationform'); // password reset routes... route::get('password/reset/{token?}','auth\passwordcontroller@showresetform');

owl - SWRLb - greaterThan and lessThan triggered -

i have problem using swrl rules. have robot should notify human in case of 2 abnormal situations. test case use tension of user: if tension less 14, robot alert tension low: (:hastension :charles ?x) &wedge; greaterthan(?x, "14.0"^^xsd:float) &rightarrow; (:hasalert :samii "your tension high"^^xsd::string) if tension greater 14, robot alert tension high. (:hastension :charles ?x) &wedge; lessthan(?x, "14.0"^^xsd:float) &rightarrow; (:hasalert :samii "your tension low"^^xsd::string) i using owl api pellet reasoner (openllet fork of pellet). have swrl rules using builtin swrlb:greaterthan , swrlb:lessthan . test add axiom     :charles :hastension "10"^^xsd:float and query data property     :samii :hasalert ?alert but when query ontology, 2 alerts: 1 greaterthan , other lessthan. think rules formed, , don't have warning or error api saying builtin not implemented, believe rules should work i...

sql - how to create a new field to show, together with the SELECT'ed fields? -

Image
these code lines filter of people on 50. select birthday table_name birthday < now() - '50 years'::interval together this, need create additional column, shows actual age. es. birthday age 2000-06-28 16 the column "age" shall created select. not present in table. you can use specific function called age() select extract(year age(birth_date)) age ... https://www.postgresql.org/docs/9.5/static/functions-datetime.html keep in mind: age subtracts current_date ( at midnight )

java - How can I reset the JWT token expiration time? -

i have created jwt token along expiration time authentication purpose. each time when url hits in application checking token. want increase jwt token expiration time. following how done. token expiring taking expiration time set while creating token. //creating jwt token once when user logged in string jwttoken = new string(jwts.builder().setsubject(user.getuserid()) .setexpiration(exptime).setissuedat(new date()) .signwith(signaturealgorithm.hs256, "secretkey").compact()); // checking presence of token every time claims claims = jwts.parser().setsigningkey("secretkey") .parseclaimsjws(jwttoken).getbody(); claims.setexpiration(time); // trying reset expiration time don't know what's going wrong. appreciated. i think expiration time part of token , it's not possible extend expiration time of token without new one. please refer jwt (json web token) automatic prolongat...

javascript - How to get float value from string using regex? -

i have string value this: "zar 200.15" using regex, how can extract float value calculations with? for context, i'm using javascript access html element's value this: var amountduestring = document.getelementbyid("amountdue").innerhtml; then need use regex float value. var amountdue = amountduestring.match(---some regex---); i want extract float value in order compare user input. try this: (\d)+\.(\d+) tested on notepad++

angularjs - Route change after login not working with Angular js, ui-router, satellizer and IE 11 -

in chrome, firefox, , opera when user logs in app redirects 'dash' state. in ie 11 logs in, redirects 'dash' state 'login' state. parts of index: <meta http-equiv="x-ua-compatible" content="ie=11" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js"></script> <script src="js/angular-ui-router.min.js"></script> .... <div ui-view></div> part of app.js: var app = angular.module('myapp', ['ui.router', 'monospaced.elastic', 'satellizer', 'slick', 'chart.js', 'wu.masonry', 'ngsanitize']); app.config(function($stateprovider, $urlrouterprovider, $authprovider) { $stateprovider .state('login', { url: '/login', ...

c# - change wpf tool tip depends upon current thread culture info -

i working on wpf application in i'm able localize labels buttons im not able localize tool tips. coming in english. changed cultureinfo japanese. still tooltip alone coming in english rest coming in japanese. how can control tool tip language

javascript - How to find element has specific color using jquery -

here html code <ul id="components"> <li>computer</li> <li>mouse</li> <li>keyboard</li> <li>printer</li> <li>cpu</li> </ul> #components li:first-child{ color:red; } #components li: nth-child(2){ color:blue; } #components li: nth-child(3){ color:red; } #components li: nth-child(4){ color:red; } #components li: nth-child(5){ color:green; } what need jquery function can find li elements in red color , can convert background yellow i mean like $("#components").find(li elements in red color).css("backgound","yellow"); // find li elements in red color , change background yellow you can use .filter(); $('ul li').filter(function() { return $(this).css('color') == 'rgb(255, 0, 0)'; }).each(function() { $(this).css('background-color', 'yellow'); }) <script sr...

c++ - graphics.h - installed it, why still error? -

so followed instructions question answer in page how install graphics.h , resulted correctly. when included it, showed me error message: c:\program files\codeblocks\mingw\include\graphics.h|302|error: redefinition of 'int right'| c:\program files\codeblocks\mingw\include\graphics.h|302|note: 'int right' declared here| why did happend? can please me fix problem? this got information from: how use graphics.h in codeblocks? did followed last resolution provided in link have specified? open file graphics.h using either of sublime text editor or notepad++,from include folder have installed codeblocks. goto line no 302 delete line , paste int left=0, int top=0, int right=int_max, int bottom=int_max, in line. save file , start coding.

android - Click listener on a view on top of another -

i have cardview , list inside it. but, when click on cardview doesn't receive click callbacks because list on top of it. solution solve this? i tried make list unclickable ; didn't work! xml layout <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" style="@style/cardviewstyle" card_view:cardcornerradius="2dp" xmlns:tools="http://schemas.android.com/tools"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:id="@+id/text_view_entry_status" android:layout_width="wrap_content" android:layout_height="wrap_content" ...

javascript - I have 3 issues revolving around the styling of divs -

i have 3 issues with. issue 1. i have navigation bar numerous elements inside of it. div id shopcartbar display the div id shoppingtab once hovered over. did set onmouseout on shopcartbar div when tried move cursor on shoppingtab div, disappear. able keep shoppingtab div visible whilst hovering on either of these divs , onmouseout work on either of these well, or @ least able hover shopcartbar div on shoppingtab div keep visible because right disappears there tiny gap between 2 when used css close, didn't fix problem. before read code , have set fixed on page, intentionally set have no onmouseout event otherwise vanish moved cursor therefore debugging purposes, made appear permanently forcing me refresh page every time wanted gone. issue 2 when set height of shoppingtab div 100%, covers span tags within , not 9 divs underneath tags, leaving content overflowing out of div. want shoppingtab div extend of content , not stop after span tags. please note: amount ...