Posts

Showing posts from May, 2010

gridview - how to add checkbox column to Extjs Grid -

i have extjs grid. want know how add checkbox extjs grid column. in datatable i'll value column 'status'. may br either true/false. based on should show checkbox column checked / unchecked. have @ sample here . uses plugin called checkboxcolumn (you have view source , find js file. some example usage plugin's file... var checkcolumn = new ext.grid.checkcolumn({ header: 'indoor?', dataindex: 'indoor', id: 'check', width: 55 }); // add column column model var cm = new ext.grid.columnmodel([{ header: 'foo', ... }, checkcolumn ]); // create grid var grid = new ext.grid.editorgridpanel({ ... cm: cm, plugins: [checkcolumn], // include plugin ... });

How to set configuration parameters in clojure library? -

i writing clojure library , wondering best practice setting configuration parameters of library. many libraries (like in clojure-contrib) use global level parameter *buffer-size* user can set calling set! on them. not seems best way me creates global state , there chances of name collision. the other way pass parameters in every function call dependent on them. if there many parameters map of them can used instead of passing individual ones. as example, let's writing cache library. using first approach have global parameters *cache-size*, *expiry-time*, *cache-dir* etc. user set! s these (or not , let them default) , calls functions (set-in-cache id obj) , (get-from-cache id) . using second approach, user first create map of parameters , passes every call (def cache-parameters {:cache-size 1000 :expiry-time: 1440 :cache-dir "c:\\cache"}) (set-in-cache cache-parameters id obj) (get-from-cache cache-paramet...

java - h:dataTable problem - Target model Type is no a Collection or Array -

i've been literally struggling this, although there tons of tutorials on topic. i'm testing functionality of h:datatable component in jsf 2.0. have following list: <h:datatable border="1" styleclass="data zebra" value="#{testtablewb.testlist}" var="items"> <h:column> <f:facet name="header"> <h:outputtext value="id"/> </f:facet> <h:outputtext value="#{items.id}"/> </h:column> <h:column> <f:facet name="header"> <h:outputtext value="name"/> </f:facet> <h:outputtext value="#{items.name}"/> </h:column> <h:column> <f:facet name="header"> <h:outputtext value="...

zend framework - Good way to initialize pages using Zend_Navigation -

i reading on zend navigation , wondering whats way set up. where setup up? can using application.ini - may make application.ini long read. maybe using resource method? maybe plugin? do hardcode pages? eg. $pages = array( array( 'label' => 'home', 'title' => 'home page title', 'controller' => 'index', 'action' => 'index' ), array( 'label' => 'blog', 'title' => 'blog', 'controller' => 'index', 'action' => 'blog', 'pages' => array( array( in dynamic site seems smarter generate database, eg. child pages of blog generated blog categories? except want once? maybe must cache it? must make sure tho if new categories added, navigation updates. to make can add new pages cms ex. have put in database model. zend create function return array of categories , pages. ex. ...

hardware - Should a software engineer know how to assemble their own computer? -

coming mac background, i've never spent time tinkering / assembling / tweaking own computer beyond occasional ram upgrades , swapping out hard disks. feel have grasp on how computer works @ conceptual level, cpu, bus, memory etc, haven't got practical experience in putting / taking apart. my question is, there gained in terms of software engineering skills learning assemble own computer? if have spent whole life putting bits of hardware together, how has influenced way write or think software? you don't learn that's usefull programmer putting computer. knowing put pci cards , how plug in processor isn't useful apart building computers. i think need low level knowledge how computers work stuff that's interesting programmers soldered on mainboard. you'll learn more programming c or assembly , maybe reading charles petzold's book code...

sql - How do I disable validation in Web Data Administrator? -

i'm trying run queries rid of xss in our database using web data administrator keep running potentially dangerous request crap. how disable validation of query in web data administrator? go install directory of web data admin, usually: c:\program files\microsoft sql server tools\microsoft sql web data administrator then in "web" folder open file "querydatabase.aspx" , edit following line: <%@ page language="c#" codebehind="querydatabase.aspx.cs" autoeventwireup="false" inherits="sqlwebadmin.query" %> add validaterequest="false" end of so: <%@ page language="c#" codebehind="querydatabase.aspx.cs" autoeventwireup="false" inherits="sqlwebadmin.query" validaterequest="false" %> note : potentially dangerous!! careful!

How did my mysql database get deleted automatically? -

i sure didn't delete database , noone else sits on machine. how did database deleted automatically? had 10 tables in :(. infact 2 databases got deleted automatically. not being shown in mysql query browser. how can recover databases back? there query show logs see if delete schema command fired in mysql? frustrated. please help. last time saw these database alive before 2 weeks , today no more. could looking @ them different user credentials not have sufficient privileges see them? what tool using view them? command line, phpmyadmin etc? yes there logs can go through see here

How pass the asp.net session token from page to page? -

best , secured way pass asp.net session token page page. 1. cookies (not secured) 2. url (not secured) 3. hidden fields ? using hidded fields right way pass ? how pass using hidded fileds? how disble session token in cookies , in url (session state conguration)? from answer similar question, " securing asp.net forms authentication token on client side? " : session: fast, scalable, , secure session state management web applications

Creating a Silverlight DataTemplate in code -

how create silverlight data template in code? i've seen plenty of examples wpf, nothing silverlight. edit: here's code i'm using for, based on answer santiago below. public datatemplate create(type type) { return (datatemplate)xamlreader.load( @"<datatemplate xmlns=""http://schemas.microsoft.com/client/2007""> <" + type.name + @" text=""{binding " + showcolumn + @"}""/> </datatemplate>" ); } this works nicely , allows me change binding on fly. although cannot programatically create it, can load xaml string in code this: public static datatemplate create(type type) { return (datatemplate) xamlreader.load( @"<datatemplate xmlns=""http://schemas.microsoft.com/client/2007""> <" + type.name + @"/> </...

linux - Automate firefox with python? -

been scouring net firewatir python. i'm trying automate firefox on linux. suggestions? the pyxpcom extension 1 possibility. but looking @ firewatir provides, have 2nd suggestion twill. it's based on mechanize , might useful in context.

plsql - how to get this order by working in oracle pl/sql -

order case when v_sort_type = 'asc' case when v_sort_order = 'lname' cast(lname varchar2(45)) || ',' || rownum when v_sort_order = 'code' cast(code varchar2(52)) || ',' || rownum end asc when v_sort_type = 'dsc' case when v_sort_order = 'lname' cast(lname varchar2(45)) || ',' || rownum when v_sort_order = 'code' cast(code varchar2(52)) || ',' || rownum end desc end i trying write conditions when v_sort_type passed in asc or dsc. getting compilation error in this. i assume common thing in pl/sql sp's. where going wrong? you need rethink order multiple "columns". order case when v_sort_type = 'asc' , v_sort_order = 'lname' lname end asc, case when v_sort_type = 'desc' , v_sort_order = 'lname' lname end desc, case when...

ASP.NET and JQuery - Popup for dropdownlist selected value -

what i'm looking popup "are sure" confirmation box if newly selected value of dropdownlist value before submit form. <select name="listsearchtype" id="listsearchtype"> <option value="c">closed</option> <option value="o">open</option> <option value="p">pending</option> </select> so if had dropdownlist above autopostback enabled, i'd want popup confirmation box if user select 'closed' before form submitted. $("#listsearchtype").onchange(function() { if ($(this).val() == "c") { var confirmed = confirm("are sure ?"); if (!confirmed) { return false; } } });

Linq to NHibernate multiple OrderBy calls -

i'm having trouble ordering more 1 field in linq nhibernate query. either know might wrong or if there work around? code: iqueryable<agendaitem> items = _agendarepository.getagendaitems(location) .where(item => item.minutes.contains(query) || item.description.contains(query)); int total = items.count(); var results = items .orderby(item => item.agenda.date) .thenby(item => item.outcometype) .thenby(item => item.outcomenumber) .skip((page - 1)*pagesize) .take(pagesize) .toarray(); return new searchresult(query, total, results); i've tried replacing thenby multiple orderby calls. same result. method works great if comment out 2 thenby calls. error i'm receiving: [sqlexception (0x80131904): invalid column name '__hibernate_sort_expr_0____hibernate_sort_expr_1__'. invalid column name '__hibernate_sort_expr_0____hibernate_sort_expr_1__'.] system.data.sqlclient.sqlconnection.onerror(sqlexcepti...

Advanced directory switching in bash -

i know few advanced ways, change directories. pushd , popd (directory stack) or cd - (change last directory). but looking quick way achieve following: say, in rather deep dir: /this/is/a/very/deep/directory/structure/with\ lot\ of\ nasty/names and want switch /this/is/another/very/deep/directory/structure/with\ lot\ of\ nasty/names is there cool/quick/geeky way (without mouse)? do mean path names same, , 1 directory name changes ("a" becomes "another")? in case: cd ${pwd/a/another} will switch other directory. $pwd holds current directory, , ${var/foo/bar} gives $var string 'foo' replaced 'bar'.

How to use regex to replace URLs with an HTML link in Qt? -

how use qstring::replace detect urls in string , replace them html link, so... [...].replace(qregexp("???"), "<a href=\"\\1\">\\1</a>") what should argument qregexp be? end of url should denoted occurrence of whitespace character (such space, \r or \n) or end of string. the regex should simple: http://, https://, ftp://, etc, followed 1 or more non-whitespace characters, should converted link. edit: solution used... [...].replace(qregexp("((?:https?|ftp)://\\s+)"), "<a href=\"\\1\">\\1</a>") i think (?:https?|ftp)://\\s+ you. don't forget potentially match invalid urls, that's ok purposes. (a regex matches syntactically valid urls quite complicated construct , not worth effort.)

wpf - Is knowing blend required? -

do expect wpf developers know expression blend? any resources learning more blend? [update] knowing blend make more productive? i found blend great way ease xaml. many of common things want easy in blend, databinding. databinding has no intellisense , found doing things in blend great way of discovering how write databinding syntax. i find myself editing raw xaml buy hand. the areas blend handy: customizing templates. animation breaking ui down user controls

c++ - Profiling in Visual Studio 2008 PRO -

how use profiler in visual studio 2008? i know theres build option in config properties -> linker -> advanced -> profile (/profile), can't find actauly using it, articles able find appear apply older versions of visual studio (eg goto build->profile bring profile dialog box, yet in 2008 there no such menu item). is because visual studio 2008 not include profiler, , if , documentation it? the profiler available in team system editions of visual studio 2008. last version used included profiler visual c++ 6.0. for visual studio 2005, try compuware devpartner performance analysis community edition .

installer - How to add uninstall option in .NET Setup Project? -

the .net setup project seems have lot of options, don't see "uninstall" option. i'd prefer if people "uninstall" standard "start menu" folder rather send them control panel uninstall app, can please tell me how this? also, aware of non microsoft installers have feature, if possible i'd stay microsoft toolkit. you can make shortcut to: msiexec /uninstall [path msi or product code]

What is the maximum recursion depth in Python, and how to increase it? -

i have tail recursive function here: def fib(n, sum): if n < 1: return sum else: return fib(n-1, sum+n) c = 998 print(fib(c, 0)) it works n=997, breaks , spits "maximum recursion depth exceeded in comparison" runtimeerror . stack overflow? there way around it? it guard against stack overflow, yes. python (or rather, cpython implementation) doesn't optimize tail recursion, , unbridled recursion causes stack overflows. can change recursion limit sys.setrecursionlimit , doing dangerous -- standard limit little conservative, python stackframes can quite big. python isn't functional language , tail recursion not particularly efficient technique. rewriting algorithm iteratively, if possible, better idea.

Objective-C difference between class and instance of that class -

could explain me difference between class , instance of class. if can use 1 instance of class in program, can use class instance , change (-) (+) in methods declaration. difference between class , instance methods. thanks this seems several questions: what difference between class , instance of class? what if can use 1 instance of class? what difference between class , instance methods? first, difference between class , instance of class class specification instance. class there, must create instance use instance methods of class. class creates instances , gives them methods. second, "if can use 1 instance of class in program" situation never come up. can make many instances of class want (hardware permitting). third, difference between class , instance method while must create instance use instance method, class methods useful functions class offers without creating object class. instance methods operate on properties/fields of specific instan...

Problem with Login control of ASP.NET -

i set website use sqlmembershipprovider written on this page . i followed every step. have database, modified web.config use provider, correct connection string, , authentication mode set forms. created users test with. i created login.aspx , put login control on it. works fine until point user can log in. i call default.aspx, gets redirected login.aspx, enter user , correct password. no error message, nothing seems wrong, see again login form, enter user's login information. if check cookies in browser, can see cookie specified name exists. i tried handle events myself , check, happening in them, no success. i'm using vs2008, website in filesystem, sql express 2005 store aspnetdb, no role management, tested k-meleon, ie7.0 , chrome. any ideas? resolution: after mailing rob have ideal solution, accepted answer. i have checked code on in files have sent me (thanks again sending them through). note: have not tested since have not installed database e...

django - Connection refused: When I try to send email from my linode server -

i have django project , email settings use personal gmail account. works fine when im testing localhost. "conection refused error" django when try linode vps. ideas ? i had similar situation on site; turned out error inside application in generation of email. in case, has been solved, should check smtp server logs verify project connecting smtp. if isn't check email_* settings in settings.py file. if is, disconnecting, i'd bet there's failing in building of email (that is, in parsing of arguments send_mail function).

unix - Trim last 3 characters of a line WITHOUT using sed, or perl, etc -

i've got shell script outputting data this: 1234567890 * 1234567891 * i need remove last 3 characters " *". know can via (whatever) | sed 's/\(.*\).../\1/' but don't want use sed speed purposes. same last 3 characters. any quick way of cleaning output? assuming data formatted example, use ' cut ' first column only. cat $file | cut -d ' ' -f 1 or first 10 chars. cat $file | cut -c 1-10

What are some appropriate and inappropriate uses of reflection in Java? -

java's reflection api powerful tool, not particularly object-oriented. situations appropriate (and conversely, inappropriate) use reflection? in opinion... appropriate (clean): instantiating root of dynamically-loaded implementation, such applet. use of proxy create proxy or mock implementation (may better @ compile time). implementing interpreters allow unrestricted access java libraries. (note, security perspective interpreted code has effective privileges interpreter - can kind of dangerous.) appropriate hacks: circumventing java language access controls in third party code absolutely have to. implementing "cross-cutting concern" such persistence. removing static dependencies load classes causing slower start up. inappropriate: general circumventing java language access controls (includes testing). anything relies upon java language access rights given particular reflection-calling class. anywhere implementing interface work. ge...

c# - Which user-mode functions to hook to monitor/intercept file access? -

which user-mode functions in windows 7 can hook monitor/ intercept file access ? i've tried ntdll.dll's ntopenfile() , ntcreatefile() , of these aren't files - they're pipes , mutexes. same goes kernel32.dll's createfile() . there function called access files/directories. if helps, i'm trying hook explorer.exe prevent access firefox.exe. i'm using easyhook, if of have familiarity it. i think i've read somewhere that, using parameters ntopenfile/ntcreatefile, can distinguish between file access/pipe access. that's still bit hazy. there nice comfortable function hook? edit: please keep in mind need intercept file access prevent access files. easyhook great solution, since allows me perform complicated hooking in few easy steps in c# managed code. there no "file open function" opens files. furthermore, hooking supported using detours. finally, must ensure computers running have .net 4.0 installed, can run in-proc sxs. a f...

java - JDBC, JNDI Problem with tomcat 6.0.26 -

greetings, developing webapp requires setting datasource jndi using enterprise jdbc classes.i using netbeans 6.9 bundled tomcat (6.0.26 app) server mysql 5.xx.the issue can still see database values relation being displayed in jsp page whereas during tomcat initialization says this: . . severe: servlet.service() servlet jsp threw exception java.lang.classcastexception: org.apache.tomcat.dbcp.dbcp.basicdatasource cannot cast javax.naming.context @ org.apache.jsp.hello_jsp._jspservice(hello_jsp.java:141) @ org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:70) @ javax.servlet.http.httpservlet.service(httpservlet.java:717) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:374) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:313) @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:260) @ javax.servlet.http.httpservlet.service(httpservlet.java:717) ...

How to Write hyperlinks using spreadsheet gem in Ruby? -

the spreadsheet gem isnt documented properly, cant understand how can write hyperlinks using spreadsheet gem. can tell me? this script create spreadsheet link in first cell require 'rubygems' require 'spreadsheet' book = spreadsheet::workbook.new sheet1 = book.create_worksheet sheet1[0,0] = spreadsheet::link.new 'www.google.com', 'link text' book.write '/tmp/spreadsheet_with_link.xls'

sql server - How do you determine what SQL Tables have an identity column programmatically -

i want create list of columns in sql server 2005 have identity columns , corresponding table in t-sql. results like: tablename, columnname another potential way sql server, has less reliance on system tables (which subject change, version version) use information_schema views: select column_name, table_name information_schema.columns columnproperty(object_id(table_schema+'.'+table_name), column_name, 'isidentity') = 1 order table_name

unit testing - Amazon S3 standalone stub server -

i seem recall reading amazon s3-compatible test server run on own server unit tests or whatever. however, i've exhausted patience looking both google , aws. such thing exist? if not, think i'll write one. note: i'm asking amazon s3 (the storage system) rather amazon ec2 (cloud computing). are thinking of park place ? fyi, old home page offline now.

oop - Is JavaScript object-oriented? -

there have been questions whether or not javascript object-oriented language. statement, "just because language has objects doesn't make oo." is javascript object-oriented language? imo (and opinion) the key characteristic of object orientated language would support polymorphism . pretty dynamic languages that. the next characteristic encapsulation , pretty easy in javascript also. however in minds of many inheritance (specifically implementation inheritance) tip balance whether language qualifies called object oriented. javascript provide easy means inherit implementation via prototyping @ expense of encapsulation. so if criteria object orientation classic threesome of polymorphism, encapsulation , inheritance javascript doesn't pass. edit : supplementary question raised "how prototypal inheritance sacrifice encapsulation?" consider example of non-prototypal approach:- function myclass() { var _value = 1; this.getvalue...

indexing - How do I check if an index exists on a table field in MySQL? -

i've needed google couple times, i'm sharing q/a. use show index so: show index [tablename] docs: https://dev.mysql.com/doc/refman/5.0/en/show-index.html

mysql - Joining multiple columns from table a to one on table b -

i've spent bit of time researching on here , mysql site i'm bit confused on 2 things: sort of join use , how (or if) use alias. the query: select forum_threads.id, forum_threads.forum_id, forum_threads.sticky, forum_threads.vis_rank, forum_threads.locked, forum_threads.lock_rank, forum_threads.author_id, forum_threads.thread_title, forum_threads.post_time, forum_threads.views, forum_threads.replies, users.username author_username forum_threads left join users on forum_threads.author_id = users.id forum_threads.forum_id=xxx now query finds threads given forum , joins threads author id username table. have lastpostid i'd include in query , join again on users table can username last poster too. i tried adding: left join users on threads.lastpostid = users.username but results in alias error users isn't unique. i tried using both alias on main query , on second join keeps giving me missing field errors. could give me point in right direction pleas...

jquery - PHP MySQL Query Question / Help - Joining tables -

i need show wall posts friends of logged in user, , user himself ofc.. :p i've searched on every coding forums, , google, did not find answer looking :/ the session logged in user are: $_session['userid'] this mysql query have far: select distinct * status_updates join friends on status_updates.member_id = friends.friend_with left join members on status_updates.member_id = members.member_id order status_id desc limit 0,10 the query outputs status update friends right, when comes logged in user, status update duplicated, here's looks like: http://i30.tinypic.com/29bkqaw.png there 2 entries in status_updates, 1 test bruker 4 , 1 endre hovde .. i'm logged in endre hovde way. i'll thankful can get, credz best answer ;) in advance! :) // endre hovde @ rcon^ what this: $query = "select su.* status_updates su su.member_id in ( select " . $_session['user_id'...

activeview - Create a "main layout" view in Rails? -

ok have small project 2 different scaffoldings i've made.in layouts directory therefor there 2 different layout.html.erb files. my question how condense 1 main layout file 2 scaffolded views share. basically purpose doing have have navigation bar , header , other such things in 1 place. if name layout file application.html.erb, default layout file. if specify layout file same name of controller, override default layout. from rails guides: to find current layout, rails first looks file in app/views/layouts same base name controller. example, rendering actions photoscontroller class use app/views/layouts/photos.html.erb (or app/views/layouts/photos.builder). if there no such controller-specific layout, rails use app/views/layouts/application.html.erb or app/views/layouts/application.builder. if there no .erb layout, rails use .builder layout if 1 exists. rails provides several ways more precisely assign specific layouts indi...

python - Google app engine parsing xml more then 1 mb -

hi need parse xml file more 1 mb in size, know gae can handle request , response 10 mb need use sax parser api , api gae has limit of 1 mb there way can parse file more 1 mb ways. the 1mb limit doesn't apply parsing; however, can't fetch more 1mb urlfetch; you'll first 1mb api. it's not going possible xml application using urlfetch api. if data smaller 10mb, can arrange external process post application , process it. if it's between 10mb , 2gb, you'd need use blobstore api upload it, read in application in 1mb chunks, , process concatenation of chunks.

sql - Join query with multiple tables involved -

i using join in sql first time respect many tables, have got error : i have 3 tables, semester table studentid department semester 1 1 1 course table courseid coursename semester 1 s.e 1 2 d.b 1 examattend table(foreign keys studentid , courseid) studentid courseid marks 1 1 88 1 2 90 i trying reslut through select coursename,marks courseid inner join examattend on ( select courseid course c, semester s s.semester = c.semester ) = examattend.courseid; this query showing me error subquery cannot return multiple query when used '=' anyone can suggest me way query done? missing syntax inner join? select coursename,marks course c inner join examattend e on c.courseid = e.courseid inner join semester s on s.studentid = e.studentid

silverlight - Disabling a EventTrigger\Storyboard Dynamically -

<grid.triggers> <eventtrigger routedevent="border.loaded"> <eventtrigger.actions > <beginstoryboard> <storyboard x:name="mystoryboard" autoreverse="true" repeatbehavior="forever"> <coloranimationusingkeyframes begintime="00:00:00" storyboard.targetname="border" storyboard.targetproperty="(border.background).(solidcolorbrush.color)"> <splinecolorkeyframe keytime="00:00:01" value="#fffafafa"/> </coloranimationusingkeyframes> </storyboard> </beginstoryboard> </eventtrigger.actions> </eventtrigger> </grid.triggers> how enable\disable event trigger\animation dynamically. thinking bi...

Setup Python environment on Windows -

how setup python environment on windows computer can start writing , running python scripts, there install bundle? database should use? i should of mentioned using web based applications. require apache? or use http server? standard setup python running web apps? download python 2.6 windows installer python.org ( direct link ). if you're learning, use included sqlite library don't have fiddle database servers. most web development frameworks (django, turbogears, etc) come built-in webserver command runs on local computer without apache.

How do I listen/identify when a program runs in Windows using C++? -

specifically, want listen when programs run , record information such as: timestamp, executable, windows name , user. alternatively, use wmi interface find out what's running , take appropriate action. in vbscript code below wmi subsystem being queried select * win32_process change process priority. find out other attributes available win32_process , should find stuff that's heading in direction want go. const normal_priority = 32 const low_priority = 64 const realtime_priority = 128 const high_priority = 256 const belownormal_priority = 16384 const abovenormal_priority = 32768 function setpriority( sprocess, npriority ) dim scomputer dim owmiservice dim cprocesses dim oprocess dim bdone bdone = false scomputer = "." set owmiservice = getobject("winmgmts:\\" & scomputer & "\root\cimv2") set cprocesses = owmiservice.execquery ("select * win32_process name = '" & sproce...

mysql - Bogus foreign key constraint fail -

i error message: error 1217 (23000) @ line 40: cannot delete or update parent row: foreign key constraint fails ... when try drop table: drop table if exists `area`; ... defined this: create table `area` ( `area_id` char(3) collate utf8_spanish_ci not null, `nombre_area` varchar(30) collate utf8_spanish_ci not null, `descripcion_area` varchar(100) collate utf8_spanish_ci not null, primary key (`area_id`), unique key `nombre_area_unique` (`nombre_area`) ) engine=innodb default charset=utf8 collate=utf8_spanish_ci; the funny thing i dropped other tables in schema have foreign keys against area . actually, database empty except area table. how can possibly have child rows if there isn't other object in database? far know, innodb doesn't allow foreign keys on other schemas, it? (i can run rename table area something_else command :-?) two possibilities: there table within schema ("database" in mysql terminology) has fk r...

android - onPostExecute on cancelled AsyncTask -

does onpostexecute execute if asynctask has been cancelled? if execute, safe should ask if task has been cancelled ( iscancelled ) @ start of onpostexecute , before doing else? the documented behaviour of onpostexecute on cancel() changed between android 2 , android 4. android 2.3.7 onpostexecute : runs on ui thread after doinbackground. specified result value returned doinbackground or null if task cancelled or exception occured. android 4.0.1 onpostexecute : runs on ui thread after doinbackground. specified result value returned doinbackground. method won't invoked if task cancelled. so if still targeting android 2 devices should assume onpostexecute called , in onpostexecute check null result.

performance - How can I speed up my PHP based website? -

i built small php based site scratch, yay me! given size of it, it's running little slower expected. i have files/folders organized this: articles [folder] css [folder] html [folder] images [folder] js [folder] photography [folder] resources [folder] articles.php [file] bio.php [file] contact.php [file] content.php [file] favicon.ico footer.php [file] header.php [file] index.php [file] photography.php [file] and of php files coded this: <?php $thispage="writing"; include("header.php"); $page = $_get['article']; $file = "articles/".$page.".html"; if(file_exists($file)) { include($file); } else { print "404 error. page not exist"; } function issafeinclude($x) { if(strpos($x, "/../") !== false || strpos($x, "../") === 0 || strpos($x, "/..") == (strlen($x) - 3) || $x == '..') return false; else return true; } //includ...

Using regex to find any last occurrence of a word between two delimiters -

suppose have following test string: start_get_get_get_stop_start_get_get_stop_start_get_stop where _ means characters, eg: startagetbbgetcccgetddddstopeeeeestart.... what want extract last occurrence of word within start , stop delimiters. result here 3 bolded below. start__get__get__ get __stop__start__get__ get __stop__start__ get __stop i precise i'd using regex , far possible in single pass. any suggestions welcome thanks' get(?=(?:(?!get|start|stop).)*stop) i'm assuming start , stop delimiters balanced , can't nested.

How do I get current datetime on the Windows command line, in a suitable format for using in a filename? -

update: it's 2016 i'd use powershell unless there's compelling backwards-compatible reason it, particularly because of regional settings issue using date . see @npocmaka's https://stackoverflow.com/a/19799236/8479 what's windows command line statement(s) can use current datetime in format can put filename? i want have .bat file zips directory archive current date , time part of name, example, code_2008-10-14_2257.zip . there easy way can this, independent of regional settings of machine? i don't mind date format, ideally it'd yyyy-mm-dd, simple fine. so far i've got this, on machine gives me tue_10_14_2008_230050_91 : rem datetime in format can go in filename. set _my_datetime=%date%_%time% set _my_datetime=%_my_datetime: =_% set _my_datetime=%_my_datetime::=% set _my_datetime=%_my_datetime:/=_% set _my_datetime=%_my_datetime:.=_% rem use timestamp in new zip file name. "d:\program files\7-zip\7z.exe" -r code_%_my_datetime%.zip...

c++ - Boost phoenix or lambda library problem: removing elements from a std::vector -

i ran problem thought boost::lambda or boost::phoenix solve, not able syntax right , did way. wanted remove elements in "strings" less length , not in container. this first try: std::vector<std::string> strings = getstrings(); std::set<std::string> others = getothers(); strings.erase(std::remove_if(strings.begin(), strings.end(), (_1.length() < 24 && others.find(_1) == others.end())), strings.end()); how ended doing this: struct discard { bool operator()(std::set<std::string> &cont, const std::string &s) { return cont.find(s) == cont.end() && s.length() < 24; } }; lines.erase(std::remove_if( lines.begin(), lines.end(), boost::bind<bool>(discard(), old_samples, _1)), lines.end()); you need boost::labmda::bind lambda-ify function calls, example length < 24 part becomes: bind(&string::length, _1) < 24 edit see "head geek"'s post why set::find tricky. go...

scala - scaladoc Ant task writing for multiple source directories? -

i wish compile scaladoc , javadoc in project both scala , java in it. project has more 1 source directory (each of may have scala or javadoc). tried: <scaladoc destdir="doc"> <classpath refid="compile.classpath"/> <src> <fileset dir="src"/> <fileset dir="tweetstream4j/src"/> </src> <include name="src/**/*.scala"/> </scaladoc> and several variants thereof. above variant get: build failed /blah/build.xml:119: /blah/src/com/foo/blah.java not directory. where "blah.java" file in source tree. i've looked @ scaladoc ant task doc , scaladoc man page . i'm using scala2.7.7final (because that's apt-get puts on ubuntu system). suggestions of how scaladoc , javadoc out of "src" , "tweetstream4j/src"? i had same question , came across this. <src> elements don't seem documented able put ...

css float - CSS [DIV-Tableless] Stack vertically with different heights filling the gaps? -

i have different divs floating left (float:left) have different heights. need stack divs image attached: http://www.krazy.es/images-stackov/capture-divs.jpg it looks div " container 5 " has clear:left; or clear:both; set in css. edit nevermind, have divs floated left. here's sample code: sample code on jsfiddle.net if play width of window, you'll notice divs attempt fill available horizontal space. messiness seeing results divs having different vertical heights. desired results if: they had same height (i.e. had 2 lines of text) you assigned height value each div height:90px; (set largest common denominator) or you decided have 3 columns of divs max , if browser window wide enough accommodate more. can put container 1, 2, & 3 in 1 div on top, , container 4, 5, & 6 in div underneath finally (for completeness), you can put container 1 & 4 in div, container 2 & 5 in div, , container 3 & 6 in div, , float divs left...

Portability of Java Swing applications to OSX -

recently wrote extremely basic java swing program couple of text fields , buttons. program works fine me on ubuntu java 1.5. when try run on osx (10.4), main window displayed correctly program seems unresponsive. nothing seems happen, no matter button click on. i know next nothing mac osx, there might doing wrong? could executing off event-dispatch thread? example, might creating, displaying , modifying jtextarea in main thread.

Apart from initial cost, are there any other benefits of using MySQL over MSQL server with .net? -

i've used both , i've found mysql have several frustrating bugs, limited support for: ide integration, profiling, integration services, reporting, , lack of decent manager. total cost of ownership of mssql server touted less mysql (.net environment), maintaining open mind point out killer features of mysql? i've used mysql in past , i'm using mssql lately can't remember mysql has , mssql can't do. i think killer feature of mysql it's simplicity. projects don't need power can have huge system mssql. have unix heritage , find simple configuration file my.ini killer feature of mysql. also security system of mysql less robust makes job right of applications. believe mysql it's killer point of view, , should stay way, letting young users being introduced rdbms simple view first. if project gets big enough considering switch more robust system, mssql can pop possibility. that's happened me.

sql - Like PIVOT but values not discrete -

a table lists multiple events each event has 4 attributes (columns), call them a, b, c, p it simpleto pivot table columns a, b, c, p=1, p=2, p=3, etc. however, need columns a, b, c, p<1, p<2, p<3, etc. in other words, if row of "simple" way x, y, z, 7, 3, 5, 2 need x, y, z, 7, 10, 15, 17 because p less n less n+1. i know can compute values (x, y, z, 7, 10, 15, 17), load them temporary table, , pivot that, maybe there's simple sql talents don't recognize immediately? if matters, result end in ssrs. if understand correctly, should work. select a, b, c, sum(case when p < 1 1 else 0 end) p1, sum(case when p < 2 1 else 0 end) p2, sum(case when p < 3 1 else 0 end) p3, sum(case when p < 4 1 else 0 end) p4 events group a, b, c this not dynamic. example, if have row in there p=4 not add row p<5. it's using strictly < , not <=.

wcf - Can I specify a contract's Name and Namespace in app.config? -

i'm pretty new wcf , soa, apologize if question poor. the way see it, if specify contract's name , namespace in app.config, change service client contracts use @ runtime rather compile time. without ability specify name , namespace in app.config, client contracts limited connecting services contracts same name , in same namespace. right? so there way choose name , namespace given contract in app.config? if not, why not? what ask doesn't make sense. name , namespace identify contract. contract cannot change without changing client. why service versioning performed adding new contract (with new name/namespace combination), not changing existing contract. you should think of contract being unbreakable agreement between client , service - provide set of operations. you can, on other hand, change endpoint client references if decide you'd client use different implementation of contract. can change binding implementation reached. must maintain same ...

performance - In R, how do you loop over the rows of a data frame really fast? -

suppose have data frame many rows , many columns. the columns have names. want access rows number, , columns name. for example, 1 (possibly slow) way loop on rows is for (i in 1:nrow(df)) { print(df[i, "column1"]) # more things data frame... } another way create "lists" separate columns (like column1_list = df[["column1"] ), , access lists in 1 loop. approach might fast, inconvenient if want access many columns. is there fast way of looping on rows of data frame? other data structure better looping fast? i think need make full answer because find comments harder track , lost 1 comment on this... there example nullglob demonstrates differences among for, , apply family functions better other examples. when 1 makes function such slow that's speed consumed , won't find differences among variations on looping. when make function trivial can see how looping influences things. i'd add members of apply family unexplore...

How do you detect low memory situations within the java virtual machine? -

i've been getting outofmemory errors lately in application. possible detect ahead of time when virtual machine running low on memory? in other words preemptively deal outofmemory errors before occur? java (as of java 5) has standard jmx bean can used receive low memory notification. see java.lang.management.memorymxbean .

git - How to diff the same file between two different commits on the same branch? -

on git, how compare same file between 2 different commits (not contiguous) on same branch (master example)? i'm searching compare feature 1 in vss or tfs, possible in git? from git-diff manpage: git diff [--options] <commit> <commit> [--] [<path>...] for instance, see difference file "main.c" between , 2 commits back, here 3 equivalent commands: $ git diff head^^ head main.c $ git diff head^^..head -- main.c $ git diff head~2 head -- main.c

oracle - What does PARTITION BY 1 mean? -

for pair of cursors total number of rows in resultset required after first fetch, ( after trial-and-error ) came query below select col_a, col_b, col_c, count(*) over( partition 1 ) rows_in_result mytable join theirtable on mytable.col_a = theirtable.col_z group col_a, col_b, col_c order col_b now when output of query x rows, rows_in_result reflects accurately. what partition 1 mean? i think tells database partition results pieces of 1-row each it unusual use of partition by. put same partition if query returns 123 rows altogether, value of rows_in_result on each row 123 (as alias implies). it therefore equivalent more concise: count(*) on ()

sql server - View output of 'print' statements using ADOConnection in Delphi -

some of ms sql stored procedures produce messages using 'print' command. in delphi 2007 application, connects ms sql using tadoconnection, how can view output of 'print' commands? key requirements: 1) can't run query more once; might updating things. 2) need see 'print' results if datasets returned. that interesting one... the oninfomessage event adoconnection works devil in details! main points: use cursorlocation = cluseserver instead of default cluseclient. use open , not execproc adostoredproc. use nextrecordset current 1 following, sure check have 1 open. use set nocount = on in stored procedure. sql side: stored procedure set ansi_nulls on go set quoted_identifier on go if exists (select * sys.objects object_id = object_id(n'[dbo].[fg_test]') , type in (n'p', n'pc')) drop procedure [dbo].[fg_test] go -- ============================================= -- author: françois -- description: test mul...

linux - Is it possible to have python open a terminal and write to it? -

for example, if have code: subprocess.call(['gnome-terminal']) is possible have python output strings specific terminal opened? thanks! possibly, easier have custom process running in subordinate terminal. example, given sserv.py example server in documentation command: gnome-terminal -e "python ./sserv.py" will happily chat on port 9999 you. given more complex sserv.py want (anything terminalish, is).

perl - release memory for multi-level hash -

assume have muti-level hash: $class->{'key1'}->{'key2'}->{$key3}->{'string'}->{$key5}, $class->{'key1'}->{'key2'}->{$key3}->{'string'}->{$key5} equals integer number. $key3 can class name "music", "english"... $key5 can student name "mary", "luke"... will following operation release memory under level $key3="music" ? i.e. memory assigned $key5 released? $current_class = $class->{'key1'}->{'key2'}->{"music"}; $current_class = undef; update: thanks both. understanding between delete , undef is: delete remove entry of key='music' so $class->{'key1'}->{'key2'}->{"music"} not exist. while undef set value of $class->{'key1'}->{'key2'}->{"music"} undef . entry of key='music' still there value of un...

Mediaelement source from server(mms:) problem wpf -

mp3 files server takes more 5mins play in mediaelement. code: <mediaelement name="player" source="{binding elementname=lbtrack, path=selecteditem.filepath, notifyonsourceupdated=true,notifyontargetupdated=true}" unloadedbehavior="stop" volume="{binding elementname=volume, path=value}" mediaended="player_mediaended" mediaopened="player_mediaopened" loadedbehavior="manual" /> you better performance activex media player. try walkthrough: http://msdn.microsoft.com/en-us/library/ms742735.aspx

debugging - How to inspect the return value of a function in GDB? -

is possible inspect return value of function in gdb assuming return value not assigned variable? i imagine there better ways it, finish command executes until current stack frame popped off , prints return value -- given program int fun() { return 42; } int main( int argc, char *v[] ) { fun(); return 0; } you can debug such -- (gdb) r starting program: /usr/home/hark/a.out breakpoint 1, fun () @ test.c:2 2 return 42; (gdb) finish run till exit #0 fun () @ test.c:2 main () @ test.c:7 7 return 0; value returned $1 = 42 (gdb)

c++ - Undefined reference to static class member -

can explain why following code won't compile? @ least on g++ 4.2.4. and more interesting, why compile when cast member int? #include <vector> class foo { public: static const int member = 1; }; int main(){ vector<int> v; v.push_back( foo::member ); // undefined reference `foo::member' v.push_back( (int) foo::member ); // ok return 0; } you need define static member somewhere (after class definition). try this: class foo { /* ... */ }; const int foo::member; int main() { /* ... */ } that should rid of undefined reference.

java - Infinite number of backup files with RollingFileAppender -

do know way create infinite number of backup files rollingfileappender ? when don't specify maxbackupindex @ all, end 1 backup file. it not possible. see log4j api : the maxbackupindex option determines how many backup files kept before oldest erased. option takes positive integer value. if set zero, there no backup files , log file truncated when reaches maxfilesize. the best can using large limit (integer.max_value max).

c# - Is Marshalling only used only for Converting Structure to Byte and ViceVersa? -

after going through marshall code snippet got idea marshalling used convert struct bytes , few other similar convesrions. use of marshall? and while going through msdn sample got floowing line: // initialize unmanged memory hold struct. intptr pnt = marshal.allochglobal(marshal.sizeof(p)); and few other sites got follwing lines like: when work `unmanaged` code, `marshaling` data `managed app-domain` `unmanaged` realm. now manged , unmanaged domain or managed , unmanaged code. while writing code how able distinguish managed , unmanaged ? i need clear fundamentals before going ahead, suggestion,doc or walkthrough sincere grattitude. thanks, subhen managed code code runs using clr (common language runtime)... unmanaged code code not dependent on clr, during runtime, such c program. there wikipedia article of computer science topics out there... google friend of developer.

SQL Server Management Studio connection issue -

i using sql server 2008 enterprise on windows server 2008 enterprise. server runs sql server 2008 machine m1. have tried using sql server management studio on machine m2 connected m1. can not use machine m3 connect m1. ideas wrong? not sure whether issue @ m1 side or m3 side? check list? error message is, provider: named pipeline provider program, error 40 -- can not open connection sql server (microsoft sql server: error 53). thanks in advance, george on m1 need enable tcp/ip in sql server configuration manager, under "protocols mssqlserver". in addition need open @ least port 1433 in windows firewall

Call image from within a javascript function? -

on this site , when user sets alarm sound , time, under "set alarm," chosen time , alarm sound appears. i want instead of example, 2:00pm [x] (alarm set - weather) or 2:00pm [x] (alarm set - rooster) want image of weather or rooster appear instead of printing text. this function printing text function getalarmname(ind){ if(ind==4) return "weather"; else if(ind==3) return "flight"; else if(ind==1) return "time"; else return "rooster"; } i tried removing "weather," , "flight," example , adding instead image/weather.jpg , image/flight.jpg, not correct syntax. you try this: function getalarmname(ind){ if(ind==4) return "<img src='image/weather.jpg' />"; else if(ind==3) return "<img src='image/flight.jpg' />"; else if(ind==1) return "<img src='image/time.jpg' />"; else return "<img src=...