Posts

Showing posts from September, 2015

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

for loop - Special for syntax for looping over all objects of a certain class? -

can compress combined for -plus- if single for , i.e. can combine first 2 lines single instruction loop? it should visit objects in childnodes instances of mynode . for childnode in childnodes { if let mynode = childnode as? mynode { // mynode } } i presume childnodes array. if yes, can filter it: for childnode in (childnodes.filter { $0 mynode }) { println ("it's node") } or if prefer more explicit code: let nodes = childnodes.filter { $0 mynode } childnode in nodes { println ("it's node") } as far know, in swift there's no clean way combine for loop optional binding skip iterations. something might possible using standard for loop, combined closure which, given index, returns next index containing mynode instance... wouldn't call simplification in terms of code , readability: let findnext = { (var index: int) -> (node: mynode?, next: int) in while index < childnodes.count {

php - Add Number for duplicate entry in sql -

i have table :- id name email username 1 johen mak jojo@yahoo.com johen_mak 2 johen mak jojo@gmail.com jojo 3 gawil gorgy jojo@homail.com gawil_gorgy 4 johen mak jojo@yamail.com jojo 5 johen mikik jojo@yamail.com jojo in table in database entry in same username , need add _1 .... end username i need update above table this:- id name email username 1 johen mak jojo@yahoo.com johen_mak 2 johen mak jojo@gmail.com jojo 3 gawil gorgy jojo@homail.com gawil_gorgy 4 johen mak jojo@yamail.com jojo_1 5 johen mikik jojo@yamail.com jojo_2 how can that

Import SQLite database using Qt/QSqlDatabase -

i have 2 separate applications, 1 placed @ production @ office, , need copy of sqlite database generated , updated @ production side. until i've tried 2 approches: copy entire sqlite file production-application , "redirect" qsqldatabase-handles file (was not able work, many connections opened , not closable) access sqlite-db on network, query data , insert missing data using sql (works, since there lot of data takes time) are there possibilities import or maybe override existing database (or single tables, placed in different files), there still open connections? using: qt 4.8, sqlite, windows 7, vs2010 so able reach goal using sqlite backup api (which distributed .h , .c qt versions). on documentation page sqlite backup there few examples, database copied either file in-memory db, or in-memory file. in case used following function (1:1 doc page, several comments removed): int loadorsavedb(sqlite3 *pinmemory, const char *zfilename, int issav

php - Restructure array to be in descending date order -

i have multi-dimensional array, has index ['dates'] . inside ['dates'] there index, , inside there ['date_time'] index data. presently ordering of part of array oldest newest date/time. wish reverse first element most recent data. here subset of data: array(4) { [0]=>array(3) { ["id"]=>string(4) "1279" ["name"]=>string(13) "account_name" ["dates"]=>array(7) { [0]=>array(3) { ["date_time"]=>string(19) "2014-11-14 09:30:03" ["follower_count"]=>string(4) "1567" ["gains_losses"]=>string(4) "1567" } [1]=>array(3) { ["date_time"]=>string(19) "2014-11-14 16:30:35" ["follower_count"]=>string(4) "1566" ["gains_losses"]=>string(2) "-1" }... here full array you m

xcopy - how to copy and paste file into folder using batch -

i want create batch file copy content of folder , paste folder. say source: d:\backup\test destination: d:\backup1 but here want create subfolder destination can paste file. @echo off :: variables echo backing file set /p source=enter source folder: set /p destination=enter destination folder: set listfile=xcopy /l set xcopy=xcopy /s/e/v/q/f/h %listfile% %source% %destination% echo files copy press enter proceed pause %xcopy% %source% %destination% pause the if not exist checks see if directory exists. if not, mkdir creates it. @echo off echo backing file set /p source=enter source folder: set /p destination=enter destination folder: if not exist %destination% mkdir %destination% set listfile=xcopy /l set xcopy=xcopy /s/e/v/q/f/h %listfile% %source% %target% echo files listed copied. pause %xcopy% %source% %destination%

mysql select condition with 3 conditions -

Image
i have table have field called cheque_type , filed comes 3 variables such life,nonmotor,motor and table has time stamp. need result how many life, nonmotor , motors checks printed what need add 3 columns sql query , number of results according category select date(`timestamp`) ___date___, count(`id`) total, sum(print_status) printed, (count(`id`) - sum(print_status)) to_be_print cheque.vouchers date( `timestamp`) >='2014-11-15' , date( `timestamp`) <='2014-11-31' group date(`timestamp`) ; select date(`timestamp`) ___date___, count(`id`) total, sum(print_status) printed, (count(`id`) - sum(print_status)) to_be_print, sum(cheque_type = 'life') life_check, sum(cheque_type = 'nonmotor') non_check, sum(cheque_type = 'motor') motor_check cheque.vouchers date( `timestamp`) >='2014-11-15' , date( `timestamp`) <='2014-11-31' group date(`timestamp`) ;

xmlhttprequest - What is the suggested way to build and send a http request in Python -

i wrote small module 1 year age. when tried add feature these days, found there big change in python's urllib , confused how build request. in old module fancyurlopener used base class, yet found deprecated since version 3.3. so read document again, , try build request instead of opener. however, when tried add headers, 1 function request.add_header(key, val) provided. have headers copied fiddler this: get some_url http/1.1 host: sosu.qidian.com user-agent: mozilla/5.0 (windows nt 6.1; wow64; rv:33.0) gecko/20100101 firefox/33.0 accept: application/json, text/javascript, */*; q=0.01 accept-language: zh-cn,en-us;q=0.7,en;q=0.3 accept-encoding: gzip, deflate x-requested-with: xmlhttprequest referer: anothe_url cookie: lot of data connection: keep-alive so have add them request 1 one? also found openner urllib.request.build_opener() can add lot of headers in 1 time. not set method 'get' or 'post'. i newbie on python, suggestions ? by far

lua - How to get past 1gb memory limit of 64 bit LuaJIT on Linux? -

the overview prototyping code understand problem space, , running 'panic: unprotected error in call lua api (not enough memory)' errors. looking ways around limit. the environment bottom line torch, scientific computing framework runs on luajit, , luajit runs on lua. need torch because want hammer on problem neural nets on gpu, there need representation of problem feed nets. (stuck) on centos linux, , suspect trying rebuild pieces source in 32bit mode (this reported extend luajit memory limit 4gb) nightmare if works @ all of libraries. the problem space not particularly relevant, in overview have datafiles of points calculate distances between , bin (i.e. make histograms of) these distances try , work out useful ranges. conveniently can create complicated lua tables various sets of bins , torch.save() mess of counts out, pick later , inspect different normalisations etc. -- after 1 month of playing finding easy , powerful. i can make work looking @ 3 distances 15

c# - NotSupportedException when doing a Bing image search programatically -

i using following code more 50 results bing image search using bing search container bing api. problem when try , execute query ( query.excecute() ) after changing off-set next 50 results ("$skip", 50) following error: a first chance exception of type 'system.notsupportedexception' occurred in microsoft.data.services.client.dll i can't figure out how query. re-iterate occurs when when loop executes second time. happens on line var results = query.execute(); , when tries query. void bingsearch(string searchterm) { try { imageset = new list<bing.imageresult>(); const string bingkey = "[key]"; var bing = new bingsearchcontainer( new uri("https://api.datamarket.azure.com/bing/search/")) { credentials = new networkcredential(bingkey, bingkey) }; var query = bing.image("\"" + sear

vbscript - Use string as Object method -

basically, i'm creating small script update ad attributes (for super user, not admin). i've got number of attributes, need custom field user can type in ad attribute , searched ldap query , displayed using objuser. here code: do while z = true attrchoice = inputbox("please enter custom attribute wish edit", "custom attribute") msgbox "you have selected " & objuser.+attrchoice, vbokonly+vbinformation, objuser.displayname on error resume next if err.number <> 0 msgbox "error!" & vbcrlf & "attribute cannot found, please try again", vbokonly+vbexclamation, "error" else z = false end if on error goto 0 loop as can see, i've tried doing objuser. attribute part few different ways - i'm not sure how use string that's input user. in custom field, user put "mail" , code run objuser.mail - make sense? if need more information, ple

box api - Way to create file with the box api -

i there way create doc, .boxnote third app box api ? seems edit, delete update functionalities avaible. i not possible. box notes created using specific web application box. box's api have two modules : box content : managing upload/download of data box view : converting docs html

Assigning values of an object to a column in Loop through R -

this snippet of r code. trying assign value of resultsdata[i] column error values not assigning. results coming in console somehow not able assign required column resultsdata=foreach(i=1:length(xyzarr)) %dopar% { xyzred[xyzsred$loopn==xyzarr[i],]$setpoint-xyzred[xyzred$loopn==xyzarr[i],]$temp } foreach(i=1:length(xyzarr)) %dopar%{ xyzred[xyzred$loopn==datapointsarr[i],]$error=resultsdata[[i]] } results in console: [[1]] [1] 1.186 1.186 1.186 1.186 1.186 1.186 1.186 1.186 1.186 1.186 1.186 1.186 1.186 2.266 2.266 2.266 2.266 2.266 [19] 2.266 2.266 2.266 2.266 1.384 2.392 2.392 i typically use combine feature. general approach calculate column, output entire row. lastly, row binding logic puts together. xyzarr$var_name_here <- numeric(nrow(xyzarr)) resultsdata <- foreach(i=1:length(xyzarr), .combine=rbind) %dopar% { xyzarr[i,]$var_name_here <- xyzred[xyzsred$loopn==xyzarr[i],]$setpoint-xyzred[xyzred$loopn==xyzarr[i],]$temp xyzarr[i,] }

node.js - Node js Error: Most middleware (like session) is no longer bundled with Express and must be installed separately -

i have upgraded express version 3 , seeing error in middleware. specifically: error: middleware (like session) no longer bundled express , must installed separately. please see https://github.com/senchalabs/connect#middleware. the stack trace is: at function.object.defineproperty.get (/home/phpsaravana/nodeshop/node_modules/express/lib/express.js:89:13) @ module.exports (/home/phpsaravana/nodeshop/node_modules/connect-mongo/lib/connect-mongo.js:30:39) @ object.<anonymous> (/home/phpsaravana/nodeshop/admin.js:6:42) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ function.module.runmain (module.js:497:10) @ startup (node.js:119:16) @ node.js:906:3 how fix this? in newer versions of express, middle-wares session not bundled express , if want use them, have install them separately. : npm install express-session and require : var session = r

ios - UISearchBar not showing scope bar when setting in storyboard -

Image
i want add searchbar scope bar top of tableview, build app storyboard. works before add scope bar. then check checkbox in attributes inspector , add 2 scope titles: the searchbar turns out way: goes wrong. i remove setting , try code: self.searchbar.showsscopebar = yes; self.searchbar.scopebuttontitles = @[@"title1",@"title2",@"title3"]; it seems works except color of copebuttons: i using xcode6.1 , deployment target 7.0, 1 have ideas? if using story board view controller should controlled navigation controller , use document outline drag , drop want.

math - Is there a mathematical formula to determine how many diagonal sequences are there in a Tic-Tac-Toe game? C# -

i'm building tic-tac-toe game project c#. teacher asked me create array while size max number of diagonal sequences possible in specific board size (not 3x3). problem now, teacher gave me wrong formula , won't calculate right. example, in 3x3 board, there should 2 possible diagonal sequences, formula calculates 1. this formula: (rows-sequence+1)*(cols-sequence+1). which means: (3-3+1)*(3-3+1) = 1 if knows correct formula, i'll grateful! think this. how many ways there place seq * seq square within row * col rectangle. teacher gave answer. there 2 diagonals in square, number of call diagonals in row * col matrix 2 times value teachers function.

c# - Synchronize two .net application using threading -

this question has answer here: win32 named mutex not released when process crashes 2 answers i have resource shared between various .net application. if 1 app using resource other apps should wait untill first app release that. other apps chance occupy resource randomly based upon cpu scheduling. i trying use mutex if application has occupied mutex , terminates abnormally other apps error. please suggest design resolve scenario. mutex right thing use. maybe this or this application terminating abnormally holding mutex (google abandoned mutex)?

java - Return subclass when superclass is defined as return type -

this question has answer here: is list<dog> subclass of list<animal>? why aren't java's generics implicitly polymorphic? 12 answers in extension of question same topic: is list<dog> subclass of list<animal>? why aren't java's generics implicitly polymorphic? had follow-up question. given have classes animal - parent dog - child why can't return list when defined return type list? private class animal{}; private class dog extends animal{}; public list<animal> makeanimallistofdogs(dog dog1, dog dog2){ list<dog> dogs = new list<dog>; dogs.add(dog1); dogs.add(dog2); return dogs; } this might seem useless example, clarify problem. if try this, error: type mismatch: cannot convert list<dog> list<animal> it off course

monitor - wait and pulse Exception in C# -

i have simulation druring time. in every steps have 4 main function f1,f2,f3,f4. f1 must run before , f2 , f3 can run after f1 parallel. when f2 , f3 finished can start f4. want create 4 task these. don't want create task in every step.(because has overhead) want after 1 task , wait next step. write code give exception. task taskf1, taskf2, taskf3, taskf4; bool lockf1,lockf2, lockf3, lockf4_1,lockf4_2; random r; public void f() { r = new random(); taskf1 = task.factory.startnew(f1); taskf2 = task.factory.startnew(f2); taskf3 = task.factory.startnew(f3); taskf4 = task.factory.startnew(f4); monitor.pulse(lockf1); } private void f1() { while (true) { monitor.wait(lockf1); console.writeline("task 1"); thread.sleep((int)(r.nextdouble() * 1000.0)); monitor.pulse(lockf2); monitor.pulse(lockf3); } } private

vb.net - VB: User Control Object Reference Error with Datagridview -

i'm working in visual studio 2010 visual basic. have windows form , user control. on user control datagridview, linked table, public shared. when putting user control on windows form following message, displayed form was: to prevent possible data loss before loading designer, the following errors must resolved: object reference not set an instance of object. at fehlteilmanagement.checkmultiple.checkmultiple_load(object sender, eventargs e) in c:\users\to113808\desktop\fehlteilmanagement\visual studio\fehlteilmanagement\fehlteilmanagement\forms\checkmultiple.vb:line 7 @ system.windows.forms.usercontrol.onload(eventargs e) @ system.windows.forms.usercontrol.oncreatecontrol() @ system.windows.forms.control.createcontrol(boolean fignorevisible) @ system.windows.forms.control.createcontrol() @ system.windows.forms.control.controlcollection.add(control value) @ system.windows.forms.form.controlcollection.add(control value) @ system.windows.forms.

python - How do I create a range that goes from the first row of a 2D matrix to the last row? -

i have matrix of dimensions nx2. defining function this: def overlap_test(r): in range( ) i'm struggling write range arguments because matrix doesn't have fixed numbers; numbers within randomly generated. want general way of saying first row last row of matrix. how want function iterate on range first row nth row??? don't know notation saying first row of matrix? the function .shape can : yourmatrix.shape this function return tuple (r, c), contains dimension of matrix. can derterminate last row of matrix, , range of function for.

objective c - How do I override -windowTitleForDocumentDisplayName? -

in mac developer reference windowtitlefordocumentdisplayname , here , suggests window controller can override method, to customize window title. example, cad application append “-top” or “-side,” depending on view displayed window. but can't find example code showing how this. when override method in custom window controller class, doesn't seem called, when create new instance of window controller class. i've been searching web couple of days find information method, there hardly info out there. of old - other question 1 of recent pages linked google. help please! this method appears called when nswindowcontroller's document set nsdocument instance.

php - JQuery .get not working on my page -

i dont understand why code doesnt work : $( "#remove" ).click(function() { var getcontent = $("#noticeid").val(); $.get("admincp.php", { removeid : getcontent } ,function(){ }); }); heres html textbox : <td><input class='form-control' style='position:absolute;left:500%;' type='text' name='noticeid' value='$editid'></td> and button <input type='button' id='remove' value='remove' class='btn btn-danger'> and heres php (on same page): if($_get['removeid']){ $removeid = $_get['removeid']; $querydelete = "delete `$dbtable`.`notices` `noticeid` = $removeid"; mysqli_query($conn,$querydelete); } this worked simple php , html must script. sorry if simple mistake cant seem fix it. edit: putting input in if clause wasnt working fixed still doesnt work, here new html code ($info7 =

c++ - Wrong use of fprintf? Getting exception First-chance exception -

i'm getting "first-chance exception @ 0x708a6b2e (msvcr120.dll)" in first line of print_bit_vector() in second execution. can tell why? code: void print_bit_vector(file* pfile, std::string title, std::vector<bool> bitvector) { fprintf(pfile, "%s:\r\n", title); int size = bitvector.size(); int = 0; (i = 0; < size; i++) { std::cout << << std::endl; //for (bool bit : bitvector) fprintf(pfile, "%d", bitvector.at(i)); } fprintf(pfile, "\r\n"); } void test() { file * pfile; pfile = fopen("c:\\...\\myfile.txt", "w"); bc bc("c:\\...\\example_test.txt"); std::vector<bool> key = std::vector<bool>(128, 0); std::vector<bool> input = std::vector<bool>(128, 1); print_bit_vector(pfile, "key", key); print_bit_vector(pfile, "input", input); //exception inside execution of print_bit_ve

java - Notation " Class<?>... " -

i have work existing code, , didnt find notation meant : class<?>... for instance, used in method : public static <t> hashset<constraintviolation<t>> validate(validator validator, t resource, class<?>... groups) { return (hashset<constraintviolation<t>>) validator.validate(resource, groups); } and called : hashset<constraintviolation<entrydto>> l = validationtools.validate(this.validator, entrydto); does mean "groups" optionnal ? found interesting topic : what class<?> mean in java? doesnt answer question... thanks answers =) the first answer have linked correctly tells class<?> means. ... called varargs , , means 0 or more arguments. argument class<?>... means number of arguments of type of class. for more info on varargs , see https://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html

python - Can't display new html page with href from homepage -

the examples find. related issues login page , iteration other pages not in way have problem, here issue have deal - i want display form creating account multiple steps, using modals, when user access button "subscribe" on homepage.html have this: <a onclick="window.location.href='account'" target="_blank"> <input type="submit" value="account"> </a> ` ...which supposed go new account.html page, in same folder homepage.html in app's urls.py, apps' name homepage have: from django.conf.urls import patterns, url homepage import views urlpatterns = patterns('', url(r'^$', views.homepage, name='homepage'), url(r'^account$', views.account, name='account'), ) and in views have: from django.shortcuts import render homepage.models import email def tmp(request): latest_email_list = email.objects.order_by('-pub_date')[:0] cont

installation - setting up android environment in linux ubuntu 12.04 64 bit -

i started setting android environment on ubuntu (12.04) machine. first, installed eclipse luna. after that, installed adt plugin eclipse -> install new software , url - https://dl.google.com/eclipse/plugin/4.4 . after plugin installation, downloaded android sdk official site - http://developer.android.com , following instructions. finally, after installation, tried creating new project importing other projects, giving me r error everytime, r.java never getting generated. can please me understand problem, finding solution. i got adt plugin url, i.e, http://developer.android.com , official android dev website, so, issue? what may issue - android sdk or adt plugin? thanks... whenever get r cannot resolved then check /res directory , there must file have error in , preventing application being built. example, may layout file or may due missing resource is, defined in xml file. if have additional, unused (!) or unreferenced (!) images in folder res/drawabl

Flex Editable ComboBox Filters list values -

i working on flex 3.6a sdk , need make editable combobox should able filter dropdown list values based on user inputs. not sure how though...plz suggest. thanks, i think you're looking autocomplete combobox. you can use tink's here: http://www.tink.ws/blog/filtercombobox/ code: https://code.google.com/p/tink/source/browse/trunk/flex3/src/ws/tink/mx/controls/filtercombobox.as swc: https://code.google.com/p/tink/downloads/detail?name=tink_flex3_mx.swc&can=2&q= or one: https://github.com/flextras/flextrascomponents/tree/master/autocompletecombobox/halo

android - How can I compare a button image to another image to see if they are equal? -

i want check if image of image button equals image. have been trying. if(string.valueof(image1.getid()) == (selectedq.image))){ resultalertfragment alertdialog = new resultalertfragment(); alertdialog.show(getfragmentmanager(), "list alert"); } else if(!(string.valueof(image1.getid()) == picturecorrect)){ resultalertfragmentincorrect alertdialog = new resultalertfragmentincorrect (); alertdialog.show(getfragmentmanager(), "list alert"); } this image selectedq set randomimage[] questionarray = { imageboy, imagegirl, imageman, imagewoman, imagecow, imagedog, imagecat, imagefox }; // random int button random randomequestion = new random(system.currenttimemillis()); int nextquestion = randomequestion.nextint((questionarray.length) - 1); selectedq.person = questionarray[nextquestion].person; selectedq

javascript - How can I animate/slide a div into view while moving the contents as opposed to just revealing the contents? -

i use jquery slideup , slidedown methods, instead of effect being 1 of contents merely being revealed, though screen being pulled , forth, contents slide view, though hidden panel being pulled , forth. if want use jquery animate check fiddle: http://jsfiddle.net/cgly77us/1/ script: $(document).ready(function(){ var slideupanimate = function(duration, callback){ var $element = $("#slideup"); var startposition = $(window).scrolltop() + $(window).height() + $element.height(); var finishposition = $element.position().top; $element.css("top", startposition + "px").show().animate({ top: finishposition + "px" },duration, callback); }; var slidedownanimate = function(duration, callback){ var $element = $("#slideup"); var finishposition = $(window).scrolltop() + $(window).height() + $element.height(); var startposition = $element.position().top; $element.css("top", startpo

c# - Does creating a new DbContext instance open a new connection and transaction? -

in ef6, when doing: this.datacontext = new mycontext("name=contextname"); does open new connection , transaction? the reason because when call uow's commit() method, dbcontext's connection open.

android - Crash report on Developer console ... seems truncated -

i trying view crash report of app on android developer console ... long , @ end of it, says "... 10 more" ... cant view rest, ideas? thanks. java.lang.runtimeexception: unable create service com.example.wb.filterservice: java.lang.nullpointerexception @ android.app.activitythread.handlecreateservice(activitythread.java:2595) @ android.app.activitythread.access$1800(activitythread.java:139) @ android.app.activitythread$h.handlemessage(activitythread.java:1292) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5097) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) @ dalvik.system.nativestart.main(native method) caused by: java.lang.nullpoin

java - I am Always getting the Instance of Parent Class.But i need a child one -

i want instance of child class getting parent class instance can explain me why?? according xmltype id getting instace of children(string or anyuri) etc.but in conditions need child class instance. code:: public abstract class wstype public final static wstype getinstance(int xmltypeid) { switch (xmltypeid) { case string: return wsstringtype2.getinstance(); //**here getting parent class calling instance of wsstringtype2.** case anyuri: return wsanyuritype2.getinstance(); } } public final static wstype getinstance(int xmltypeid, string data) throws xcallexception { wstype wsdata = wstype.getinstance(xmltypeid); /**/calling happening here** } } public class wsstringtype extends wstype { protected string m_data; public wsstringtype() { m_data = "'"; } public wsstringtype(string name){ m_data=name; } public static wsstringtype getinstance() { return new wsstringtype(); }

Android Lollipop preference -

Image
is there easy way create preference system preferences in lollipop? my previous app had headers , fragments, want use appcompat toolbar , preferenceactivity (onbuildheaders) can't use new toolbar. that's why i'm searching complete redesign of preferences. i want this: has tutorial this? it' s simple. apply theme.appcompat.xxx activity , put preferencefragment in activity if use api level >= 11. edit for lastest supoort libary appcompat-v7, google provides appcompatdelegate trick, here sample code google.

javascript - why does the got view is undefined in construct function? -

why got view undefined in construct function ? i set in define, set in function arguments, still undefined, view returned object. here view must got: define([ 'jquery', 'backbone', 'resources', 'views/ship', 'models/ship', 'models/stage' ], function ($, backbone, resources, shipview, shipmodel, stagemodel) { var stageview = backbone.view.extend({ tagname: 'canvas', id: 'stage', classname: 'stage', model: stagemodel, initialize: function () { this.listento(stagemodel, 'change', this.move); this.ctx = this.el.getcontext('2d'); resources.load(['images/space1.jpg']); }, render: function() { this.el.width = $('body').width(); this.el.height = $('body').height(); this.model.xpos = 1500 - (this.el.width / 2); this.model.ypos = 1500 - (this.el.height / 2); return this; },

Converting CSV file to UCS-2LE encoding with php -

i'm creating csv file. need in ucs-2le encoding. tried following, neither of work: $value = mb_convert_encoding($value,"ucs-2le"); $value= iconv( mb_detect_encoding( $value ), 'ucs-2le', $value ); opening file in notepad++ shows encoding ansi. code: $file = fopen($filename,"w"); array_walk($csv_data, 'encodecsv'); foreach ($csv_data $line) { fputcsv($file, explode(',', $line)); } fclose($file); function encodecsv(&$value, $key){ $value = mb_convert_encoding($value,"ucs-2le"); //$value= iconv( mb_detect_encoding( $value ), 'ucs-2le', $value ); } you should add byte-order-mark ( bom ) @ beginning of file. should '\xff\xfe' in case: $file = fopen($filename,"w"); fwrite($file, '\xff\xfe');

jquery not storing data() values -

what don't understand .data()? here 2 divs:- <div id="dataobjects"> <div id="datagetterclone"></div> </div> here code:- for (var = 0; < 4; i++) { var elementid = "datagetter"; $("#" + elementid + "clone") .clone() .attr('id',elementid + i.tostring()) .addclass("newitem") .data('dflt_internal_id' ,"") .data('dflt_elem_category' ,"category") .data('dflt_elem_type' ,"standard") .data('dflt_elem_name' ,"getter " + i.tostring()) .data('dflt_elem_top' ,20) .data('dflt_elem_left' ,40) .data('dflt_elem_height' ,60) .data('dflt_elem_width' ,80) .appendto($("#dataobjects")); } // keep track of number of changes saved, , display error later if there none var itemcount = 0; // prepare items inserted var createdon = new date

c# - Mono mkbundle throws weird error -

i've been trying compile or bundle application using mkbundle. script i'm executing: set -o errexit set -o nounset mono_version="3.2.3" export mono=/cygdrive/c/progra~2/mono-$mono_version machineconfig=$programfiles\\mono-$mono_version\\etc\\mono\\4.0\\machine.config export path=$path:$mono/bin export pkg_config_path=$mono/lib/pkgconfig icon_name='"icon.ico"' echo "1 icon $icon_name" > icon.rc export cc="i686-pc-mingw32-gcc icon.o -u _win32" output_name=output.exe mkbundle jiratempoapp.exe monoposixhelper.dll gtk-sharp.dll glib-sharp.dll atk-sharp.dll gdk-sharp.dll glade-sharp.dll glib-sharp.dll pango-sharp.dll restsharp.dll jirarestlib.dll --deps --machine-config "$machineconfig" -o $output_name -z rm icon.rc rm icon.o cp $mono/bin/mono-2.0.dll . cp $mono/bin/zlib1.dll . ./$output_name i had add monoposixhelper.dll because got entrypoint not found error. got weird error: $ ./mkbundle_cygwin.sh

assembly - Changes value use in all functions (NASM) -

i have problem accumulator eax. in main function don't true value. in set, put eax 1. accumulator 8. set function change value in set function. how can use changes in functions? function: mov edx, [esp +4] cmp edx, 3 je set ret set: mov eax,1 ret main: pushad mov eax,0 mov, ebx,2 loop: add ebx,1 call function push eax push ; string db... call printf ; print number 8 add esp,8 cmp ebx, 4 jne loop popad ret you not passing arguments function , presumably comparison false , eax remains unchanged. first time around should zero, on it's return value printf may 8 . want pass ebx argument function , either preserve eax through printf or 0 explicitly in function . example: main: pushad mov eax,0 mov ebx,2 loop: add ebx,1 push ebx ; pass argument call function add esp, 4 ; free argument push eax ; save eax push eax push ; string db... call printf ; print number 8 add esp,8 pop eax ; restore eax cmp ebx, 4 jne loop popad ret ps: learn use debugger find own mist

oracle - Connecting SQL Developer 1.5.4 to tnsnames.ora -

i having trouble establishing connections tnsnames.ora while using sql developer 1.5.4. have looked @ other threads on site , have told me go tools> preferences > database > advanced > tnsnames directory. missing option connect tns directory , getting option "advanced parameters" instead of "advanced". body know find option on sql developer 1.5.4? sorry won't let me post image. i appreciate help. thanks niall i don't think can. @ work, dbas years ago started keeping current tnsnames.ora on network share, still had maintain local versions people using sql developer until relatively recently. honest, don't remember version option introduced select directory, quite confident later version you're on. jamabing says, it's free , don't need install it, why not upgrade anyway?

python - Selenium: For loop breaks find_element -

this 1 has me stumped. it's related question: selenium: iterating through groups of elements this works fine: print driver.find_element_by_xpath('//div[@class="_1zf"]//div[@class="_946"]//div[contains(text(), "lives in")]').text this not: group = driver.find_elements_by_class_name('_1zf') person in group: print person.find_element_by_xpath('.//div[@class="_946"]//div[contains(text(), "lives in")]').text when put in loop, element can't found. @automaticstatic: group list of elements person 1 of elements present in list of elements in group group = driver.find_elements_by_class_name('_1zf') # group list of elements person in group: print person.text # person 1 of elements present in list of elements in group hope work you.

javascript - Stick header causes page jumps when short page -

my sticky header causes page jump when page isn't long. on pages large amounts of scrolling works fine when small amount jumps point of stick. think gets trapped in between point sticks , transition part. #header{ width: 100%; height:100%; } .headertwo{ width: 100%; height: 48px !important; background: url(../images/work/topsky.jpg) no-repeat; background-size: 100%; } #header_stick{ width: 100%; height: 80px; margin-top: 16px; font-size: 16px; background-color: white; -webkit-transition: .25s ease; -moz-transition: .25s ease; -o-transition: .25s ease; -ms-transition: .25s ease; transition: .25s ease; } #header_stick img{ margin-top: 1px; width: 120px; -webkit-transition: .25s ease; -moz-transition: .25s ease; -o-transition: .25s ease; -ms-transition: .25s ease; transition: .25s ease; } .stick { position:fixed; top:0; height: 51px; margin-top: 0px; font-size: 1

c# - Consuming a DLL(Universal Apps) from a WinRT Component -

i have c++ (native code) dll project developed ios , android. port c++ dll (universal apps) consumed c# universal store application. code isn't hw dependent. as first step, before moving code, created small test solution follows: i created c++ dll (universal apps), mydll, has c++ add1(int, int) function. i created c++ winrt component (universal apps) has c++ add2(int, int) function. i created c# universal application, myapp, calls add2 calls add1 . compilation passes ok, when run myapp application crashes , report mydll wasn't loaded. my questions are: is scenario described above possible? , if so, can problem causing myapp crash? is there better way me port ios/android c++ code consumed in c# universal application? thx 1) hans, first guess you're not including dll in apps package. if it's not deployed in package isn't available loaded. since can't add reference dll you'll need add explicitly: add files project, open fil

Reading a value from a session variable into a local variable in Coldfusion -

i hope can me. read session variables local variable, don't have create endless read locks. came across interesting behavior. note have not applied write locks brevity's sake: consider following: example 1: <cfset session.testvalue = 1 /> <cfset lcktestvalue = session.testvalue /> <cfoutput>#lcktestvalue#</cfoutput><br /> <cfset session.testvalue = 2 /> <cfoutput>#lcktestvalue#</cfoutput> output: 1 1 example 2: <cfset session.testvalue1.item = 1 /> <cfset lcktestvalue1 = session.testvalue1 /> <cfoutput>#lcktestvalue1.item#</cfoutput><br /> <cfset session.testvalue1.item = 2 /> <cfoutput>#lcktestvalue1.item#</cfoutput> output: 1 2 i trying work out why second example, updates 'lcktestvalue1.item', when value read once? have expected example 1 & 2 produce same output, , following produce second example's output: example 3: <cfset

ios - Add deprecation to a Core Data object or attributes -

we making big change our core data model. there couple of attributes don't want use anymore. example, following values someobject . however, don't want remove values our core data yet because using everywhere in our project. i wondering whether possible add deprecation tag of attributes in core data, warning whenever use them. @interface someobject : _someobject // ... @end @interface _someobject : nsmanagedobject {} @property (nonatomic, strong) nsnumber* values; // , massive amount of auto-generated code core data @end and saw post how flag method deprecated in objective c . , tried adding deprecation tag inside _someobject.h such as: @interface _someobject : nsmanagedobject {} @property (nonatomic, strong) nsnumber* values __attribute__((deprecated)); // , massive amount of auto-generated code core data @end and works way want have 'values' deprecated warnings on place. able focus on these warnings , fix of them before our next ship. 1 thing do