Posts

Showing posts from February, 2014

php - foreach loop accepts only the first index of array -

i made simple example in php, objective insert values of array database. field names array keys , field values array values. chose object-oriented style querying because i'm practising oop. when looped it, issue this: code accepts first index of array, "name"; supposed accept 4 values since table consists of 4 fields (name, email, username, password). result in database name field has value, rest of fields null. here code: <?php class user { public static function insert($table, $table_fields = array()) { if(count($table_fields)) { foreach($table_fields $field_name => $field_value) { return "insert $table ($field_name) values ('$field_value')"; } } return false; } } $connect = mysqli_connect('localhost', 'root', '', 'sample'); mysqli_query($connect, user::insert('users', array( 'name' => 'sample name',

android - Multiple device push -

i want implement push application should work on ios, android , in browser. do need implement 1 solution ios , android (fcm) , 1 browser (websockets)? or possible e.g. push websockets devices? fcm supports chrome client. don't want force users use chrome browser. websockets if using websockets push in android , ios, receive push if application open. means if establish connection successfully. fcm if client registration successful , have fcm registration id if app not in foreground receive push. so suggest use fcm android , ios.

Need to displaying number of videos displaying in Curosol using selenium -

Image
need displaying number of videos displaying in curosol using selenium. tried xpath : homepagenumberofplaylist_xpath = //div[@class='jcarousel']/descendant::ul/descendant::li driver.findelement(by.xpath("homepagenumberofplaylist_xpath")).getsize(); but getting error java.lang.illegalargumentexception: cannot find elements when xpath expression null. thanks in advance.

javascript - if page link is like test.html?a=1&b=2 then how load function will work getting value of a and load particular div? -

my html page is: test.php?a=1&b=2 send response post.php abc.php when response callback post.php , test.php. ( test.php -> post.php -> abc.php ) sending ( abc.php -> post.php -> test.php ) receiving test.php main page post.php , abc.php both jquery response page how load function work including $_get value in page? when use this: $("#div").load("test.php #div") result: load div data , not getting a , b value $.ajax({ method: "post", url: "abc.php", data: datastring }) .done(function( msg ) { $("#div").load("test.php?a="+xx+ "#div"); } in abc.php page have send a value in echo echo $xx; echo a value response data in session $("#div").load("test.php #div") getting session data cart items on particular div but when used this $("#div").load("test.php?a="+xx+ "#div"); result : load whole pag

function - Default Parameters for method in c# -

i have following method signature want give default value 1 of parameters dont want give default value other parameter leadsourcestatus protected promotioncatalogresponserootobject getvideopromotioncatalog(promotioncatalogtypes catalogtype = promotioncatalogtypes.residential, leadsourcestatus leadsourcestatus) but when try this, error optional parameters must appear after required parameters what best way deal this? the best way deal told do, , put optional param @ end: protected promotioncatalogresponserootobject getvideopromotioncatalog(leadsourcestatus leadsourcestatus, promotioncatalogtypes catalogtype = promotioncatalogtypes.residential)

python - Replacing nodal values in a mesh with >1e6 inputs selectively using a polygon -

Image
i have set of data represents set of nodes, each node associated value (represented color in image). want achieve selectively changing values. the mesh represents porous system (say rock example) model. pressure in system specified @ nodes. input contains pressure attributed each node want able re-assign initial conditions pressure @ specific nodes (the ones located inside polygon). weights of nodes pressure @ node. i want define polygon, , attribute value each vertex (think of weight), , using weight of vertex , distance vertices each node inside polygon correct value node. this output like: i working on algorithm takes in set of values of form [x,y,z] , [value,value,value,value]. both have same number of rows. e.i, rows in first input location of node, , rows in second values associated node. i made algorithm takes in set of points forming polygon , set of weights corresponding each vertex of polygon. i scan merged inputs , replace value of node found inside polygon

java - SpringBoot get environment variables for @Configuration class -

i'm struggling following problem: in springboot project want initialize datasource myself. inside method want work environment variables read yml file. @configuration public class datasourceconfig { @bean public jdbcdatasource createmaindatasource() { // init datasource , read environment variables } } application.yml: spring: datasource: url: jdbc:mysql://localhost:3306/xxx driverclassname: com.mysql.jdbc.driver then defined class @configuration obtain environment variables. @configuration @configurationproperties(prefix="spring.datasource") public class propertiesconfig { private string url; private string driverclassname; } but have problem class datasourceconfig being initialized before propertiesconfig leading problem can't use environment variables. can of me that? to create datasource need propertiesconfig , inject bean: @configuration public class datasourceconfig { @autowired pri

ios - UINavigationBar translucent removes the image which added on navigation bar -

Image
earlier want scroll uiview below navigation bar , so, set self.navigationcontroller.navigationbar.translucent = no; after setting translucent no the background navigationimage missing. white in colour. no idea went wrong here. please find below image navigation bar . [self.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed:@"bg.png"] forbarmetrics:uibarmetricscompact]; self.navigationcontroller.navigationbar.translucent = no; your feedback appreciated! use uibarmetricsdefault instead of uibarmetricscompact [self.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed:@"bg.png"] forbarmetrics: uibarmetricsdefault]; self.navigationcontroller.navigationbar.translucent = no;

magento2 - Adding custom Image attribute for category in magento 2 -

i have tried below code adding thumbnail image in category. when upload image in custom field below error. error attention the file not uploaded. error: "the file not uploaded." errorcode: 666 category_form.xml <field name="thumbnail_image"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="datatype" xsi:type="string">string</item> <item name="source" xsi:type="string">category</item> <item name="label" xsi:type="string" translate="true">category image</item> <item name="visible" xsi:type="boolean">true</item> <item name="formelement" xsi:type="string">f

android - fetch distinct and unique contacts from the phone avoiding duplicity -

i want retrieve contact list phone avoiding duplicates. think retrieving contacts google account,phone or sim. how avoid duplicate contacts. though contact can have same number different numbers. same name , same number should not appear in list. code. contentresolver cr = getcontentresolver(); final string[] projection = new string[] { contactscontract.commondatakinds.phone.contact_id, contactscontract.contacts.display_name, contactscontract.commondatakinds.phone.number }; string selection = contactscontract.contacts.in_visible_group + " = '" + ("1") + "'"; //string selection = contactscontract.contacts.has_phone_number; cursor cur = cr.query(contactscontract.commondatakinds.phone.content_uri, projection, selection + " , " + contactscontract.contacts.has_phone_number + "=1", null, contac

reactjs - how to reduce redux boilerplate -

i'm new redux , find every little thing x turns x_success , x_failure, when fetching data or trying create new entity, , means more action creators, , more handling in reducers. what's recommended approach here? thanks. recommended approach x_success, x_failure etc. async operations only. let's see why : async operations in spa operations want know when operation started, when got response back type of response , success or failure so have seperate actions creator functions return objects , 1 async action creator function can return function instead of object , calls other action creators body. for reasons above should have seperate action creators, 1 async action creator , of course every action creator should have constant in reducer. assuming writing constants, actions , reducers in seperate folders, can nightmare. if case, should take @ here duck modular redux . duck modular redux should definetely implement reduce boilerplate. other thin

javascript - Unable to stop the downloading a file when the array is empty using ng-csv -

i have scenario want export array of json data csv file checking condition array empty or not. if array not empty getting file data. if empty want prevent downloading of file.i unable stop downloading of file.i using angular 1.5 components , angular material. html: <md-menu-item> <md-button ng-csv="$ctrl.csvprocess()" csv-header="["firstname","lastname","phonenumber","email"]" filename="details.csv">export selected</md-button> </md-menu-item> controller: csvprocess() { if (this.memberselrows.length === 0) { this.toastservice.show('please select member(s) export.', { theme: 'warn' }); } else { var csvobject = {}; var csvarray = []; angular.foreach(this.memberselrows, function(value, key) { csvobject = {}; csvobject.firstname = value.firstname csvobject.lastname =

c# - Xamarin forms how to pass Entry value from one to class to another class List? -

i want pass inserted number value page inserting value page list , update listview new value. here addcardpage xaml: <entry x:name="cardnr" text="" completed="entry_completed" keyboard="numeric" /> here addcardpage xaml.cs method: void entry_completed(object sender, eventargs e) { var text = ((entry)sender).text; //cast sender access properties of entry new cards { number = convert.toint64(text) }; } here cardspage class declared data: public cardspage() { initializecomponent(); base.title = "cards"; list<cards> cardslist = new list<cards>() { new cards { number=1234567891234567, name="dsffds m", expdate="17/08", security=123 }, new cards { number=9934567813535135, name="jason t", expdate="16/08", security=132 }, new cards { number=4468468484864567, name="carl s", expdate="17/01", security=987 },

Hash and salt passwords in C# -

i going through 1 of davidhayden's articles on hashing user passwords . really can't trying achieve. here code: private static string createsalt(int size) { //generate cryptographic random number. rngcryptoserviceprovider rng = new rngcryptoserviceprovider(); byte[] buff = new byte[size]; rng.getbytes(buff); // return base64 string representation of random number. return convert.tobase64string(buff); } private static string createpasswordhash(string pwd, string salt) { string saltandpwd = string.concat(pwd, salt); string hashedpwd = formsauthentication.hashpasswordforstoringinconfigfile( saltandpwd, "sha1"); return hashedpwd; } is there other c# method hashing passwords , adding salt it? actually kind of strange, string conversions - membership provider put them config files. hashes , salts binary blobs, don't need convert them strings unless want put them text files. in book, beginning a

html - bbpress forum functionality -

i began using bbpress on website, have been far unsuccessful in implementing or finding answer of things need forum do. if possible, easiest ways of implementing following: limiting length of replies on forum minimum , maximum word/character amount. limiting user on forum have x replies per thread. limiting length of thread x amount of replies. thanks.

javascript - Set environment variable in ubuntu for ionic -

Image
hi have tried hard solve not able success. please me i trying build ionic android application . @ screen shot i have ionic, cordova,node , working android command my problem is, i not able save $android_home environment variable in ubuntu 15.10 . i follow these steps shown below in screen i not able understand happening on here try in console type these (remember change current location) export android_home=/home/dquintana/android/sdk export path=$path:/home/dquintana/android/sdk/tools if want make permanent add lines in ~/.bashrc file

go - Golang idomatic nested error handling -

i have gotten go , have seen lot of discussion how error handling. the pattern have seen laid out following: err := dosomething() if err != nil { //handle } // continue often times when managing amqp connections, condition want continue if error nil, because need on connection: c, err := connect() if err != nil { return nil, err } s,err := c.registersomethingonconnection() if err != nil { return nil, err } val, err := s.dosomething() return val, err as can see want run line c.registersomethingonconnection if error returned connect() nil. however, dislike above due returns. returns make me uncomfortable because in long run hurts readability , obscures when function exits. solution far has been following: var err error var val returntype c,err := connect() if err == nil { s,err := c.registersomethingonconnection() if err == nil { val,err = s.dosomething() } } return val,err i 2 reasons. first, prevents returning nil. second, find mak

php - Dompdf footer not set..? -

here using dompdf generating pdf header,body,footer. when try add footer ,it's not attaching. it come body code, want set footer @ bottom. can figure-out wrong below code ? code : global $_dompdf_show_warnings; global $_dompdf_debug; global $_dompdf_debug_types; global $_dompdf_warnings; $_dompdf_show_warnings = false; require_once(realpath(apppath."third_party/dompdf")."/dompdf_config.inc.php"); spl_autoload_register('dompdf_autoload'); $dompdf = new dompdf(); $dompdf->set_paper("letter", "portrait"); $html = '<html> <head> <title> </title> </head> `enter code here` <body style="margin:0; background-color:#ff9900; color:#ffffff;"> <div> <div style="margin:15px;">

Capture Screenshots at Defined Time Intervals Automatically using asp.net c# web forms -

i have 1 online test website, , want capture screenshot @ defined time intervals, automatically, using asp.net c# web forms. need other related sample code. i had tried 1 way. getting url, using capture html response http request. want store html image in database table. i'm not getting ideas regarding this. below c# code. using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.net; using system.text; public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { getimage(); } public void getimage() { webclient myclient = new webclient(); string mypagehtml = null; byte[] requesthtml; // gets url of page string currentpageurl = request.url.tostring(); utf8encoding utf8 = new utf8encoding(); // setting currentpageurl mypage.aspx fetch source (html) // of mypage.aspx , put in mypagehtml varia

javascript - Syntax Error - Map multidimensional array in React-Redux -

i've been scratching head hours trying figure out why syntax error when trying iterate multidimensional array : const inputpanel = react.createclass({ render() { const { board } = this.props; return( <br /> {board.map(rows => { rows.map(cell => <div classname="digit">1</div>); }) } ); } }); codepen: http://codepen.io/anon/pen/vxgmrr i tried add\modify parenthesis types , nothing helps. here view i'm trying produce: </br> <div classname="digit">1</div> <div classname="digit">1</div> <div classname="digit">1</div> </br> <div classname="digit">1</div> <div classname="digit">1</div> <div classname="digit">1</div> </br> <div classname="digit">1</div> <div classname="digit">1</div> <div cla

c# - Microsoft.Jet.OLEDB.4.0 not retrieving delete marked records from DBF -

i using following code retrieve data dbf file... dbfconnectionstring = "provider=microsoft.jet.oledb.4.0;extended properties=\"dbase iv\";data source=" + apppath + "test\\sales\\" + datetime.now.tostring("yyyymm") + "\\"; oledbconnection odconnection = new oledbconnection(dbfconnectionstring); odconnection.open(); oledbcommand ocmdtest = new oledbcommand("select * payment", odconnection); ocmdtest.executenonquery(); oledbdataadapter = new oledbdataadapter(ocmdtest); oledbdataadapter.fill(dataset); datatable = dataset.tables[0]; this works fine except not retrieving records marked deleted. able retrieve deleted records vfpoledb.1 provider , executing additional code ( foxpro excellent gives me issues regarding field formats :- error reading numeric values vfpoledb driver , can fixed casting these fields problem tables big have figure out , cast many fields ) oledbcommand ocmdtest1 = new oledbcommand("set

dictionary - Python multiprocessing pool with shared data -

i'm attempting speed multivariate fixed-point iteration algorithm using multiprocessing however, i'm running issues dealing shared data. solution vector named dictionary rather vector of numbers. each element of vector computed using different formula. @ high level, have algorithm this: current_estimate = previous_estimate while true: state in all_states: current_estimate[state] = state.getvalue(previous_estimate) if norm(current_estimate, previous_estimate) < tolerance: break else: previous_estimate, current_estimate = current_estimate, previous_estimate i'm trying parallelize for-loop part multiprocessing. previous_estimate variable read-only , each process needs write 1 element of current_estimate . current attempt @ rewriting for-loop follows: # class , function definitions class a(object): def __init__(self,val): self.val = val # representative getvalue function def getvalue(self, est): return est[self] + self.val

meteor - Collapsible Tables in Bootstrap 4 -

so i'm using bootstrap 4 , meteor , trying create table collapses when click on row element. i'm having problem collapsing row resizing down size of first <td> element if i'm using colspan="3" . here's html: <table class="table"> <thead class="thead-inverse"> <tr> <th>school</th> <th>tech</th> <th>date</th> </tr> </thead> {{#each school}} <tbody> <tr class="school-row"> <td scope="row">{{trimstring name}}</td> <td>{{trimstring tech}}</td> <td>{{formatdate createdat}}</td> </tr> <tr class="room-collapse"> <td scope="row" colspan="3" data-parent=".room-collapse"> <p>hello test.</p> </td> </tr> </tbody> {{/each}} </tabl

javascript - dns caching in request module - node.js -

in project big amount of request same url using 'request' module. reason lot of request go dns server in order resolve url address instead of having sort of caching this. there kind of built-in mechanism in 'request' module resolve this? or other solution? thanks! this question little old may have found answer, had problem , used dnscache module handle it. had high amount of io (node reading /etc/resolv.conf ), , module seemed handle problem. couldn't find in request's or node's source handle problem, did find this related issue .

command line - Batch File Adding Space to Variable -

@echo off cls rem start backup title backup setlocal enabledelayedexpansion rem capture date/time(right down second) , assign variable set yy=%date:~-4% set dd=%date:~-7,2% set mm=%date:~-10,2% set newdate=%dd%%mm%%yy%_%time:~0,8% set newdate=%newdate::=% set foldername=svetlana_backup_%newdate% rem variables set drive=r: set sevenzip=%userprofile%\7z.exe set destination=r:\backup echo running backup batch file echo please plug in %drive% pause echo %foldername% mkdir %destination%\%foldername% /f "tokens=1,2 delims=," %%i in (backuplist.txt) ( set completesource=%%i set completedestination=%destination%\%foldername%\%%j echo source: "!completesource:"=!" echo destination:"!completedestination:"=!" mkdir "!completedestination:"=!" xcopy "!completesource:"=!" "!completedestination:"=!" /e /f ) rem zip folder using 7z command line utility %sevenzip% -tzip %desti

android - onMessageReceived() is not called when app is in foreground -

i using following code receive fcm message sent through firebase console, fucntion never called. instead able receive message in launcher class when app in background, when app in foreground , not able it. public class myfirebasemessagingservice extends firebasemessagingservice { private static final string tag = "myfirebasemsgservice"; string message=""; map<string, string> m1; @override public void onmessagereceived(remotemessage remotemessage) { //displaying data in log //it optional log.d(tag, "from: " + remotemessage.getfrom()); log.d(tag, "notification message body: " + remotemessage.getnotification().getbody()); system.out.println("---------------------"); message = remotemessage.getnotification().gettitle(); m1= remotemessage.getdata(); system.out.println("=============="+m1); system.out.println("=============="+m1.get("url")); //calling method

jsf - Dynamic <ui:include src> depending on <ui:repeat var> doesn't include anything -

i new jsf , struggling dynamicaly rendering included pages. code looks this: menubean @viewscoped public class menubean implements serializable { private menuitem[] menuitems = new menuitem[] { new menuitem("page_1", "/page_1.xhtml"), new menuitem("page_2", "/page_2.xhtml"), }; private string selecteditemlabel; //... } menuitem public class menuitem implements serializable { private string label; private string page; //... } index.xhtml <ui:repeat var="menuitem" value="#{menubean.menuitems}"> <h:panelgroup rendered="#{menubean.selecteditemlabel eq menuitem.label}" layout="block"> <h:outputtext value="#{menubean.selecteditemlabel}" /> <ui:include src="#{menuitem.page}" />

java - Spring websocket STOMP Unsubscribe from eventHandler -

i have spring websocket stomp application accepts subscribe requests. in application have handler subscribe, is, @component public class subscribestompeventhandler implements applicationlistener<sessionsubscribeevent> { @override public void onapplicationevent(sessionsubscribeevent event) {} } that use validate subscription. in case if subscription invalid, instance, current user can not see subscription, broker (i use simplemessagingbroker) "forget" subscription, or preferably, not register @ all. my questions are: can make broker not register subscription, if move handling of subscription request incoming message interceptor , stop message propagation? what else used event handler cancel subscription? you need create channelinterceptor implementation. extend channelinterceptoradapter , override presend(message<?> message, messagechannel channel) . here access headers session information validation. need registrate interc

jquery - how to give space in navbar-Bootstrap -

Image
i trying give space menu, shows me not exact result shown in original template. <nav class="navbar navbar-default"> <div class="container-fluid"> <!-- <div class="navbar-header"> <a class="navbar-brand simple_color" href="#">simplex</a> </div> --> <ul class="nav navbar-nav navbar-right w"> <li class="active comenu"><a href="#">home</a></li> <li><a href="#">about</a></li> <li><a href="#">services</a></li> <li><a href="#">client</a></li> <li><a href="#">contacts</a></li> </ul> </div> </nav> want make menu same shown in original template. can me? just replace navbar-nav class nav-justified . check out bootstrap

c# - Which is the proper way for async method returns task? -

i confused following methods. 1 best , why? these working fine. public string getstring(int i) { return "testing number " + i.tostring(); } //async methods i'm confused public task<string> getstringasync(int i) { return task.fromresult<string>(getstring(i)); } //or public task<string> getstringasync(int i) { task<string> task = new task<string>(() => getstring(i)); task.start(); return task; } //or public task<string> getstringasync(int i) { var tcs = new taskcompletionsource<string>(); tcs.setresult(getstring(i)); return tcs.task; } the caller be task<string> task = someclass.getstringasync(9); console.writeline(task.result); //or var result = await someclass.getstringasync(9); console.writeline(result); thank much. i think may not understand why want use async. async .net allows freeing of threads waiting on external action take place (network call or hard disk cal

Rails 4.2 Time_zone_conversion.rb Error. How do I fix this? -

i totally lost on one. i'm using ruby 2.2.4 , upgrading app rails 4.1.0 4.2. app working fine. changed gemfile use: gem 'rails', '~>4.2' then ran spec tests , app blew error: usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -i/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.5.0/lib:/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-support-3.5.0/lib /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.5.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb coverage report generated rspec /path-to-my-app/coverage. 22 / 1206 loc (1.82%) covered. /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/time_zone_conversion.rb:64:in `create_time_zone_conversion_attribute?': undefined method `type' "number(38)":string (nomethoderror) /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/time_zone_conversion.rb:53:in `block (2 level

MongoDB avoid duplicates using $addToSet in aggregation pipeline -

there aggregation pipeline: db.getcollection('yourcollection').aggregate( { $unwind: { path: "$dates", includearrayindex: "idx" } }, { $project: { _id: 0, dates: 1, numbers: { $arrayelemat: ["$numbers", "$idx"] }, goals: { $arrayelemat: ["$goals", "$idx"] }, durations: { $arrayelemat: ["$durations", "$idx"] } } } ) which perform on following data (sample documents): { "_id" : objectid("52d017d4b60fb046cdaf4851"), "dates" : [ 1399518702000, 1399126333000, 1399209192000, 1399027545000 ], "dress_number" : "4", "name" : "j. evans", "numbers" : [ "5982", "5983", "5984",

angular - Is it possible to get native element for formControl? -

i've got angular2 reactive form . created formcontrol s , assigned input fields by [formcontrol]=... . understand creates nativeelement <-> formcontrol link. my question: possible nativeelement formcontrol ? wanna myformcontrol.nativeelement.focus() i can share 1 terrible solution works me. in reactive forms can use either 1) formcontroldirective ts mycontrol = new formcontrol('') template <input type="text" [formcontrol]="mycontrol"> or 2) formcontrolname ts myform: formgroup; constructor(private fb: formbuilder) {} ngoninit() { this.myform = this.fb.group({ foo: '' }); } template <form [formgroup]="myform"> <input type="text" formcontrolname="foo"> </form> so these directives write patch like 1) formcontroldirective const originformcontrolngonchanges = formcontroldirective.prototype.ngonchanges; formcontroldirective.proto

vue.js - vue routing with extra? -

i have wired problem: i using vue-route, login link is: http://localhost/#!/login i have <form> login: <button @click="submit()">login</button> the submit button call login function, use vue-resource make api call, stop @ $http.post below: context.$http.post(login_url, creds).then(function (res) { it direct : http://localhost/?#!/login <- ? this happen once when login loaded, sub sequence work correctly. if take out the form, problem go away: <form class="form"> is possible you're not preventing default action of button? buttons, when defined in context of form, are automatically assumed submit buttons . you can fix adding type="button" button: <button type="button" @click="submit()">login</button>

php - socket_write(): unable to write to socket [10053] -

i'm using whatsapp api laravel 5.2 https://github.com/mgp25/chat-api and got error when trying send new message socket_write(): unable write socket [10053]: established connection aborted software in host machine. send controller $massage = "thanks subscribe"; whatsapi::send($massage, function ($send) { $user = user::find(1); $send->to($user->phone); }

c# - Right Shift And Left Shift Operator in SQL Server -

in sql server, shift operators not present per knowledge. if have achieve right shift , left shift, efficient way of doing it? with mathematical expressions give me same output shift operator must have given. or will call clr function calculate right shift , left shift because shift operators available in c# give me output expecting. please suggest 1 more efficient way of doing it.

c++ - Prevent duplicate objects in classes/instance access with singleton -

the use provide .instance access, prevent duplicate objects of classes. is code implementation of singleton? template <typename t> class singleton { public: static t *ms_singleton; singleton() { assert(!ms_singleton); long offset = (long)(t *) 1 - (long)(singleton <t> *)(t *) 1; ms_singleton = (t *)((long) + offset); } virtual ~singleton() { assert(ms_singleton); ms_singleton = 0; } static t &instance() { assert(ms_singleton); return (*ms_singleton); } static t &instance() { assert(ms_singleton); return (*ms_singleton); } static t *instance_ptr() { return (ms_singleton); } }; template <typename t> t *singleton <t>::ms_singleton = null; how use it: class test1: public singleton<test2> { // }; if not, wrong here? should rewrite here? your singleton class has weird things. relyi

java - Selenium IEDriver dosen't work on VPN -

my selenium script work on both driver chromedriver , iedriver when i'm not connected vpn. but when try run same script while i'm connected vpn it works chromedriver only , iedriver browser open , maximized , url , after scenarios skipped below error. org.openqa.selenium.nosuchwindowexception: unable browser (warning: server did not provide stacktrace information) command duration or timeout: 17 milliseconds note : while debugging noticed that, after geturl() once browser window opened, tried getcurrenturl() , got following result. ie gives initialbrowserurl instad of actual url . iedriver logs: [testng]started internetexplorerdriver server (32-bit) [testng] 2.53.1.0 [testng] listening on port 28196 [testng] local connections allowed [testng] actual url url : mydomain.com/xyzapplication/ [testng] getcurrenturl (driver.getcurrenturl): localhost:28196/ chromedriver logs: [testng] starting chromedriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd0512

node.js - How do you display mongoose data in a pug template -

i exploring pug templates , have exporess/mongodb/mongoose backend. the router index page meant display 'testimonials' , have following 'route': const testimonial = require('../models/testimonial'); exports.index = (req, res) => { testimonial.find((err, testimonials) => { if (err) { console.log("error: " + err); } else { res.render('home2', { title: 'website', testimonials: testimonials, }); } }); }; if add 'console.log' statement before render return testimonials in collection, data side works. the index page includes 'partial' pug template testimonials following: .nk-box.bg-gray-4 .nk-gap-4 .row .nk-carousel-2(data-autoplay='12000', data-dots='true') .nk-carousel-inner each testimonial in testimonials div div blockquote.nk-testimonial-3 .nk-testimonial-photo(sty

react router - How do I access action and history from BrowserRouter in Matched route (v4)? -

Image
i'm using react router v4 , using browserrouter. this screenshot here shows browserrouter's props have action="pop" . however, when route matched in screenshot above, registermatch or matchprovider not receiving action, history, etc. via props. i see via https://github.com/reacttraining/react-router/blob/v4/website/components/fakebrowser/index.js#l96 there might need injection of these props, i'm not able make sense of or make work. using <router /> history prop or <browserrouter /> basename prop solves this. e.g. <router history={history}> <browserrouter> ignores history prop. use custom history, ' + 'use import { router } instead of import { browserrouter router } .

sql - How do I join tables while preserving the exact information on one table? -

i want join 2 tables matching time in 1 table period (a start , end time) on second, , need operation preserves exact information on 1 table. more specifically, have these tables. table t1: cid time1 2016-01-05 11:00:00 2016-01-15 11:00:00 2016-01-25 11:00:00 b 2016-01-09 11:00:00 table t2: cid period_start period_end 2016-01-01 00:00:00 2016-01-10 00:00:00 2016-01-10 00:00:00 2016-01-16 00:00:00 2016-01-12 00:00:00 2016-01-20 00:00:00 and want output as: cid time1 period_start period_end 2016-01-05 11:00:00 2016-01-01 00:00:00 2016-01-10 00:00:00 2016-01-15 11:00:00 2016-01-10 00:00:00 2016-01-16 00:00:00 2016-01-25 11:00:00 null null b 2016-01-09 11:00:00 null null a few additional information/conditions: i want information on t1 preserved in output (e.g., no rows on t1 joined multiple rows on t2, no rows t1 missing in output). i