Posts

Showing posts from September, 2010

c++ - insert performance sort data in list and vector -

in principle , practice book of bjarne stroustrup there exercise in chapter 20 asks insert random value in vector , list in sort way (experiment suggested jhon bentley) this code (if there better way doing sorry ) #include <vector> #include <list> #include <iostream> #include <ctime> #include <random> #include <chrono> using namespace std; template<typename iter, typename t> int find_index(iter start, iter end, const t& value) { int index = 0; while (start != end) { while (start!=end && value >= *start) { ++index; ++start; } return index; } return -1; } template<typename iter> void print(iter first,iter end) { while (first != end) { cout << *first << endl; first++; } } int generate_random(int min, int max) { random_device device; mt19937 generator{ device() }; uniform_int_distribution...

python - Cannot run app pool as service account -

i had python flask website ran fine when ran app pool own account. when tried changing service account (which should have permissions), following error http error 500.0 - internal server error the page cannot displayed because internal server error has occurred. most causes: •iis received request; however, internal error occurred during processing of request. root cause of error depends on module handles request , happening in worker process when error occurred. •iis not able access web.config file web site or application. can occur if ntfs permissions set incorrectly. •iis not able process configuration web site or application. •the authenticated user not have permission use dll. •the request mapped managed handler .net extensibility feature not installed. detailed error information: module fastcgimodule notification executerequesthandler handler python flask error code 0x80070542 requested url http:...

c# - Entity Framework code first - update database in different project -

i have test dbcontext use integration tests, have pending changes. it's in project: app.webapi.integration using system.data.entity; using system.data.entity.infrastructure; using app.web.data; using app.web.model.entities; namespace app.webapi.integration.data { public class integrationtestdbcontext : dbcontext, idbcontextfactory<integrationtestdbcontext> { public integrationtestdbcontext(string conn = "defaultconnection") : base(conn) { configuration.lazyloadingenabled = false; } public integrationtestdbcontext() { } public virtual idbset<question> questions { get; set; } public virtual idbset<answer> answers { get; set; } public virtual void markas(object item, entitystate entitystate) { entry(item).state = entitystate; } public integrationtestdbcontext create() { return new integrationtestdbcontex...

(matlab) Hold on doesn't work for large data sets -

i trying plot 9 sets of x,y data points on same graph, blocked off 3 different colors. particular data, hold on works first 4 sets, after new sets erase old ones. each set has approximately 1500 points. if plot 150 points each set, problem occurs after 7 sets. thanks you need adjust java heap memory size: on home tab, in environment section, click preferences. select matlab > general > java heap memory. select java heap size value using slider or spin box. ... click ok. restart matlab.

android - SQLite database is empty after first loading -

when create db , insert items inside , after try read it empty, in first start of app, there anyway refresh db or reload after insert new item. want read from first start, not second. here code: public class dbhelper extends sqliteopenhelper { protected sqlitedatabase database; public dbhelper(context context) { super(context, dbconstants.db_name, null, dbconstants.db_version); open(); } public void insertmuseum(museum museum) { contentvalues cv = new contentvalues(); cv.put(dbconstants.key_id, museum.getid()); cv.put(dbconstants.key_url, museum.getimageurl()); cv.put(dbconstants.key_description, museum.getdescription()); cv.put(dbconstants.key_location, museum.getlocation()); cv.put(dbconstants.key_name, museum.getname()); cv.put(dbconstants.key_map_status, museum.getmapstatus()); cv.put(dbconstants.key_map_size, museum.getmapsizekb()); database.insert(dbconstants.db_tab...

dictionary - how to convert python dict to geojson file in form standard? -

i want convert excel file geojson file. dictionary like: [ {"noadresse": 42537006584, "nousager": 42537000086, "lateffective": 45.83675, "longdebut": 4.91956, "latdebut": 45.75529, "longeffective": 4.84574, "idvehicule": "246veh", "latarrivee": 45.83492, "nodemande": 42537000003, "longarrivee": 4.84762}, {"noadresse": 42537007718, "nousager": 42537002720, "lateffective": 45.83955, "longdebut": 4.84574, "latdebut": 45.83675, "longeffective": 4.83098, "idvehicule": "246veh", "latarrivee": 45.83935, "nodemande": 42537000004, "longarrivee": 4.83084}, {"noadresse": 42537005803, "nousager": 42537002424, "lateffective": 45.98730, "longdebut": 4.83098, "latdebut": 45.83955, "longeffective": 4.72695, "idveh...

ecmascript 6 - es6- arrow function- no duplicate named arguments -

Image
i can't understand last ways of arrow functions have: no duplicate named arguments- arrow functions cannot have duplicate named arguments in strict or nonstrict mode, opposed nonarrow functions cannot have duplicate named arguments in strict mode. the above paragraph picked book "understanding ecmascript 6" wrote nicholas c. zakas in 'function' chapter. according description above, know arrow function has not arguments other function. i can understand sentence before half, other half start "as opposed to...". what's mean "nonarrow functions cannot have duplicate named arguments in strict mode." in fact, functions in strict mode have arguments. have no idea author mean. it means following valid javascript: function bar(foo, foo){} it not, however, when using strict mode: 'use strict'; function bar(foo, foo){} // syntaxerror: duplicate formal argument foo with arrow functions, duplicat...

javascript - jQuery .pop() is not a function -

i trying make function running, anyway caught problem "uncaught typeerror: this.chart_data.pop not function" here code $(data).each(function(){ console.log(this.chart_data); console.log(this.chart_data.pop()); var end = (this.chart_data).pop(); ret.push({ name: this.name, y: end['y'], link: this.link, color: chart_colours[i] }); i++; }); thank concern , help. this line give error: console.log(this.chart_data.pop()); i not sure why displaying pop method. still, need replace above line following: console.log($(this.chart_data).pop()); and use pop method while assigning: var end = $(this.chart_data).pop();

javascript - How to get data from MongoDB to simple array using Node.JS and Mongoose? -

Image
let's mongodb schema: var shopschema = new mongoose.schema({ nameshop: string, products: [ { type: mongoose.schema.types.objectid, ref: 'product' }] }); var productschema = new mongoose.schema({ nameproduct: string, fruits: [ { type: mongoose.schema.types.objectid, ref: 'fruit' } ] }); var fruitschema = new mongoose.schema({ namefruit: string, price: number }); module.exports = { shop: mongoose.model('shop', shopschema), product: mongoose.model('product', productschema), fruit: mongoose.model('fruit', fruitschema) } i know can data in way, result of code "ugly" array var schema = require('../model/schema'); schema.shop.find({}).populate({ path: 'products', model: 'product', ...

ios - dyld: could not load inserted library -

when try run ui , unit tests, got exception: dyld: not load inserted library '/private/var/containers/bundle/application//autotestingapp.app/frameworks/idebundleinjection.framework/idebundleinjection' because no suitable image found. did find: dyld: library not loaded: @rpath/xctest.framework/xctest what try reinstall xcode check developer , provision profile app build successful, not tested. whats wrong me? for it's worth, might able avoid issue running test on simulator instead of device. make sure you've set profiles correctly: i.e. xcode 7.0 xctest dyld: not load inserted library idebundleinjection

android - Leaftlet angular overlay image issue -

i have used leaflet plugin develop ionic hybrid app. when put in native environment, found many issues occur. there anyway fix that? issue 1: zoom in , zoom out image run away randomly. issue 2: when click zoom in or zoom out button change full screen. i have recorded video show problem here . here code have written floorplan: var local_icons = { defaulticon: { } } angular.extend($scope, { defaults: { // scrollwheelzoom: false, crs: 'simple', maxzoom: 3 }, maxbounds: leafletboundshelpers.createboundsfromarray([[-350, -620], [350, 620]]), // maxbounds: leafletboundshelpers.createboundsfromarray([[-540, -960], [540, 960]]), layers: { baselayers: { pwtc: { name: 'pwtc', type: 'imageoverlay', url: 'app/hbe/lib/img/floorplan/hall1.jpg', bounds: [[-540, -960], [540, 960]], ...

Python - pandas, DataFrame look like Nan but the behavior is like number -

when or save to_csv dataframe see cell containing nan , when use same cell behaves number. how comes? in [84]: db['category_1']['also'] out[84]: 0.91652216992816438 in [85]: db.loc['also'] out[85]: frequency 0.275729 ts_1 true category_1 nan name: also, dtype: object in [88]: db['category_1'].sum() out[88]: 99.99999999999974 in [89]: db['category_1']['also'] = 0 db['category_1'].sum() out[89]: 99.08347783007159

c# - WPF Combobox floating watermark - MetroStyle -

i have textboxes using floating watermark this: <textbox x:name="cbcombo" mah:textboxhelper.watermark="some watermark" mah:textboxhelper.usefloatingwatermark="true" text="{binding path=prop.name}" isenabled="false"></textbox> and work intended. have problem combobox - same settings (usefloatingwatermark, watermark) sets floating watermark not working @ all: <combobox mah:textboxhelper.watermark="receiver" mah:textboxhelper.usefloatingwatermark="true" x:name="cbnotworking" verticalalignment="top" margin="{staticresource mainmargin}" itemssource="{binding somecollection}" displaymemberpath="name" selectedvaluepath="id" /> combobox above not work. shows watermark @ beginning not after item selection (at left-top corner of combobox). searched answer @ mahapps gitter room , told me possible accomplish this. i tried nuget package...

refactoring - How would you simplify this c# statement? -

i know there has simpler way of writing expression. not able figure out how however. if (order != null) { name += " " + order + extension; } else { name += extension; } any suggestions appreciated. you use ? operator: name+= (order == null) ? extension : " " + order + extension;

Failed to create repository via gitlab-shell -

i installed gitlab via omnibus package on centos 7. when try create new project web interface got following error : the form contains following error: failed create repository via gitlab-shell in logs : gitlab-rails processing projectscontroller#create html parameters: {"utf8"=>"✓", "authenticity_token"=>"[filtered]", "project"=>{"namespace_id"=>"1", "path"=>"extrapack-monfatec", "import_url"=>"[filtered]", "description"=>"", "visibility_level"=>"0"}} unable save project. error: failed create repository completed 200 ok in 1049ms (views: 157.3ms | activerecord: 21.0ms) gitlab-shell i, [2016-07-11t13:40:42.549484 #31319] info -- : adding project root/extrapack-monfatec.git @ </var/opt/gitlab/git-data/repositories/root/extrapack-monfatec.git>. gitlab:check checking gitlab shell ... gi...

html - Simple way to externally disable bootstrap a:hover color? -

my question simple : there way externally disable color bootstrap sets on a:hover elements ? i'm making website uses many different font colors, , i'd prefer not have css setting each one. until i've been doing manually each case, i'd still done default, since blue color ugly on colored backgrounds. i've seen proposing following : a:hover { color: inherit; } as expected it, doesn't work, can't find other way :'( do need every color there'll on website ? you have set class each anchor use different hover-over color change. i.e. html <a href="#" class="hover-white">anchor text white on hover</a> <a href="#" class="hover-red">anchor text red on hover</a> css .hover-white:hover {color: white;} .hover-red:hover {color: red;}

Using date, and date only, in java -

Image
i'm writing java program , have been stuck quite while date, datetime , forth parts of java programming. what want have date object only. have class: deployment.java public class deployment { int id; localdate devicedeploymentdate; //i'm unsure should public deployment(int id, localdate devicedeploymentdate) { this.id = id; this.devicedeploymentdate = devicedeploymentdate; } public deployment() { } public localdate getdevicedeploymentdate() { return devicedeploymentdate; } public void setdevicedeploymentdate(localdate date) { this.devicedeploymentdate = date; } public int getid() { return id; } public void setid(int id) { this.id = id; } } and have date picker in gui. from date picker can date in string format (and change int year, int month , int date if needed ofc). want store sort of date within deployment object, , not want time part of @ all. qu...

ruby on rails - Sort by date in jsonb postgres -

i have model data stored in json format in jsonb column in postgres. i want sort output data field using activerecord query. model.all.order("json_data -> 'date'") gives me output orders alphabetically based on date string. is there easy way can sort date? note: dates in following format: "fri, 24 jun 2016 04:13:26 -0700" if date in sensible format postgres deal automatically. model.all.order("(json_data ->> 'date')::timestamp time zone desc") or model.all.order("(json_data ->> 'date')::timestamptz desc") if date field string little unorthodox, can following model.all.order("to_timestamp(json_data->>'date','dy, dd mon yyyy hh24:mi:ss ') desc") details here note ->> there output string rather json object. you can of course create column , store information there per @uzbekjon's answer below.

multithreading - Python : Creating a socket in a thread -

i trying create socket in thread , unable so. code is #!/usr/bin/env python import threading import socket class test1(): def serve(self): host = '' port = 9999 th_obj = threading.thread(target = self.thread_method, args = (host,port)) th_obj.daemon = true th_obj.start() def thread_method(self,host,port): sock = socket.socket(socket.af_inet,socket.sock_stream) sock.setsockopt(socket.sol_socket, socket.so_reuseaddr,1) sock.bind(('',9999)) sock.listen(5) while true: connection, addr = sock.accept() connection.settimeout(60) while true: data = connection.recv(2048) t = open('file.txt', 'a') t.write(data) test1().serve() the problem script won't when set daemon = true while working without it. how can solve problem. essential me demonize it.

javascript - Storing the value of variable in JS -

since main language c, used pointers , love them. have project need finish in javascript , i've got problem don't know how solve. i want store value of variable got request. have script send php page, sends daemon written in c. when string wanted, use length measure size of string got , in next request want send number of bytes got url parameter. window.onload = function() { if (bytes === undefined) { var bytes = 0; } var url = "/test/log.php?q=" + bytes; function httpget(url) { var xhttp = new xmlhttprequest(); xhttp.open("get", url, true); xhttp.onload = function(e) { if (xhttp.readystate === 4) { if (xhttp.status === 200) { console.log(xhttp.responsetext); var option = ""; obj = json.parse(xhttp.responsetext); (var key in obj) { option += obj[key]; } document.getelementbyid("list").innerhtml = asdf; bytes =...

Django test if the variable is numeric -

looks question should covered, after spending time, did not find how check variable numeric in django template. {% if my_var.isnumeric %} # {% endif %} update learnt below discussion, there seems no built-in tag check this, , end having create our own template tag. assuming "numeric" means "contains digits" (and no decimal point, no minus sign, etc.) custom filter best bet: from django import template register = template.library() @register.filter(is_safe=true) def is_numberic(value): return "{}".format(value).isdigit() docs custom template filters: https://docs.djangoproject.com/en/1.9/howto/custom-template-tags/ usage in templates: {% load your_custom_lib %} ... {% if something|is_numberic %}... if consider integers numeric (positive , negative), function becomes: try: int("{}".format(value)) except valueerror: return false else: return true in case "numeric" means "integ...

layout - How can I rotate image view during pathAnimation in android? -

i first setting path through coordinates using path.lineto() function. now animating image view on final path using value animator. above api 21 pathanimator = objectanimator.offloat(monsterimage, "x", "y", path); for api 11+ used this: pathanimator = valueanimator.offloat(0.0f, 1.0f); pathanimator.addupdatelistener(new valueanimator.animatorupdatelistener() { float[] point = new float[2]; @override public void onanimationupdate(valueanimator animation) { float val = animation.getanimatedfraction(); pathmeasure pathmeasure = new pathmeasure(path, false); pathmeasure.getpostan((pathmeasure.getlength() - 1) * val, point, null); monsterimage.setx(point[0]); monsterimage.sety(point[1]); } }); but want whenever animation changes direction should rotate image. i.e. each ...

typescript - Extending routerLink in angular 2? -

how can extend [routerlink] directive angular router v3 can wrap custom functionality myself? i've taken @ routerlinkwithhref directive , appears want extend, produced this: extendedrouterlinkdirective import {directive, input} '@angular/core'; import {routerlinkwithhref} "@angular/router"; import {model} "../classes/model.class"; @directive({ selector: 'a[extendedrouterlink]' }) export class extendedrouterlinkdirective extends routerlinkwithhref { @input('extendedrouterlink') model : model; // future custom logic } and try , use so: <a [extendedrouterlink]="model"> and include in directives array of component: ... directives: [router_directives, extendedrouterlinkdirective], ... yet, following runtime error: "template parse errors: can't bind 'extendedrouterlink' since isn't known native property" if remove extends routerlinkwithhref directive , works w...

ios - WKWebView does not load NSURLs created with fileURLWithPath:relativeToURL: -

i noticed wkwebview not load (via loadfileurl:allowingreadaccesstourl: ) nsurl created fileurlwithpath:relativetourl: . i created github repo showing behavior: https://github.com/davidkraus/wkwebviewnsurl as workaround can pass absolute string of url new nsurl. var theurl = nsurl(fileurlwithpath: "www/index.html", relativetourl: folder) // create new nsurl theurl = nsurl(string: theurl.absolutestring)! webview.loadfileurl(theurl, allowingreadaccesstourl: theurl)

javascript - Unable to display table data from array using D3.js -

var data = [ ["first name", "last name", "job title", "favorite color", "wars or trek?", "porn name", "date of birth", "dream vacation city", "gpa", "arbitrary data"], ["james,matman", "chief sandwich eater", "lettuce green", "trek,digby green", "january 13, 1979", "gotham city", "3.1", "rbx-12"], ["the", "tick", "crimefighter sorta", "blue", "wars", "john smith", "july 19, 1968", "athens", "n/a", "edlund, ben (july 1996)."] ]; var sortascending = true; var titles = data[0]; var table = d3.select('#page-wrap') .append('table'); var headers = table.append('thead') .append('tr') .selectall('th') .data(titles) .enter() .append(...

node.js - VSTS Gulp build step error -

i have issue while setting build steps in vsts . use gulp generate css less files. in visual studio (task runner explorer) works fine, following build error when it's run in vsts: gulp failed error: c:\npm\modules\gulp.cmd failed return code: 1 i tried example mentioned in the docs npm / gulp setup, didn't work me either. change applied setting path gulpfile.js. left rest untouched (npm install arguments, gulp task name, working folders, etc.) yet got error mentioned above. any suggestions doing wrong? here's full log of failing build step: 2016-07-11t12:07:06.7456466z set workingfolder default: c:\lr\mms\services\mms\taskagentprovisioner\tools\agents\1.102.0\tasks\gulp\0.5.24 2016-07-11t12:07:06.9966480z ##[debug]agent.workfolder=c:\a 2016-07-11t12:07:07.0176485z ##[debug]loading inputs , endpoints 2016-07-11t12:07:07.0186489z ##[debug]loading endpoint_auth_e43d0f79-1244-42ad-b28b-5b98484615e7 2016-07-11t12:07:07.0186489z ##[debug]loading en...

R Jupyter: Error in checkInstall(models$library) -

Image
i trying train model using train() function caret package. getting following error: but library installed. tried reinstalling library still getting same error. appreciated.

c# - how to change connection string db value app setting to web config -

currently mvc project.previous developer database connected app settings change web config i have changed code appsettings webconfig <appsettings> <add key="tickportalsql" value="server=1.34.34.4.;database=montage;user id=montage;password=pwd;trusted_connection=false;" /> </appsettings> this code change web config <connectionstrings> <add key="tickportalsql" value="server=1.34.34.4.;database=montage;user id=montage;password=pwd;trusted_connection=false;" /> </connectionstrings> previous developer using appsettingsreader public abstract class homesqldbrepository { public string connectionstring { get; set; } = appsettingsreader.readstring("thenna"); const int maxitemcount = 1000; public enum sqlexecutetype { scalar, nonquery, reader } public async task<string> executesqlasync(string procname, sqlexecute...

Reading a generated JSON File in Java -

i'm asking because searching while , had no luck. •• first of all, put here link page links of project needed see i'm doing. put them here because otherwise can't. can put 2 links. link: http://pastebin.com/rry5cbcd •• i'm coding in java to-do list. want make save/load system using json. finished save class, it's in link above. now i'm doing load class. want class loading data file it's generated info in jlist , saving data object array, arraylist or making visible in jlist. if info in variable know how make visible in jlist. problem don't know how read data jsonobject in jsonarray generated user (because data in json file user puts in jlist don't know how many elements user add). in link above. if need else, main class or something, project in link above. i didn't find nothing in google reading generated json file. need guys. and, last 1 thing, sorry english. you can use jackson task easy. add following dependencies ...

algorithm - Understanding a solution to the Euler Project in Python -

i'm going through euler project. i've started using javascript , i've switched python yesterday, got stuck in problem seemed complex solve javascript solved in python, , i've decided start first problem again in python. i'm @ problem 5 asks me find smallest positive number evenly divisible of numbers 1 20. i know how solve paper , pencil , i've solved using programming, in search optimising crossed solution in forum of euler project. it seems elegant , fast, ridiculous fast compared mine, takes 2 seconds solve same problem numbers 1 1000, mine takes several minutes. i've tried understand it, i'm still having difficulty grasp doing. here is: i = 1 k in (range(1, 21)): if % k > 0: j in range(1, 21): if (i*j) % k == 0: *= j break print it posted user named lassevk that code computing least common multiple of numbers 1 20 (or whichever other range use). it starts 1 , ea...