Posts

Showing posts from May, 2012

java - How to highlight current line of execution in debug perspective in Eclipse -

i using eclipse ganymede 3.4.2. see current execution line highlighted in green arrow @ left in eclipse debug perspective. unfortunately dont know how set it. have seen in eclipse platform , wondering if can set display. please help. in debug perspective, double click left of line set break point. once break point set, can highlight running code line line. update : if doesn't work expected, check preferences here : window > preferences > general > editors > text editors > annotations > debug call stack , debug current instruction pointer

performance - iOS app freezes when changing CLLocationManager accuracy, returning from background state -

i'm using cllocationmanager instance, while running in background. to save device power, interchange between kcllocationaccuracythreekilometers , kcllocationaccuracybest when restore app running background, cllocationmanager instance activates kcllocationaccuracybest , if it's not using accuracy. however, there seems some kind of freezing 2~3 seconds , not responding user interaction. if i'm not wrong in analysis, changing accuracy of cllocationmanager instance seems main cause . can explain limitations should aware of, when changing cllocationmanager accuracies? and, have kind of solution issue?

c++ - Is it a good thing that the top items in my programs profile are _Unwind_SjLj_Unregister and _Unwind_SjLj_Register? -

as follow this question, thing top 2 things still exception handlers? on 1 hand, doing lot of exceptions. on other, in sdl, meaning optimized possible, means other functions fast. so... here's top of profile of program after running around 64 seconds, after did optimization flat profile: each sample counts 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 8.32 3.39 3.39 _unwind_sjlj_register 6.77 6.15 2.76 _unwind_sjlj_unregister 6.28 8.71 2.56 4000006 0.00 0.00 cast128::setkey(std::string) 3.73 10.23 1.52 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() 3.61 11.70 1.47 __dynamic_cast 3.56 13.15 1.45 64000080 0.00 0.00 cast128::f(int...

data binding - Silverlight Parent Usercontrol Resources access -

a simple question it's possibile usercontrol, view (directly in xaml) parent resources? for example e usercontrol contains <usercontrol.resources> <viewmodel:exampleresource x:key="exampleresourcex1"></viewmodel:exampleresourcex> </usercontrol.resources> and usercontrol inside him, need reference , bind exampleresourcex1 staticresource it's possible? thanks it possible? static resources can defined @ level , visible below level using static resource binding. we put our converters app.xaml instead of in pages can seen app-wide.

doctrine2 - How can I add a related entity to a user object at the point of creation in FOSUserBundle? -

in symfony2 rc3, trying create related entity on user object (fosuserbundle) @ point of user creation can display appropriate fields on edit profile form. doing following in registrationformhandler. class registrationformhandler { protected $request; protected $usermanager; protected $form; public function __construct(form $form, request $request, usermanagerinterface $usermanager) { $this->form = $form; $this->request = $request; $this->usermanager = $usermanager; } public function process($confirmation = null) { $user = $this->usermanager->createuser(); $this->form->setdata($user); if ('post' == $this->request->getmethod()) { $this->form->bindrequest($this->request); if ($this->form->isvalid()) { if (true === $confirmation) { $user->setenabled(false); } else if (false === $confirmation) { $user->setconfirmationt...

ruby - Scope of private, protected, and public -

within ruby class definition, scopes of private keyword in following scenarios: class foo def bar_public puts "public" end private def bar_private puts "private" end def bar_public_2 puts "another public" end end does private act on bar_private? or on bar_public_2 well? in case both bar_private , bar_public_2 private. that because both methods "within scope" of private keyword. > f = foo.new #<foo:0xf1c770> > foo.new.bar_private nomethoderror: private method 'bar_private' called #<foo:0xf1c770> > foo.new.bar_public_2 nomethoderror: private method 'bar_public_2' called #<foo:0xf1c770> either way, best way answer question open irb , try out ;-)

android - Relative Layouts and Linear Layouts -

how embed tab layout within button. main layout linear layout, don't know how program main activity.java class. me started main.java code looks right now import android.app.activity; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.content.intent; public class remote_docactivity extends activity implements onclicklistener { /** called when activity first created. */ //private static final string tag = "remote_doc"; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); view patient_button = findviewbyid(r.id.patientbutton); patient_button.setonclicklistener(this); view doctor_button = findviewbyid(r.id.doctorbutton); doctor_button.setonclicklistener(this); view about_option = findviewbyid(r.id.aboutbutton); about_option.setonclickliste...

PHP Regex to convert text before colon to link -

i need find first occurance of colon ':' , take complete string before , append link. e.g. username: @twitter nice site! rt www.google.com : visited! needs converted to: <a href="http://twitter.com/username">username</a>: nice site! rt www.google.com : visited! i've got following regex converts string @twitter clickable url: e.g. $description = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $description); any ideas : ) i'd use string manipulation this, rather regex, using strstr , substr , strlen : $username = strstr($description, ':', true); $description = '<a href="http://twitter.com/' . $username . '">' . $username . '</a>' . substr($description, strlen($username));

iphone - reload TableView when the app comeback from a modalView -

basically problem... can't reload data of table view when comeback modal view. i try reload data table view result not effects. any idea? please... your main view controller viewwillappear call when modal view dismissed (or other reason view appear). implement call reloaddata on table @ point, so: - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; [self.tableview reloaddata]; }

is there an attractively themed Drupal app (kinda like Joomla) with at least hello-world implementation of lots of hooks for learning purposes? -

joomla looks pretty out of box. drupal looks ugly out of box , not anything, except admin tasks. is there chance n00b-friendly drupal app pretty (kind of joomla out of box) , use whole bunch of hooks see them in action in relatively big app? eta: ok, let me ask more specific question same area. there drupal distro/app have same basic functionality , look-and-feel out of box joomla? while might not know enough functionality , look-and-feel perfect n00bs, popularity of joomla suggests can thought of decent first approximation. conversely, widespread n00b unhappiness out of box drupal suggests it's not approximation @ all. what customized drupal distribution? managing news open atrium open publish pressflow if don't how drupal looks, install new theme .

javascript - How do I get the sidebar to move up -

i have page , want sidebar slide down user , works if on small screen 1024 * 768 not see bottom. here of code used make sidebar work. suggestions on how can change behavior. $(window).scroll(function(){ sidebar_position(); }); $(window).resize(function(){ sidebar_position(); }); function sidebar_position(){ var w_width = ($(window).width() -1000) /2; $('#sidebar').css('left', w_width); var sidebar_height = $('#sidebar').outerheight(); var content_height = $('#widecolumn').outerheight(); var w_height = $(window).height(); if ( sidebar_height > w_height) { $('#sidebar').css('position', 'absolute'); } else { $('#sidebar').css('position', 'fixed'); }; if (sidebar_height > content_height) { content_height = sidebar_height; $('#widecolumn').css('min-height', content_height); }; if($.browser.ms...

c# - Using a SSH library to connect to unix and tail a file: Is this the right approach? -

as ive stated few other questions, ive been using new ssh .net library connect unix server , run various scripts , commands. well, i've attempted use run unix tail -f on live log file , display tail in winforms richtextbox. since library not fully-fleshed out, kinda-sorta solution i've come seems lacking... feeling when know there has better way. have connection/tailing code in separate thread avoid ui thread lock-ups. thread supports cancellation request (which allow connection gracefully exit, way ensure process unix side killed). here's code far (which record seems work, thoughts on if right way go it): passwordconnectioninfo connectioninfo = new passwordconnectioninfo(lineip, username, password); string command = "cd /logs; tail -f " + buildfilename() + " \r\n"; using (var ssh = new sshclient(connectioninfo)) { ssh.connect(); var output = new memorystream(); var shell = ssh.createshell(encoding.ascii, command, output, outp...

php - Zend: HTTP Error 500 -

i have 1 zend project developed on server (where works fine), when transferred production server keep getting internal server error message , website won't work. what can't understand admin part (www.mysite.com/admin) works fine, when try access website (www.mysite.com) interrupts. i know long shot, have suggestion start searching cause of problem? up knowledge 500 error generated when web server not answer scripting engine in time, php in case of zend. interesting know if receive error or after time. if takes time application may hanging in loop.

regex - Using powershell to delete the middle of a string -

i have text file contains text data collate unknown null, or data collate unknown not null, i need delete collate , unknown text file, i'm thinking -replace form of regex way go in way shape or form, can't figure out how keep null or not null. also note every line in file not contain collate , unknown i suppose unknown placeholder number of characters? then try $result = $subject -creplace 'data collate .*?((?:not )?null,)', 'data $1'

jquery - Why do my fields not populate with current value on JQGrid Inline Edit? -

i using jqgrid throughout application. on 2 screens inline edit, works fine. if field has value, puts value textbox when goes edit mode. on 1 grid, not happening, , fields go blank when edit mode activated. does know why happening? the code bit much, i'll post if requests it. now, have thoughts why it's happening? thanks! edit - code: the defaults called first, init @ bottom kicks off rest. let me know if more needed. here setdefaults call: $.extend($.jgrid.defaults, { datatype: 'json', height: "100%", loadui: 'none', images: "/css/redmond/images/", jsonreader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, userdata: "userdata", id: "id" }, ...

android - Allow User to Click on Advertisement to Unlock Features -

is reasonable give user option either purchase full version or click on advertisement unlock feature in application. understanding, admob pays based on clicks, not impressions. possible listen ad clicks in android? from admob terms of use available here if user publisher, user shall not, , shall not authorize or encourage third party generate fraudulent impressions of or fraudulent clicks on advertisement, you should not ask users click on advertisement. it's against terms of service.

objective c - link redeclared as different kind of symbol in -

i have objective-c program, added little lib linked list in plain c. header: typedef struct { int v; int w; } edge; edge edge(int, int); typedef enum tagtiponodo { k_casellapolozia, k_casellakiller } tiponodo; typedef struct node *link; struct node { int v; link next; }; typedef struct node2v *link2v; struct node2v { int v; int val; link2v next; }; link2v new2v(int v, int val, link2v next); void del2v(int v, link2v *lista); void update2v(int v, int val, link2v lista); link sort2x(link2v lista); link sort2xdecr(link2v lista); int maxinlist(link2v lista); struct graph { int v; int e; link *adj; int *tipo;}; typedef struct graph *graph; graph graphinit(int); void graphinserte(graph, edge); void graphremovee(graph, edge); int graphedges(edge [], graph g); graph graphcopy(graph); void graphdestroy(graph); void graphshow(graph g); void ingr(); link nodeindistance(graph g, int a, int distance); link nodeindistanceoftype(graph g, int a, int distance, tiponodo tipo...

php - Is there any way to receive an image file through Flex's HttpService? -

i've written piece of code use php script send data flex . here's flex code: <s:httpservice id="imageservice" url="http://localhost/bookview/amfphp/services/imageserver/showimage.php" useproxy="false" method="post" result="handleimageresult(event)" fault="handlefault(event)" showbusycursor="true"> <s:request xmlns=""> <bdla>"lashf"</bdla> </s:request> </s:httpservice> here's php code: public function returnrandomimage(){ $contents = file_get_contents("images/code_complete2.png"); header('content-type: image/png'); return $contents; } thing is: i'm interested in using php send image file, render , use in flex. however, when .send() h...

drag and drop - jquery draggable and mouseover -

i have dropdown menus open on mouse over. i'm implementing drag-n-drop features using draggable , droppable jquery ui. seems mouseover events menus not fire when dragging, there way allow them work? i've implemented follows (simplified): $('#some_id').draggable({ helper: 'clone', opacity: 0.35, zindex: 20000, cursor: 'move' }); $('#some_menu').live('mouseenter click', function(){jthis.find('div').addclass('opened');}); i found out logical problem. once start dragging element, sticks under mouse pointer.. hence, it'll hover on current element time!! a (not pretty) fix set cursorat option mouse pointer outside of draggable element: $('#some_id').draggable({ cursorat: {left: -10, top: -10} }); it nicer if there way somehow pass mouse pointer underneath element being dragged, far haven't found solution that. hope helps bit!

java - GWT - server side - how to add external lib right to war file with eclipse -

i have tried add external jar eclipse project , works in "run -> gwt application" mode only. when deploy tomcat external jar missing in exported war file :( please tell me how can add external lib gwt project have added automatically exported war file (servlets use it)? any useful comments appreciated add file war/web-inf/lib folder. can drag file folder. add file build path right clicking on project -> properties -> build path -> libraries tab.

Iterating with .each through jQuery ajax json is not working in IE -

i'm using following code create divs "random" products. json data received php this: {"new":[{"product_id":"50",...},...], "best":[{"product_id":"26",...},...], ...} "new" products must go <div id="new"> , "best" "best" , on. code: $.ajax({ url: "/index.php?ajaxrequest&action=5", datatype: "json", error: function (xhr, status, errorthrown) { alert(errorthrown + '\n' + status + '\n' + xhr.statustext); }, success: function (data) { $.each(data, function (key, value) { var new_str = '<ul>'; $(value.sort(function () { return 0.5 - math.random() }).slice(0, 3)).each(function () { new_str += '<li><a href="' + this.link + '" class="right_sidebar">'; ...

Android obfuscate app using proguard keeps obfuscating library jars - or is it? -

i'm new using proguard i'm making newbie mistake. i've got app after run release build (which uses proguard obfuscate) crashes pretty quickly. believe i've narrowed down fact seems obfuscating reference libraries. in case reference libraries used define message classes using communicate device using google protobuffers. building using, ant release. proguard config is: -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -keep public class * extends android.app.activity -keep public class * extends android.app.application -keep public class * extends android.app.service -keep public class * extends android.content.broadcastreceiver -keep public class * extends android.content.contentprovider -keep public class * extends android.app.backup.backupagenthelper -keep public class * extends android.preference.preference -keep public class co...

Named arguments and generic type inference in C# 4.0 -

i had been programming under assumption that, when calling method in c# 4.0, supplying names arguments not affect outcome unless in doing "skipping" 1 or more optional parameters. so bit surprised discover following behavior: given method takes func<t> , executes , returns result: public static t f<t>(func<t> f) { return f(); } and method above method visible: static void main() { string s; calling f (without named arguments) compiles without issues: s = f<string>(() => "hello world"); // explicit type argument <string> s = f(() => "hello world"); // type inference and when using named argument... s = f<string>(f: () => "hello world"); ... above line of code using explicit type argument still compiles without issues. , maybe not surprisingly, if have resharper installed suggest "type argument specification redundant". however, when removing type a...

java - Click on JTable Model Updates JTextfield -

i have jtable custom abstract table model , select row in table , information appear in textboxes left. happen automatically out use use of buttons. approach can think of involves button. table model looks this: public class admintablemodel extends abstracttablemodel { private arraylist<contestant> contestants; private string[] columns={"first name", "last name", "entry"}; public admintablemodel(arraylist<contestant> contestants) { this.contestants = contestants; } public admintablemodel(list l) { contestants.addall(l); } public int getrowcount() { return contestants.size(); } public int getcolumncount() { return columns.length; } public string getcolumnname(int col) { return columns[col]; } public object getvalueat(int row, int col) { contestant contestant = contestants.get(row); switch(col){ case 0: return contestant.getfirst_name(); case 1: return contestant.getl...

binary - How to reverse this php code "pack("L", 1000);"? -

i have code this: echo bin2hex( pack( "l", 1000 ) ); which prints: e8030000 now, having e8030000 , how can reverse int 1000 ? update: found answer: unpack( "l", ( pack( "h*", 'e8030000' ) ) ); answer: unpack( "l", ( pack( "h*", 'e8030000' ) ) );

opengl - Is double buffering needed any more -

as today's cards seem keep list of render commands , flush on call glflush or glfinish , double buffering needed more? opengl game developing on linux (ati mobility radeon card) sdl/opengl flickers less when sdl_gl_swapbuffers() replaced glfinish() , sdl_gl_setattribute(sdl_gl_doublebuffer,0) in init code. particular case of card or such things on cards? edit: i've discovered cause kwin. appears datenwolf said, compositing without sync cause. when switched off kwin compositing, game works fine without source code patches double buffering , glfinish 2 different things. glfinish blocks program, until drawing operations completed. double buffering used hide rendering process user. without double buffering, each , every single drawing operation become visible immediately, assuming display refresh frequency infinitely high. in practice display artifacts, parts of scene visible in 1 state, rest not visible or in other state, picture incomplete, etc. double bu...

vb.net - Open and edit DWG file without AutoCAD -

i trying open dwg file in vb.net forms without opening autocad. however, problem occurs: the specified module not found. (exception hresult: 0x8007007e) i want edit image in dwg file, i.e. factory layout, , store information object used in layout figure out best possible way reach source destination. this factory layout map input robot move according path available. can help? how should proceed? use teigha or special program (i don't remember name) autocad developers open dwg file.

ios - Reverb effect in iPhone app -

can please give pointers how can add re verb effect recording in iphone app? vocal live free on app store pretty example of how want include reverb effect. core audio overview in ios documentation references reverb audio unit. any beyond helpful. yoy can use objectal library. see link below https://github.com/kstenerud/objectal-for-iphone .

How can I declare a variable outside of a block when the variable defines an anonymous class in C# -

i have following code , works good: var _data = (from qu in _que.getall( u => u.company == "ge" ) select new { qu.name, qu.address }); the signature of getall method icollection<t> getall(expression<func<t, bool>> predicate); now need enclose above in block becomes: { var _data = (from qu in _que.getall( u => u.company == "ge" ) select new { qu.name, qu.address }); } var _abc = _data; <<< doesn't work once _data becomes local , can't access outside block. assume need declare _data outside of block. declare type that's returned , placed _data anonymous type. there way can declare _data without having change query or make return type? your question unclear, think understand it, about. try avoid requiring this, can like: // i'm assuming name , address strings var _data = enumerable.repeat(new { name = "", address = "" }, 0); ...

c++ - Problem on my binary tree class' nodes -

i'm trying code class binary tree representation. each node has value ( key ), index , , node* pointer parent( p ), left-child( left ) , right-child( right ). problem on pointers. it's easier giving example problem explaining. i coded print() function prints out each node in tree. here class header file. , here main test file. the problem is, when call t.print() , prints 10, 5 , 7. the problem you're using vector , internally (re-)allocates storage needed. so, when pushing vector, whole internal data copied other memory location - making pointers still point old locations invalid. an easy "fix" reserve amount of space vector, can @ least store amount of nodes in without re-allocation. for example adding @ start of rootedtree constructors : t.reserve(64); note that not robust solution (if try put more 64 nodes in vector, you're still have same problem) - it'll confirm above analysis.

java - performance is slow with hibernate and MS sql server -

i'm using hibernate , db sqlserver. sql server differentiates it's data types support unicode ones support ascii. example, character data types support unicode nchar, nvarchar, longnvarchar ascii counter parts char, varchar , longvarchar respectively. default, microsoft’s jdbc drivers send strings in unicode format sql server, irrespective of whether datatype of corresponding column defined in sql server supports unicode or not. in case data types of columns support unicode, smooth. but, in cases data types of columns not support unicode, serious performance issues arise during data fetches. sql server tries convert non-unicode datatypes in table unicode datatypes before doing comparison. moreover, if index exists on non-unicode column, ignored. lead whole table scan during data fetch, thereby slowing down search queries drastically. the solution used ,we figured there property called sendstringparametersasunicode helps in getting rid of unicode conversion. property defa...

How do I set jquery pagination show page 1 on load -

i'd set page 1 show first when load page using pagination link jquery pagination reading documentation: https://github.com/gbirke/jquery_pagination#readme it seems plugin has option named : current_page :- page selected when pagination initialized. default: 0 so think like: $("#news-pagination").pagination(122, { items_per_page:20, callback:handlepaginationclick, current_page : 1 }); hth :)

PHP Imagick resize with black background -

i writing php script using imagick extension. want script take image user uploads, , create 200x128 thumbnail out of it. that's not thing. obviously, not images fit aspect ratio of 200x128. want script fill in gaps black background. right now, image resizes, there no black background , size isn't correct. basically, image should 200x128. resized image go in center, , rest of contents filled black. any ideas? here's code: function portfolio_image_search_resize($image) { // check if imagick loaded. if not, return false. if(!extension_loaded('imagick')) { return false; } // set dimensions of search result thumbnail $search_thumb_width = 200; $search_thumb_height = 128; // instantiate class. then, read image. $im = new imagick(); $im->readimage($image); // obtain image height , width $image_height = $im->getimageheight(); $image_width = $im->getimagewidth(); // determine if picture portrait or l...

iphone - Convert UIImage into bytes -

i getting uiimage using uiimagepickercontroller. how can calculate number of bytes hold image in kb/mb ? using values have make logic user cant add images more size of 1mb sure can. convert uiimage nsdata object, has length property, give size in bytes. can calculate size in whatever unit need. so example: uiimage *img = [uiimage imagenamed:@"some.png"]; nsdata *dataobj = uiimagejpegrepresentation(img, 1.0); int bytes = [dataobj length]; //convert whatever unit need

sql server - how to export records/data from one database table to another database table? -

how export records 1 database table , import database table? (same table structure). if table have exact same structure, , no autogenerated fields can use: insert destinationtable select * sourcetable you can use the select * destinationtable sourcetable syntax, create , fill destination table on fly.

php - Detecting direct changes in MySQL through -

i have php application talks mysql. application connects mysql using username , password. makes changes mysql database through application can username logged , can later audited. however, need operations backend , ie directly database. want know is possible log information users logging db directly( using phpmyadmin ) , making changes specific tables , how information can viewed later ? further, possible if changes made specific tables directly through backend triggers fired if same changes made front end, ie using php application , these triggers not fired ? -thanks in advance yes, can log changes made database setting lots of triggers on tables need track. can use mysql's user() function current user name. using mentioned user() function can determine, whether need log activity or not (i presume using different users in php scripts , in phpmyadmin)

To retrieve contact list with number in android -

hi want retrieve name , numbers contact list in android ,am using following code, give me name not number gives null value number note : using android emulator public void demo(){ string phonenumber; string [] item = new string[]{ people._id, people.name, people.number}; cursor cur = getcontentresolver().query(people.content_uri ,item , null, null, null); int phonenumberindex = cur.getcolumnindexorthrow(people.number); if (cur != null) { log.v("cur not null", "cursor not null"); if (cur.movetonext()) { log.v("movetonext", "moved first"); log.v("movetonext", "cursor moved first , checking"); phonenumber = cur.getstring(phonenumberindex); system.out.println("****** from_number "+phonenumber +" *****************"); } } } it gives null because u r trying retrieve 1 numbe...

java - Ant foreach avoiding empty variables -

i have following line in build.xml file: <foreach list="${clients}" delimiter="," target="clean other hosts" param="client.string"/> however, if ${clients} empty (it contains maybe new-line character, because read file), calls target once. is there workaround, prevent happen (the calling of loop)? technically, task correct, because "".split(",") equals {""} . can work around problem wrapping task <if> task : untested: <if> <not><equals arg1="${clients}" arg2="" /></not> <then> <foreach list="${clients}" delimiter="," target="clean other hosts" param="client.string"/> </then> </if>

c# - How to test MVC actions with Code First? -

i'm trying test mvc actions, created irepository , mockrepository public class repository : dbcontext, irepository { public idbset<tentity> someentities { get; set; } } public interface irepository : idisposable { idbset<tentity> someentities { get; set; } int savechanges(); } with create , delete actions simple, stuck edit action : private irepository repository; public actionresult edit(tentity entity) { if (modelstate.isvalid) { repository.entry(entity).state = entitystate.modified; repository.savechanges(); return redirecttoaction("index"); } return view(entity); } so see 2 ways solve problem: should add irepository new method dbentityentry<tentity> entry<tentity>(tentity entity) tentity : class; how this? dbcontext.entry method returns specific dbentityentry<tentity> type? or change way update entity? recommended ...

How to add plone group members from script -

i tried add plone user script ran "./bin/instance run myscript.py" ipdb>app.plone.portal_groups.addprincipaltogroup('newuser', 'administrators') true but when check web interface user not added group. although ipdb>app.plone.portal_groups.getgroupmembers('administrators') ['newuser'] says otherwise. when run same code in normal plone instance (by opening console http://localhost:8080/plone/ipdb ) works. do have commit changes made zodb or that? you need commit transaction after doing changes import transaction # things transaction.commit()

ruby on rails - 'Company' and 'Person': threat them similar... but gives problems when creating forms -

our company can have contract person , company. so responsible 'party' of contract, can both person , company. i have setup model where: --- contract ------ person | -- company class contract < activerecord::base belongs_to :party, :polymorphic => true end class party < activerecord::base self.abstract_class = true has_many :contracts, :as => :party end class organization < party end class person < party end --- what want able have form "new contract" , in field "contract with" i'd have dropdown box of known people , companies. --- in end: i'm willing change model , ideas... behaviour should remain contract can closed both person , company. suggestion welcome! you fill select values string containing both class , id (i.e. ), process in either model or controller.

zend framework - Facing issue when search using Zend_Lucene -

i using zend_lucene search functionality.i 've following code, $doc->addfield(zend_search_lucene_field::text('categoryname', $result->name)); here name in " $result->name " varchar type in database. have following values dinesh,kumar123,3333 . testing purpose have stored number in name field. when search dinesh , search comes exact result when use number search, 3333 search has no result. done wrong on code zend_search_lucene_field::text . is there way search number/char/alphanumeric (kumar123) ? thanks in advance finally found declaring " zend_search_lucene_analysis_analyzer::setdefault(new zend_search_lucene_analysis_analyzer_common_textnum_caseinsensitive()); " , use zend_search_lucene_field::keyword instead of zend_search_lucene_field::text

ios - How do you build a 3 column layout of varying height images for the iphone -

i need create screen scrolls vertically - tableview need 3 columns , within 3 columns need add images of varying height - not fit rows tableview can provide. should create 3 tableviews , lay them out side side - or else. think build positioning images using coordinates wanted benefit methods table view can provide. if want columns act stuck together, scroll simultaneously, think best approach use uiscrollview images added in correct placed "by hand." uitableview , friends not built handle non-lined columns. added if use uiscrollview , , have large number of images want display (that is, user can scroll long time), wise recycle uiimageview objects scrolled off screen. uitableview uitableviewcell objects, , that's why uitableview wins. can win, too, if code carefully.

iphone - NSString is NULL -

hiiii freinds please guys me why str null creasy nsstring *strdata = @"issam bey" ; nsmutabledata *objnsdata = [nsmutabledata datawithdata:[strdata datausingencoding:nsisolatin1stringencoding]]; objnsdata = [objnsdata encryptaes:@"12345678901234561234567890123456"]; //nsstring* decryptedstr = [[nsstring alloc] initwithdata:objnsdata encoding:nsasciistringencoding]; nsstring *str=[[nsstring alloc] initwithdata: objnsdata encoding:nsutf8stringencoding]; nslog(@"%@",str); if doing encryption , decryption read encrypting / decrypting / base64 encode / decode in iphone objective-c . for aes256 encryption-decryption, read adding methods nsdata , nsstring using categories provide aes256 encryption on ios .

java - Separation of data and presentation -

i have html js , css web page users enter information , every information user enters stored in div tag , when clicks on save page, whole html saved contains both user data , presentation. there many 40 div tags has saved. page save made available once user hits particular url www.mydomain.com/xyz.html page loaded. i tried keep data in xml file, saving whole html page inside xml page. next step saving particular div tags dynamic in xml file , when ever user hits url particular xml file reconstructed , displayed. is doing right? or there other practice keep data , presentation. btw java,j2ee based web application. have common template page when user hit www.mydomain.com/xyz.html parse xyz , lookup db 40 information pull bean now put bean values on presentation.

android - How to define Textchanged event for edit text? -

how define textchanged event edittext?? thanks, balu. you need this: inputview.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { } @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void aftertextchanged(editable s) { } });

design patterns - Serialization and Deserialization When References Are Involved in C# -

i have singleton class called manager holds list of object instances: static class manager { static list<foo> foos = new list<foo>(); } i have collection of object instances using class called meter uses references items in list foos: class meter { public foo myfoo = null; } ... public void createmeter(int userchoice) { meter mymeter = new meter(); mymeter.myfoo = manager.foos[userchoice]; } when application saves project file serializes instances of foo in foos along instances of meter. my problem how deserialize arrangement. following: deserialize project-wide instances of foo reconstruct manager.foos deserialize meter instance includes instance of foo myfoo property search manager.foos , find matching reference mymeter.myfoo , assign reference manager.foos. this seems me clunky , not easy extend. rather meter factory doesn't need search manager.foos during deserialization because in future meter might take it's refence foo ...

Mongodb group and sort -

i using mongod database rails 3 how execute similar code following sql in mongod. there way execute group , sort in mongod select a,b,sum(c) csum coll active=1 group a,b order thanks inspired example on mongo's website. generate dummy data: > db.stack.insert({a:1,b:1,c:1,active:1}) > db.stack.insert({a:1,b:1,c:2,active:0}) > db.stack.insert({a:1,b:2,c:3,active:1}) > db.stack.insert({a:1,b:2,c:2,active:0}) > db.stack.insert({a:2,b:1,c:3,active:1}) > db.stack.insert({a:2,b:1,c:10,active:1}) > db.stack.insert({a:2,b:2,c:10,active:0}) > db.stack.insert({a:2,b:2,c:5,active:1}) mongo query: > db.stack.aggregate( ... {$match:{active:1}}, ... {$group:{_id:{a:"$a", b:"$b"}, csum:{$sum:"$c"}}}, ... {$sort:{"_id.a":1}}) result: {"result" : [ {"_id" : {"a" : 1,"b" : 2},"csum" : 3}, {"_id" : {"a" : 1,"b" : 1},...

android - Best practices for using EC2 to host java web services -

i'm in middle of writing android app, , i'd externalise of features external service. either use existing hosting, , write simple php web services, or little more involved- (which have th advantage of me not having learn php). ideally, i'd write web services in java because i'm comfortable writing , securing them. i'm wondering whether sensible use of ec2, , if so, ami best use? any appreciated. if you're looking @ java web service , you'd scale aws's elastic beanstalk amazon's turnkey solution. takes care of automatically scaling app demand grows , shrinks. http://aws.amazon.com/elasticbeanstalk/

performance - Include all functions in the php file I need or just the functions I need? -

so here want do. the first option write each function in different php file each 1 , include of them in php file called include functions.php , whenever create new page , let's index.php include "functions.php"; why need that? because i'll have include 1 file , functions included. problem server load. i'm not sure how uncalled functions affect performance. the second option create again files need, team them , whenever need function call it. drawback of i'll have more work in order categorize , i'll have include lot of files so want ask, first option increase cpu , memory load have go second one? there performance issues first way or functions not being used not parsed @ php ? disk slowest part of server, in case variant "all functions in 1 file" give little more performance, theoretically. but don't recommend create "functions.php", better way oop . create classes (objects) methods, use autoloaders , psr...

Need Batch script in windows to upload files to a particular ftp location -

i have several backup files in location, c:\backup_folder\... need batch script ( .bat ), files under c:\backup_folder\*.zip moved particular ftp location ( ftp.mysite.com ). also, if file exists on ftp site, must overwritten new file... can show me script performs these backups? the trick automated file xfer windows (for me @ least) has been using correct commandline upload tool. me, when i've wanted shell-scriptable tool, ends being rsync cygwin. since asked windows batch ftp (as opposed safer, more reliable solution, might want try using windows build of wput since want overwrite file each time, use -u (re-upload) option. found wput supported of ftp options wanted, , should handle job. although absolutely agree desire re-upload entire file, can set few optimizations might find handy if you're uploading on slow link, using timestamp comparison decide if don't need upload (-n). option backup scripts may want remove source file after successful uploa...

flex - function name in xml and call this function -

i have functions , xml file in store name of functions , components..eg. <commands> <command> <flexobject>myobject1</flexobject> <flexfunction>myfunction1</flexfunction> </command> <command> <flexobject>myobject2</flexobject> <flexfunction>myfunction2</flexfunction> </command> </commands> i want make array of functions , call them..like as arr:array = new array(); arr.push(myobject1.myfunction1); arr.push(myobject2.myfunction1); arr[0](); call myobject1.myfunction1 function myobjects , myfunctions classic component , functions when call setcommandsservice.send <s:httpservice id="setcommandsservice" url="commands.xml" result="setcommandsservice_resulthandler(event)"/> in handler name of function string , dont know how can add array function.. okay, need make sure objects , functions there, should possible using dyna...

How to get the list of apache modules enabled with php -

i have tried <?php print_r(apache_get_modules()); ?> and got fatal error: call undefined function apache_get_modules() in why error built in function , how list of modules the manual page contains details php , apache version support apache_get_modules() . you must running php >= 4.3.2 , using apache 2 handler api, or php >= 5.0 , apache 1 or apache 2 filter api.

lisp macro expand with partial eval -

i have following code confuse me now, hope can tell me difference , how fix this. (defmacro tm(a) `(concat ,(symbol-name a))) (defun tf(a) (list (quote concat) (symbol-name a))) i think should same effect, seem not. try following call: cl-user> (tf 'foo) (concat "foo") cl-user> (tm 'foo) value 'foo not of expected type symbol. [condition of type type-error] so, what's problem? what want is: (tm 'foo) ==> (concat "foo") first, note that `(concat ,(symbol-name a)) and (list (quote concat) (symbol-name a)) do exact same thing. equivalent pieces of code (backquote syntax isn't restricted macro bodies!): both construct list first element symbol concat , second element symbol name of whatever variable a refers to. clearly, makes sense if a refers symbol, which, svante has pointed out, isn't case in macro call example. you could , of course, extract symbol list (quote foo) , preven...

c# - Polymorphism - exercise -

alright, exercise: define class named student, containing 3 grades of students. class have function calculates grades average. now, define class named student1 derived student , add function calculate sum of grades.in main program, define student variable , object of type student1. perform placement of object variable , run function of student1. note: not homework, i'm learning own. code: class student { protected int grade1, grade2, grade3; public student(int grade1, int grade2, int grade3) { this.grade1 = grade1; this.grade2 = grade2; this.grade3 = grade3; } public double average() { return (grade1 + grade2 + grade3) / 3; } } class student1 : student { public student1(int grade1, int grade2, int grade3) : base(grade1, grade2, grade3) { } public double sum() { return grade1 + grade2 + grade3; } } class program { static void main(string[] args)...

How to Render content include razor syntax in asp.net mvc 3 -

in database there record include razor syntax "hello @model.name, wellcome ..." when record view how can render model property ? thanks, there many ways. pulling view database rather file http://razorengine.codeplex.com http://ibashir.blogspot.com/2010/11/razor-parser-without-mvc.html http://blog.andrewnurse.net/2010/07/22/usingtherazorparseroutsideofaspnet.aspx i'm biased towards razorengine codeplex it's been used in mini-profiler developers of site.

c++ - Most important const & rvalue refs -

in c++03 can use const& trick (or "most important const") extend lifetime of temporary lifetime of reference. question is, in c++0x, behaviour extend rvalue references? i.e auto&& x = somefunction(); according [class.temporary] , if compiles yes, lifetime of temporary extended.

c# - Two overlapping ListBoxes. Selection problem -

i'm trying display shapes in 2 separate listboxes occupying same space. i've set background both transparent , {x:null} mouseclick still getting captured topmost listbox can't select shapes underlying listbox. here sample code reproducing problem. <grid> <!-- listbox 1 --> <listbox background="{x:null}"> <listbox.itemspanel> <itemspaneltemplate> <canvas background="{x:null}"/> </itemspaneltemplate> </listbox.itemspanel> <listbox.itemtemplate> <datatemplate> <grid background="transparent"> <ellipse width="100" height="100" stroke="blue" strokethickness="10"/> </grid> </datatemplate> </listbox.itemtemplate> 1 </listbox> <!-- listbox...