Posts

Showing posts from June, 2014

Result of Variable needs Formatting in ColdFusion -

using coldfusion, if result of variable not correctly formatted when rendered, how change it? example, have variable #number# , displayed value ,3642, want displayed 3642 instead. how can achieve formatting? you can replace non-numeric characters regular expression. <!--- original variable ---> <cfset input = ",3642," /> <!--- solution ---> <cfoutput>#rereplacenocase(input,'[^0-9]','','all')#</cfoutput>

MySQL - Select concatenate 2 values with 1 id -

for example, have table 'map': map: id | place __________ 1 | 1 | b 2 | 2 | b 2 | c what mysql query can use me have following results: id | place __________ 1 | a,b 2 | a,b,c you should use group_concat() function this. can use follows. select id,group_concat(distinct place order place asc separator ',') map group id

if statement - Rails - Trouble with setting var and getting value on layout -

i'm having newb moment, trying find right (rails) way set variable on show.html.erb , value on layout. in show.html.erb setting var so: <% @meta_title = @content.meta_title %> in layout, want set <title> if defined , has length , otherwise want use default site setting (loaded config.yml). in /views/layouts/public.html.erb <%= @meta_title ? @meta_title : app_config[:site][:title] %> i've tried many variations can't seem nail conditions down, things this: <%= !@meta_title.blank? ? @meta_title : app_config[:site][:title] %> <%= !@meta_title.nil? || meta_title.length? ? @meta_title : app_config[:site][:title] %> this should easier me have difficulty w/ if, unless statements. can lend hand? thanks! layouts cannot variables show templates , there no reason on show action since want in layout. in application_helper.rb: def meta_title(title) if title title else title_constant #or a...

django - How to reduce DB queries? -

models: class technology(models.model): name = models.charfield(max_length=100, unique=true) slug = models.slugfield(max_length=100, unique=true) class site(models.model): name = models.charfield(max_length=100, unique=true) slug = models.slugfield(max_length=100, unique=true) technology = models.manytomanyfield(technology, blank=true, null=true) views: def portfolio(request, page=1): sites_list = site.objects.select_related('technology').only('technology__name', 'name', 'slug',) return render_to_response('portfolio.html', {'sites':sites_list,}, context_instance=requestcontext(request)) template: {% site in sites %} <div> {{ site.name }}, {% tech in site.technology.all %} {{ tech.name }} {% endfor %} </div> {% endfor %} but in example each site makes 1 additional query technology list. there way make in 1 query somehow? what looking efficient way reverse...

css - Why does it need left property to be centered? -

i go site: http://www.domdesignonline.de/ . take @ div#siteend , don't understand why centered, needs left property. i'm css beginner. thanks first. div#siteend has width of 100% , contained in div less 100% wide. this means if doesn't have left:0; left side of bounding box on inner-leftside of parent item ( div#wrap ). you leave out left:0; , make width of div#siteend same div#wrap , achieve same effect.

iphone - presentRenderbuffer : GL_RENDERBUFFER_OES takes long time -

i added profiler game , isolated function. it, sometimes, cause fps drop. result: present buffer time: 22 present buffer time: 1 present buffer time: 9 present buffer time: 1 present buffer time: 20 present buffer time: 6 present buffer time: 4 present buffer time: 4 present buffer time: 22 present buffer time: 4 present buffer time: 8 present buffer time: 4 present buffer time: 4 present buffer time: 15 present buffer time: 1 present buffer time: 1 present buffer time: 1 present buffer time: 11 present buffer time: 1 present buffer time: 6 present buffer time: 1 present buffer time: 1 present buffer time: 25 present buffer time: 6 present buffer time: 7 present buffer time: 1 present buffer time: 10 present buffer time: 7 present buffer time: 3 present buffer time: 1 present buffer time: 12 present buffer time: 9 present buffer time: 6 present buffer time: 9 do know why @ every few frames function takes more time? this code: f64 time = -system::gettime(); [m...

flash - ensureIndexIsVisible(), scroll to the top of a List control? -

i'm using fb4 , apparently need use ensureindexisvisible() scroll specific item in s:list . anyway, code below scrolls item not scroll top of list (it's @ bottom, , cut off somewhat). there anyway that? mxml: <s:list id="schedule" dataprovider="{schedule}" creationcomplete="creationcompletehandler(event)"/> as3: protected function creationcompletehandler(event:event):void { var d:date = new date(); var today:string = string((d.month + 1) + "/" + d.date + "/" + d.fullyear); var dp:xmllistcollection = event.currenttarget.dataprovider; for(var i:uint; < dp.length; i++){ if(dp.child("date")[i] == today){ event.currenttarget.ensureindexisvisible(i); } } } bad solution, it's work me var pt:point = list.layout.getscrollpositiondeltatoelement(i); while (pt) { list.validatenow(); if (pt.y > 0) { var delta:int = list.layout....

loops - Javascript: Passing custom arguments to a callback function -

i have callback function setup: var contextmenu = []; var context = [ { "name": "name1", "url": "url1" }, {"name": name2", "url: "url2" } ]; for(var i=0; < context.length; i++) { var c = context[i]; var arr = {}; arr[c.name] = function() { callback(c.url); } contextmenu.push( arr ); } function callback(url) { alert(url); } the problem url value passed callback last value in context variable - in case "url2". expecting pass specific values each "instance" of callback, callback seems remember same value, last time referred. i kind of stuck. appreciated. ps: using jquery contextmenu which, understanding, not support sending custom data callback functions. in context have problem. suggestions overcome in environment helpful! use additional closure. arr[c.name] = (function(url) { return function() { callback(url); } })(c.url); see creating closures i...

multithreading - simultaneously download files in Android -

i'm writing app android device, simple download manager. want download 2/3 files simultaneously, i'm confused how it. i don't want use async task because killed , want run download in background. think should use intentservice, can run 1 intentservice @ time. have 2 ideas, how it, don't know 1 choose. first run intentservice inside asynctask , second run thread inside intentservice. either ways don't know how inform intentservice new file download, while download running. or maybe should use traditional 'implement runnable'? i'm writing app android 2.2, don't have downloadmanager service :/. thanks in advance asynctask want if download happens while activity up. don't forget though services can killed as application. option service spawns 1 thread per download.

Unicode system fonts for ipad -

i'd create uilabel chinese on it. need unicode font this, , there system font can use on ipad? assuming so, need escape character denote if wanted hardcode it, ie use \u type of notation? please assume i'm pretty clueless unicode, question implies. for global product/system this, unicode support basic requirement. ios device support natively, including unicode fonts , codepages. no effort on needed. for unicode string literals used in source files(i assume xcode here also), haven't try yet, coworkers seems have no problem it. some google results on can refer: http://www.cocoabuilder.com/archive/cocoa/97208-cant-use-utf-8-source-files-false-string-interpretation.html http://www.cocoabuilder.com/archive/cocoa/224023-unicode-in-constant-nsstrings.html

javascript - form loop all and check radio + options -

i have long form , trying loop done. not sure how check options (dropdown) , radio type's, if exist, select checked or selected , put in array. is there better way construct it? , when loop done, pass var sending in ajax? var parameters = ""; var form = document.getelementbyid("someform"); for(var = 0; < form.elements.length; i++){ if(form.elements[i].value) { if(form.elements[i].type == "text" || form.elements[i].type == "select-one" || form.elements[i].type == "hidden") parameters = parameters + '&' + form.elements[i].name+'='+escape(form.elements[i].value); if((form.elements[i].type == "radio" || form.elements[i].type == "checkbox") && form.elements[i].checked) parameters = parameters + '&' + form.elements[i].name+'='+form.elements[i].value; } } i use this, if need ajax form. append parameters ...

mysql - Database Choice for WebSite -

i have developed several websites on local host school. can program database driven aspects of webisite such blog on own no problem. @ school used mysql db hosted on dedicated server, when server went down not have access data. have mysql db on localhost but...my question this: if use mysql db on localhost, won't have access data when computer running site can make server requests? how can set kind of db site reliable , doesn't depend on localhost act db server? i developing in .net thanks. ps don't have access schools' server more. pps still don't have site set through hosting provider...probalby going go godaddy you'll need server that. server cost on monthly basis, haven't heard of free mysql servers, else may able that. regular hosting providers supply php , mysql server. run sites on dreamhost (www.dreamhost.com) it might worthwhile amazon ec2 : http://aws.amazon.com/ec2/ amazon rds pure database usage : http://aws.amazon....

jquery - variable named undefined in Javascript Libraries -

possible duplicates: how javascript/jquery syntax work: (function( window, undefined ) { })(window)? what advantages using (function(window, document, undefined) { … })(window, document) confer? i have seen many javascript libraries create variable named "undefined", iam unable figure out purpose, below lines copied jquery library * date: wed feb 23 13:55:29 2011 -0500 */ (function( window, undefined ) { // use correct document accordingly window argument (sandbox) var document = window.document; var jquery = (function() { please suggest me reason , benefits of doing so!! what see this: (function(undefined) { /* lots of code */ }()); this creates anonymous function , executes it. function has parameter called undefined . since there no argument passed function, variable undefined in fact javascript primitive value undefined . so why want this? well, problem can create variable name undefined , set like, e.g.: var undefined...

logging - Log4j: One log file per war -

is possible set individual log files per war file basis? have 2 application 'wars' each pertaining specific function , managed different teams. want output individual war's log in own log file. please note both these war use common code , hence can spearate @ package level. inputs appreciated. thank you if you're deploying application in jboss, can set <filter> <appender> declared in jboss-log4j.xml . example jboss wiki : <appender name="app1log" class="org.apache.log4j.fileappender"> <errorhandler class="org.jboss.logging.util.onlyonceerrorhandler"></errorhandler> <param name="append" value="false"/> <param name="file" value="${jboss.server.home.dir}/log/app1.log"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5p %c{1} %m%n"/> </layout...

Android Widget Update TextView Text -

i have android widget updated 1 time per day (as stated in providerinfo.xml file). here is, currently, onupdate method: public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { remoteviews rvs = new remoteviews(context.getpackagename(), r.layout.main); rvs.settextviewtext(r.id.textviewquote, "we updated! yay!"); appwidgetmanager.updateappwidget(new componentname(context, main.class), rvs); } however, textview never changes. onupdate called @ beginning, when widget first created right? how 1 change text in textview? thanks edit: provider info: <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="294dp" android:minheight="72dp" android:updateperiodmillis="86400000" android:initiallayout="@layout/main"> and manifest: <receiver android:name=".main" > <intent-filter> ...

jqgrid get values from combobox inside cell -

i'm using select type inside column , when i'm generating xml grid's data , can't value of select type cell. this code: {name:'code',index:'code', width:80, sorttype:"int" , editable:true,edittype:"select", editoptions: { value:"1:11 ;2:22" } and xml generating with: var datafromgrid = grid.jqgrid ('getrowdata'); var xml = xmljsonclass.json2xml ({row: datafromgrid}, '\t'); i inside xml "11" intead of "1". how can option value? thank's in advance. if use datatype:"xmlstring" changed "local" datatype after filling of grid. in case of datatype:"local" grid has internal data parameter represent grid data , not visualization of current page of data receive with var datafromgrid = grid.jqgrid ('getrowd...

How to define Xor in Coq and prove its properties -

this should easy question. i'm new coq. i want define exclusive or in coq (which best of knowledge not predefined). important part allow multiple propositions (e.g. xor b c d). i need 2 properties: (xor a1 a2 ... an)/\~a1 -> xor a2... (xor a1 a2 ... an)/\a1 -> ~a2/\.../\~an i'm having trouble defining function undefined number of variables. tried define hand two, three, 4 , 5 variables (that's how many need). proving properties pain , seems inefficient. given second property, assume definition of exclusive or @ higher arities “exactly 1 of these propositions true” (and not “an odd number of these propositions true” or “at least 1 of these propositions true , @ least 1 false”, other possible generalizations). this exclusive or not associative property. means can't define higher-arity xor xor(a1,…,an)=xor(a1,xor(a2,…)). need global definition, , means type constructor must take list of arguments (or other data structure, list obvious choice). ...

jquery - Detecting ajax:failure in Rails 3 forms -

i working form in rails 3 , running totally weird situation. basically, form detects successful return, fails detect "400" error. here code. jquery: $(".editorial_review").live('ajax:failure', function(xhr, status, error) { alert('error'); }) .live('ajax:success', function(){$(this).parents('tr').prev('tr.main').fadeout(); $(this).parents('tr').fadeout(); }); }); rails: def create render :json => {:error => 'no final status selected'},:status => 400 , return if params[:status].blank? @success = send(params[:status].gsub(' ', '_')) respond_to |format| format.js {head:ok} end end haml: -semantic_form_for editorialreview.new, :remote=>true |f| i've checked in firebug, , seems kosher, , indeed when controller responds head :ok there no problems speak of. any appreciated. thanks! the jquery rails.js...

php function problem with color -

i have made function returns color based on rgb color (used @ param) but have problem color (100,76,66). brown color function returns dark olive green. is there mistake in function ? example: $str_color = getcolornamebyrgbcolors('100,76,66'); echo $str_color; function getcolornamebyrgbcolors($str_comma_sep_rbg) { /* php function colorname problem */ $arr_input = explode(',', $str_comma_sep_rbg); // dark olive green // based on --> http://www.w3.org/tr/svg/types.html#colorkeywords $arr_colors = array( 'alice blue' => array(240, 248, 255), 'antique white' => array(250, 235, 215), 'aqua' => array(0, 255, 255), // *** 'aquamarine' => array(127, 255, 212), 'azure' => array(240, 255, 255), 'beige' => array(245, 245, 220...

python - Django easy-thumbnails MAX SIZE -

is there way set max size images uploaded in django app using easy-thumbnails app? in settings list don't see it. to cap file size, might want in webserver, rather in django. alternatively, can specify custom file handler , can raise error if file big: from django.core.files.uploadhandler import temporaryfileuploadhandler, stopupload class sizelimituploadhandler(temporaryfileuploadhandler): def new_file(self, field_name, file_name, content_type, content_length, charset): if content_length > max_file_size: raise stopupload(true) though cause connection reset error in order stop processing large file. if want cap image size, can resize image before saved stated in readme: by passing resize_source argument thumbnailerimagefield , can resize source image before saved: class profile(models.model): user = models.foreignkey('auth.user') avatar = thumbnailerimagefield( upload_to='avatars', ...

Groovy older version in Grails war -

for reason, 'grails war' including in "web-inf/lib" 'groovy-1.6.9.jar' , 'groovy-all-1.7.8.jar' files. i'm working grails 1.3.7 , when deploy war in tomcat, receive following error: org.springframework.beans.factory.beancreationexception: error creating bean name 'pluginmanager' defined in servletcontext resource [/web-inf/applicationcontext.xml]: invocation of init method failed; nested exception java.lang.nosuchmethoderror: org.codehaus.groovy.control.sourceunit.getsource()lorg/codehaus/groovy/control/io/readersource; the way i'm able deploy war removing older groovy file , application runs fine. i debugged dependency process , find this: [not required] org.codehaus.groovy#groovy;1.6.9!groovy.jar ... :: evicted modules: junit#junit;3.8.2 [junit#junit;4.8.1] in [test] in org.codehaus.groovy#groovy;1.6.9 latest-revision so, continued , got file 'org.codehaus.groovy.modules.http-builder/htt...

video - DirectShow : IMediaSeeking::SetRate not working with H.264 streams -

how can set video playback rate when working h.264 video streams directshow? it looks imediaseeking::setrate dosen't work on h.264 video decoder. tried following decoders far : microsoft dtv-dvd decoder (shipped windows 7), ffdshow video decoder , axis h.264 decoder. also, noticed dmo called frame rate converter. think in situation? thank you. one way have done mpeg-2 transport stream container h.264 video , aac audio. doing live capture hd-pvr , fed output capture mpeg-2 demultiplexer. split off audio , video separate pins, having audio go directly streaming buffer engine sink. fed video mpeg-2 video analyzer filter , sbe sink. in separate graph, started sbe source , fed video microsoft dtv-dvd decoder , on vmr9. audio sent microsoft audio decoder (i don't remember exact 1 @ moment) , on directsound device. once did of this, use istreambuffermediaseeking , istreambuffermediaseeking2 interfaces on sbe source set rate faster or slower, needed. if using l...

Restricting User based on GeoLocation in asp.net mvc -

in asp.net mvc app have survey model can created anyone. moreover, want people specific part of world participate (vote) in survey. easy job if know location (it city, country or state etc.). want add location restriction @ time of survey creation (i.e user tell people of islamabad or punjab or pakistan) vote or fill out survey form. moreover, want add location restriction applicable (or expected) small number of surveys (5 percent @ most) how efficiently implement functionality. you couple of ways: determine user based on previous question asking location. not bullet proof user somewhere not. obtain ip -> country mapping list provide lookup of customer's ip address vs. location. restrict based on this.

iphone - GameKit Device Identification -

in ios gamekit framework, code identify names of devices connected together? with gksession can peers specified state name. //get connected peers nsarray *peerids = [gksession peerswithconnectionstate: gkpeerstateconnected]; for(nsstring *peerid in peerids) { //log peer name nslog(@"%@", [gksession displaynameforpeer:peerid]); }

c++ - Circle and hand detection in OpenCV -

beginner here. i'm trying detect circle , hand, , draw circle around circle , rectangle around hand, , display both in same image. when run program memory error, can please help? below code: #include "opencv/cv.h" #include "opencv2\highgui\highgui.hpp" #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <conio.h> using namespace std; //declarations iplimage* img = 0; cvhaarclassifiercascade *cascade; cvmemstorage *cstorage; cvmemstorage *hstorage; void detectobjects( iplimage *img ); int key; int main( int argc, char** argv ) { cvcapture *capture; iplimage *frame; // loads classifier hand haar cascade char *filename = "haarcascade_hand.xml"; cascade = ( cvhaarclassifiercascade* )cvload( "haarcascade_hand.xml", 0, 0, 0 ); // setup memory buffer hstorage = cvcreatememstorage( 0 ); cstorage = cvcreatememstorage( 0 ); // initialize camera capture = cvcapturefromcam( 0...

.net - Is there a generic collection with a key/value pair where key can occur more than once? -

i want use generic collection dictionary , dictionary requires every key unique. have multiple values same "key", need generic collection allow that. i realize makes key no longer key, don't know else call it. several options consider: use dictionary<tkey, list<tvalue>> — keep list of values each key, not preventing duplicate values same key (i.e. duplicate pairs); use dictionary<tkey, hashset<tvalue>> — keep set of value each key, preventing duplicate values same key; use list<keyvaluepair<tkey, tvalue>> — keep list of pair, not preventing duplicate values same key. note in latter case keyvaluepair struct , not class , hence implies bit different handling. the right option depends on actual use case.

javascript - How do I extract "search term" from URLs? -

how extract "test" following url? http://www.example.com/index.php?q=test&=go i've found script extract path (window.location.pathname), can't find or figure out how extract or split url. -ben var m = window.location.search.match(/q=([^&]*)/); if (m) { alert(m[1]); // => alerts "test" }

mysql - PHP Conversion Tracking -

i have 3 pages trying "track" speak. signup process 3 pages. basically, i'm not wanting count hits out of sequence (ie. if user checks thank page (3rd page)) don't want count conversion again. so 1. user enters landing page +1 hit 2. user enters intermediary page +1hit 3. user enters thank page +1 conversion i know how increment count pretty easy hits, unsure how "not" count if out of sequence. you set session variable on page 1 set '1', page 2 = '2' , on, set variable if less current page number, so: session_start(); if($_session['cur-page'] < [current page number]) { $_session['cur-page'] = [current page number]; loghit(); } where loghit() tracks page hit.

coffeescript - Can I use ProcessingJS compiler for converting Java code to JavaScript for non-ProcessingJS purposes? -

basically, question how use processinjs compiler use in same way coffeescript allows writing client side code, except in java language. i'm thinking of live coding in java in browser similar "try coffeescript" option in coffeescript website. this confusing question. let's go through step step: the processing language designed syntactically similar java, , compiled java (quoth wikipedia article on processing : "the code translated pure java before compiling"). processingjs project 2 parts: 1) js library using canvas, , 2) compiler (written in js) compiles processing code js code uses aforementioned library. it possible use processingjs compile processing code js code runs in real-time directly in browser. indeed, has already been done . ( update: interactive processingjs editor link used go has been replaced http://sketchpad.cc/ .) but, when talk using processingjs "live coding in java in browser"... well, processingjs doesn...

Length of string in Perl independent of character encoding -

the length function assumes chinese characters more 1 character. how determine length of string in perl independent of character encoding (treat chinese characters 1 character)? the length function operates on characters, not octets (aka bytes). definition of character depends on encoding. chinese characters still single characters (if encoding correctly set!) take more 1 octet of space. so, length of string in perl dependent on character encoding perl thinks string in; string length independent of character encoding simple byte length. make sure string in question flagged utf-8 , encoded in utf-8. example, yields 3: $ perl -e 'print length("长")' whereas yields 1: $ perl -e 'use utf8; print length("长")' as does: $ perl -e 'use encode; print length(encode::decode("utf-8", "长"))' if you're getting chinese characters file, make sure binmode $fh, ':utf8' file before reading or writing i...

list - Please explain this python "for" statement: methodList = [method for method in dir(object) if callable(getattr(object, method))] -

i trying use introspection list of objects functions. have been reading "dive python", , aforementioned statement: methodlist = [method method in dir(object) if callable(getattr(object, method))] does trick. problem is, have no idea doing. me looks extreme shorthand looping, testing, , adding elements list. if correct, part of statement what?! in other words, can 1 please translate english. another way @ this: methodlist = [] method in dir(object): # every attribute in object # note methods considered attributes if callable(getattr(object, method)) # callable? methodlist.append(method) return methodlist the construct list comprehension filter. see: dir() , callable() , getattr() , list comprehensions

iphone - Why the UITableViewCell's changing their value in single cell? -

in app, have customize uitableviewcell , using contentview property. problem data in cells going in different cells. example:the data in cell 3 going cell 8 or 9 when scroll bottom or scroll up. here's code iam using in cellforrowatindexpath: - (uitableviewcell *)tableview:(uitableview *)tv cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; cgfloat fontsize = [uifont systemfontsize]; cgfloat smallfontsize = [uifont smallsystemfontsize]; uitableviewcell *cell = [tv dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1 reuseidentifier:cellidentifier]autorelease]; mainlabel = [[[uilabel alloc] initwithframe:cgrectmake(5,0,150,42)] autorelease]; mainlabel.font = [uifont systemfontofsize:smallfontsize]; mainlabel.numberoflines = 3; mainlabel.linebreakmode = uilinebreakmodewordwrap;...

python - Most efficient way to reverse a numpy array -

believe or not, after profiling current code, repetitive operation of numpy array reversion ate giant chunk of running time. have right common view-based method: reversed_arr = arr[::-1] is there other way more efficiently, or illusion obsession unrealistic numpy performance? when create reversed_arr creating view original array. can change original array, , view update reflect changes. are re-creating view more need to? should able this: arr = np.array(some_sequence) reversed_arr = arr[::-1] do_something(arr) look_at(reversed_arr) do_something_else(arr) look_at(reversed_arr) i'm not numpy expert, seems fastest way things in numpy. if doing, don't think can improve on it. p.s. great discussion of numpy views here: view onto numpy array?

android - View images from a website in app? -

in android app have see images website. on website images sorted in categories , can voted. app should see (when select category) pictures category , votes each picture. i have never done , have no idea how start this. can give me idea? idea welcome.. thanks in advance. first, should try retrieve list of images have display. can accomplished retrieving page of wanted category on website (see http://developer.android.com/reference/org/apache/http/client/methods/httpget.html ) , parsing (you can use may ways that, let choose 1 want apply). the next step, in opinion, create custom adapter in order keep data. so, create class extends baseadapter, , manage make contain list of drawable ( arraylist<drawable> ) , list of urls ( arraylist<string> ). also, provide method allows add url adapter. when url added, create new thread (or asynctask) retrieve image (in order use httpget here too) , create drawable (using drawable.createfromstream). once download done, n...

.net - How to add custom documents properties to Excel from SL4 -

i want add custom property excel document oob silverlight application. when try add value following exception: could not convert argument call add. dynamic properties = document.customdocumentproperties; properties.add("a",true,4,"b"); //could not convert argument call add. i don't know wrong argument, because in exception cannot see more details exception. think problem msodocproperties. property didn't find in sl api office, because of used 4 value. can me, or give me hint? add method description: http://msdn.microsoft.com/en-us/library/microsoft.office.core.documentproperties.add.aspx according documentation included link second parameter of type boolean. yet passing string "b" parameter. think should passing false .

php - How a website should handle a database crash -

i creating website in php has database backend (can either mysql or sql server) , realized if database crashes @ time, website not run , cause headaches. so proper thing display on website if database (or crucial outside component) goes down? particular website relies heavily on database , useless without it. one option have been told email website admin , display error 500 page says wrong server , make website unusable till issue fixed. there else work around problem? there ways design website database (any crucial component) crashing isn't issue? i looking general rules of thumb specific examples of how people have worked around in past. also, these examples don't have website example. if have 1 database server, , website cannot work without it's database, there no magic : you'll have display sort of nice error page , informing users there technical problem , website come shortly. generally speaking : chances of such problem pretty low if ...

c# - Where to put temporary, non-admin files? -

i have csharp application , downloading temporary file, need program run in non-administrator mode , can write c drive if have administrator mode on. what directory open writing programs no administrator privellages? did try path.gettemppath() ?

javascript - Canvas overlapping elements -

Image
i have canvas animation redraws exact same element on (it long story why necessary) happens, , happens enough. now assumed drawing element (using context path , stroke method) on existing exact replica of image should nothing @ animation. instead draws on past image , blurs sides (as if didn't draw @ same location. please let me know if there way fix this thanks this happening because canvas strokes anti-aliased. in practical sense you're drawing semi-opaque pixels on other semi-opaque pixels, , pixels overlaid opacities added together. don't think can (currently) force canvas object turn off anti-aliasing on strokes, may have live it. big of problem? http://img813.imageshack.us/img813/303/canvasl.png edit: guess try using pngs transparent backgrounds markers, instead of drawing them strokes. https://developer.mozilla.org/en/canvas_tutorial/using_images

swing - Getting an input with a java applet while executing a method -

i have implemented console calculator application. stores variables well. want use same parser in java applet. want use same parser class time want inputs variables via dialog box. should stop execution of program , asks user input in popup box , when enter value, want use value in next line of application. instead of getting value bufferedreader, want sthg this if someappletclasss.dialogresult = ok, value = someappletclass.myvalue; i'm new java programming , appreciated. use joptionpane#showinputdialog() . string inputvalue = joptionpane.showinputdialog("please input value"); see also: the java tutorials - how make dialogs?

iphone - scattering effect -

i went through resources not getting scattering effect of image smoothly. however, able zoom , had scattered not smooth want. want click on button , should zoom , other image should scatter i want image scattered link given below possible in iphone? http://www.touchmagix.com/templates/diamond.htm this hell lot of graphics. if intend achieve iphone sdk, start learning details calayer , try manipulate movements of different objects. require lot of coding logic. suggestion going cocos2d , try different classes , api's present there. in cocos2d can create image act actual physical object , can apply laws of physics it. if create ball, , push it, ball go in direction of push , bounce if gets hit other physical object , don't require coding this. cocos2d takes care of these things. try it.

tortoisesvn - How many persons can work simultaneousy on the same file which is added into Tortioise SVN repository? -

how many persons can work simultaneousy on same file added tortioise svn repository? "unlimited" , "one" correct answers. let me explain detailfully. unlimited because svn designed collaborative development without imposing limits on number of people can contribute development one because developer being able commit modifications 1 possesses latest version of file. further modifications require merging previous modifications current ones. however, in practice you organize team in order small groups of people working on same file simultaneously, or commit small , simple modifications shared files. affects number of required merge/conflict resolution operations. simple example: if have single global language file, can allow every developer add few lines @ bottom of without changing other lines. translates easy merging, since modifications "add lines" anyway, may want prevent people simultaneously work on same file locking it. ...

c++ - find an item in a list of pointers -

i trying understand how find item in list of pointers in c++, using std::find if had example: std::list<string> words; std::string word_to_be_found; i search this: std::list<string>::iterator matching_iter = std::find(words,begin(), words.end(), word_to_be_found) but if have lsit of pointers? std::list<string *> words; the above syntax not work anymore. can similar way? thanks! you can pass predicate std::find_if function: bool pointee_is_equal(const std::string& s, const std::string* p) { return s == *p; } // ... std::list<string>::iterator matching_iter = std::find_if(words,begin(), words.end(), std::bind1st(pointee_is_equal, word_to_be_found)); in c++11 becomes easier, lambdas: auto matching_iter = std::find_if(words,begin(), words.end(), [&word_to_be_found](const std::string* p) { return word_to_be_found == *p; ...

Which Javascript Menu is Used on the Oracle Website? -

does know javascript menu (in jquery if possible) similar javascript menu used in oracle? and must work ie7+ , ff2+ http://www.oracle.com/index.html this menu not display list of element instead, show entire div. you may this menu demo here

internationalization - Localized messages in Pentaho reports -

i trying put localized message in pentaho report. message has 1 parameter inserted message's localized text like all approved disconnects of ${company} in ${region} how do using pentaho report designer? i've tried resource-message . correctly accesses localized text defined in resource bundle inlined report file cannot substitute placeholder parameter. how connect message parameters of report? are connecting message parameters or field? resource-message should fine. need replace curly braces parentheses. for example, in translations file. report_date=report date: $(report date, date, mmmm yyyy)

jquery - Google Charts API shows blank screen with $(document).ready method -

i've got several functions instantiate various charts using google charts api. when call them without jquery's $(document).ready method, works fine. method, i'm looking @ blank screen. why? <script type="text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" charset="utf-8"></script> <script type="text/javascript" src = "http://www.google.com/jsapi" charset="utf-8"></script> function drawcolumnchart1(){..some code..} function drawcolumnchart2(){..some code..} function drawgeochart(){.some code..} //this works fine. google.load("visualization", "1", {packages:["piechart", "corechart", "geomap"]}); google.setonloadcallback(window.drawcolumnchart1); google.setonloadcallback(window.drawcolumnchart2); google.setonloadcallback(window.drawgeochart); //this doesn't work $(document).ready(function(){ ...

windows - Visual Studio 2010 debugger locks up until debugged program is killed -

so in c# .net v4 project in vs2010, i've got debugging issue. frequently, if not of time, debugger freezes when try use - typically on exceptions, it's ok if try manually break. the way i've discovered fix kill debugged program ([projectname].vshost.exe), unlocks ide , executes mouse presses , things happened in absence. the main windows gui not affected. there minimal cpu load. waiting nothing. output window (full of "loaded xxx, symbols loaded") uneventful. i've read symbol servers deadlocks, or deadlocks in gui, neither of issue here (the symbol servers disabled). anyone have ideas? giving me big problem, because can't debug program. unfortunately, number of things. most often, i've had type of thing happen when program caught in infinite loop... since yours breaking on exceptions, maybe add exception handling?

jsonp - How do browsers assess the origin domain for XMLHttpRequest? -

i thought origin domain xmlhttprequest domain loaded javascript using it. for instance, thought if on page http://mydomain1.com/ have: <script src="http://mydomain2.com/script.js" /> script.js can interact mydomain2.com via xhr. was, thought, 1 of nice things jsonp. i seeing bit of evidence in testing though js loads mydomain2.com, xhr's origin still mydomain1.com. have been way off base time? it domain of page (possibly in frame) executes javascript. if domain javascript loaded, happen people using jquery.ajax after loading jquery cdn (such http://code.jquery.com/jquery-1.6.2.js )? ;-) jsonp doesn't allow acting as domain, rather allows injecting from domain. source uri of script element not restricted same domain origin restriction xhr: in manner jsonp can used freely send data (in uri) , execute returned javascript (not json) directly in context of current page. including script tags remote sites allows remote sit...

Trouble updating a particular user in a mysql database -

im trying update particular user logged in using update mysql command, instead going first user in database itself, if can id appreciate it edit: im wanting increment number of 'items' user has, code below going first user in database <?php session_start(); $dbhost = 'localhost'; $dbuser = ''; $dbpass = ''; $dbname = ''; $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('error connecting mysql'); mysql_select_db($dbname); $query = sprintf("update users set item = item + 1 ", mysql_real_escape_string($_post['item'])); mysql_query($query); ?> your sprintf() call has parameter, no placeholder: $query = sprintf("update users set item = item + 1 ", mysql_real_escape_string($_post['item'])); probably supposed following, assuming int column named item $query = sprintf(...

python - Aptana (eclipse) does not recognize modifications to PATH written in .bashrc -

Image
i encountered , solved this problem earlier day , run similar in context. when fire python (2.7) in mac terminal (mac os lion) , do import oursql everything fine. when same within python script in aptana ide following error. traceback (most recent call last): file "/users/salah/documents/aptana studio 3 workspace/pubmap/src/scripts/parse_all_dblp_authors.py", line 10, in <module> import oursql importerror: dlopen(/library/python/2.7/site-packages/oursql.so, 2): library not loaded: libmysqlclient.18.dylib referenced from: /library/python/2.7/site-packages/oursql.so reason: image not found this same error in problem above used solve adding path=${path}:/usr/local/mysql/bin export dyld_library_path="$dyld_library_path:/usr/local/mysql/lib/" to .bashrc and if [ -f ~/.bashrc ]; source ~/.bashrc fi to .bash_profile. why have no effect on aptana? way aptana derivate of eclipse relevant eclipse should relevant aptana, - @ l...

java - Combining JMenu clipboard functions, accelerators, and actionMenu support (best practices) -

i've got component several jtables on it. i've installed custom transferhandlers on tables. now, want means invoke cut/copy/paste commands on these tables, via: the menubar, works on focused jtable popup menu on jtables keyboard shortcut, works on focused jtable jtable's actionmap has entries "cut", "copy", "paste". actions these keys correct thing, invoking transferhandler. i've tried following: datatable.getinputmap(jcomponent.when_ancestor_of_focused_component).put(cutmenuitem.getaccelerator(), "cut"); this works when press cmd-x, not when select "cut" menu. assume because menu consumes event, , never gets jtable. i can think of several hacky ways implement this, there clean way go it? how can menu items send actioncommand focused component? it's not clear how initializing menu items. jtable not 1 of text components, may want @ ccp in non-text component regard setting edit menu. ...

entity framework ctp5 - How to define the database schema name in EF CTP 5 -

i using ctp 5 existing database. tables created under schema different dbo. sql generated dbcontext using dbo. how make dbcontext use correct schema name? totable has overload accepts 2 strings: first name of table , second name of schema. same possibility offered attribute used decorate class.

iphone - Multi-language documents (RTF) in iOS : Files, SQLite, Core Data ? How? -

i'm making first ios app, , i'm facing first (little) issue. the app classical ios ui experience : mean, table views, tab bar, push controllers etc. displaying documents (from rtf files existing), audio , video files. my rtfs have mixed languages, supported ios, think it's important isn't ? considering audio , video stored in sandbox documents directory, i'm not sure rtf. i want reactive, on every devices, idea store rtfs in core data entity (using binary type) , getting in application nsattributedstring can respond initwithrtf message. i guess after i'll have load uiwebview ? or displaying nsattributedstring textview preserve it's formatting ? but don't know how ship application core data pre-filled database. so here questions : is idea store rtfs in core data ? faster simple uiwebview load rtf file documents folder directly ? maybe sqlite better case ? how pre-fill database application ? any specific consideration multiple langua...

Perl script making a pattern in variables -

#! /usr/bin/perl use strict; use warnings; #always use these! open (myfile, '>script2.txt'); $world = 1; $top (1 .. 100) { $left (1 .. 100) { print myfile "\#world$world \{ background: url(/images/1.png) 0 0 no-repeat; float: left; width: 1%; height: 2%; position: absolute; top: $top\%; left: $left\%; z-index: -1; margin-top: -10px; margin-left: -10px; \} \#world$world:hover \{ background-position: 0 -20px; cursor: pointer; \}"; $world++; } } close (myfile); currently perl script generates 10000 results (100 top x 100 left) how can modify $top produces 0, 2.5, 5...100 instead of 0, 1, 2, ...100 , $left produces 0, 1.25, 2.5, ... 100 instead of 0, 1, 2, ... 100 thanks perl's foreach loop usef...

c# - Hudson CI can't reach MySQL Server -

i have multiple unit tests have connect mysql server retrieve or modify data (i know more integration tests, let's not dive now). full suite of nunit tests pass no issues both in nunit gui , in nunit console. i automating our build process using hudson continuous integration. part of introduced batch command invoke nunit console execute tests after building full solution: "c:\program files (x86)\nunit 2.5.10\bin\net-2.0\nunit-console.exe" /framework:net-4.0 tests\mytestproject\bin\debug\mytestproject.dll /xml=mytestproject.dll.xml /config:debug exit 0 it should work exception tests tha connect database server: mysql.data.mysqlclient.mysqlexception : unable connect of specified mysql hosts. so hudson can't reach mysql server, when connection string same if executed tests manually. hudson , server in same machine way, dev box now. also, few tests not need database pass no problems. why hudson can't reach mysql server? update: not tests failing, t...

java - What's meant by "Data Encapsulation"? Use private data fields or methods? -

say have classa , classb extends classa classa { private int x; private void m1() { } } classb extends classa { } under data encapsulation, should private data field , methods. correct? but, in case, classb can not use classa 's data field , methods. so, under data encapsulation should use private access modifiers only? can use protected access modifier rather private solve problem under rule of data encapsulation? essentially, encapsulation way of making sure functions in class ran processes tested , known work. if function has no reason called object other ones intend to, why should given ability seen , accidentally called? it's more form of programmer controls, setting rules , basic guidelines of proper code use, in api scenario want expose functions or classes. "good practice" states should using 'private' functions not interface other class itself. functions need interface children classes, can use protect...

data binding - Enable TextBox when ListViewItem is selected in WPF (databinding) -

how can enable/disable textbox databinding in wpf when listviewitem (not) selected? i have created converter class: public class boolconvert : ivalueconverter { public object convert(object value, type targettype, object parameter, cultureinfo culture) { return value == null; } public object convertback(object value, type targettype, object parameter, cultureinfo culture) { throw new exception("the method or operation not implemented."); } } and added property textbox: isenabled="{binding selecteditem, elementname=listviewcards, converter={staticresource boolconvert}}" but have xamlparseexception becouse can´t find class :-( you alternately use style trigger on textbox, eliminating need valueconverter: <textbox> <textbox.style> <style targettype="{x:type textbox}"> <setter property="isenabled" value="false"/> <style.trigger...

double - How to make C++ cout not use scientific notation -

double x = 1500; for(int k =0; k<10 ; k++){ double t =0; for(int i=0; i<12; i++){ t += (double) x * 0.0675; x += (double) x * 0.0675; } cout<<"bas ana: "<<x<<"\tson faiz: "<<t<<"\tson ana: "<<x+t<<endl; } this output bas ana: 3284.78 son faiz: 1784.78 son ana: 5069.55 bas ana: 7193.17 son faiz: 3908.4 son ana: 11101.6 bas ana: 15752 son faiz: 8558.8 son ana: 24310.8 bas ana: 34494.5 son faiz: 18742.5 son ana: 53237 bas ana: 75537.8 son faiz: 41043.3 son ana: 116581 bas ana: 165417 son faiz: 89878.7 son ana: 255295 bas ana: 362238 son faiz: 196821 son ana: 559059 bas ana: 793246 son faiz: 431009 son ana: 1.22426e+006 bas ana: 1.73709e+006 son faiz: 943845 son ana: 2.68094e+006 bas ana: 3.80397e+006 son faiz: 2.06688e+0...

javascript - Changing shown URL with a firefox addon -

how can change displayed url firefox addon without changing page location? reason can load local html file not show actual local path in url bar. example user experience: user clicks on button in firefox, opens local html file. instead of showing path, shows "local html file" in address bar. title , content of page specified html file. edit: want build addon , not find addon me this. when file bundled addon, has " chrome url " (nothing google chrome) have control over. otherwise change url bar directly: document.getelementbyid('urlbar').value = '...'

.net - Performance issues with repeated calls to ConfigurationManager.AppSettings to get appsetting values? -

i'm working on code base has lot of identical configurationmanager.appsetting calls scattered throughout. does sound possible performance issue? or because data being small trivial , not 'expensive'? going file data, or .net runtime cache file/values/calls? if isn't performance issue disorganized approach accessing application configuration values, , should re-factored cleaner , consistent implementation of accessing settings? i it's more of code maintainability issue performance issue. simple dictionary lookup on appsettings isn't going problem unless have code tries perform lookup on appsettings in loop runs hundred times. surely such code cause performance problem. more important have configurationmanager.appsettings["mykey"] throughout codebase. introducing magic string. if have change key in configuration file, have thorough search , replace in projects. moreover, make decision based on value stored in appsettings. it...

objective c - Using SBApplication to open a URL in Safari? -

i'm trying use sbapplication tell couple of browsers (safari , chrome) open given url. however, apps treat file url. here's pseudo/jstalk code i'm using: var safari = [sbapplication applicationwithbundleidentifier:@"com.apple.safari"]; var url = [nsurl urlwithstring:@"http://apple.com/"]; [safari open:url]; // results in opening "file:///http/::apple.com:" any hints? making safari.h file sdp ( sdef /applications/safari.app | sdp -fh --basename "safari" ) doesn't see can do. just read wish open url using multiple browsers. thus, answer isn't of here: i'd propose ask nsworkspace open url: // make url nsurl *someurl = [nsurl urlwithstring:@"http://my.server.vom/" ]; if ([[nsworkspace sharedworkspace] openurl:someurl]) { nslog(@"fine. url opened."); } else { // shouldn't happen } regarding problem: did try pass string safari, not nsurl?

"Guard" operator like JavaScript in PHP -

i in javascript: function (a, b, c) { var foo = || b || c; return foo.bar; } is there quick way assignment fallback or require custom function ? php 5.3 introduces ?: operator (not confused ternary conditional, go figure). don't use php, imagine it'd like: $foo = $a ?: $b ?: $c see: http://php.net/manual/en/language.operators.comparison.php since php 5.3, possible leave out middle part of ternary operator. expression expr1 ?: expr3 returns expr1 if expr1 evaluates true, , expr3 otherwise. happy coding.

c# - Binding to a dependency property of a user control WPF/XAML -

my app looks this: sectionheader sectionheader content sectionheader content sectionheader user control 2 dependency properties = title , apps. title not change apps needs bound main window view model apps property. apps property required 2 of 3 section headers. <c:sectionheader dockpanel.dock="top" x:name="sectionresources" title="resources" apps="{binding path=apps}" /> this how @ moment. problem apps don't show up. in sectionheader datacontext set follows allows title show up. datacontext="{binding relativesource={relativesource self}}" apps itemssource itemscontrol in usercontrol: <itemscontrol itemssource="{binding apps}"> so questions are: how can data bind usercontrol dp? is easier way of doing layout without usercontrols? edit: forgot mention apps observablecollection of appsitems. this dp looks like: public static readonly dependencypropert...