Posts

c# - Check if the image resource is null -

i working on windows phone 8 application. string image = "/mydata/" + myobject.imagename + "big.png"; bitmapimage bmp = new bitmapimage(new uri(image , urikind.relative)); myimage.source = bmp; i have image in folder mydata/, have 2 sets of images <imagename>big.png,<imagename>small.png. so here happening want check if <imagename>big.png exists in location or not, if not pick <imagename>small.png. how ? edit i solved myself, here how. file.exists("path file") here path should `foldername/filenames` , not `/foldername/filenames` thanks helped me. string image = "/mydata/" + myobject.imagename + "/big.png"; string filename = path.getfilename(image); if(!string.isnullorempty(filename)) { messagebox.show("file exist -"+filename); } else { messagebox.show("no file exist -"); } bitmapimage bmp = new bitmapimage(new uri(image , urikind.relative)); if...

javascript - Updating MongoDB array from variable array in batch operation? -

i working in node.js , attempting push or pull contents of array mongodb collection. [working] code pull objects array in fieldarray looks this: for (var i=0; < mylist.length; i++) { collection.update( {field:"myvalue"}, {$pull: {fieldarray: mylist[i]}}, function(err, item){...} ); } i'm aware of ability use $push/$each, $addtoset/$each , $pullall don't seem accept values dynamically array (or haven't found indication can). basically, i'd able use function array of 1 item or 1 hundred, using appropriate batch calls. is there way make such call without having loop through separate call on database each iteration? you want $pullall . trying iterate over collection.update( { "field": "myvalue" }, { "$pullall": { "fieldarray": mylist } } ) if doesn't work then array elements not matching structure used in document. make them way.

return model object from spring controller -

i have spring controller in curd methods there. @controller public class editemployeecontroller { @autowired private employeemanager employeemanager; @requestmapping(value = "/", method = requestmethod.get) public string listemployees(modelmap map) { map.addattribute("employee", new testemployee()); map.addattribute("employeelist", employeemanager.getallemployees()); system.out.println("calling listemployees"); return "editemployeelist"; } @requestmapping(value = "/add", method = requestmethod.post) public string addemployee(@modelattribute(value="employee") testemployee employee, bindingresult result) { employeemanager.addemployee(employee); return "redirect:/"; } @requestmapping("/delete/{employeeid}") public string deleteemplyee(@pathvariable("employeeid") integer employeeid) { employeemanager.deleteemployee(em...

Python BeautifulSoup similar divs in the same container sorting -

i able scrape data want, since divs in 1 container "content-body" when results dumped whole ( can test code , see) in match_date match tourny. import requests bs4 import beautifulsoup, tag lxml import html import requests import mysqldb import urllib2 import itertools import re import sys datetime import date, timedelta td, datetime urls =("http://www.esportsheaven.net/?page=match") hdr = {'user-agent': 'mozilla/5.0'} req = urllib2.request(urls,headers=hdr) page = urllib2.urlopen(req) soup = beautifulsoup(page) tournament=soup.findall('div',{'class':['content-body']}) match_time = soup.find_all("div", style = "width:10%; float:left;") match = soup.find_all("div", style = "width:46%; float:left; margin-left:2%; margin-right:2%") tourny = soup.find_all("div", style = "width:40%; float:left; overflow:hidden;") tag in tournament: tag in match_time: pr...

javascript - button not work in IE11 -

problem: http://jsfiddle.net/7zdbb/1/ if click first , second row's deny button, third row's deny button can't click in ie 11. i tested on ie8、ie9、ie10、firefox , chrome, , not problem. this source code. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <style> #main table{ border-collapse:collapse; width:100%; } #main td{ border:1px solid #eea; padding:4px 6px; } #main table tr.excepted td{ background:#f99; } form table {background:#fefef1} </style> <script src="jquery.js" type="text/javascript"></script> </head> <body > <div id="base"> <div id=...

generating alphanumeric employees id using trigger in mysql? -

hello friends want create table employees create table if not exists `employees` ( `sno` int(11) not null auto_increment, `empcode` varchar(20) not null, `employeename` varchar(20) not null, `fathername` varchar(20) not null, `gender` varchar(6) not null, `dob` date not null, `contactno` varchar(12) not null, `address` varchar(100) not null, `city` varchar(20) not null, `state` varchar(20) not null, `branch` varchar(20) not null, `dateofjoining` date not null, primary key (`sno`), unique key `empcode` (`empcode`) ) engine=innodb default charset=latin1 auto_increment=1 ; and want generate unique employee code when insert new record in employees table in sequence in employees table example cg000001 cg000002 ... on using mysql trigger not able logic fail time please me using after trigger can't access new flushed. you need before trigger. create trigger bi_table_name before insert on employees each row begin set new.empcode = c...

add two date using datetime php class -

i need add 30 days 2014-03-06 . i've done below code:- $due_dt = new datetime("2014-03-06"); $act_dt = $due_dt->add("+30 days"); this code giving below error:- message: datetime::add() expects parameter 1 dateinterval, string given any please... use datetime::modify $date = new datetime('2014-03-06'); $date->modify('+30 days'); echo $date->format('y-m-d');