Posts

Showing posts from July, 2011

shell - In unix, how can I pipe the output of who into the groups command? -

i'm trying this: say there 4 users logged unix machine, a, b, c, , d. now, groups these guys belong to, have type out : groups b c d. what wondering, if there way who | groups can pipe users logged-in groups command, print out users given along group information. however, not seem work intended - rather, above command gives group first user belongs to. in bash, zsh, , others: groups $(who | cut -d' ' -f 1)

iphone code not firing -

i have class im using , cant code fire weatherserver.m ---------------------- - (nsarray *)weatheritemsformapregion:(mkcoordinateregion)region maximumcount:(nsinteger)maxcount { //code not firing } myviewcontroller.h ----------------------- @class weatherserver; @interface mapview : uiviewcontroller <mkmapviewdelegate, uitextfielddelegate, cllocationmanagerdelegate, adbannerviewdelegate> { weatherserver *weatherserver; } @property(nonatomic, retain) iboutlet weatherserver *weatherserver; @end myviewcontroller.m ---------------------- #import "weatherserver.h" @implementation mapview @synthesize weatherserver; - (void)mapview:(mkmapview *)map regiondidchangeanimated:(bool)animated { nsarray *weatheritems = [weatherserver weatheritemsformapregion:mapview.region maximumcount:300]; [mapview addannotations:weatheritems]; } @end regiondidchangeanimated fires ok however, code in weatheritemsformapregion never gets fired. i figured out go...

mysql - DB Design - Contextual constraints -

i have pair of tables parent-child relationship. domain: id int not null auto_increment primary_key domain varchar(100) not null domain_url: id int not null auto_increment primary key domain_id int not null path varchar(512) here want keep path unique in 1 domain. across domain path can duplicating. best constraint apply on path. should focus on composite key between domain_id , path. composite key reliable solution? i think want apply unique constraint in domain_url table on domain_id, path composite key. enforce requirement "to keep path unique in 1 domain"

c# - creating a web service with paging -

i creating web service in asp.net 2.0 c# , have web method looks this: [webmethod()] public list<comment> getyoursaycomments(int pagenumber, int pagesize, int commenttopicid) { commentmanager cm = new commentmanager(); return cm.getyoursaycomments(pagenumber, pagesize, commenttopicid, true); } this working greate services returned entities, method returns paged results. best way return total row count client? you have create custom type include count: public class envelopewithcount<t> { public t value { get; set; } public int rowcount { get; set; } } and web service return new type: [webmethod] public envelopewithcount<list<comment>> getyoursaycomments(int pagenumber, int pagesize, int commenttopicid) { commentmanager cm = new commentmanager(); envelope<list<comment>...

.net - Requirements for collection class to be used with LINQ -

i thought enough requirement class should satisfy able use where() implement ienumerable . but today friend of mine asked me question, why cannot apply where() object of spusercollection class (it sharepoint). since class derived spbasecollection implements ienumerable - expected should fine. not. any ideas, why? the linq extension methods defined on ienumerable<t> , not ienumerable . example, see where<t> signature: public static ienumerable<tsource> where<tsource>( ienumerable<tsource> source, func<tsource, bool> predicate ) to mitigate issue, linq cast<t> extension method turns ienumerable ienumerable<t> can used normal linq functions. in example below, can't e.where(...) , can cast , use where . int[] xs = new[] { 1, 2, 3, 4 }; ienumerable e = xs; var odds = e.cast<int>().where(x => x % 2 == 1); unfortunately, needs used lot when dealing pre-generics apis in .net bcl.

Multiple types in one specialized D template -

say have deal ushort , uint way, string differently. guess need 1 specialized template string , other both ushort , uint . it? // void func(t)(t var) { ... } // uint , ushort void func(t: uint, ushort)(t var) { ... } that idea, although code can't compile. it's valid or bad? try this: void func(t)(t var) if ( is(t : uint) || is(t : ushort) ) { ... } void func(t : string)(t var) { ... } you in 1 function: void func(t)(t var) { static if ( is(t : uint) || is(t : ushort) ) { ... } else if ( is(t : string) ) { ... } else { // handle else } }

regex - Date format in php using regular expression -

hai, can me change "wed sep 29 14:47:37 +0000 2010" "sep 29,2010 @ 2:47pm" using regular expression in php? you can use strtotime . no need regular expression. date('m j, y \a\t g:i a', strtotime('wed sep 29 14:47:37 +0000 2010'));

SQL Server - what is the size of my database if this is the output from sp_spaceused -

Image
i ran command: exec sp_spaceused the output was: so size of database? - 4768.25 - 4076.57 = 691.68 mb (1st table) or 19896 kb (2nd table)? edit i'm using sql server 2005 express has "database size" limit of 4 gb. in context of "database size", if calculate how far space limit - should consider unallocated space database can still use? your database size 4768.25mb sql server allocate database file bigger used space. unallocated space filled until database file needs 'grown' again

xslt - Umbraco and EXSLT sets do not work -

i'm creating xslt's using umbraco 4.5.2 , want add de set:distinct function exslt.org (http://www.exslt.org/set/functions/distinct/index.html) however, when reference set:distinct error: system.xml.xsl.xsltransformexception: cannot find script or extension object associated namespace 'http://exslt.org/sets'. i've added files, extension in xslt , namespace this: <?xml version="1.0" encoding="utf-8"?> <!doctype xsl:stylesheet [ <!entity nbsp "&#x00a0;"> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:exsl="http://exslt.org/functions" xmlns:set="http://exslt.org/sets" xmlns:umbraco.library="urn:umbraco.library" xmlns:exslt.exsltcommon="urn:exslt.exsltcommon" xmlns:exslt.exsltdatesandtimes="urn:exslt.exsltdates...

Access from Java to Tomcat paths -

have webapp running in local tomcat. path is: tomcat/webapps/myproject . have resources in project in folder path: tomcat/webapps/myproject/resources so, trying acces resources java project, using file config.properties . in file have this: tomcat.url= http://localhost tomcat.port=8080 tomcat.resources=/myproject/resources i tryed different combinations of / or \ error running project: trying acces directory not exist my java code: configuration config = new propertiesconfiguration("config.properties"); string sourcepath = config.getstring("tomcat.resources"); //and try list folder file dir = new file(sourcepath); string[] children = dir.list(); if (children == null) { // either dir not exist or not directory throw new serviceexecutionexception("trying generate metadata in directory not exist"); } i don't know wrong, in projects made before, simliar this, had similar , found e...

How to write a simple C program for usb port? -

i want test usb on linux to detect c new storage device, usb pen drive, inserted, use getlogicaldrives(); or getlogicaldrivestrings() , see if new entries detected. also have @ how getdriveinfo2 implemented (it uses winapi) , this stack overflow question, related or possibly dupe. once have logical drive name, open directory , enumerate files there directory findfirstfile() .

java - Resulting Jar From Ant Builder Can't be Seen in Eclipse Workspace -

i have java project in eclipse built through ant. normally, see resulting jar appear in workspace in eclipse. suddenly, project only, jar doesn't show within eclipse. know jar being created because when @ workspace within windows explorer, see jar. how can eclipse show resulting jar build within eclipse itself? i think it's problem of refreshing workspace or project directories. however, can automatically: in project properties, select builders , ant builder . in properties of builder, go in refresh tab, , check resfresh resources upon completion , choose the project containing selected resource option.

c# - WCF service show exception when securing service with wshttpbinding and username authentication -

i have created workflowservice in .net 4.0 i trying secure (wcf) service , used following link see how done. i followed instructions, when define servicebehavior everthing works fine. configuration this: <behaviors> <servicebehaviors> <behavior> <servicecredentials name="servicebehavior"> <usernameauthentication usernamepasswordvalidationmode="membershipprovider" membershipprovidername="aspnetsqlmembershipprovider" /> </servicecredentials> <servicemetadata httpgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="false" /> </behavior> </servicebehaviors> </behaviors> my bindings specified this: <bindings> <wshttpbinding> <binding name="centraladminbinding"> <security mode="transportwithmess...

asynchronous - Best practice to close WCF Clients after async calls -

can advice me best practice closing wcf clients after doing async calls? should within "completed" method or should there different approach? /bb it's practice close client in endoperation() method. --larsw

.net - Why does this code not bind SelectedItem to a property? -

i'm pretty new xaml, , first task in new job untangle particularly malodorous collection of spaghetti code. learning xaml @ same time untangling horror-show proving beyond me, apologies homework-level questions i'm asking, these days. anyway, have following xaml code: <usercontrol.resources> <collectionviewsource x:key="xmlobjectgroups" source="{binding path=xmlobjectlist}"> <collectionviewsource.groupdescriptions> <propertygroupdescription propertyname="isdatetype"/> </collectionviewsource.groupdescriptions> <collectionviewsource.sortdescriptions> <scm:sortdescription propertyname="isdatetype" direction="ascending"/> <scm:sortdescription propertyname="ordernumber" direction="ascending"/> </collectionviewsource.sortdescriptions> </collection...

iphone - how to implement picker for a large amount of values -

i have 20,000 records (coming sqlite db) need present user possible choices, conventional picker control out of question. another possibility indexed uitableview user check desired value, keeping 20k records in memory doesn’t seem idea. how should go implementing ui it? edit: possible auto-complete combo-box? i'd @ sort of nested ui i.e. uitableview has a, b, c etc start , when user presses on row show table view results starting a. there need query got number of results started a, b, c etc showed letters in first table has results each query in second table simple - results starting 'a' etc. you'd never have load 20,000 results memory @ same time :) however, should make sure have index on field you're querying, otherwise queries going rather slow :( the other solution use search box @ top of table view - user types in letters , each time list reduced results starting letter. that's pretty simple query implement :) however, still h...

parsing - Are there any multipart/form-data parser in C# - (NO ASP) -

i trying write multipart parser things getting complicated , want ask if knows of ready parser in c#! just make clear, writing own "tiny" http server , need pars multipart form-data too! thanks in advance, gohlool i open-sourced c# http form parser here . this more flexible other 1 mentioned on codeplex, since can use both multipart , non-multipart form-data , , gives other form parameters formatted in dictionary object. this can used follows: non-multipart public void login(stream stream) { string username = null; string password = null; httpcontentparser parser = new httpcontentparser(stream); if (parser.success) { username = httputility.urldecode(parser.parameters["username"]); password = httputility.urldecode(parser.parameters["password"]); } } multipart public void upload(stream stream) { httpmultipartparser parser = new httpmultipartparser(stream, "image"); if (...

Polyline disappears while setting PolylineStyle property of a line series in a Silverlight chart -

i have silverlight chart has multiple line series dynamically created. when assign polylinestyle of dynamically created lineseries lines in chart disappear. markers shown. odd because when assign same style xaml works should. i'm using following code assign style: agentseries.polylinestyle = (style)agentschart.resources["agentresultchartlinestyle"]; this style contains 1 setter - strokethickness = 2. am doing wrong here? why lines disappear when set polylinestyle code on dynamically added lineseries? when setting strokethickness property code, need set stroke property lines visible.

Shell Script for checking existence of a directory -

if[-d /abmusr06/abm/users/dywrk01/run_time]; echo "pack installation failed" exit(1) fi this above code fine? assuming bourne shell (/bin/sh): if [ -d /abmusr06/abm/users/dywrk01/run_time ] echo "pack installation failed" exit 1 fi put spaces around brackets: if [ -d . think of [ (key)word - needs stand itself. wouldn't ls-l , ls (space) -l . use exit 1 , not exit(1) . the semicolons unnecessary if on separate lines. the above seems work in cygwin me.

c++ - How do I validate template parameters in compile time when a templated class contains no usable member functions? -

i have following templated struct : template<int degree> struct cpoweroften { enum { value = 10 * cpoweroften<degree - 1>::value }; }; template<> struct cpoweroften<0> { enum { value = 1 }; }; which used this: const int numberofdecimaldigits = 5; const int maxrepresentablevalue = cpoweroften<numberofdecimaldigits>::value - 1; // can use both constants safely - they're surely in sync now template requires degree non-negative. i'd enforce compile-time assert that. how do that? tried add destructor cpoweroften : ~cpoweroften() { compiletimeassert( degree >= 0 ); } but since not called directly visual c++ 9 decides not instantiate , compile-time assert statement not evaluated @ all. how enforce compile-time check degree being non-negative? template<bool> struct staticcheck; template<> struct staticcheck<true> {}; template<int degree> struct cpoweroften : staticcheck<(degree > 0...

excel - VBA: How to display a cell value by its defined name? -

i have defined name particular column in worksheet. how display cell value defined name? i've tried these: public sub test() dim r range set r = thisworkbook.names("somename").referstorange msgbox cstr(r.value) end sub but run-time error occured "type mismatch" (error code: 13). what's wrong code? actual data type of referstorange.value? the documentation says referstorange returns range object, seems differ range object returned activecell, because i've no problem following code: msgbox cstr(activecell.value) i've been using excel 2003 referstorange return range object. assume you're getting type mismatch on cstr line. if range has multiple cells, value property returns variant array. in immediate window (control+g in vbe). ?typename(thisworkbook.names("somerange").referstorange) range ?typename(thisworkbook.names("somerange").referstorange.value) variant() the cstr function...

php - php_excel07- how to fix min heigth and mak to grow height based on the contents of a cell -

i have export data xlsx, exported file should in pre defined format. becoz of these using "phpexcel". , created template of format each row specified height. actually in each cell writing data dynamically. if text larger, row height in not increased. so ther anyway tat row height increased fit cell text. to set row autofit: $objphpexcel->getactivesheet()->getrowdimension(10)->setautosize(true); and set individual cells allow wrapping $objphpexcel->getactivesheet()->getstyle('a10:d10')->getalignment()->setwraptext(true);

javascript - How to retrieve JSON variables from a AJAX response -

when tried fetch values json response, stucked up. here code code: $.ajax({ url: 'checkvotes.php', datatype: "json", success: function(data) { // want fetch , down variables json here } }); ajax response php {"sample":[{"id":"1","message":"my message","up":"200","down":"34"}]} $.ajax({ url: 'checkvotes.php', datatype: "json", success: function(data) { var = data.sample[0].up; var down = data.sample[0].down; } });

web services - Mobile Application Using Sencha Touch - JSON Request Generates Syntax Error -

i started playing bit sencha touch. so i've built simple application based on 1 of examples see how goes. basically creates json request executes last.fm web service music events near user's location. here's json code: var makejsonprequest = function() { ext.util.jsonp.request({ url: 'http://ws.audioscrobbler.com/2.0/', params: { method: 'geo.getevents', location: 'são+paulo+-+sp', format: 'json', callback: 'callback', api_key: 'b25b959554ed76058ac220b7b2e0a026' }, callback: function(result) { var events = result.data.events; if (events) { var html = tpl.applytemplate(events); ext.getcmp('content').update(html); } else { alert('...

PHP: get frame from SWF to JPEG or GIF -

how frame animate swf jpeg(or better animate gif), using php. possible using ffmpeg? thanks. this not possible without using windows box open file , capture screenshot of file. if can convert .swf .flv can use ffmpeg pull frame, if game, yea sort of out of luck unless can setup (or on) windows box. i try , find code used windows capture screenshot, worked in windows 7 , xp , post here, have wait till later not have access backup files right now. you might take @ thread: website screenshots using php

c# - How can I know which method called event handler -

i have 2 methods: private void rvlisten_opt() private void rvlisten_fut() on event, both call: void onrvmessagereceived(object sender, sigrvmessageeventargs args) when onrvmessagereceived called, how can check of 2 methods called it? know can done using object sender, i'm not sure how it. if can edit sigrvmessageeventargs class add field set differently in 2 calls.

objective c - Have 2 different TableViews in one UIView -

i have 2 tableviews in view right now. 1 grouped: can press , push view(like menu) other 1 plain: want show searchresults i know can use displaycontroller don't know how show results on table can tell me more this?? thanks in advance you showing 1 tableview @ time right? a tableview's style cannot changed once created. if want avoid creating 2 tableviews in ib, can instead create 1 tableview @ runtime. when creating tableview, can tell style want using initwithframe:style: method.

sockets - How to get computer's WAN IP address in Java? -

how wide area network of computer java? try this: serversocket ss = new serversocket(port); system.out.println(ss.getinetaddress().gethostaddress()); //wich return 0.0.0.0 then try this: system.out.println(inetaddress.getlocalhost().tostring()); //which return keenan-a658368c/192.168.1.100 < yes connected router like function said, return local ip address how wan ip address? such 118.137.43.219 you can http://whatismyip.com/automation/n09230945.asp . can open httpurlconnection site , parse output. this program should helpful : import java.net.httpurlconnection; public class getexternalip { public static void main(string args[]) { try { java.net.url url = new java.net.url( "http://whatismyip.com/automation/n09230945.asp"); java.net.httpurlconnection con = (httpurlconnection) url .openconnection(); java.io.inputstream stream = con.getinputstream(); ...

java me - J2ME: Get only year/month/day from DateField -

i'm trying use datefield display year, month or day has been selected in calendar. public datefield getdatefield() { datefield = new datefield("datefield", datefield.date); datefield.setdate(new java.util.date(system.currenttimemillis())); } then i'd use code, instead of long date "thu oct 07 00:00:00 gmt+02:00 2010" see month has been selected, "october" or "10" etc. string month = datefield.getdate().tostring(); system.out.println("selected month: " + month); i can't find on datefield thing... want short date "2010-10-05" if specific date has been selected in datefield. calendar cal= calendar.getinstance(); cal.settime(datefield.getdate()); string date = cal.get(calendar.year) + "-" + ( cal.get(calendar.month) + 1 ) + "-" + cal.get(calendar.day_of_month);

sql server - Best way to enforce this data-integrity constraint? -

i have 3 tables (lets call them foo, bar , baz. tables: foo fooid bar barid fooid baz bazid barid anothervalue obviously foreign keys make each baz associated bar, , hence, associated foo. want ensure each set of baz same "anothervalue" associated foo's unique for instance, if had foos (1, 2, 3) bars ((10, 1), (11, 1), (12, 1), (13, 2)) bazs ((100, 10, "a"), (101, 10, "b"), (102, 13, "a"), (104, 11, "b")) this should blocked because baz 104 , baz 101 both have anothervalue "b" , foo 1. options have thought of (in order of current preference) indexed view i create view on these 3 tables , put unique index on 2 columns computed column add fooid computed column baz. add index on anothervalue , fooid. check constraints i'm pretty sure can added , work. haven't used check constraints much, , i'm not sure if best way this. trigger this seems ugly me. ...

objective c - Object changes from NSMutableArray to NSData to NSString -

i have program works normally. downloaded code http://github.com/matej/mbprogresshud show progress meter when doing something. this code makes progress meter pop up. [hud showwhileexecuting:@selector(mytask) ontarget:self withobject:nil animated:yes]; this show progress meter while method mytask running. this code showwhileexecuting method. - (void)showwhileexecuting:(sel)method ontarget:(id)target withobject:(id)object animated:(bool)animated { methodforexecution = method; targetforexecution = [target retain]; objectforexecution = [object retain]; // launch execution in new thread taskinprogress = yes; [nsthread detachnewthreadselector:@selector(launchexecution) totarget:self withobject:nil]; // show hud view [self show:animated]; } if use call function mytask 1 of class properties change nsmutablestring nsdata object somewhere, , later on change nsstring . don't see anywhere in code causes change, it's kind of bug. memo...

mysql - PHP show values of associative array when one of the values equals a specified value -

i have mysql recordset have put associative array can reuse on , over. i used function put values array: while(($comments[] = mysql_fetch_assoc($rscomments)) || array_pop($comments)); here print_r($comments) displays array ( [0] => array ( [commentid] => 10 [comment] => ouch [commentauthor] => randy krohn [commentdate] => 2010-10-06 17:19:49 [id] => 1231 [categoryid] => 42 ) [1] => array ( [commentid] => 12 [comment] => dirty duck [commentauthor] => john lemoine [commentdate] => 2010-10-06 17:22:43 [id] => 1411 [categoryid] => 42 ) [2] => array ( [commentid] => 13 [comment] => talk deja vu! [commentauthor] => dber [commentdate] => 2010-10-06 17:24:48 [id] => 1473 [categoryid] => 42 ) ) i looping through list of images, , want display comments associated images specified imageid (for example 1473). i need display ones id equal specified value? this must easy, reason, flying on head. thanks help! ...

database design - Composite Index vs. INCLUDE Covering Index in SQL Server -

Image
i understand composite indexes used left right (e.g. if index on city, state, city = "blah" or city = "blah" , state = "aa" work fine state = "aa" not). does same principle apply include indexes? thanks in advance! clay include columns can used supply columns select portion of query. cannot used part of index filtering. edit : further clarify point, consider example: i create simple table , populate it: create table mytest ( id int, name char(10) ) insert mytest (id, name) select 1, 'joe' union select 2, 'alex' now consider these 3 indexes , corresponding execution plans simple select. select id, name mytest name = 'joe' case 1 : index on id results in table scan. create index idx_mytest on mytest(id) case 2 : index on id including name. better because index covers query, still scan operation. create index idx_mytest on mytest(id) include (name) case ...

fonts - Delphi 6 : How can I display large size high quality Text via the TextOut() method? -

i have timage component print text string using tcanvas.textout(). set height , width of timage large size 50 pixels x (textwidth) pixels, , set canvas font height little smaller 48 pixels. bitblt() timage's bitmap on main canvas. see on screen big skinny letters terribly jagged. want instead thick jumbo letters appear smooth. reason using timage/bitblt combo because need resizing , alpha blending of text on fly. what easiest way me big smooth letters printed timage bitmap? are never displaying timage ? should use off-screen bitmap instead. common technique achieve double buffering (flicker-free rendering). for example, var bm: tbitmap; procedure initoffscreenbitmap; begin bm := tbitmap.create; bm.setsize(bmwidth, bmheight); end; procedure drawbitmap; begin // draw on bm end; procedure swap; begin bitblt(canvas.handle, x, y, bmwidth, bmheight, bm.canvas.handle, 0, 0, srccopy) end; if using modern version of windows (e.g. vista+), or windows xp...

c# - Partially Overriding a Virtual Auto-Property in a Child Class -

time theoretical question ran across. the following code valid , compiles: public class parent { public virtual object testproperty { get; set; } } public class child : parent { private string _testvalue = "hello world!"; public override object testproperty { { return _testvalue; } } } public class consumer { parent p = new child(); public consumer(){ p.testproperty = 3; } } my question is: why c# allow me partially override testproperty auto property in child when leads partially unpredictable behavior? there practical application? i'm allowed set value of testproperty using parent's setter (i checked il being generated , setter still setting backing object in parent class) though value not accessible public. this behavior consistent non-auto-implemented properties in c#. it's been possible override or set method virtual property. hence making impossible auto-implemented property create unnecessar...

struts2 - Why am I not getting Spring Security Login Error Messages? -

using spring security 3 along struts 2 , tiles 2, have login page appears when supposed , performs login expected -- when enter bad user credentials returned login page no information went wrong. i've checked configuration parameters , can't see problem is. my spring security xml config follows: <http auto-config="true" use-expressions="true"> <intercept-url pattern="/" access="permitall" /> <intercept-url pattern="/css/**" access="permitall" /> <intercept-url pattern="/images/**" access="permitall" /> <intercept-url pattern="/js/**" access="permitall" /> <intercept-url pattern="/public/**" access="permitall" /> <intercept-url pattern="/home/**" access="permitall" /> <intercept-url pattern="/user/**" access="hasrole('auth_manage_users')...

css - divs and background images -

so here problem i'm trying solve, want use background image 500px wide divs has drop shadow on right edge want text stop , wrap after 475px , still want entire image show include dropshadow. there anyway accomplish this? html code: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <link href="tech/sandbox2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="page1top">top</div> <div id="page1mid">lorem ipsum dolor sit amet, consectetur adipiscing elit. donec sodales, sapien vel porttitor eleifend, dui ante rutrum ligula,...

c# - Transferring Data between two SQL Server 2000 Repository -

i need extract data sql repository process , save in 2nd repository. nature of data: transfer selected users data, though tables similar in both repository not same, , amount of processing needs done on data transferred. the volume data large 5,00,000. what technique should used transfer data: use stored procedure through link server transfer data. use dts - data transfer service (since have sql server 2000 can’t use ssis). use c# extract data repository a, process , call sp insert data in repository b. i not sure way go, process data in optimal , robust manner. any suggestion appreciated. thanks in advance. thanks reply thought said dts fastest but have constraint thought limit using dts problem have 3 levels of hierarchy in tables (foreign keys levels) , destination database generate auto identity values each table in hierarchy main concern if able maintain relations newly generated identity values if use dts i new dts concept have strong knowledge of store...

css3 - Best CSS buttons that are cross browser, degrade gracefully, and work on input or link -

i have seen lot of attempts @ css buttons (for example http://ubuwaits.github.com/css3-buttons/ ) but haven't seen 1 emerge yet safe use in production , meets following requirements: looks on modern browsers degrades gracefully on older browsers down @ least ie7 (bonus if ie6) - don't care if good, long aren't noticeably bad works equally on input tag (submit button) or link (a tag) what best ones people using in production? better still use css sprites. involves putting button states in 1 image file , setting background-image property. changing position of background-image @ different states (active, hover) image appears switch when in fact change position. google css sprites tutorial more. also navigation bar or list should unordered list each button element. degrades best.

java - Find nearest date from a list -

i have list of dates , current date. how can find date nearest current date? i'd use collection.min custom comparator "orders" dates according distance current time. final long = system.currenttimemillis(); // create sample list of dates list<date> dates = new arraylist<date>(); random r = new random(); (int = 0; < 10; i++) dates.add(new date(now + r.nextint(10000)-5000)); // date closest "now" date closest = collections.min(dates, new comparator<date>() { public int compare(date d1, date d2) { long diff1 = math.abs(d1.gettime() - now); long diff2 = math.abs(d2.gettime() - now); return long.compare(diff1, diff2); } });

xslt - How to use XSL variable in xsl:apply-templates? -

i have reasonably complex call xsl:apply-templates: <xsl:apply-templates select="columnval[@id , not(@id='_name_') , not(@id='group') , not(@id='_count_')]"/> the expression reused in other places this: <xsl:apply-templates select="someothernode[@id , not(@id='_name_') , not(@id='group') , not(@id='_count_')]"/> i want generalize somehow, can define once , reuse elsewhere. however, doesn't seem work: <xsl:variable name="x">@id , not(@id='_name_') , not(@id='group') , not(@id='_count_')</xsl:variable> <xsl:apply-templates select="columnval[$x]"/> <xsl:apply-templates select=...

Any unzip-and-run Visual-Studio or third party free tool? -

i use clickonce publication method, hate sending bunch of files people , having "please unzip , run setup". need simple thing. program puts files in single file, unzip them temp folder , runs setup. haven't check deep in visual studio features (i'm using 2010 professional version) far haven't found way achieve this. check out install package builder advanced installer . package exe or msi install you. can have build solution each time you! freeware version should work fine simple installs. edit i'm sorry thought freeware version unlimited :( apologies.

networking - How can I display posts from the other sites in a WordPress multisite setup? -

i have small network of sites setup wordpress 3.0's multisite feature. create site pulls posts various other sites display. new 'hub' site seem own separate site user (with domain mapping), content coming posts other sites. how can posts site in wordpress multisite setup? can query posts based on name of site? end result needs collection of posts different sites sorted date. thanks help. i had similar issue wanted posts 1 blog , display on other came following solution modify meet needs if needed <?php global $switched; switch_to_blog(2); //switched 2 // latest post $latest_posts = get_posts('category=-3&numberposts=6&orderby=post_name&order=dsc'); $cnt =0;?> <ul> <?php foreach($latest_posts $post) : setup_postdata($post);?> <li> <a href="<?php echo get_page_link($post->id); ?>" title="<?php echo $post->post_title; ?>"><?php echo short_title('...

python - Modelling Data with Google App Engine Datastore -

i building web application on google app engine in python harvest horse racing data of form. basic data structure course has many meetings has many races has many horses has 1 jockey , had 1 trainer. far have got following models (reduced number of fields sake of brevity). class course(db.model): course_number = db.integerproperty() # course id (third party) course_description = db.stringproperty() # course name class meeting(db.model): course = db.referenceproperty(course) # reference course meeting_number = db.integerproperty() # lifetime meeting number course meeting_date = db.dateproperty() # meeting date class race(db.model): meeting = db.referenceproperty(meeting) # reference meeting race_number = db.integerproperty() # eg 1 1st race of meeting race_name = db.stringproperty() # race name time_of_race = db.timeproperty() # race time i having trouble working out how store data on horses, trainers, jockeys in data...

ruby on rails - Is attr_accessible inherited by derived classes whe using STI? -

i've got class structure similar family of classes using sti class root < activerecord::base attr_accessible :root_prop end class child < root attr_accessible :child_prop end class grandchild < child attr_accessible :gc_prop end all properties working fine until added attr_accesible markers, know related that. appears properties giving accessible status on base classes not getting set. attr_accessible need set each class, or need somewhere else reason values not getting set? the comment here answer. attr_accessible method work derived classes. however, when dealing associations, accessible attribute requires _id suffix class grandchild < child attr_accessible :associated_class_id belongs_to :associated_class end is correct way mark association attr_accessible method. detail missing original question.

navigation - Active menu state in wordpress -

i have 2 blog pages: other 1 gets post 1 category , other gets post other categories. , im using new menu system introduced in 3.0. now problem when user on lets on category2 single post page, still in menu category1 has active state class. on both categories, single post uses same template (the default one). well that's easy there nice post on here , put in function.php file within theme. <?php function insertads($content) { $content = $content.'<hr /><a href="http://www.wprecipes.com">have visited wprecipes today?</a><hr />'; return $content; } add_filter('the_excerpt_rss', 'insertads'); add_filter('the_content_rss', 'insertads'); ?>

Saxon XSLT 2.0 and RFC 822 date format -

what right way format xs:datetime rfc 822? you need fn:format-datetime i think should be: format-datetime(current-datetime(), '[fnn,*-3], [d01] [mnn,*-3] [y0001] [h01]:[m01]:[s01] [z]', 'en', '', 'us') right now, me, output: thu, 07 oct 2010 21:10:03 -03:00

c# - mdbg can't debug my hello world program -

in order try out mdbg, have following simple hello world program: // kkk.cs using system; class hellomain { static public void main() { console.writeline("hello"); } } compile csc /debug kkk.cs, yields: kkk.exe kkk.pdb i (from visual studio command line): mdbg kkk.exe or mdbg !r kkk.exe i got: error: request not supported. (exception hresult: 0x80070032) try csc /debug /platform:x86 kkk.cs you're running on 64-bit windows. mdbg 32-bit process , can debug 32-bit processes.

java - Service layer and controller: who takes care of what? -

in class we're learning how build spring application, though spring isn't directly involved, learned how make interfaces dao , service layer objects. please correct me if i'm wrong: dao layer pretty abstract: contains crud operations , further used read data.(ie: objects, specific objects, etc) service layer: contains services create things, , delete things, business logic should be. now of makes sense in service layer; except "updating" objects. put "update" function saves object in database? or need define logic there well? confusion as, understanding objects in spring pojo's. validates data? let's have object "child" has: name , surname , gender , photo , birthdate fields. how name services? or let controller take care of validation, doesn't seem right me. on other hand wouldn't seem right either delegate every setter needs called service layer. so basically: me how define saving objects via service layer. ...

networking - How to determine (using C API) the system's default NIC? -

in linux, after establishing dhcp lease, when run command route , last line gives me system's default route , nic. e.g., kernel ip routing table destination gateway genmask flags metric ref use iface 142.157.138.0 * 255.255.254.0 u 2 0 0 wlan0 link-local * 255.255.0.0 u 1000 0 0 wlan0 default 142.157.138.1 0.0.0.0 ug 0 0 0 wlan0 is there way nic marked "default" through c api, instead of running route , parsing output? thanks. (interesting in linux , darwin, windows.) i don't know off-hand, study source. on ubuntu box, route provided net-tools : ~$ route /sbin/route ~$ dpkg -s /sbin/route net-tools: /sbin/route so make directory somewhere, run apt-get source net-tools . poked source, , route.c looked place start. if there's no arguments passed route , calls route_info() given address family , options, grep that: ~/z$ g...

jquery: hide title attribute but not remove it -

i have seen people solution on mouse over, grab value in title attribute, then, remove value. while on mouse out, we'll put on. $(this).attr('title',''); or $(this).removeattr('title'); i want know possible hide tooltip appearing removing title attribute? thanks! no can't, browser decide title attribute. can, however, save node later reference (and possibly restoring title): $(this).data("title", $(this).attr("title")).removeattr("title");

python - Changing the active database in django -

i'm writing testing application i'm using test rest of code base. i'd able when test using manage.py command, automatically change logging different database. there way this? django automatically creates , drops test database you. unless otherwise specified (we'll see how in second) test_ + <the name of database in settings file> . if settings uses database foo , tests executed against test_foo . no configuration changes needed this. if wish execute tests against custom database (rather test_foo ) can tweaking test_name setting . can add test_name each dictionary in databases .

binding - How do I make my WPF User Control's dependency properties update my view model? -

i'm trying create user control dependency properties bind to. internally have combobox bound these same properties, binding works 1 way. combobox fills itemssource , selecteditem doesn't updated viewmodel i'm binding to. a simplified example: this view model bind user control: public class peopleviewmodel : inotifypropertychanged { public peopleviewmodel() { people = new list<string>( new [] {"john", "alfred","dave"}); selectedperson = people.firstordefault(); } public event propertychangedeventhandler propertychanged; private ienumerable<string> _people; public ienumerable<string> people { { return _people; } set { _people = value; if (propertychanged != null) { propertychanged(this, new propertychangedeventargs("people")); } } } private string _select...

Rails Nested Attributes Mass Assignment Error -

i have user model cannot create client due being unwritable in mass assignment. how make can create client model? code , error found here: http://pastie.org/1206482 i think have add: attr_accessible :client_attributes to user model. client_attributes hash in user hash posted create action. the transmitted hash looks this: :user => { :username => "one", ..., :client_attributes => { :name => "client" } }

Managing User Accounts with Rails 3 and Devise -

i have implemented devise in rails 3 application , need admin users able manage users. users not registerable , therefore admin must create accounts. best way go this? it doesn't seem dry create own userscontroller when devise provides devise::registrationcontroller don't see other options. i opted create own userscontroller along side registrationcontroller . makes sense have own restful controller admin purposes. it's not devise's job manage user records , maintain administrative fields associated them. is, after all, authentication framework. seems correct leave designed for. required create own user model reason.

java - Downloading Image to SD Card in Service fails (Android) -

i created separate project , activity downloads image url, converts bitmap, , uses fileoutputstream save file sd card. when in separate project , free-standing activity, worked fine, , see image stored on sd card. public class picturedownload extends activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); downloadfromurl("http://www.coutblog.com/prism/uploads/0030.jpg", "newpic.jpg"); displaypic("newpic.jpg"); } // place download file private final string path = "/sdcard/"; public void displaypic(string filename) { imageview image = (imageview)findviewbyid(r.id.image); bitmap bmap = bitmapfactory.decodefile(path + filename); image.setimagebitmap(bmap); } /** * downloads picture url sd card * @param imageurl: url download (absolute web url) * @param filename: name of fi...

How should I handle errors inside or outside a Perl module? -

i started learning how make module in perl perltoot : package person; use strict; my($name, $age, $peers) = ( 0 .. 2 ); sub new { $self = []; $self->[$name] = undef; $self->[$age] = undef; $self->[$peers] = []; bless($self); return $self; } sub name { $self = shift; if (@_) { $self->[$name] = shift } return $self->[$name]; } sub age { $self = shift; if (@_) { $self->[$age] = shift } return $self->[$age]; } sub peers { $self = shift; if (@_) { @{ $self->[$peers] } = @_ } return @{ $self->[$peers] }; } 1; i know how, if possible sample code should threat errors within module , outside ? for example: use person; $test= person->new() or die person->error; or sub new { $self = []; $self->[$name] = undef; $self->[$age] = undef; $self->[$peers] = []; bless($self); ######### # error happened here , need ######### return $self; } ...

cocoa touch - When should i release this object? -

- (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview *)view { cgrect imageframe = cgrectmake(0.0, 0.0, 15, 15); uiimageview *label = [[uiimageview alloc] initwithframe:imageframe]; if (row == 0) { label.backgroundcolor = [uicolor redcolor]; } if (row == 1) { label.backgroundcolor = [uicolor bluecolor]; } if (row == 2) { label.backgroundcolor = [uicolor blackcolor]; } return label; } label leak. know it. but.... just [label autorelease]; before return

xaml - In WPF, how do I set a button's click event to change a grid's visibility? -

i'm trying set button's event change grid's visibility using xaml. i'm pretty sure should using eventtrigger, couldn't work recent attempt create datatrigger bound field in view-model: <style x:key="personalinfogridstyle" targettype="{x:type grid}"> <style.triggers> <datatrigger binding="{binding path=personalinfogridvisibility}" value="collapsed"> <setter property="grid.visibility" value="collapsed"/> </datatrigger> </style.triggers> </style> the above code isn't working, matters less me achieving whole thing in xaml (without using view-model or code-behind). can explain how should go or if it's possible? :) ahead can use toggle button? <window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="htt...

c# - How to change the property of a control from a flowlayoutpanel? -

Image
how change property of control in flowlayoutpanel assuming add controls programatically , assuming name of each controls same? for example image shows there 2 text boxes , 2 buttons, how change color of button 2? assuming controls has been added @ runtime. foreach(controls ctrl in flowlayoutpanel1.controls) { //what should put here? } well, easiest way retain explicit reference buttons you're adding. otherwise add tag distinguish them (to robust against i18n issues). e.g. can set tag of "button2" "button2" , can use: foreach (control ctl in flp.controls) { if ("button2".equals(ctl.tag)) { ctl.backcolor = color.red; } } i assuming problem find actual button again , not setting background color. likewise check control being button , text being "button2" if text can change depending on ui language that's not idea. eta: totally forgot can use control's name property well. if want change backg...

javascript - Intercepting DOM and JS engine calls -

i want intercept dom object read , write queries fired js while getting loaded browser. after intercepting these calls, wish screen them. have written logic screening not able block calls. is there way other modifying source code of browser achieve this? if pls me. you mean this? (for reason fails in fx illegal operation) <script> var oldget = document.getelementbyid; document.getelementbyid=function(id) { return confirm('someone wants know '+id+', ok?')?oldget(id):null; } window.onload=function() { alert(document.getelementbyid('div1').innerhtml); } </script> <div id="div1">hello</div>

How to convert string to xml file in java -

<?xml version="1.0" encoding="utf-8"?><soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"><soap:body><loginresponse xmlns="http://tempuri.org/questiphonewebservice/questiphonewebservice"><loginresult>&lt;return_value&gt;&lt;error result= '-1' desc = 'the password entered system not valid. please check password , try again.'/&gt;&lt;/return_value&gt;</loginresult></loginresponse></soap:body></soap:envelope> hi getting value webservices. want convert above string xml can tell how convert string xml file in java <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instanc...

displaytag - Display tag pagination problem -

in display tag used pagination feature ,when want see list of 15 rows display tag featch rows database. every time when click on pagination number,it featch of rows db.bcoz of slow performace of application. i want in display tag when want see 15 rows display tag fetch 15 rows db not entire db rows. plz me if 1 knows. you have use external pagination feature. first, specify in html tag you're using external pagination. , create object implements org.displaytag.pagination.paginatedlist . finally, have implement dao makes query 15 rows , returns paginatedlist. 1) jsp this <display:table name="command" sort="external" partiallist="true" size="${command.fulllistsize}" pagesize="${command.objectsperpage}"> <display:column property="name" title="name"/> ... </display:table> note specified sort external. 2) org.displaytag.pagination.paginatedlist implementation. public cla...