Posts

Showing posts from March, 2011

java - HashMap values to Collection -

i have following code: hashmap<integer, string> h = new hashmap<integer, string>(); h.put(1, "a"); h.put(2, "b"); h.put(3, "c"); h.put(4, "d"); system.out.println(h); //{1=a, 2=b, 3=c, 4=d} collection<string> vals = h.values(); system.out.println(vals); //[a, b, c, d] iterator<string> itr = vals.iterator(); while (itr.hasnext()) //a b c d { system.out.print(itr.next() + " "); } my questions: h.values() returns collection view of values in h . since vals interface, how can assign values interface (they cannot instantiated)? class implementing interface? object of class? similar question itr . know vals.iterator() returns first element of collection. how can assign interface instance? the underlying principle governs answers questions called liskov's substitution principle applies in case assign value of instance of given int

qt - MouseArea covering a QML Row (or, Auto-Sizing Image+Text) -

Image
summary : how can stick icon next text, without hardcoding dimensions, , wrap both of them in mousearea ...in way works inside gridlayout ? i have created qml layout has rows of labels across tappable "buttons". buttons icon along text: to create buttons using row , 2 items stick (without hardcoded dimensions) , have automatic size gridlayout can use: gridlayout { columns:2; rowspacing:30 text { text: audioserver.label layout.alignment: qt.alignleft } row { spacing:10; layout.alignment:qt.alignright image { width:29; height:30; y:10; source:"qrc:/rescan.png" } text { text:"find another" } } text { text: "system uptime "+system.uptime layout.alignment: qt.alignleft } row { spacing:10; layout.alignment:qt.alignright image { width:29; height:30; y:10; source:"qrc:/restart.png" } text { text: "restart" } } } i want put mousearea around each button. i

mysql - Calculate the right moment with timezones -

i have user table timezone (example: america/bogota) , timezone offset (example: -25200). we have webserver in germany (europe/berlin) , want send emails on right moment when user in usa, africa or asia has 6am. i getting offset following php code , insert in user-table. function delta_offset( $server_timezone, $user_timezone ) { $dt = new datetime('now', new datetimezone($server_timezone)); $offset_server = $dt->getoffset(); $dt->settimezone(new datetimezone($user_timezone)); $offset_user = $dt->getoffset(); return $offset_user - $offset_server; } $server_tz = "utc"; $user_tz = $this->input->post( 'timezone' ); $offset = delta_offset( $server_tz, $user_tz ); it seems works "get timezone , offset"-thing, dont know how query components in 1 query user-items. can give me or hint solve that?

php - MySQL ENUM value is not saved when calling stored procedure through PDO -

i have created stored procedure: create procedure logadd( in log_title varchar(128), in log_type enum('message','warning','error'), in log_info text ) deterministic modifies sql data comment 'insert new log entry' begin insert `tbl_logs` ( `title`, `type`, `info` ) values ( log_title, log_type, log_info ); end which works when executed data directly added in query. when bind parameters, type column, of enum type, not saved (is empty). can see value sent string: $stmt = $pdo -> prepare("call logadd(?, ?, ?)"); $stmt -> bindparam(1, 'message title'); $stmt -> bindparam(2, 'message'); $stmt -> bindparam(3, 'message information'); $stmt -> execute(); why isn't enum value saved?

javascript - How do I get the value from a data-selected input option? -

how can data-selected's value input? let's want "title" value that? $( document ).ready(function() { //console.log("prdcl ready"); $("#digital_object_prdcls__0__prdcl_links__0__ref_").on('keyup change', prdcl_link); $("#digital_object_prdcls__0__volume_num_").on('keyup change', prdcl_link); $("#digital_object_prdcls__0__issue_num_").on('keyup change', prdcl_link); function prdcl_link(){ //console.log("entered function"); var valp = {}; valp = $("#digital_object_prdcls__0__prdcl_links__0__ref_").data('data-selected'); console.log(valp); var valv = $("#digital_object_prdcls__0__volume_num_").val(); //console.log(valv); var vali = $("#digital_object_prdcls__0__issue_num_").val(); //console.log(vali); }; }); <input type="text" class="linker initialised" id="digital_

download - ASP.NET MVC serving files using return File and default Content -

i amazed speed differences between when place file in content folder , let user download it, , when send file. this result in 100kb/s in dedicated server 2 open section public filepathresult getfile() { return file("c:\\a.pdf", "application/octet-stream"); } when play same file in "webroot\content\a.pdf" , download it, capable open 10 sections , speed 1000kb/s. 10 times faster. can indicate how send file user max speed? i tried various methods, like: the 1 above (return file) using response.write using loop , buffer , detecting http header request partial content the fdm (free download manager) software default opens around 3 sections. download manager acts strange when file served via "content/" folder capable open 10 sections no configuration changes. i found answer, , related processmodel of asp.net allow me show how maximize potential of server microsoft limited default. don't need pay more upgrade managed d

save CountDown in android studio -

my app has text view , button, when touch button, countdown start when close the app , open again countdown return 0 again. how can save countdown? shared preferences? here code: public class mainactivity extends activity { button b1; textview tv1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tv1 = (textview) findviewbyid(r.id.tv1); b1 = (button) findviewbyid(r.id.b1); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu // adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.

r - Find biggest independent subset of a connectivity matrix -

i have 2 groups linked connectivity matrix following: # # x1 x2 x3 x4 x5 x6 # 1 0 0 0 0 0 v1 # 1 1 1 0 0 0 v2 # 0 1 0 0 0 0 v3 # 0 0 1 0 0 0 v4 # 0 0 0 1 0 0 v5 # 0 0 0 1 0 0 v6 # 0 0 0 0 1 0 v7 # 0 0 0 0 1 1 v8 # 0 0 0 0 1 0 v9 # 0 0 0 0 0 1 v10 # so x1 linked v1 , v2 while v2 linked x1, x2 , x3 , on. need find way (algorithm or command) getting biggest independent subsets of matrix. so, in case: # x1 x2 x3 # 1 0 0 v1 # 1 1 1 v2 # 0 1 0 v3 # 0 0 1 v4 and: # x4 # 1 v5 # 1 v6 and: # x5 x6 # 1 0 v7 # 1 1 v8 # 1 0 v9 # 0 1 v10 do have hint? guess there's library or function use either graph analysis or linear algebra. as hinted can igraph: # dummy data df1 <- read.table(text = " x1 x2 x3 x4 x5 x6 v1 1 0 0 0 0 0

java - How do I change method code formating in NetBeans -

Image
i installed new netbeans 8.1, , when want format code alt+shift+f code placed in method looks ugly, there: how can change code formating had before in netbeans 7.4 , on image there: you can format multiple files/folders @ time! in projects window/sidebar, if select 1 or more folders or files , press alt + shift + f . netbeans asks "recursively format selected files , folders?" and pressing ok recursively format selected files/folders. on mac os x, shortcut ctrl + shift + f . (note: it's ctrl , not ⌘ ) edit :- open tools -> options -> keymap , action called "re-indent current line or selection" , set whatever shortcut want. work.

php - Can't connect xdebug to PhpStorm -

Image
i have big problems connect xdebug phpstorm 2016.1 web server validation shows me ok. phpinfo: xdebug support enabled version 2.4.0 ide key phpstorm supported protocols revision dbgp - common debugger protocol $revision: 1.145 $ directive local value master value xdebug.auto_trace off off xdebug.cli_color 0 0 xdebug.collect_assignments off off xdebug.collect_includes on on xdebug.collect_params 0 0 xdebug.collect_return off off xdebug.collect_vars off off xdebug.coverage_enable on on xdebug.default_enable on on xdebug.dump.cookie no value no value xdebug.dump.env no value no value xdebug.dump.files no value no value xdebug.dump.get no value no value xdebug.dump.post no value no value xdebug.dump.request no value no value xdebug.dump.server no value no value xdebug.dump.session no value no value xdebug.dump_globals on on xdebug.dump_once on on xdebug.dump_undefined off off xdebug.extended_info off off xdebug.file_

c# - Underscore Arrow (_ => ...) What Is This? -

reading through c# in nutshell noticed bit of code i've never came across: _uisynccontent.post(_ => txtmessage.text += "test"); what underscore followed arrow? i've seen lambda expressions written in similar way nothing underscore. it's lambda expression uses _ instead of x parameter. _ valid identifier can used parameter name. as mentioned in comments, it's convention among developers call _ indicate it's not used lambda expression, it's no more that: convention.

javascript - Cant display row in an HTML table using angular ng-repeat and jquery -

i have html table expands or collapse depending if user clicks on row, main record "parent" row, if click you'll see child row displays records, issue add third row should display default because child hidden until click on parent third row wont appear , cant figure out problem =( here's example in fiddle , below youll see directive. angular .module('app',[]) .controller('datactrl',datactrl) .directive('drilldown',drilldown); function datactrl($scope) { $scope.category = [ { "desc": "category 1", "lw$": "45", "lw": "-4%", "l4w": "-15.7%", "l13w": "24%", "l52w": "-6%" } ] $scope.subcat = [ { "desc": "sub category 1",

javascript - Want a Button But Have to Use Input Where Type=File? -

Image
i have import button want this: the html looks this: <button on-read-file="importtasks(contents)" class="btn btn-default" ng-click="importtasks();">import</button> however, because want button open file, research shows need use input control , looks this: here html it: <input type="file" on-read-file="importtasks(contents)" class="btn btn-default" ng-click="importtasks();"></input> i don't need input box, , don't need button browse. want functionality of second option, of first. possible? hide input , use label "for" attribute matches input's id. style label want. <input type="file" id="abc" hidden> <label for="abc">import</label> edit for completeness, here's actual code used. because button wrapped in label, no styling necessary. <input id="hiddenimport" style="di

php - How to make a barlike chart but only with html and css -

i have database lots of records , have make foreach loop in order data. problem chart every data overload page. need make barlike chart using 2 divs , 1 div(the blue one) take percentage of main 1 (the grey div) accourding value data. did of don't know how make inner div build change it's percentage width according how close highest value in database. how fetch numbers shown in right. <?php echo @$item->{"media_count"}; ?> i attach image can see how need make like. barlike chart <table class="table table-bordered"> <tbody style="width: 401px; border: 0;"> <?php foreach ($data->data->data $key => $item): if (@$item->{"name"}) { ?> <tr> <td> <?php echo @$item->{"name"}; ?> </td> <td>

graphics - How to read data from a UTexture2D in C++ -

i trying read pixel data populated utexture2d in unreal engine c++ project. before post question here, tried use method described in link: https://answers.unrealengine.com/questions/25594/accessing-pixel-values-of-texture2d.html . however, doesn't work me. pixel values got texture garbage data. i want depth values scenecapture2d , post-processing material contains scenetexture: depth node. need depth values available in c++ can further processing opencv. in directx11, staging texture can used cpu read, in unreal engine, don't know how create 'staging texture' dx11 has. can't correct pixel values current method makes me think may try access no-cpu-readable texture. here experimental code reading data rgb utexture2d. initialize rgb texture: videotexturecolor= utexture2d::createtransient(640, 480, pf_b8g8r8a8); videotexturecolor->updateresource(); videoupdatetextureregioncolor = new fupdatetextureregion2d(0, 0, 0, 0, 640, 480); colorregiondata = new fupd

c# - Single.TryParse always failing -

i've been looking @ calculator friend, , we're having difficulties single.tryparse method. according msdn, following code should work: float j; if (single.tryparse("1.5", out j)) console.writeline(j); else console.writeline("string not parsed."); but outputs string not parsed. know why might case? this using visual studio 2015, community edition - believe use .net 4.6? other code i've tried: string value = "1.5"; float number; numberstyles style = system.globalization.numberstyles.allowdecimalpoint; cultureinfo culture = system.globalization.cultureinfo.createspecificculture("en-gb"); if (single.tryparse(value, style, culture, out number)) console.writeline(number); else console.writeline("error parsing number");

regex - How to match subdomain with gorilla mux -

i need build route matches 2 subdomains(prefix.api.example.com , prefix.api.sandbox.example.com) using gorilla mux router. far have regex below router returns 404 on requests. idea why that? router := mux.newrouter() route := router.host(`prefix.api{_:(^$|^\.sandbox$)}.example.com`) more code package main import( "github.com/gorilla/mux" "net/http" ) type handler struct{} func (_ handler)servehttp(w http.responsewriter, r *http.request){ w.write([]byte("hello world")) w.writeheader(200) } func main() { router := mux.newrouter().strictslash(true) route := router.host(`prefix.api{_:(^$|^\.sandbox$)}.example.com`) route.handler(handler{}) http.handle("/", router) panic(http.listenandserve(":80", nil)) } request: $ curl prefix.api.sandbox.example.com/any -v * trying 127.0.0.1... * connected prefix.api.sandbox.example.com (127.0.0.1) port 80 (#0) > /some http/1.1 > host: pref

Angular 2 component to component communication -

Image
i have top menu (component) displays list of models, , side menu (component) displays list of colors. in center of page have table (component) displays list of things based on user selections of color , model controls. none of controls child of other. table component rendered in router-outlet container. how can make table component listen property changes in 2 menu components? i have tried session service described here: https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-servicehttps://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service it not work because table component not child of menu components. i make simple service it: @injectable() export class filterservice { public modelchange$:eventemitter; public colorchange$:eventemitter; constructor(){ this.modelchange$ = new eventemitter(); this.colorchange$ = new eventemitter(); } public setmodel(model)

python - Installing Ipython - command Line -

im installing ipython school project. im doing through windows command line using command "pip install ipython" , error in end: windowserror: [error 32] process cannot access file because being used process: 'c:\users\daniel\appdata\local\temp\pip-ni1wof-record\install-record.txt' i reinstalled python 2.7 didn't change thing. restarted computer. idea i'm doing wrong?

MongoDB | Node.js Connection Pooling w/ module.exports -

hey guys i'm pretty new creating modules, i'm having bit of trouble accessing mongodb connection pool main application. here's module: // mongo-pool.js // ------------- var assert = require('assert'); var mongodb = require('mongodb'); var mongoclient = mongodb.mongoclient; var url = 'connection_url'; var mongopool = { start: function() { mongoclient.connect(url, function(err, db) { assert.equal(null, err); console.log("successfully connected mongo"); // make db object accessible here? }); } } module.exports = mongopool; when require mongo-pool.js , call mongopool.start() says connected mongo, although db object not accessible make queries. here main js file: var mongopool = require('./mongo-pool.js'); var pool = mongopool.start(); var collection = pool.db.collection('accounts'); collection.update( { _id: 'diynaiis' }, { $push: {

iOS Nest Firebase Framework [nest-api] -

i using firbase 1.2.3 provided nest sdk ios. have found firebase framework provided dated cannot built bitcode enabled. means cannot build whole project bitcode support. appears documentation still pushing firebase, in practice not updating it. example, believe firebase version 2.3.4 (bitcode supported). when use later version authorization process unstable , can take long time. has been successful , using more recent firebase framework?

deezer - Search using parentheses and single quote -

im using advanced search track , title, there seems problem either single quote or parentheses in query. with complete title i'm not getting correct track: https://api.deezer.com/search?q=track:"(i don't feel like) giving in" artist:"sea pinks"&limit=1&output=json only if remove parentheses part: https://api.deezer.com/search?q=track:"giving in" artist:"sea pinks"&limit=1&output=json

perl - Why do XS subs use const char *? -

a lot of perl xs code uses const char * return value of xs sub never char * . example: const char * version(...) code: retval = chromaprint_get_version(); output: retval code xs-fun can explain why const preferred? in testing, returned scalar modifiable whether const used or not. it's clarity. chromaprint_get_version function returns const char * , xsub should defined const char * return type well. if have @ built-in typemap , doesn't make difference whether use const char * , char * , or unsigned char * . use t_pv typemap. in cases, xsub return sv containing copy of c string, modifiable.

gulp - Jquery mobile not rendering after injecting precompiled handlebars -

the environment building app in phonegap , using handlebars templating. jquery-mobile in mix provide widgets , out of box themes. templates packed gulp build file , rendered onto page through separate js files. the route the file structure /- --|templates/ ----|login.hbs/ --|www/ ----|js/ ------|index.js ------|render/ --------|loginview.js the template before packing, login.hbs: <div class="app" data-role="page"> <div data-role="header"> <h1>index page</h1> </div> <div data-role="main" class="ui-content"> </div> <div data-role="footer"> <h1>title on page</h1> <button id="login-btn" class="ui-btn ui-icon-plus ui-btn-icon-left">login page</button> </div> </div> the file handles rendering, loginview.js var loginview = function() { this.initialize = function() { this.el = $(&

assembly - What does `1<<0` do in this code snippet? -

what these lines of code ? mbalign equ 1<<0 meminfo equ 1<<1 i know equ declare constants in nasm, 1<<0 do? it looks similar c bit operators far know in assembly use shl , etc. although shift nothing makes things easier read, think of mbalign equ 1<<0 meminfo equ 1<<1 as saying mbalign equ bit0 meminfo equ bit1 etc.

angularjs - Displaying server data on angular js Grid -

in offline web app , want dispaly server data on angularjs grid. have jsfiddle example new jsfiddle it displays default data . this code sync server $('#btnsyncserver').click(function () { var customers = []; db.linq.from(config.objectstorename).select().then(function () { if (customers.length > 0) { var postdata = { revision: parseint(localstorage.customerrevision, 10), appid: config.appid, customers: customers }; $.ajax({ url: 'api/service', type: 'post', datatype: 'json', contenttype: "application/json", data: json.stringify(postdata), success: function (data) { if (data.revision == localstorage.customerrevision) { alert('there newer version on server. please sync server first.'); } else {

eclipse - How to listen to changes in Java editor to refresh a view part? -

i'm implementing eclipse plug-in refresh new view part when change occurs in java file. possible? , how? besides that, need identify abstract syntax tree (ast) of present code in java editor. suggestion? you can listen changes of underlying idocument described here: eclipse plugin granularly monitor editor changes the java editor input adapts ijavaelement . example: editor.geteditorinput().getadapter( ijavaelement.class ) if result icompilationunit , can create ast thereof described here: https://www.eclipse.org/articles/article.php?file=article-javacodemanipulation_ast/index.html

partition - Sage ('Python-like' language) Attribute error "IntegerListsLex_with_category.element_class" object -

given integer k, have programmed way take partitions of k such that (1) each partition has @ n entries (where n given) (2) each partition not have repeated odd numbers. i categorized list of these partitions in descending order. however, unable append zeros end of given partition in list such partitions n-tuples. # define n , k (k, n) = (10, 5) # find partitions of k of max length n, , put partitions in list b b = partitions(k, max_length=n).list() # extracts partitions repeated odd components , creates separate list them, namely b_repeated_odds b_repeated_odds = [] in range(0, len(b)): j in range(0, len(b[i])): l in range(0, len(b[i])): if b[i][j]%2 == 1: if b[i][l]%2 == 1: if b[i][j] == b[i][l]: if j != l: b_repeated_odds.append(b[i]) # remove duplicates b_repeated_odds b_unique = uniq(b_repeated_odds) # remove unwanted partitions original list b, , sort fin

jquery - When hover the Selected image, the selected Image pops up -

my code pure html few javascript.i have sets of image need when hover image pops in big picture or same size html code: <div class="content-box-left-bootomgrid lastgrid"> <img src="../images2.jpg" title="ocean" /> <img src="../images3.jpg" title="pool" /> </div> when users hover image,the image pops need img { height: 200px; width: 200px; -webkit-transition: 1s ease-in-out; -moz-transition: 1s ease-in-out; -o-transition: 1s ease-in-out; -ms-transition: 1s ease-in-out; transition: 1s ease-in-out; } img:hover { -webkit-transform: scale(1.2); -moz-transform: scale(1.2); -o-transform: scale(1.2); -ms-transform: scale(1.2); transform: scale(1.2); } try one. think proper way it. increase or decrease number inside scale.

Using Javassist library to detect runtime type of a method caller -

i know javassist.expr.methodcall.getclassname() returns compile time type of method caller because depends on bytecode analysis. wondering if there efficient way actual runtime type of method caller javassist using trick or through code inspection. here simple example make things clearer. public interface animal { public void eat(); } public class dog implements animal { @override public void eat() { system.out.println("dog eating"); } } public class mainclass { public static void main(string[] args) { animal = new dog(); a.eat(); } } in example, find way "dog" object method caller method "a.eat()" from javassist.expr.methodcall can runtime class has called method: ctclass ctc = javassist.expr.methodcall.getmethod().getdeclaringclass(); once have javassist representation of class called method contains need class. ps if need dog instance can use reflection taking name c

How to add extra text to input value result using jQuery -

my html form is: <form id="search" action="form.html" method="get"> <input type="text" id="keyword" name="search" placeholder="keywords" /> </form> when type "test" , hit enter, go form.html?search=test using jquery, how can add "xx-" on result, i.e. form.html?search=xx-test ? thank you use keypress catch enter event , make url redirect this. $('#keyword input').bind('keypress', function(e) { if(e.keycode==13){ var keyword= $('#keyword').val(); window.location = form.html?search=xx_' + keyword; } });​

excel - Adding Keyword with count of occurrence in sheet2 to existing excelfile from sheet1 with pandas python -

i fetching data web excel sheet using pandas & able save sheet 1, want fetch data of particular column sheet 2 of same excel want put name of keyword & number of times keyword appear in column for example ,i have column title car manufacturer in sheet 1 & there can multiple rows different data same car manufacturer many customer can own audi,ford etc & there 6-7 columns in sheet1 & car manufacturer 1 of them . want data manufacturer count 1. audi 100 2. ford 30 3. mercedes 25 4. xxxxx 9 in sheet 2. python code samples appreciated! you asked similar question on adding data second excel sheet. perhaps can address there issues around to_excel() part. on category count, can do: df.manufacturer.value_counts().to_frame() to pd.series counts . need convert result .to_frame() because dataframe has to_excel() method. so altogether, using linked answer: import pandas pd openpyxl import load_workbook book = load

android - BottomSheet with ViewPager and Fragments? -

Image
i want view in older version of streetview. i have tried bottomsheetbehavior viewpager, dynamic height of fragments not working properly. using customviewpager can set height of fragment public class custompager extends viewpager { private view mcurrentview; public custompager(context context) { super(context); } public custompager(context context, attributeset attrs) { super(context, attrs); } @override public void onmeasure(int widthmeasurespec, int heightmeasurespec) { if (mcurrentview == null) { super.onmeasure(widthmeasurespec, heightmeasurespec); return; } int height = 0; mcurrentview.measure(widthmeasurespec, measurespec.makemeasurespec(0, measurespec.unspecified)); int h = mcurrentview.getmeasuredheight(); if (h > height) height = h; heightmeasurespec = measurespec.makemeasurespec(height, measurespec.exactly); super.onmeasure(widthmeasurespec, heightmeasurespec); } public void measurecurrentvie

Difficulty in Arduino programming on LED -

im working on arduino proramming have 1 led off on next one.. 16 leds tgt , im using shift register mc74hc595an aka 595 register. im finding difficult code them myself still learning how programme arduino. having code or work out on code share me please? form of appreciated! thank you! here code did doesnt seem working. const int button0pin = 15; const int button1pin = 1; const int button2pin = 2; const int button3pin = 3; const int button4pin = 4; const int button5pin = 5; const int button6pin = 6; const int button7pin = 7; void setup() { // put setup code here, run once: pinmode(button0pin, output); pinmode(button1pin, output); pinmode(button2pin, output); pinmode(button3pin, output); pinmode(button4pin, output); pinmode(button5pin, output); pinmode(button6pin, output); pinmode(button7pin, output); pinmode(14, input); serial.begin(9600); } void loop() { // put main code here,

html - How to give proper width to a .png in email newsletter for outlook 2013 -

i have developed email newsletter. developed email newsletter working fine on email clients except outlook 2013 . i using image in email newsletter not taking table width have given, taking own width i.e. 658px image attached and code table <table bgcolor="#ffffff" cellpadding="0" cellspacing="0" width="600px" align="center"> <tbody> <tr> <td style="align:center;vertical-align:top;width:600px"> <div style="width:600px;align:center"> <img src="images/demo1.png" style="width:600px"> </div> </td> </tr> </tbody> </table> please provide suggestions on how put image inside table <table bgcolor="#ffffff" cellpadding="0" cellspacing="0" width="600px" align="center"> <tbody><tr> <td style="align

nashorn - How to avoid "ReferenceError: "a" is not defined" -

the below code throws referenceerror: "a" not defined. possible avoid , treat variable null? scriptengine engine = new scriptenginemanager().getenginebyname("nashorn"); map<string, string> s = new hashmap<string, string>(); // s.put("a", "a"); bindings bindings = engine.createbindings(); bindings.putall(s); object res = engine.eval("!a", bindings); system.out.println(res); if don't have variable name "a" defined in scope chain, referenceerror should thrown per ecmascript specification. if uncomment line: // s.put("a", "a"); line "a" defined , therefore no referenceerror. you can check if variable defined or not using "typeof" operator. "typeof == 'undefined'" evaluate false undefined variable "a". won't referenceerror undefined variables. again standard compl

Overlap Bar chart android -

i want create overlapped bar chart application. know stacked bar chart , sub column bar chart. possible implement overlapped bar chart present in http://www.highcharts.com/demo/column-placement . using mpandroidchart https://github.com/philjay/mpandroidchart generating stacked bar chart , sub column bar chart.

php - Compare passwords in PHPBB3 and Mysql -

this case: i trying compare password given in form made myself password exist in database , created phpbb . so: 1. password of course hashed in mysql database 2. use password_hash() what think should work: $match = password_verify( (password_hash($userpass, password_default)), $row[3] ); phpbb can hash plain text , same hash stored in database so, how same functionality?

custom action - Stop windows service before perform the uninstallation -

Image
i have installer installs few components including windows service, after installed it'll start service installed onto system using customaction. the problem when uninstall application, installer asks close application before continue. i created custom action stop service, , scheduled uninstall actions. but not executed until press ok error dialog after manually stop service. it failed on win7, tested same msi on winxp , worked fine (the custom action executed before checking file in-use)!!! i'm using vs2010 setup project create installer, don't have problem modify (using orca example) after build. here content of installexecutesequence table : i found installvalidate action check in-use files, can't sequence custom action stop service before because before installinitialize action require custom actions after ( ice77 evaluator ) ice77 posts error if in-script custom action sequenced before installinitialize action or after installfinalize

How to divide a json into several parts in AngularJS -

i designing waterfall page, , these days i'm getting started on angularjs. wanna divide json data several parts display wrap each in different div. whole data in array, called items. <div id="dym-waterfall"> <div class="dym" ng-repeat="item in items"> </div> <div class="dym" ng-repeat="item in items"> </div> <div class="dym" ng-repeat="item in items"> </div> <div class="dym" ng-repeat="item in items"> </div> </div> there couple of ways of solving problem. firstly, assign scope value every part in "items". instance, assume json array: [data1, data2, data3, data4, data5] and in controller this: $scope.data1 = items[0]; do every part need broken up. keep in mind 'data1' part arbitrary , can make name want. in html: <div class="dym" ng-repeat="stuff in data1">&

Bluemix Container doesn't work -

i started container 2 weeks ago, today container doesn't work. here message web. contaner status start new contaner from error message, not reach container, intermittent network problem on side, or container problem itself. you can check container status command: cf ic info cf ic inspect if consistent problem container issue on backend, may have engage bluemix support check it.

java - Can Linux and Windows data system co-exist -

planning have 2 system - linux (running java , databae posgrsql) , windows (running .net application , database ms sql) in parallel. of data residing in both database systems accessed both applications in linux , windows. so, can 2 system co-exists? can either of applications access , manipulate data? in theory possible ... large degree. couple of things things think about: if data duplicated across different databases in ad-hoc fashion, going have solve problem of keeping copies in step. if system requires transactions read / update data in multiple databases, going need use distributed transactions going make things complicated. (really complicated if don't have overarching xopen/xa framework in system architecture.) my advice try simplify technology base, , if can't try keep clean boundaries between respective databases. ideally, design architecture there application service tier separate / independent services each database. have clients talk appl

Basic Auth header not sent (Swagger) -

Image
i have basic auth secured api after filling in authentication credentials, not apply request header. saw"error server not found or error occurred " @ swagger editor , "401 unauthorized" on fiddler. user name , pwd : odata , qtkr47ptm3pmzlyehnrw4dxhhgyjmfm3ckuzfxdn0tk= here swagger json { "swagger": "2.0", "info": { "version": "1.0.0", "title": "basic auth example", "description": "an example how use basic auth swagger.\nserver code available [here](http://navm3.cloudapp.net:90/nav/odata). it's running on navm3.\n\n**you can use below user name , password test.**\n* user name: `odata`\n* password: `qtkr47ptm3pmzlyehnrw4dxhhgyjmfm3ckuzfxdn0tk=`\n" }, "host": "navm3.cloudapp.net:90", "basepath": "/nav/odata", "schemes": [ "http" ], "securitydefinitions": { "basicauth":

arrays - VB.NET Get Keys by sorted Values in Hashtable -

i studying vb.net , want know better idea keys sorted values in hashtable here solution built dim int_value integer() = new integer() {-9, 2, 8, 6, 8, 1, -9} dim int_key integer() = new integer() {1, 2, 3, 4, 5, 6, 7} dim dum_int(int_key.length) integer dim store_keys new arraylist array.copy(int_value, dum_int, dum_int.length - 1) array.sort(dum_int) array.reverse(dum_int) = 0 dum_int.length - 1 ii = 0 int_value.length - 1 if dum_int(i) = int_value(ii) store_keys.add(int_key(ii)) int_value(ii) = integer.maxvalue end if next next i got output like.. '' output'' (0) 3 {integer} object (1) 5 {integer} object (2) 4 {integer} object (3) 2 {integer} object (4) 6 {integer} object (5) 1 {integer} object (6) 7 {integer} object i assume have hashtable. i create 2 array

amazon s3 - Access S3 in cron job in docker on Elastic Beanstalk -

i have cron job in docker image deploy elastic beanstalk. in job wish include read , write operations on s3 , have included aws cli tools purpose. but aws cli isn't useful without credentials. how can securely include aws credentials in docker image, such that aws cli work? or should take other approach? always try avoid setting credentials on machines if run within aws. do following: go iam console , create iam role, edit policy of role have appropriate s3 read/write permissions. then go elastic beanstalk console, find environment , go the configuration/instances section. set "instance profile" use role created (a profile associated role, can see in iam console when you're viewing role). this mean each beanstalk ec2 instance have permissions set in iam role (the aws cli automatically use instance profile of current machine if available). more info: http://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html#use-role

Is it possible to set the standard input/output to a file in C? -

this question has answer here: redirect stdout file without ansi warnings 1 answer can standard input/output set file c programme. know can use fscanf , fprintf read , write file setting std i/o file, can use printf/scanf i/o operations in c programme? is possible set standard input/output file in c? yes, can using freopen . example code above site: #include <stdio.h> #include <stdlib.h> int main(void) { puts("stdout printed console"); if (freopen("redir.txt", "w", stdout) == null) { perror("freopen() failed"); return exit_failure; } puts("stdout redirected file"); // written redir.txt fclose(stdout); }

python - Getting system check errors -

i trying set local development environment complex web application. there no proper documentation setting environment, it's been 2 days resolving errors myself. after resolving errors, getting system check errors mentioned below , don't understand mean? can help, these errors mean , how resolve them. django.core.management.base.commanderror: system check identified issues: errors: <class 'credits.admin.creditshistoryadmin'>: (admin.e035) value of 'readonly_fields[29]' not callable, attribute of 'creditshistoryadmin', or attribute of 'credits.creditshistory'. <class 'credits.admin.creditshistoryadmin'>: (admin.e035) value of 'readonly_fields[30]' not callable, attribute of 'creditshistoryadmin', or attribute of 'credits.creditshistory'. the class credits.admin.creditshistoryadmin has attribute readonly_fields . it's list of fields shown read-only in admin (see docs on modeladmin.r

jsp - How to get radio button group values in servlet? -

this question has answer here: how transfer data jsp servlet when submitting html form 4 answers i want values selected radio button in jsp form servlet.how values in servlet,for in advance. jsp page is: <table class="table" id="attendancetableid" style="width: 500px;"> <% for(int i=0;i<=se.size()-1;i++) { %> <tr> <td><input type="textbox" name="studentname" value="<%=se.get(i)%>" style="background-color: #a7c5c2" readonly></td> <td><input type="radio" name="status_<%= %>" value="present" style="width: 15px; height: 15px;" />present <input type="radio" name="status_<%= %>" value="absent" style="width

jpa - Hibernate many to many removing entries in join table while update owner table -

i trying update entity having many many relationship table. @entity(name = "coaching") public class coachingentity { @manytomany(fetch = fetchtype.lazy, cascade = { cascadetype.refresh }) @jointable(name = "coaching_field", joincolumns = @joincolumn(name = "coachingid", referencedcolumnname = "coachingid"), inversejoincolumns = @joincolumn(name = "fieldid", referencedcolumnname = "fieldid")) private set<fieldentity> fieldentitylist; now, when update coachingentity, hibernate removing entries coaching_field table (many many join table). have searched in internet ( jpa update many-to-many deleting records ) not able find right approach. in jpa many many merge on owner triggers delete on join table , tried recommended approach used set facing same problem. per https://stackoverflow.com/a/1078295/2116229 , need override equals , hashcode? you need overwrite equals() , hashcode

javascript - Anchor tag for an ID on another page -

i have anchor tag on 1 page , want move other page index.html page has "about us" id on div. id working same page not when try go page. there questions similar mine none give me answer, in 1 question said related script doesnt give solution of do. can solution through javascript or jquery solution. please me, thanks it evident comments missing forward slash between url , section id. please include "/" <a href= "index.html/#aboutus"> , not <a href= "index.html#aboutus">

Testng assertj report and continue -

i'm using testng assertj test web using fluentlenium , extent reports reporting results i askd before question forgot mention use of assertj. the provided answer extend soft assert , has onassertfauilre function. is there assertj soft assertions? or other soultion bypass it? in next assertj version (2.5.0) have access soft assertions errors (see commit ). hope helps

socket.io - Difference between events close and disconnect Socket I/O -

on server side there 2 events namely close , disconnect . difference between two. how , when fired respectively. here doc on socket.io io.sockets.on('connection', function(client){ client.on('disconnect', function(){ /// }); client.on('close', function(){///}); }

java - Changing Text Value of JLabel In Real Time -

i trying change text of jlabel (searchedstock) in real time. here code: public void gamegui() { gridbagconstraints c = new gridbagconstraints(); c.fill = gridbagconstraints.horizontal; c.gridwidth = 2; jlabel welcome = new jlabel("welcome " + playername + "!"); welcome.setfont(new font("arial", 1, 30)); gamepanel.add(welcome, c); c.gridx = 0; c.gridy = 1; gamepanel.add(new jpanel(), c); c.gridwidth = 1; c.gridy = 2; gamepanel.add(new jlabel("symbol search:"), c); c.gridx = 1; final jtextfield symbolsearch = new jtextfield(10); gamepanel.add(symbolsearch, c); c.gridx = 0; c.gridy = 3; gamepanel.add(new jpanel(), c); c.gridx = 0; c.gridy = 4; c.gridwidth = 2; jbutton search = new jbutton("search"); search.addactionlistener(new actionlistener() { public void actionperformed(actionevent e){ stockvalue = double.tostring(ge

performance - Set mobile data enabled via android code on switch button -

i tried following method: public void mobiledataenable(boolean enabled) { try { final connectivitymanager conman = (connectivitymanager)getsystemservice(context.connectivity_service); final class<?> conmanclass = class.forname(conman.getclass().getname()); final field iconnectivitymanagerfield = conmanclass.getdeclaredfield("mservice"); iconnectivitymanagerfield.setaccessible(true); final object iconnectivitymanager = iconnectivitymanagerfield.get(conman); final class<?> iconnectivitymanagerclass = class.forname(iconnectivitymanager.getclass().getname()); final method setmobiledataenabledmethod = iconnectivitymanagerclass.getdeclaredmethod("setmobiledataenabled", boolean.type); setmobiledataenabledmethod.setaccessible(true); setmobiledataenabledmethod.invoke(iconnectivitymanager, enabled); } catch (exception e) { e.printstacktrace(); } } added fol

javascript - jQuery best practices in case of $('document').ready -

i researching on jquery best practices , found this article by greg franko normally, do: $("document").ready(function() { // dom ready! // rest of code goes here }); but article recommends use: // iife - invoked function expression (function($, window, document) { // $ locally scoped // listen jquery ready event on document $(function() { // dom ready! }); // rest of code goes here! }(window.jquery, window, document)); // global jquery object passed parameter i can see comments there, couldn't figure out saying. so, better approach , why? i know both methods work, how second 1 become better ? immediately invoked function expressions (iifes) iifes ideal solution locally scoping global variables/properties , protecting javascript codebase outside interference (e.g. third-party libraries). if writing jquery code run in many different environments (e.g. jquery plugins), important use iife locally scope