Posts

Showing posts from March, 2012

Are there other default maven archetype properties -

i'm creating maven archetype has bunch of custom properties. ex: <requiredproperties> <requiredproperty key="db-name"> <defaultvalue>some db-name</defaultvalue> </requiredproperty> <requiredproperty key="station-name"> <defaultvalue>localhost</defaultvalue> </requiredproperty> ... </requiredproperties> when new project generated based on archetype maven knows default variables groupid, artifactid, version. maven knows others trivial variables env.user, user, host, path, basedir or others? are? how can them? thanks. i realise old question, came across question earlier , voted it. wondering same, have come solution / workaround enabling access these properties. i created own maven plugin aptly named property-setter-maven-plugin sets system and, importantly, execution properties. configuration of plugin allows number of properties , values specified (and since de...

android - Confused about pixels and points -

i know question may relate design, since pretty important part of programming applications looks on multiple devices different screen try asking here. have browsed other questions here relates points , pixels, find formula, ok not understand it. from here: wikipedia - points (1 point = 1⁄72 inches = 25.4⁄72 mm = 0.3527 mm) so start: point way of measuring, else right? 1 point defined 1/72 inch, constant? why wikipedia article 1/72 inch equals 0.3527 mm? when divide 1/72 inch , multiple result 2.54 centimeters 0.0352775? i appriciate if "guide" me through convertion of pixels points , again. feel pretty uncomfortable points. sorry asking stupid question. read followings carefully: 1 point = 1⁄72 inches 1 inch = 2.54cm --> 1 point= 2.54 cm/72 = 0.03527cm 1 cm = 10 mm --> 0.03527 cm = 0.3527 mm // missed this 1 point = 0.3527 mm

javascript - using Change on an Input and then modifying the input's ATTR? -

given: html <input checked="checked" class="list_completed_checkbox" id="list_item_completed" name="list_item[completed]" type="checkbox" value="1"> jquery: $('.list_completed_checkbox').change(function() { $(this).attr('disabled', 'disabled'); }); when check or uncheck checkbox, why isn't disabled attr being applied input? thanks your code works me: http://jsfiddle.net/jasongennaro/qye96/ perhaps else interfering?

iphone - Is there a way to determine device orientation if view is loaded before [window makeKeyAndVisible] is called? -

view of uiviewcontroller loaded nib before [window makekeyandvisible] called in application:didfinishlaunchingwithoptions: cannot correct device orientation - i.e. self.interfaceorientation , [[uiapplication sharedapplication] statusbarorientation] , [[uidevice currentdevice] orientation] give me false orientation info i'm in portrait mode (ipad's default mode, think). is there way work around problem? please don't need use accelerometer ;) edit: interested on getting orientation info based on accelerometer reading: http://web.archive.org/web/20091111033649/http://blog.sallarp.com/iphone-accelerometer-device-orientation it appears can't rely on [uidevice currentdevice].orientation until orientation changes first time. if so, hack getting raw accelerometer readings. #define kupdatefrequency 30 // hz #define kupdatecount 15 // init after half second #define kfilteringfactor (1.0f / kupdatecount) - (void)applicationdidfinishlaunching:(uiapplica...

Wicket listview skipping `list` tag -

how can generete next list <span wicket:id="listview"> label is: <span wicket:id="label">a</span><br/> label is: <span wicket:id="label">b</span><br/> label is: <span wicket:id="label">c</span><br/> </span> instead of <span wicket:id="listview"> label is: <span wicket:id="label">a</span><br/> </span> <span wicket:id="listview"> label is: <span wicket:id="label">b</span><br/> </span> <span wicket:id="listview"> label is: <span wicket:id="label">c</span><br/> </span> if someting unclear pease write. how this? wicket:container tag not show in final markup. <span> <wicket:container wicket:id="listview"> label is: <span wicket:id="label">a</span...

php - dynamically created HTML file input element doesn't post data -

i have form dynamically created using document.createelement. components created in same way. form used upload file php script , when submitted loads reponse in iframe specified target attribute of form. unfortunately, server receives blank $_files array, , when inspect post request see file data wasn't included in request. if instead, on-the-fly, use google chrome developer tools edit dynamically created form (in process edit , change absolutely none of code), form submissions thereafter work perfectly, sending relevant file data. so makes me realise there nothing wrong construction of form in html, because worked without changing anything. leads me believe browser doesn't me dynamically create file input elements? for completeness' sake, here dynamically generated form: <form method="post" action="includes/uploadpic.php" enctype="multipart/form-data" target="fileresponse"> <input type="file...

sqlite - PHP SQLite3 Catch All Errors -

i trying ways catch sqlite3 errors in php? have tried many , seem work. consider code below, enough catch errors? can suggest else? $result = $stmt->execute(); if ($this->db->lasterrorcode()){ throw new databaseerror($this->db->lasterrormsg(), $this->db->lasterrorcode()); } else { return $this->db->changes(); } i think enough because there's error code when error raised of course must work.

c# - Selenium: Get all text with same id -

Image
the xpath of elements want read (accounting, business, marketing, technology) follows: /html/body/table/tbody/tr/td[2]/table/tbody/tr/td[2]/font/a /html/body/table/tbody/tr/td[2]/table/tbody/tr/td[4]/font/a /html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[2]/font/a /html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[4]/font/a the id of elements is //font[@class='wlcategorylinkbold']/a the page testing similar following: i have following test method: public void listalllinksinarray() { selobj = new defaultselenium("localhost", 4444, "*iexplore", "http://localhost/crm.aspx"); selobj.start(); selobj.open("http://localhost/crm.aspx"); selobj.selectframe("content"); list<string> topics = new list<string>(); int count = (int)selobj.getxpathcount("//font[@class='wlcategorylinkbold']/a"); (int = 1; <= count...

iphone - ObjectiveC sqlite3 issue -

i'm finding have issue when updating/inserting table in iphone app because have text column, , when text includes ' symbol, things messed up. best way handle this? should check before use string has apostrophe? there quick way add formatting add escape character in front of each apostrophe? does question make sense? lol. sqlite requires ' symbol escape 2 ''. look @ official sqlite faq : (14) how use string literal contains embedded single-quote (') character? sql standard specifies single-quotes in strings escaped putting 2 single quotes in row. sql works pascal programming language in regard. sqlite follows standard. example: insert xyz values('5 o''clock');

mysql - sql_range_query error with Sphinx -

while setting sphinx on production server, strange error came when trying index error: index 'benefit_core': sql_range_query: have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1 this doesn't happen on local machine. , yes, empty string. does seen type of issue before? benefit.rb define_index # fields indexes category indexes title indexes tags indexes description indexes brief_description indexes brand indexes short_description indexes long_description indexes benefit_description indexes address.city indexes address.state indexes address.street_1 sanitize_sql(["active = true , expiration > ?", time.now]) set_property :field_weights => { :title => 15, :tags => 10, :brand => 10, :description => 3 } end thinking-sphinx - 1.4.4 sphinx - 0.9.9 thank you! be sure running recent version of thinking sphinx, 3.0.4 ...

javascript - Question on tabbing to next NON-READONLY field -

on blur of field1, field2 set readonly cursor on page defaults field2 , cursor located @ end of value , when user clicks backspace button value can erased. ability have cursor move next non-readonly or enabled field on page. do-able jquery? any help/direction appreciated. thank you. here code: [code] $(function() { $("#artransferform\\:fromaccountamt").blur(function() { var origaccountamount = $("#artransferform\\:fromaccountamt").val(); var fromaccountamount = $("#artransferform\\:fromaccountamt").val(); // call validation "r2" function var modfromaccountamount = r2(fromaccountamount); //alert("modfromaccountamount = " + modfromaccountamount); fromaccountamount = $("#artransferform\\:fromaccountamt").val(modfromaccountamount).val(); //alert ("modified fromaccountamount = " + fro...

iphone - Calling a SuperClass's DataSource? -

i working on simple slot machine. sub-classed uipickerview. pickerview datasource don't need define in controller, because 5. can define in subclass so? @interface slotmachineview : uipickerview <uipickerviewdatasource> { } @end #import "slotmachineview.h" @implementation slotmachineview - (id)init{ if ((self = [super init])) { super.datasource = self; } return self; } - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview{ return 5; } - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component{ return 5; } - (void)dealloc { [super dealloc]; } @end yes, can. can write self.datasource = self , because super , self same object*. remember, object instance of superclass instance of class it's declared as. has same properties , responds same messages. *the difference between super , self super skips on methods defined in current class.

vb.net - Unable to execute SQL command in windows service -

i'm working on creating windows service send emails customer when within month of having submission expire. i'm using vb.net in visual studios 2008 because it's windows service it's difficult debug. trying narrow down error created "senddebugemail" method sends me email if gets line. emails never make past "dr = cmd.executereader()" i'm wondering doing wrong. sql statement should work fine. i've tested in sql server database. i've created dummy_database made in sql server well. added insert sql statement dummy table have in there see if access database. table takes in line number , time sent. when run windows service database updates fine. any appreciated. thanks dim conn new sqlconnection(connstring2) senddebugemail("134") sql = "select email _customer custid in (select custid _onlinecustomer expirationdate <= '6-20-12' , expirationdate >= '6-10-12')" dim cmd new sqlc...

ruby - Return match position in String.scan -

i need scan larger text documents patterns expressed in regular expressions , extract number of surrounding text tokens. @ moment use string.scan retrieve matches, doesn't give me position of matched string in document. there elegant solution this? check out post . it works on match object. m.begin(1)

extjs4 - How do I enable only new rows in a Ext 4 Grid Panel? -

so have extjs 4 grid panel has 2 columns. column one combobox custom renderer ext.ux.comboboxrenderer = function(combo) { return function(value) { var idx = combo.store.find(combo.valuefield, value); var rec = combo.store.getat(idx); return (rec == null ? '<img src="/js/extjs4/resources/themes/images/default/grid/loading.gif" />' : rec.get(combo.displayfield) ); }; } column two numeric column { allowblank: false, header: 'time', dataindex: 'tedpaidtime', align: 'right', field: { xtype: 'numberfield', allowblank: false, minvalue: 0, maxvalue: 100000 }, flex: 0.20, selectonfocus:true } now, when load datastore , want first column read only. easy if set readonly flag. however, have button adds new record store , want new record not have readonly flag. so basically, once change column 1 , save, can not alter it. able alter new records befor...

objective c - Draw a square on Mac OS X? -

i draw small square, 4x4 pixels. able adjust color @ runtime (not color or anything, user doesn't need able to). had been doing nsimage , uses lot of resources , can't adjust, , making different little color swatch in photoshop change new color huge pain, no longer suitable. how can done on mac os x ? the simplest way draw 4x4 square @ coordinate 0,0 (bottom left) on mac os x: nsrectfill(nsmakerect(0.0, 0.0, 4.0, 4.0)); the simplest way set colour used sort of drawing: [[nscolor colorwithcalibratedred:... green:... blue:... alpha:1.0] set]; ;)

c# - Login popup vs Login page -

want know best practice when have multiple logins forms. do you: a) place each on single webform. b) use modal popup update panel inside. trying think best seo. cheers do whichever creates better user experience. if worried seo on login pages, may want reconsider priorities.

css - How do I dynamically create a collage (grid with no gaps) of images, where images have different heights? -

Image
i want display page of thumbnails. thumbnails user uploaded artwork images. each image has constrained width, not constrained height, show full image without cropping. i want images butt against each other no gaps in between. number of columns not fixed: if expand or resize page images should flow correct number of columns. float:left is almost, want. except when there tall images in page gapped look: how eliminate gaps? if want in css have create divs every column, , float columns (but messes order of images). alternatively, can use jquery plugin this one .

javascript - Multiple timers on the same page don't work smoothly -

i have 3 javascript timers working @ same time on page using settimeout , functions called these timers not working smoothly , seems timers waiting on each other, , times hang page. is there best practice when dealing js timers avoid behavior? examples: sometimes use jquery timers this: $(document).everytime(1000, "blinkred", function (i) { $(price).toggleclass('valuered'); }, 10); and use normal settimeout javascript function. the timers not waiting each other, functions called when timer done, are. so, when put blocking code (like alert) in first timer function, prevent other timers go off.

Fluent NHibernate and NHibernate version issue -

could not load file or assembly 'nhibernate, version=3.2.0.2002, culture=neutral, publickeytoken=aa95f207798dfdb4' or 1 of dependencies. system cannot find file specified. this caused number of things, probable cause start project not reference assembly 'nhibernate, version=3.2.0.2002, culture=neutral, publickeytoken=aa95f207798dfdb4' although other assemblies have referenced use assembly. add assembly start project , shall fine. and please try ask questions in better manner.

oop - What is the difference between "uses" and "depends upon"? -

in beginners guide dependency injection noticed the uml diagram distinguishes between "uses" , "depends upon". since both require form of reference in class "uses" or "depends upon", wonder: difference between two? check out blockquotes relationship types taken ibm rational software architect documentation . "depends upon" means following: a dependency relationship indicates changes 1 model element (the supplier or independent model element) can cause changes in model element (the client or dependent model element). supplier model element independent because change in client not affect it. client model element depends on supplier because change supplier affects client. "uses" means following: a usage relationship dependency relationship in 1 model element requires presence of model element (or set of model elements) full implementation or operation. model element ...

utf 8 - Does Google Chart support UTF-8 Characters? -

i have title , labels unicode labels in google chart, not being displayed properly. here's example: http://chart.apis.google.com/chart?chs=300x225&cht=p3&chco=344566,c4c4c4&chds=0,90&chma=70,70&choe=utf-8&chtt=test&chd=t:27933485,20611682,34172068&chl=un%e9%a7%85xbr%e1%83%a6cker|test1|test2 characters not appear right see. is there way make google charts display utf-8 characters properly? i've tried many things nothing worked me. the problem appears unicode codepoints (e9a785 -> 99c5 , e183a6 -> 10e6) providing. these characters not appear displayed in google chart. experiments other codepoints (specifying them utf-8 in same format query) appear work fine. the particular characters in example (the first cjk unified ideograms , second georgian) little strange. might want double check correct.

ajax - jquery plugin: what is wrong with $.fn. in my plugin? -

what wrong jquery plugin when make function inside plugin $.fn. you can see mean here . have 2 forms , share same plugin, $(document).ready(function(){ $("#search-title").post_form_public(); $("#subscribe-email").post_form_public(); }); the first form won't working again when second form triggered. it works fine if attach plugin 1 form only. below more details inside plugin code, post_form_public: function(options) { // set default values, use comma separate settings, example: var defaults = { top: 250, // top of proceesing popup , result popup. width: 400 // width of proceesing popup , result popup. } var options = $.extend(defaults, options); var o = options; var $cm = this.submit(function(e){ var object = $(this); // path attribute of action in form. var target_postpath = object.attr('action'); var top = o.top; ...

c - Identifying programs "before" and "after" program in a pipeline are from the same "toolset" -

say, writting toolset every single tool operates on same textual data stream, parses it, operation on , returns textual stream using same syntax in original input. tools can combined (together other unix tools/scripts/whatever) in pipeline. because textual input processing (parsing) quite expensive, avoid in case 2 or more tools toolset 1 right after in pipeline , use binary streams instead (to store directly in memory struct, w/o useless "extra" parsing). possible know (using trick, inter-process communication, or whatever else) if tool "before" or "after" tool in pipeline part of toolset? guess unix env. not prepared such sort of "signalling" (afaik). ideas... no, processes piped have no methods of two-way communication. if parsing expensive necessary (i'd guess isn't, profile it), have 2 options can think of: have master program takes options tell tools run, in order, , have run "parse" tool, followed request...

GWT Frame.seturl different behavior in IE and Chrome -

i create frame in gwt, wanna change frame.set(url) after clicking button. however, found in ie8, no matter url set frame, shows first url set. while, in chrome, works fine, change page displayed after set new url it. it bug of gwt or behavior difference of ie , chrome? string url = gwt.gethostpagebaseurl() + "uploads/disclaimer.html"; frame fame= new frame(url); rootpanel.get().add(frame); while, found settings of ie playing tracks. ie default settings not check new file in same url automatically.

Parse error: syntax error, unexpected T_STRING in /home/sites/vip3796392/httpd/htdocs/index.php on line 38 -

ive been trying move opt-in registration form register.php page onto index make signin more easier, ive hit stumbling block! <?php // connects database mysql_connect("localhost", "o679_members", "akubras08") or die(mysql_error()); mysql_select_db("o679_members_members") or die(mysql_error()); //this code runs if form has been submitted if (isset($_post['submit'])) { //this makes sure did not leave fields blank if (!$_post['username'] | !$_post['email'] | !$_post['pass'] | !$_post['pass2'] ) { die('you did not complete of required fields'); } // checks if username in use if (!get_magic_quotes_gpc()) { $_post['username'] = addslashes($_post['username']); } $usercheck = $_post['username']; $check = mysql_query("select username users username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if name exists gives erro...

sql - Oracle hash data across rows -

suppose have oracle table 2 columns: type varchar2 , data varchar2. want know if there efficient way in plsql or straight oracle sql compute hash on data column (ideally sha1, md5 or custom oracle hash functions acceptable). example, mysql implementation of solution might like: mysql dialect query: select type, sha1(group_concat(data order data separator '')) data_hash my_table group type example output: +------+------------------------------------------+ | type | data_hash | +------+------------------------------------------+ | | dbe343bfc23545c72f11fc7d2433df3263a71d0d | | b | b2baee034a7ed3aa1fa1bd441e141909f1b2f57c | +------+------------------------------------------+ i'd prefer straight query on cursor iteration, , sha1 on other hashes. you try select type, sum(ora_hash(data)) my_table group type oracle have collect doesn't work ora_hash. in 11g can do select deptno, ora_hash(listagg(ename) within gro...

Choosing an MVVM Framework for Silverlight 4 -

i have used mvvmlight before in few projects. has has used prism before know of significant benefits on mvvmlight. or pretty have same features? prism made extensibility components can used implement mvvm designs. think prism heavy simple sl applications. check out earlier post on subject: mvvm light + unity or prism?

Android Phone-to-Phone Communications -

this more explanation asking question. wondering if possible write android application can communicate android phone, given phone number of phone want communicate with. communicate, mean want able send data phone , have application on other phone able recive it. if not possible this, guess alternative have application "sign" phone server. i'm assuming server can act proxy communicate both phones. any clarification helpful! check out bump api. allows establish connection between 2 (i think more possible) devices, , gives channel on communicate. devices need "bumped" first, it's fair game.

Force close while attaching the video in android MMS -

i trying attach video in mms application. application went force close. not able find reason. can provide log. please have on , give me suggestions. 07-01 10:11:34.546: warn/dalvikvm(1064): threadid=1: thread exiting uncaught exception (group=0x4002d560) 07-01 10:11:34.546: info/activitymanager(244): starting: intent { act=android.media.action.video_capture cmp=jp.co.sharp.android.camera/.videocamera.videocamera (has extras) } pid 1064 07-01 10:11:34.556: error/androidruntime(1064): fatal exception: main 07-01 10:11:34.556: error/androidruntime(1064): android.content.activitynotfoundexception: unable find explicit activity class {jp.co.sharp.android.camera/jp.co.sharp.android.camera.videocamera.videocamera}; have declared activity in androidmanifest.xml? 07-01 10:11:34.556: error/androidruntime(1064): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1405) 07-01 10:11:34.556: error/androidruntime(1064): @ android.app.instrumentation.execstartacti...

c# - How can I sort the results of a LINQ query -

i have following query. there easy way sort results in numeric order of rowkey. rowkey string. sort _rowdata , not modify query want try different sort orders , i'm looking 1 line changes , not redo query. var _rowdata = (from qu in _que.getall( u => u.partitionkey == partitionkey ) select new { qu.partitionkey, qu.rowkey, qu.style, qu.shorttitle, modifiedtostring = string.format("{0:mm/dd/yyyy hh:mm}", qu.modified) }); i want sorting outside of linq query. reason want able let user choose sort of rowkey, modifiedtostring , shorttitle. when use orderby extension, don't modify original query, enumerates same values: var _rowdata = ... var _rowdatasortedbyrowkey = _rowdata.orderby( u => u.rowkey ); var _rowdatasortedbymodifiedtostring = _rowdata.orderby( u => u.modifiedtostring ); var _rowdatasortedbyshorttitle = _rowdata.orderby( u => u.shorttitle ); var _rowdatasortedbyother = _rowdata.orderby( ... );

php - Why would \n\r appear if I used nl2br()? -

someone made group on site has description \n\r . thing description text: //convert urls links $group_description = preg_replace('#([\s|^])(www)#i', '$1http://$2', $group_description); $pattern = '#((http|https|ftp|telnet|news|gopher|file|wais):\/\/[^\s]+)#i'; $replacement = '<a href="$1" target="_blank">$1</a>'; $group_description = preg_replace($pattern, $replacement, $group_description); $group_description = str_replace("\'" , "'", $group_description ); $group_description = nl2br($group_description); /* convert e-mail matches appropriate html links */ $pattern = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.'; $pattern .= '[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i'; $replacement = '<a href="mailto:\\1">\\1</a>'; $group_description = preg_replace($pattern, $replacement, $group_description); you can see happening he...

android - Unable to see my files in SD card -

i have created text files in sd card, unable view files. i using path environment.getexternalstoragedirectory(); create files. i not getting exception while creating files. when open ddms in eclipse unable see files there also.. if created files @ environment.getexternalstoragepublicdirectory(environment.directory_pictures); then can see files @ /data folder of device , not in sd card itself. when click on gallery icon in device, can see pictures, videos, camera shots folders not files .. please suggest proper way of creating files in sd card. thanks. environment.getexternalstoragedirectory() doesn't return location external card. on android tablets (android 3.0+) directory mounted in internal memory. from docs : note: don't confused word "external" here. directory can better thought media/shared storage. filesystem can hold relatively large amount of data , shared across applications (does not enforce permissions)...

iphone - Create MailBox in the application -

create our own mailbox in iphone application same functionality of other mailbox. idea how achieve target? in advance if want writing code you, go peopleperhour . stackoverflow isn't give me codez website, website can advice when having problems own code. going give advice: have @ this library. it's ios 4.3 , allows you write mail client in objective-c.

actionscript 3 - Calculating column and row number in an isometric rectangular shaped grid -

i'm trying extend isometric flash game based on as3isolib. game support diamond shaped grids have implement possibility have rectangular shaped grids, too. please see example grid . i managed create grid. here code: private function createrectangulargrid():void { var c:int, r:int; var node:datanode; var pt:pt; var nodepos:point; var isevenrow:boolean; (c=0; c<cols; c++) { nodepos = new point(c*_cellsize, -c*_cellsize); (r=0; r<rows; r++) { node = new datanode(); node.col = c; node.row = r; node.x = nodepos.x; node.y = nodepos.y; node.z = z; node.width = _cellsize; node.length = _cellsize; node.height = 0; pt = new pt(node.x, node.y, node.z); isomath.isotoscreen(pt); node.screenx = pt.x; node.screeny = pt.y; _nodes.set(c, r, node); isevenrow = r % 2...

javascript - Smooth Div Scroll jquery not scrolling -

the smooth div scroll great reason area no longer scrolls when edit or remove #makemescrollable or #makemescrollable div.scrollablearea * when leave works. problem customization. and won't work after take "*" out of div.scrollablearea * if edit part it's been frustrating figuring out why part supposed editable not work @ all. any jquery helpful! in advance! /* can alter css in order give smoothdivscroll own look'n'feel */ /* invisible left hotspot */ div.scrollinghotspotleft { /* hotspots have minimum width of 75 pixels , if there room grow , occupy 10% of scrollable area (20% combined). adjust own taste. */ min-width: 75px; width: 10%; height: 100%; /* there big background image , it's used solve problems experienced in internet explorer 6. */ background-image: url(../images/big_transparent.gif); background-repeat: repeat; background-position: center center; position: absolut...

How can I make two Ruby symbols point to the same object? -

i assigning temp password users. now have code , works: temp_password = random_pronouncable_password @user = user.create!(params[:user].merge(:password => temp_password, :password_confirmation => temp_password)) but want way able this @user = user.create!(params[:user].merge(:password, :password_confirmation => temp_password)) anyone know how this? if have two, repeat them , maybe format code make repeat obvious: @user = user.create!(params[:user].merge( :password => temp_password, :password_confirmation => temp_password )) anything else bunch of noise serves no useful purpose. looks @ above know what's going on barely thought , that's indicator of clean code. you come clever using hash[] constructor or possibly hash default value waste of cleverness. cleverness in limited supply should save special occasions when needed.

tfs - Get credentials of active Team Explorer from Addin VS 2008 -

i have vs 2008 , team explorer, , tfs. i open vs 2008 using local administrator (machine\admin). open team explorer connect tfs server using domain user (domain\user). login dialog appears when connect tfs in team explorer (i put login , password). now, in addin, programatically want connect tfs. how can credentials (that introduce in login dialog in team explorer) connect tfs ? reference: how active team foundation server , project add-in http://blogs.msdn.com/b/hippietim/archive/2006/03/29/563988.aspx have tried: system.net.networkcredential credential = (system.net.networkcredential)system.net.credentialcache.defaultcredentials; aside that, setup account addin run under using : new networkcredential(username,password,domain) system.net.credentialcache.defaultcredentials may pass admin creds though. in case, creating account addin run under still option.

ios - UIView animation determine center during animation -

i'm using uiview's + animatewithduration:delay:options:animations:completion: method move view along line on course of few seconds or so. i determine, @ arbitrary time during animation, uiview along path moving. when , try , access center or frame , find location set it's final destination. the reason i'm doing i've got nstimer firing every 0.1 seconds (or thereabouts) update parent view show line uiview has been. want able keep updated uiview moves. any ideas on how this? similar question found http://forums.macrumors.com/showthread.php?t=1056105 , there no resolution shown. alternatively...are there better ways this? thanks! uiviews backed calayers, , layer actual animation. calayer exposes property presentationlayer which, when accessed, returns copy of calayer represents, closely can, current state visible user. asking view.layer.presentationlayer.frame can frame of layer visible user right now, , corresponds frame of uiview.

javascript - jstree node name -

this data format nodes: { data: "new structure", attr: {id:"1", class:"structurenode", rel:"root"} } i have reference node in question, , can attributes nodereference.attr('attributename') however, can't access node name, stored in "data". there way access while having node reference (other searching through dom find text in <a> field, find cumbersome)? i've considered storing name in attr array well, don't have redundancy. thanks :-) i found solution in documentation. apparently, need .get_text(nodereference) :-)

extjs4 - extjs grid - how to make column width 100% -

the property width pixel width. { xtype: 'grid', store: store, selmodel: ext.create('ext.selection.checkboxmodel', { mode: 'single' }), layout: 'fit', columns: [ { text: "pum", dataindex: 'srd_name_fl', width: 400 } ], columnlines: true } if have 1 column how can make column width = 100% or if have several columns - how make last column stretch end of grid? for extjs3, set forcefit on gridpanels viewconfig . see: http://dev.sencha.com/deploy/ext-3.4.0/docs/?class=ext.grid.gridview for extjs 4 set forcefit directly on gridpanel: http://docs.sencha.com/ext-js/4-0/#/api/-cfg-forcefit , use in conjunction flex on columns. example v4 var p = ext.c...

ruby - How to get Pik running in Git/Cygwin after it gets running in Command prompt of Windows XP? -

i have installed ruby 1.8.7. want have ruby 1.9.2 on system.having windows system have go pik instead of rvm. have in place cygwin , git bash. have installed pik through windows xp command prompt , changed $path variable putting pik path before ruby path. pik commands work sin windows not allow me install new ruby throws anerror "1.9.2 unknown". cygwin , git gets ruby version right not recognize pik common , not sure how done. other article changed the user profile variable in 1 of bash files of cygwin , git , tried no help. i need in telling me file need put common , in $userprofile directory not locate bash file , installation on c drive.

android - How to save files in pc rather than sdcard through USB -

i want have import , export functionality in application. want save , retrieve files not in mobile in pc.so when connect phone pc through usb , click on import button files automatically import application can use data inside them , same export.the location predefined. don't know whether simple input/output streams can me or not because have tried failed , not getting method in android api too. don't know whether functionality in android or not because when connect mobile pc our sd card treated drive in pc. appreciated. there nothing built android gives device access on host pc.

sql - Manage Exceptions in Java -

i'm doing small database program. connection connection = drivermanager.getconnection(..., ..., ...); string createtable= "create table employee ..."; try { statement stmt = connection.createstatement (); stmt.executeupdate(createtable); stmt.close(); connection.close (); } catch(exception ex) { system.out.println("erreur : " + ex.tostring()); } when run program going fine, second time exception : duplicate table name : employee ok fine know how manage exceptions, how managing every possible exception. : if exception duplicattion error then display custom duplicate message. if it's duplicate primary key then display error message , on. thanks. you'll have parse exceptions method string "subtype" of actual sql exception: try { // ... } catch (sqlexception e) { if (e.getmessage().tolowerstring().contains("duplicate table name")) { // handle duplicate table name probl...

html data in a string make clickable html link AS3/Flex -

i have scenario string html data, not html data it's email (outlook) saved html file , dropped in string. now string needs formatted html document , should clickable link in datagrid. when click on link, html document should pop-up , should gave me nice html page readable normal users. hope it's bit clear want o_0. i don't know start. you can download example html here: http://www.mediafire.com/?b2gfwymw70ynxir thanks! ---edit hopefully can explain little bit better. need create link , when click on html page. string variable has html data in it, precise, source data of html example above. example: public var html:string = source_code_of_example_file; the entire source code of html page in variable html . need make link , when click on it, html page (as pop-up) on fly. you can use htmltext property , specify css perform proper formatting: <mx:textarea id="resourcetext" height="100%" width="100%" st...

c# - How to parse links from the string -

i have string "go stack overflow http://stackoverflow.com " want parse link string using c#. wants output in following format. " go stack overflow <a href=http://stackoverflow.com target=_blank>http://stackoverflow.com</> " is possible in c#? use regular expression pattern ^(https?://)?(([0-9a-z_!'().&=$%-]: )?[0-9a-z_!'().&=$%-]@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!'()-]\.)([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!*'().;?:@&=$,%#-])/?)$

java - How to call create a proper interface -

i have interface 2 methods interface ifoo{ void fooone(a,b,c); void footwo(d,e,f); } now there 2 implementation class extends interface. 1 follows: class foo1 implements ifoo{ void fooone(a,b,c); void footwo(d,e,f); } other 1 follows : class foo2 implements ifoo{ void fooone(a,b,c); void footwo(d,e,f); } now foo2 class dosen't needs parameter e @ all. parameter e required class foo1. it's somehow ambious why parameter passed class foo2. there way can class foo2. class foo2 implements ifoo{ void fooone(a,b,c); void footwo(d,f); } if footwo(d,e,f) interface, class foo2 must implement that. however, expose non-interface overloaded public method foo2, this public void footwo(d,f) { this(d, null, f); }

android emulator - google maps not displaying -

in application want display maps. not displaying don't know why behaves. actually first got api running cmd in cmd prompt this. first went c:\program files\java\jdk1.6.0\bin>keytool.exe -list -alias androiddebugkey -keystore "c:\documents , settings\administrator\.android\debug.keystore" -storepass android -keypass android enter cmd. got md5 finger print androiddebugkey, jun 21, 2011, privatekeyentry, certificate fingerprint (md5): 87:a0:e9:d4:d6:c8:b1:e6:ab:d1:ad:de:a7:03:b1:7f so have copy 1 http://code.google.com/android/maps-api-signup.html , got api 00fpjatadwkotgrosangjka0bxxbhjbaub_gyba . put xml this <com.google.android.maps.mapview android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apikey="00fpjatadwkotgrosangjka0bxxbhjbaub_gyba" /> and ja...

javascript - Append messages different color in log_console -

can me javascript. have log console <div id="log_console"></div> and need write function has 2 parameters type = {success, error} , text ="some text" . need show each message in separated line , blue if success, red if error. how solve problem ? function log(type, text) { var colour = (type = 'success') ? 'blue', 'red'; $('<p />').css('color', colour).html(text).appendto($('#log_console')); }

android - List all activities within an APK from the shell -

is there way list activities of particular .apk file shell? found this post describes how list activities in apk not shell. if can pull out apk file own machine, can use aapt command in android sdk aapt dump xmltree <apk-file> androidmanifest.xml the format bit perplexing @ first, info there.

django/python - db hits while accessing variables -

class appuser(models.model): user = models.foreignkey(user, unique=true) slug = models.slugfield(editable=false, blank=true) for above model suppose have object "appuser" have rendered in template does django hits user db each time when use appuser.user.username in our code?? any on how in django/python db lookups done while accessing foreign key , many-to-many variables ?? you should read through details database access optimization: https://docs.djangoproject.com/en/1.3/topics/db/optimization/ and select_related() : https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related as quick answer question: depends on how you've retrieved object with appuser = appuser.objects.get(pk=id) it hit database separately appuser.user. but with appuser = appuser.objects.select_related().get(pk=id) it joined query, accessing appuser.user not trigger sql query.

c# - Retrieve Windows Events programmatically from a remote computer - Windows XP -

i need retrieve windows event logs programmatically remote xp system. links/resources related helpful. thanks in advance! you should able event event log/build watcher using windows management instrumentation (wmi). here's article on building "watcher". http://www.siccolo.com/articles/codeproject/logwatcher_rss_feed/build_log_watcher_rss_feed_using_wmi.html there few caveats using wmi remotely, long have correct permissions on remote system, should fine.

sql - When to choose a Dictionary ADT -

in college learned 3 main abstract data types containers (stacks, queues, , tables), dictionaries, , priority queues. there unlimited number of ways group adts @ high level this, start. i don't understand when choose dictionary adt solve computational problem though. stacks , queues seem come naturally, not dictionaries. the 1 example can think of dictionary in sense use in real world. dictionary keeps , ordered set of words fast lookup, , when word is: correct spelling, how pronounce word, part of speech is, definition of word, etc. as i'm starting understand better, more seems "dictionary" way think of querying database. when write sql select statement, you're looking when primary key equals value (not of course, can select on field exists in table). is correct way think of dictionary adt? or intended use more limited this... your sql example pretty accurate. you're searching primary key (the key of dictionary entry) fields (the values)...

Is there a request–response networking API for Java? -

i'm looking simple java library enable write code in following fashion: remote remote = remote.connect("some_host:1234"); future<string> response = remote.request("hello"); // else string reply = response.get(); it should based on tcp/ip , use plain text messages across network language agnostic, non-java servers able send/receive requests/responses. (before telling me use plain sockets, keep in mind in case need implement wrappers delimit payload, care received messages reordering, thread handling... example simple, not trivial implement well .) is there existing api out there this? ps: ...the simpler, better! take @ jms .

Is it a good way to realize a MVVM app in WPF? -

i rather new wpf question may confusing... i'm trying realize chat app using jabber.net , follow correct mvvm architecture. have following models: buddylistmodel chatsessionmodel chatmessagemodel the following viewmodels: buddylistviewmodel chatsessionsviewmodel chatmessagesviewmodel each of vm contains observablecollection<> of corresponding models. i instanciate jabber in buddylistviewmodel (where i've put login handling) , event handlers (presence,new message) in vm; problem that, doing in way, must call other vms methods (addnewchatsession when new message arrives,....) buddylistviewmodel , don't know if right approach mvvm. another problem i'm handling messages in single viewmodel , think use filters (in linq, example) show messages in corresponding chatsession. thing? thanks in advance suggestions ! i'd create applicationviewmodel holds instance of of main model (which may jabber object), , pass instance other vms instan...

c# - SharePoint 2007 Custom Webpart, saving data to the properties -

how can go creating custom web part has custom ui editing. when page in edit mode have special button show "edit" , when user clicks on it posts page. catch , want display custom ui can edit web part properties. need able have rich text fields, , text fields editable , post can save them properties. i'm struggling creating richtextfield, or textbox can grab data in post back. know how if outputted raw html page, use http.context, what's c# way it? thanks! you can check in web part if page in edit mode or display mode , render controls accordingly. how tell if page in edit mode on non-publishing site on postback, can fetch values , assign web part properties. since handing custom, need set dirty flag: http://msdn.microsoft.com/en-us/library/ms157656.aspx

asp.net mvc 3 - What is the best strategy for calling Stored procedure in MVC? -

i using repository pattern in asp.net mvc3. extracting data through stored procedure. should create different repository each stored procedure or create single repository class procedures? i can't embed them in table classes few of them gets data 2 or more tables. so can best option per repository pattern? repositories should handle model , it's aggregates. doesn't matter of use plain sql or sp fetch those. in other words: method used fetch objects not important. can sql statements, stored procedures, web services or whatever. what's important group objects belong , put them in same repository class. classical example order , orderline .

java - How do I declare an exception in an anonymous thread? -

inputstream in = clientsocket.getinputstream(); new thread() { public void run() { while (true) { int = in.read(); handleinput(i); } } }.start(); i'm listening new data on socket code , get: facenetchat.java:37: unreported exception java.io.ioexception; must caught or declared thrown int = in.read(); ^ when add " throws ioexception " after " run() " get: facenetchat.java:34: run() in cannot implement run() in java.lang.runnable; overridden method not throw java.io.ioexception public void run() throws ioexception { ^ it's simple, i'm @ loss. how passed this? you can't override interface of runnable.run() not throw exception. must instead handle exception in run method. try { int = in.read(); } catch (ioexception e) { // makes sense application }

c# - WSSF application, catch exception level -

at level in web service software factory or n-tier application correct catch .net exceptions, , throw custom exceptions (faults) ? did in service implementation , created fault contract every service operation, i'm not shure well. regards, sergiu. that's best place catch exception. top layer when control leaves code best place exception. contain inner exception , complete stack trace.

sql server - sql sub and grand total -

is there nice consise way grand totals here-- query shows sub totals each day, how can grand total of each sub total without sub query or query also there better use compute sum? select loguser,logdate,logaction,logtime log loguser in ('scott') , logdate between '2011-06-01' , '2011-06-15' order logdate desc compute sum(logtime) logdate sql server 2008 r2 i'm not familiar compute you've used it, (or variation on it) should work in sql dialects... select loguser,logdate,logaction,sum(logtime) log loguser in ('scott') , logdate between '2011-06-01' , '2011-06-15' group loguser,logdate,logaction rollup order logdate desc

database - In Grails... How to union two tables in a single controller? -

i have 2 tables, installed plugin in grails. columns in t1 are: a1, b1, c1, d1 columns in t2 are: a2, b2, c2, d2 i need select columns a*, b*, c*, d* ( =1,2) both tables in controller union , sort of them column d , how can that? furthermore, how can pagination work treating result single table? pls help. appreciate!! not sure if helpful or not. hit similar (though not exact) problem in past, , solved creating view. can create view union , select, , create new domain class maps view. you won't able use grails auto create table, limitation.

javascript - Whats the difference between window.location.host and window.location.hostname -

this question has answer here: location.host vs location.hostname , cross-browser compatibility? 5 answers they both seem give me same thing (the domain name executing script). so what's difference (if any) , should each used? https://developer.mozilla.org/en/window.location host.... : host name , port number. [www.google.com]:80 hostname : host name (without port number or square brackets). www.google.com

sencha touch - Can't get data from store to show up as the model -

i'm kinda new sencha touch, please bear me. at app's launch set viewport viewport use, , set views app namespace. launch: function() { this.views.viewport = new this.views.viewport(); this.views.homecard = this.views.viewport.getcomponent('home'); this.views.usercard = this.views.viewport.getcomponent('user'); this.views.infocard = this.views.viewport.getcomponent('info'); } the viewport loads home view first, , here meet problem. homecard: toolbardemo.views.homecard = ext.extend(ext.panel, { title: "meny", iconcls: "home", scroll: "vertical", bodystyle: "background-color: #ffffff !important; background-image: url(images/background.png) !important; background-repeat:no-repeat; background-position:bottom left;", initcomponent: function() { toolbardemo.views.homecard.superclass.initcomponent.apply(this, arguments); ...