Posts

Showing posts from February, 2013

matlab - Choose boxplots (columns) to show in the matrix -

i read boxplot documentation . but don't understand how display columns in matrix (not few). i tried this: %data matrix 5 columns %i want display second , third column boxplot(data,{2,3}) i know simple problem find nothing in google or matlab documentation. to display few columns, use indexing matrix. example, display columns 2 , 3 : boxplot(data(:,[2 3]))

java - Mockito issue with List -

i have dao method returns list. now trying mock dao class in service layer when invoke dao method, giving me empty though have mocked dao method below sample code snippet, public class abctest { @injectmocks abc abc = new abc(); @mock private abcdao dao; @before public void setup() { mockitoannotations.initmocks(this); dao = mockito.mock(abcdao.class); mockito.when(dao.getlistfromdb()).thenreturn(arrays.aslist("1","2","3")); } @test public void testservicemethod() { abc.servicemethod(); // inside method when dao method called, giving me empty list though have mocked above. } any pointers helpful don't use mockitoannotations.initmocks(this); use @runwith(mockitojunitrunner.class) instead you calling dao = mockito.mock(abcdao.class) overrides dao created mockitoannotations.initmocks(this) the abcdao instance inside abc different dao member of test case. i can assume following fail: asserttrue(dao ...

css - Why is my html table taking up more height than necessary? -

i have table bunch of same image in single row. image has height of 21px cells of table have rendered height of 25px (in chrome, safari, , firefox). there's nothing else in table, , can tell, there no margins, borders, or padding. why table taller needs be? here's example: http://jsfiddle.net/q6zy17dz/ and here's simple example of table: <table> <tbody> <tr> <td><img src="http://i.imgur.com/b2f5t2b.png"></td> <td><img src="http://i.imgur.com/b2f5t2b.png"></td> <td><img src="http://i.imgur.com/b2f5t2b.png"></td> <td class="datetime"></td> <td><img src="http://i.imgur.com/b2f5t2b.png"></td> <td><img src="http://i.imgur.com/b2f5t2b.png"></td> <td><img src="http://i.imgur.com/b2f...

android - Change width of a ListView item(row)? -

Image
i have listview every row shows different percentage. and wanna change 1 of inner layouts width (inside inflated counterview ) purpose . for example: if first value item in listview 10% width set 10px too if second value item 50% width change 50px too something this: how can ? i tried these codes doesn't work , width doesn't change: (i defined match_parent width layout inside xml , wanna change programmatically) public class myadapterscores extends baseadapter { @override public view getview(int position, view convertview, viewgroup parent) { if (convertview == null) { layoutinflater layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); convertview = layoutinflater.inflate(r.layout.scores_layout,null,true); //i wanna change 'relativelayoutrightsqure' width inside 'scores_layout' view layout = convertview.findviewbyid(r.id.relativela...

java - How to remove the brackets [ ] from ArrayList#toString()? -

i have created array list in java looks this: public static arraylist<integer> error = new arraylist<>(); (int x= 1; x<10; x++) { errors.add(x); } when print errors errors [1,2,3,4,5,6,7,8,9] now want remove brackets([ ]) array list. thought use method errors.remove("["), discovered boolean , displays true or false. suggest how can achieve this? thank in advance help. you calling system.out.println print list. javadoc says: this method calls @ first string.valueof(x) printed object's string value the brackets added tostring implementation of arraylist. remove them, have first string: string errordisplay = errors.tostring(); and strip brackets, this: errordisplay = errordisplay.substring(1, errordisplay.length() - 1); it not practice depend on tostring() implementation. tostring() intended generate human readable representation logging or debugging purposes. better build string whilst iterating: list<...

c# - Mocking ControllerContext.IsChildAction throws exception in ParentActionViewContext -

i have asp.net mvc method in controller: public actionresult update() { if(!controllercontext.ischildaction) { return redirecttoaction("details","project"); } return partialview(); } i mock ischildaction returns true. var mockcontrollercontext = new mock<controllercontext>(); mockcontrollercontext.setupget(m => m.ischildaction).returns(true); yourcontroller controller = new yourcontroller(); controller.controllercontext = mockcontrollercontext.object; but change somehow reflect asp.net mechanism expects property controllercontext.parentactionviewcontext not null. when return statement executed in test throws null reference because property null. can not mock because not virtual :/ any idea how inject in controller context value it? you have use callbase = true in controllercontext moq: var mockcontrollercontext = new mock<controllercontext> { callbase = true, }; this way can still setup ischilda...

r - How to use SwitchToFrame in Selenium, Rstudio? -

i have started using r (version 3.2.1) , rstudio (version 0.99.465) on windows 7. i facing error shown below (error shown switchtoframe). error: summary: nosuchframe detail: request switch frame not satisfied because frame not found. class: org.openqa.selenium.nosuchframeexception i can run code individually (line line) log in currently, however, if run script, error above appear. tried add settimeout(), wait iframe appear, however, seems doesn't work well. code appurl <- "http://www.trademap.org/country_selcountry_mq_ts.aspx" rselenium::startserver() library("rselenium") #open headless driver phantom(), use chrome,etc pjs <- phantom() remdr<- remotedriver(browsername="phantomjs") remdr$open() remdr$navigate(appurl) #log in itc webelem<-remdr$findelement(using="css","#ctl00_menucontrol_marmenu_login")$clickelement() webelem<-remdr$settimeout(type="script",10000) webelem<-remdr$swit...

powershell - Command runs in ISE but not as ps1 in Console -

i found numerous threads , went through them none of them adressed issue. try keep short. new-psdrive –name "g" –psprovider filesystem –root "\\dom\dfs\dom-loc-share" –persist it works fine if run ise. works fine when copy paste console. not work if try running ps1 in console. i restarted ise i checked , both run in single threaded apartment executionpolicy unrestricted i run both administrator can please me? use -scope global , more information visit technet article: about_scopes https://technet.microsoft.com/en-us/library/hh847849.aspx [...] windows powershell protects access variables, aliases, functions, , windows powershell drives (psdrives) limiting can read , changed. enforcing few simple rules scope, windows powershell helps ensure not inadvertently change item should not changed. [...] new-psdrive –name "g" –psprovider filesystem –root "\\dom\dfs\dom-loc-share" –persist -scope global ...

sql - conditional join in bigquery -

Image
i have 2 tables. table 1 single column of integers. table 2 has 3 columns : start_integer, end_integer, data the simple query join column of integers data where integer >= start_integer , integer <= end_integer in many sql implementations can accomplished left conditional join ... on between select tbl1.integer, tbl2.data tbl1 left join tbl2 on tbl1.integer between tbl2.start_integer , tbl2.end_integer; but seems bigquery supports join on = condition. this accomplished cross join, bigquery complains tables big. cross join each invalid. how can accomplish join task within limitations of bigquery's sql? below bigquery sql: select tbl1.integer, tbl2.data bq:data.tbl1 cross join bq:data.tbl2 tbl1.integer between tbl2.start_integer , tbl2.end_integer; which returns error: error: 4.1 - 4.132: join operator's right-side table must small table. switch tables if left-side table smaller, or use join each if both tables larger maximum described @...

Using google cloud service account -

i given google cloud service account 1] client id 2] email id 3] certificate fingerprint 4] .p12 file i had java process communicating big query own personal email account client secret file etc. setup working fine. now have use service account, did not see client secret provided account. wondering how supposed integrate service account current process. i tried find bunch of things on google found this: https://developers.google.com/identity/protocols/oauth2serviceaccount is correct way use or service accounts there else ? there better example somewhere can see proper steps use info have access google cloud app service account. thanks. yes, link have way use service account. need "client secret" the developer console , in form of json or p12 file. as example, storage-serviceaccount-cmdline-sample should serve simple sample.

node.js - Sails.js body contents when Content-Type is text/csv -

do need special handle post requests text-ish content-type ? i need handle text/csv when method in controller, looks sails.js tried parse body json: poststuff: function(req, res) { sails.log.info("poststuff") sails.log.info(req.body) sails.log.info(req.headers['content-type']); ...etc... gives me: info: poststuff info: {} info: text/csv i find documentation on bodyparser middleware little bit obscure. fwiw, tried setting content-type text/plain in request, no avail. i tried explicitly adding text bodyparser middleware, didn't seem have effect: http.js module.exports.http = { bodyparsertext: require('body-parser').text(), middleware: { order: [ 'startrequesttimer', 'cookieparser', 'session', 'myrequestlogger', 'bodyparser', 'bodyparsertext', 'handlebodyparsererror', 'compress', 'methodoverri...

iis - AJAX Post without filename and query gives not allowed HTTP VERB -

we working existing script makes prototype ajax post request url /ds?params= . when call made result is: http error 405 - http verb used access page not allowed. if use firebug , right click on ajax request , choose "open in new tab" work, http verb changed get i tried adding mapping asp.dll in configuration website in iis explained on iis forums , it's still not working.

python - One line repeating counter with itertools? -

i want write infinte generator using itertools combines count , repeat iterators, repeating each number n times before incrementing. there more concise way came with? from itertools import * def repeating_counter(times): c = count() while true: x in repeat(next(c), times): yield x >>> rc = repeating_counter(2) >>> next(rc) 0 >>> next(rc) 0 >>> next(rc) 1 >>> next(rc) 1 use integer division! def repeating_counter(times): return (x // times x in count())

How does http security hasRole() method work -

i have developed restful api in spring retrieves user info database (mongodb) , returns data client consumes rest api. before data retrieved rest api checks see if user admin or not. only admin can perform operations retrieve user info so in securityconfig.java class have this: http.authorizerequests() .antmatchers("/users/get/**", "/users/get/**").hasrole("admin"); http.httpbasic(); now, users have roles , working expected in sense when call curl adminusername:adminpassword@localhost:8080/users/get/allusers i able retrieve users because user username of adminusername admin , has permission. if replace adminusername non-admin username, access denied error. my question is, adminusername:adminpassword part before @localhost:8080.... header of http request? the reason ask because need create client able log in, have credentials (username , password) verified, , have username , password used session id , time client makes http r...

ruby on rails 3 - Redmine How to display application menu under specific top menu? -

i working on leave management system plugin want show application menu under lms menu.... here past init file code menu :top_menu, :leave_transactions, { :controller => 'dashboard', :action => 'index' }, :caption => 'lms' , :if => proc.new { user.current.logged? } menu :application_menu, :dashboard, { :controller => 'dashboard', :action => 'index' }, :caption => 'dashboard' , :if => proc.new { user.current.logged? } menu :application_menu, :leave_transactions, { :controller => 'leave_transactions', :action => 'index' }, :caption => 'apply leave' , :if => proc.new { user.current.logged? } menu :application_menu, :holiday_informations, { :controller => 'holiday_informations', :action => 'index' }, :caption => 'holiday' , :if => proc.new { user.current.logged? } its working me application menu display on menu. want avoid , whe...

java - Getting a weird error when attempting to execute a simple program in Maven Web on Ubuntu -

i attempting netbeans work on ubuntu. using java-8 trying launch simple program prints command line: system.out.println("test"); doing package inside maven web project the error: failed execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project mavenproject1: command execution failed. cannot run program "java" (in directory "/home/jon/netbeansprojects/mavenproject1"): error=13, permission denied -> [help 1] this works fine eclipse maven web project, , runs fine maven java application, not netbeans web application. checked permissions, , has read, write, , execute permissions. try: - set environment variable java_home , this link guide you. - set maven_home variable in similar way.

java - Widget Char-Sequence Error in Android Studio -

iam dumb newbie android programmer, here have problem in case want run android programs make on android studio ide. when run program, error field said "process: com.example.ever_ncn.cashflow, pid: 6317 java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.textview.settext(java.lang.charsequence)' on null object reference" i still dont understand explanation on question. i confuse cuz of error, have googling still unsolved. please master, answer question simple , easy understanding explanation. thank you. nb. main activity show activity contain spinner spinner value taken database. source code main_activity.java : public class mainactivity extends actionbaractivity { private static button btninewtrans; private static button btniviewcash; private static button btniaddcateg; databasehelper dbhelper = new databasehelper(this); spinner selectcategory; arrayadapter<string> adaptercategory; @override protected void oncre...

java - Aligning buttons to center in BoxLayout -

Image
i trying set buttons center using box.createhorizontalstrut() method. if use this.getwidth()/2 not work. how can center in frame. code package ch17; import java.awt.color; import java.awt.container; import java.awt.fontmetrics; import java.awt.graphics; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; import javax.swing.border.titledborder; public class q17_1 extends jframe{ jbutton left = new jbutton("<="); jbutton right = new jbutton("=>"); jpanel p1 = new jpanel(); jradiobutton rb1 = new jradiobutton("red"); jradiobutton rb2 = new jradiobutton("yellow"); jradiobutton rb3 = new jradiobutton("white"); jradiobutton rb4 = new jradiobutton("gray"); jradiobutton rb5 = new jradiobutton("green"); jpanel p2 = new jpanel(); message m = new message("welcome java"); public q17_1(){ ...

c# - How to invoke a .Net method with unsigned integer argument from IronPython -

the method in csharp have 2 variants public class mmsvalue { public mmsvalue (int value) { valuereference = mmsvalue_newintegerfromint32 (value); } public mmsvalue (uint32 value) { valuereference = mmsvalue_newunsignedfromuint32(value); } when call ironpython, invokes mmsvalue(int value) . there way call mmsvalue(uint32 value) ? taken ironpython documentation: http://ironpython.net/documentation/dotnet/ if want control exact overload gets called, can use overloads method on method objects: import clr clr.addreference('classlibrary1') classlibrary1 import mmsvalue system import uint32 uint32_mmsvalue = mmsvalue.__new__.overloads[uint32](mmsvalue, 1) this create instance of mmsvalue using uint32 constructor.

c# - what is difference between HttpCacheability.NoCache and HttpCacheability.ServerAndNoCache? -

what difference between httpcacheability.nocache httpcacheability.server httpcacheability.public httpcacheability.private httpcacheability.serverandnocache at condition should use one? from msdn nocache : sets cache-control: no-cache header. without field name, directive applies entire request , shared (proxy server) cache must force successful revalidation origin web server before satisfying request. field name, directive applies named field; rest of response may supplied shared cache. private default value. sets cache-control: private specify response cacheable on client , not shared (proxy server) caches. public sets cache-control: public specify response cacheable clients , shared (proxy) caches. server specifies response cached @ origin server. similar nocache option. clients receive cache-control: no-cache directive document cached on origin server. equivalent serverandnocache. serverandnocache applies settings of both server...

select matching objects from array in elasticsearch -

{ class: 1, users: [{ name: 'abc', surname: 'def' }, { name: 'xyz', surname: 'wef' }, { name: 'abc', surname: 'pqr' }] } i have document structure above object , want return users have name 'abc' problem matches name 'abc' returns array. want matched users . mapping - { "class":"string", "users" : { "type" : "nested", "properties": { "name" : {"type": "string" }, "surname" : {"type": "string" } } } } then if have users field mapped nested type, it's start! using nested inner_hits , can retrieve matching user names query one: { "_source": false, "query": { "nested": { ...

ios - Error "Application tried to present modal view controller on itself" while activating UISearchController on action -

in code how setup uisearchcontroller : searchresultcontroller = storyboard!.instantiateviewcontrollerwithidentifier(dbsearchresultcontrolleridentifier) as! dbsearchresultcontroller searchcontroller = uisearchcontroller(searchresultscontroller: searchresultcontroller) searchcontroller.searchresultsupdater = self searchcontroller.delegate = self searchresultcontroller.tableview.tableheaderview = searchcontroller.searchbar on action is: @ibaction func citybuttontapped(sender: uibutton) { searchcontroller.active = true } but have error: application tried present modal view controller on itself. presenting controller uisearchcontroller: 0x7f9a0c04a6a0 the apple documentation uisearchcontroller says following things: setting active property yes performs default presentation of search controller. set searchresultscontroller parameter nil display search results in same view searching. so looks using current view controller searchresultscontroller ,...

javascript - Facebook Graph API Returning Empty Data -

i tring facebook friend list getting response null. using javascript sdk. addition in summary getting friend's number. not getting there data. here code:- fb.init({ appid : '{app-id}', cookie : true, // enable cookies allow server access xfbml : true, // parse social plugins on page version : 'v1.0' // use version 2.2 }); function testapi() { fb.login(function(response){ fb.api("/me/friends", function (response) { console.log(response); }); },{scope: 'user_friends'}); // fb.api('/me/feed', 'post', {message: 'hello, world!'}, function(){ // console.log(response); // }); } <fb:login-button scope="public_profile,user_friends" onlogin="checkloginstate();" data-auto-logout-link="true"></fb:login-button> can tell me, making mistake? did fb.init() correctly ? did add correct permissions...

ios - Universal App: Getting Table View To Fill Whole Screen -

Image
i have 2 table views, both without table view controllers, have view controller that's taking care of both of them. the problem i'm getting weird scalings of tables on different devices. seems perfect on iphone 4 simulator. table looks ridiculous on ipad simulator. my table views view settings this: scale fill i tried changing launch images see if have impact on scaling/zooming/etc, didn't seem change anything. how can table views automatically fill whole screen on universal app? edit: alignment constraints disabled: if using autolayout give constaints table view leading, trailing, top & bottom. change size per device.

Can't parse json object(android) -

sorry english, can't parse json object this: { "user": { "id": 34, "last_login": { "date": "2015-07-30 11:22:34.000000", "timezone_type": 3, "timezone": "europe/oslo" } } } i don't know, why it's not working. need parse last_login , can't this my code jsonobject jsontable = json.getjsonobject("user"); if(jsontable.length() > 0) { check = true; profiledetalisobject pfdet = new profiledetalisobject(); pfdet.setid(jsontable.getstring(tag_id)); jsonobject date = jsontable.getjsonobject("last_login"); if(date.length() > 0) { iterator<string> iteratordate = date.keys(); while( iteratordate.hasnext() ) { ...

random - Seeding QUASI_SCRAMBLED_SOBOL64 in CURAND -

how can seed curand_rng_quasi_scrambled_sobol64 generator? because gives me same numbers every time run , can't use curandsetpseudorandomgeneratorseed curand_rng_quasi_scrambled_sobol64 generate 64 bit random integers curandgeneratelonglong . how seed generator in following code? size_t n = 10; curandgenerator_t gen; unsigned long long *devdata, *hostdata; hostdata = (unsigned long long *)calloc(n, sizeof(unsigned long long)); cudamalloc(&devdata, n*sizeof(unsigned long long)); curandcreategenerator(&gen, curandrngtype_t::curand_rng_quasi_scrambled_sobol64); (size_t j = 0; j < 3; j++) { curandgeneratelonglong(gen, devdata, n); cudamemcpy(hostdata, devdata, n * sizeof(unsigned long long), cudamemcpydevicetohost); (size_t = 0; < 3; i++) { printf("%llx\n", hostdata[i]); } printf("\n\n"); } curanddestroygenerator(gen); cudafree(devdata); free(hostdata); as per docuementation , quasi random generators,...

winapi - Is it possible to programmatically retrieve this text using the windows api? -

Image
i know it's possible programmatically retrieve text #2 (refer image below) using win32gui.getwindowtext(handle) . not find function retrieve text #1, there still way retrieve text programmatically? text #1 appears if hover on taskbar icon few seconds. alternatively, know these kind of popups called? me in search also. consider using the official windows media player sdk information plying song instead of trying wrestle out getwindowtext() (which i don't think works across-process boundaries ) of tooltip (which owned windows, not child windows). this method seems right 1 (but wouldn't know sure).

javascript - Backspace is not working in Textarea of My Form on Mozila browser -

function onlyalphabets(e, t) { try { if (window.event) { var charcode = window.event.keycode; } else if (e) { var charcode = e.which; } else { return true; } if ((charcode > 64 && charcode < 91) || (charcode > 96 && charcode < 123)) return true; else return false; } catch (err) { alert(err.description); } } function isnumber(evt) { evt = (evt) ? evt : window.event; var charcode = (evt.which) ? evt.which : evt.keycode; if (charcode > 31 && (charcode < 48 || charcode > 57)) { return false; } return true; } $('input.facebookurl').keyup(function(){ if ( ($(this).val().length > 0) && ($(this).val().substr(0,24) != 'http://www.facebook.com/') || ($(this).val() == '') ){ $(this).val('http://www.facebook.com/'); } }); <table align="center"...

javascript - App Orientation not working in Firefox OS packaged "web" type app -

i trying make app should work in portrait view. test app in device uploading files including manifest file in local apache server , install in device function navigator.mozapps.install(manifesturl); written in install.html file. while installing phone correctly detecting manifest file , shows app name developer , on provided in manifest file. while running app orientation not working well. when rotate device app gets rotated. manifest file { "name": "mathbrain", "description": "let calculate", "launch_path": "/mathbrain2/index.html", "icons": { "16": "/icons/icon16x16.png", "48": "/icons/icon48x48.png", "60": "/icons/icon60x60.png", "128": "/icons/icon128x128.png" }, "type": "web", "fullscreen":"allowed", "permissions": {}, "orientation...

android - How to enable Lollipop features(TranslucentStatus, colorButtonNormal, etc) in Kitkat -

i've developed app working fine on lollipop devices without problem.but, there problem in kitkat , can't find in manuals or ducumentation in android developers . for example, have theme in styles everyscreens or android versions: <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.noactionbar"> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="colorprimary">@color/colorprimary</item> <item name="windowactionbar">false</item> <item name="android:windowtranslucentstatus">true</item> <item name="android:colorbuttonnormal" tools:targetapi="lollipop">#43a047</item> <!-- customize theme here. --> </style> and had use tools:targetapi disabling suggest or error.but, need use features colorprimarydark...

google app engine - Gmail API Python: RequestTooLargeError: The request to API call datastore_v3.Put() was too large -

i getting following error batch request gmail api on google app engine: requesttoolargeerror: request api call datastore_v3.put() large. from other questions on stackoverflow understand problem has memcache. nevertheless don't know how solve issue, since coming if run 1 request per batch , before can content of email (like compressing it). my code looks follows: count = 0 #start new batch request after every 1000 requests batch = batchhttprequest(callback=get_items) in new_items: batch.add(service.users().messages().get(userid=email, id=i), request_id=str(count)) count += 1 if count % 1000 == 0: n in range(0, 5): try: batch.execute(http=http) break except exception e: if n < 4: time.sleep((2 ** n) + random.randint(0, 1000) / 1000) else: raise ...

javascript - how to get response from a function and validate another function in jquery -

when click button want validate 2 functions 1 one , functions validateemail(email); validatemobile(mobile); trying far , code when click getotp button $('.getotp').click(function(e) { e.preventdefault(); var response; var email=$('#email').val(); validateemail(email); if(response=true){ var mobile=$('#mob').val(); validatemobile(mobile);}}); my emailvalidation function is function validateemail(email){ var emailreg = new regexp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); var valid = emailreg.test(email); if(!valid) { $('.errornotice').text('email address not valid'); response=false; } else { response=true; } }//email validate function and mobile...

Shadow of CardView not visible on Android Lollipop -

following code works on kitkat, shadows not visible in lollipop. actually can see shadow in android studio preview, not while running on device/emulator. i'm using cardview adapter of viewpager (android.support.v4.view.viewpager) <android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" card_view:cardusecompatpadding="true" card_view:cardcornerradius="4dp" card_view:cardelevation="6dp"> actually shows shadow in l version, based on elevation can't see shadow if card height match parent try adding margin card if want see shadow

aurelia - TypeScript How to access object defined in other class -

i have project uses aurelia framework. want make global\static object should accessed across couple files. when try access different file says object undefined. here looks like: firstfile.ts export function showa() { console.log("changed " + a); } export var = 3; export class firstfile { public modifya() { = 7; showa(); } it says = 7. use in other file this. secondfile.ts import firstfile = require("src/firstfile"); export class secondfile { showa_again() { firstfile.showa(); } i execute showa_again() in view file called secondfile.html <button click.trigger="showa_again()" class="au-target">button</button> when click button, see in console variable "a" still 3. there way store variables between files? i'd recommend inject firstfile secondfile . code has smell of bad architecture. to answer question: looking static ( playground sample ) export cl...

css - Altering height of Bootstrap panel footer -

Image
i want change height of bootstrap's panel footer make shorter, after looking around everywhere haven't found way whilst adjusting position of text within footer, doesn't poke out bottom. (merely adjusting font size wasn't enough) here code , screenshot of issue: .panel-default>.panel-footer { color: rgba(0, 0, 0, 0.6); font-size: smaller; max-height: 20px; } <div class="panel-footer"> (0 comments) </div> http://i.stack.imgur.com/aaxx8.jpg quas94 hi there. need here change height of panel footer css. here fiddle . .panel-heading{ height:50px; } .panel-body{ min-height:150px; background-color: gray; } .panel-footer{ height:100px; background-color: chartreuse; }

Remove last 3 characters of string or number in javascript -

i'm trying remove last 3 zeroes 1437203995000 how in javascript. im generating numbers new date() function here approach using str.slice(0, -n) . n number of characters want truncate. var str = 1437203995000; str = str.tostring(); console.log("original data: ",str); str = str.slice(0, -3); str = parseint(str); console.log("after truncate: ",str);

c# - How to do client-server over the internet -

we want create apps connects our database (sybase ads, connectable via .net) on internet. clients include windows forms app , android app phones , devices. i know c#. i'm new web apps , webservices bear me here. i'm thinking maybe best way creating webservice in c# run on iis interrogate ads database using ado.net. so webservice expose methods via wcf can consumed clients. the clients invoke methods via wcf. right in thinking wcf return data in .net xml objects? also can .net forms consume xml objects easily? the apps have bespoke restricted access using credentials. how approach sound? performance or security issues think about? data not classified wouldn't want snoopers able pick phone numbers etc. can security sorted out going http https? what performance. presumably slower if apps connected using ado.net ads on lan. wcf use bufers http requests? e.g. can can start reading stream on client before whole http request has finished? i'm thinking pop...

json - How do I define a javascript function as a variable from a variable -

i'm trying create callback function in response jsonp request in node. i receive callbackname string, , have object (lets var obj = {a : "b"}) need return following : callbackname({a : "b"}); i tried concatenating strings - got "callbackname([object object])"; i tried json.stringify got: "callbackname({\"a\":\"b"});" which close - it's stringy. there way want? update the code i'm using - in aws lambda function (turns out rather significant!) context.succeed(request.callback + "(" + json.stringify(obj) + ");"); as mentioned below - lambda expects object in succeed, calls json.stringify on. any ideas on how proceed? if understand question, need this: var obj = {a:"b"}; var callbackname = "callback"; var scope = {}; scope.callback = function(e) { return function() { console.log(e); } } settimeout( scope[callbackname]...

wpf - How can I get an arrow pointed on my border? -

Image
ive tried million things , im there... i have border, , want arrow coming off point upwards (i same each side , bottom after have done also). here have far: <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition /> </grid.rowdefinitions> <polygon points="5,0 10,10, 0,10" stroke="black" fill="white" grid.row="0" horizontalalignment="center" margin="0,0,0,-2" panel.zindex="10" strokethickness="2" strokedasharray="1 0" /> <border background="#00000000" borderbrush="black" borderthickness="2" cornerradius="10" grid.row="1"> the polygon creates perfect arrow, bottom border of triangle black , want white. not sure how white white bg bleeds arrow. here looks far: i want rid of black line underneath it. interested if there whole different...

c# - Nullable <= vs == comparison result -

this behaviour sounds wrong me. datetime? birth = null; datetime? death = null; console.writeline(birth == death); // true console.writeline(birth <= death); // false why so? incredibly strange. of course mean why second expression not evaluate true well. edit: i understand following comparisons return false , because cannot said how relate each other: console.writeline(birth < death); // false console.writeline(birth > death); // false this understandable behaviour. but... @ logic: <= means < or == we don't know how read < - true or false we know == true since 1 of conditions true , other condition cannot untrue result. logic or , not and . my point true or else should true. i know c# team designed way, intuition different. since smart people have written c# such rules, want learn why intuition wrong here :) i understand not looking specs explanation of why nullables designed way. to remove ambiguity, designers have...

c++ - Installing libcurl on Visual Express 2013 -

update: placing #include "stdafx.h" on top fixed errors except: error 1 error lnk1104: cannot open file 'libcurl.lib' c:\users\geeh\documents\visual studio 2013\projects\consoleapplication2\consoleapplication2\link consoleapplication2 a question that's been asked many times, , still have hard time installing kind of library on kind of compiler. went visual express, trying install libcurl, both manually , using "nuget", seems best option me. downloaded , installed nuget, ran command install libcurl, , did. included d:\program files (x86)\microsoft visual studio 12.0\libcurl\include;$(includepath) in " project properties-> vc++directories/include directories" d:\program files (x86)\microsoft visual studio 12.0\libcurl\lib;%(additionallibrarydirectories) in linker/additional library directories and libcurl.lib;libeay32.lib;ssleay32.lib;ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib;ws2_32.lib; in linker/input/additional ...

performance - Mysql (Myisam) variable setting -

i have single processor dedicated server 4gb ram , 400mb mysql database (myisam) has big performance problems. database used ecommerce. tryied tune using mysqltuner script, without results. because variable settings have been modified several times, have basic configuration start from, thereafter try tune it. try tool, show results performance tuning. https://tools.percona.com/wizard

Is there any way to cast android v4 supportFragment to android fragment? -

i did:- extends activity class in class. fragmentmanager fragment=(fragmentmanager)getsupportfragmentmanager(); but give error. you can't cast between these 2 classes, suppose compile errors because importing wrong fragmentmanager. getsupportfragmentmanager returns fragmentmanager class , importing this

performance - URL is creating correctly but result isn't successful -

i creating script hitting url , logging in db (a hit on url recorded developer in db). via "test script recorder" have performed below mentioned things i recorded login mechanism i hit url required hit ( each url varies number) now have run script changing recorded script these things i have done ${number} url number hit , through csv_data config have provided csv file for each url working fine , creating url correctly the issue not giving error on jmeter side. url correctly being made on jmeter side, if click through browser hit taken (and logged), not through jmeter. since url being made correctly why isn't hitting jmeter? confused on part, please guide i disabling few parts of recording , hindering overall progress, enabling them started working.

php - how to protect a site-wide secret key -

imagine pretty standard website, user authenticating email/password pair. passwords, ha shashing random salt, rest of data kept unencrypted. we step forward , encrypt sensitive data password key, key , obviously, shall known application able decript data operation. we don't want have in source code, it's kept in file , read app when needs it. we've secured file user executes app can read it (this point has appeared after discussions below) have considered buying hardware hsm , found not possible (for instance running server on virtual machine) this way relatively protected complete db stealing, right? however, key might become known if gets access os user read rights. the question is: best practices keeping such key secure? buy hardware security module , keep key in it. key not able read. yubi makes reasonably priced hsm. $500 if recall correctly. while we're here, db server should on different box in different network zone web server.

php - Character Encoding/decoding becomes a mess -

in webapp place <div id="xxx" contenteditable=true > editing purpose. encodeuricomponent(xxx.innerhtml) send via ajax post type server, php script creates simple txt file in turn can downloaded user store locally or print on screen. works perfect far, … yes, but, character encoding mess. special characters german Ä interpretated wrong. in case ä google days , study php methods iconv() , know how set browsers character encoding , set text editor correct correspondending decoding. nothing helps, still messs, or becoming weired. so question : in encoding/decoding roundtrip browser server , browser have what, ensure Ä still Ä ? i answer question, because turns out problem stated above. contenteditable part of section of html code. on serverside php need filter out contenteditable text via domdocument this: $doc = new domdocument(); $doc->loadhtml($_post["data"]); then access elements , textual content usual. save text file_put_c...

Scala - How to return a Map value by function? -

why below function not work in scala? def getupdatedmap(keywords: string, m: map[string, string]) : map[string, string] = { m += (keywords -> "abcde") } compilation error: value += not member of map[string, string] i'm quite new in scala, thing have forget define or missing? thanks. you confusing immutable map , mutable map . // import mutable map mutablemap import scala.collection.mutable.{map => mutablemap} val mmap = mutablemap("a" -> 1) mmap += "b" -> 2 // mutates original map // mmap = map(b -> 2, -> 1) // use immutable map val imap = map("c" -> 3) val updatedimap = imap.updated("d", 4) // returns new updated immutable map // imap = map("c" -> 3) // updateimap = map(c -> 3, d -> 4)

php - POMM Postgresql multiple schema and global class -

we facing 2 issues, solved 1) how point dynamically schema in pomm. example have public schema stores users details , private schema related each user. when user logs in logic read public schema, find private schema number , redirect user private schema - how can achieve in pomm ( http://www.postgresql.org/docs/9.1/static/ddl-schemas.html ). inside each private schema there multiple tables (example employees general data / employees salary data , on). 2) when have multiple schemas same table structure (employee general / employee salary data) need 1 class working schemas - each table pomm generates 1 class. thank help. by default, pomm's model manager uses each schema namespace , access relations using qualified name schema.relation . the idea here tweak model manager schema can guessed search_path environment variable. you need template schema relations in common in schemas defined. generate models, structures , entities schema only: $ php vendor/bin...

javascript - redis in node.js zadd arguments -

i have line in node.js, wrong number of arguments. in redis-cli easy, etg test 10 2, reason wont work here. example: convensation:convensationids:user:23984 294874 1 my code: redis_client.zadd(['convensation:convensationids:user:' + data.from ,convensationid ,data.to]); error: rr wrong number of arguments 'zadd' command edit: i tried redis_client.zadd('convensation:convensationids:user:' + data.from ,convensationid ,data.to); but got same error above. you're passing 1 argument, namely array. try passing values of array proper arguments: redis_client.zadd('convensation:convensationids:user:' + data.from ,convensationid ,data.to);

regex - CMake bracket escape character for custom target command -

i in need of bracket escape character used avoid quoting special characters in cmake when parsing make commands add_custom_target. more of syntax problem understanding, not covered in cmake documentation. an example case is: add_custom_target ( defined_path .exe <args1> | ( ! grep ... ) in example, extension resolved | "(" grep ... ")". unfortunately appending backslash before brackets works string cases, i.e. assigning variable set: set ( "(" ). variable resolved in build.make surrounded quotations. likewise parsing pre-formatted list using separate_arguments resolves quotations. the full command without make formatting executed successfully. cmake requires explicit call shell in target command

matlab - How to count non zero elements in a vector and replace this values based the number of occurences -

this question has answer here: finding islands of zeros in sequence 7 answers i'm new matlab user , in case have vector let say: v = [0 0 0 0.1 0.2 0.3 0.4 0.5 0 0 0 0 0 0 0.1 0.2] i want count consecutive non 0 values i.e in vector have first 5 nonzero values [0.1 0.2 0.3 0.4 0.5] , 2 last nozeros values [0.1 0.2] what want is: count consecutive non 0 values , put condition i.e. if length of nonzeros greater 3 ( count>3 ) respective values of vector v(i) remain v(i) if length consecutive values less 3 ( count<3 ) respective values of v(i) = 0 i want new vector let v1 derivated vector v where: v1 = [0 0 0 0.1 0.2 0.3 0.4 0.5 0 0 0 0 0 0 0 0] any appreciated. if have matlab image processing toolbox, can use power of morphological operations. morphological opening ( imopen ) removes objects smaller structuring element image. can use in...

numpy - Python: standard deviation of gaussian weighted pixel region -

i calculate gaussian weighted standard deviation of 2d array python, know how this? apply 2d gaussian filter instead of returning convolution of each array element filter, return standard deviation of gaussian weighted values around array element. cheers, tomas there numpy function called std. example x = np.random.uniform(0,5,(20,20)) np.std(x) and return standard deviation of 20x20 array. if want specific portion of image can use array splicing accomplish this.

ios - how to hide button when clicked from another view -

i beginner of xcode programming. trying action, when click button view, button of b view hidden. know can use button.hidden = true; self view controller don't know how control button other view. thanks @ibaction func testbut(sender: uibutton) { setting.hidden = false } before, create custom view button, button action , protocol as: protocol customviewdelegate { func buttonpressed (sender: anyobject) } class customview: uiview { @iboutlet weak var button: uibutton! var delegate: customviewdelegate! override func awakefromnib() { super.awakefromnib() } class func loadviewfromxib() -> customview { return nsbundle.mainbundle().loadnibnamed("customview", owner: self, options: nil)[0] as! customview } @ibaction func buttonpressed(sender: anyobject) { self.delegate.buttonpressed(sender) } } in viewcontroller. class viewcontroller: uiviewcontroller, customviewdelegate { var firstview: cus...

java - JPA commit() after persist() : Required or Not -

i working jpa 2.0 project, saving entity class objects :- initialcontext ctx = new initialcontext(); usertransaction usertrans = (usertransaction) ctx.lookup("java:comp/usertransaction"); entitymanagerfactory emf = persistence.createentitymanagerfactory(persistence_name); entitymanager em = emf.createentitymanager(); user user = new user("ankit","nigam",25); em.persist(user); // persisted in db after executes usertrans.commit(); // whether required or not. so whether using usertrans.commit() or not, user object getting saved in db, after persist() executes. of colleagues say, standard should commit() transaction. what should approach follow , whats logic behind commit() , persist() . please throw lights. is autocommit on in db? if reason why changes permanently stored in db irrespective of whether or not commit transaction application. in production autocommit set off because hampers performance/re...

c# - Error Loading Report "Dispacher processing has been suspended" -

Image
i above error when try open report. private void btnloadcustremitt_click(object sender, routedeventargs e) { try { customerremittreportwin cusremrep = new customerremittreportwin(); cusremrep.show(); } catch (exception ex) { this.myerrormessage(ex); messagebox.show("this part executed"); } } when pressed on load message appears, , after message shows surety did put messagebox on right code. on vs 2012 working fine. moved vs 2013, windows 10, getting issue?? =-=-=-=--=-= there simplar problem posted, not sure how fix problem solution.. https://stackoverflow.com/questions/23452864/wpf-dispatcher-processing-has-been-suspended-but-messages-are-still-being-pro# = i think might need wrap ui relevant code in dispatcher.begininvoke call defer ui operations when dispatcher resumes processing. private void btnloadcustremitt_click(object sender, routedeventargs e) { try { dispatcher.begininvoke(...