Posts

Showing posts from April, 2010

.net - C# how to change bitmap image color and apply anti-aliasing -

i working on flowchart making application , involves changing color of images transparency(png). i've been searching hours workarounds , it's either it's not i'm looking or can't make work. first, let me show codes , how it. removed parts of code unrelated question. this class "create" flowchart symbols. inherited label class because need text centered on symbols. use images in .png format located inside resources folder , change color according user wants. namespace pf2 { public class terminal : label { public void createterminal(int x) { this.width = 250; this.height = 100; this.name = "terminal" + x; this.autosize = false; bitmap resized = new bitmap(properties.resources.shapeterminal, new size(this.width, this.height)); this.image = globals.changecolor(resized, color.yellow); this.text =

c# - How to iterate through a list so that the last iteration step goes back to the first object? -

i have list of points form plane. want create edges between consecutive points , add them list. here code have: // points forming plate arraylist points = part.points; // number of points forming plate int pointcount = points.count; // create edges list<linesegment> edges = new list<linesegment>(); (int = 0; < pointcount - 1; i++) { // start , end points point start = points[i]; point end = points[i+1]; // create edge linesegment edge = new linesegment(start, end); // add edge list edges.add(edge); } it doesn't quite work because doesn't create last edge between last , first points on list. way correct it? make work if statement this: for (int = 0; < pointcount; i++) { // start , end points point start = points[i] point; point end; if (i == pointcount-1) end = points[0] point; else end = points[i+1] point; // rest of code here } but i'm sure there more elegant way it. in python start lo

html - Enable ng-click on a popup (mapbox) -

first apologize poor english i'm working on map marker , popup declared mapboxgl, i'm trying put ng-click button of popup instantiated in controller mymap.on('touchstart', function (e) { var features = mymap.queryrenderedfeatures(e.point, { layers: ['points'] }); if (!features.length) { return; } console.log(features); var feature = features[0]; if(popup == undefined){ var html = '<div class="popup-info">'; html += "<h5>"+ feature.properties.type + "</h5>"; html += "<p>"+ feature.properties.description +"</p>"; html += '<button ng-click="gotocomment()">commentaires (' + nbcomment +') </button>'; html += "</div>"; html += '<a href="#" class=&quo

javascript - Highlight text using query value in Griddle table -

i have data in griddle table. entering search string through custom filter box. want highlight search string value in griddle columns . how possible ? want achieve in react <code>https://jsfiddle.net/julmot/buh9h2r8/"</code>

javascript - image slideshow using canvas HTML5 -

i trying create image slideshow using html5 canvas , little bit of javascript. problem following: slideshow works fading effect want first passing through image set, , after that, images drawn canvas without effect, , keeps going that. html: <canvas id="showcanvas" width='600' height='400'>canvas not supported</canvas> javascript: <script type="text/javascript"> var imagepaths = ["images/j0149014.jpg","images/j0149024.jpg","images/j0149029.jpg"]; var showcanvas = null; var showcanvasctx = null; var img = document.createelement("img"); var currentimage = 0; var revealtimer; window.onload = function (){ showcanvas = document.getelementbyid('showcanvas'); showcanvasctx = showcanvas.getcontext('2d'); img.setattribute('width','600'); img.setattribute(

Jquery calculate months between 2 dates -

what achive if user puts in date 08/08/2016 08/09/2016 = 1 month 08/08/2016 01/09/2016 = 1 month 08/08/2016 30/08/2016 = 1 month so basicly if wants rent room 01/08/2016 30/08/2016 counts 1 month could me achive jquery? or point me start. please have @ code. please note while testing this; put date in "mm/dd/yyyy" format i.e. date format. hope you $(document).ready(function() { $("#calc").click(function() { var = $("#from").val(); var = $("#to").val(); var monthdifference = 0; if (from != "" && != "") { var fromdate = new date(from); var todate = new date(to); calculatemonths(fromdate, todate, monthdifference); } }); function calculatemonths(fromdate, todate, monthdifference) { if (fromdate < todate) { monthdifference++; fromdate.setmonth(fromdate.getmonth() + 1); calculatemonths(fromdate, todate, mon

c - Memory allocation error (I think?) in a dynamically sized shopping list. -

i've included code below if kind enough complile see problem. i'm trying make dynamically allocated shopping list used pointers , memory allocation. the entries stored in 1d char array (seperated null pointers). arrays containing location of first character , entry length have been created in order navigate list. the code works small entries, when use list of large entries (e.g. 'adsjasdkasjdaksdj') code thinks length (strlen(message)) '110040'. me looks memory error i'm no computer scientist (more of amateur coder). tried extending memory allocated using realloc() problem persists.. appreciated! i've put code in loop take 10 entries testing purposes. #include <stdio.h> #include <stdlib.h> #include <string.h> int listentries = 0; int main(int argc, const char * argv[]) { //initial definition , allocation of memory. char *list; list = (char *)malloc(sizeof(char)); //allocates requested memory , returns pointer

ruby on rails - Password contains special characters not saved correctly -

update: fixed setting config.pepper in devise.rb i use rails 4 , devise 3.4.1 . built api register , authenticate user. clients use api emberjs web app, ios app , android app, post man chrome app development. if registered user password contains special characters post man user registered , log in successfully. when register user other clients user registered can't log in again. i checked following points: 1- checked request headers , same clients. (true) 2- used rails debugger ensure server received password correctly.(true) 3- have 3 environments development, staging, production. problem exist in staging , production works @ development.

ruby - Click not working with react component + capypara -

i've react component when click in icon, state change , put input instead of icon. when try simulate on test, using capybara component doesn't change. there's chance click doesn't work @ component because of capybara? or not work because it's react component? component: render() { return ( <div> { this.state.editable ? this.rendereditablecomponent() : this.rendernoteditablecomponent() } </div> ) } rendereditablecomponent() { return ( <editabledeliverlimit value={ this.state.value } handleclick={ this.handleclick.bind(this) } /> ) } rendernoteditablecomponent() { return ( <noteditabledeliverlimit value={ this.state.value } handleclick={ this.handleclick.bind(this) } /> ) } test: then "should successfuly change deliver limit" wait_for_selector_appearance("##{ad_table_row_id(@ad)} .ad-table-row-deliver-limit span") find("##{ad_table_

c++ - CGAL. Concave hull 3d (Alpha_Shapes_3) -

Image
there set of points (3d space). , construct 3d conсave hull according given set of points. result want obtain subset of points, calculated conсave hull consists of. looking forward help. in advance. i did job. #include <cgal/exact_predicates_inexact_constructions_kernel.h> #include <cgal/delaunay_triangulation_3.h> #include <cgal/triangulation_hierarchy_3.h> #include <cgal/alpha_shape_3.h> #include <cgal/io/io.h> #include <iostream> #include <sstream> #include <string> #include <fstream> #include <cgal/io/writer_off.h> #include <cgal/simple_cartesian.h> using namespace std; typedef cgal::exact_predicates_inexact_constructions_kernel k; typedef cgal::alpha_shape_vertex_base_3<k> vb; typedef cgal::triangulation_hierarchy_vertex_base_3<vb> vbh; typedef cgal::alpha_shape_cell_base_3<k> fb; typedef cgal::triangulation_data_structure_3<vbh, fb&

apache spark - pyspark 2.0 throw AlreadyExistsException(message:Database default already exists) when interact with hive -

i 've upgraded spark 2.0.0 1.3.1, wrote simple code interact hive(1.2.1) used spark sql, i've put hive-site.xml spark conf directory, , expected results sql, throws weird alreadyexistsexception(message:database default exists) , how ignore this? 【code】 from pyspark.sql import sparksession ss = sparksession.builder.appname("test").master("local") \ .config("spark.ui.port", "4041") \ .enablehivesupport()\ .getorcreate() ss.sparkcontext.setloglevel("info") ss.sql("show tables").show() 【log】 setting default log level "warn". adjust logging level use sc.setloglevel(newlevel). 16/08/08 19:41:22 warn util.nativecodeloader: unable load native-hadoop library platform... using builtin-java classes applicable 16/08/08 19:41:24 info execution.sparksqlparser: parsing command: show tables 16/08/08 19:41:25 info hive.hiveutils: initializing hivemetastoreconnection version 1.2.1 using spark classes.

python - How to use Tensorflow and Sci-Kit Learn together in one environment in PyCharm? -

i using ubuntu 16.04 . tried install tensorflow using anaconda 2 . installed environment inside ubuntu . had create virtual environment , use tensorflow . how can use both tensorflow , sci-kit learn in single environment . anaconda defaults doesn't provide tensorflow yet, conda-forge do, conda install -c conda-forge tensorflow should see right, though (for others reading!) installed tensorflow not work on centos < 7 (or other linux distros of similar vintage).

UIRefreshControl cancel touch on top of custom cell - Objective-c iOS -

i have issue uirefreshcontrol : after first time triggered, cancels touch on top of first custom cell (even if hidden), if invisible. if remove superview, add again, issue still there. actually have uitableview populated data. user can refresh table view pulling , i've added uirefreshcontrol table view in viewdidload() self.refreshcontrol = [[uirefreshcontrol alloc]init]; self.refreshcontrol.tintcolor = [uicolor colorwithred:0.35 green:0.78 blue:0.98 alpha:1.0]; [_tableview addsubview:self.refreshcontrol]; i've not added selector refreshcontrol object because want tableview refresh when user stopped touching screen. i've added scrollview's delegate method : - (void)scrollviewdidenddecelerating:(uiscrollview*)scrollview { if (self.refreshcontrol.isrefreshing) { dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ dispatch_sync(dispatch_get_main_queue(), ^{ [self refreshtable];

php - Laravel Eloquent Modal - First Row? -

inside od seeder file tried first record of user-model. can't seem find correct way. i want fetch first user, , id use in user_id (foreign key). this not working: class terminalstableseeder extends seeder { /** * run database seeds. * * @return void */ public function run() { $user = user::findorfail(1)->first(); db::table('terminals')->delete(); terminal::create([ 'serial' => 'r-123-548-753', 'state' => 1, 'user_id' => $user->id ]); } } it fails because said "1", requires 1 parameter, first row in user doesn't have id of 1, don't want hardcode this. simple solution use firstorfail $user = user::firstorfail(); //it return first record top terminal::create([ 'serial' => 'r-123-548-753', 'state' => 1, 'user_id' => $user->id' ])

html - Stack divs ontop of each other -

Image
i have 3 column set of divs styled table. i'd these 3 columns stack vertically on mobile device. i believe maybe possible using float method, titles , description each column appear in seperate rows (divs) i'm not sure how make happen? intension fiddle https://jsfiddle.net/8tv35jll/ html <p><img alt="service-desk-team-heads-mini-min.png" height="212" src="/sites/default/files/pictures/service-desk-team-heads-mini-min.png" title="the 2016 workbooks support team" width="878" /></p> <h4 style="text-align: left;">please use search tool above,&nbsp;the left-side menu or links below browse through our knowledge base.</h4> <div class="rtable"> <div class="rtablebody"> <div class="rtablerow"> <div class="rtablecell"> <h4>new workbooks?</h4> </div> <div class="rtablecell"> <

PHP: Design pattern for managing types of entity -

i have user entity. have multiple "types" of entity, different managers , repositories. user entities of types share userinterface . now, i'm looking method of organizing everything. first thing came mind create this: interface usertypemanagerinterface { public function addusertype($name, repositoryinterface $repository, managerinterface $manager); public function hastype($name); public function getrepository($type); public function getmanager($type); } then in places manage multiple types of user @ once, inject this, , in places manage specific type of user, inject specific repository , manager objects, type. seems pretty clean approach, @ same time, when create test class using usertypemanager need mock usertypemanager , mock need return other mocks (repository , manager). this doable of course, made me thinking if can avoided. other thing can think of, allow avoidance of above complexity during testing, this: interface usertypemanagerinterface

How to send responsive array from android using retrofit -

i trying call web service receives responsive array. sending hash map values using retrofit in android giving me 500 internal server error.following code: @post("/save") public void createaccount( @body map<string, string> data, callback<response> callback); that's how can retrofit 2 interface: @post("/save") call<jsonelement> createaccount(@body requestbody requestbody); request code: //create jsonobject key-pair values jsonobject root = new jsonobject(); root.addproperty("key1", "value1"); root.addproperty("key2", "value2"); //get string string resultjson = root.tostring(); //parse requestbody type requestbody requestbody = requestbody.create(mediatype.parse("application/json"), resultjson); //create adapter retrofit restadapter = new retrofit.builder() .baseurl(constants.root_api_url) .addconverterfactory(gsonconverterfacto

delphi - Easiest way to find the mean of a dynamic array -

i have created dynamic array, , have passed values it. there shortcut finding mean of dynamic array. var themin, themax: integer; x: array of integer; //dynamic array declaration .... themin := minintvalue(x);//i able retrieve minium value of dynamic array themax := maxintvalue(x);//i able retrieve maximum value of dynamic array is there other way mean using math library. it easy write such function. function mean(const data: array of integer): double; overload; var i: integer; begin result := 0.0; := low(data) high(data) result := result + data[i]; result := result / length(data); end; i overloaded sit alongside same named functions in math unit. if wish use built in library code can use sumint math unit: themean := sumint(x) / length(x); sumint performs summation using integer accumulator. faster bespoke function uses floating point accumulator. however, integer accumulator potentially subject overflow may off-putting. on other hand

javascript - Why does Google Tag manager append at the end of the body? -

i trying implement google tag manager run problem since gtm appends tags right before closing tag of body. whenever have template needs call bit of code 1 of scripts in google tag manager undefined error. obvious since not matter place script in view, gtm come after since appends right before closing body tag. is there way fix behaviour , why google this? understand helps non-blocking might place async attributes on scripts , same? an example have facebook pixel 1 of tags in gtm , need able make specific event call when loading page view. fbq('track', 'search'); ofcourse needs fbq instance begin with. leave me 1 option , try , place script in footer general template , messy. any workaround behaviour? the issue facing facebook library not loaded when calling function. 1 method migrate facebook code gtm trigger on pages , fire specific code on dom ready you use code below , see when _fbq.loaded variable set true. https://gist.github.com/chrisjho

angularjs - Ionic popup template content does not fix to popup window -

i'm trying use popup view list inside it. list contains many items. when i'm trying this, list not fixing popup menu in devices. it's working in browser. view in device looks following image. mobile user interface this controller .controller('taskctrl', function ($scope, $http, $ionicpopup) { $scope.taskslist = function () { $scope.listdata = []; (var = 0; < 100; i++) { $scope.listdata.push(i) } var mypopup = $ionicpopup.show({ template: ' <style>.popup { width:500px; height:50%; }</style> <ion-list> ' + ' <ion-item ng-repeat="item in listdata"> ' + ' {{item.id}} ' + ' </ion-item> ' + '</ion-list> ', title: 'current tasks', scope: $scope, buttons: [ { text: '<b>close</b>

ssl - Wordpress install on https://www domain -

how can install wordpress on https://www domain ? installed normal method not working! used code redirecting https , www. rewriteengine on rewritebase / rewritecond %{https} !=on [or] rewritecond %{http_host} ^bloom\.pk$ [nc] rewriterule ^ https://www.bloom.pk%{request_uri} [r,l]

javascript - click on hyperlinks in unit testing using protactor in angularjs -

i new in unit testing in angularjs. read tutorial from: https://github.com/angular/protractor/blob/master/docs/tutorial.md . i want click on hyperlink dont know how can achieve this. here code: <li ng-repeat="menu in sidebarlinks" ng-if="menu.visible == true " ng-class="{active: isactive('/{{menu.action}}')}"> <a ng-href="#/{{menu.action}}" title="{{menu.name}}" ng-click="loadsubmenus(menu.action)" ng-class="{active: isactive('/{{menu.action}}')}"> <div class="icon {{menu.icon}}" ng-class="{active: isactive('/{{menu.action}}')}"></div> <span>{{menu.name}} </span> </a> </li> in unit testing: describe('protractor demo app', function() { browser.driver.get('https://localhost:8443/login.ht

javascript - Why are only half the element's classes able to be toggled? -

i'm utilizing jquery's .toggleclass() function create favorite button inside several <div> elements, each has <a> element, , <i> element. i'm using 2 icons font awesome classes i'm toggling , forth between. this works fine demonstrated jsfiddle . the issue i'm having when dynamically generate these elements using php foreach loop half of generated element's classes toggle. html : <div> <a class="h-icon" href="#"> <i class="fa fa-heart-o" aria-hidden="true"></i> </a> </div> <div> <a class="h-icon" href="#"> <i class="fa fa-heart-o" aria-hidden="true"></i> </a> </div> <div> <a class="h-icon" href="#"> <i class="fa fa-heart-o" aria-hidden="true"></i> </a> </div> <div> <a

php - Json encode with strips html tags -

how strip html tags complete row json_encode <?php $return_arr = array(); $sql="select * products "; $results=$conn->query($sql); if($results->num_rows > 0) { while($rowz = $results->fetch_assoc()){ array_push($return_arr, $rowz); } } echo json_encode($return_arr); ?> my output field like( "<.p>"lorem ipsum<./p>lorem lorem lorem <./br>.....") strip_tags require string not array you can use following code: <?php $array = array( '<p>hello</p>' ); array_walk_recursive($array, function (&$val) { $val = strip_tags($val); }); echo json_encode($array); ?> above code, in array_walk_recursive array values , strip html tags.

javascript - How to add texts or label to an object like decals? -

in site: https://www.owayo.com/konfigurator_html/index.php?sport=basketball&product=shirts&lang=en&land=us# you can put button "text", add text , put button "ok". text created add objects decal. how can display effect? thank much! i believe should create texture text , add material

autolayout - use code init UITextView, Constraints not working -

use code init uitextview, constraints retuen nsarray count 0 - (void)textviewdidchange:(uitextview *)textview{ nslog(@"constraints:%@",textview.constraints);} 2016-08-08 17:43:32.347 demo[5756:2552780] constraints:() but use storyboard init ok.

c# - Set image resolution -

i have array of image bytes , set resolution. original image can jpeg, png, bmp. output - png. using imagemagic convert image , manipulations. using (var image = this.convert(originalimage, height, width)) using (var stream = new memorystream()) { image.quality = 90; image.write(stream, magickformat.png); return stream.getbuffer(); } i tryed modify image.getexifprofile , has no success (at least png images). i can't use comandline tool (like imagemagic or exiftool) here. there 3 exiff tags need modify xresolution yresolution resolutionunit i can achieve bitmap, resource overhead (need create memorystream ...). i have found pdf specification , consume time make work. does can point me right direction? thanks.

range - seiyria/bootstrap-slider getValue() not working -

i've looked through answers on topic, reason can't work. i've set slider following markup: <input data-slider-id="xslide" type="text" data-provide="slider" data-slider-min="0" data-slider-max="10" data-slider-step=".5" data-slider-value="0" data-slider-tooltip="show" data-slider-orientation="vertical" data-slider-reversed="true"></input> what want first of console.log numerical value. i've tried playing type number or text didn't work. tried per example on github: var myslider = $("xslide").slider(); var value = myslider.slider('getvalue'); console.log(value); but produced error $(...).getvalue not function i tried writing $('#xslide').data('slider').getvalue() produced error $(...).data(...) undefined . i tried solutions offered on example page like $('#xslide').slider({ formatter: functi

Previous sprite in paper2D flip book animation remains behind updated sprite animation -

i have been stuck on issue around week now, have tried searching around can't seem find conclusive fix issue. imgur album , link doc shows blueprint animations sprite , how looks in game. the sprite changes depending on how far away player away enemy. image of in-game , enum switch node: http://imgur.com/a/8ljdy image of movement node: https://drive.google.com/file/d/0bx4vd3wkvxnvlvi0y0rhsdhiyxc/view?usp=sharing sorry way doc blueprint looks. great. never mind guys. found out. changing papersprite character flipbook instead, able cycle through enums without error

c++ bmp to 2d-array prints unrealistic values -

i'm having trouble small project i'm doing. have convert bmp file 2d array of color (i made own typedef struct each color). code works (it doesn't run errors) , values matching image others don't; 3 first pixels of image white while says first red, green , blue. #include <string> #include <iostream> #include <fstream> using namespace std; const int w = 960, h = 720; typedef struct colors { int red; int green; int blue; } color; color image[h][w]; void readbmp(char *filename) { file *f = fopen(filename, "rb"); unsigned char info[54]; fread(info, sizeof(unsigned char), 54, f); // read 54-byte header // extract image height , width header int width = *(int *) &info[18]; int height = *(int *) &info[22]; /* w = width; h = height;*/ int size = 3 * width * height; unsigned char *data = new unsigned char[size]; // allocate 3 bytes per pixel fread(data, sizeof(unsigned char)

How does Apache resolve 'localhost' -

with regular apache setup, typing localhost or 127.0.0.1 browser result in apache trying serve files out of ~/public_html . want know how ~ part resolved, since no information system user included in http request , , multiple users using same apache service @ same time, can't resolved based on "current logged in user" . how apache know how resolve ~ ? apache has user directive available. the user directive sets user id server answer requests. in order use directive, server must run root . if start server non-root user, fail change lesser privileged user, , instead continue run original user.

phantomjs - Detecting Image on Page Load -

i want test whether particular image loaded javascript on page load. this image loaded after particular js library gets executed . for reference : using utility js library - zurb's foundation detects view port , user agent , loads appropriate image. when page downloaded - "src" attribute in img tag empty when foundation js executes loads image adding src tag on img tag. in onresourcereceived - image never shows up. in onloadfinished - image tag attribute src not present. how tackle scenario when image load triggered javascript library. ? basically test case want execute : test whether right quality image being loaded based on device.

Kubernetes fails to pull Docker image from artifactoryonline.com -

i using kubernetes on aws run play+akka streams server. here version details: client version : version.info{major:"1", minor:"2", gitversion:"v1.2.4+3eed1e3", gitcommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", gittreestate:"not git tree"} server version : version.info{major:"1", minor:"2", gitversion:"v1.2.4", gitcommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", gittreestate:"clean"} here deployment script: apiversion: extensions/v1beta1 kind: deployment metadata: name: service-validation2 labels: name: service-validation2 spec: replicas: 1 strategy: type: recreate template: metadata: labels: name: service-validation2 spec: containers: - name: service-validation2 image: company-docker-docker-local.artifactoryonline.com/service:1.0.192 ports: - containerport: 9000 imagepullsecrets:

Moodle user enrollment to a course using Api -

i new moodle, setup site in local server. created new courses, users it. want enroll patient specific course (created using admin side) through javascript api. options enroll user in course. couldn't find apis enroll section javascript api ? moodle uses php api , has webservice api. see nice ws example : using moodle create users , enroll them in courses via sql you call webservice api via js..

javascript - drawing a flow chart to show system interactions -

i have transactional data in oracle db , need know best way show data flowcharts on webpage? sample data in tables::::: txn1|sourcesys txn1|system1 txn1|system2 txn1|system3 txn1|endsys i want output in gui flowchart diagram sourcesys -----> system1 -----> system2 -----> system3 -----> endsys i thinking angular js flot maybe? can please suggest few simple ways go this? (only opensource libs please). thank you. you may use piechart drawing flow chart easily. reference link: https://developers.google.com/chart/interactive/docs/gallery/piechart

json - converting Javascript's Date.now() into timestamp in Stream Analytics -

i tried collect pressure values using node.js in raspberry pi , azure stream analytics in azure iot hub. sent data iot hub json file using code : var data = json.stringify({ deviceid: "myraspi10", pressureval: value, time:date.now() }); when checked console, here's being sent hub { "deviceid":"myraspi10", "pressureval":39, "time":1470642749428 } how convert time value timestamp in azure stream analytics? try sending new date() instead of date.now() . produce string output "2016-08-08t08:22:34‌​.905z" may azure stream analytics treat date. (haven't used though, idea).

javascript - Angular JS inaccurate substraction of two decimal numbers -

in angular js application have 3 amounts in 1 object. in chrome browser debugger have following: payment.amountforclosing = payment.amountremaining - payment.amountreserved; payment.amountremaining has value of 3026.2 payment.amountreserved has value of 2478.4 after substraction payment.amountforclosing has value of 547.7999999999997, , 547.8 displayed. when user tries make payment closing, validation logic returns error indicating there not enough money make payment closing because of state presented above. those amount values come c# webapi 2.0 backend, system.decimal types. when dealing currency, worst thing can use floating point numbers, can see. because of way how floats stored, operations may provide incorrect results. thing correct multiplication/division power of 10. best way store currency integer/biginteger, or whatever, , save e.g. 4 decimal places 12100 should represent 1.21 then can subtraction/multiplication of integer numbers , @ end divide po

castle windsor - How can I register a Wcf Service contract without knowing the implementation -

without castle windsor write: var channelfactory = new channelfactory<icredentialservice>("default"); icredentialservice credentialservice = channelfactory.createchannel(); how can register wcf service contract castle windsor api? add castle windsor wcf integration facility nuget package project add wcffacility container: container.addfacility<wcffacility>(); then, tell container provide wcf client when have dependency on service interface: container.register( component.for<icredentialservice>() .aswcfclient(wcfendpoint.fromendpoint("endpointname"))); it use named endpoint in .config retrieve settings endpoint. whenever class resolved container has constructor dependency on icredentialservice container inject wcf client.

ruby on rails - Network monitoring in Web App -

i want create web app can monitor network components status in network. think must 1 page icons of network components connected lines. , every icons show component status. i prefer rails, open other tech. has ideas make it? the problem web apps, need load page information network. guess useful make script retrieves information along time (i use perl that) , simple web interface display information given. the web interface used display information given script (service) but think there're lot of open source projects you're looking for...

google chrome extension - using promises in javascript -

var promise = new promise(function(resolve, reject) { //asynchronous part var dom_domain_name_encoded; chrome.tabs.query({ "active": true, "currentwindow": true, "status": "complete", "windowtype": "normal" }, function (tabs) { (tab in tabs) { dom_domain_name_encoded=tabs[tab].url; dom_domain_name_encoded = encodeuricomponent(dom_domain_name_encoded); console.log(dom_domain_name_encoded); // return dom_domain_name_encoded; } }); //asynchronous part ends here. if (dom_domain_name_encoded) { console.log("encoded , returning"); resolve(dom_domain_name_encoded); } else { console.log("error"); reject(error("it broke")); } });

How do I use Notepad++ Compare as the diff tool in git bash/command line? -

is there way change default diff tool in gitbash? this post seems suggest possible provided no command line examples. link: running notepad++ command line compare plugin showing compare result since official diff plugin notepad++ seems uph0/compare , possible setting be: $ git config --global --add diff.guitool nppdiff $ git config --global --add difftool.nppdiff.path "c:/program files/notepad++/plugins/compareplugin/compare.exe" $ git config --global --add difftool.nppdiff.trustexitcode false

javascript - doh of dojo is not working with sinon -

i have tried this solution, not works well. here example code link above: require([ "doh/runner", "http://sinonjs.org/releases/sinon-1.17.5.js" ], function(doh){ console.log(sinon); }); error message: $ node ../../dojo/dojo.js load=doh test=tests/test_sinon_spy.js error: enoent: no such file or directory, open 'http://sinonjs.org/releases/sinon-1.17.5.js' besides this, try require sinon.js directly. sinon-1.17.5.js have been moved directory doh same runner.js , , renamed sinon . (the directory ) require([ "doh/runner", "doh/sinon" ], function(doh, sinon){ console.log(sinon); }); there no error message, sinon undefined: $ node ../../dojo/dojo.js load=doh test=tests/test_sinon_spy.js undefined 0 'tests run in' 0 'groups' ------------------------------------------------------------ | test summary: ------------------------------------------------------------ 0 tests i

javascript - How to check this promise state, when programming a new promise? js -

i programming new promise, has many different conditions call reject() or resolve() related state, know promise state set first call reject() | resolve() . question is: there native (build-in) way promise state? following demonstrative-code: exports.addstatement = function (db, description, data) { return new promise(function (resolve, reject) { validator.validatestatement(description, data) .then(function (data) { //...... if(cnd1) resolve(res); if(cnd2) reject(err); //...... //how check if promise rejected or resolved yet? }) .catch(function (err) { reject(err); }) }) }; you cannot directly examine state of promise. that's not how work. can use .then() or .catch() on them callback notified. or, in specific case, can change way code structured remove anti-pattern of creating unnecessary outer promise , swit

python - Why does next() always display the same value? -

i practicing yield statement. have written following function in python 2.7: >>> def mygen(): ... = 0 ... j = 3 ... k in range(i, j): ... yield k ... >>> mygen().next() 0 >>> mygen().next() 0 >>> mygen().next() 0 whenever call mygen().next() displays output 0 , instead of 0 , 1 , 2 & stopiteration . can please explain this? you recreating generator each time, starts beginning each time. create generator once : gen = mygen() gen.next() gen.next() gen.next() generator functions produce new iterator every time call them; way can produce multiple independent copies. each independent iterator invocation of function can stepped through separately others: >>> def mygen(): ... = 0 ... j = 3 ... k in range(i, j): ... yield k ... >>> gen1 = mygen() >>> gen2 = mygen() >>> gen1.next() 0 >>> gen1.next() 1 >>> gen2.next() 0 >>> ge

xml - change xmlns value per element in xmlns -

i ask how xmlns attribute can added element on xsd. the output should similar this: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <asn> <itemcode id="itm0002212"> <serialno xmlns="1231123321231600000"> <msn/> <msisdn>123456789</msisdn> </serialno> <serialno xmlns="1231123321231700000"> <msn/> <msisdn>123456788</msisdn> </serialno> <serialno xmlns="1231123321231800000"> <msn/> <msisdn>123456787</msisdn> </serialno> <serialno xmlns="1231123321231900000"> <msn/> <msisdn>123456786</msisdn> </serialno> </itemcode> </asn> i tried use following xsd below application not

android - How to string to shared preference without an editText? -

can save strings sharedpreference without using edittext. using edit text format of putting string shared preference right? editor.putstring("username", etusername.gettext().tostring()); i want happen users id db saved on sharedpreference. editor.putstring("userid", *******); what should put there? thanks. don't know how it. and db users. mydb editor.putstring("userid", parameter); yes, in second parameter can save sting whatever want.

How to fix duplicate data when use Fragment and TabLayout in Android -

i want show website datas in 3 fragments json ! when swipe between tab s not duplicate datas. when click on tab s, duplicate previous data again! send data from asynctask fragments use eventbus component. fragment codes: public class free_fragment extends fragment { private recyclerview mrecyclerview; private free_recycler_adapter madapter; private recyclerview.layoutmanager mlayoutmanager; private list<datamodel> datamodels = new arraylist<datamodel>(); private context context; private boolean isdatafetched; private boolean misvisibletouser; private view view; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view = inflater.inflate(r.layout.fragment_free_layout, container, false); context = getcontext(); if (misvisibletouser) { loaddata(); } ///----- recyclerview -----