Posts

Showing posts from May, 2010

Converting 6 audio channels to 2 in ffmpeg -

im doing 2 pass encode on uploads site. unfortunately when user uploads 6 audio channel .mkv files (5.1 surround), ffmpeg spits out following error: resampling input channels greater 2 unsupported. im running latest version of ffmpeg. doing -ac 6 instead of usual - ac 2 proceeds encoding, creates larger file useless data, creates step in long file processing script, , i'd rather avoid modifying conversion command. is there can make -ac 2 work? it known bug/limitation of current ffmpeg. in experience concluded can't done ffmpeg alone. you have transcode audio/video separately. 1) extract .wav file source movie. 2) resample 2ch stereo audio editing tool such audacity . 3) encode audio stream 3) transcode video stream 4) mux audio/video target format

Dashcode project opening in xcode problem -

if make our dashcode application open in xcode making native app.... dashcode ide, tool or set of tools developing mac widgets, web based ipxxx applications , webkit based web applications. in dashcode javascript, css , html used develop these applications. xcode ide developing native mac applications , ipxxx applications not exclusively objective-c , interface builder graphical elements. a dashcode project in reality set of file in folder, mac finder makes bundle. if right click project , click on open project see files in project. opening dashcode project in xcode doesn't anything, tried it, if did xcode not perform magical transformation , turn js/css/html objective-c , therefore not turn think mean native app. need learn objexctive-c cocoa , xcode programming tools , interface. in answer oyur added comment not not change code.

html - ignore malformed XML with Perl-XML -

i'm using perl command line utility xpath extract data html code follows: #!/bin/bash echo $html | xpath -q -e "//h2[1]" the html malformed causes xpath throw below error: not well-formed (invalid token) @ line x, column y, byte z: i can't fix html since it's provided external source means every time html changed have fix manually again. i looked xpath man pretty empty: http://www.linuxcertif.com/man/1/xpath.1p/ i wondering whether there way tell xpath ignore malformed html. give idea of how malformed here few lines source code: <div id="header-background" style="top: 42px; >&nbsp;</div> <---- missing closing " <div id-"page-inner"> <---- - instead of = thanks try out html::treebuilder::xpath uses html parser build document can queried using xpaths. html parser should ok malformed xml. also see article on html scraping xpath .

javascript - How many pixels is the screen (maxized window) -

is there international standard pixels of screen in maxized browser window? none standards exist. can assume basing on statistics, lowest popular resolution , accomodate that. current;y 1024px screen width desktop oss pretty it. you still need substract pixels browser gui objects (like scrollbars example). since size of these items depends on os/browser/browser settings used, number can vary. bottom line: there no standard.

GWT uploading a file to a unix path -

i'm kinda puzzled how unix path looks like. have followed example write simple fileuploader using gwt. guide written windows in mind. if have c drive. in windows told program save files c:\save_here\ but in unix, i'm using ubuntu, there no c drives or other drives single letter representation. wonder write instead? i'm getting error 500 time now. , can't figure out how path should be. the guide i've been following found here edit not problem duo path. still need though fixing problem. followed steps in url posted on question. unix paths start @ common root , denoted / , separates directories / e.g. /home/starcom might home directory. create new directory, mkdir /home/starcom/uploaded , use path. or testing perhaps use /tmp you can more info here

osx - What to use for VHDL/digital-logic simulation on Mac OS X -

i realized there no altera quartus or xilins ise or modelsim on mac os x. what people use @ least simulate vhdl , schematic designs on macs? try ghdl (alternate link: @ ghdl.free.fr ). from site: ghdl open-source simulator vhdl language. ghdl allows compile , execute vhdl code directly in pc. combined gui-based wave viewer , vhdl text editor, ghdl powerful tool writing, testing , simulating vhdl code. ghdl based on popular gnu compiler gcc , runs on linux, windows , apple os x. can freely download binary distribution os or try compile ghdl on own machine.

java - How to migrate from 2.0.0.RC2 spring batch version to 2.0.4? -

i have migrate project 2.0.0.rc2 version 2.0.4. problem xsd of 2.0.4 different 2.0.0.rc2. means none of job configuration going work. job configuration in 2.0.0 rc2 <batch:job id="taskletcomponenttestjob"> <batch:step id="tasklettestcomponent" tasklet="taskletfortestcomponent"> <batch:listeners> <batch:listener ref="customstepexecutionlistener" /> </batch:listeners> </batch:step> <batch:listeners> <batch:listener ref="customjobexecutionlistener" /> </batch:listeners> </batch:job> job configuration in 2.0.4 be <batch:job id="taskletcomponenttestjob1"> <batch:step id="tasklettestcomponent" > <batch:tasklet ref="taskletfortestcomponent"> </batch:tasklet> </batc...

redirect - webview is not redirecting anymore (Facebook API in webos) -

i trying implement possibility post on facebook wall app. http://developers.facebook.com/docs/authentication/ web application section. it used work. did open following url in webview "https://graph.facebook.com/oauth/authorize?client_id=123456789123456&redirect_uri=http://www.mydomain.com&scope=publish_stream&display=wap" and after user typed credentials , gives me neede permissions, webview redirected redirect uri (www.mydomain.com) including variable parsed code needed. but of sudden not redirected redirect_uri anymore. redirected blank facebook page (http://m.facebook.com/connect/uiserver.php) it work on pc browser , in webos browser, not in webview. i wrote complete new application nothing webiveiw in it. main-assistant.js looks this. function mainassistant(argfrompusher) { } mainassistant.prototype = { setup: function() { ares.setupsceneassistant(this); console.log("setup"); //this.controller.get("fa...

How to ensure that a plane perfectly fills the viewport in OpenGL ES -

i'm trying create flat plane such fills viewport in opengl es application. can achieve effect creating plane , experimentally moving forwards , backwards until right effect, i'm must possible work out how far away camera should be. welcome pointers! i need accurate because plane has texture applied it, want fill window , not clipped @ all. thanks! use glfrustum instead of gluperspective set perspective projection. glfrustum define projection in terms of plane want display viewport-filling. pseudocode: aspect = win.width/win.height bt = tan( fov/2 ) lr = bt * aspect glmatrixmode(gl_projection) glloadidentity() glfrustum( -lr * zclip.near, lr * zclip.near, -bt * zclip.near, bt * zclip.near, zclip.near, zclip.far) glmatrixmode(gl_modelview) glloadidentity() vertices = [ (-lr * planedist, -bt * planedist, -planedist), ( lr * planedist, -bt * planedist, -planedist), ( lr * planedist, bt * planedist, -...

RDF metadata in SVG collaborative work -

i can't find example of how annotate nested svg rdf. rough structure of document: <svg> <title>main document</title> <metadata> needs title, publisher, date, cc:license, , cc:attributionurl. </metadata> <svg> <title>contribution 1</title> needs title, date, , contributor 1. </svg> <svg> <title>contribution 2</title> needs title, date, , contributor 2. </svg> </svg> here first lines of svg document generated inkscape. put rdf in tag metadata. <?xml version="1.0" encoding="utf-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ...

syntax - What's the difference between [[]] and [] in Ruby? -

came across snippet : @@datalist[i] = [[0,[]]] what double brackets do? if wrote : @@datalist[i] = [0,[]] .. work different? [] empty array. [[]] array containing empty array single element. [0,[]] array containing 2 elements. [[0, []]] array containing 1 element, happens array.

ruby on rails - dealing with variables not being set or not existing -

i wondering if there better way check if variable exists, this if !params['attribute']['institution'].blank? but if attribute doesn't exist error thrown. i saw .try() couldn't see how work in situation. also can recommend ruby book or ruby web resource ? thanks alex you can use present? or presence described blog post ola bini.

Create a HTML table from a xml document in ASP.NET/C#? -

i querying web service , returned soap message. want create html table , select node should in column , on. have been googling bit wonder if of know guide on how properly? thanks in advance. the proper way xsl transformation (xslt). see here tutorial on xslt.

Prevent user to enter whitespace during form input in asp.net model validation? -

i have bee using model validation in asp.net mvc website. want have functionality prevent user entering whitespace in testbox , submit form. there other validation attributes available, not find validation attribute prevents user entering whitespace in input textbox. i develop custom attribute this, there method called regular expression validator think use achieve functionality. example: can set attribute has regular expression validating email. if user enters wrong email, message shown email format wrong. i want use same, don't know regular expresison validates form input field if user enters whitespace. please me kind of regular expression? thanks, [regularexpression(@"[^\s]+")] public string data { get; set; }

C# Class and Oracle Mapping Parameters -

i have type declared in oracle database: create or replace type t_project_code_changes table of obj_project_code_change; i map type in c# so [oraclecustomtypemapping("dev_schema.obj_project_code_change")] class projectcodechangefactory : typefactorytemplate<projectcodechangedto> { //code } the above code works without error, if remove schema name 'dev_schema' attribute, fails: [oraclecustomtypemapping("obj_project_code_change")] generates following error: unhandled exception: system.invalidoperationexception: custom type mapping 'projectcodechangedto' not specified or in valid. @ oracle.dataaccess.types.oracleudt.getudtname(string customtypename, string datasource) at point want ship code past 'dev_schema', result in code failing. the schema name comes connection string user id : "data source=dbname;user id=dev_schema;password=pwd;pooling=false;" is there can onm oracle of c# sid...

wcf - Reporting Services LocalReport and WIF -

i have wcf webservice uses wif authentication. part of responsibility of webservice generate report , email it. if render report data fine. if include report parameters, report constants, or datetime.now following exception: an error occurred during local report processing.failed load expression host assembly. details: request permission of type 'system.security.permissions.securitypermission, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089' failed i can run same report in wcf service not use wif, security environment fubarred. i don't know how proceed solving problem. can help? thanks! this works: var reportinstance = new localreport(); reportinstance.setbasepermissionsforsandboxappdomain(new permissionset(permissionstate.unrestricted)); i don't understand why. understand report being granted permissions can't wif, don't understand permissions or why needs them. so, answer "gives man fish," can else ...

regex - Using replace-regexp with lisp expression -

i have line: ;last updated: sunday, january 23, 2011 i replace date current time. so, used replace-regxp following key combinations: m-x replace-regexp ret \(last updated: \)[a-z ,]*[0-9 ,]* ret \1\,(format-time-string "%a, %b %e, %y") but yields following result: ;last updated: tuesday, january 25, 2011unday, january 23, 2011 how can replace-regexp replace whole of old date instead of first letter? your regex matches upper case letters. since u in sunday lower case, matches last updated: s , that's gets replaces. to fix add a-z character range.

ruby on rails - Help on Inserting a record to the db -

i insert record db based on values of querystring parameters, @ minute have scaffold methods , works, takes values @ in new method, when sumbit button clicked, inserted db. how can 'skip' clicking of button, inserted in new method? code: @book = book.new(params[:book]) @book = book.new({:user_id=>session[:user_id], :author=>session['test']}) respond_to |format| if @book.save format.html { redirect_to(@book, :notice => 'book created.') } format.xml { render :xml => @book, :status => :created, :location => @book } else format.html { render :action => "new" } format.xml { render :xml => @book.errors, :status => :unprocessable_entity } end end put in action want save automatically: @book = book.new(params[:book]) @book.save some thing might want add: save if if params[:book] set: unless params[:book].blank? @book = book.new(params[:book]) @book.save end also think of error h...

python - GAE: How to get the blob-image height -

given follwing model on gae: avatar = db.blobproperty() by calling image instance properties height or width ( see documentation ) with: height = profile.avatar.height the following error thrown: attributeerror: 'blob' object has no attribute 'height' pil installed. if image stored in blobproperty, data stored in datastore, , if profile entity, height can accessed as: from google.appengine.api import images height = images.image(image_data=profile.avatar).height if image in blobstore, (blobstore.blobreferenceproperty in datastore), have 2 ways of doing it, better way complicated , requires getting reader blob , feeding exif reader size. easier way is: if avatar = db.blobreferenceproperty() , profile entity, then: from google.appengine.api import images img = images.image(blob_key=str(profile.avatar.key())) # must execute transform access width/height img.im_feeling_lucky() # transform, otherwise gae complains. # set quality 1 r...

sql - How to do a FULL OUTER JOIN in MySQL? -

i want full outer join in mysql. possible? full outer join supported mysql? you don't have full joins on mysql, can sure emulate them . for code sample transcribed this question have: with 2 tables t1, t2: (select * t1 left join t2 on t1.id = t2.id) union (select * t1 right join t2 on t1.id = t2.id t1.id null)

vb.net - asp.net 4 Membership.CreateUser reference required to assembly error -

new .net still learning....i have managed asp.net membership working sql server. the problem i'm having error in vs2010 in code behind file when attempting create user. red exclamation mark appear on .createuser on code below. error message: reference required assembly 'system.web.security.applicationservices, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e65' containing type 'system.web.security.membershipuser'. add 1 project. code: protected sub button1_click(byval sender object, byval e system.eventargs) handles button1.click try membership.createuser(r_user_name.text, r_password.text) label1.text = "user created" 'response.redirect("default.aspx") catch ex exception label1.text = "error" end try i've tried adding following web.config: not sure if thats correct!! error message when open page: parser error message: could not load file or ...

linux - How to run process as background and never die? -

i connect linux server via putty ssh. tried run background process this: $ node server.js & however, after 2.5 hrs terminal becomes inactive , process dies. there anyway can keep process alive terminal disconnected? edit 1 actually, tried nohup , close putty ssh terminal or unplug internet, server process stops right away. is there have in putty? edit 2 (on feb, 2012) there node.js module, forever . run node.js server daemon service. simple solution (if not interested in coming process, want keep running): nohup node server.js & powerful solution (allows reconnect process if interactive): screen also consider newer alternative screen, tmux.

c# - How to convert a FullTextSqlQuery result to an SPListItem? -

i though following code work every time @ file.item; null. should doing different? microsoft.office.server.search.query.fulltextsqlquery query = new microsoft.office.server.search.query.fulltextsqlquery(sitecollection); query.querytext = "select title, path, description, write, rank, size scope() \"scope\" = 'socialnetworking'"; query.resulttypes = microsoft.office.server.search.query.resulttype.relevantresults; //query.rowlimit = int32.maxvalue; query.trimduplicates = true; query.enablestemming = false; query.ignoreallnoisequery = true; query.keywordinclusion = microsoft.office.server.search.query.keywordinclusion.allkeywords; query.timeout = 0x2710; query.highlightedsentencecount = 3; query.sitecontext = new uri(sitecollection.url); query.authenticationtype = microsoft.office.server.search.query.queryauthenticationtype.ntauthenticatedquery; microsoft.office.server.search.query.resulttablecollection queryresults = query.execute(); microsoft.office.s...

Constant pointer array or pointer to an array ? What is faster in C? -

hello i'm in intermediary c class right , thought came mind: int multi[3][4]; // const multidimensional array int* ptr = *multi; // ptr pointer variable hold address of multi const array so, faster/smaller/optimized access multidimensional array position? this: multi[3][1]; // index value position or *(*(multi+2)+1); // pointer position on array or (updated) ptr += 9; // pointer arithmetic using auxiliary pointer since "multi" const array compiler should "know" localization of element position, in case of using variable pointer pointing array take more processing time, on other hand faster when searching item want display. faster/smaller/optimized approach? thank in advance. they're compiled in same way, *(pointer_to_first_element + x + y) .

Is Boost.Preprocessor self-contained? -

i'm thinking using boost.preprocessor in project, don't want make entire boost library dependency. can copy alone , away this? otherwise, dependencies? new answer i got bcp working: ./bcp --list preprocessor --boost=/usr/local/include/boost_1_45_0/ | grep -v preprocessor no errors detected w/o grep like: boost/preprocessor.hpp boost/preprocessor/arithmetic.hpp boost/preprocessor/arithmetic/add.hpp boost/preprocessor/arithmetic/dec.hpp boost/preprocessor/arithmetic/detail/div_base.hpp boost/preprocessor/arithmetic/div.hpp boost/preprocessor/arithmetic/inc.hpp boost/preprocessor/arithmetic/mod.hpp boost/preprocessor/arithmetic/mul.hpp boost/preprocessor/arithmetic/sub.hpp original answer try using boost bcp utility copy it i did quick grep -r "include" /usr/include/boost/preprocessor/* | grep -v preprocessor , didn't come matches. have sworn config needed. edit (my grep-ful weak =/) grep -rh ...

security - IP Filtering in sql server 2008 -

i want filter ips in sql server. read on blog suggested using trigger. how can this? don't use firewall or isc or other things. logon trigger extract ip address client_net_address in sys.dm_exec_connections reject connections in trigger based in ip address i haven't done myself, should straightforward do

sql - mysql query help -

i have query: select * table field1 null , (field2 '%01%' or field2 '%02%' or field2 '%04%' ) the goal pull rows field2 has 01, 02, or 04 part of it. field2 typically has comma separated values 01,02,03 or single 02. however, when run query, 1 result has 01,02,03,04 value, , isn't 1 in table exact same data. this table looks like: |id|field1  |field2              | 1| null|01,02,03,04 | 2| null|01,02,03,04 | 3| null|01,02,04 you can use regexp function: select * table field1 null , (field2 regexp '0[124]') e.g: select * ( select 'skjdfhskdjf01kjsaksjfhk dsfkjhskdfj' info union select 'skjdfhskdjf02kjsaksjfhk dsfkjhskdfj' info union select 'skjdfhskdjf03kjsaksjfhk dsfkjhskdfj' info union select 'skjd...

validation - How to validate HTML form input without using JavaScript? -

i have form following: <form action="/html/tags/html_form_tag_action.cfm" method="get"> <table> <tr> <td>name:</td> <td> <input type="text" name="name_applicant" value="" maxlength="100" /> </td> </tr> <tr> <tr><td>date of birth:</td></tr> <tr> <td>date:</td><td> <select> <option value ="1">1</option> <option value ="2">2</option> <option value ="3">3</option> <option value ="4">4</option> <option value ="5">5</option> <option value ="6">6</option> <option value ="7">7</option> <option value ="8">8</option> <option value ="9">9</option> <option value ="10">10</option> ...

Undo a Git merge, but keep later changes, and rewrite history -

i have bunch of branches, each different features. i'll have branch "not_master" contains master+feature so: (not_master) a--b--c--d--e---m--x--y--z (feature a) --h--i--j-/ sometimes want unmerge feature a, keep commits x,y,z in "not_master". in other words, this: (not_master) a--b--c--d--e--x--y--z i see can git revert -m 1 m add commit end reverts changes, don't want since these commits haven't been published yet adding more commits makes history harder read. others suggest doing git reset --hard m , dump changes of x,y,z . thinking wrong way? should git reset --hard m , cherry pick x,y,z? git rebase want. git rebase -i <commit e> should work: open editor, , delete merge commit , save. you should able directly specify rebasing x..z onto e, sorting out semantics of command-line bit hairy. if i'm reading man page right, should git rebase --onto <commit e> <commit m> not_master . ...

c# - Elegant Way For This UI to Work? -

in vs .net 4.0 : so have comboboxes query server data match text in combobox, when combobox text changed(event). i want combobox drop down when query done user can see results , perhaps use them. the problems : rapid-fire queries => rapid-fire dropdown menu (not helpful) changing contents of dropdown causes text input cursor reset first position in field. typing more 3 characters before cursor forced first position hard. - default behaviour of combobox far know pressing 'down' scroll through list of suggestions causes first entry @ top of dropdown put text field. preferably doesn't happen unless user hits return or clicks it. what : overcoming dropdown-cursor repositioning issue. (this above all) scroll list arrow keys without being forced select anything. limit rate @ server queried. i have own solutions in place, terrible @ moment. i'm handling dropdown , query timings timer objects, implementation prevents query going on while user ty...

Ruby on Rails 3 Limited Multi-table query and Array Typecasting -

i'm trying show 5 reviews specific category opposed 5 reviews of category. have posted later working comparison purposes. the reviews have category id index, use category name , compare name category name of reviews want. store 5 reviews extract in array (is efficient way?). reviews , categories 2 separate tables. currently i'm getting error "can't convert review array". i'm guessing typecasting issue? don't want review become array. want result equivalent old code @review holds 5 reviews. i'm not sure if i'm approaching problem correctly. current code def home @review = [] idx = 1 review.find_each |review| break if idx == 5 @category = category.find(review.category_id).category_name if @category == "something" @review += review , idx+=1 end end end old code def home @review = review.find(:all, :limit => 5) end thanks help! what happening review ...

jQuery image gallery customization -

edit: question partially answered @ point, neil has put me on right path using scrollto plugin; however, detailed below, i'm still having issue getting "next" , "previous" links correctly adjust scrolling thumbnail list desired. thus, i'm wondering if other skilled jquery programmers out there take stab @ , try me overcome obstacle... in advance. ///////////////////////// wondering if proficient jquery programmers out there can offer assistance in modifying image gallery script: use galleriffic in upcoming project-- great plugin if you're not familiar-- instead of dividing thumbnails pages, i'd have scrolling div displaying thumbs @ once, shown here . my question whether it's possible have scrolling list of thumbs "follow" state of large image-- is, if 1 clicks "next photo" display full-size image, , corresponding thumbnail out of view, list scroll automatically show current thumbnail, if makes sense. guess such scri...

build - how to compile multiple java source files in command line -

i new java command line building. in eclipse, need write source in sample project , builds automatically. i know javac file1.java -----> file1.class if file1.java source file, can java file1 run it. however, if have 2 source files, file1.java file2.java how can build program? thanks lot! try following: javac file1.java file2.java

Git: Viewing log info for revisions ahead of the currently checked out one -

just wondering, if check out git revision behind recent, run git log, shows logs checked out revision - not modern. so, how view log info branches ahead of checked out revision? if have checked out different revision, no longer on original branch. can still run git log branchname to full log of branch interested in. if want see different log entries git log ..branchname which show log entries between current branch , branch name specified. you can 2 branches: git log branch1..branch2

python - How to get self file name -

possible duplicate: python, path of script is there way can print self filename of file , current location. could __file__ looking for?

Can anybody tell me how to create our own custom text view in android? -

hi can tell me how create our own custom text view in android? want set different colors textview font. can give example? whatever want: public class simpletextview extends textview { private static int color=color.red; public simpletextview(context context) { super(context); this.settextcolor(color) } public simpletextview(context context, attributeset attrs) { super(context, attrs); this.settextcolor(color) } public simpletextview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); this.settextcolor(color) } public static void setglobalcolor(int gcolor) { color=gcolor; } } so anytime can change color of textviews globally.

ASP.NET Caching - Programatically Invalidating Server Cache...confusion on example -

i'm reading how programmatically invalidate cached pages on server in asp.net, , book ("mcts self-paced traing kit (exam 70-515)") says: to directly control whether cached version of page used or whether page dynamically generated, response validatecacheoutput event , set valid value httpvalidationstatus attribute. the code segments following: public static void validatecacheoutput(httpcontext context, object data, ref httpvalidationstatus status) { if (context.request.querystring["status"] != null) { string pagestatus = context.request.querystring["status"]; if (pagestatus == "invalid") status = httpvalidationstatus.invalid; else if (pagestatus == "ignore") status = httpvalidationstatus.ignorethisrequest; else status = httpvalidationstatus.valid; } else status = httpvalidationstatus.valid; } protected void p...

server side set intersection in mongodb -

in application working on, requirement massive set intersection, tune of 10-1,000,000 items or so. items intersecting objectid's. so instance there boxes document , inside boxes document there item_ids array. item_ids array each box holds 10-1,000,000 objectid's. the end goal here say, given box objectid 4d3dc3898951498107000005, , box b objectid 4d3dc3898951498107000002, item_ids have in common? here how im doing it: db.boxes.distinct("item_ids", {'_id' : {$in : [objectid("4d3dc3898951498107000005"), objectid("4d3dc3898951498107000002")]}}) firstly curious if seems sane approach. in research far seems map reduce common suggestion large intersections, not recommended realtime queries. secondly, curious how behave in sharded environment? mongos run chunk of query on mongod's needs , aggregate result magically? lastly, if above sane, sane do: db.items.find({'_id' : { $in : db.eval(function() {return db.box...

.net - AssociationSet in EF4 -

i beginner in ef4 , , not able understand in .edmx file , could explain me benefit of associationset ,i think association element represents relationship between tables , why should use associationset . thanks, the associationset container association. lets began simle case when have contract , address types. relationship described in xml like: <association name="fk_address_contact"> <end role="contact" type="samplemodel.contact" multiplicity="1"> <ondelete action="cascade" /> </end> <end role="address" type="samplemodel.address" multiplicity="*" /> <referentialconstraint> <principal role="contact"> <propertyref name="contactid" /> </principal> <dependent role="address"> <propertyref name="contactid" /> </dependent> </referentialcon...

windows phone7 socket programming? -

how make windows phone7 suport socket programming? solution here? no, doesn't support yet. though microsoft has announced add in future. see wikipedia article more information (the announced apis section).

java - looking up entity manager in EJB Helper classes -

i trying inject entity manager in helper class, can pass helper session bean, problem need use entity manager in static init block of helper class (some thing like): class mysessionbeanhelperclass { // staff here... static { someclass s = new someclass(entitymanager); } } so, think way lookup entity manager instead of injecting it. , using passed sessioncontent not work here. (is it????) (this first question) the second question is: if used ordinary way lookup resource (in case entity manager) (something following:) context ic = new initialcontext(); em = (entitymanager) ic.lookup("java:comp/env/persistence/em"); is convert transactions used entity manager bean-managed transaction?? thanks! i don't think it's idea static initializer. have sure necessary services (such jndi, jpa) before lookup occurs, can't guarantee when static initializer. it's known problem in ejb there no "standard" way of performing one-t...

appcelerator - Titanium Mobile: execute code loaded from network -

i'm writing mobile apps of appcelerator's titanium mobile. i need load javascript code (business logic) our server , execute on device. dynamically injecting code titanium mobile app. additional note: code needs call few titanium's methods. can done? thanks, peter yes can done. can't put application in app store it's against terms of service download code remotely , execute it. there examples in kitchen sink on downloading file remotely , saving it. file can .js file, , can included or referenced when app loads. can have json, functions, whatever in it. i'm doing in app right moving json objects around, should able run code too.

iphone - Unable to set values in NSMutableDictionary in Unit tests -

i writing unit tests in ghunit test framework. have nsmutabledictionary detailsdict defined in application delegate. in application delegate set values in & save it. works fine in app when try call method set values on in unit tests not able set value & dictionary remains empty. in test case alloc init appdelegate. message method object sets few keys when check values remains empty. is there dont know unit testing or missing....? any answers pointers highly appreciated. edit: got had separately alloc init detailsdic variable this #ifdef unit_testing detailsdict = [[nsmutabledictionary alloc] init]; #endif still open other answers on other ways of doing this. you can't alloc , init variable. can alloc , init object, , indeed need alloc , init nsmutabledictionary object somewhere . the proper place somewhere run both application , every test case. app delegate's init method choice. that said, i'd app delegate should not exist @ in u...

procedural programming - What scope should my data objects have in VBA -

i populating set of arrays worksheet data. manipulate data before writing out worksheet (see example below). if want use same worksheet data again, how can avoid rewriting code populates arrays worksheet? should write code in 1 long procedure don't need repopulate arrays? should make arrays global can reused in several procedures? should pass arrays procedures need them in long argument list? any other options? sub manipulatedata() dim people(1 max_data_row) string dim projects(1 max_data_row) string dim startdates(1 max_data_row) date dim enddates(1 max_data_row) date ... loop through worksheet cells populate arrays ... array data end sub i'd create class contain arrays private variables , create 1 public sub called initialise or similar loads , other subs/functions needed give functionality need. that way don't have pass arrays around they're still not global. problem making them global it's more risk o...

c++ - Boost Plugin choices -

i'm looking implement plugin architecture our current application (unix, c++) , have been reviewing options (pending approval) within boost libraries. edit: i'm looking dynamically add classes @ runtime. boost.plugin boost.reflection boost.extension i wondering everyones experience/opinion on these , other implementations. eh. used dlopen , dlsym along pair of extern "c" static functions must defined in dll extern "c" static plugin* create( arg_pack* ); extern "c" static errno_t destroy( plugin* ); have plugin-manager ".dll" or ".so" files , load them a map<string, pair< plugin*(*)(arg_pack*), errno_t(*)(plugin*)> > you can lookup plugin based on name (the string above) , it's 'constructor' or 'destructor' see also: gmodule

php - Put result into session variables -

i have following: $res = $backend->user_login($data); when do: print_r($res); die(); i have: array ( [id] => 4cf79960693054282e58eedb [phone-id] =>email@email.com [phone-type] => web ) now have put each of 3 results in session variable, end 3 session variables containig id, phone-id , phone-type. how can that? thanks lot you mean this? foreach($res $name => $var) { $_session[$name] = $var; }

c++ - How to disable warnings for system headers in Sun Studio 12 -

we're in middle of tidying our codebase (among other things) fixing compiler warnings. the end goal turn on flag converts warnings errors. we've run slight snag system , thirdparty headers. of system headers cause various compilers emit warnings. can't go modifying system headers fix warnings. with intel compiler (and gcc) use -isystem instead of -i when building include path tell compilers headers in dirs system headers , stops warning them. it's simple matter of turning on -werror flag. we're using sun studio 12, flag -errwarn=%all should equivalent of -werror, can't find way tell compiler ignore warnings in system / thirdparty headers. there -errhdr flag, doesn't seem want. does know how accomplish sun studio 12? obviously, isn't want in absence of better wrap offending includes in #pragma error_messages block. e.g. #pragma error_messages (on , tag .. tag) #include <map> // etc #pragma error_messages (default , tag...

Actionscript 3 - find the coordinate of an edge of a movie clip -

how find left edge of movie clip? try using getbounds or getrect methods of display object: http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/flash/display/displayobject.html#getbounds() http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/flash/display/displayobject.html#getrect()

iphone - Obj-C, How to store / retrieve several date ranges and evaluate it for use based on past or future, least code possible? -

i need produce functions allow me store , retrieve date ranges. evaluate dates based on todays date, add them array. i'm not sure how many ranges i'll need keep. perhaps you've seen similar example of can use reference? edit. need save them use when app next run too. you can represent date range in 2 ways: start date + end date start date + duration you can represent date nsdate instance, double (or, if desperately need save memory, int, unix timestamp). i'd make class that. @interface daterange : nsobject <nscoding> { nstimeinterval start, end; } @property (nonatomic, assign) nsdate* startdate; @property (nonatomic, assign) nsdate* enddate; @property (nonatomic, assign) nstimeinterval duration; - (bool) containsdate: (nsdate *) date; @end @implementation daterange - (nsdate *) startdate { return [nsdate datewithtimeintervalsincereferencedate: start]; } - (void) setstartdate: (nsdate *) date { start = [date timeintervalsi...

Modules Design in C++ -

i'm new in website , want ask questions c++ because i'm learning these days , i'm noob (i know c , java). i'm using stroustrup book still don't understand uses , differences between classes , namespaces. also did c programs subject (operating systems) , want join of them in c++ program. idea have creat modules (because programs rely on different purpose). , have "main.cpp" file it's defined function called several times modules, check if module available , if so, can choose function of module want (depending on parameter passed). but problem don't know what's better way that. should use? classes or namespaces? , how can design? thought using design following: main.cpp --> modulea.cpp (implement interfacea.h) --> moduleb.cpp (implement interfaceb.h) --> modulec.cpp (implement interfacec.h) i searching on web other similar questions , found this one think it's complicate simple program. thank :) you wo...

ocaml - GODI-Batteries: Installation problems (yet again) -

i have asked question before turns out believed solution not. the problem i have started fresh godi installation , attempting install batteries library . have dependencies sorted, e.g. camomile. following error: > ocamlfind ocamlopt -a -package camomile,num,str src/batcamomile.cmx src/batconcurrent.cmx src/batinnerweaktbl.cmx src/batinnerio.cmx src/batinterfaces.cmx src/batmonad.cmx src/batref.cmx src/batvalue_printer.cmx src/batenum.cmx src/batprintf.cmx src/batlist.cmx src/batreflist.cmx src/batarg.cmx src/batbitset.cmx src/batchar.cmx src/batreturn.cmx src/batstring.cmx src/batuchar.cmx src/batutf8.cmx src/batrope.cmx src/batunix.cmx src/batio.cmx src/batarray.cmx src/batbigarray.cmx src/batnumber.cmx src/batbig_int.cmx src/batstd.cmx src/batbool.cmx src/batbuffer.cmx src/batint.cmx src/batmap.cmx src/batoption.cmx src/batpmap.cmx src/batlazylist.cmx src/batparserco.cmx src/batvect.cmx src/batcharparser.cmx src/batfloat.cmx src/batstream.cmx src/batgenlex.cmx src/batco...

Using Favicon With Bookmarklets -

i have bookmarklet webservice. bookmarklet link's code : (spaces added readability) javascript: void((function () { var e = document.createelement('script'); e.setattribute('type', 'text/javascript'); e.setattribute('src', 'http://www.girmiyor.co.cc/bookmarklet.js'); document.body.appendchild(e) })()) and want add favicon bookmarklet link. found this post it. they give example javascript code adding favicon javascript:’<!doctype html><html><head><title>hello world</title><link rel=”icon” type=”image/png” href=”http://www.tapper-ware.net/devel/js/js.bookmarklets/icons/next.png” /></head><body>hello world</body></html>’; i want use method on bookmarklet code. have combine codes. isn't work. readability version : javascript: void((function () { document.write('<html><head><link rel=\'shortcut icon\' href=\'http...

How to regenerate jQuery Mobile style after Ajax request? -

i'd apply autogenerated jquery mobile style (classes jquery mobile applies on page loading) after additionnal content loading via ajax. i load content via ajax parsed , organised <ul> , style jquery applies on page loading isn't applied again on ajax loaded content. assuming ul jquery-mobile "listview", try refresh entire list using : $('#yourlist').listview('refresh'); jquery mobile doucmentation http://jquerymobile.com/demos/1.0a2/#docs/forms/plugin-eventsmethods.html

java - What would be an appropriate data-structure to store a 2D table structure in memory? -

i have 2d table structure reading underlying database, , wondering, best in-memory data-structure use store into. where, can accessible further reading, manipulation, etc. i maps of maps like map<string, map<string,string>> table = new hashmap<string, map<string,string>>(); here example column_a(primary), column_b, column_c -------------------------------- abc | xyz | 123 def | xxx | 456 so after read table use this: map.get("abc").get("column_b").equals("xyz") map.get("def").get("column_c").equals("456") hope helps. note: chose first map have key of string because table may not have integers ids. can change them if think integer fit better.

jquery - javascript: returning a bool -

i have written jquery / js function "runs php query". function runquery(op){ if(op.type == "edit"){ var b = false; if(op.id != "" && (op.fromsong || op.tosong || op.when || op.comment)){ $.post("processor.php", { id: op.id, type: "edit", fromsong: op.fromsong, tosong: op.tosong, when: op.when, comment: op.comment }, function(data){ if(data == true){ console.log(true); b = true; }else{ console.log(false); b = false; } }); } return b; } i want return true of false depending on server answers. i'm sure php script working correctly , returning true or false correctly. every time run function console.log() outputs correct value, unlike variable b. seems alway false. doing wrong? since .ajax() call ( $.post wrapper $.ajax ) runs asyncronously , variable b return false . best thing "workaround" pass in call...

c++ - Turning on g++ optimization causes segfault - I don't get it -

i've been working on program, , decided turn on optimizations using g++ -o3 . suddenly, program started segfaulting. i've hunted problematic code down, , minimized program still segfaults (only when using level 3 optimizations). hoping take quick peek @ code (i tried minimizing as possible): // src/main.cpp #include "rt/lights/point.hpp" int main(int argc, char **argv) { rt::light *light = new rt::light::point(alg::vector(.0f, 5.0f, 5.0f), rt::color(1.0f), .5f); return 0; } // include/rt/lights/point.hpp #ifndef rt_light_point_hpp_ #define rt_light_point_hpp_ #include "rt/accelerator.hpp" #include "rt/color.hpp" #include "rt/intersection.hpp" #include "rt/light.hpp" // abstract namespace rt { namespace light { class point : public light { public: point(alg::vector pos, color color, float intensity) : light(intensity * color), pos(pos) {} color get_contrib(const intersection&, const accelerator...

How do I set delivery_mode on message using php extension AMQP with RabbitMQ? -

i've set whole infrastructure meaning i've configure php amqp extension http://www.php.net/manual/en/book.amqp.php . i've set durable exchange , queue. know should publish message delivery_mode = 2 (or equivalent in php) according http://www.rabbitmq.com/tutorial-two-python.html . don't know if can , if don't know how. $message = new amqpmessage(serialize($object), array('content_type' => 'text/plain', 'delivery_mode' => 2)); this using http://code.google.com/p/php-amqplib/ , guess native extension has similar syntax.

cocoa - Best way to share a resource inside an iPhone Application -

i kinda new objective-c , iphone development , have question. i'm creating app retrieved data internet using json-rpc. i've created json-rpc client performs requests , passes down results using delegate. however need use client quite few times in application, have been thinking. best way share client resource? understanding (from i've read far @ least) have following options: instantiate seperate client on each of controllers need access remote data pass instantiated client down on each new controller instance add client appdelegate create singleton of client , use that use global variable 1,2 options seem waste of resources. i've been reading 3,5 not best way go. leaves 4. don't think can use singleton delegates. should switch nsnotification? is there other way go about? from understand, trying want connect server on internet multiple times download data? if should use nsurlconnection class , create nsurlconnection object each time reques...

php - Sort multi-dimensional array help -

i trying sort array season_number not sure function use assume need custom sort? ideas? array ( [0] => array ( [season_number] => 7 [show_id] => 21 [show_seasons_id] => 14 ) [1] => array ( [season_number] => 6 [show_id] => 21 [show_seasons_id] => 31 ) [2] => array ( [season_number] => 1 [show_id] => 21 [show_seasons_id] => 40 ) [3] => array ( [season_number] => 2 [show_id] => 21 [show_seasons_id] => 41 ) ) you can use usort function 'compare' function: function compare_my_elements( $arr1, $arr2 ) { $s1=$arr1["season_number"]; $s2=$arr2["season_number"]; if( $s1 == $s2 ) return 0; return ( $s1 > $s2 ? 1 : -1 ); } usort( $my_md_array, compare_my_elements )...

Bandwidth Monitoring using c++ program -

i developing small application requires module check whether there bandwidth or not.basically module should trigger event when bandwidth goes down. can achieved using c++ program look network interface in /sys/class/net/ directory. system has 2 interfaces lo , eth0. there lot of files describing status of interface explore. i start operstate, statistics/rx_bytes or statistics/rx_packets.

apache - htaccess to redirect to a sub-directory based on the host name -

question: what ruleset need following redirects: [1] http://www.xyzblog.com/foo/bar.php => htdocs/projects/xyzblog/foo/bar.php [2] http://www.xyzblog.com/js/jquery-min.js => htdocs/js/jquery-min.js [3] http://www.bigcommerce.ch/images/baz.png => htdocs/projects/bigcommerce/images/baz.png [4] http://www.bigcommerce.ch/css/reset.css => htdocs/css/reset.css in [2] , [4] requested file exist in original path, no redirect takes place. background: i have wamp envo uses apache friend's excellent xampp. work on multiple projects different clients , have set following directory structure: htdocs + css + images + includes + js + projects + bigcommerce + xyzblog ... when start working on new project create directory same name under projects; moreover, name project after host name of client. if start working on project production site http://www . dreamvacation.com add dreamvacation directory under projects directory. lastly tempor...

When I create an iphone window based app, how to tell interface builder create window for retina pixel size? -

i hope create iphone window based app retina screen? found size of window in mainwindow.xib fixed. how adjust or there tell interface builder create window retina pixel size? welcome comment thanks interdev there's no need in terms of various components layout in interface builder, it's based around points, not pixels - , iphone screens sizes same in points no action required. in terms of images you're loading, need supply higher resolution (twice pixel size) versions, long these named "[original name]@2x.[extension]" they'll work automatically. for more information on image naming, see "specifying high-resolution images in ios" section of resource programming guide , if want delve little deeper, there's discussion on "points versus pixels" within drawing , printing guide ios . update - of iphone 5, iphone screens no longer same point size. :-)

Slowdown in large perl array -

i'm running perl program have take 1 million line text file, break down chunks (anywhere between 50 , 50,000 lines per chunk), , run calculations , such on them. right now, load of data array1. take array2 , use pull chunks of data need. need perform on array 2, , go , grab next set. example data a, blah1, blah2 a, blah6, blah7 a, blah4, blah5 b, blah2, blah2 so grab first 3 array 2, sort them, move on next set. program works pretty , efficiently begin with, experiences severe slowdown later on. 50k takes 50 seconds, 100k takes 184 seconds, 150k takes 360 seconds, 200k takes 581 seconds, , gets exponentially worse program continues (4500 seconds @ line 500k) no, cannot use database project, suggestions? my @rows1=<file>; $temp = @rows1; for($k = 0; $k < $temp; $k++) { @temp2array = (); $temp2count = 0; $thisrow = $rows1[$k]; @thisarray = split(',', $thisrow); $currcode = $thisarray[0]; $flag123 = 0; $temp2array[$...

android - Using Jackson to deserialize JSON objects to POJOs -

i'm trying use jackson in android project via objectmapper. my pojo follows: public class product { @jsonproperty("title") string title; @jsonproperty("vendor") string vendor; public void settitle(string title){ this.title = title; } public void setvendor(string vendor){ this.vendor = vendor; } public string gettitle() { return title; } public string getvendor() { return vendor; } } i've written unit test see if jackson working deserialize json objects. context ctx; public void setup() throws exception { super.setup(); ctx = getcontext(); } public void testconvertjsontoproduct() throws exception { objectmapper m = new objectmapper(); product product = m.readvalue(ctx.getassets().open("foo.json"), product.class); assertequals("macbook", product.gettitle()); } my actual json file contains more information i've set in product, want working. using larger file causes p...