Posts

Showing posts from July, 2015

associations - Get id form another table, rails -

i have table test having fields 'user_id' , 'post_id'. user_id fetch current_user.id , post_id post table. do: in test controller:- def create @user = current_user @test = test.new(params[:test]) @post = post.find(params[:id]) @test.post_id = @post.id @test.user_id = @user.id respond_to |format| @test.save format.html { redirect_to(:back, :notice => "successfull") } else format.html { render :action => "new" } end end in models, create association:- in test.rb: belongs_to :post in post.rb: has_many :test the view page is: = form_for @test, :validate => true |f| .span = f.text_field :email, :placeholder =>"email address" .span = f.label :name = f.text_field :name .span = f.submit "save" the user_id save post_id give error: called id nil, mistakenly 4 -- if wanted id of nil, use object_id how can resolve problem ? is standard mes

Install PostgreSQL with given admin password on Windows 7 -

i install postgresql part of custom application installer. there way install postgresql without asking user admin password, , provide custom admin password postgresql. later when application needs "admin" activities on postgresql db application knows password is. reason is, when user supply admin password postgresql during install time, user not remember 6 months down line when application needs admin functions on db, , user have supply password. thank you according official docs , can done --superpassword option when running installer in unattended mode. in general looking @ doing, need run in unattended mode anyway (from custom application's installer). additionally, find lot of other useful switches in doc. best of luck.

google cloud messaging - Pass Additional value to Android GCM onRegistered method -

i want pass additional value gcm onregistered method, because want check if user unregistered , want call gcmregistrar.register(registrationactivity.this, sender_id); , pass existing user id onregistered method. question how pass additional value can value in onregistered . package bd.org.basis.projectmanagement; import android.content.context; import android.content.intent; import android.util.log; import com.google.android.gcm.gcmbaseintentservice; import static bd.org.basis.projectmanagement.registrationactivity.sender_id;; public class gcmintentservice extends gcmbaseintentservice { public gcmintentservice() { super(sender_id); } @override protected void onerror(context context, string error) { // todo auto-generated method stub } @override protected void onmessage(context context, intent intent) { // todo auto-generated method stub log.e("onmessage", "see later"); string title=in

php - mysqli multiple where clause for two different variables -

i have users current latitude , longitude saved variables $latitude , $longitude . want data database echo out if latitude , longitude matches users current latitude , longitude. $con=mysqli_connect("localhost","db_username","password","db_dbname"); $stmt = $con->prepare('select * test geoloc1 = ? , geoloc2 = ?'); $stmt->bind_param('ss', $latitude, $longitude); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { ?> <div class="latlon"> <a><?php echo $row['geoloc1'] ?></a> </div> <?php } ?> yet im getting error fatal error: call undefined method mysqli_stmt::get_result() , can't seem solve why coming up! just quit unusable mysqli , use pdo, has 2 advantages: in neat , works. $dsn = "mysql:host=localhost;dbname=db_dbname;charset=utf8"; $opt = arra

c# - Entity Framework Code First without app.config -

i hope able me, because seems i'm totally stuck. for upcoming projects in our company we'd use entity framework 5 code first approach. played around little while , everytime try use ef our existing libraries, fail because seems ef heavily relies on existing app.config. in our company, have inhouse database library allows connect various data sources , database technologies taking advantages of mef (managed extensibility framework) database providers. have pass database settings, such host (or file), catalog, user credentials , database provider name, library looks appropriate plugin , returns me custom connection string or idbconnection. we'd use library ef because allows flexible database use change database @ runtime. so. saw typical dbcontext object takes no parameters in constructor. automatically looks appropriate connection string in app.config. don't such things changed default constructor take dbconnection object get's passed dbcontext base class.

c++ - Most efficient way to move row/column in 2D std::vector -

Image
i'm creating game application in c++. have map represented 2-dimensional std::vector of tile objects. i need update map player moves. server application row or column new part of global map, should placed in local client's map, example: in figure 1 there's local map before player moves. top row filled objects 1, center 2 , bottom 0. when player moves up, new top row filled objects 3 , others should go down, , previous bottom row should disappear. i can moving required objects in for loops, thinking if there's kind of algorithm in standard library or prefered many, efficient way achieve kind of modifications. edit: sorry didn't realize there difference between doing operation row , column, indeed there is. editted title, because need column too. you might want implement iterator , don't move elements of vectors @ all. define variable index of top row (on screen), use modulo operator iterate on rows (so 000 row should overwritten 333, ,

sql - SSIS Web service task, WSDL file not valid error -

i trying run ssis package web service task sql server job, failing below error message executed user: ukdbt91db05v\system. microsoft (r) sql server execute package utility version 10.50.2500.0 64-bit copyright (c) microsoft corporation 2010. rights reserved. started: 10:08:01 error: 2013-04-25 10:08:02.68 code: 0xc002f304 source: dad web service task description: error occurred following error message: "microsoft.sqlserver.dts.tasks.webservicetask.webservicetaskexception: input web services description language (wsdl) file not valid. @ microsoft.sqlserver.dts.tasks.webservicetask.webservicetaskutil..ctor(object connection, string downloadedwsdl) @ microsoft.sqlserver.dts.tasks.webservicetask.webservicetask.executethread()". end error dtexec: package execution returned dtser_failure (1). started: 10:08:01 finished: 10:08:02 elapsed: 1.014 seconds. package execution failed. step failed.

php - How to persist a form to a database, NOT entity, in Symfony2 -

i'm rebuilding web app using symfony2. want users update specific records have on our mysql database. however, users aren't confident computer users , don't way web application (in current form) works. therefore, ui/ux perspective, decided use 2 forms edit specific data instead of current 1 form users don't like. the mysql database table in question holds numerous fields of information, such personal details , other information relevant them. forms split reflect this, idea 1 form updates personal details, , 1 form updates rest, user doesn't have deal 1 long form. at moment though, when go use 1 form, error: the class 'symfony\component\form\form' not found in chain configured namespaces during form submission this error solved in question . however, it's left me problem. currently, because i've split form in two, i'm unable save data database. can overcome using 1 form, goes against wishes of users of database. furthermore, kno

php - Is there risk of unavailable sources in composer-based project? -

when putting php project composer, on installation / deployment, composer fetch dependencies original sources. this lead problems when deploying, when source (maybe temporarily) becomes unavailable. is there included mechanism keep @ least current, stable versions of dependencies able deploy current version other instances? right there no 1 click solution this, plan work on give more reliability.

mysql - Getting minimum value for three columns group by a single column in a single table -

i have single table , table structure this: unique_id vendor_name price1 price2 price3 code 1 vendor 1 0.0012 0.0014 0.0054 125 2 vendor 2 0.0015 0.0016 0.0050 125 3 vendor 3 0.0011 0.0019 0.0088 125 4 vendor 1 0.0025 0.0024 0.0034 126 5 vendor 2 0.0043 0.0019 0.0065 126 6 vendor 3 0.0019 0.0085 0.0082 126 i have fetch min price each price column group code. , expected output follows: code price1 price2 price3 vendor price1 vendor price 2 vendor price 3 125 0.0011 0.0014 0.0050 vendor3 vendor1 vendor 2 126 0.0019 0.0019 0.0034 vendor3 vendor2 vendor 1 so mysql query fetch records this? , have make quer

Kendo tooltip showing error in console -

i have written code kendo tooltip , showing error - uncaught typeerror: object [object object] has no method 'kendotooltip' it editable listview in kendowindow. here code <span style="float: right; margin-top: 4px;"> <a id="mortgage_add_row" href="#"><img src="<?php echo static_dir; ?>images/icon7.png" alt="" height="36" width="37"></a> <a id="mortgage_delete_row" href="#"><img src="<?php echo static_dir; ?>images/icon8.png" alt="" height="36" width="37"></a> <a id="mortgage_edit_row" class="k-edit" href="#"><img src="<?php echo static_dir; ?>images/icon9.png" alt="" height="36" width="37"></a> <a id="mortgage_save_row" class="k-insert&qu

c# - Add list of objects to List<List<Objects>> if not contain -

i have list<list<vertex>> , vertex has property id . need add list<vertex>> list, not duplicate lists. public void addcomponent(list<vertex> list) { list<list<vertex>> components = new list<list<vertex>>; //i need if (!components.contain(list)) components.add(list); } you like: public void addcomponent(list<vertex> list) { var isinlist = components.any(componentlist => { // check equality if (componentlist.count != list.count) return false; (var = 0; < componentlist.count; i++) { if (componentlist[i] != list[i]) return false; } return true; }); if (!isinlist) components.add(list); }

java - Hadoop produces only one output from reducer -

although know hadoop not used image processing, proof of concept, have been trying implement image processing using hadoop. in course of doing so, have implemented sobel edge detection algorithm use mapreduce model , run under hadoop. my program supposed take folder hdfs input , process files in folder , write output hdfs. however, considering single file input folder , writing single file output. here source code of files https://gist.github.com/ardahal/f0046e50e04fadc28a96 this going semi-automatic better nothing. let say, input directory is: /user/hadoop/inpur_dir/input_i.txt path pth = "/user/hadoop/inpur_dir/input_" for(int = 0; < number_of_image; i++){ fileinputformat.addinputpath(job, pth.suffix(i+".txt") ); } and here multiple output . better proposed before

javascript - Where is VLC browser plugin documentation? -

i don't having luck trying find it. information on wiki outdated, vlc javascript object has changed lot since wiki page written. google searching give me more updated of how current interface is. for example, wiki says document.video1.play() in demo page, browser says object not have such method. found in current interface play method moved child object named playlist. document.video1.playlist.play() works. i tried enumerate properties of javascript object reason not work playlist object has of methods interested in. if use method ( how enumerate properties of javascript object? , how display methods of object in javascript? ) enumerate properties playlist object 2 properties , no method name, including ones confirmed exists. tried in chrome , firefox. so far have confirmed following interface: vlc multimedia plugin (compatible totem 3.4.3) if main embeddable object called vlc in document (i don't video1) can access methods by: // don't need explain these,

r - More efficient strategy for which() or match() -

i have vector of positive , negative numbers vec<-c(seq(-100,-1), rep(0,20), seq(1,100)) the vector larger example, , takes on random set of values. have repetitively find number of negative numbers in vector... finding quite inefficient. since need find number of negative numbers, , vector sorted, need know index of first 0 or positive number (there may no 0s in actual random vectors). currently using code find length length(which(vec<0)) but forces r go through entire vector, since sorted, there no need. i use match(0, vec) but vector not have 0s so question is, there kind of match() function applies condition instead of finding specific value? or there more efficient way run which() code? thank you the solutions offered far imply creating logical(length(vec)) , doing full or partial scan on this. note, vector sorted. can exploit doing binary search. started thinking i'd super-clever , implement in c greater speed, had trouble debugging i

css - Using border-image properly -

i'm trying implement border-image property in div have created, leaf image ( http://imageshack.us/photo/my-images/703/leafy.png/ ) go around edge of div. i have attempted cannot leaves normal , seem overlap in corners, find border-image property confusing , frustrating, can point me in right direction! the code using here: jsfiddle.net/mqrd6/ and trying achieve (roughly) here: http://imageshack.us/a/img203/1029/concepto.png also know ie (as usual) doesn't support border-image property, there workaround this? using javascript or something? really appreciate :) you try this: http://jsfiddle.net/mqrd6/3/ the trick set width of border-image same border-width : #leaf { width: 760px; vertical-align: middle; border-width: 22px; border-image: url(http://img703.imageshack.us/img703/4976/leafy.png) 22 22 round; } no versions of ie supports border-image. give support in ie try css3pie , simple library allows use several css3 features in ie6 or

rtmp - jwPlayer 6 seeking to exact position -

is possible somehow jwplayer 6 seek exact position in video, regardless of keyframe interval? i acknowledge requires have go previous key frame , load there, want skip few seconds , start @ second specify. we're using wowza streaming. if response involves injecting keyframe @ position want - there tools can mp4-videos? e.g "promotetokeyframe videofile.mp4 12.0" you can use our api , jwplayer().seek(); seek available keyframes. api reference here, in case need - http://www.longtailvideo.com/support/jw-player/28851/javascript-api-reference

java - Fetching product details using eBay API -

i able structured data form of category hierarchy using getcategories() method of ebay's trading api . want product list of of categories of ebay site. best way of doing this. other api need use ? you can use finditemsbycategory call via finding api . pass 3 category ids , ebay search items belonging categories. in addition possible following call. filter results various fields such condition , price. sort results. use pagination split results across several pages. more information , examples can found in official ebay documentation .

ios - Load Large Data from multiple tables in parallel using multithreading -

i'm trying load data 10k records 6 different tables ultrlite db. i have created different functions 6 different tables. i have tried load these in parallel using nsinvokeoperations, nsoperations, gcd, subclassing nsoperation nothing working out. actually, loading 10k 1 table takes 4 sec, , 5 sec, if keep these 2 in queue taking 9 secs. means code not running in parallel. how improve performance problem? please me in this. thanks in advance. there may multiple ways of doing it. what suggest : set number of rows table view exact count (10k in case) table view optimised create few number of cells @ start(follows pull model). cellforrowatindexpath called few times @ start. have array , fetch 50 entries @ start. have counter variable. when user scrolls table view , count reaches after 50 fetch next 50 items(it take less time) , populate cells next 50 data. keep on doing same thing. hope works.

php - PDO SHOW TABLES array -

just working function , it's not working out planned. supposed grab table names in database , store them in array. results of array doubling array shown in example below: array ( [0] => 113340 ) array ( [0] => 113340 [1] => 116516 ) array ( [0] => 113340 [1] => 116516 [2] => 139431 ) array ( [0] => 113340 [1] => 116516 [2] => 139431 [3] => 20731 ) array ( [0] => 113340 [1] => 116516 [2] => 139431 [3] => 20731 ... ) the code using: function itemdiscontinued($dbh, $id, $detail) { try { $tablelist = array(); $result = $dbh->query("show tables"); while ($row = $result->fetch(pdo::fetch_num)) { $tablelist[] = $row[0]; print_r($tablelist); } } catch (pdoexception $e) { echo $e->getmessage(); } } to names of tables better public function list_tables() { $sql = 'show tables'; if($this->is_connected) { $query = $this->pdo->query($

javascript - Why the page is longer on Chrome? -

check page www.danielmalek.bugs3.com/oferta.html, on chrome can see bit long beam on left side not reaching end of site. on firefox , ie seems right, @ localhost chrome displays well. html code: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl"> <head> <title>strony internetowe - daniel małek</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link href="style.css" type="text/css" rel="stylesheet" /> <script language="javascript" type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function (){ /*$("body").css("overflow-y", "hidden");*/

java - What does "biased" mean in "Metrics" histogram -

one of properties codahale's "metrics" received "biased". can explain mean? public histogram newhistogram(class<?> klass, string name, boolean biased) creates new histogram , registers under given class , name. parameters: klass - class owns metric name - name of metric biased - whether or not histogram should biased returns: new histogram when in doubt, @ source: /** * uses exponentially decaying sample of 1028 elements, offers 99.9% confidence * level 5% margin of error assuming normal distribution, , alpha factor of * 0.015, heavily biases sample past 5 minutes of measurements. */ biased { @override public sample newsample() { return new exponentiallydecayingsample(default_sample_size, default_alpha); } }; a biased histogram 1 gives more weight more recent measurements.

javascript - Knockout.js use foreach to display object properties -

i have viewmodel load users , list of socialgraphs wcf services. users appear correct no socialgraph entry appears. have checked service , json returned , seems ok. should change models sth different or way i'm loading stuff in viewmodel? $(document).ready(function () { var viewmodel = { users: ko.observablearray([]), loadusers: function () { odata.read("service_userprofile/", function (data) { viewmodel.users.removeall(); $.each(data.results, function (index, item) { var socialgraphs = viewmodel.loadsocialgraph(); var user = new userprofilemodel(item, socialgraphs); viewmodel.users.push(user); }); }); }, loadsocialgraph: function () { var result = new array(); // user id loaded dynamically in later steps odata.read("/service_userprofile(1)/s

regex - How can i take src value from jquery zoom using regular expression in php -

i tried $content =file_get_contents("http://www.starplugins.com/cloudzoom"); preg_match('/<img[\s\s][^>]*src="([^"]*)"[^>]*id="zoom1"[^>]*>/',$content,$arr); print_r($arr); it returns empty array when take html part , tested rubular gives correct output.please figure out try this: /\<img.*?id\=["\']zoom1["\'].*?src\=["\'](.+?)["\'][\s]{0,}.*?\/{0,1}\>/ims if returns false, try this: /\<img.*?src\=["\'](.+?)["\'][\s]{0,}.*?id\=["\']zoom1["\'].*?\/{0,1}\>/ims . basically, regex highly dependent upon order of id , src. however, since dealing html here, better use dom/xpath instead.

jquery - Use handsontable with an existing table -

do know if can use hansontable jquery plugin table exists ? because in documentation, saw can create table handsontable : var data = [ ["", "kia", "nissan", "toyota", "honda"], ["2008", 10, 11, 12, 13], ["2009", 20, 11, 14, 13], ["2010", 30, 15, 12, 13] ]; var $container = $("#example1"); $container.handsontable({ data: data }); but wish : $("#montableau").handsontable(); in order give handsontable's feature table do have idea please ? workaround: var data = []; $('#montableau tr').each(function(index,el){ var rowdata = []; $(el).children().each(function(index,el){ rowdata.push($(el).html()); //or use text() if u prefer }); data.push(rowdata); }); el = $('#montableau').after('<div class="handsontable"></div>').next(); $('#montableau').remove(); el.handsontable({ dat

python - Export user data with django in django-admin to CSV -

i need export csv users of database, have more or less clear ( https://docs.djangoproject.com/en/dev/howto/outputting-csv/ ), need select fields exported previously. is possible, using model, show can select fields exported? from console, try >>> django.contrib.auth.models import user >>> open('myfile.csv', 'w') csv: ... user in user.objects.all(): ... d = '%s, %s, %s,\n' % (user.username, user.last_name, user.first_name) ... csv.write(d) where set d whichever fields want save. of course, pain if want several times - it's better idea create custom admin command .

python - finding wxpython event documentation -

how can find out functions , attributes of various events released wxpython? when bound function triggered event sent bound function e.g.: self.bind(wx.evt_button, self.eventbuttonfunction, self.button) ... def eventbuttonfunction(self,event): each widget (e.g. checkbox, togglebutton etc) has different set of attributes , functions. can't find information in docs , have been resorting using dir print them out so: def eventbuttonfunction(self,event): s in dir(event): print s which annoying. in docs somewhere missing? thanks the wxpython docs aren't complete underlying c++ wxwidgets docs, in many cases, you'll have use c++ docs, translating symbols of form wxfoo wx.foo . you're looking this list , list of event classes mapped macros apply, , each class hyperlinked class definition, although it's still not entirely complete. from memory, evt_button generates wxcommandevent , although if you're not sure event type you're

c# - Call parent page's method from a user control -

i have user control displayed popup. need call method parent page when user control dismissed user. how can that? i tried calling in 'unloaded' event of popup cannot access parent page's methods control... you can pass used instance of parent page popup. way, can access public methods parent page has.

Using ServiceStack.Text as JSON Serializer for SignalR -

to have consistent serialization across application layers, want use same serialization library (servicestack.text) signalr use everywhere else. while following signalr's wiki entry replacing used json serializer, created basic handler: public class signalrservicestackjsonserializer : ijsonserializer { public void serialize(object value, textwriter writer) { var selfserializer = value ijsonwritable; if (selfserializer != null) selfserializer.writejson(writer); else jsonserializer.serializetowriter(value, writer); } public object parse(textreader reader, type targettype) { return jsonserializer.deserializefromreader(reader, targettype); } } integration: var serializer = new signalrservicestackjsonserializer(); globalhost.dependencyresolver.register(typeof(ijsonserializer), () => serializer); unfortunately, after integrating it, signalr js client different packages default serializer. l

javascript - swtiching of tabs to change div content in html5 and jquery -

using ul li want create tab based switching , navigation structure <body> <header> <ul> <li>apples</li> <li>mangoes</li> </ul> </header> <section> <div class="left"> <ul> <li>left tab1</li> <li>left tab2</li> <li>left tab3</li> </ul> </div> <div class="right"> <ul> <li>apples content1 tab1</li> <li>apples content2 tab1</li> </ul> <ul> <li>mangoes content1 tab1</li> <li>mangoes content2 tab1</li> </ul> </div> </section> </body> apples , mangoes switching tabs on top , left tabs navigating tabs on left , right tabs show content. on top default apples in selected state , lefttab1 selected right part must show apples content1 tab1 , apples content2 tab2 if switch appl

animation - Move an SVG object along a line or a path -

i'd animate svg object follows svg path have built line generator in d3.js. there easy way achieve this? in particular, i'd obtain interpolated coordinates correspond path. there, easy perform animation using tween.js or d3.js itself. as far know, there's no way coordinates of interpolated svg path in d3, i.e. might have interpolation yourself. to animate svg object along path, don't need use d3 however. can use svg <animatemotion> element native svg animation -- see here example.

JPA Query with openJPA only works as 'native' SQL, but it does not when transformed as JPQL or with JPA Criteria -

i have sql query , mapping of classes. using openjpa, if query made @namednativequery works fine, returning correspondent class , expected result. if transformed jpql @namedquery returns noresultexception getsingleresult method. tried jpa criteria not working, @ least not in environments. cannot reproduce problem locally, occurs in test system. locally of approaches work ok. i think configuration problem, haven't found anything. sql: select * my_rel_table map map.type = ?1 , map.region_id = ?2 jpql: select m myrelationclass m m.type= :type , m.region = :region does have idea wrong? ibm openjpa, websphere 8.0 i cannot reproduce problem locally, occurs in test system. are connecting same database in both environments? if not, possible local database doesn't have correct data in it? you enable openjpa sql trace see jpql being translated to: openjpa.log=sql=trace also, set following property see parameter values : openjpa.connectionfactoryproper

Maven vs. Eclipse Project Facets for Java EE 6 -

i have created maven projects inside eclipse these archetypes: ejb-javaee6 webapp-javaee6 the projects created without facets. does make sense convert such maven projects faceted form? which facets helpful , ones cause trouble maven project? specifically: of following project facets in conflict in responsibility of maven? java javascript ejb module dynamic web module glassfish deployment descriptors files javaserver faces i have impression converting maven project faceted form mean mixing 2 worlds. therefore tend not enable project facets. but work have examples of maven projects in faceted form , wondering whether there might (risk-free) benefits it. eclipse facets , maven archetypes orthogonal - i.e. have no influence on each other, or rather no knowledge of each other. can safely add facets if facilitate work eclipse.

powershell - Activate-Feature : Error activating feature <featurename> at siteURl>The located assembly's manifest definition does not match the assembly reference -

error: activate-feature : error activating feature …<featurename>……… @ …<siteurl>……..the located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) issue has caused when using powershell script retract , deploy wsp solution, wsp deploys somehow failed activate feature event receiver starting services below: stop-service -name “spadminv4” start-spadminjob start-service -name spadminv4 waitforsolutiondeploymentjobtofinish $name note: have not found issue when fresh deployment instead retraction/deployment. works file when retract solution in separate script , deployment new powershell instance i have found following references while investigating: http://sisharepoint.wordpress.com/2010/03/26/getting-around-gac-problems-when-you-deploy-sharepoint-solutions-with-powershell/ http://blogs.msdn.com/b/briangre/archive/2011/02/17/sharepoint-2010-visual-studio-solution-deploy-deployment.aspx please guide me resolve issue

c# modify a generic property -

i have viewmodel 2 properties of same type (bool). have function sets 1 of properties bool value. let's have isreadonly property. public void setreadonly(myviewmodel vm, bool newval) { vm.isreadonly = newval; } now want make more generic, , have function both: public void setbooleanproperty(myviewmodel vm, bool newval, ?bool? myproperty) { vm.myproperty = newval; // sure error, myproperty doesn't exist in viewmodel. shows way have. } i started approach: public void setbooleanproperty<tprop>(myviewmodel vm, bool newval, tprop myproperty) { vm.??? = newval; } i don't use function getpropertybyname("isreadonly") think available somewhere in reflection classes .net. reason: if developer refactors project , renames isreadonly, string wouldn't updated. there solutiuon ? you're trying use reflection without using reflection. don't think you're going find answer. there no generics against properties in language

Set current location in the top half of the map in Android -

i paint current location on googlemap. showing half of map (the other half hidden under view, cannot change this). i want move camera center top half of map in current location, can me this? there way set x , y of view want show current location? i using google maps android api v2. the google.maps.map class has method called setcenter takes in google.maps.latlng parameter. method centers map on given latlng. using clever code, first use getcenter() method on map determine true center of map, average latitude of latlng latitude of top of viewport. give latitude of new center. longitude of new center remain same. set map new coordinate pair , problem solved. happy coding! routemapper

setTimeout, show and hide using jQuery -

i have large want display onload , have timeout display smaller image. onmouseover, using jquery slide in large image , on mouse slide out large image , slide in smaller image. here code have mouseover, mouseout function. need start large 1 displayed 5 seconds , slide smaller one.: <script type="text/javascript"> $(document).ready(function () { $(".expanded").show(); $(".collapsed").hide(); $(".collapsed").mouseover(function () { $(".collapsed").slideup(500); $(this).next(".expanded").slidetoggle(500); }); $(".expanded").mouseleave(function () { $(".expanded").slideup(500); $(".collapsed").slidedown(500); }); }); </script> i create global variable "readyforhovering" set false until timeout expires such as: var readyforhovering = false; $

ruby on rails - skip authentication for CKeditor? -

i using ckeditor in rails app. works pretty well, did not manage photo upload/brows/send server work ! i using cancan , getting cancan::authorizationnotperformed @ /pictures , after commenting out config.authorize_with :cancan in config/initializers/ckeditor.rb so thought uncommenting config.authorize_with :cancan , using skip_authorization_check , don't know use it! new rails. i pretty tried can ! any help/leads/tips please ? looking @ ckeditor/pictures_controller.rb of gem gives idea how solve issue. (use bundle open ckeditor root directory of app, navigate app/controller/ckeditor/ ) so, create ckeditor/pictures_controller.rb in rails app content: class ckeditor::picturescontroller < ckeditor::applicationcontroller load_and_authorize_resource def create @picture = ckeditor::picture.new respond_with_asset(@picture) end def destroy @picture.destroy respond_with(@picture, :location => pictures_path) end protected

Ruby on Rails SQlite 3 database query -

i have been looking online how queries ruby on rails , can find information how build query not put physical code. new ruby on rails. i have 1 database called story , has title , content columns made. have page used input title , content , stored database , have page displays contents of database not understand how query find let's say, "a record has content or title contains word or phrase" <%= @story.content %> so understand displays content on screen, same thing queries? in rails active records used not direct sql queries here's link explains ...... http://guides.rubyonrails.org/active_record_querying.html for example lets have post model , want index posts use @posts = post.all you want show specific post ,find id @post = post.find(params[:id]) create new post @post = post.new

c# - Collection modified during foreach error -

i know can't modify collection during foreach , should able set variable values of underlying iterator through it. reason method below, every time executes giving "collection modified..." error: private static iinstrument adjustforsimpleinstrument(datetime valuedate, iinstrument temp) { var instr = temp; foreach (var component in instr.components) { component.schedule.schedulerows.removeall( sr => ((sr.payment != null) && (sr.payment.paymentdate != null) && (sr.payment.paymentdate.adjusteddate.date <= valuedate.date))); if ( !component.scheduleinputs.scheduletype.in(componenttype.floating, componenttype.floatingleg, componenttype.cap, componenttype.floor)) continue; foreach (var row in component.schedule.schedulerows) { var clearrate = false; if (row.payment.comp

c# - SSIS Script Vague Error "Object Refrence not set to an instance of an object" -

i'm working on ssis script, , going through visual studio, when execute get: [ftp script task] error: error: object reference not set instance of object. here's code running. doing wrong? public void main() { try { // ftp connection connection managers collection connectionmanager ftpserver = dts.connections["sftp_connection"]; // create ftp connection object , credentials of connection manager ftpclientconnection sftp_connection = new ftpclientconnection(ftpserver.acquireconnection(null)); // open connection sftp_connection.connect(); // set work folder value of variable sftp_connection.setworkingdirectory(dts.variables["ftpworkingdirectory"].value.tostring()); // create stringarrays

Is it possible, in R parallel::mcparallel, to limit the number of cores used at any one time? -

in r, mcparallel() function in parallel package forks off new task worker each time called. if machine has n (physical) cores, , fork off 2n tasks, example, each core starts off running 2 tasks, not desirable. rather able start running n tasks on n workers, , then, each tasks finishes, submit next task now-available core. there easy way this? my tasks take different amounts of time, not option fork off tasks serial in batches of n. there might workarounds, such checking number of active cores , submitting new tasks when become free, know of simple solution? i have tried setting cl <- makeforkcluster(nnodes=n) , indeed set n cores going, these not used mcparallel() . indeed, there appears no way feed cl mcparallel() . latter has option mc.affinity , it's unclear how use , doesn't seem want anyway (and according documentation functionality machine dependent). i'd suggest taking advantage of higher level functions in parallel include functionality instea

php - Separate multidimentional array into separate arrays -

i trying head around arrays. the arrays should this: $questions[$a] => array( [0] => no, comment1 [1] => yes, comment2 [2] => no, comment3 ) $answer[$a] => array( [0] => no [1] => yes [3] => no ) $comment[$a] => array( [0] => comment1 [1] => comment2 [3] => comment3 ) ========================================================================= second edit: need execute in loop create third array - if($answer[$a] == "yes") { $display[$a] = "style='display:none'"; } else { $display[$a] = "style='display:block'"; } this have: (28th minitech) while ($a > $count) { if($count > 11) { foreach($questions $q) { list($answer, $comments[]) = explode(',', $q); if($answer === "yes") { $display[$a] = "style='display:n

eclipse gef - gef : change child constraint to a new parent -

i have somme process elements can contain other process elements no limit. i managed addition of new process other directly palette, works right when drag process drawn integrate new child of process drawn, editor don't let me , have white cross cursor. in model process class extending containerelement class wich handles addition , removal of children , notification stuff. i thinking since process have new parent must add in change constraintcommand here's snippet of code public class processfigure extends figure { public processfigure() { setlayoutmanager(new xylayout()); ellipse = new ellipse(); ellipse.setfill(false); add(ellipse); label = new label(); add(label); ellipse.setlayoutmanager(new xylayout()); } public ifigure getcontentpane() { return ellipse; } ... } ------------------------------ public class processeditpart extends containerelementeditpart { ... public ifigure getcontentpane() {