Posts

Showing posts from May, 2013

svn - Has this branching strategy sense in a web development ecosystem? -

i don't know if question stack-overflow related or should posted on stack-exchange platform, anyway.. the problem new branching system have in mind adopt in near future. @ work develop primarly web applications (ecommerce, cms, classified, special purpose) , websites in php , our vcs svn . this new model want adopt: trunk : development staging (branch): branch created test new features on remote ambient (the same system live has, same server..) live (branch): branch live. other branches develop concurrent features. now, idea bugfix live , push changes trunk. develop features directly on trunk or branches merge trunk. push trunk staging ready new features go live soon; , then? how can staging live branch? have pass trunk? now strategy is: trunk : it's live version branch each feature live bugfix done trunk pushed branches staging working copy switchs branch @ end of development of feature, before merge trunk. but method has drawbacks: al...

iphone - NSURL Exceptions -

Image
i trying grab path value array nsurl set icon in app. an nsinvalidargumentexception', reason: '-[__nsarrayi length]: unrecognized selector sent instance 0x5622590. if use nslog expected output: nslog(@"%@",[[wforecast.wicons objectatindex:0]valueforkey:@"nodecontent"]); which gives me: im setting value follows nsurl *urlpath; nsstring *urls = [[wforecast.wicons objectatindex:0] valueforkey:@"nodecontent"]; urlpath = [nsurl urlwithstring:(nsstring *)urls]; i appreciate longwinded way of doing things trying break individual components find out going wrong @ loss! you have same problem this other questioner had . passed object not nsstring needed pass nsstring. use debugger determine exception occurred. if haven't done this, wouldn't sure code showed caused it; debugger tell exception occurred no room doubt. once you've found exception occurred, can examine object passed, , @ got from. need fix either...

What's the difference in those declarations (in JavaScript)? -

possible duplicate: javascript: var functionname = function() {} vs function functionname() {} in javascript can write: function thefunc(arg) { ... } or thefunc = function(arg) { ... } or thefunc : function(arg) { ... } what's real difference , when should use which? one difference between first , second syntax that's not mentioned (not in linked questions well) if function returns function object results of using 'thefunc' quite different thefunc = function(arg) { return function(x) { return arg+x; } }(5); res = thefunc(2); // res == 7 making equivalent to thefunc = function(5) { return function(x) { return 5+x; } } res = thefunc(2); // res == 7 because function anonymous. while function thefunc(arg) { return function(x) { return arg+x; } } byfive = thefunc(5); res = byfive(2); // res == 7 would have same result, making function factory reusable. the practical uses won't clear in ...

zend form - Element Label in two line -

i extremely new zend framework, in registration form, need label text in 2 line. example:- in case first name, need display below: first name: how can implement this? please me!!! by default, input fields labels being escaped zend_view_helper_formlabel . however, can easy switch off: $yourtextinputelement->getdecorator('label')->setoption('escape', false); this way can use labels e.g. $yourtextinputelement->setlabel('first <br/> name'); .

concurrency - Limiting the maximum number of concurrent requests django/apache -

i have django site demonstrates usage of tool. 1 of views takes file input , runs heavy computation trough external python script , returns output user. tool runs fast enough return output in same request though. want limit how many concurrent requests url/view keep server getting congested. any tips on how go doing this? page in simple , usage low. presuming using mod_wsgi, segment wsgi application on multiple mod_wsgi daemon process groups specific urls want restrict delegated mod_wsgi daemon process group of own lesser number of processes/threads. wsgidaemonprocess myapp processes=2 threads=10 wsgidaemonprocess myapp-restricted threads=2 wsgiscriptalias / /some/path/app.wsgi wsgiprocessgroup myapp <location /some/specific/url> wsgiprocessgroup myapp-restricted </location> note requests queued access 2 threads in restricted process still consume worker thread in main apache server child processes. thus, want make sure use worker mpm (so no mod_php) ,...

expression - Java modulus operator - why is the result unexpected? -

i understand in modulus 17/12 = 5 . why 4+17 % 2-1 value 4 , , (4+17) % 2-1 value 0 ? operator precedence. % evaluated first, so 4 + 17 % 2 - 1 is equivalent to 4 + (17 % 2) - 1 17%2 == 1 yields 4+1-1 equals 4 when place brackets there, change order of evaluation: (4+17) % 2 - 1 is equivalent to 21 % 2 - 1 which again, because of % having higher precendence - , yields 1 - 1 which 0

java - JSP code error - can't figure why -

')' expected out.println("welcome "+myname+", <a href="logout.jsp\" >logout</a>"); ^ illegal character: \92 out.println("welcome "+myname+", <a href="logout.jsp\" >logout</a>"); ^ all jsp files in 1 folder, not sure why issue? the quotes around logout.jsp need escaped. change to: out.println("welcome "+myname+", <a href=\"logout.jsp\" >logout</a>");

how to show create PHP progress bar showing progress of file upload and data insertion into database -

possible duplicate: upload progress bar in php guys, need problem i'm doing file upload process source file transfered server , data inserted in database. i need display progress bar shows progress time of file uploading server till data inserted database uploaded file. i find files uploading progress bar files uploading server , progress bar not till data insertion. thanks in advance ! okay, write progress bar need know 100% of file-size are. know file-size on server-side (with php runs server-side), first have receive whole file. after receiving file, doesn't anymore, because upload finished. progress-bars on file-uploads done flash, can detect file-size client-side actionscript (flash's scripting language).

javascript - jQuery round function -

how can round number using jquery? if number 3168 want print 32. or if number 5233 result should 52. how can that? should use math.round function? yes, should use math.round (after dividing 100). jquery library dom traversal, event handling , animation built on top of javascript. doesn't replace javascript , doesn't reimplement basic functions.

Is there any C/C++ library similar to apache httpcomponents? -

are there library similar apache httpcomponents c/c++ language? thanks in advance, dario. i'm not sure how similar particular apache components, might want @ poco , ace . both provide quite bit in way of networking in c++. ace tends more all-encompassing of 2 (both in terms of supporting lots of protocols , such, , in terms of tending control/dominate of how application written/works). depending on you're after, @ boost.asio and/or libcurl .

objective c - iPhone Buttons Question -

once tap button, default highlight color blue. how can change highlight color of button. either in interface builder or code. in ib when select button attributes of uibutton choose "highlighted state configuration" (instead of "default state configuration") , select image background. or in code: [mybutton setbackgroundimage:[uiimage imagenamed:@"imagename"] forstate:uicontrolstatehighlighted]; so rather set image, set color. you might want code examples of creating custom uibutton ([ uibutton buttonwithtype:uibuttontypecustom] ), using uiimage's stretchableimagewithleftcapwidth:topcapheight: instance method.

java - What is endorseddirs and how it is used in a application? -

in respect maven-compiler-plugin. there setting added project's pom file. configuration given below. <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> <compilerarguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerarguments> </configuration> </plugin> </plugins> what mean have <endorseddirs> in compiler arguments? how works java compiler? from documentation of endorsed standards override mechanism , mechanism provide newer versions of endorsed standard included in java 2 platform your project must creating and/or using such implementation. by specifying <endorseddirs>...

c# - How to get all string format parameters -

is there way format parameters of string? i have string: "{0} test {0} test2 {1} test3 {2:####}" result should list: {0} {0} {1} {2:####} is there built in functionality in .net supports this? i didn't hear such build-in functionality try (i'm assuming string contains standard format parameters start number digit): list<string> result = new list<string>(); string input = "{0} test {0} test2 {1} test3 {2:####}"; matchcollection matches = regex.matches(input, @"\{\d+[^\{\}]*\}"); foreach (match match in matches) { result.add(match.value); } it returns {0} {0} {1} {2:####} values in list. tehmick's string result empty set.

microformats - Which HTML5 microdata do I use for a job (vacancy)? -

i'm trying markup vacancy/job item microdata wonder whether i'm doing right way, because item properties 'title' , 'date' don't make sense in combination itemtype 'organization'. how 1 rewrite following block better leveraging microdata? <li itemscope itemtype='http://data-vocabulary.org/organization'> <a href='web_developer.html'> <span itemprop='title'>web developer</span> <span itemprop='name'>company name</span>, <span itemprop='locality'>city</span> </a> <p itemprop='summary'>lorem ipsum dolores amet ...</p> <p>published @ <span itemprop='date'>28 jan 2011</span>, <span itemprop='views'>75</span> views</p> </li> or can create/suggest itemtype=...

Help with php random random array -

i need array problem have, far have this: $array1 = array('foo1', 'foo2', 'foo3', 'foo4', 'foo5'); $array2 = array('newfoo1', 'newfoo2', 'newfoo3', 'newfoo4', 'newfoo5'); $random1 = array_rand($array2); $random2 = $array2[$random1]; foreach($array1 $key){ echo $key . '<br />'; echo $random2 . '<br /><br />'; } which outputs: foo1 newfoo4 foo2 newfoo4 foo3 newfoo4 foo4 newfoo4 foo5 newfoo4 but want "newfoo4" (array2) random item output somethng this: foo1 newfoo3 foo2 newfoo4 foo3 newfoo1 foo4 newfoo5 foo5 newfoo2 rather same, but allow duplicates of array2 array1 , array2 not have have same amount items in arrays .... so instance if array1 had 5 items , array 2 3 items end result output be: foo1 newfoo3 foo2 newfoo1 foo3 newfoo3 foo4 newfoo2 foo5 newfoo3 ...i hope makes sense ... $array1 = array('foo1', ...

How to show virtual keypad in an android activity -

why not able show virtual keyboard in activity. here code: package som.android.keypad; import android.app.activity; import android.os.bundle; import android.view.inputmethod.inputmethodmanager; import android.widget.edittext; public class showkeypad extends activity { inputmethodmanager imm; @override public void oncreate(bundle icicle) { super.oncreate(icicle); edittext edittext = (edittext)findviewbyid(r.id.edittext); ((inputmethodmanager) getsystemservice(this.input_method_service)).showsoftinput(edittext, 0); } } <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="som.android.keypad" android:versioncode="1" android:versionname="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".sh...

jQuery find antecedent? -

when want find child of object can use children() ; when want find object inside object, not it's child, can use find() . if want find parent, use parent() , if want find antecedent, not knowing if it's parent grandparent, grand-grandparent, how can it? i'll give example: building plugin applied 'input:text'. in end, need form holds them. sometimes, text-boxes directly inside form, or can inside unordered list or inside table. am able refer form in general way? you can use jquery's closest() method: $('input:text').change( function(){ var ancestorformelement = $(this).closest('form'); // stuff. }); $('input:text').change(function() { var ancestorformelement = $(this).closest('form'); ancestorformelement.addclass('hasinputchanged'); }); form { border: 2px solid #000; padding: 1em; } form.hasinputchanged { border-color: limegreen; } <script src="https://aj...

.net - Cut and Paste Code Reuse - JavaScript and C# -

what best tool(s) tracking down "cut , paste reuse" of code in javascript , c#? i've inherited big project , amount of code repeated throughout app 'epic'. need getting handle on stuff can refactored base classes, reusable js libs, etc... if can plug visual studio 2010, added bonus. simian has built in support c# , javascript. there tool called clone detective works add-in visual studio, although doesn't works javascript.

c# - Pass data between 2 dynamically loaded User control -

i have scenario dynamically load 2 user controls in webform, , need them interact together. here's code : default.aspx.cs controla ca = (controla)loadcontrol("~/controla.ascx"); controlb cb = (controlb)loadcontrol("~/controlb.ascx"); page.controls.add(ca); page.controls.add(cb); now thing is, controlb needs pass data controla. data not event (well part of). when user click on link controlb, data db, , need pass controla id of first data fetch request. , of course, when user click on link in controlb, page postback. i looked @ events & delegates, can't make work. right way go ? if have clue, appreciated ! a quick , dirty method comes mind declare id of first data fetch public property of controlb, , set value on link postback's handler on controlb eg. on controlb's event handler : public void link_click(object sender, eventargs e) { this.firstfetchedid = getvaluefromdb(); } then on controla's prerender : protected ...

django templates - Filtering results and pagination -

i have template shows filter form , below list of result records. bind form request filter form sets options user submitted when results returned. i use pagination. using code in pagination documentation means when user clicks next page, form data lost. what best way of dealing pagination , filtering in way? passing querystring paginiation links. change pagination links form buttons , therefore submit filter form @ same time, assumes user hasn't messed filter options. as above original data hidden fields. alj if don't mind tweaking urls bit can embed filter options directly url. has nice side benefit of making search options bookmarkable. when user clicks next/prev buttons on pagination information carried forward url. you may have split urls page tad though. if you've used keyword args view function though, can put logic view in 1 function. quick example in urls.py urlpatterns = patterns('', (r'^some_url/to/form/$', '...

branding - Creating a custom Publishing Portal Web site in SharePoint 2010 -

custom web sites built on sharepoint cropping everywhere (just visit topsharepoint.com see). said, question pertains creating customized, branded site using sharepoint cms depicted many of topsharepoint.com sites. i understand concept of creating custom master master page(s) (sharepoint 2010 includes minimal.master start). problems have are: what site template 1 use? in 2007 recommended front-facing web site site collection template publishing portal. still case? what navigation use? leverage oob navigation? if so, how style extensively? how keep on-page editing capabilities within new site template? are there online tutorials walk-throughs address of these issues? have been searching, it's sparse out there.

java JIT -- what optimizations are possible? -

academically curious. can jit take code this, recognize format string static final , precompute sliced format string, optimizing down stringbuilder minimal appends? public static string builddeletesql(baseobject object) { string table; string schema; string deletesql = string.format( "delete %s.%s %s = '%s' , %s = '%s'", schema, table, baseobject.attr_id, stringutils.escapeforsqlstring(object.getid()), baseobject.attr_revision, stringutils.escapeforsqlstring(object.getrevision()) ); return deletesql; } theoretically, jvm grok example. meantime, in reality, existing jvms won't; it's not lucrative place spend budget optimizations. since string formatting done serialize data, in case you'll end spending of time waiting i/o complete.

validation - C# Make button disabled unless atleast more than 1 items is checked -

there form 3 check box items , button. unless there atleast more 1 items checked on form keep button 'finish' disabled. private void btnfinish_validating(object sender, canceleventargs e) { if ((checkblinna.checked == false && checksoup.checked == false) || (checkblinna.checked == false && checkgnocchi.checked == false) || (checksoup.checked == false && checkgnocchi.checked == false)) { btnfinish.enabled = false; } } thought work button enabled start , when of check boxes checked button goes disabled forever. you can : void updatefinishenabled() { var boxes = new checkbox[] { checkblinna, checksoup, checkgnocchi }; btnfinish.enabled = boxes.any(b => b.checked); } call inside form load , validating handler.

windows phone 7 - How to set a timer in wp7 applications? -

how can set timer run code? can't find control named timer . what steps needed this? you're looking dispatchertimer class . dispatchertimer dt = new dispatchertimer(); dt.interval = timespan.fromseconds(10); dt.tick += delegate { ... }; dt.start();

Android TextView formatting -

i trying implement textview serving header listview. want format have title centered on first line , additional information on lines following. how can format text/string create kind of formatting? i suggest use addheaderview specify header. way can use separate xml layout define header. you can use gravity more specific layout

algorithm - Brute force magic squares -

basically have 3 x 3 grid filled 2 digit numbers 00 - 99. of numbers given input rest unknown. suggestions on how solve such problem brute force in c? edit: sorry forgot part of problem. every row , column , diagonal must add same number. don't want code ideas started algorithm there simple recursive solution problem, example of type of brute force called backtracking (google that). the recursive function (say, fill_next) finds next cell unknown value. if there no such cell, checks square see if fits requirements (the sums correct) , if prints square solution; returns. if there cell unknown value, loops, trying each of values 0 99 in turn cell calling recursively fill in next unknown cell. how next cell unknown value: can pass find_next number of next cell start looking at; start whole thing off calling fill_next(0). cell number 0 through 8 since have 9 cells. if storing square in 2d array, use num%3 , num/3 indices. this easier describe giving few lines of co...

What's happening in this Perl foreach loop? -

i have perl code: foreach (@tmp_cycledef) { chomp; ($cycle_code, $close_day, $first_date) = split(/\|/, $_,3); $cycle_code =~ s/^\s*(\s*(?:\s+\s+)*)\s*$/$1/; $close_day =~ s/^\s*(\s*(?:\s+\s+)*)\s*$/$1/; $first_date =~ s/^\s*(\s*(?:\s+\s+)*)\s*$/$1/; #print "$cycle_code, $close_day, $first_date\n"; $cycledef{$cycle_code} = [ $close_day, split(/-/,$first_date) ]; } the value of tmp_cycledef comes output of sql query: select cycle_code,cycle_close_day,to_char(cycle_first_date,'yyyy-mm-dd') cycle_definition d order cycle_code; what happening inside for loop? huh, i'm surprised no 1 fixed :) it looks person wrote trying trim leading , trailing whitespace each field. it's odd way that, , reason overly concerned interior whitespace in each field despite anchors. i think should same trimming whitespace around delimiter in split : foreach (@tmp_cycledef) { s/^\s+//; s/$//; #leading , trailing whitespace on whole string...

php - checkbox not checked while editing the user record in cakephp -

i have table user have fields username , password , , type . type can or combination of these: employee , vendor , client e.g. user can both vendor , client , or combination. type field have used multiple checkbox (see code below). views/users/add.ctp file: <div class="users form"> <?php echo $this->form->create('user');?> <fieldset> <legend><?php __('add user'); ?></legend> <?php echo $this->form->input('username'); echo $this->form->input('password'); echo $this->form->input('type', array('type' => 'select', 'multiple' => 'checkbox','options' => array( 'client' => 'client', 'vendor' => 'vendor', 'employee' => 'employee' ) )); ?> </fieldset> <?php echo $this->form->end(__...

jquery, need similar functionality of disable for select optoins -

i using coding this: \$(this).attr("disabled", 'disabled'); \$(this).removeattr("disabled"); this disable option. want have same accessibility , coding prefer make invisible on drop down menu instead. thanks you'll need remove() , re-add them. could try hide() , show() , @ least ie won't support it.

Twitter on Android -

i using twitter4j in android app. have done research, unable signout programmaticaly account api. the rest of things doing well. how signout, session clear? twitter4j stateless requires no logging out. see: http://groups.google.com/group/twitter4j/browse_thread/thread/5957722d596e269c/c2956d43a46b31b5

installer - Detecting the presence of a directory at install time -

in wix directorysearch can used determine if specific directory exists on target computer. don't understand if there's consistent way determine directory does not exist. for example: <property id="installdir" secure="yes"> <registrysearch id='installdir' type='directory' root='hklm' key='software\company\product\install' name='installpath'/> </property> <property id='is_installed' secure='yes'> <directorysearch id='isinstalled' path='[installdir]' /> </property> when both registry key , directory exist, is_installed property set path returned directorysearch . when directory not exist, is_installed appears set "c:\". is condition like: <condition>not (is_installed = "c:\")</condition> a reliable way detect directory found? there better way? answer: here wix code based on mrnxs answer acc...

android - How to do the following in ListView -

how following stuffs in listview only show scroll bar when user flip list. by default, if list more screen, there scrollbar on right side. is there way set scrollbar shows when user flip list? keep showing list background image when scrolling. i've set image background of listview, when scroll list, background image disappear , shows black list view background. is there way keep showing list background image when scrolling? don't show shadow indicator. when list has more items display, there black-blur shadow indicate user there more items. there way remove item? you can turn scrollbars on , off using setverticalscrollbarenabled(). "shadow" indicator called fading edge in our apis. there various methods control fading edges in base view class.

svn - Subversion: Is there any good reason not to create a Tag from multiple revisions? -

i know possible, , there various ways it, there reason not create tag multiple revisions? what proposing create program based on svnkit , jakarta poi reads list of build artifacts excel spreadsheet / csv file (a mix of java class files , other stuff) @ various svn revisions, creates tag out of it, , tag becomes next proposed release. i approach because: we have documentation (a baseline if will) detailing going each release. it gives our release manager (without checking out head or having learn complicated things branching , merging) developers can check-in whatever want when want without being constricted such concept 'release window'. i.e. restricting developers checking in prior release. i distrust approach because: it feels i'm violating basic svn principles (although i'm not sure what). it because of niggling doubt i'm putting idea out there people kick tires speak. guys think? you're not violating svn principles doing this. t...

asp.net - C# is there a nicer way of writing this? -

int uploadsid; int pagenumber; int x; int y; int w; int h; bool isvaliduploadid = int.tryparse(context.request.querystring["uploadid"], out uploadsid); bool isvalidpage = int.tryparse(context.request.querystring["page"], out pagenumber); bool isvalidx = int.tryparse(context.request.querystring["x"], out x); bool isvalidy = int.tryparse(context.request.querystring["y"], out y); bool isvalidw = int.tryparse(context.request.querystring["w"], out w); bool isvalidh = int.tryparse(context.request.querystring["h"], out h); if (isvaliduploadid && isvalidpage && isvalidx && isvalidy & isvalidw & isvalidh) { this ajax handler, checking passed params ok. considered bad, , there better way write this, or not important? assuming you're not going use individual bool variables elsewhere, could write as: int uploadsid, pagenumber, x, y, w, h; if (int.tryparse(context.request.querystrin...

JQuery Ajax Help -

i have page on site loads html via ajax. jquery is: $(document).ready(function() { $('.projects a').click(function(event) { $('#work').load(this.href); event.preventdefault(); }); }); and html is: <div class="projects"> <a href="work/link.html" title="blah" id="blah">blah</a> <a href="work/link1.html" title="blah" id="blah">blah</a> <a href="work/link2.html" title="blah" id="blah">blah</a> </div> this works fine requirements have changed pull area of page i'm loading #work div. when .project clicked load contents of #this div this.href #work. can point me in right direction? take @ loading page fragments section. can target sections of page loaded adding selector url string. the .load() method, unlike $.get(), allows specify portion of remote document inserted. ach...

python - Remove the first character of a string -

i want remove first character of string. for example, string starts ":" , want remove only, there lot of ":" in string shouldn't removed. i writing code in python s = ":dfa:sif:e" print s[1:] prints dfa:sif:e

html - how can i make my webpages buttons look like those of facebook buttons? -

could please share script here make webpage buttons , feel of facebook or @ least extent. in advance. i'm curious know because has been 7 days trying so, of css, had not succeeded. please me. i'd recomment use tool chrome development tools or web development tools firefox , inspect button style want mimic. found button on facebook , seems they're using label container stylesheet: webkit-box-shadow: rgba(0, 0, 0, 0.046875) 0px 1px 0px 0px; background-attachment: scroll; background-clip: border-box; background-color: #ddd; background-image: none; background-origin: padding-box; border-bottom-color: #999; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: #999; border-left-style: solid; border-left-width: 1px; border-right-color: #999; border-right-style: solid; border-right-width: 1px; border-top-color: #999; border-top-style: solid; border-top-width: 1px; color: #666; cursor: pointer; direction: ltr; display: inline-block; font-family: ...

Is it possible to easily modify the log4net section in the config file of several running applications remotely? -

our product consists of client, server , agents. each deployed on different machines. qa having hard time manipulate log4net sections in respective config files. right now, have have remote desktops relevant machines , open notepad in each of them , edit files 1 @ time switching between different machines proceed. real pain in ass. can suggest better solution problem? thanks. you store log4net configuration in database (you consider create web interface allows qa team modify configuration). have figure out how applications pick new configuration (e.g. have remote admin interface allows tell applications use new configuration). on start-up load configuration there. maybe advisable have backup configuration in file loaded first in case loading database fails. default configuration instance qa team gets email if loading configuration database fails. another option store log4net configuration files on network share... create application setting tells application find l...

javascript - Insert HTML in NicEdit WYSIWYG -

how can insert text/code @ cursors place in div created nicedit? i've tried read documentation , create own plugin, want work without tool bar (modal window) this quick solution , tested in firefox only. works , should adaptable ie , other browsers. function insertatcursor(editor, value){ var editor = niceditors.findeditor(editor); var range = editor.getrng(); var editorfield = editor.selelm(); editorfield.nodevalue = editorfield.nodevalue.substring(0, range.startoffset) + value + editorfield.nodevalue.substring(range.endoffset, editorfield.nodevalue.length); }

javascript - Module Drag Boxes in JS -

is there library in javascript can let user drag , drop boxes , configure? igoogle. check out jquery ui jquery . has draggable class allow drag , drop elements.

sqlite - Doubt in Core Data -

can convert sqlite file core data sqlite , use in our application?thanks in advance probably not. core data creates it's own tables map entities to. far aware it's can create sqlite db , core data magically start working. easiest thing manually import data sqlite database , create entities appropriate in app , save store in core data using sqlite database.

php - Executing calling class' method -

class car { $gas= new gas(); $gas->fill( 'filledhandler' ); function filledhandler() { echo 'gas has been filled!'; } } class gas { function fill( $function ) { // here $function(); } } i need call $function of calling class. right now, it's looking global function you have pass calling instance. class car { function fillgas() { $gas = new gas(); $gas->fill($this, 'filledhandler'); } function filledhandler() { echo 'gas has been filled!'; } } class gas { function fill($obj, $function) { // if need class name, use get_class($obj) $obj->$function(); } }

R substitute on expression with assignment -

why these 2 cases behave differently? >substitute(c1<-100,list(c1=100)) 100 <- 100 vs > substitute(c1=100,list(c1=100)) [1] 100 as understand assignops operator = evaluates immediately. second expression equivalent substitute(100,list(c1=100)) . take in braces , result is > substitute({c1=100},list(c1=100)) { 100 = 100 }

Ruby on Rails - f.error_messages not showing up -

i've read many posts issue never got work. my model looks this: class announcement < activerecord::base validates_presence_of :title, :description end my controller's create method(only relevant part) looks this: def create respond_to |format| if @announcement.save flash[:notice] = 'announcement created.' format.html { redirect_to(@announcement) } format.xml { render :xml => @announcement, :status => :created, :location => @announcement } else @announcement = announcement.new @provinces = province.all @types = announcementtype.all @categories = tag.find_by_sql 'select * tags parent_id=0 order name asc' @subcategories= '' format.html { render :action => "new" } #new_announcement_path format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } end end end my form looks this:...

SQL Server, View using multiple select statements -

i've banging head hours, seems simple enough, here goes: i'd create view using multiple select statements outputs single record-set example: create view dbo.testdb select x 'first' the_table the_value = 'y' select x 'second' the_table the_value = 'z' i wanted output following recordset: column_1 | column_2 'first' 'second' any appreciated! -thanks. if want this: column_1 | column_2 'first' null null 'second' you can use union suggested in other answers, if want on same row in question: column_1 | column_2 'first' 'second' try this: create view dbo.testdb select dt.first,dt2.second (select x 'first',row_number() over(order x) rownumber the_table the_value = 'y' ) dt left outer join (select x 'second',row_n...

jQuery and function scope -

is this: ($.fn.myfunc = function() { var dennis = function() { /*code */ } $('#element').click(dennis); })(); equivalent to: ($.fn.myfunc = function() { $('#element').click(function() { /*code */ }); })(); if not, can please explain difference, , suggest better route take both performance, function reuse , clarity of reading. thanks! the difference former provides reference function. thus, can this: ($.fn.myfunc = function() { var dennis = function() { /*code */ } $('#element').click(dennis); dennis(); })(); which isn't possible latter. this can useful. example, may want click manipulate part of page, want on page load. with: $(function(){ var manipulatesomething = function() { // stuff }; // on click $("#element").click(manipulatesomething); // , right (document.ready) manipulatesomething(); }); (aside: wouldn't call $("#...

Is there a way to set two C#.Net projects to trust one another? -

i have 2 c#.net projects in single solution modelproject , pluginproject. pluginproject plug-in application, , consequently references api. pluginproject used extract data application plugs into. modelproject contains data model of classes extracted pluginproject. the extracted data can used independent of application or plug-in, why keeping pluginproject separate modelproject. want modelproject remain independent of pluginproject, , applications api. or in other words want able access extracted data without needing access pluginproject, application, or application's api. the problem i'm running though pluginproject needs able create , modify classes in modelproject. however, i'd prefer not make these actions public using modelproject. extracted data should read-only, unless later modified pluginproject. how can keep these projects separate give pluginproject exclusive access modelproject? possible? you define methods modify modelproject objects internal...

php - Zend Debugger Error: Zend Debugger: Cannot read a valid value of zend_debugger.httpd_uid or zend.httpd_uid, will not perform dropping of privileges -

i have error after installing zend debugger on ubuntu server php 5.2.6 , apache2: zend debugger: cannot read valid value of zend_debugger.httpd_uid or zend.httpd_uid, not perform dropping of privileges apache not start, creates httpd process netstat shows listening ports 80 , 443, pid file never written , it's not serving requests. i wanted post question because there no info on google this. the solution issue had ioncube installed. ioncube , zend debugger not play nice together. i uninstalled ioncube (no longer needed it) , well.

Simple select not working on JDBC SQL Server? -

i trying move project using mysql database 1 uses sql server 2008, select working in mysql no longer working in sql server preparedstatement statement = connection .preparestatement("select u.user_firstname,u.user_lastname user_details u, login l l.username=? , l.login_user = u.user_id"); statement.setstring(1, username); resultset resultset = (resultset) statement.executequery(); it gives me empty resultset when there values corresponding username, when run query using sql server management studio - query works properly i.e. gives non-zero rows, there sql server specific change need ? don't see wrong here, i'd @ how connection object. perhaps database url, pointing wrong schema -- perhaps default one, not database.

python - BeautifulSoup and lxml.html - what to prefer? -

this question has answer here: parsing html in python - lxml or beautifulsoup? of these better kinds of purposes? 7 answers i working on project involve parsing html. after searching around, found 2 probable options: beautifulsoup , lxml.html is there reason prefer 1 on other? have used lxml xml time , feel more comfortable it, beautifulsoup seems common. i know should use 1 works me, looking personal experiences both. the simple answer, imo, if trust source well-formed, go lxml solution. otherwise, beautifulsoup way. edit: this answer 3 years old now; it's worth noting, jonathan vanasco in comments, beautifulsoup4 supports using lxml internal parser, can use advanced features , interface of beautifulsoup without of performance hit, if wish (although still reach straight lxml myself -- perhaps it's force of habit :)).

php - Can I have a user submit a form and receive a PDF copy? -

not quite sure how ask :) need have forms online people can fill out, registration form etc. submit , emailed me , have stored in database. there way files pdfs? can have editable pdf form online? thank you. can have editable pdf form online? not -- can have normal form (html served on http), , in server-side method accepts post requests, validate user-supplied data, , if fine generate pdf on fly , return query's result, email it, store it, whatever. details depend on yr server-side language (e.g., if python, you'd use reportlabs' popular pdf-writing package -- there many server-side languages , i'm not know best solution own preferred one, statistically speaking;-). general concept isn't different in each server-side case, , hope i've summarized adequately in previous paragraph;-).

How to use a function for every C# WinForm instead of pasting -

protected override bool processcmdkey(ref message msg, keys keydata) { { if (keydata == keys.escape) this.close(); return base.processcmdkey(ref msg, keydata); } } i discovered snippet close windows form esc. want implement every windows form. try create new abstract class inherit form , windows form inherit 1 . doesn't work way . abstract class absform: form { protected override bool processcmdkey(ref message msg, keys keydata) { { if (keydata == keys.escape) this.close(); return base.processcmdkey(ref msg, keydata); } } } public partial class hoadonbansach : absform { public hoadonbansach() { initializecomponent(); } thanks reading :) i suggest not doing in form instead implement imessagefilter , add using application.addmessagefilter. following: public class clo...

c++ - Problem allocating derived class array with new -

i have simple program $ cat a.cpp #include <iostream> class myclass { public: virtual void check() { std::cout << "inside myclass\n"; } }; class myclass2: public myclass { public: int* a; virtual void check() { std::cout << "inside myclass2\n"; } }; int main() { myclass *w, *v; w = new myclass2[2]; v = new myclass2; std::cout << "calling w[0].check\n"; w[0].check(); std::cout << "calling v->check\n"; v->check(); std::cout << "calling w[1].check\n"; w[1].check(); } $ g++ a.cpp $ ./a.out calling w[0].check inside myclass2 calling v->check inside myclass2 calling w[1].check segmentation fault i thought possible use new allocate derived class objects. also, v->check() seems work fine. w = new myclass2[2]; this creates array of 2 myclass2 objects. of type myclass2[2] . new ...

datatable - JSF 2.0 Dynamically Remove Components -

as follow on answered question on adding components dynamically in jsf 2.0 (see link below), approach of using datatable, removing 1 of added components? how dynamically add jsf components based on code snippet in other question linked, need following changes: add column delete button table. <h:column><h:commandbutton value="delete" action="#{bean.delete}" /></h:column> add datamodel<item> property bean , wrap list of items in able obtain table row button clicked. private datamodel<item> model = new listdatamodel<item>(items); (don't forget getter, note can instantiate in bean constructor or postconstruct) use in datatable instead. <h:datatable value="#{bean.model}" var="item"> add delete method bean. public void delete() { items.remove(model.getrowdata()); } see also: benefits , pitfalls of @viewscoped - contains jsf 2.0 crud table example

Python 3 Online Interpreter / Shell -

is there online interpreter http://codepad.org/ or http://www.trypython.org/ uses python 3? answer since question closed, give answer here. wandbox offers online repls many languages, including python 2.x , 3.x, c++ , java. ideone supports python 2.6 , python 3

c++ - Thumbnail Provider not working -

i'm trying write windows explorer thumbnail handler our custom file type. i've got working fine preview pane, having trouble getting work thumbnails. windows doesn't seem trying call dllgetclassobject entry point. before continue, note i'm using windows 7 , unmanaged c++. i've registered following values in registry: hkcr\clsid\<my guid> hkcr\clsid\<my guid>\inprocserver32 (default value = path dll) hkcr\clsid\<my guid>\inprocserver32\threadingmodel (value = "apartment") hkcr\.<my ext>\shellex\{e357fccd-a995-4576-b01f-234630154e96} (value = guid) i've tried using win sdk sample, , doesn't work. , sample project in article ( http://www.codemonkeycodes.com/2010/01/11/ithumbnailprovider-re-visited/ ), , doesn't work. i'm new shell programming, not sure best way of debugging this. i've tried attaching debugger explorer.exe, doesn't seem work (breakpoints disabled, , none of outputdebugstrings d...

Getting map zoom level for given bounds on Android like on JS Google Maps API: map.getBoundsZoomLevel(bounds) -

i have cluster marker defines bounding rectangle containing group of markers. cluster has center (lat,lon), marker count , latitude , longitude span calculate bounds. the google maps api (js) has function called "getboundszoomlevel(bounds)" cannot find equivalent method in google maps sdk android. how can estimate zoom level given bounds (especially on different devices different resolutions/densitys)? i've planned user can touch cluster marker , map view centered center , bounds of cluster. has working code snippet or suggestions me? thanks in advance regards thorsten. thank answer solvek. meanwhile found solution i've adapted , works. method computes bounds of set of geo points, computes span of these points , uses zoomtospan , animateto zooming , centering given area: public static void zoominbounds(final mapview view, final geopoint.. bounds) { int minlat = integer.max_value; int minlong = integer.max_value; int maxlat = intege...

windows vista - Silverlight 4 xap doesn't show up in Firefox, but works in IE -

i upgraded silverlight 3 web project silverlight 4. had rebuild code in vs 2010 toolkit et al installed , host on server. on testing, sl xap showed in ie 7 , worked expected. but, on firefox, xap getting downloaded doesn't showup. little bit of firebugging shows that, xap downloaded browser. right clicking page confirms sl runtime not loaded. inorder confirm had sl4 runtime, visited silverlight.net site , tested of showcase apps, show fine. what should looking for, if xap getting downloaded successfully, not loading runtime? appreciate suggestions or questions. many thanks!! the div hosting siverlight might not showing, or correct size in ff.

if statement - Profanity filter- Java -

we have filter out 3 words cat, dog, , llama. program has filter out these words when varying in case cat. import java.util.scanner; public class assign5 { public static void main(string[] args) { string cat,dog,llama,x,y,z; system.out.println("enter word"); scanner keyboard = new scanner (system.in); x=keyboard.next(); y=x.tolowercase(); if (y.indexof("cat")!=-1||y.indexof("dog")!=-1|y.indexof("llama")!=-1) { system.out.println("profanity detected"); } else if(y.indexof("cat")!=-1||y.indexof("dog")!=-1|y.indexof("llama")!=-1) { y.charat(0); y.charat(1); y.charat(2); y.charat(3); system.out.println("no profanity detected"); } } } output: enter word dogmatic profanity detected i trying weed out words contain 3 words. it's not reading it. tried splitting characters u...

iphone - How to ask UIImageView if MultipleTouchEnabled is "YES" -

i have created few uiimageviews programmatically, have feeling though setmultipletouchenabled yes during setup, not getting set , it's leading multi-touch issues. my question is, within touchesbegan how go asking uiimageview touched if has multipletouchenabled or not? i new i'm stumbling through code , learning go (with of course). thank ahead of time! multipletouchenabled property of uiview , can check using dot syntax property access like: if (aview.multipletouchenabled) { nslog(@"multipletouch enabled"); }

php - Using md5_file(); doesn't return the md5 sometimes? -

<?php include_once('booter/login/includes/db.php'); $query="select * shells"; $result=mysql_query($query); while($row=mysql_fetch_array($result, mysql_assoc)){ $hash = @md5_file($row['url']); echo $hash . "<br>"; } ?> the above code. works flawlessly on urls, every , skip md5 on line, if doesn't retrieve it, though file there. i can't figure out why. ideas? edit: when removing '@' returns this: [function.md5-file]: failed open stream: no such file or directory the @ in front of md5_file suppresses warnings/errors might raised. removing @ allow errors md5_hash displayed , allow see why failing. no such file or directory means there no file name has been searched. might want inspect urls causing warnings; maybe refer file has been renamed or moved.

php - Can't change Joomla Default language -

on site http://www.bostonteaclub.com want default language chinese. set default language chinese in backend (it's got star next it) when went page noticed site displaying in english. if check source code see on bottom hidden var_dump of language object, , looks of default still en-gb ["_default"]=> string(5) "en-gb" why this? thanks edit default language used when language file in requested language not exist. still problem remains, why site not default chinese? can change language of site , works in chinese http://www.bostonteaclub.com/中文版 edit 2 joomfish "site default language: 中文版." in administration... here go: found when going plugins 'system - jfrouter' perpetrator! disabled language determination , discovered "language selection new visitors" helpful to. bonus: plugin lets choose weather use sef prefix or sub-domains language selection. hope helps future people looking how solve problem. ...

css - How to get elastic table next to an image? -

this want: http://img571.imageshack.us/img571/4618/myimage.png this best come with: css img { background: red; float: left; } table { background: yellow; width: 90%; } html <img src="image.jpg" width="40" height="40" /> <table> <tr><td>table</td></tr> </table> there problem approach. if resize browser window @ point table jumps below image: click view demo . what better way of achieving layout? try surrounding table div that: <img src="image.jpg" width="40" height="40" /> <div style="padding-left:40px"> <table> <tr><td>table</td></tr> </table> </div>

Compact a given array problem -

dont know whether duplicate, interview question asked me. given array of random numbers , -1 placed inbetween, have compact array meaning -1s replaced , final output should last valid index fresh array. example. input: 3 4 -1 -1 -1 5 8 -1 8 output: 3 4 5 8 8 5 8 -1 8 , last valid index 4 input: -1 -1 -1 -1 -1 2 output: 2 -1 -1 -1 -1 2 , last valid index 0 input: -1 -1 -1 3 3 3 output: 3 3 3 3 3 3 , last valid index 2 you should not swap values last valid index along array enough decipher not -1 values. int k=0 i=0; i<len; i++ if arr[i]!=-1 arr[k]=arr[i] k++ end if return k-1

ruby on rails - Jquery UI Accordion and JQuery Grid plugin not going well together -

i have used jquery -ui accordion plugin menu (since looks neat) , jquery -grid rails plugin data. have vertical menu , data on right side, style of menu disappears , grid showing properly. faced issue before ? check make sure aren't having css issues. guess css directives stepping on each other. use firebug in firefox verify css files doing what.

winforms - How to keep the code decoupled from the GUI in C#? -

i have developed c# script opens xls file, parses , creates list of xml files validating them. every main steps of program logged this: console.writeline("step creating xml 1... done!) console.writeline("step validating xml 1... done!) the xls file path hard-coded , i'm creating tiny gui windows forms allow user select xls file , read steps made program in textbox . i had no problem in creating button open file dialog select xsl file then, once selected, i'm puzzled on how code part show program's steps information user. which common method accomplish task keeping core program gui agnostic? as said in other answers, raise event gui handles showing log text. complete examples: 1) first of think informations carry event , extend eventargs class define argument event class. suppose expose string log text: public class logeventargs : eventargs { public string messageevent {get;set;} } 2) semplicity suppose have myapplicati...

drools - Is CEP what I need (system state and event replaying) -

i'm looking cep engine, i' don't know if engine meets requirements. system has process multiple streams of event data , generate complex events , cep engine fits (esper, drools). i store raw events in database (it's not cep part, this) , use rules (or continious queries or something) generate custom actions on complex events. of rules dependent on events in past. instance: have sensor sending event everytime spouse coming or leaving home , if both car , car of fancy woman near house, sms 'dangerous'. the problem restart of event processing service lose information on state of system (is wife @ home?) , restore need replay events unknow period of time. system state can depend not on raw events, on complex events well. the same problem arises when need report on complex events in past. have raw events data stored in database, , generate these complex events replaying raw events, don't know period have replay them. at same time it's clear rules ...

visual studio 2008 - Tools needed to get started with Silverlight -

what tools required start silverlight development? vs2008 adequate? background: i'm thinking of dipping toes silverlight. i'm tired of flash dev tools , process, pita communicating web service. in addition studio you're going want hands on expression blend. since these products made 2 separate teams (studio , blend), you'll find there things easier in 1 vs. other. i use both, going blend handle animations , roughing out, , studio coding.

c - On a 16-bit microprocessor, should I be using datatype short instead of int? -

i've read using short vs int creating inefficiency compiler in needs use int datatype regardless because of c integer promotion. true 16-bit microprocessors? another question: if have array of 1s , 0s, efficient use uint8_t or unsigned char in 16-bit microprocessor? or there still issue being converted int.. please me clear muddy issue in mind. thanks! on blackfin not simple answer whether 32 or 16 bit types generate higher performance since supports 16, 32 , 64-bit instructions, , has 2 16 bit macs. depend on operations, suggest trust compiler optimiser make such decisions, knows more processor's instruction timing , scheduling care to. that said may in compiler int , short same size in case. consult documentation, ot test sizeof , or in limits.h header numeric ranges infer widths or various types. if want restrict data type size use stdint.h types such int16_t . stdint.h defines fastest minimum-width integer types such int_fast16_t , gu...

javascript - Is there a Firebug console -vsdoc.js? -

if not, care write one? myself...but don't have time right now...maybe next week (unless beats me it). if are bored , want compile vsdoc: here firebug api. here blog post format vs doc comments intellisense. here example vsdoc (jquery-1.4.1-vsdoc.js). i created following because kept typing cosnole instead of console . can use starting point (ish). console = { /// <summary> /// 1: javascript console /// </summary> /// <returns type="object" /> }; console.log = function (object) { /// <summary> /// write console's log /// </summary> /// <returns type="null" /> /// <param name="object" type="object"> /// write object console's log /// </param> }; there now. i've made community wiki feel free edit , improve... (function (window) { var console = { firebug: { /// <summary>the firebug version...