Posts

Showing posts from February, 2011

reactjs - Dynamically set form field values in React + Redux -

my app's store has store.authstate subtree. in subtree, there 3 things, authtoken , isfetching boolean and, importantly fields object. form contains 2 fields : username , password . i have created action called set_form_field_value should generate , update each field's state changed user. i set_form_field_value update fields object. if user fills in both username , password fields, store.authstate should this: { authtoken: undefined, isfetching: false, fields: { username: "brachamul", password: "azerty123" } } however, seems current code overwrites , end : { field: { username: "brachamul" } } the data in field changes based on field last edited. it's either username or password. here code : switch (action.type) { case 'set_form_field_value': let field = {} // create "field" object represent current field field[action.fieldname] =

C stack implementation throws bad access error -

am building stack in c. stack fails exc_bad_access error on if check in isempty() function, , i'm not sure why. typedefs & definitions: #define nodesize sizeof(stacknode) struct stacknode { int data; struct stacknode *nextptr; }; typedef struct stacknode stacknode; typedef stacknode *stacknodeptr; stack operation functions void push(stacknodeptr *topptr, int value) { // declare new node , set top stacknode *node; node = malloc(sizeof(nodesize)); node->data = value; node->nextptr = *topptr; // reassign pointer top *topptr = node; printstack(*topptr); } int pop(stacknodeptr *topptr) { stacknode *node = *topptr; if (isempty(node)) { return 0; } // grab current top node , reset 1 beneath top pointer. *topptr = node->nextptr; printstack(*topptr); return node->data; } int isempty(stacknodeptr topptr) { if (topptr == null || topptr->nextptr == null) { // bad_access

sql - Creating Custom columns in stored procedure postgres -

i using stored procedure return type of student enrolled @ college. pushing id through should return first name , last name in new column going made(ex: commuter, employee, resident). keep getting error: error: syntax error @ or near "if" line 8: if exists (select count(commuterid) > 0 commuter wh...). any tips or ideas? create or replace function roleatmarist(int, refcursor) returns refcursor $$ declare identifier int := $1; resultset refcursor := $2; begin open resultset if exists (select count(commuterid) > 0 commuter commuterid = identifier) select fname, lname, "commuter" role people peopleid = identifier; end if; if exists (select count(employeeid) > 0 employee emplpoyeeid = identifier) select fname, lname, "employee" role people peopleid = identifier; end if; if exists (select count(residentid) > 0 studentpark residentid = identifier) select

php - Laravel 5. How I can save and take back values of Session -

Image
i try save after log in of user, values in session database. try use code validate login , put in session. protected function login(request $request){ $var = $request->session()->all(); return dd($var); $user = model\account::where('username',$request['username'])->first(); if(isset($user)){ if (hash::check($request['password'], $user->password)) { $request->session()->put('usuarios',$user); return view('aluno/showactivities'); } else{ return dd('invalid password.'); } } else{ return dd('user doesn't exists.'); } } obs: use controller execute login. route defined code in down. route::post('/new/login',['as' => 'authregister', 'uses' => 'usercontroller@login',f

php - Struggling with Cypher & CREATE UNIQUE -

i reading soccer match data text file , want create matches , referee nodes. way want logic work create match node , referee name , create referee node if referee not exist else link existing referee match. presently not have root node , not sure if should create 1 (very new graph modeling). i have following query in think close not there. $match= $client->makenode(); $match->setproperty('label', "match: ".$feed['match_number']) ->setproperty('type', "match")->save(); //now match node created lets see if current referee in feed exists already $querystring = "start match=node({nodeid}) ". <----- need @ cases????? "create unique (referee{label:{name}, type:'referee'})-[:refereed{ label:'refereed' }]->(match)"."return referee"; $query = new neo4j\cypher\query($client, $querystring, array('nodeid' => $match->getid(),'name' => $feed['r

javascript - How can one determinate if a function will return sub-functions without execution -

it context of one-page application development, need transform string executable function. var repo = {}; i used strings in 2 formats : repo.toto = "function toto(){\ alert('hello, toto');\ }"; repo.titi = "function titi(){\ this.sub1 = function() {};\ this.sub2 = function() {};\ this.sub3 = function() {};\ }"; i want know if function once executed give, or not, object of sub-functions. below full case illustrate problem. eval not solution. var createfunc = function(name) { var string = repo[name]; var func = function("return new "+string+""); repo[name] = func; }; typeof repo.toto; //string typeof repo.titi; //string createfunc('toto'); createfunc('titi'); typeof repo.toto; //function typeof repo.titi; //function repo['toto'](); //alert('hello, toto'); //object {} repo['titi'](); //object { sub1: anonymous/titi/this.sub1(), sub2: anonymous/titi/thi

pascalscript - Inno Setup - Pascal Script - Conditionally hide/show a task -

Image
here's list of tasks: [tasks] name: "d3d"; description: "install d3d engine"; groupdescription: "engines:" name: "gl"; description: "install opengl engine"; groupdescription: "engines:"; flags: unchecked name: "sw"; description: "install software engine"; groupdescription: "engines:"; flags: unchecked name: "desktopicon"; description: "{cm:createdesktopicon} launcher"; groupdescription: "{cm:additionalicons}" name: "desktopicond3d"; description: "{cm:createdesktopicon} d3d engine"; groupdescription: "{cm:additionalicons}" name: "desktopicongl"; description: "{cm:createdesktopicon} opengl engine"; groupdescription: "{cm:additionalicons}" name: "desktopiconsw"; description: "{cm:createdesktopicon} software engine"; groupdescription: "{cm:additionalicons}" now, want achi

java - Global Scanner works once but gets a bit hairy on the second run -

i know site can pretty harsh noobs myself have tried 3 days right. part of homework assignment final project. problem have when use case 1 more once, first time works planned second time seems skip on following lines. system.out.println("please enter title: "); string title = two.nextline(); the areas focusing on in bookstore class in add()method , in main class, case 1. when trying add second book, code skips past book title , goes straight isbn. import java.util.scanner; public class mis_tester { public static scanner 2 = new scanner(system.in); public static scanner 3 = new scanner(system.in); public static void main(string[] args) { scanner in = new scanner(system.in); bookstore bookseller = new bookstore(); order addbook = new order(); sale sell = new sale(); boolean finished = false; while(!finished){ system.out.println("select: (0) output; (1) add book; (2) delete book; (3) order boo

java - Is it possible for try-with-resource to fail to close resources? -

as per oracle documentation the try-with-resources statement try statement declares 1 or more resources. resource object must closed after program finished it. try-with-resources statement ensures each resource closed @ end of statement. object implements java.lang.autocloseable, includes objects implement java.io.closeable, can used resource if resource not implement autocloseable cannot declared within try block, has declared in body part & has explicitly closed in block. possible try-with-resource fail clean resources unless use idiom incorrectly if there nested resources & close() call not idempotent underlying resource? understand try-with-resource ensures close() getting called behind scene, if close not close underlying resources try-with-resource remain ineffective clean-up resources. have contrary view or more clarification? disregarding code not work (like example of close() methods not closing resource) or such external factors people attaching

r - File path with write.zoo -

i'm using r on mac osx , following guide download , maintain collection of csvs stock prices. http://www.thertrader.com/2015/12/13/maintaining-a-database-of-price-files-in-r/ library(quantmod) startdate = "2000-01-01" thepath = "" source(paste("listofinstruments.r",sep="")) (ii in theinstruments){ print(ii) data = getsymbols(symbols = ii, src = "yahoo", = startdate, auto.assign = false) colnames(data) = c("open","high","low","close","volume","adj.") write.zoo(data,paste(thepath,ii,".csv",sep=""),sep=",",row.names=false) } i'm trying keep r files separately csv files, change variable "thepath" existing subdirectory named csv. e.g. thepath = "\\csv\\" however creates file named \csv\^gspc.csv opposed writing subfolder. what correct way specif

Printing multiple Markers on Android google maps -

so got code trying add markers saved in database: @override public void onmapready(googlemap googlemap) { mmap = googlemap; // add marker in sydney , move camera control.conectar(); arraylist<sucursal> sucursales = control.getsucursales(); control.cerrar(); latlng loc; for(int x=0;x<sucursales.size();x++){ loc = new latlng(sucursales.get(x).getx(), sucursales.get(x).gety()); mmap.addmarker(new markeroptions().position(loc).title(sucursales.get(x).getnombre())); } mmap.movecamera(cameraupdatefactory.zoomto(12)); mmap.movecamera(cameraupdatefactory.newlatlng(new latlng(20.67711737527203, -103.36349487304688))); } all db rows getting obtained correctly , cicle working, first row seems "working" because not putting on right location either. ive tried exact code time, think im missing now. the first thing should take care of have data needed in sucursales variable. doing can sure of placing marke

.net - Live Video Display Stutter Using StetchBlt to Write Bitmaps To Panel in C# -

the project i'm working on requires live agc , display of 14 bit gray-scale video. video grabbed teledyne dalsa camera link card , processed pixel array on 1 thread stored bitmap. second display thread grabs latest available bitmap image , writes panel using stretchblt. processing thread runs on average around 40hz while display thread can re-draw latest image @ 150hz or faster. same image re-written multiple times before new 1 becomes available, don't think issue. problem occurring there sort of stutter using method of display. when video camera feeding program slewed left or right it's not smooth , there bit of lag/aberration. vertical lines in image seem hang slightly. my question is, there way fix this? there better way display live video? both threads running plenty fast enough render video doesn't stutter somehow still graphically when compared 30hz unprocessed analog signal. input appreciated , can provide more information if helpful. thanks! kidron

javascript - html text-input ?no value or text attribute -

hello @ stack overflow, i've searched in-depth no avail. background: i'm developing web application using visual web developer express 2010, , using bootstrap css. i have text-input form control on site user enter search query. problem: text-input form control has no value or text attribute. when there value/text typing in. image of textbox , html code i planned on javascript changing text in textbox selection of list-item. if can provide other information or code, please let me know & update. my theory bootstrap javascript & jquery libraries interfering, haven't clue start probing. value attribute on dom node's in-memory javascript representation, has getter retrieve current value of input , setter update on-screen, not in computed page. however, html attribute value , in-memory parameter not kept in sync default. is, computed html not keep track of user has typed, value javascript attribute does . can go ahead , update input us

c# - Arranging dotnet core app for 3-tiers with data access layer -

Image
my typical .net 4.5x web application structure has minimum of 3 tiers: web project (a .net web application), domain/business logic project (a class library), , data access project (a class library). web project references business layer, , business layer references data access layer. i approach since web project not have reference data access project (it must go through domain/business logic layer first). web project shouldn't have access context or repository classes. in 3-tiered .net 4.5.x app, declare connection string in web.config , give name of dbcontext name attribute of connection string. in new dotnet core paradigm, every example see has dbcontext configured in startup.cs this: public void configureservices(iservicecollection services) { // add framework services. services.addmvc(); services.addentityframework() .addsqlserver() .adddbcontext<myapplicationcontext>("myconnectionstring or reference it"); } by giving s

Facebook Messenger Platform: how to get user specific information? -

i'm trying recent released facebook messenger platform , far good. worked , able create echo bot. but i'm wondering how identify user started chatting in page. example, when user started chatting pid user (page specific user id). making follow request facebook graph api: get https://graph.facebook.com/v2.6/{page_specific_user_id} i discovered can ask following fields: first_name,last_name , profile_pic. so question is, how discover if user current customer of business page? there way of querying more information (like e-mail , real facebook user id)? currently, there's no way this. best way prompt user enter information in chat or give them link mobile login page or other way of linking account chat.

swift - Confusion Regarding How to Use Capture Lists to Avoid a Reference Cycle -

my custom uiviewcontroller subclass has stored closure property. closure signature defined take single argument of same type of class: class myviewcontroller { var completionhandler : ((myviewcontroller)->(void))? // ... } ...the idea being, object passing argument of handler, bit like uialertaction initializer . in addition, , convenience, have factory(-ish) class method: class func presentinstance(withcompletionhandler handler:((myviewcontroller)->(void))) { // ... } ...that performs following actions: creates instance of view controller, assigns completion handler property, presents modally whatever happens top/root view controller @ time of call. my view controller leaking: set breakpoint on deinit() execution never hits it, way after i'm done view controller , dismissed. i not sure of how or should specify capture list in order avoid cycle. every example have come across seems place closure body defined, can't code compile. w

ibm mobilefirst - Unable to connect to WLADM -

Image
i trying install , setup mobilefirst. able install nd, create server, install mobilefirst server, install database, create database , trying create runtime configuration tool. below database screenshot proves database exist this screenshot of creating admin configuration , show port number ok this screen shot of database additional setting checking database wladm70 have given, validation happened without problem in checking database state.

Stability testing of REST API -

i have registration rest api want test - register 15000 users , pound server repeated incident reports (varying traffic max being 100 per minute, min being 1 per 24 hrs , avg being 1 per minute ) on period of 48 hours. which tool can use test stability of rest api? for pounding server incidents on period of time, can use http://runscope.com/ . helpful testing apis. can trigger events in runscope on period time or schedule hit server required.

jquery - how to make first column of data table as hyperlink -

to draw data table used below code function getdatatable(data1) { var cols = []; var examplerecord = data1[0]; var keys = object.keys(examplerecord); keys.foreach(function(k) { cols.push({ title: k, data: k //optionally type detection here render function }); }); var table = $('#querybuildertable').datatable({ columns: cols }); //add data , draw table.rows.add(data1).draw();} in first column got caseid want column hyper link user can click on link please in code use json , json key working column name here. try in following way $('#querybuildertable').datatable( { "columndefs": [ { "targets": 0, "data": "the_link_defines", "render": function ( data, type, full, meta ) { var returnstring=''; /*here can check condition making link */ if(your condition data obj) returnstring =&

ios - Using protocols for detecting value changes in UISegmentedControl -

i have uisegmentedcontrol in uitableviewcell, need listen value changes in tableviewcontroller. so far know have use protocols able this, i'm not sure put code. should in uitableviewcell? in viewcontroller? bit confusing me. i need pinpointing on start, or better, code example? here code using protocol.in sample , can observe value change of segmentcontrol. can know cell's segment being tapped , know segment data change. // viewcontroller.m #import "viewcontroller.h" #import "segmenttestcell.h" @interface viewcontroller ()<uitableviewdatasource, uitableviewdelegate, segmenttestcelldelegate> @property (nonatomic, strong) uitableview *table; @end @implementation viewcontroller #pragma mark - lifecycle - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. [self.table registerclass:[segmenttestcell class] forcellreuseidentifier:@"cellid"]; [self.view addsubview:s

html - Bootstrap Carousel issue -

Image
i having issue carousel. mean works fine there wierd symbols new buttons change slides. i don't know how fix this. here code it. <div class="well"> <div id="mycarousel" class="carousel slide"> <ol class="carousel-indicators"> <li data-target="#mycarousel" data-slide-to="0" class="active"></li> <li data-target="#mycarousel" data-slide-to="1"></li> <li data-target="#mycarousel" data-slide-to="2"></li> </ol> <!-- carousel items --> <div class="carousel-inner"> <div class="item active"> <div class="row-fluid"> <div class="span3"><a href="#x" class="thumbnail"><img src="http://placehold.it/250x250" alt="image" style="max-width:100%;" /></a></div

Android AESObfuscator limit licensing to specific device? -

the class provided in google lvl aesobfuscator accepts device id parameter. mean user 2 devices able access using specific device id? recommend passing info instead enable multi device access same user? thanks the aesobfusvator used encrypt , store information localy (policy class) , not used send encrypted information server. there idea of 1 user /multiple devices won't affected , 1 user can access app on multiple devices

nlp - Why does my NamedEntityAnnotator for date mentions differ from CoreNLP demo's output? -

Image
the date detected following program gets split 2 separate mentions whereas detected date in ner output of corenlp demo single should be. should edit in program correct this. properties props = new properties(); props.setproperty("annotators", "tokenize, ssplit, pos, lemma, ner, entitymentions"); stanfordcorenlp pipeline = new stanfordcorenlp(props); string text = "this software released on februrary 5, 2015."; annotation document = new annotation(text); pipeline.annotate(document); list<coremap> sentences = document.get(sentencesannotation.class); for(coremap sentence: sentences) { list<coremap> mentions = sentence.get(mentionsannotation.class); if (mentions != null) { (coremap mention : mentions) { system.out.println("== token=" + mention.get(textannotation.class)); system.out.println("ner=" + mention.get(namedentitytagannotation.class));

How to install an npm package from GitHub directly? -

trying install modules github results in: enoent error on package.json. easily reproduced using express: npm install https://github.com/visionmedia/express throws error. npm install express works. why can't install github? here console output: npm http https://github.com/visionmedia/express.git npm http 200 https://github.com/visionmedia/express.git npm err! not package /home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/tmp.tgz npm err! error: enoent, open '/home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json' npm err! if need help, may report log at: npm err! <http://github.com/isaacs/npm/issues> npm err! or email to: npm err! <npm-@googlegroups.com> npm err! system linux 3.8.0-23-generic npm err! command "/usr/bin/node" "/usr/bin/npm" "install" "https://github.com/visionmedia/express.git" npm err! cwd /home/guym/dev_env/projects_git/proj/somename npm err!

Atlasstian/Stash Git Api - Getting names of files modified between commit -

i'm trying create nightly process create list of files changed between last commit of previous day , current head of branch. i've been looking @ stash api, can found here: https://developer.atlassian.com/static/rest/stash/3.11.3/stash-rest.html it looks /compare/changes , /diff capable of accomplishing task, can them work single commit changes. is there way expand can names of files changed between multiple commits? ex: files between commit1 through commit10 ? i glanced @ briefly (and have odd terminology, calling these "changesets" instead of "commit" ids: make sense mercurial, not git) api does take 2 ids , need. for instance, in example, want see happened between commit1 through commit10 the word "between" bit suspect (because commits not linear in first place, , because introduces fencepost errors) in general, this, compare (the id of) commit1 (or parent, depending on whether counting fence posts or fenc

Java, If a draggable object touches other object -

i have code dragging label width mouse. lbl_banner.addmouselistener(new mouseadapter() { @override public void mousepressed(mouseevent e) { //catching current values x,y coordinates on screen x_pressed = e.getx(); y_pressed = e.gety(); } }); lbl_banner.addmousemotionlistener(new mousemotionadapter(){ @override public void mousedragged(mouseevent e){ //and when jlabel dragged setlocation(e.getxonscreen() - x_pressed, e.getyonscreen() - y_pressed); } }); now, how make function: while i'm dragging label around screen, if label dragging touches other object (label, button,...) something. if(//labeltouchessomething){//do something} while not technically dragging dynamic move of component (dragging transfer of contents in between components), can compute intersection of current moving component against other components (this may need navigation inside hierarchy). may can you: how detect collison of compon

r - Swapping values between two columns using data.table -

i have been breaking head on translating this question data.table solution. (to keep simple i'll use same data set) when v2 == "b want swap columns between v1 <-> v3 . dt <- data.table(v1=c(1,2,4), v2=c("a","a","b"), v3=c(2,3,1)) #v1 v2 v3 #1: 1 2 #2: 2 3 #3: 4 b 1 the code below working solution data.frame , because of amount of frustration has given me because using data.table without realising i'm determined find solution data.table. dt <- data.table(v1=c(1,2,4), v2=c("a","a","b"), v3=c(2,3,1)) df <- as.data.frame(dt) df[df$v2 == "b", c("v1", "v3")] <- df[df$v2 == "b", c("v3", "v1")] # v1 v2 v3 #1 1 2 #2 2 3 #3 1 b 4 i have tried writing lapply function looping through target swapping list, tried narrow down problem replace 1 value, attempted call column names in different ways without success.

ios - Amazon SES: sending email error -

i using awsses sending email. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { awsstaticcredentialsprovider *credentialsprovider = [[awsstaticcredentialsprovider alloc] initwithaccesskey:my_key secretkey:my_secret]; awsserviceconfiguration *configuration = [[awsserviceconfiguration alloc] initwithregion:awsregionuseast1 credentialsprovider:credentialsprovider]; [awslogger defaultlogger].loglevel = awslogleveldebug; [awsses registerseswithconfiguration:configuration forkey:@"useast1ses"]; } send email function - (void) email { awssescontent *messagebody = [[awssescontent alloc] init]; messagebody.data = [nsstring stringwithformat: @"test email"]; awssescontent *subject = [[awssescontent alloc] init]; subject.data = [nsst

angular - Angular2 @Input issue -

i new angular2 , trying hand using @input not able proceed because of below issue. after @input component not proceed further. have verified in chrome developer tools , see execution goes outside class after @input import {component, input, oninit} 'angular2/core'; import {http, http_providers} 'angular2/http'; import 'rxjs/rx'; var availablejobs = []; @component({ selector: 'job-categories', templateurl:'templates/job.categories.html', providers:[http_providers] }) export class jobcategories{ @input('rows') rows: string; @input('cols') columns: string; constructor(http: http){ http.get('appjs/dummyjson.json').map(res => res.json()).subscribe( (data) => { availablejobs = data; console.log(availablejobs); }); } } could please me overcome. the html tag i see problem

Python module installed but getting an import error in windows -

i installed python module, installation success. installed changing path in windows powershell folder , then python setup.py install but when try import error message no module named yahoo_finance any idea? you don't have yahoo_finace module installed. you can install module command: python -m pip install yahoo_finance here may read more pip: https://pip.pypa.io/en/stable/reference/pip/

c# - datagrid view select row is not working -

Image
i filled gridview cell cell without using datasource. when reload 1 column after drag , drop rows, not working: row[6].selected = true; and turns color of row blue selected thing, when call if row selected returns me null! , that's because of sign in default column in gridview pointer each row. , when click on row selecting row manually shows again. so my question how enable sign selecting process . the datagridview can have multiple selected rows, if multiselect option set true. the black arrow represents row has current cell selected. so need set this.datagridview1.currentcell = this.datagridview1.rows[1].cells[0]; for row , cell want highlighted black arrow. also aware cell use must visible, enabled , not header cell otherwise might not work.

javascript - Knockout JS style binding causing error -

i need data-bind background-image div using knockout js style attribute. data-binding product.image. product.image string of image file name. need however, add path file before file name. code: <div data-bind="style: { background-image: 'url(../../the_vegan_repository/product_images/'+ product.image + ')' }" but causes console error: uncaught syntaxerror: unable parse bindings. bindings value: style: { background-image: 'url(../../the_vegan_repository/product_images/'+ product.image } message: unexpected token - why causing error? here code: <script type="text/html" id="product-template"> <div class="col-sm-6 col-lg-2 clickable" style="margin-top:20px; padding: 25px;"> <div style="border-radius: 15px; border: 5px solid #fc4747;height: 270px;overflow: hidden;"> <div data-bind="style: { background-image: 'url(../../the_

rust - Can a trait be passed as a Fn reference or closure -

in rust, can take in reference fn documented : fn call_with_one(some_closure: &fn(i32) -> i32) -> i32 { some_closure(1) } let answer = call_with_one(&|x| x + 2); however want write trait that, if implemented, runnable can passed expects fn() . possible? trait runnable { fn run(&self); } struct myrunnable; impl runnable myrunnable { fn run(&self) {} } struct structthattakesclosure<'life> { closure_field: &'life fn(), } fn main() { // there way change runnable trait automatically match // fn() interface such myrunnable instance can passed directly? structthattakesclosure { closure_field: &|| myrunnable.run() }; } i have tried implementing 3 extern calls default functions didn't manage working. this not possible on stable rust, because exact definition of fn trait unstable. on nightly rust can implement fn traits, concrete types, it's not helpful. impl<'a> std::ops::fn

php - Error in creating thumbnails from my form -

i've got problem script of mine create thumbnails images/photos users can upload form in personal website. first of all, after possible controls prevent possible attacks, rename photo uploaded user using php functions, , i'd show logged user (and logging function use here sessions) uploaded images/photos thumbnails, giving him possibility click on them , obtain way photos original dimensions. the problem got the thumbnails , i'm not able create!!!. i created new table in mysql database way: create table uploaded (id_file int(11) unsigned not null auto_increment url_file varchar(50) not null, name_file varchar(100) not null, type_file varchar(20) not null, description varchar(255), notes text, data_insert datetime not null, address_ip char(15) not null, username varchar(20) not null, id_user int(11) not null, primary key(id_file) ); then created file in php called vision.php show user images, , file

php - Custom field for category in prestashop 1.5.4 -

i'm trying add new custom field category in prestashop 1.5.4 , new image field. i'm looking solution nothing seems help. this have done far: http://wklej.org/id/1081777/ alter table ps_categories , add new field

c++ - What's the best strategy to get rid of "warning C4267 possible loss of data"? -

i ported legacy code win32 win64. not because win32 object size small our needs, because win64 more standard , wish port our environments format (and use 3rd party libs offering better performance in 64bits in 32bits). we end tons of; warning c4267: 'argument': conversion 'size_t' '...', possible loss of data mainly due code like: unsigned int size = v.size(); v stl container. i know why warning makes sense, know why issued , how fixed. however, in specific example, never experienced cases container size exceeded unsigned int 's max value in past.... there no reason problem appear when code ported 64bits environment. we had discussions on best strategy supress noisy warnings (they may hide relevant 1 miss), not make decision on apropriate strategy. so i'm asking question here, best recommended strategy? 1. use static_cast use static_cast . unsigned int size = static_cast<unsigned int>(v.size()); . don't "like"

mysql - PHP query fetching records from table2 to table 1 -

i got 2 tables student s_id, lastname, firstname, middlename takensubject s_id, subjectcode, time i have code below using session display take subject takensubject display id want display full name of student using id takensubject code below show error warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean. can me correct query? <?php include'database.php'; $sescode = $_session['sessioncode']; $sestime = $_session['sessiontime']; $conn = mysqli_connect($server, $dbusername, $dbpassword, $database); if (!$conn) { die("connection failed: " . mysqli_connect_error()); } $sql = "select * takensubject tb2, student tb1 tb2.s_id=tb1.s_id , schoolyear ='$sy' , semester ='$sem' , subjectcode='$sescode' , time='$sestime'"; $no = 0; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row

java - Procrun fails to start the windows service -

i have small spring-boot based application i'm trying register windows service using procrun. unfortunately, procrun seems failing start application. here's main class: public class daemon { public static void main(string[] args) throws ioexception { if ("start".equals(args[0])) { start(args); } else if ("stop".equals(args[0])) { stop(args); } } public static void start(string[] args) { application.main(new string[0]); } public static void stop(string[] args) { } } here's installation bat: set "current_dir=%cd%" set "application_service_home=%cd%" echo %application_service_home% set service_name=cmsapi set executable_name=%service_name%.exe set executable=%application_service_home%\%executable_name% set cg_start_class=com.castsoftware.analyser.daemon set cg_stop_class=%cg_start_class% set cg_path_to_jar_containing_service=%application_service_home%\..\..\cast-cmsapi.jar set cg_startup_ty

The concept of django admin when adding information with foreign keys -

this question has answer here: django: adding “add new” button foreignkey in modelform 2 answers i can't find right words google here find help. want use idea of admin page in django when add information , has foreign key, plus sign present beside field , that, can add data pops in new window , after saving, new data automatically reflects selection. okay. solved add button. want data appear after saving in select drop down. haven't had answer yet this easy, if other model(which foreign key) added admin. directly shows plus button. but, if don't want that. i guess searching inlinemodeladmin .

scala - Pattern-matching & existential type -

why doesn't work? scala should understand in case of case hasints , outer.type <: hasints.type . what's workaround (without removing type member)? sealed trait outer { type inner } case object hasints extends outer { override type inner = int } def id(outer: outer): outer.inner = outer match { case hasints => 0 } edit: on otherhand, if change type member existential universal, compiles. sealed trait outer[inner] case object hasints extends outer[int] def id[i](outer: outer[i]): = outer match { case hasints => 0 } why work in first case , not second? they're arguably identical (and indeed, in dotty be.) dependent types. there no particular way compiler determine outer.inner when return int . error puts well: scala> def id(outer: outer): outer.inner = | outer match { | case x@ hasints => 0 : hasints.inner | } <console>:15: error: type mismatch; found : hasints.inner (which exp

php - How to make control characters visible in string? -

i wondering if possible make control characters in string visible. $mystring = "test\n"; echo $mystring; this output test don't want php translate \n should output test\n (for debugging purposes). possible? put between single quotes: $mystring = 'test\n'; echo $mystring; //returns test\n

networking - Routing Information Protocol number of hops -

Image
can explain me, why subnet z 7 hops away router d (and not 3 hops)? ones counted? please see picture below: i believe 'break' in image means "any number of routers exist here."

python 2.7 - Update with pull in MongoDB 3.2.5 matching but not modifying document -

i getting 500 error on getjson request maps python 2.7 function containing mongodb update $pull . last error seen sudo tail -f /var/log/apache2/error.log is: [wsgi:error] [pid 1721:tid 140612911712000] [client 127.0.0.1:59078] keyerror: 'nmodified', referer: http://localhost/control_room the python logic deals particular key update $pull : update_with_pull = collection.update({"user_email":user_email,"top_level.year":entry_year,"top_level.month":entry_month}, { "$pull": {dynamic_nested_key: {"timestamp":entry_timestamp}}}) the conditional after trying catch if document has been modified or not with: if update_with_pull['nmodified'] == 1: #do stuff i tested same operation in mongo shell , returned: writeresult({ "nmatched" : 1, "nupserted" : 0, "nmodified" : 0 }) so seems matching query not doing modifications. to further troubleshoot, entry_timestamp value