Posts

Showing posts from April, 2015

Problem in C# .net web application Redirection -

i coded httpmodule , added correctly site give me error when run it: **the page isn't redirecting firefox has detected server redirecting request address in way never complete.** using system; using system.web; using system.net; using system.text; using system.io; namespace commonrewriter { public class parseurl : ihttpmodule { public parseurl() { } public string modulename { { return "commonrewriter"; } } public void init(httpapplication application) { application.beginrequest += new eventhandler(application_beginrequest); application.endrequest += new eventhandler(application_endrequest); } private string parseandreapply(string texttoparse) { string final = null; if (texttoparse.contains("....

sql server - Update or Insert Depending on Whether the Record Already Exists -

i want update "grade" column in "studenttable" clause of "studentid"". , if there no "studentid" found in "studenttable" want insert data instead. how can this? you first check if record exists, if perform update, if not exist, means need insert it. here go: if exists(select * studenttable studentid = @myid) begin --exists perform update update studenttable set grade = 'a+' studentid=@myid --other code... end else begin --record not exist insert insert studenttable(myid, grade) values (@myid, 'a+') --other code... end

python - Difference between frompyfunc and vectorize in numpy -

what difference between vectorize , frompyfunc in numpy? both seem similar. typical use case each of them? edit : joshadel indicates, class vectorize seems built upon frompyfunc . (see the source ). still unclear me whether frompyfunc may have use case not covered vectorize ... as joshadel points out, vectorize wraps frompyfunc . vectorize adds features: copies docstring original function allows exclude argument broadcasting rules. returns array of correct dtype instead of dtype=object edit: after brief benchmarking, find vectorize slower (~50%) frompyfunc large arrays. if performance critical in application, benchmark use-case first. ` >>> = numpy.indices((3,3)).sum(0) >>> print a, a.dtype [[0 1 2] [1 2 3] [2 3 4]] int32 >>> def f(x,y): """returns 2 times x plus y""" return 2*x+y >>> f_vectorize = numpy.vectorize(f) >>> f_frompyfunc = numpy.frompyfunc(f, 2, 1...

Bash, always echo in conditional statement -

this may turn out more of thought exercise, trying echo newline after command i'm executing within conditional. example, have: if ssh me@host [ -e $filename ] ; echo "file exists remotely" else echo "does not exist remotely" fi and want throw in echo after ssh command regardless of outcome. reason formatting; way newline exist after prompt password ssh. first try if ssh me@host [ -e $filename ] && echo ; because && echo not change conditional outcome, bash not execute echo if ssh returned false. similarly, if ssh me@host [ -e $filename ] || (echo && false) ; does not work because short-circuit if ssh returns true. an answer problem be ssh me@host [ -e $filename ] result=$? echo if [ $result == 0 ] ; but wondering if there similar conditional expression this. thanks. while work if foo && echo || ! echo; i'd prefer putting whole thing function function addecho() { "$...

storing data picked up from php file in jquery -

i have php file runs simple jquery script: var text = $(".hide").text(); i wondering how store data when redirect other pages you put a cookie . write it, leave page, read own cookie when next page. or post php script, , store in session variable. in jquery, this $.post("my_other_script.php", { text: "my piece of text"} ); my_other_script.php be <?php $_session['text'] = $_post['text']; ?> here jquery page documentation it.

java - JMS MockTopic message not picked up by message listener? -

i trying write junit test show jms subscriber's start() function kicks off message listener topic (and messages not being consumed before start() called). i running issue messages placed on topic before start() function called not processed once start() called. messages placed on topic after start() called processed immediately. mocktopic topicwriter = getmocktopic(topic); // publish message listener pick mockobjectmessage objectmessage = new mockobjectmessage(message); objectmessage.setbooleanproperty("broadcast", true); topicwriter.addmessage(objectmessage); // message doesn't consumed because subscriber has not been started //...assert message not processed... (**succeeds**) // start subscriber/listener subscriber.start(); //...assert messages sitting on topic processed... (**fails**) // publish message listener pick topicwriter.addmessage(objectmessage); //...assert message gets processed... (**succeeds**) while shows listener not running b...

c# - Paralleling trading software (continue) -

i'm not sure if need use such advanced technics plinq that's because rephrase previous question paralleling trading software think previous question complicated , not clear, hope extracted required infromation , nothing else. i have 2 similar (i identical) threads. thread1: while (true) foreach (object lockobj : lockobjects) { lock (lockobj) { // work (may take time) } } } thread2 (the same, work): while (true) // same lockobjects thread1 used threads use "shared" resources foreach (object lockobj : lockobjects) { lock (lockobj) { // work (may take time) } } } profilier says 30% of processor time i'm waiting lock released. how avoid easily? how say, "ok, if object locked now, postpone object processing, process object, , return object after while?" one approach maintain queue of free objects, , list of each thread has processed. have threads find first...

MySQL Join Query to Sum a Field in One Table based on Its Corresponding Login ID in another Table -

i have mysql table comment following fields: loginid submissionid points i have mysql table called submission following fields: loginid submissionid for given submissionid , loginid in 2 tables represent different things , therefore nor correspond. i join sum points loginid . however, not loginid in comment , rather loginid in submission . connection between 2 tables made via submissionid i can't work. below have far. i'm trying desired sum each loginid pulled another, third table, l.loginid represents. how can this? left join ( select c2.submissionid, c2.loginid sum(points) total comment c2 inner join submission s2 on s2.submissionid = c2.submissionid group c2.submissionid ) cscs on cscs.loginid = l.loginid select s2.loginid, sum(points) total submission s2 inner join comment c2 on s2.submissionid = c2.submissionid group s2.loginid this give points sum each loginid in submission table.

c# - How do I unit test a method like this using IOC -

i'm trying wtire unit tests function looks this: public list<int> process(int input) { list<int> outputlist = new list<int>(); list<int> list = this.dependency1.getsomelist(input); foreach(int element in list) { // ... procssing element //do more processing int processedint = this.dependency2.dosomeprocessing(element); // ... processing processedint outputlist.add(processedint); } return outputlist; } i planning on mocking dependency1 , dependency2 in test cases i'm not sure how should set them up. in order setup dependency2.dosomeprocessing need know value of "element" each time called. figure out either need to: copy paste of logic process() method test case calculate values hand (in actual function involve hard coding doubles many decimal places test case) bite bullet , use actual implementation of dependency2 instead of mocking it. none of these solutions se...

Django-CMS plugin not appearing -

i'm deploying django website. custom plugins have work on computer (i can add them template block drop down.) when push code out site, not plugins available. the database tables created, , if import plugin_pool , call discover_plugins() , get_all_plugins() plugins show up. question is, why aren't plugins showing? ideas? is app plugin ( cms_plugins.py file) in installed_apps ? does have models.py (which empty) file? can import cms_plugins.py file when using python manage.py shell ? the common problem import errors in cms_plugins.py file

linq - How to learn MVC 3 and Entity Framework? -

i have need learn mvc 3 razor view engine , entity framework 4, , trying figure out start. over year ago, build site in mvc 2 , linq sql, it's been long time since i've thought @ , i've forgotten lot. though, still have loose understanding of routing, action links, , bit of linq. so, i'm not starting scratch, feels it. i've been doing lots of digging around, in order learn can, have begun feel bit overwhelmed. watched videos on http://www.asp.net/mvc . while these helped, there still lots of holes in knowledge. in case, here specific things i'm hoping guys can me find: a good, hands-on mvc 3 tutorial (not unlike nerd dinner tutorials available mvc 2) a clear explanation of entity framework 4, including coverage of topics such lazy loading , poco objects a clear explaination of linq, focusing on of extension methods available, etc resources not focused on code first models. have database in use (i'm not sure see value in code first anyway) ...

c# - why EF takes a long time in first called method -

i'm working @ application on web , i'm using ef create model , accessing db. create session var use in session level: private model.websitemodelcontainer s_defaultmodel; public model.websitemodelcontainer defaultmodel { { s_defaultmodel = httpcontext.current.session["defaultmodel"] websitemodelcontainer; if (s_defaultmodel == null) { s_defaultmodel = new model.websitemodelcontainer(); httpcontext.current.session["defaultmodel"] = s_defaultmodel; } return s_defaultmodel; } } use defaultmodel in code: return defaultmodel.ages.orderby(c => c.agename).tolist(); after new build of project, first database query executed causes ef build views uses data access. can cause significant delay. can work around having ef pre-compile views. see how to: pre-generate views improve query performance msdn.

error on click of Submit Button in asp.net mvc page -

i in strange problem. have asp.net mvc web page. scenario this: let's user clicks on submit button once , page postback server. far fine. but if user keeps on clicking submit button continuously , page processing. application crashes. how can solve problem? have tried disabling button javascript?

c# - Converting gridview into image -

i want convert gridview image , save localdisk in asp.net 3.5.i donot have idea how it. can please suggest something. thanks in advance. the following links may you: convert datagridview bitmap exporting datagridview excel/pdf/image file using reporting services report generation - codeproject

C++ file IO seeking to a specific line -

for instance, have test.txt containing : apple computer glass mouse blue ground then, want retrieve 1 random line text file. here's code : ifstream file; file.open("test.txt", ios::in); char word[21]; int line = rand()%6 + 1; (int x = 0 ; x < line ; x++) test.getline (word, 21); cout << word; the problem variable 'word' contains first line, no matter random number given... seed random number suggested comments above #include <cstdlib> #include <ctime> #include <fstream> //...other includes , code ifstream file; file.open("abc.txt", ios::in); char word[21]; srand( time(null) ); int line = rand()%6 + 1; (int x = 0 ; x < line ; x++) file.getline (word, 21); cout << word;

wordpress - Display Ad every after 3 Posts -

i'm trying display advertisement every after 3 posts in wordpress blog. guys check that's wrong in code? see code here see make $after_every = 0 , add $after_every++ bottom of while loop then add 1 condition if($after_every%3==0){ show add} i think works.

php - pass fpassthru contents to variable -

here's portion of code (taken google charts example here http://code.google.com/apis/chart/image/docs/post_requests.html ) display image chart: $context = stream_context_create( array('http' => array( 'method' => 'post', 'content' => http_build_query($chart)))); fpassthru(fopen($url, 'r', false, $context)); the problem instead of displaying image directly, i'd pass contents of fpassthru (which image) variable.. perhaps like $image = fpassthru(fopen($url, 'r', false, $context)); any idea? thanks use file_get_contents : $image = file_get_contents($url, false, $context); or stream_get_contents (but don't forget close file): $f = fopen($url, 'rb', false, $context); $image = stream_get_contents($f); fcloes($f);

Retrieve data from mongodb using C# driver -

i'm using official mongodb driver c# in test project , i've insert document c# web application mongodb. in mongo console, db.blog.find() can display entries i've inserted. when tried retrieve them, .net throw exception "system.invalidoperationexception: readstring can called when currentbsontype string, not when currentbsontype objectid." my entity class simple namespace mongodbtest { public class blog { public string _id { get; set; } public string title { get; set; } } } and retrieve code public list<blog> list() { mongocollection collection = md.getcollection<blog>("blog"); mongocursor<blog> cursor = collection.findallas<blog>(); cursor.setlimit(5); return cursor.tolist(); } can me out? thanks! i suppose need mark blog id bsonid (and insert id yourself) attribute: public class ...

javascript - jQuery custom validator method getting called whenever element changes -

i have select target of custom validator method. validator: var validator = $("#myform").validate({ rules : { source: "source_selected", }, messages : { }, errorlabelcontainer: $("#error_container ul"), errorcontainer: $("#error_container"), wrapper : "li" }); custom validator method: $.validator.addmethod("source_selected", function(value, element) { var source_id = $(element).selectedvalues(); if(source_id == 0) { return false; } return true; }, "please select source copy subscriptions from."); select: <select name="source" id="source"> <option value="0">-- choose --</option> <? foreach($managers $id => $name) { ?> <option value="<?=$id?>"><?=$name?></option> ...

exe - Python Pmw and cx_Freeze? -

i unable make executable python program uses pmw (python mega widgets). use cx_freeze (through gui backend "gui2exe"). searching pmw site i've found it's caused how pmw library checks modules when ran , doesn't work when use py2exe or similar programs because libraries in zip file. more info can found here: http://pmw.sourceforge.net/doc/dynamicloader.html give solution in page, under "freezing pmw", providing script generates single standalone pmw module can freeze. however, script uses deprecated code , won't work python 2.6 +. i've tried modify no luck. edit: i'd mention replacing 'regex' 're' won't work. #!/usr/bin/env python # helper script when freezing pmw applications. concatenates # pmw megawidget files single file, 'pmw.py', in current # directory. script must called 1 argument, being # path 'lib' directory of required version of pmw. # freeze pmw application, need copy # following fil...

eclipse - Generate .jar from scala -

i'm developing application on eclipse scala , create .jar. have found tuto that, use package scala.tools.nsc , don't know can found thing. have tried too, generate .class , command jar cmf .... generate .jar when launch .jar error occur. (noclassfound) sbt have tried too, when compile project work eclipse lot of error appear. somebody can me explain how can create .jar eclipse or tools. eclipse has build-in option generate runnable jars, hidden. not recognize scala's main() signatures, have create java class main() method. create java class main() method forwards call scala code. then right click on newly created java class , select: run -> java application. create runnable configuration later used part of runnable jar. now ready dig out runnable jar option eclipse's menu: file -> export -> java -> runnable jar file in presented dialog select launch configuration have created earlier (in step2), name jar (myapp.jar), select dependen...

Silverlight Saving a Class Instance to Isolated Storage -

im wondering how go saving instance of class silverlight isolated storage. need know if possible class save isolated storage can have list of instances of class. here example of situation: public class mysettingstostore private mpropertya string public property propertya() string return mpropertya end set(byval value string) mpropertya = value end set end property private mlstofsubclass list(of mysubclass) public property lstofsubclass() list(of mysubclass) return mlstofsubclass end set(byval value list(of mysubclass)) mlstofsubclass = value end set end property end class public class mysubclass private mpropertya string public property propertya() string return mpropertya end set(byval value string) mpropertya = value end set end property private mpropertyb string public property propertyb() string return mpropertyb en...

asp.net - How can I parse a date like 07/21/2011 23:59:59 in c# -

how can parse date using datetime.parseexact?: 07/21/2011 23:59:59 in c#? thanks :) cultureinfo provider = cultureinfo.invariantculture; datetime.parseexact("07/21/2011 23:59:59","mm/dd/yyyy hh:mm:ss",provider)

actionscript 3 - AS3 : Scaling Sprite with Matrix on slider change? -

i have sprite holds bitmap data. want give user ability resize image slider. using code beneath, can see problem scaling additive image gone totally. i understand have scale in non additive way, can not figure out how? i tried pass : var m:matrix = userimagecopy.transform.matrix; when userimagecopy holds original image. helped scaling then, each time scaling started userimage jumped position of userimagecopy. any help? function onsliderchange(evt:event):void { trace( evt.target.value); //this create point object @ center of display object var ptrotationpoint:point = new point(userimage.x + userimage.width / 2,userimage.y + userimage.height / 2); //call function , pass in object rotated, amount scale x , y (sx, sy), , point object created scalefromcenter(userimage, evt.target.value, evt.target.value, ptrotationpoint); } private function scalefromcenter(ob:*, sx:number, sy:number, ptscalepoint:point) { var ...

asp.net mvc 3 - Label with HTML content -

how may create strongly-typed label html content inside in mvc3? <label for="nnn"><input type="checkbox" id="nnn" />herp</label> i have checked code in w3c validator , seems valid, there way it? thanks. you use custom html helper tagbuilder . something (untested); public static mvchtmlstring labelcheckboxfor<tmodel>( htmlhelper<tmodel> htmlhelper, expression<func<tmodel,bool>> expression, string text) { var labeltag = new tagbuilder("label"); labeltag.mergeattribute("for", "nnn"); labeltag.innerhtml = htmlhelper.checkboxfor(expression) + text; return labeltag.tostring(tagrendermode.selfclosing); } might not 100% idea. i'm not sure how pull "for" value out of model. might need fromlambdaexpression , or parameter. and use this: @html.labelcheckboxfor(model => model.somefield, "herp")

javascript - setInterval() for an analogue clock -

i'm quite new javascript , have trouble working etinterval() . i'm creating analogue clock exercise. have function settime() gets , displays time rotating arrows accordingly. i want execute function again , again. here code : $(document).ready(function(){ function settime(){ var d = new date(); var hour = d.gethours(); var minute = d.getminutes(); var hourrotation = hour * 30 + (minute / 2); var minuterotation = minute * 6; $("#small").css({ "-webkit-transform": "rotate(" + hourrotation + "deg)", "-moz-transform": "rotate(" + hourrotation + "deg)", "-o-transform": "rotate(" + hourrotation + "deg)" }); $("#big").css({ "-webkit-transform": "rotate(" + minuterotation + ...

Which Android/Java ORM uses “object caching” like Hibernate does? -

i saw bunch of questions lightweight alternatives hibernate, android. of them has “identity map” pattern? this pattern makes sure object representing row in db exists once in session. – helps program consistent: if change mapped object somewhere, changed everywhere (because references point same object). doesn’t matter if re-fetch object via new database query, or still have around earlier calls: orm makes sure behave same thing. hibernate in it’s “level 1 cache”. ormlite android orm package of version 4.26 (released on 9/26/2011) contains first take on internal object cache. ormlite not have "session" pattern user can inject cache dao , can flush whenever choose. here docs cache support. http://ormlite.com/docs/object-cache to quote manual, cache supports following things: if create object using dao, added cache. when query object using dao, if object in cache returned. if not in cache added cache. not apply raw query methods. if update o...

jQuery mouseover not working for li element -

i'm trying make menu based on ul element show link description underneath link. so far, have following code (simplified little) echo ' <script> $("#menu_1").mouseover(function() { $("#description").replacewith("test"); }); </script> <ul class="menu_top"> <li id="menu_1"><a href = "#">test</a></li> </ul> <div id="description" class="menu_desc">&nbsp; </div> '; however, everytime move mouse on li element, nothing happens. does know i'm doing wrong? javascript code executed encountered. might happen before document ready. in case, you're trying select #menu_1 element before exists in document . because want jquery code run after document ready, jquery provides shortcut method you: $(function () { // code run after whole document ready go $("#menu_1")...

Enabling site-wide RSS in Plone -

i plone newbie , i'm trying set site-wide rss feed of site's content in plone 4.0.7 i have followed instructions here: http://plone.org/documentation/manual/plone-community-developer-documentation/functionality/rss i've partially succeeded - created content collection, , rss feed working: http://nitric.co.za/site-feed/rss the problem <link type="alternate"... /> not appearing on every page of site. the instructions suggest in zmi -> portal_actions -> site_actions there should record rss. there no such record in installation. under portal_actions -> document_actions there cut , paste site_actions had no effect. what best way rss link tag appear in html header of every page on site? site_actions links @ bottom of page (eg site map, accessibility, contact) won't in getting elements header. to have feeds available on pages throughout portal need create custom theme package , either register custom viewlet or customize ma...

Why doesn't google show www. for my website on searches? -

my site http://www.billysclaypots.com shown in google without www. in front when search "billys clay pots". how can make google shows www. in front, know usability studies confirm users less go url without www think there fault site. i've added line .htaccess redirect nonwww requests www , works: rewritecond %{http_host} !^www\. rewriterule ^ http://www.%{http_host}%{request_uri} [l,r=301] my guess may have submitted site google/addurl without www in front ....

Error while printing in WPF -

i'm getting following error while printing in wpf. printticket provider failed retrieve printcapabilities. win32 error. here code print printdlg.printdocument(idpsource.documentpaginator, "hello wpf printing."); i don't know problem, related printer. from control panel -> printers & fax right click printer , take printer preferences change source property 'manual feed'& apply.(initially was'autoselect') still got error. again me changed source property 'auto select'& apply. changed quick set property 'defaults'& apply now working fine

oracle - Exporting result of select statement to CSV format -

possible duplicate: create excel spreadsheet oracle database how can export result of select statement csv format in oracle, please in pl/sql thanks if use tool sql developer, or toad, or sqlnavigator have option saving results of query. if use sqlplus, can use spool command.( how spool csv formatted file using sqlplus? ) what's case?

c# - trying to create the click event handler -

Image
so i've made range bar chart ms chart control. have question: how can implement event handler when user clicks on red colour? can't see 1 anywhere. i uploading sample graph here i want show graph if click on red colour on graph so how can create click event handler 1 see find region part of live using c# similar question ... within click handler var pos = e.location; var results = chart1.hittest(pos.x, pos.y, false, chartelementtype.datapoint); foreach (var result in results) { if (result.chartelementtype == chartelementtype.datapoint) { if (result.series.points[result.pointindex].color == color.red) { console.writeline("success?"); } } } note color null on particular point appear red on graph (it obtained series). long manually set color on clickable points, work, may want think whether color thing should testing.

Problem calling shell script from PHP which calls Java -

first have tell you, i'm french guy, can make mistake english ;-) here problem : want use java processor transform xml file. made shell script wich working well. when execute shell script php doesn't work ... // tried $resultat = shell_exec("sh ".$chemin."script.sh"); // , after $resultat = shell_exec("java -jar ". $jar ." -s:".$source." -xsl:".$xslt); the file "script.sh" contains : jar='lib/saxon/saxon9he.jar' source='temp/fichier_xml.xml' result="temp/output.xml" xslt="xml_to_xml.xsl" java -jar $jar -s:$source -xsl:$xslt i think that's problem java ... can not resolve !! if have idea me, thanks try using script in backticks i.e. ``

ASP.NET opening email attachements -

i have asp.net web forms application pulls email imap account. using imap control nsoftware ip*works pull emails. in order download , save attachments 1 this... for (int part = 0; part < imaps1.messageparts.count; part++) { if (imaps1.messageparts[part].filename.length > 0) { imaps1.localfile = "c:\\users\\someguy\\documents\\" + imaps1.messageparts[part].filename; imaps1.fetchmessagepart(imaps1.messageparts[part].id); } } but don't want downloaded; want attachment open. how that? thanks! you need save attachment contents response.outputstream rather file on disk.

jquery - Creating xls in javascript using ActiveXObject -

my code var fsobj = new activexobject("scripting.filesystemobject"); var excelapp = new activexobject("excel.application"); excelapp.displayalerts = false; var wbobj = excelapp.workbooks.add; var wsobj = wbobj.worksheets(1); when use below code works fine (i.e., executes excel , fills in 2 rows) wsobj.cells(1,1).value="hello"; wsobj.cells(2,1).value=comparedata.response.length; wbobj.application.visible=true; but when use below code says expected ';' in 3rd line (with hello), not able find problem here. here jsfiddle link, not working though, if can make work for(i=0;i<comparedata.response.length;i++) { wsobj.cells(i,1).value="hello"; } wbobj.application.visible=true; row numbers in excel start 1, not 0. should write for(i=0; i<comparedata.response.length; i++) { wsobj.cells(i + 1, 1).value="hello"; }

How do I achieve ajax autocomplete using data-filter attribute in Jquery mobile -

i've been looking @ the: data-filter="true" option filtering list based on entered search box using jquery mobile. i'd same except hook in ability use ajax get() populate list. know how go doing or example anywhere of being achieved. i've not seen on jq mobile site. thanks. i couldn't find built in ask, able achieve using simple ajax request , manually filling list. started text box search field, , empty ul <div data-role="fieldcontain"> <label for="search">search:</label> <input type="search" name="search" id="search" value=""/> </div> <ul id="results" data-role="listview"> </ul> this script block send ajax request after each key press, might better add delay though. abort previous request if still loading , person types key. not perfect, start. <script> var last, last_xhr; var x = $('#...

ruby on rails - Why am I getting an error when I try to update my Heroku database? -

why getting error when try update heroku database? whenever try heroku rake ... command same error: $ heroku rake db:setup (in /app) rake aborted! uninitialized constant rake::dsl /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:tasklib>' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:rake>' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `require' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks/documentation.rake:1:in `require' /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks/documentation.rake:1:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/railties-3...

sorting - CoreData maintain relationship order -

Image
i have simple coredata model expressed as: there number of "trips" can contain multiple images. additionally, single image can in multiple trips. my issue want maintain order in added trip. normally, add field imagedata object maintains index . however, because image can in number of trips doesn't make sense. what clean way maintaining index in case? the old way of handling provide linking entity encodes order. trip{ //...various attributes images<-->>triptoimage.trip } image{ //...various attributes trips<-->>triptoimage.image } triptoimage{ trip<<-->trip.images image<<-->image.trips previous<-->triptoimage.next next<-->triptoimage.previous } the linking entity extending modeling of relationship. can create arbitary order of trips or images. however, such ordering can rendered superfluous better model design. in case, if images have specific dates , locations, how can part of mo...

adding /using silverlight ddl in visual studio 2008 -

i trying add silverlight3.0 ddl in visual studio 2008 getting following error help. ** error in loading type assembly.could not load file or assembly system.windows ** have tried repairing silverlight tools installation? , have silverlight sdk installed? the silverlight sdk can installed using following link: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=16011 the silverlight addon vs 2008 sp1 can found here includes sdk , other components: http://www.microsoft.com/download/en/details.aspx?id=9394 you may check following: http://hmcguirk.blogspot.com/2011/02/silverlight-could-not-load-file-or.html hope helps!

html - How to increase height of an element upwards? -

the html code: <ul> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> <li>f</li> </ul> if add 1 more li in list, height grows downwards. keep list bottom static , increase height upwards. update: trying keep small bar in bottom of browser window always. when user picks something, bar show item. if more 1 item, container has auto increase height upwards. how it? any suggestions appreciative! thanks! so guess list should in absolute position width specified bottom .

user interface - Examples of UX Web Application Diagrams -

i looking examples of ux diagrams, not technical perspective, more user experience perspective. mainly keeping in mind of different states, logged in, not logged in, public profile, private profile, first time visiting page, etc etc. are looking tool "wireframes"? - try http://webdesignledger.com/tools/10-excellent-tools-for-creating-web-design-wireframes

asp.net - NHibernate: Criteria query slow in web app but fast in unit tests, why? -

i having problem criteria query in nhibernate executes in less second when run in unit test, when try run context of web application, takes on minute. both hitting same database same data. my nhibernate mapping: var properties = new dictionary<string, string>(); var configuration = new configuration(); properties.add("connection.provider", "nhibernate.connection.driverconnectionprovider"); properties.add("proxyfactory.factory_class", "nhibernate.bytecode.defaultproxyfactoryfactory, nhibernate"); properties.add("connection.release_mode", "on_close"); properties.add("current_session_context_class", "web"); properties.add("dialect", "nhibernate.dialect.mssql2005dialect"); properties.add("connection.connection_string_name", "dbconnection"); configuration.properties = properties; sessionfactory = configuration.buildsessionfactory(); the difference in mappi...

ANDROID : Changing the color of ExpandableListView's group indicator -

the problem : i've changed app's background color white, , cannot see expandablelistview's group indicator anymore. expandablelistview has methods change text color, background color, , divider color, nothing can see group indicator color. i not want provide custom drawables, want change color of drawables provided android, programmatically. i feel there must simple way this. you have use custom drawables here. can't change android drawables provided android.

xcode - How many versions back is it common to test iOS apps? -

is common test apps compatibility older ios versions (in case, ios 4.3 apps ios 2.x)? or apps tested 1 version or so. idea percentage of ios market lost me if app doesn't work on older versions? i'm guessing miniscule amount, seems enough employer ask me distant backwards compatibility -_- this varies quite bit app-to-app, depending on features being used , broadness/niche-ness of market. broadest should target is: current release, previous "dot" release, last version of previous major release. (now, 5.0 not yet released, 4.3, 4.2, 3.2 (which ipad only, 3.1.3 iphone/ipod). my suggestion never need support more this. if product doesn't work on 3.0, user can update free. of course older hardware doesn't update, , if market "people getting left behind" (which doesn't overlap "people spending money in app store") can support older. some support newer because of powerful features being used in newer releases. 4.0 had lo...

documentation - What IP addresses to use in public bug reports if the actual ones are confidential? -

i wondering best practice using ip addresses in publicly available reports, e.g. bug reports, if don't want use actual 1 privacy reasons , don't want confuse people want me. i considered addresses test-nets, see rfc 5737 : 192.0.2.0/24 - test-net-1 198.51.100.0/24 - test-net-2 203.0.113.0/24 - test-net-3 but not clear me paragraph means: rfc 5737, section 4: addresses within test-net-1, test-net-2, , test-net-3 blocks should not appear on public internet , used without coordination iana or internet registry [rfc2050]. does mean, 1 should use in-house documentation or no device should appear on internet claiming has 1 address test nets? the other option use private ip addresses, e.g. 10.0.0.0/8. anything else? what considered best practice? does mean, 1 should use in-house documentation or no device should appear on internet claiming has 1 address test nets? the latter -- no device on internet should use 1 of ip a...

iphone - Choosing unique label for NSManagedObject in CoreData -

i'm searching better alternative deal problem. in coredata model have nsmanagedobject called project. in subclass override accessor method (setter) label attribute. here check whether same label used. if is, add underscore , number label, e.g. "myproject" renamed "myproject_1". of course have check whether find label "myproject" or "myproject_"+number. regular expression. nsstring *regexstring = [nsstring stringwithformat:@"%@_[0-9]+", value]; nspredicate *predicate = [nspredicate predicatewithformat:@"(label = %@) or (label matches %@)", value, regexstring]; [request setpredicate:predicate]; then check how many results fetched, lets 5, know next 1 hast called "myproject_6". it works fine have noticed there little problem code: happens if have following labels: myproject_1, myproject_2, myproject_3 and user decides call project myproject_55. search retrieve 4 elements , next project labeled mypro...

javascript - Iterate over array and calculate average values of array-parts -

i have array this: ["2011-06-16 16:37:20",23.2], ["2011-06-21 16:37:20",35.6], ["2011-06-26 16:37:20",41.8], ["2011-07-01 16:37:20",25], ["2011-07-06 16:37:20",22.8], ["2011-07-11 16:37:20",36.4], ["2011-07-16 16:37:20",34], ["2011-07-21 16:37:20",20] [...] format: [$date,count] now need add 3rd 4th value every array element, average of n counts before or after. example if n=3 the 3rd value should average of 3 count-values before , 4th value should average of 3 count-values after current array element. result that: ["2011-06-16 16:37:20",23.2, null, 34.13], ["2011-06-21 16:37:20",35.6, null, 29.86], ["2011-06-26 16:37:20",41.8, null, 28.06], ["2011-07-01 16:37:20",25, 33.53, 31.06], ["2011-07-06 16:37:20",22.8, 34.13, 30.13], ["2011-07-11 16:37:20",36.4, 29.86, null], ["2011-07-16 16:37:20",34, 28.06, null], ["2...

java - how do you add an item in a list if a user presses yes button in an alert dialog box and don't add it if he presses no -

i making app in if user selects submenu item pop alert dialog asks confirmation whether wishes save item in list , saves if presses yes , doesn't add if presses no. you can use show alert: alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage("are sure this?").setcancelable(false).setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dosomething(); dialog.cancel(); } }).setnegativebutton("no", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); alertdialog alert = builder.create(); alert.show();

function - Simplifying php code -

i'm working on revamping cms right now. currently, i'm trying minimize front end code make theming easier. display latest posts, code using: <?php $query = mysql_query("select * posts order id desc") or die(mysql_error()); while($row = mysql_fetch_array($query)) : ?> <h3><a href="?id=<?php echo $row['id'] ?>"><?php echo $row['title'] ?></a></h3> <?php endwhile; ?> what best way simplify front end user? i'm thinking using functions.php file not sure how that. there way make first 2 lines of php function , user have call function? here function use: function getposts() { $query = mysql_query("select * posts order id desc") or die(mysql_error()); $result = array(); while($row = mysql_fetch_object($query)) { $result[] = $row; } return $result; } and in template: <?php foreach(getposts() $post) : ?> <h3><a href=...

css - HTML textarea tag help required -

i have set default value in textarea. want when clicks on textarea default value disappears. whats html code that? <textarea onfocus="this.value = ''">this default value</textarea> this little piece of code responsible: onfocus="this.value = ''" basically when focus event fired, value of current field set empty string "" of course can make more complexe , make sure erase when element contains default message: <textarea id="myfield">this default value</textarea> javascript: var defaultmsg = "this default value"; document.getelementbyid("myfield").onfocus = function () { if (this.value == defaultmsg) { this.value = ""; } } document.getelementbyid("myfield").onblur = function () { if (this.value == "") { this.value = defaultmsg; } }

How to pass parameters from bash to php script? -

i have done a bash script run php script. works fine without parameters when add parameters (id , url), there errors: php deprecated: comments starting '#' deprecated in /etc/php5/cli/conf .d/mcrypt.ini on line 1 in unknown on line 0 not open input file: /var/www/dev/dbinsert/script/automatisation.php? id=1 i run php script bash this: php /var/www/dev/dbinsert/script/automatisation.php?id=19&url=http://bkjbezjnkelnkz.com call as: php /path/to/script/script.php -- 'id=19&url=http://bkjbezjnkelnkz.com' also, modify php script use parse_str() : parse_str($argv[1]); if index $_server['remote_addr'] isn't set. more advanced handling may need getopt() , parse_str() quick'n'dirty way working.

php - Youtbe API -- OAuth and RSA-SHA1 security certificate -

i want make file upload upload (uploaded) movie file youtube account. understanding, need youtube api key (which have) , send file google. i'm having problems. seem needing "rsa-sha1 security certificate" complete oauth registration. how such certificate? documentation can find on matter hard understand "api noob" me. thanks! i can appreciate difficulty learning oauth incantations. every time go through understand little bit better. here's google note generating rsa-sha1 certificates.

css - Issue with overflow in IE7 -

i'm having issue ie7 related overflow. http://www.photocrayze.com/photos on google chrome, firefox, or browser that's not ie7, layout works intended. tags (look @ photos 'city people' , 'kaleidoscopic') cut off @ edges , set half opacity. on mouseover, edges revealed , set full opacity. however, in ie7, when mouseover photo, div.photo-tags-inner expands , messes layout. i'm not sure how explain better... how can fix issue? also, seems setting opacity 0.5 doesn't work in ie8 (but works in ie7 , ie9 , other browsers)... zoom: 1; -ms-filter: progid:dximagetransform.microsoft.alpha(opacity=0.5); opacity: 0.5; filter: alpha(opacity=0.5); in css style .photo-browser tr td .photo-info .photo-tags { margin: 0.5em auto auto; opacity: 0.5; overflow: hidden; position: relative; width: 200px; } get rid of overflow hidden , should work. next time use firexfox's firebug play around styling teh desired output. notice horizontal scroll bar ...

javascript - Undefined ParentNode DOM error onmouseout -

how's it, [ here small page illustrating problem ] (problem appears in firefox) so have function onmouseout="regress(event, this)" tests if mouse actually got outside current element , of it's children. ( more details on why did , matter ). if mouse outside, want stop animation on button , reset timer (which did). , works. only doesn't. in firefox (tested v5.0) is. dom related error. parentnode of element triggered function "" , parent of "undefined" , error , code explodes. here's baffling part: error occurs when mouse goes off button area. there's case when onmouseout event gets triggered (for avoidance of i'm using function). onmouseout off child of button child of button. in case, parentnode works fine, going buttonchild button buttonparent blabla body , stops. my question is, why undefined error appear in 1 case , doesn't in other. mind there no errors in chrome or ie9. how can fix it? this baffles me. ...

Get a c++ object in QML and use it in javascript -

i'm making application in i'd call function qml in c++ source, , c++ function return me , object can use same properties in javascript part of qml. i've made connection , everything. i've tried send qvariantmap , tried use object in javascript, don't properties of object there 2 ways exporting qobject based types c++ qml: return standalone qobject directly property reader or q_invokable function. note, object returned property has c++ ownership, q_invokable-object has js ownership. can change default behaviour via http://doc.qt.nokia.com/4.7/qdeclarativeengine.html#setobjectownership . return array of qobjects. in case should use qobjectlist, qdeclarativepropertymap (not qvariantmap) or qabstractlistmodel.

c# - Using Android speech API in Windows -

i using visual studio 2010 experiment monodroid in c#. i'm aware android applications can run on windows using emulator. possible use android api in windows console application? use android speech recognizer without running in emulator on windows. no-- android api (partly) based on firmware designed run on particular hardware platform-- the emulator emulates platform @ hardware level, why api runs in emulator. the api won't run without emulator. the speech recognizer in android uses google web service of work, anyway. phone captures audio-- recognition happens on google servers.

osx - Installing oursql on Mac OS Lion successes but import in python fails. **Why?** -

i followed installation instructions installing oursql on mac os x. since sudo pip install oursql told me, couldn't find mysql_config (located locate mysql_config and) told find by sudo mysql_config=/usr/local/mysql-5.5.14-osx10.6-x86_64/bin/mysql_config pip install oursql i added terminal output @ bottom readability reasons. after fired python in terminal (on mac os lion python 2.7 now,...) , did >>> import oursql but python keeps telling me: >>> import oursql traceback (most recent call last): file "<stdin>", line 1, in <module> 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 what miss? suggestions? terminal output, of pip installation: downloading/unpacking oursql downloading oursql-0.9.2.tar.bz2 (113kb): 113kb downloaded running setup.py egg_info package...

math - C++ how to make simple sha256 generator with boost? -

i need simple string sha256 generator class. not want build big libraries openssl or cripto++ - want turn strings sha256. how create such class or it? like others have said, under impression hashing under sha256 not trivial enough implement subset of bigger coding project. if take @ wikipedia page sha-2 , notice pretty intense math. if actual encryption abstract (the math theory itself), can found here . if you're programmers emphasis not in security, want use else's tested , tried implementation. can find few here . let me know if helped. sorry couldn't answer question straight code or of nature.

jquery - Opera does not change the height of the page. Why? -

open http://188.232.30.182/ in opera one click left arrow (it possible , right, need 2 clicks) scrolling page bottom. why there blank space , how fix it? in other browsers, well probably issue opera. i checked firefox 5, ie 9 , google chrome 14. seems work out fine. try upgrading opera's version. check view/display options, manage size. probably addon interfering. so report bug , find out!

database - Is there a script to create Magento models? -

can provide script create magento models, supports external database connections (which connect other primary magento database)? sure. go here: http://www.magentocommerce.com/wiki/intelligent_model_wizard dustin oprea

codeigniter - Blank Page PHP Error from Old CogeIgniter Library -

i downloaded open source php invoicing program (bamboo) 2 years ago , used few quick invoices needed send. now when try access home page, blank. looked in log file , reads "exit signal segmentation fault". i attempted force php variable within url, typed 'http://localhost/bamboo/index.php?/login' , returned me page errors, namely deprecated function in codeigniter code. i've never had experience codeigniter, , i'm assuming need upgrade fix these errors, doesn't easy thought judging update page. can give me advice on how can break through error access old invoices? fyi, looks current codeigniter version have 1.7.1. try setting wamp / lamp test environment running old version of php (~4 or pre 5.3) test way, should work under old environment, fastest if worked before, work old dependencies.

Use SQL Server 2005 XML APIs to normalize an XML fragment -

i have (untyped) xml being stored in sql server 2005 need transform normalized structure. structure of document looks so: <wrapper> <parent /> <node /> <node /> <node /> <parent /> <node /> <node /> <node /> <wrapper> i want transform this: <wrapper> <parent> <node /> <node /> <node /> </parent> <parent> <node /> <node /> <node /> </parent> <wrapper> i can select xml out relational structure if need to, put problem there no attributes linking parent , child nodes together, order becomes issue when using set-based operations. how can use .nodes()/.value()/other sql server xml apis transform data? transformation needs run part of batch sql script extracting tool/language not reasonable option me. actually - following code works (grouping here may isn't optimal, anyway): declare @xml xml ...

c# - consuming web services - how to develop ui pulling results from many sources -

i´m looking books, tutorials or videos displaying best practices consuming webservices. main idea learn how manage user interface results pulled many sources (eg: ebay developer, yahoo shopping xml, etc) , displayed customers in list of results. many years ago website called www.mpire.com used work in way, displaying results on demand. i´m developing c#, razor, ef 4, sql server. in advance. here overview. can start searching more concepts on google. learn how connect various api's , retrieve data. can in controller considered best practice create c# api wrapper each of api's connecting to. application can use wrapper simplify , seperate concerns. many popular api's .net wrappers created , available on open source sites such codeplex or github. documentation each api place start. reference wrapper language working in or may have developed there own can download. once retrieving data, have consider if going store data in app or if going call api data. ...

Jquery & Rails 3: Run controller action from js file? -

i click div on page run number of javascript tasks, run action on controller. explain in greater detail: i have untitled.js file in have put bunch of jquery code : $(function(){ $('nav li').hover(function(){ $(this).addclass("bigger", 50); }, function(){ $(this).removeclass("bigger", 50); }); $('#notify').click(function(){ $('.notifications').show(); }); $('#notify').click(function(){ (some code run controller action) }); }); i run controller action called "run_tasks" on "users" controller when #notify button clicked, showing notifications class. can see in above code have jquery code showing .notifications sorted out, don't know put in "(some code run controller action)". provide information controller action, run tasks want run, doesn't redirect new page or anything. here basic format of users controller: class userscontroller < applicati...