Posts

Featured post

How do you convert a timestamp into a datetime in python with the correct timezone? -

you naively expect work: import pytz datetime import datetime def tz_datetime_from_timestamp(timestamp): """convert timestamp datetime """ tz = pytz.timezone('australia/perth') server_time = datetime.utcnow() delta = tz.utcoffset(server_time) value = datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz) return value + delta print tz_datetime_from_timestamp(1416387060) and convert timestamp 1416387060 wed nov 19 16:51:00 2014 gmt+8:00. ...but not. prints: 2014-11-19 16:51:00+07:43 the timezone of australia/perth not gmt+7:43. it gmt+8:00. unequivocally stated on australian government website http://www.australia.gov.au/about-australia/our-country/time : awst equal coordinated universal time plus 8 hours (utc +8). so, heck pytz pulling 7.43 from? well, turns out pytz pulls data http://www.iana.org/time-zones time zone database, , database states: # western australia # # rule name type in on @

d - Is there I can get GDC to give me source code with all templates expanded, but no other work done? -

suppose have file foo.d instantiates bunch of templates. there way can ask gdc (specifically) give me foo.d templates instantiated, nothing else done? gcc -e option doesn't work, d templates not expanded c preprocessor, i'm not sure option should try (or if 1 exists).

css - How to add a transition to a absolute positioned box on hover -

hi have created boxes overflow: hidden , on hover box drop down showing inner box. i have created , works fine use transition on effect smoothen drop down. have added transition , not working. any advice great on thank you. <html> <head> <title></title> <style type="text/css"> #items {width:300px;} .item {width:100px;border:solid 1px #ccc;float:left;height:20px; z-index:0;overflow:hidden;position:relative;} .item:hover{overflow:visible;z-index:100;} .item:hover .inner{z-index: 100;} .inner{position: absolute; background: white; width: 100%; } </style> </head> <body> <div id="items"> <div class="item"><div class="inner">text 1<br>text 1<br>text 1</div></div> <div class="item"><div class="inner">text 2<br>text 2<br>text 2</div></div> <div class="item"><div class="in

.net - Preventing XSS attacks across site -

i need review quite large .net 4.0 project , re-factor prevent xss attacks. first thing did turn on requestvalidation site, there else can @ global level or going case of trawling through every page, validating input , html encoding output. there lots of pages, , 300 classic asp pages still in use. is htmlencode() safe use or need install microsofts antixss package. requestvalidation approach. at global level 1 more thing can think of enabling x-xss-protection header @ http responses. easy implement , gives native defences browser (ie 8+, chrome) has offer based on xss patterns. x-xss-protection: 1; mode=block you may @ content-security-policy, think in scenario may big roll out entire site. those think of http header based xss mitigations. generic , not apply asp.net. answering other question is htmlencode() safe use or need install microsofts antixss package what benefit make encodertype antixssencoder in mvc application? antixssencoder uses whitel

HTML pattern attribute for email validation -

i need email address of user match format while registering. name.name@gmail.com he should not able enter @yahoo.com or @hotmail.com or else other @gmail.com. also, allowed enter lower case letters , period [.] if wants. may please know how achieve this? have got far. pattern ="[a-z.]+@gmail.com" try /^([a-z0-9.])+\@gmail.com+$/

sql server - Generate Invoice Number for Multi user environment in C# -

i generating invoice numbers using max function , adding 1 last invoice number. straightforward. applied multi user environment getting problem. because 2 users open invoice window @ same time both same id, invoice number should first thing appear , not last cannot use identity (auto generate id) invoice number. want generate invoice number multi user environment windows form application in c#... the other problem happen 2 users accessing , updating same record same time. i hope understand problem. read optimistic vs. pessimistic locking need solution. can please reply me have different database table store max invoice number. when user opens invoice window, run stored procedure to: lock table get current number store current+1 number unlock table return current+1 number this ensure though there simultaneous requests unique invoice number. the flip side: 1. stored procedure cannot run simultaneously multiple users bottleneck in case of high traffic. 2. th

how to display 2 form fields on same line with bootstrap -

i creating form in bootstrap should responsive. see below code. <form novalidate="novalidate" class="form-inline"> <div class="form-group"> <label class="col-sm-4 control-label" for="inputfirstname">first name:</label> <div class="col-sm-4"> <input class="form-control" type="text" id="inputfirstname" ng-model="patient.firstname"/> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label" for="inputlastname">last name:</label> <div class="col-sm-4"> <input class="form-control" type="text" id="inputlastname" ng-model="patient.lastname"/> </div> </div> &l