Posts

Showing posts from September, 2012

c++ - template member of std::pair<> must have const copy constructor. How to implement that constraint -

c++11 standard require template member of std::pair<> must have const copy constructor. otherwise, not compile.(from book the c++ standard library , nicolai m. josuttis.). so, code below wouldn't compile if it's against c++11 standard: class a{ int i; public: a(){} a(a&){} }; int main(){ pair<int, a> p; } with -std=c++11 , g++ compiler report error: constexpr std::pair<_t1, _t2>::pair(const std::pair<_t1, _t2>&) [with _t1 = int; _t2 = a]' declared take const reference, implicit declaration take non-const: constexpr pair(const pair&) = default that because declare a's copy constructor non-const. if change a(a&){} a(const a&){} , or remove -std=c++11 flag, fine. my question is, how constaint implemented? can see no support in language provide inside template parameter t . mean, declared this: template<typename t1, typename t2> class pair{ ... //how

eclipse - Adding Files to the Root of a elipse e4 rcp application -

in order add configuration files eclipse e4 rcp application, have followed steps greg-449 in link : the application featured based, , in feature project folder have attached file "test_config_file.txt" at feature´s 'build.properties' file next lines: bin.includes = feature.xml root=file:test_config_file.txt basically stated @ above link. when run product (via run configuration), file not copied folder run configuration locates product. thanks much the configuration in feature used when build / export product. when running code using run configuration have put files in correct location manually. alternatively code support command line argument specify location of file.

How to clear the form after submitting in model-driven form? (Angular 2) -

how can clear form after submitting in model-driven form? have use ngmodel ? thanks <form [ngformmodel]="myform" (ngsubmit)="onsubmit()"> <input type="text" [ngformcontrol]="name"> <button type="submit">submit</button> </form> . myform: controlgroup; name: abstractcontrol; ngoninit() { this.myform = this._formbuilder.group({ 'name': [""] }); this.name = this.myform.controls['name']; } onsubmit() { this.name.value = ""; // not working. } you can iterate controls in this.myform.controls , call updatevalue() . otherwise see https://github.com/angular/angular/issues/4933

c# - How to get Appium working on a Mac for mobile web automation using Simulators -

i long time windows user have been tasked figuring out mobile automation on mac company. i using windows visual studio , c# write automation scripts. able run locally against chrome, firefox, ie, & android web applications using selenium. attempting run on macbook pro received run selenium tests against safari on ios simulators. first time using mac i'm not @ familiar how things work on platform. once mobile web figured out need looking native apps well. my setup on mac is: os x el capitan version 10.11.3 macbook pro (retina, 15-inch) 2.5ghz intel core i7, 16gb ddr3 amd radeon r9 m370x 2048mb xcode 7.2.1 (7c1002) apple developer license (with available simulators downloaded) appium 1.4.13 (draco) installed dmg downloaded appium.io. when run appium doctor following: last login: mon feb 22 14:34:40 on ttys000 '/applications/appium.app/contents/resources/node/bin/node' '/applications/appium.app/contents/resources/node_modules/appium/bin/appium-do

java - Configuration mechanism to flag the attributes of an object that should be synchronized -

i'm refactoring old java application. has component responsible synchronizing complex object object of same type different source. object has lot of attributes (nearly hundred) of different types, including class types, in turn have lot of attributes. i want have feature tell component attributes of object should synchronized or not. first idea dependency injection. should inject? don't want have interface methods public boolean shouldsynchronizeattributea() , public boolean shouldsynchronizeattributeb() etc. every attribute including attributes of compositions of objects. how solve issue in nice , maintainable way? here example using strings , mvel . there many other libraries available (e.g, ognl). use orika (i not familiar with. used dozer many years ago) public static void main(string[] args) { final someclass o1 = new someclass(); o1.setaddress(new address("paris")); final someclass o2 = new someclass(); o2.setaddress(new addres

Sorting the C# List with Date(11 Sep 2015 --> Date format) in Descending Order? -

indexlist = savelist .where(i => (convert.todatetime(i.event_startdate) < datetime.today) && (convert.todatetime(i.event_enddate) < datetime.today)) .tolist(); event_list.itemssource = indexlist.orderby(i => i.event_startdate); i wrote code above sort list contains date in format(11 sep 2015), want sort in way that, should display recent date date on top of list. how modify above statement i have tried using orderbydescending(i=>i.event_startdate); no use. you need parse date to datetime object in order sort it, things easy: var results = (from item in savelist let dtstart = convert.todatetime(item.event_startdate) let dtend = convert.todatetime(item.event_enddate) dtstart.date < datetime.today && dtend.date < datetime.today orderby dtstart descending select item).tolist(); event_list.itemssource = results;

javascript - state could not be resolved in angularjs -

i using nested view ui-router. menu html <li ng-class="{active: $state.includes('staffs')}"> <a ui-sref="dashboard"><i class="fa fa-users"></i> <span class="nav-label">{{ 'staffs' | translate }}</span> <span class="fa arrow"></span></a> <ul class="nav nav-second-level collapse" ng-class="{in: $state.includes('staffs')}"> <li ui-sref-active="active"><a ui-sref="staffs.add"><i class="fa fa-circle-o"></i>{{ 'addstaff' | translate }}</a></li> <li ui-sref-active="active"><a ui-sref="staffs.view"><i class="fa fa-circle-o"></i>{{ 'viewstaffs' | translate }}</a></li> <li ui-sref-active="activ

gradle - duplicate entry: com/google/android/gms/internal/zzaa.class after adding facebook sdk -

Image
am getting error when trying generate release apk, after added facebook audience network sdk. full error: execution failed task ':app:transformclasseswithjarmergingforrelease'. > com.android.build.api.transform.transformexception: java.util.zip.zipexception: duplicate entry: com/google/android/gms/internal/zzaa.class here's gradle file: buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'io.fabric.tools:gradle:1.+' } } apply plugin: 'com.android.application' apply plugin: 'io.fabric' android { compilesdkversion 24 buildtoolsversion "23.0.2" defaultconfig { applicationid "com.coolcrazyapps.myapp" minsdkversion 15 targetsdkversion 21 versioncode 10 versionname "2.0" multidexenabled true } buildtypes { release { minifyenabled f

jpa - How does Hibernate hbm2ddl automatically create table? -

i reading example of java ee (jboss) application, , learning basics of hibernate in java ee. under src/main/resources/meta-inf/persistence.xml: <jta-data-source>java:jboss/datasources/memberds</jta-data-source> <properties> <!-- properties hibernate --> <property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.show_sql" value="false" /> </properties> </persistence-unit> under src/main/resources/import.sql: insert member (id, name, email, password, phone_number) values (0, 'john smith', 'john.smith@mailinator.com', 'password', '2125551212') under model package, has member class. my questions: how application automatically create table member in database? where schema information? why , how 'import.sql' atomically executed once application running? the answer

Does converting the symbol '&' to '&amp;' in XML file affect the google search? -

i have generated xml sitemap, submit google search engine. while testing xml file in notepad++ , notepad looks perfect. while testing browsers google, ie, firefox, , edge either shows error or not display properly. in chrome found problem due & symbol. so, replaced & symbols &amp; . browsers displayed properly. but, converted urls using &amp; not works. does changing & &amp; affects sitemap, has submitted google search engine? for example, <?xml version="1.0" encoding="utf-8"?> <sitemapindex xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"> <sitemap> <loc>http://www.example.com/about.php?course=physics&code=ptxui</loc&

javascript - Ignoring required's on an entire form using jQuery.Validate() -

i'm trying ignore required validation on entire form using jquery validate can't seem working, on mvc project using @html helper can't add names elements validate, cant remove validation add using jquery since not fields required, i'll put current java below , appreciated $("body").on("click", ".next", function(e) { e.preventdefault(); var btn = $(this); var form = btn.closest("form"); form.validate({ rules: { required: false } }); //check if form valid if (form.valid()) { var out = form.validate({ rules: { required: true } }); if (form.valid()) { alert("valid , complete"); } else { alert("valid not complete"); } } else { showsysmessage("invalid data. please check data in highlighted fields", { color: "#ffb347" }); }; }); edit this validator needs va

c# - List all containers and blobs -

i working on azure local development storage containers , blobs. want able display containers , blobs in listbox treeview of local development storage. code: public list<string> listcontainer() { list<string> blobs = new list<string>(); // retrieve storage account connection string. cloudstorageaccount storageaccount = cloudstorageaccount.parse( cloudconfigurationmanager.getsetting("azurestorageconnectionstring")); // create blob client. cloudblobclient blobclient = storageaccount.createcloudblobclient(); //get list of blob above container ienumerable<cloudblobcontainer> containers = blobclient.listcontainers(); foreach (cloudblobcontainer item in containers) { blobs.add(string.format("{0}", item.uri.segments[2])); } return blobs; } here displaying containers. need display blobs each container has, subfolders.

javascript - URL Query Parameters -

i'm facing problem. i'm using node , express. index.html contains 2 inputs. <form action="/profile" method="get"> <input id="variable1" name="variable1" type="text" placeholder="..."> //xxx select : <select id="variable2" name="variable2"> <optgroup label="y"> <option value="variable">yyy</option> </select> in profile.js got: router.get('/profile', function(req, res){ var var1 = req.params.variable1; var var2 = req.params.variable2; res.render('result'); } node renders result.html , url is https://localhost:3030/profile?variable1=xxx&variable2=yyy the question how https://localhost:3030/profile/xxx/yyy instead of url above? define route as: /profile/:var1/:var2 now access them using req.params: var var1 = req.params.var1; var var2 = req.params.var2;

c# - String was not recognized as a valid DateTime on one PC -

language: c#, .net framework: 4.5, method used: datetime.parseexact so in 1 of our projects we're using following function parse string datetime: private datetime formatdate(string date, string format) { try { iformatprovider culture = new cultureinfo("en-us", true); datetime dt = datetime.parseexact(date, format, culture); return dt; } catch (exception ex) { throw new exception(ex.message); } } and calling this: datetime startdate = formatdate("01/17/2016", "m/d/yyyy"); on our 3 pcs, code works when date format on each pc dd/mm/yyyy, on 2 of pcs, when date format dd-mmm-yy produces bug when trying execute parseexact: string not recognized valid datetime. while keeps working on third pc when using dd-mmm-yy format. compared date , time settings on 3 pcs, settings equal, 1 difference on 2 pcs use visual studio 2013 while on third visual studio 2015. exception details: m

apache - How to add custom information into Zip archive for every ZipArchiveEntry in Java (getComment is always null) -

using: java, apache commons compress (1.10) ( org.apache.commons.compress.archivers.zip.ziparchiveoutputstream ) ( org.apache.commons.compress.archivers.zip.ziparchiveentry ) is there way, how add custom information (byte[] or string) zip archive entry? i tried use following methods: entry.setextra(byte[] extra); entry.setextrafields(zipextrafield[] fields); entry.setcomment(string comment); but seems setextra limited 2 bytes , setextrafields takes zip standarized fields, not custom parameter. the promissing setcomment null (decompression), no matter if , set (compression). compression example (using setcomment ): ziparchiveoutputstream zaos = new ziparchiveoutputstream(fos); ziparchiveentry entry = new ziparchiveentry(file.getname()); entry.setcomment("test"); zaos.putarchiveentry(entry); // write data zaos.closearchiveentry(); zaos.finish(); on decompression entry.getcomment() null .

python - Sort list of lists that each contain a dictionary -

i have list: list_users= [[{'points': 9, 'values': 1, 'division': 1, 'user_id': 3}], [{'points': 3, 'values': 0, 'division': 1, 'user_id': 1}], [{'points': 2, 'values': 0, 'division': 1, 'user_id': 4}], [{'points': 9, 'values': 0, 'division': 1, 'user_id': 11}], [{'points': 3, 'values': 0, 'division': 1, 'user_id': 10}], [{'points': 100, 'values': 4, 'division': 1, 'user_id': 2}], [{'points': 77, 'values': 2, 'division': 1, 'user_id': 5}], [{'points': 88, 'values': 3, 'division': 1, 'user_id': 6}], [{'points': 66, 'values': 1, 'division': 1, 'user_id': 7}], [{'points': 2, 'values': 0, 'division': 1, 'user_id': 8}]] i need sort list points , values. how can sort

spring - @Component vs new operator in java -

i new spring concept, have little confusion @component default singleton creates instance whenever class loaded , same instance reused; same happens new operator. if class declared singleton can change properties of class using setters , getters same new operator also. when call new , creating instance during runtime manually. assume , have controller being called 'n' number of times im turn calls service. java in plain java, creating new object calling new . means , creating 'n'number of objects spring in spring, when deploy application in server or load spring xml/configuration class , spring creates instances of classes annotated , , stores in spring container. now,even if controller called 'n'times, spring use same object again , again because wont call new instead use annotation called autowired

javascript - How to dynamically add active class to li element? -

hi have multiple user role based system. every user have many pages in order lessen code have used header.php file header common every page. want know how can apply active tag element page open javascript. have attached code echoed using php, inside php echo tag. example if open home class='active' should added li of home. if($role=='s') { echo"<div class='navbar navbar-default' id='navbar-second'> <ul class='nav navbar-nav no-border visible-xs-block'> <li><a class='text-center collapsed' data-toggle='collapse' data-target='#navbar-second-toggle'><i class='icon-menu7'></i></a></li> </ul> <div class='navbar-collapse collapse' id='navbar-second-toggle'> <ul class='nav navbar-nav'> <li><a href='home'><i class='icon-home position-left'></i> home</a></li&

solr - Query for records with overlapping dates in cassanda -

given table startdate , enddate columns how query records periods overlap. dates use datefield type. changing type daterangefield query? using cassandra solr. i sharing data model records periods overlap event create table event ( start_date date, id timeuuid, end_date date, primary key ((start_date), id)) select * event start_date =date; i think if create data model , query problem solve.

How to structure object in javascript -

how can structure object allow initialization same way stripe api: var stripe = require("stripe")( "sk_test_bqokikjovbii2hlwgh4olfq2" ); i have tried this var example = (function () { function example(api_token) { this.token = api_token; } example.prototype.getself = function (callback) { //do stuff }; return example; }()); module.exports = example; but cannot set property 'token' of undefined error when calling var sdk = require('./example')(api_key); since function isn't being called constructor (via new keyword), need make sure function provide doesn't expect called way. you this: function example(api_token) { this.token = api_token; } // ...prototype, etc. function example(api_token) { return new example(api_token); } module.exports = example; or don't use constructor function @ all, , use object.create : var exampleproto = { getself: function() {

angularjs - How to access Devise_token_auth access token of omniauth provider? -

how access access token of omniauth provider should sent after successful authentication devise_token_auth gem , ng-token-auth angular? i'd store token make future requests omniauth provider updating information. omniauth provider strava. see devise_token_auth creating own access tokens, aren't accessing strava. have no idea devise token auth pulls in information strava after reading through gem's code. seems should pretty simple thing, can't 1 wants information returned. in advance. we have been able figure out lot of experimentation. @resouce return nil too, did find access-token , other information returned omniauth provider, located in request.env['omniauth.auth'] , located in redirect_callbacks action of omniauthcallbacks controller. needed set up mount_devise_token_auth_for 'user', at: 'auth', controllers: { omniauth_callbacks: 'registrations'} in routes.rb , , create custom controller named registrationscontroll

ruby on rails - Devise authentication for polymorphic solution -

consider application, needs have 2 different types of user: user in standard client organization entity offering services through application requirements: different standard controllers (sessions, registrations etc) access different parts of application of course this seems walk in park creating 2 separate models devise , wouldn't duplicate functionality authentication. i went polymorphic association, organization , user different models, both 1-1 relation entity representing authentication. entity has devise attributes (like password etc), while others have type-specific ones. unfortunately solution comes lot of drawbacks, having define custom helpers, warden strategies , devise failure apps. i'm wondering, there concise solution type of issue? ideally, having 2 devise models delegating regarding authentication separate entity.

oauth 2.0 - Use Google Credentials to Login in to the SharePoint 2013 Foundation server without using Azure Access Service (ACS) -

i want achieve open authentication in sharpoint 2013 without acs. here scenario. i have fba configured site in sp2013. have created 1 custom login page used provide 3 buttons user 1.sharepoint login 2.google 3.microsoft 1.sharpoint login when user click on button, redirect standard sharepoint login page drop down windows authentication , forms based authentication. google (need this) when user click on button, should open page or user should redirected page google ask allow deny buttons user. according selection , user should provided , access sharepoint site. microsoft (need help) same above redirect microsoft login page. please this. dont want use paid products or acs. thanks you can write own security token service register in sharepoint trusted token issuer. but authentication 1 part provide access users. if want authorize single user microsoft or google, need write custom claim provider provide identities authorization.

ruby on rails - No route matches {:action=>"/microposts", :controller=>"microposts", :params=>{:micropost=>{:content=>"Lorem ipsum"}}} -

i stuck on rails tutorial michael hartl (railstutorial.org), chapter 13 and getting following 2 errors: 1) error: micropostscontrollertest#test_should_redirect_create_when_not_logged_in: actioncontroller::urlgenerationerror: no route matches {:action=>"/microposts", :controller=>"microposts", :params=>{:micropost=>{:content=>"lorem ipsum"}}} test/controllers/microposts_controller_test.rb:11:in 'block (2 levels) in <class:micropostscontrollertest>' test/controllers/microposts_controller_test.rb:10:in 'block in <class:micropostscontrollertest>' 2) error: micropostscontrollertest#test_should_redirect_destroy_when_not_logged_in: actioncontroller::urlgenerationerror: no route matches {:action=>"/microposts/499495288", :controller=>"microposts"} test/controllers/microposts_controller_test.rb:18:in 'block (2 levels) in <class:micropostscontrollertest>' t

Apache runs the image files as PHP files -

i updated php php7, apache configuration went wrong. doesn't read files directly , php deal them. did test, wrote <?php echo "hello world"?> txt file , renamed test.jpg. , shows 'hello world' when visit jpg file. can't find error is. this test url: http://shouke.luopan.me/test.jpg try change header content type : header("content-type: image/jpg");

curl - How to send Cookie using PHP Goutte -

i have code in php goutte $client = new guzzlehttp\client([ 'base_uri' => 'http://www.yellowpages.com.au', 'cookies' => true, 'headers' => [ 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'accept-encoding' => 'zip, deflate, sdch', 'accept-language' => 'en-us,en;q=0.8', 'cache-control' => 'max-age=0', 'user-agent' => 'mozilla/5.0 (x11; ubuntu; linux x86_64; rv:47.0) gecko/20100101 firefox/47.0' ] ]); i want send custom cookie server usually way using simple curl $a_curl_opts = array( curlopt_nobody => 0, curlopt_returntransfer => 1, curlopt_cookiefile => $file_cook, curlopt_cookiejar => $file_cook, ); curl_setopt_array($curl_init, $a_curl_opts); and saw som

twitter bootstrap 3 - Boostrap - form-inline with label on the left and input on the right -

Image
i have inline form, in each line want have label on left side, , input on right side. have tried pull-right , align-right , text-right , none of them works. fiddle here ! here do: <style> .form-group label{ text-align: left!important; } </style> <form action="" class="form-horizontal" method="post" role="form"> <div class="form-group"> <label class="col-md-2 control-label" for="firstname">first name</label> <div class="col-md-4"> <input class="form-control" id="firstname" name="firstname" type="text" value="" /> </div> </div> <div class="form-group"> <label class="col-md-2 control-label pull-left" for="lastname">last name</label> <div class="col-md-3&q

khan academy - How can i make a circular motion in javascript -

i'm trying make solar system using javascript, , i'm using khan academy make it, font know how can make them move in circle around sun kept browsing net hours, couldn't find anything. here's project can see have done , can in it https://www.khanacademy.org/computer-programming/solar-system/6120244512161792 just started: x = 100 // center y = 50 // center r = 50 // radius = 0 // angle (from 0 math.pi * 2) function rotate(a) { var px = x + r * math.cos(a); // <-- that's maths need var py = y + r * math.sin(a); document.queryselector('#point').style.left = px + "px"; document.queryselector('#point').style.top = py + "px"; } setinterval(function() { = (a + math.pi / 360) % (math.pi * 2); rotate(a); }, 5); div { position: fixed; width: 10px; height: 10px; } #center { left: 100px; top: 50px; background: black; } #point { left: 0px;

javascript - Is it correct that one-time-binding re-evaluates variable when combined with ngIf directive? - AngularJS -

one of mates in work show me weird behavior of one-time binding in angular. usecase: when have element text binding one-time binding inside block conditional ng-if , if change value, example adding letters, , later change condition of ng-if, , after value one-time binding has been refreshed . html: <div ng-if="a" class="blue">{{ ::text }}</div> it kind of bug, or expected behaviour? here example of i'm doing: http://codepen.io/samot/pen/rljadn if condition of ng-if made false , true, recreate contents, causing one-time ng-bind directive evaluated again. the thing 1 time binding avoid adding watch on expression, doesn't "cache" or "store" result case content of directive compiled again. so it's expected behavior.

java - Storing shapes in JComponent -

i unsure of how store multiple different shapes using 1 arraylist of type shape. here main. public class a1 { public static boolean rdraw = false; public static boolean edraw = false; public static boolean ldraw = false; public static void main(string[] args) { jframe frame = new jframe(); jbutton rect = new jbutton("rectangle"); rect.addactionlistener(new actionlistener (){ public void actionperformed(actionevent e){ if(e.getsource()==rect){ rdraw = true; edraw = false; ldraw = false; } } }); jbutton ellipse = new jbutton("ellipse"); ellipse.addactionlistener(new actionlistener (){ public void actionperformed(actionevent e){ if(e.getsource()==ellipse){ rdraw = false; edraw = true; ldraw = false; } } }); jbutton edge = new jbutton("edge");

angularjs - Saving a file using the ContentType with a valid file extension -

i want able save file via http post valid file extension. i can't use contenttype because it's not valid file extension. i'm trying angularsjs http post. note last line in code. how can give file proper extension instead of hard coding it? .success(function (data, status, headers, config) { var filename = attrs.downloadtype + "_" + attrs.downloadid; var contenttype = headers('content-type'); var file = new blob([data], { type: contenttype }); saveas(file, filename + '.txt'); }) create conversion function: function extconvert(contenttype) { var exthash = { "text/plain": "txt", "application/json": "json" } return exthash[contenttype] || "txt"; }; then use in code: httppromise.then(function onfulfilled(response) { var filename = attrs.downloadtype + "_" + attrs.downloadid; var contenttype = respon

visual studio - Cannot create GLFWwindow in C++ - glfwCreateWindow returns nullptr? -

after running several tests on code, have determined both glfw , glew initialised yet when try , create glfwwindow* object used glfw functions, glfwcreatewindow() function returns nullptr . why , how fix it? here code: #include <iostream> #define glew_static #include <gl/glew.h> #include <glfw/glfw3.h> const gluint windowwidth = 500, windowheight = 500; int main() { glfwinit(); glfwwindowhint(glfw_context_version_major, 3); glfwwindowhint(glfw_context_version_minor, 3); glfwwindowhint(glfw_opengl_profile, glfw_opengl_core_profile); glfwwindowhint(glfw_resizable, gl_false); glfwwindow* window = glfwcreatewindow(windowwidth, windowheight, "learn opengl", nullptr, nullptr); if (window == nullptr) { std::cout << "failed create glfw window!" << std::endl; char myvar1; std::cin >> myvar1; glfwterminate(); return -1; } glfwmakecontextcurrent(window); glew

java - Puting data in HashMap is taking too much time -

hashmap<string, object> merchantdetailmap = new hashmap<string, object>(); if(dataandsize != null) { resultlist<voltmerchantdetail> tempmerchantlist = (resultlist<voltmerchantdetail>) dataandsize.get("voltdbdatalist"); vmerchantlist = (list<voltmerchantdetail>) tempmerchantlist; for(voltmerchantdetail vmerchant : vmerchantlist){ hashmap<string, object> merchantdetails = new hashmap<string, object>(); merchantdetails.put("toactormsisdn", vmerchant.gettoactormsisdn()); merchantdetails.put("fromactormsisdn", vmerchant.getfromactormsisdn()); merchantdetails.put("customcol1", vmerchant.getcustomcol1()); merchantdetails.put("customcol2", vmerchant.getcustomcol2()); merchantdetails.put("customcol3&