Posts

Showing posts from 2010

Powershell Get-ADgroup show member names inline -

i've got script lists groups details. amongst others members. default members shown dn's. how can show names (eg jon doe, jane doe, ...). currently code goes follows: $groups = get-adgroup -filter * -searchbase $searchbase -properties $groupcolumns | where-object {$_.groupcategory -eq "distribution"} | sort-object name | select-object $grouptableheader this returns groups columns want. members-column content shown cn=john doe,ou=users,dc=company,dc=com cn=jane doe,ou=users,dc=company,dc=com thanks in advance help you issue get-adobject each member , name expensive operation. can use regular expression extract names: $_.member -replace '^cn=([^,]+).+$','$1' the above captures after 'cn=' until first comma, , replaces whole string match.

vb.net - RightToLeft RichTextBox with pre-loaded text -

Image
ok found strange type of bug in ms default richtextbox in vb.net 2008. if add line of text in richtextbox programmaticlly. there gape right side. see image below here code private sub button1_click_1(byval sender system.object, byval e system.eventargs) handles button1.click dim f new form dim rtb new richtextbox f.width = 500 f.height = 500 rtb.righttoleft = windows.forms.righttoleft.yes = 1 20 rtb.appendtext("بسم اللہ الرحمن الرحیم" & vbnewline) next rtb.dock = dockstyle.fill f.controls.add(rtb) f.show() end sub i can't explain it, try changing order of code richtextbox control added form before append text. worked me: private sub btn1_click(byval sender object, byval e eventargs) handles btn1.click dim f new form f.width = 500 f.height = 500 dim rtb new richtextbox rtb.name = "rtb" rtb.dock = dockstyle.fill rtb.righttoleft = righttoleft.yes f.controls.add(rtb) = 1 2...

iphone - Objetive c - proper way to set subview frame so it will fill the screen -

i have viewcontroller inside of navigationcontroller, view controller has tableview. in viewdidload set tablview - (void)viewdidload { [super viewdidload]; // init tableview cgrect tableframe = self.view.bounds; _tableview = [[uitableview alloc] initwithframe:tableframe style:uitableviewstyleplain]; _tableview.delegate = self; _tableview.datasource = self; [self.view addsubview:_tableview]; } the problem code table view frame not correct - height 460 , need 416. [the iphone screen height 480, minus status bar (20) minus navigation bar (44) = 416] so proper way set table view fill screen? can think of 2 ways: set frame = (0, 0, 320, 416) use: [_tableview setautoresizingmask:(uiviewautoresizingflexibleheight | uiviewautoresizingflexiblewidth)]; don't use magic numbers. use resizing flags correctly. yes, 2. approach correct. 1) use superviews bounds. _tableview.frame = self.view.bounds; ; 2) set autoresizing flags [_t...

sql server - Manually rename tabs in SSMS -

i'm getting confused tab in sql server management studio 2008 r2. don't find default naming scheme of tabs intuitive. there way can manually rename them? then don't use tabs, switch window view: from menu: tools - options in dialog box, environment - general: click on "mdi" environment radio button i fought tabs , gave up, works better me. tabs show first few characters, ends being beginning of database name, usless me. can use menu - "window" see list of windows.

ruby on rails 3 - resque no longer starts "Can't assign requested address - connect(2)" -

since few days i'm unable start resque have tried debugging issue on kinds of ways no result ! knows solution? kind regards this log output from: bundle exec rake resque:start log: bundle exec rake resque:start --trace ** invoke resque:start (first_time) ** invoke resque:workers:start (first_time) ** execute resque:workers:start rake aborted! can't assign requested address - connect(2) tasks: top => resque:work (see full trace running task --trace) *** starting worker dev2.local:4323:critical,high,low ** [09:01:12 2012-06-15] 4323: registered signals ** invoke resque:scheduler:start (first_time) ** execute resque:scheduler:start rake aborted! can't assign requested address - connect(2) tasks: top => resque:scheduler (see full trace running task --trace) 2012-06-15 21:01:20 schedule empty! set resque.schedule ** invoke resque:web:start (first_time) ** execute resque:web:start /users/jordan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:346:in `op...

ios - Test my Titanium application on multiple iPhone devices not via iTunes? -

i'd test application made titanium mobile on multiple devices. the issue is, not care whatever happen on iphone, not on other iphones. actually, have 1 iphone, need test on more several devices (iphone, iphone 4, ipad, ipod) borrow of them friends. since friends not want me mess devices up, need test no trouble such losing applications data. and did research this, , understand if import application devices through right way formally recommended appcelerator, devices lose individual data because it's implemented via itunes. is there way achieve testing ? i appreciate if show way. many in advance. you should try out ad distribution : with ad hoc distribution can share application 100 other ipad, iphone, or ipod touch users. through email or posting website or server, users can download , install app. or check out testflight a free testing service mobile developers, managers , testers.

javascript - Unable to return an image stream using Struts2 Ajax (Dojo) -

using struts2 2.2.3, tomcat 7 i'm trying show personal profile information (name, address, etc. plus photo) individual dynamically when user selects name list. i'm having trouble returning , displaying photo when use ajax (dojo) calls. some of photos held in db (and not in file), want return , display photos image stream. can return , display image stream (using action stream result) when send tomcat non-ajax request page containing this: <img id="photo" src= "" /> <script type="text/javascript">document.getelementbyid("photo").src = "profilephotoaction?mynumber=" + new date().gettime();</script> the script gets executed, action found, , stream returned. however, when trigger ajax request content includes above within sx:div, script not executed; i've tried 'executescripts' attribute of sx:div set both true , false. i've tried build img tag in other ways well, example: <img ...

asp.net mvc 3 - Save a value to Database - MVC -

i trying save value in "usercontroller" cannot seem tog et save database. i can database value stored in usercontroller change when value submitted , view refreshed looks though stored. (ie. changing test tested) however, refresh page again returns previous value , database shows no change throughout this. usercontroller: var g = httppost.vanityurl; db.ppuser_edituser(g); ppuser_edituser in ppuser: public ppuser ppuser_edituser(string personvanity) { ppuser user = sessionuser.loggedinuser.person; user.vanityurl = personvanity; basedb.submitchanges(); return user; } editprofile view: <div> @html.labelfor(m => m.vanityurl, "edit custom url:") @html.textboxfor(m => m.vanityurl, new { maxlength = 15 }) </div> basedb: public partial class studiokit_mvc3repository : idisposable { private studiokit_mvc3modelsdatacontext _basedb; public studiokit_mvc3modelsdatacontext basedb...

How can I make firefox render PNG with correct colors? -

Image
firefox 12 renders image below in paler colors while chrome 19, opera 11, safari 5 , ie9 render correctly. the image on left original png uploaded stackoverflow while 1 on right screenshot snippet of firefox's rendering: when view question page on firefox still see difference. believe firefox applies same color transformation it's own rendering (saved snip tool) too. don't see rendering difference on stackoverflow logo. i tried both paint.net's saved png , output of optipng, results same. troubleshooting hints appreciated. the png image has gama chunk, rendering depend on whether thing doing rendering supports gamma correction pngs. firefox support this. other browsers may not.

c# - WPF Event Handler in Another Class -

i have built series of event handlers custom wpf controls. event handles format text displayed when user enters or leaves textbox based on type of data contained (phone number, zip code, monetary value, etc.) right have of events locally in c# code directly attached xaml. because have developed controls, means logic repeated lot, , if want change program-wide functionality have make changes everywhere event code located. i sure there way put of event handlers in single class. can point me in correct direction? i saw article: event handler located in different class mainwindow i'm not sure if directly relates i'm doing. rather make small changes existing logic have, works, rewrite commands. i if possible: lostfocus="expandedtextboxevents.textbox_lostfocus" it easy enough this: private void textboxcurrencygotfocus(object sender, routedeventargs e) { expandedtextboxevents.textboxcurrencygotfocus(sender, e); } private void textboxcurrencylostf...

objective c - for a strong collection instance, is assign it to nil equals to release it and assign to nil? -

so have strong collection variable x (of type nsmutablearray e.g.), when doing dealloc, if x = nil, same effect following? [x removeallobjects]; [x release]; // not needed in arc x = nil; strictly speaking, 2 not identical. setting strong variable nil indeed release object. however, array removeallobjects if getting destroyed. if variable holds strong reference array, stay alive , not remove items contains.

c# - Calling a service via Ajax Request -

i trying yo make call service it's not finding reason , think because not calling right way: how can add response possible error?, better idea.. getting call failed because have in both functions: function successfunc(response) { if (200 == response.status) { alert("call success"); } } function failurefunc(response) { alert("call failed"); } in order clients accessing web service through ajax, have add attribute declaration web service: [system.web.script.services.scriptservice()] you can read more @ scriptserviceattribute class

Redis lua scripting - What is the python equivalent of the lua script written in Ruby? -

i not know ruby know python. python equivalent running below code? example taken redis website. so, this? <<eof? would in python: randompushscript = """ lua code here """ randompushscript = <<eof local = tonumber(argv[1]) local res math.randomseed(tonumber(argv[2])) while (i > 0) res = redis.call('lpush',keys[1],math.random()) = i-1 end return res eof r.del(:mylist) puts r.eval(randompushscript,1,:mylist,10,rand(2**32)) the << indicates heredoc. after there marker (here eof ). next lines string, until marker appears again. yes, """ python equivalent.

Android Drawable, receiving image from a socket -

i'm receiving image through socket in android aplication, did debugging , when i'm going save image in drawable d, program waits happens. think has have relation clientsocket.getinputstream(); or socket. have multithreading server in c++ , when stop server, android aplication continues , can see image sent before. but, think it's not server problem, because socket in server send data , shows message printf("bytes enviados %d\n", bytesenviados); @ end of server code. here have code: public drawable mandamensajevideo(string mensaje, string ip, int puerto ) throws ioexception{ socket clientsocket = new socket(ip, puerto); dataoutputstream outtoserver = new dataoutputstream(clientsocket.getoutputstream()); outtoserver.writebytes(mensaje); outtoserver.flush(); inputstream inputstream = clientsocket.getinputstream(); drawable d = drawable.createfromstream(inputstream, null); clientsocket.close(); outtoserver.close(); ...

SQL Join Problems -

i'm having problem assume related join in sql statement. select s.customer 'customer', s.store 'store', s.item 'item', d.dlvry_dt 'delivery', i.item_description 'description', mj.major_class_description 'major description', s.last_physical_inventory_dt 'last physical date', s.qty_physical 'physical qty', s.avg_unit_cost 'unit cost', [qty_physical]*[avg_unit_cost] value argus.delivery d join argus.store_inventory s on (s.store = d.store) join argus.item_master on (s.item = i.item) join argus.minor_item_class mi on (i.minor_item_class = mi.minor_item_class) join argus.major_item_class mj on (mi.major_item_class = mj.major_item_class) s.last_physical_inventory_dt between '6/29/2011' , '7/2/2012' , s.customer = '20001' , s.last_physical_inventory_dt not null it comes seemingly infinite amount of copies of 1 ...

django - I can seem to get right the urlconf line for my absolute path -

i've been trying various combinations write url absolute path of single blog posts @ page. here need right: mypage.com/blog/2012/6/dasdf/ this not working, tried named groups ?p : (r'^\d{4}/d{1,2}/(?p<path>.*)/$', detail), can show me how should done can see wrong? p.s here error the current url, blog/2012/6/dasdf/, didn't match of these. thanks in advance. i guess you're missing 'blog' argument path. furthermore, recommend try restrictive allowed characters, since know can expect receive in url. don't know how imported 'detail', want refer 'application.views.detail'. named arguments make sure can change order of arguments in future. i guess should work: (r'^blog/(?p<year>([0-9]{4}))/(?p<month>\d{1,2})/(?p<path>[a-za-z0-9-]+)/$', 'application.views.detail'), otherwise, i'd suggest checking whether url have created matches urls django provides error message. ...

osx - How to add slash after autocomplete for symbolic link in Mac os Terminal? -

i have problem, after ln -s point1 point2 when try point1 , put "tab" button - need adding "/" autocomplete, if symlink point directory. use mac os terminal. is possible? thank you! as far know depends on autocompletion of shell using. if using bash (which if did not change shell) at answer question

xml - How can I Import data (text) from a word document into a SQL Server database? -

i have huge word document data contact details people. there close 350000 such contact details needs inserted database. how do this? convert xml , database, or should use scripting language parse word data , insert database? parse word document using scripting language perl. covert xml or txt. once done can import data database. refer following link more help: convert word doc or docx files text files?

jquery - JSON object sort in Javascript -

i have json object jobj=json.parse(jsnstr) array returned json.parse , wish sort name. have used jobj=$(jobj).sort(sortfunction); function sortfunction(a,b){ return a.name.tolowercase() > b.name.tolowercase() ? 1 : -1; }; but didnt work out instead getting undefined obj help? you can't sort hash; must array. can setup reference of each a.name value array , sort array custom function have there. json = json.parse(...); var refs = []; for(var in json) { var name = i.name; refs.push({ name : name.tolowercase(), object : }); } var sorted = refs.sort(function(a,b) { return a.name > b.name; }); now in refs array sorted , can access each object individually sorted[index].object.

sql - Datetime and Integer functions on Varchar fields -

we refactoring weird system within backend, values should stored number , date columns, propperly designed constraints, stored varchar (using ui validation). thing is, while new system our ones must start run so: is possible manipulate varchar columns integer say lower or greater comparisons and, given dates stored same format dd/mm/yyyy possible treat varchar column date , use functions as: in between? would work: select column1, column2 table convert(datetime, datecolumn, 3) between @startdate , @enddate

tfs - BuildAgent working directory in distributed environment -

i've got build controller running 2 agents (agent1, agent2) on same machine. i've installed build agent (agent3) on different machine inside same ad. now when comes agent3 error, agent3 can not access share on \buildagentmachine\build. agent1 , agent2 have working directories: d:\builds\$(buildagentid)\$(builddefinitionpath) (where d:\builds local folder on build controller shared via network). agent3's working directory is: $(systemdrive)\builds\$(buildagentid)\$(builddefinitionpath) on local hard drive. now whats funny beside: on build controller computer following folders under d:\builds: 1 2 3 projectname looks agent3 putting stuff directly under \controller\builds means, write access enabled agent. if error accessing share, sure it's not erroring out when build tries copy build outputs build drop share? make sure user account build agent 3 configured run same 1 used build agents 1 , 2. can check in tfs admin console on build agent m...

c++ - Changing last 5 char of array -

i have program encrypts files, adds extension ".safe" end. end result "file.txt.safe" when go decrypt file, user enters file name again: "file.txt.safe" saved char. want remove ".safe" , rename file original name. i have tried following, nothing seems happen , there no errors. decrypt (myfile); //decrypts myfile char * tmp = myfile; char * newfile; newfile = strstr (tmp,".safe"); //search tmp ".safe" strncpy (newfile,"",5); //replace .safe "" rename (myfile, newfile); i'm sure i'm missing obvious, if approach doesn't work, i'm looking simple method. edited add: (copied moderator poster's response k-ballo) thanks everyone. took std::string approach , found work: decrypt(myfile); string str = myfile; size_t pos = str.find(".safe"); str.replace(pos,5,""); rename(myfile, str.c_str()); for want do, changing strncpy line work: *newfil...

dictionary - Add column in dict with partial key in python -

setting dict: rr = range(1,11) ft =[('sd:jan:'+ str(x), 'news') x in rr] fd = dict(ft) fd {'sd:jan:1': 'news', 'sd:jan:10': 'news', 'sd:jan:2': 'news', 'sd:jan:3': 'news', 'sd:jan:4': 'news', 'sd:jan:5': 'news', 'sd:jan:6': 'news', 'sd:jan:7': 'news', 'sd:jan:8': 'news', 'sd:jan:9': 'news'} fd.keys() ['sd:jan:10', 'sd:jan:2', 'sd:jan:3', 'sd:jan:1', 'sd:jan:6', 'sd:jan:7', 'sd:jan:4', 'sd:jan:5', 'sd:jan:8', 'sd:jan:9'] how add values of 'jan' in key? edit: adding values (1+2+3+4+5+6+...+10) partial key of "jan." how using generator expression : sum(int(i.split(':')[-1]) in fd.keys()) gives: 55 splits each entry : , g...

Access jackrabbit repository through Apache Sling -

i followed apache sling tutorials using launchpad . understood, uses built in jackrabbit repository within launchpad. there way access standalone jackrabbit repository using sling api without using launchpad? thanks. the embedded repository provided org.apache.sling.jcr.jackrabbit.server bundle, if bundle , ones requires active should corresponding slingrepository service, backed embedded jackrabbit repository.

c# - How can I auto-format text pasted into rich textbox? -

i have notes program use document cases while working, when copy , paste data other windows pastes in formating site. there setting rich text boxes (and text boxes in general) remove formatting , put text textbox? if not can have use method looks @ clipboard contents , sends string specific font/size etc? you should able unformatted string specifying textdataformat , set text : var stringtopastein = clipboard.gettext(textdataformat.text); or letting richtextbox automagically using dataformats options: dataformats.format myformat = dataformats.getformat(dataformats.text); richtextbox1.paste(myformat);

sql - PHP Abstraction Layer - Get class from name -

i'm writing simple database abstraction layer in php. i'm working on query builders, classes build sql "code". are there better ways doing this? if($dbengine == "mysql") { mysqlquerybuilder::buildinsert($table, $data); } else if($dbengine == "pgsql") { pgsqlquerybuilder::buildinsert($table, $data); } // , on... i'm thinking like: $querybuilder = get_class_from_name($dbengine . "querybuilder"); $querybuilder::buildinsert($table, $data); any ideas on how can this? you if want static: $statement = call_user_func(array($dbengine . 'querybuilder', 'buildinsert'), $table, $data); but agree niko comment, having instance of builder nicer. update: with way niko suggested, do: $classname = $dbengine . 'querybuilder'; $builder = new $classname(); $statement = $builder->buildinsert($table, $data); so no if s required @ all, code looks shorter , cleaner...

php - Speeding Up Image Loading from DB -

Image
i'm loading 9 images database , syntax looks this: <img src="image_loader.php?id=4"></img> my php image_loader.php looks like: <?php /* set connection using mysql_connect , mysql_select_db */ $query = sprintf("select ... ... id='".$_get["id"]."'"); $result = mysql_query($query, $con); mysql_close($con); if (!$result) { // no result } else { $row = mysql_fetch_row($result); header('content-type: image/png'); echo $row[0]; mysql_free_result($result); } ?> each image 10-13k bunch seems loading slow. realize there bottle-necking in number of requests browser can execute @ time wait times seem gratuitous. any suggestions on how images loaded database fast? also, , separate question, possible instruct browser (or server) cache images .gif/.png/.jpg srcs? seems firefox , chrome doesn't, i'm not of this. ...

Connection reset by peer java.net.SocketException: Transport endpoint is not connected -

i using nio threads in serversocketchannel opened , client port bind.but when tried read data socket chanel below mention exception displayed.it greatful if provides solution. connection reset peer java.net.socketexception: transport endpoint not connected @ sun.nio.ch.socketchannelimpl.shutdown(native method) @ sun.nio.ch.socketchannelimpl.shutdownoutput(socketchannelimpl.java:669) @ sun.nio.ch.socketadaptor.shutdownoutput(socketadaptor.java:386) @ iyp.trncomms.connrecordwriter.checkshutdown(connrecordwriter.java:131) @ iyp.trncomms.connrecordwriter.continuewriting(connrecordwriter.java:214) @ iyp.trncomms.connrecordwriter.retry(connrecordwriter.java:101) @ iyp.trncomms.connrecordwriter.shutdown(connrecordwriter.java:92) @ iyp.trncomms.connrecord$workingstate.toonholdstate(connrecord.java:1224) @ iyp.trncomms.connrecord$workingstate.oninputerror(connrecord.java:1152) @ iyp.trncomms.connrecord.read(connrecord.java:124) @ iyp.trncomms.ni...

qt - How to change color of focus rectangle of items in QTreeView? -

is possible change color of dotted focus rectangle items (rows consisting of multiple qstandarditems) in qtreeview ? in stylesheet qtreeview::item:focus not work and can't reimplement paint function in custom qitemdelegate since overrides stylesheet settings. thanks in advance qtreeview::item:selected works me: #include <qtgui> int main(int argc, char *argv[]) { qapplication app(argc, argv); qfilesystemmodel model; model.setrootpath(qdir::currentpath()); qtreeview tree; tree.setmodel(&model); tree.setallcolumnsshowfocus(true); tree.setstylesheet("qtreeview::item:selected { border-color:green; " "border-style:outset; border-width:2px; color:black; }"); tree.show(); return app.exec(); }

android - TimerTask doesn't take effect -

here's code: public class somename extends mapactivity implements onclicklistener, ontouchlistener{ public timer t1 = new timer(); public timertask tt; public long interval = 5000; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.map); timer(); } public final void timer() { t1 = new timer(); tt = new timertask() { @override public void run() { systemclick(); } }; t1.scheduleatfixedrate(tt, 10000, interval); } public void systemclick() { toast.maketext(getapplicationcontext(),"system button clicked", 5).show(); } actually, want call function, refresh location. but can't understand why never toast on screen. i'm new android. thanks help. use handler in activity final handler handlerforadd = new handler(); runnable runnableforadd = new runnable() { ...

java - How to design an extendable HTML form without JavaScript? -

designing , processing form user can add arbitrary number of new input fields tedious without using javascript . currently doing following: using two different submit buttons in form, 1 adding new input field , 1 submitting form results database request. the used method post for adding new input fields use get since 2 methods in 1 form not possible have in post request. making 1 type of input field rather easy, when need sub-forms (some groups of input fields in same form), becomes not tedious, error-prone ! i not satisfied, there more intelligent way realize without starting write lot of processing code , doing redirection or @ least ease implementation reduce error risk! also, maybe there solution provided java solve generically elegant, since using java servlets . with javascript turned on offer separate solution, concerned fall solution, not normal case. see, working without javascript severely restrict abilities: have rely upon standard http request/...

tcl - set date to 90 days from current unix timestamp -

hi want set future_date variable show date 90 days today. set $future_date "" #set $future_date date in unixtime stamp 90 days current timestamp can in tcl? in tcl, clock seconds command returns time in term of seconds. add 90 days it, have multiply 90 60 (seconds in minute), 60 (minutes in hour) , 24 (hours in day): set today [clock seconds] set future [expr {$today + 90 * 60 * 60 * 24}] puts [clock format $today -format "today %b %m, %y"] puts [clock format $future -format "90 days today %b %m, %y"] please clock command more information.

java - Possible memory leak with StringBuilder? -

i using stringbuilder create file object, using see if directory file located inside of exists: stringbuilder sbfile = new stringbuilder(); sbfile.append("/home/logs/"); file ofile = new file(sbfile.tostring()); if(!ofile.exists()) ofile.mkdir(); sbfile.append("mylogfile.log"); ofile = new file(sbfile.tostring()); but worried reusing same ofile reference on 2 different "versions" of string builder ( /home/logs/ vs /home/logs/mylogfile.log ) create memory leak. if so, how should write differently? there no memory leak. instance of file created first time, garbage-collected jvm when no longer used. the other thing don't need use stringbuilder . file class has constructor takes parent , filename. example this: file parent = new file("/home/logs/"); if(!parent.exists()) parent.mkdir(); file file = new file(parent, "mylogfile.log"); // todo: file... also, may interested in how garbage collectio...

android - Only Four Options For ShareActionProvider With ActionBarSherlock -

Image
i trying share plain text while using share action provider via actionbarsherlock , there 4 options share , no "see all..." option. why that? this looks like: and want like: ok regardless of actionbarsherlock first test see if creating intent correctly, abs uses same code generic chooser see if app's looking show when execute code. intent i= new intent(intent.action_send); i.settype("text/plain"); i.putextra(android.content.intent.extra_text, "my test text"); startactivity(intent.createchooser(i,"share using ...")); all of app's handle plain text show up, if facebook, or whatever expecting not there app's don't support action_send intent type have registered (plain/text). (facebook does, more in minute) abs has sample using share action provider try's send photo, not text message (status update) setup should using @override public boolean oncreateoptionsmenu(menu menu) { //...

Where should i create django apps in django 1.4? -

i've started new project in django 1.4 , since they've changed default layout manage.py , whole folder hierarchy (see https://docs.djangoproject.com/en/dev/releases/1.4/#updated-default-project-layout-and-manage-py ) cannot decide should put app packages - inside mysite or outside it? what's best practice? reason, startapp command creates app outside of mysite package, feels somehow wrong. so, what's best? this: manage.py mysite/ __init__.py settings.py urls.py myapp/ __init__.py models.py or this: manage.py myapp/ __init__.py models.py mysite/ __init__.py settings.py urls.py ? the second way. manage.py myapp/ __init__.py models.py mysite/ __init__.py settings.py urls.py

javascript - Unexpected results when multiplying window.innerHeight by a nonwhole number in Firefox -

Image
firstly, i'm no means web designer have little idea i'm doing. i'm working on html/javascript unity webplayer application trying make webplayer take (not all) of browser's viewable area. <body> of page set have no margins nor scroll bars so, <body margin="0" marginwidth="0" marginheight="0" scroll="no"> i'm getting values browser's viewable area this, winwidth = window.innerwidth; winheight = window.innerheight; and call unity webplayer this, unityobject.embedunity("unityplayer", "webplayer.unity3d", winwidth, winheight, params); everything seems work setup. however, when multiply winwidth , winheight non-whole numbers (i.e., 0.5 or 1.9) height not scaled in firefox 12. regardless of value put in there, it's same (wrong) vertical height. in picture, both innerheight , innerwidth multiplied 0.9 and, can see, height wrong—and wrong height no matter non-whole num...

ipad - lay out a view in Storyboard then load it in a PopOver from code? -

Image
i have relatively complex ui appearing in popover (complex enough doing layout , relationships code pain), button calls created , placed parent view (which exists in storyboard) code. i've tried making popover segue parent view's viewcontroller object popover content vc, triggering performseguewithidentifier. works, can't figure out how set popover's anchor code appears @ wrong place (squished @ bottom of screen). is there way set popover segue's anchor dynamically? or can create uipopovercontroller object , view i've put in storyboard it? or there other obvious way i'm not seeing? please gentle, i'm new here. ipad ios5.1 xcode4.3.2 alex, i'm not sure understand you're trying do, let me take stab @ think understand. for same reason cite (view complexity, etc.), build out views in storyboard , load them action. can instantiate view controller identifier this: fancyviewcontroller *controller = [[self storyboard] ...

c++ - Win32-Based Applications, trying to update the text of the label -

this code displays window text label saying: "please enter number", , button. when click button should replace text " text ". works, writes/prints new text on top of first text. overlapping. i want string of text change instead of writing on first one, don't know how i'm new windows application development. please me out guys. the whole source is: #include <windows.h> #include <iostream> using namespace std; enum { id_label = 1,id_button0}; static hwnd static_label, button0; hdc hdc; hbrush newbrush; hinstance g_hinst; lresult callback wndproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam); int winapi winmain(hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int nshowcmd) { lpctstr classname = text("myclass"); wndclassex wc; wc.cbsize = sizeof(wc); wc.style = cs_hredraw | cs_vredraw; wc.cbwndextra = 0; wc.cbclsextra = 0; wc.lpfnwndproc ...

Hive QL Except clause -

how do except clause (like sql) in hive ql i have 2 tables, , each table column of unique ids, want find list of ids in table 1 not in table 2 table 1 apple orange pear table 2 apple orange in sql can except clause (http://en.wikipedia.org/wiki/set_operations_%28sql%29) can't in hive ql i don't think there's built-in way left outer join should trick. this selects ids table1 not exist in table2 : select t1.id table1 t1 left outer join table2 t2 on (t1.id=t2.id) t2.id null;

ASP.NET Form Authenticaion -

i have created asp.net project , connect database. after added login , register control. like: <asp:login id="login1" runat="server" destinationpageurl="~/users/useraccount.aspx"> </asp:login> actually works! registration , login operation. how? code, sql statement? don't see related that. please explain me how works? , how modify registration control if need information. thanks! those built in controls part of framework. take @ link if wanting make more of custom registration process. http://msdn.microsoft.com/en-us/library/aa478962.aspx it may understand whats going on.

java - Oracle column name issue -

i have parent-child mapping in hibernate entities connected through table. the problem column automatically created hibernate in table called "_actions_id" . use oracle , says column name "_actions_id" invalid. it works fine when wrap name "" , execute script manually, there way make hibernate wrap columns "" ? in example, specified join table, scenarios this people table: pid | name 1 | albert 2 | bob telephonenumbers table: tid | tel 1 | 123-456 2 | 456-789 3 | 789-012 join table: pid | tid 1 | 1 1 | 2 2 | 3 i.e. column connects current entity entity in collection in neither current table nor table collection entity. more useful many-to-many mapping, can use onetomany if don't have control on telephonenumbers table example. otherwise should use plain @joincolumn . the usage of @jointable has been explained many times many websites. see javadoc , this question .

iOS In App Purchase - Store Credits -

i implementing in-app purchases in app allows download , read articles. rather having product identifier every single article, rather sell "credits", i.e, credit pick 5 articles, or 10, etc. apple's guidelines state: 11.4 apps use iap purchase credits or other currencies must consume credits within application 11.5 apps use iap purchase credits or other currencies expire rejected i not sure how interpret 11.4. application indeed consume credits make purchases, in reality tracked server. know if type of system allowed? yes, want allowed. 11.4 means can't following: 1) sell 100 credits $0.99. 2) save information user has 100 credits server, , then 3) let user use credits on website, or other application other ios app, purchase things. does make sense? :)

git - Efficient retrieval of releases that contain a commit -

in command line, if type git tag --contains {commit} to obtain list of releases contain given commit, takes around 11 20 seconds each commit. since target code base there exists more 300,000 commits, take lot retrieve information commits. however, gitk apparently manages job retrieving data. searched, uses cache purpose. i have 2 questions: how can interpret cache format? is there way obtain dump git command line tool generate same information? you can directly git rev-list . latest.awk : begin { thiscommit=""; } $1 == "commit" { if ( thiscommit != "" ) print thiscommit, tags[thiscommit] thiscommit=$2 line[$2]=nr latest = 0; ( = 3 ; <= nf ; ++i ) if ( line[$i] > latest ) { latest = line[$i]; tags[$2] = tags[$i]; } next; } $1 != "commit" { tags[thiscommit] = $0; } end { if ( thiscommit != "" ) print thiscommit, tags[thiscommit]; } a sample comman...

C# asp.net: Cookie Expiration date in Chrome -

i'm having issue expiration date of cookie in c# when in chrome. here code i'm using: public static void createcookie(users u, datetime expirationdate) { httpcookie logincookie = new httpcookie("cookie"); logincookie.value = "somevalue"; logincookie.expires = datetime.utcnow.adddays(1d); httpcontext.current.response.cookies.add(logincookie); } i've run code through fiddler , return correct expiration date. cookie's expiration date correct in firefox , ie9 however, when run in chrome expiration date set to: sun, 07 dec 1969 03:28:36 gmt always @ 3:28:36 gmt never changes. idea on why happening appreciated. thanks! i've tried set expiration date using: datetime.now.adddays(1d) same result. it's bug in current version of chrome, it's displaying of expiration date wrong, not actual expiration, value have set honored chrome! here's link bug has been fixed in nightly builds (verified fixed 20.0.1132....

reverse engineering - What's debug section in IDA Pro? -

i try analyze dll file poor assembly skills, forgive me if couldn't achieve trivial. problem that, while debugging application, find code i'm looking in debug session, after stop debugger, address gone. dll doesn't obfuscated, many of code readable. take @ screenshot . code i'm looking located @ address 07d1ebbf in debug376 section. btw, did debug376 section? so question is, how can find function while not debugging? thanks update ok, said, stop debugger, code vanished. can't find via sequence of bytes (but can in debug mode). when start debugger, code not disassembled imediately, should add hardware breakpoint @ place , when breakpoint hit, ida show disassembled code. take @ screenshot see line of code i'm interested in, not visible if program not running in debug mode. i'm not sure, think it's unpacking code @ runtime, not visible @ design time. anyway, appreciated. want know why code hidden, until breakpoint hit (it's shown "db 8...

gdb - how could the const char * changed? -

i writing program can print directory recursively, below gdb debug segment note d_path (it const char * passed parameter print_dir_tree) "/home/cifer/.gftp" before step "if (dr == null) {" however, printed "/home/cifer/!\200" after clause who can tell me why? lot! breakpoint 1, print_dir_tree (d_path=0x805b058 "/home/cifer/.gftp", depth=4) @ dir_demo.c:15 15 dir *dr = opendir(d_path); (gdb) print d_path $2 = 0x805b058 "/home/cifer/.gftp" (gdb) print d_path $3 = 0x805b058 "/home/cifer/.gftp" (gdb) step 16 if (dr == null) { (gdb) print d_path $4 = 0x805b058 "/home/cifer/!\200" (gdb) step 20 struct dirent *de = null; (gdb) print d_path $5 = 0x805b058 "/home/cifer/!\200" (gdb) step 21 while((de = readdir(dr)) != null) { (gdb) print d_path $6 = 0x805b058 "/home/cifer/!\200" (gdb) i need see code tell sure if asking if const can changed ans...

c++ - Get the status of a std::future -

is possible check if std::future has finished or not? far can tell way call wait_for 0 duration , check if status ready or not, there better way? you correct, , apart calling wait_until time in past (which equivalent) there no better way. you write little wrapper if want more convenient syntax: template<typename r> bool is_ready(std::future<r> const& f) { return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready; } n.b. if function deferred never return true, it's better check wait_for directly in case might want run deferred task synchronously after time has passed or when system load low.

android - Best way to freeze and application while the database is doing some heavy background work? -

i have background service heavy lifting within transaction once day. if user happens start app @ time, want them sit tight till finishes (around 10 secs or so). what's best way across activities? check if service running in "onresume" function of each activity? , how know when it's done? local broadcasts i'm guessing... best practices anyone? update: i've managed stall "onresume" till service done. problem user sees blank screen till then. i've tried progressdialogs , regular dialogs while onresume paused. display when onresume returns , defeats purpose. in other words, progress dialog doesn't "show" after "show()" called :( local broadcasts good. have activities question service if busy or not, , display appropriate message user before finishing activity. once service done, have send intent finished.

Can cakephp have multiple 'content'? -

so in cakephp's layout have the $this->fetch('content') right? mean can have 1 'content' in 1 layout? need multiple content multiple controller can done? how? please me!!! the layout isn't capable of pulling information controller. controller place view prepared placed within layout. when access cakephp url, it's in following format: http://example.com/controller/action in other words, you're connecting directly controller, not layout. you use controller data models , when ready set view , view displayed, layout wrapped around it. so, put html/css etc in layout if want appear in of views. to answer question, though, controllers don't have content. content (presumably) in database. databases accessed using models , it's possible pull data multiple models using single controller, done defining relationships between multiple models.

ruby - How to bind enum value to a field in rails -

i have created enum field in database. want bind field view in such way shows available values selection. in case male , female. t.enum :sex ,:limit => [:male, :female] edit: sql generated: started put "/profiles/3" 127.0.0.1 @ 2012-06-04 22:11:35 -0700 processing profilescontroller#update html parameters: {"utf8"=>"?", "authenticity_token"=>"ijgsa4rfvebc/lwd6pi69rj5o0rxmpntu7pavqk5hpm=", "profile"=>{"firstname"=>"huzaifa ", "sex"=>"female"}, "commit"=>"update profile", "id"=>"3"} [1m[36mprofile load (1.0ms)[0m [1mexec sp_executesql n'select top (1) [profiles].* [profiles] [profiles].[id] = @0', n'@0 int', @0 = 3[0m [["id", "3"]] [1m[35msql (0.0ms)[0m begin transaction [1m[36mcache (0.0ms)[0m [1mselect @@trancount[0m [1m[35msql (0.0ms)[0m commit transaction redire...

javascript - Loop PHP forms a chosen number of time from drop box -

<div id="form1" /> <form name="choice"> <table> <tr> <td> number of new types want add </td> <td> <select name="<?php echo $num; ?>"> <option value="1" selected>1 row</option> <option value="2">2 rows</option> <option value="3">3 rows</option> <option value="4">4 rows</option> <option value="5">5 rows</option> </select> <div class='inputs'></div> </td> </tr> </table> </form> <form name="myform" action="addacc...

python - Django Generic Views Date-Based URLconf -

trying teach myself django running snag. generic views seem great idea find documentation little cryptic @ times (maybe i'm being prissy). have been trying use date based generics views in , archieveindexview. i have attempted following non-djangoproject.com examples , still have problems. used example provided @ this site. here current project/urls.py . @ point, not worrying pattern matching, trying work. from django.conf.urls import patterns, include, url django.views.generic.dates import archiveindexview blog.models import entry django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', archiveindexview.as_view('date_field': 'pub_date', 'queryset': entry.objects.all())), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), ) with setup keep receiving invalid syntax error @ line describing archiveindexview c...

javascript - How can I trigger the upload file with Valums Ajax File-Uploader? -

when using valums ajax file uploader, how can trigger upload? the default behavior upload begin after user selects file. want prevent happening, , instead trigger upload when user clicks separate "upload" button after have selected file. i looked through code , found upload begins on change event attached file input. began adding return false; to onsubmit function, , attaching click event button triggered change event: $('#startupload').on('click', function() { // conditionals $('input[name="file"]').trigger('change'); }); that doesn't work. opens file menu again. how can prevent upload occurring after user selects file , instead trigger when user clicks button? you have modify file-uploader.js file this. in line 309, modify onchange function return false. add following function above it, code becomes: startupload: function(){ this._oninputchange(this._button.getinput()); }, _createupl...

python - __del__method not executing when involving circular reference -

i find custom __del__ method seems not execute when circular referencing involved. here sample code: class delclass(): def __init__(self,a): self.prop = def __del__(self): print 'del' if __name__ == "__main__": dc1 = delclass(none) dc2 = delclass(dc1)#dc2 referring dc1 dc1.prop = dc2#dc1 referring dc2, creating circular reference del dc1#not executing custom __del__ method dc = delclass(1) del dc#executing custom __del__ method why happens? edit: brenbarn. found reason. del something decrements reference count of something 1. __del__ execute when reference count reaches 0. here test code: import gc class delclass(): def __init__(self,name,a): self.name = name self.prop = def __del__(self): print '#####deleting',self.name dc1 = delclass("dc1",none) dc2 = delclass("dc2",dc1)#dc2 referring dc1 dc1.prop = dc2#dc1 re...

php - how to specify values on $this->fetch() cakephp 2.1 -

we know $content_for_layout deprecated in cakephp 2.1 , changed $this->fetch('content'); wherever put fetch('content') contents of view layout tag viewed. my question example have view navigation(), contents of view placed on $this->fetch('nav_view'), , view main_board() contents on $this->fetch('main_board'), and 2 fetches outputted on same layout. possible?? somewhere in view/element/helper: $this->start('nav_view'); // render 'nav_view' stuff here echo $this->element('...'); $this->end(); render same content: // in layout $this->fetch('nav_view'); apparently, documented in cookbook, under using view blocks .

javascript - Multiselect dropdown option value taking only one word -

i have multiselect dropdown inside table <td> <select multiple="multiple" name="multiple" id="multiple" class="required"> </select> </td> the option values populated json data. for(var i=0;i<jsonstring.length;i++){ var name=jsonstring[i].name; $('#multiple').append('<option value=' + name + '>' + name + '</option>'); } when user start selection trying display each selected item inside paragraph <script> function displayvals() { var multiplevalues = $("#multiple").val() || []; $("p").html( " <b>selected properties:</b> " + multiplevalues.join(", ")); } $("select").change(displayvals); displayvals(); </script> but in paragraph 1 word per selection, not complete name. (say if select "some text" "some"). can point out er...

winforms - How to check if the Form object is till running with C# -

let's say, have 2 winforms here, form1 , form2 respectively. , made form1 hidden. wonder how write code in form2 detect if form1 object still running or not. i trying use form1.activeform seems give me null value. better ideas? thanks. you use method active forms: public static form isformalreadyopen(type formtype) { foreach (form openform in application.openforms) { if (openform.gettype() == formtype) return openform; } return null; }

javascript - Html5 Canvas Transformation Algorithm - Finding object coordinates after applying transformation -

on html5 canvas drawing objects (rectangle, circle, etc...), these objects have transformation properties scale, skew, rotation etc... these objects can nested. problem occurs when after applying transformations, want find exact x, y coordinate of given object, going on head. to experts interactive computer graphics; please me solve problem. thanks in advance. all affine transformations in 2d can expressed matrix of form: [ c dx ] t = [ b d dy ] [ 0 0 1 ] this expressed method context.transform(a, b, c, d, dx, dy); . when applied coordinate, (x,y) , first have add third coordinate, 1 : <x, y, 1> . can multiply transformation matrix result: [ a*x + c*y + dx ] [ b*x + d*y + dy ] [ 1 ] if other '1' in last coordinate, have divide vector it. to go other way, have invert matrix: [ d/m -c/m (c*dy - d*dx)/m ] [ b/m a/m (b*dx - a*dy)/m ] [ 0 0 1 ] where m (a*d - b*c) . multiple transfo...

c# - Open file with association -

i made file editor in c#, , can open files using 'open' button in toolbar, associated correct file types program, when click file extension *.nlp program opens correctly, not open file (which quite logical since did not implement yet) now question, how implement such thing? want file opened , loaded when click on it. (btw, file plain text, nothing special, , it's windows if matters) in windows file associations stored , managed in registry under hkey_classes_root you can following manually or write little setup program write correct entries registry. you need register extension , associate program this document describes. see this doc registry should this: hkey_classes_root .nlp (default) = yourprogid//can want yourprogid shell open command (default) = yourapp.exe %1 now , key answer %1 in command key. filename opened , passed argument app. so : static void main(string[] args) { // arg...

php - get nearest lat long around 25 km from given array lat long -

i have array of lat long : var locationlist = new array( '23.2531803, 72.4774396', '22.808782, 70.823863', '24.3310019, 72.8516531', '22.3073095, 73.1810976', '22.3038945, 70.8021599', '23.850809, 72.114838' ); i want nearest around 25 km 's lat long first given array 23.2531803, 72.4774396 are there calculation nearest 25 km 's lat long given array. note: reason can not use sql query, because lat long given address step 1: calculate distance between start coordinate , every subcoordinate step 2: pick smallest distance step 3: < 25 km? success! how calculate distance between 2 coordinates: function distance($lat1, $lon1, $lat2, $lon2) { $d = 6371; // earth radius $dlat = $lat2-$lat1; $dlon = $lon2-$lon1; $a = sin($dlat/2) * sin($dlat/2) + sin($dlon/2) * sin($dlon/2) * cos($lat1) * cos($lat2); $b = 2 * atan2(sqrt($a), sqrt(1-$a)); $c = 2 * atan2(sqrt($a), sqrt(1-$a)); return $d * $c; } ...

c# - JSON request returns object error using JQUERY -

i have aspx page returns valid json - when called via jquery can see in fiddler json returned error thrown [object error]. protected void page_load(object sender, eventargs e) { string json = "{\"name\":\"joe\"}"; response.clearheaders(); response.clearcontent(); response.clear(); response.cache.setcacheability(httpcacheability.nocache); response.contenttype = "application/json"; response.contentencoding = encoding.utf8; response.write(json); response.end(); } the html page consuming page in different domain, , using jsonp. function jsonpcallback(response){ alert(response.data); } $(document).ready(function(){ $.ajax({ url: 'http://localhost:30413/getprice.aspx', datatype: 'jsonp', error: function(xhr, status, error) { alert(error); }, success: jsonpcallback ...

php - How would you rate Open Street Maps reliability? -

i'm constructing geo location mobile app , i'm @ crossroads of api integrate with. guess 2 biggies google maps , open street maps. hear google start charging api in fall , i'm not sure app profitable then, i've decided go open street maps. the thing i'm wondering if open street maps reliable enough prime time. i've tried queries, , honest couldn't find couple of locations here in georgia. i've never had problem google maps. has has been using open street maps had problem it's reliability? i'm building ios app , know, ios doesn't have geocoder can tell latitude , longitude address, that's why have @ other alternatives. backend php making calls mapquest's nominatim implementation (no query limits) via curl if it's consolation. there conceptual difference between google maps , open street maps. former commercial product (even if @ moment free) provides access features clean, mature apis (geocoding, map tiles, client-si...