Posts

Showing posts from February, 2010

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

MySQL Workbench EER Diagram changing table colors -

after creating eer diagram existing database unable read table names in diagram due table header , tablename text both being black. i'm not sure why wasn't way last time used it. know if there way of changing colors used in diagram? i've hunted through menus nothing obvious. pointers appreciated, thanks click on table want change color. on left side, under properties editor section have tab named properties (tabs positioned @ bottom of area). click on , first property can modify color. value should entered in hexa :)

asp.net - How to prevent users from manipulating html content "badly" and posting it back to server? -

i have not found same or related question above. if asked, please let me know, delete mine. i learning asp.net mvc 2. after downloading rendered page, visitors have chance manipulate html contents illegally , submit server. in mvc, how can avoid issue? you cannot prevent on user side. therefore must ensure server reacts correctly manipulated input. note automatic model binding tricky: both over- , under-posting can cause trouble. excellent post on topic: http://bradwilson.typepad.com/blog/2010/01/input-validation-vs-model-validation-in-aspnet-mvc.html

actionscript 3 - Making 3d models in flash -

hy! i have make animation school. my cencept: make 4 pictures person's head , wire them cube. want import adobe flash professional cs5. my question: is possible? if not, there other rudiments solve problem? thanks helping check out away3d's tutorials: http://away3d.com/tutorials

export - Need to move code from hosted svn repo to production server -

i going export since repo externally hosted svn it's https:// address not allowed export command(torotoise svn). how move code? (the production server externally hosted address). may not understand correctly, of course can use export-command of tortoisesvn https:// have tried it? exact error message? ohterwise can use commandline: svn export <your_repo_url> <path(optional)>

java - What does "@Override" and "<? extends Page>" mean? -

@override public class< ? extends page> gethomepage() { return homepage.class; } public class<homepage> gethomepage(){ return homepage.class; } the first 1 has annotation override. mean or send framework. will both methods return same class. mean mean ? extends page . mean ? mark. 1) override annotation javadoc : indicates method declaration intended override method declaration in superclass. if method annotated annotation type not override superclass method, compilers required generate error message. 2) ? means any. example : < ? > means java data type can here < ? extends page > means subclass of page allowed here.

templates - MVC .NET using Html.EditorFor in my controller -

i'm using custom editor templates in view, , know if possible obtain same result controller. <%: html.editorfor(model => model.book) %> does knows if it's possible? i found possible solution: add user control , call html.editorfor(model => model.book) inside. in controller have call view(usercontrol,model) does have better idea?

html - Centering my Logo Div -

i have tried every possible method center logo div no luck. ended going old school align="center" no luck. please - http://rezaee.me/kel/ cheers try removing position: fixed #logo declaration.

iphone - How to Give action to the tab bar item -

this code tab bar - (void)viewdidload { [super viewdidload]; self.title = nslocalizedstring(@"crops ", @"articles"); uitabbar *tabbar = [[uitabbar alloc] initwithframe:cgrectmake(0, 376, 320, 44)]; item1 = [[uitabbaritem alloc] initwithtitle:@"typestotry" image:[uiimage imagenamed:@"crops.png"] tag:0]; item2 = [[uitabbaritem alloc] initwithtitle:@"whentoplant" image:[uiimage imagenamed:@"crops.png"] tag:1]; nsarray *items = [nsarray arraywithobjects:item1,item2,item3,item4,item5, nil]; [tabbar setitems:items animated:yes]; [tabbar setselecteditem:nil]; tabbar.delegate=self; [self.view addsubview:tabbar]; } what want whenever tap on 1st tab want go particular description ,so right action.please me in this. questions may simple,but me difficult :),please new developer thanks hi think can add following line of code make tab bar item workable [item1 performselecto

amazon web services - DNS Round Robin very slow requests in failover scenario -

currently i'm configuring server pool aws. simple setup 2 database servers scalable server array , 2 load balancers in front of all. every machine has failover standing , should pretty robust. the load balancers should able failover through round robin dns. in happy day scenario both machines hit , distribute traffic on array. when 1 of these machines down round robin dns in combination client browser retry should make browsers should shift target host machine still once hit timeout. not came seems solution. the problem i'm experiencing following. shift happen not once failed request each , every subsequent request same browser. simple page request takes 21 seconds load after images take 21 seconds load. following page request takes long. failover works same time useless. output dig: ; <<>> dig 9.6.1-p2 <<>> example.com ;; global options: +cmd ;; got answer: ;; ->>header<<- opcode: query, status: noerror, id: 45224 ;; flags: qr

Convert ASP.NET MDF to MySQL Database? -

how convert aspnetdb.mdf mssql database mysql works asp.net here tool: access mysql small program convert microsoft access databases mysql. http://www.bullzip.com/products/a2m/info.php

php - Can I Pass value from form to popup window, display something based on what was passed, then pass something back? -

i need using php , javascript. i have 1 form, few inputs. 1 of them gender. when click link/button need pass value of gender drop down popup. based on value show either male or females portraits. i'd pass value parent window once select portrait , click button. i have code display portaits. how pass values , forth, , how make value passed parent window available php code in new popup? any appreciated. the problem defined, question still vague. i'll give shot though. if mean pop-up (separate window) rather on-page dialog (such jquery ui elements , forth), communication channel you'll want use object returned window.open() communicate parent page child page, , window.opener communicate child parent. example: var genderpicker = document.getelementbyid('genderselect'); var gender = genderpicker.options[genderpicker.selectedindex].value; var portraitchooserwindow = window.open("path/to/script.ext?gender=" + gender); // portraitch

visual studio 2008 - TFS Build Agent Use Multiple Configurations -

i'm trying use tfs build agent replace old build.bat file builds of projects. have c# , c++ projects need compiled. of c# projects have configuration release|any cpu , of c++ projects have release|win32 configuration. i've created msbuild project includes of projects. how specify c++ projects should use release|win32 configuration , c# projects should use release|any cpu configuration. john. are projects contained in single solution? if so, can create solution configuration maps appropriate project-level configurations each project.

How to get the version history of a list using Client Object Model Sharepoint 2010 -

i want access list item history details since have multiline fields enabled append data mode. also, want see if date modified after creation of item , etc. how can through sharepoint 2010 client object model? this demonstrated here: http://www.learningsharepoint.com/2010/07/16/programmatically-get-document-version-history-using-client-object-model-sharepoint-2010/

c# - to pass data around using event handling -

anyone can detail pros , cons pass data 1 class using event mechanism? when best time use event pass data? let's take example. have system 20 people subscribed weather station changes in weather. want weather station keep track of people , services subscribed? in opinion weather station should not know people or services waiting weather changes. weather station should dispatch event, , whoever listening notified :-) so point is, use events notify observers action or state change occurred in object. observers can difference type of objects since don't have know them. if listens object, takes care of it. if 1 one relation , object waiting happen of same type, wouldn't need event case. events great decouple systems, seen in example above weather station. weather station can run on own without knowing services or users listening it.

iphone - fire event when touch up inside uiview and outside button -

i have view overlayed iphone's camera view. in view have uibuttons displayed in positions depending of values accelerometer/compass. need fire event when user touch inside view doesn't touch inside uibuttons, mean, opposite action of touch inside uibuttons. knows kind this? thanks! if implement uiresponder touchesbegan:withevent: method.. - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event ...on view, you'll able tell when user has pressed outside of buttons. see uiresponder class reference more information.

jquery - Drupal - show popup on front-page load only one time -

using jquery, cck , views can show simple popup when front page loaded. (to point special event...) with simple script popup appears every time visit front page, change behavior: must appear 1 time per session. any advice? cookie? global variables? what's best solution? thanks bye update resolved using jquery plugin "cooquery" temporary cookie. solution satisfy me enough! link text

JQuery AutoComplete with ASP.Net -

below javascript <script> $(function () { function log(message) { $("<div/>").text(message).prependto("#log"); $("#log").attr("scrolltop", 0); } $("#city").autocomplete({ source: function (request, response) { $.ajax({ url: "getpostcodes.aspx", datatype: "jsonp", data: { like: request.term }, success: function (data) { response($.map(data.regionlist, function (item) { return { label: item.detail, value: item.detail } })); } }); }, minlength: 2, select: fu

serialization - Need to Seriazlize List<object>, but FXCop complains "Do not expose generic lists" -

i have object need serialize. object contains several properties, including list. fxcop complaining should not expose generic lists, , that, however, due fact can't specify interface based property on object want serialized i'm not sure turn next. any thoughts? btw, i'm using xmlserialization, that's not requirement. i took fxcop's suggestion , wrapped list in collection. blew of code out of water, after few adjustments , running again. here's code showing before , after: before: public class persistentdataview { public string title { get; set; } private list<object> inputs { get; set;} } after: public class persistentdataview { private list<object> _inputs; public string title { get; set; } public collection<object> inputs { { if (_inputs == null) _inputs = new list<object>();

html - Setting tab order with javascript -

i have page has multiple forms. i'm using mootools sliding tabs each of buttons on menu slide along next form. there 3 forms technically on same html page. see example of technique @ http://creativepony.com/archive/demos/sliding-tabs/ my problem when user presses tab key , tabs through last field want tab order goes first field. user not accidentally tab next form. user end looping around same form fields. user reach next form use menu don't want them able tab next form. i aware of setting tab order 'tabindex' doesn't me make user return first field of form. any ideas how achieve javascript? i making fields in forms aren't visible disabled , browser knows skip them, regardless of navigation mechanism (think accessibility aids).

Database design - defining a basic many-to-one relationship -

this basic database design question. want table (or multiple tables) defining relationships between customers. want primarycustomer can linked multiple secondarycustomers, , can have many secondarycustomers same relationship. primarycustomerid relationshipid secondarycustomerid 1) if primary key {primarycustomerid} can have 1 linked customer of kind. 2) if primary key {primarycustomerid, relationshipid} , can have 1 linked customer each relationship type. 3) if primary key {primarycustomerid, relationshipid, secondarycustomerid} , can have whatever like, having columns primary key seems wrong. what's right way set things up? number 3 right way go data model. linking tables have columns in join link other tables.

android - How can I check if the Launcher/Home screen is currently displayed -

i working on widget fetching , displaying data. refresh rate custom. what do, fetch data when widget displayed (when launcher on top). is there way check if launcher displayed? there's no way of doing this, unless of course homescreen has api requesting information. best bet listening screen turn ons/turnoffs. but so, pick conservative refresh rate , let users modify it.

php - CakePHP HABTM association rules -

if want create category , able link products tags can so: create category , product tables. create tags table tags like: ruby, earrings, white-gold create category_tags , product_tags table map them set category , product hasandbelongstomany tags set tags hasandbelongstomany products , hasandbelongstomany categories now have 2 products 1 tags: ruby , earrings , tags: ruby , bracelet say want create ruby earrings category. i add ruby , earrings tags category. under normal habtm model associations both products returned because though 1 has earrings tag both have ruby tag. how can make match products have of same tags category (products can have more tags must have tags corresponding category has) in order returned? also, taking further, how add -tags category products must not have these tags returned? the script below solved issue generating query so: php $data = $this->designer->find( 'first', array( 'con

What's the difference in how Nhibernate treats .FirstOrDefault vs .SingleOrDefault? possible bug? -

just starting out nhibernate , using nhib 3.0's (3.0.0.2001) linq following models public class request { public virtual guid id { get; set; } public virtual state {get;set;} } public class state { public virtual guid id {get;set;} } so i'm trying retrieve request based on it's state id. _session.query<request>().where(x => x.state.id==someguidvalue).firstordefault(); seems pretty straight forward, gets sql error based on generated sql looks @p0 parameter missing, though not sure why'd included here. {"line 1: incorrect syntax near '('."} select top (@p0) requ0_.id id0_ , requ0_.state_id state8_0_ [request] requ0_ requ0_.state_id=@p1 ] name:p1 - value:a2e63925-6628-4786-a621-9e5200d5ab71 however, using singleordefault works, fine. _session.query<request>().where(x => x.state.id==someguidvalue).singleordefault(); any insight appreciated. thanks i believe singleordefault error when more 1 re

hibernate search logging text files -

we gathering lot of logs, going use database or file store these logs , want able search through them using text search. there way efficiently. so got exceptionpersistingservice eps = new exceptionpersistingservice(); try{ //some code might trow exception }catch(exception e){ eps.savenewexceptin(getstacktrace(e)); } public static string getstacktrace(throwable athrowable) { //add class name , message passed constructor final stringbuilder result = new stringbuilder("trace: "); result.append(athrowable.tostring()); final string new_line = "<br>"; result.append(new_line); //add each element of stack trace (stacktraceelement element : athrowable.getstacktrace()) { result.append(element); result.append(new_line); } return result.tostring(); } than create lucene implementation (i recommend using hibernate search) index the exception strings stored in database. in save() method can cr

php - How to make a correct Joomla URL using the Joomla Classes -

i busy making joomla! component. , know want link component. so, example want link component 'my_component' 'his_component'. simple do. make normal link href="?option=com_his_component". problem 1 of consumers uses seo friendly urls. , in case url won't work. does know way correct way (i think joomla! api) just wrap link call jroute::_($url) : $link = jroute::_('index.php?option=com_his_component&foo=bar');

Visual Studio 2010 Builds to wrong directory -

my project's output path set "bin\debug\" i'm building through vs2010 , builds ..\..\build\bin\x86\debug (and not bin\debug). can't find other settings in .sln or .csproj might affect this. ideas? turns out have (plugin?) msbuild looks before.targets file in parent directory , overwriting outdir based on that.

printing - How can I extract only the email body with Python using IMAP? -

i relatively new programming , python, think have done ok far. code have, , works fine, except gets entire message in mime format. want text body of unread emails, can't quite figure out how strip out of formatting , header info. if send basic email using smtp python script made works fine, , prints body, if send email using outlook prints bunch of garbage. appreciated. client = imaplib.imap4_ssl(popserver) client.login(user, password) client.select('inbox') status, email_ids = client.search(none, '(unseen subject "%s")' % printsubject) print email_ids client.store(email_ids[0].replace(' ',','),'+flags','\seen') email in get_emails(email_ids): get_emails() def get_emails(email_ids): data = [] e_id in email_ids[0].split(): _, response = client.fetch(e_id, '(uid body[text])') data.append(response[0][1]) return data sounds you're looking email

java - Sharing JGroups comm channel with EHCache -

i'd use jgroups replication w/ ehcache , share communication channel own app. what's recommended way this? (similar jboss's "shared transport" feature) i thinking jgroupscachemanagerpeerproviderfactory might have public methods access channel object, did not see these. thanks!

.net - VSTO Outlook 2007 unique message ID -

i creating outlook 2007 add-in using vsto. need store information (entered user) each email. first thought create small "database" references each email necessary. can't seem find accessible identifier each email purpose. there id or other unique field available each mail message item can use? c# or vb.net code fine. can easy points you! thanks in advance! the mail item has number of properties, including entryid property . can add custom properties .

ios - Apply filter over UIView/UIWindow to modify underlying view rendering -

i'm trying make "dark mode" app, , i'd in easy way. there way apply filter or create view on other views appear inverted - "accessibility" on ios 3.2+? know core image filters don't work on iphone, that's not big deal me - long there's way apply different sort of filter. is feasible on iphone? how apple it? it sounds you're thinking of placing semi-transparent view filled dark color on entire user interface. if that's case, should read forwarding touch events discussion of issues involved. another way change set of colors , images use draw views. both these schemes easier , work better if you're dealing custom views. if you're using overlay, document linked above explains standard ui elements don't take kindly event forwarding. if change colors, well... depending on ui elements you're using, may or may not possible substitute own images , colors.

bash script and command definition -

got little bash script so: #!/bin/bash time_cmd='/usr/bin/time -f "%e execution time"' ${time_cmd} ls only problem: doesn't work: /usr/bin/time: cannot run execution: no such file or directory command exited non-zero status 127 "0:00.00 what doing wrong? try making it... #!/bin/bash time_cmd='/usr/bin/time -f "%e execution time"' eval "$time_cmd ls" this utilize bash re-parse command string after has been constructed, quoted argument recognized properly.

Installing Standard Ruby Classes Documentation with rdoc3 -

what correct procedure have standard ruby class documentation available via "ri" system? know rdoc-data gem, still appropriate rdoc3 (3.0.1) gem? ruby 1.8.7/linux (os) specific if possible. thank you. i ended installing rdoc-data gem , ran: rdoc-data --install (after creating /usr/share/ri ) , seems work. nice if there way install documentation somewhere other /usr/share/ri @ least docs available.

backgroundworker - C#: Why is my background worker thread signaling done when it isn't? -

c#, using vs2010 , i've got makes no sense. at startup program needs load several hundred k text files. after ensuring loading code working fine threw in background thread. long run within ide everything's fine when it's run standalone thread says it's done when isn't. of course goes boom. the trigger code: backgroundworker background = new backgroundworker(); background.runworkercompleted += new runworkercompletedeventhandler(databaseloaded); background.dowork += new doworkeventhandler(delegate { database.load(); }); background.runworkerasync(); and stuff that's going boom in databaseloaded() . i put messageboxes trace what's going on: first , last lines of load() method , first line of databaseloaded() . in ide triggers expect: load() beginning, load() done, databaseloaded() . however, when run standalone load() beginning, databaseloaded() , unhandled exception box (the loader hasn't gotten build empty tables, let alone fill

matlab rgb values dilemma -

when wrote these commands out = ones(size(ben)) imshow(out) the output white picture expect dark picture because rgb values 1,1,1. when give 255,255,255 gives white picture. isn't dilemma ? try out = ones(size(ben), 'uint8'); ones() default creates array of doubles. when imshow() gets array of doubles assumes pixel values range between 0 , 1, , assigns white color greater 1. however, if pass array of uint8 imshow() assume range between 0 , 255. you can try using imagesc(); instead of imshow() , may need colormap gray after wards grayscale image. another alternative rescale image before display: imshow(out / max(out(:)));

algorithm - Given a file, find the ten most frequently occurring words as efficiently as possible -

this apparently interview question (found in collection of interview questions), if it's not it's pretty cool. we told efficiently on complexity measures. thought of creating hashmap maps words frequency. o(n) in time , space complexity, since there may lots of words cannot assume can store in memory. i must add nothing in question says words cannot stored in memory, if case? if that's not case, question not seem challenging. optimizing own time: sort file | uniq -c | sort -nr | head -10 possibly followed awk '{print $2}' eliminate counts.

java - can I specify the return type in the hql words -

hi: using hibernate3.6,i meet problem when querying. take hql exmaple: string hql="select count(distinct ip),sum(bytes) entity en .... query q=session.createquery(hql); list<?> list=q.list(); now can retrive columen properties list following way: string[] properties={"count","sum"}; (object obj : list) { map<string, object> m = new hashmap<string, object>(); object[] props = (object[]) obj; if(properties.length!=props.length) throw .... (int = 0; < props.length; i++) { m.put(properties[i], props[i]); } } now,my problem that,when hql result no set,the count 0,but sum null. want 0 also. of course,i can converting explicitly if know column name , type(they count,sum in above example) of result table db,but did not know. that's say,i can not use this: if(props[i]=null) props[i]=0; m.put(properties[i], props[i]); since type of props[

batch file - echo -e equivalent in Windows? -

is there linux "echo -e" equivalent in windows can use "echo -e \xnnn" print out character ascii code hexadecimal value nnn ? there no equivalent, can write own function. i split problem 2 parts. convert hex number decimal. convert decimal number ascii. converting hex decimal simple by set "myhex=4a" set /a decimal=0x%myhex% converting number ascii more tricky, depends of required ascii-range if need range 32 (space) 126'~', use =exitcodeascii variable set "decimal=%1" cmd /c exit /b %decimal% echo "%=exitcodeascii%" if need special characters cr , lf , esc , del , possible create them pure batch. if need more use vbscript. forfiles method a more general way use command forfiles ( dostips: generate character... ) echo-e.bat @echo off set "arg1=%~1" set "arg1=%arg1:\x=0x%" forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%arg1%" you c

Combinations and Permutations in F# -

i've written following combinations , permutations functions f# project, i'm quite aware they're far optimised. /// rotates list 1 place forward. let rotate lst = list.tail lst @ [list.head lst] /// gets rotations of list. let getrotations lst = let rec getall lst = if = 0 [] else lst :: (getall (rotate lst) (i - 1)) getall lst (list.length lst) /// gets permutations (without repetition) of specified length list. let rec getperms n lst = match n, lst | 0, _ -> seq [[]] | _, [] -> seq [] | k, _ -> lst |> getrotations |> seq.collect (fun r -> seq.map ((@) [list.head r]) (getperms (k - 1) (list.tail r))) /// gets permutations (with repetition) of specified length list. let rec getpermswithrep n lst = match n, lst | 0, _ -> seq [[]] | _, [] -> seq [] | k, _ -> lst |> seq.collect (fun x -> seq.map ((@) [x]) (getpermswithrep (k - 1) lst)) // equivalent: | k, _ -> lst |> getrotations

Flash framework to help with "packager for iPhone" -

are there frameworks flash (as3) optimised outputing iphone using flash packager iphone ? i have used "packager iphone" of flash apps , games, , work ok. there things need changing. there guidelines creating content , using packager. can see guidelines here . are there application or game frameworks out there yet, take sort of optimisation account? i not think exists far. project suspended while (when apple not allowing use c++/objective c devices) - it's life, expect come.

PHP Class on Class, get Parent -

let's have 3 classes. 1 being parent , 2 being "childs". however, i'm not using class - extends - : class root { function root(){ $this->son = new son(); $this->daughter = new daughter(); } } class son { ... } class daughter { ... } how call function of son function of daughter ? in other words, how reference class root son/daughter call functions of each other, each other? a classic case of dependency injection. class root { function root() { $this->son = new son($this); $this->daughter = new daughter($this); } } class son { function __construct($parent) { $this->parent = $parent; } function foo() { $this->parent->daughter->bar(); } } just careful not create rigid dependencies between classes shouldn't have them. inheritance may better way go. alternatives include registry pattern , factory patterns.

asp.net - How to invoke a Forms Auth login modal dialog instead of redirecting to a loginUrl signin page? -

i've finished implementing modal dialog login popup asp.net website. experience similar digg.com. when log in, fancy popup modal dialog (provided jquery tools overlay control ). dialog ascx file in master page, it's available globally. uses pagemethod validate current user. if validation succeeds, call window.location.reload(); in pagemethod's success callback. this works great when logging in on page doesn't require authentication, when non-auth users trying navigate page requires auth? is possible modify web.config file instead of redirecting signin.aspx page non-authenticated users invoke modal dialog instead? let's non-authenticated user on default.aspx doesn't require auth. wants navigate "add.aspx" does require auth. what's best way handle modal dialog popup? if have use dedicated page, guess i'll have signin.aspx page invokes dialog when loads , if authentication succeeds, it'll use javascript redirect destinatio

iphone - Need to get current location and destination location pin -

how current location green pin , destination location red pin? when work on stuff destination location red pin, not @ current location. my source code. #import <uikit/uikit.h> #import <mapkit/mapkit.h> #import <mapkit/mkannotation.h> #import <corelocation/corelocation.h> @interface addressannotation : nsobject<mkannotation> { cllocationcoordinate2d coordinate; nsstring *mtitle; nsstring *msubtitle; // cllocationmanager *locationmanager; // cllocation *currentlocation; } @end @interface mapviewcontroller : uiviewcontroller <cllocationmanagerdelegate,mkmapviewdelegate> { iboutlet mkmapview *mapview; addressannotation *addannotation; nsstring *address; cllocationmanager *locationmanager; cllocation *currentlocation; } +(mapviewcontroller *)sharedinstance; -(void)start; -(void)stop; -(bool)locationknown; @property(nonatomic,retain)cllocation *currentlocation; @property(nonatomic,retain)nsstring *addres

php - drupal------how to output it -

this code in module file. if want print second or third value or value., how should do? function alterlink_address(){ //page callback function $sql = db_query("select field_link_url {content_type_address}"); while ($q = db_fetch_object($sql)){ return $q->field_link_url.'<br>'; } } i'm no drupal expert , there surely more economic way, still work: function alterlink_address(){ //page callback function $sql = db_query("select field_link_url {content_type_address}"); while ($q = db_fetch_object($sql)){ $results[] = $q->field_link_url.'<br>'; } return $results[0]."<br />"; } where 0 in square brackets number (starting 0) of result want return. a couple of notes: a correct indentation can save lives; getting plethora of results database , displaying few of them nice method awaken cthulhu. suggest take @ drupal docs directly results need.

Checking OpenGL resource leaks -

so have rather large opengl program going, , checking normal memory leaks (those new , delete) rather trivial -- run on valgrind. but best way check potential opengl leaks? there opengl utility that'll tell how many resources (e.g framebuffers) being used @ time, or such? or way attach counter every glgenblah , gldeleteblah pairs? glintercept check textures haven't been freed, perhaps checks framebuffers, if not, maybe modified it.

jquery - how to save dynamically changed ( byjquery ) html DOM? -

i got nice layout generator using jquery dynamic forms, , jquery ui features change number of used elements, css properties etc. looks great there 1 problem presentation of current result. save generated html dom , parse somehow ( delete hidden elements dom tree etc ). ideas how save current (modified) html + css? solution using jquery follows: step 1: convert whole (modified) html string representation: var html = $('html').clone(); var htmlstring = html.html(); step 2: base64 encode htmlstring , put datauri inside hyperlink: var datauri = "data:text/html;charset=utf-8;base64," + $base64.encode(htmlstring); $("body").append("<a href='" + datauri + "'>save</a>"); note: i'm using library base64 encoding above: http://hpyer.cn/codes/jquery-plugin-base64-encode-and-decode step 3: right-click on 'save' link dynamically created above , choose "save as" browser's conte

php - Upgrade WAMP to MySQL 5.5? -

my dev team uses wamp php/mysql environment learnt uses mysql 5.1 , mysql @ 5.5 now. can mysql upgraded 5.5 separately without issue make work wamp or there patch wamp latest mysql? i want ensure work latest build of mysql not sure if simple download mysql 5.5 , gets auto-added wamp server, or if there compatible? assume since wamp never updated mysql not compatible? found you: step1: (x represents number) download latest version of mysql first... copy new folder of mysqlx.x wamp\bin\mysql\ check if folder of mysql , database files exist in mysqlx.x\data folder. if mysql folder doesn't exist, copy working previous version of mysql. check if mysqlx.x\bin folder , executable files in exist. check if folder mysqlx.x\share exist. if don't exist, extraction of latest version of mysql isn't done properly. check if mysqlx.x\my.ini file exist. if doesn't exist, copy file previous wokring version of wamp mysql in wa

c++ - recursive return type -

i browsed through mark probst's diploma thesis , stumpled on following code: typedef void* cont(void); (;;) { cp = (cont*)(*cp)(); } i'm pretty sure cast should read (cont) , not (cont*) , because explains: the function wishing proper tail call returns the address of function called and cont pointer-to-function type. let's change line to: cp = (cont)(*cp)(); now wondering, how can rid of cast? can cont defined returns cont ? how typedef cont like? need helper type achieve this? impossible? no, typedef void* cont(void); cont defines function type returning void * . think confusing typedef void (*cont)(void); or typedef void *(*cont)(void); . i don't believe it's possible eliminate need cast in scenario i'm open convinced otherwise.

warnings - Output in makefile at top-level -

i setting variable in makefile this: somevar = foo this makefile later includes other makefile in actual building of programs takes place: include generic/makefile.common so no build targets defined in first makefile , it's setting variables used common generic makefile actual package building. now know should careful when using foo , remind myself of this, want print warning message whenever makefile used setup make process. problem cannot insert echo command after variable definition, because not yet building there. is there solution (more elegant adding fake target message printed destroy separation of setting variables , building)? somevar = foo $(warning careful foo)

java me - how to make httpclient portable on different handset such as android and j2me -

how make httpclient portable on different handset such android , j2me i think, that's not possible, since sending , receiving of http requests highly platform specific. check out android html package documentation , comparison j2me example .

ruby on rails 3 - How to resolve undefined method `middleware' while running rack-bug -

i have set rack-bug in ruby. have added config.middleware.use ("rack::bug", :secret_key => "ept5ucichlshcer9dlooeapg66pthd9k8l0q9avitiaa/kury7de52hd4ywy+8z1", :password => "some_pass" ) into config/environments/development.rb file. when start server load_environment': undefined method middleware' #<rails::configuration:0x7f7e80b53b18> (nomethoderror) showing. in configuration same thing mentioned in many sites. how can resolve problem? using rail-2.2.2.

continuous integration - How to unit test WIX merge modules? -

i building merge modules wix. batch files calls wix tools generate merge modules *.wxs files run daily build. i trying figure out how automate testing of these merge modules. things test are, whether merge module installs required files, whether versions of files correct etc. one idea have write script (may vb script) install merge module @ temporary location , check if has installed correctly. however, not sure if correct way it. are there standard ways of writing unit tests merge modules? ideas around how go welcome. i've thought haven't come like. first call integration testing not strictly unit testing. second problem of "right files" , "right versions" difficult define. i'm tempted wix/msi data defines installer do. it's declarative in nature , therefore definition correct. it's tempting want create yet set of data cross checks implementation of installer accomplish first data set didn't represent? it's ha

Use Perl to edit HTML files -

the output below generated third party tool validates xml files against xml schema. output validation errors. ok, little context. from errors above displayed in html, want able perform "syntax highlighting" using perl. instance, want able highlight parts of text above. specifically, want colour text conforms "line [0-9]*" bold , in red. i've tried experiment regex search , replace i've not been successful. any pointers/hints fantastic. thank you! line 8: element 'alphabet', attribute 'letters': value 'xyz' not match fixed value constraint 'abc'. line 185: element 'drink': attribute 'coffee' required missing. line 254: element 'timeout': element not expected. line 269: element 'commands': element not expected. expected 1 of ( eat, drink, sleep ). line 812: element 'software': attribute 'version' required missing. line 876: element 'windows-software': attribut

c# - Shouldn't my nhibernate mapping take care of this? Error: not-null property reference a null or transient value -

i have database 3 tables: project sponsor projectsponsor in domain objects, have object project has child property called sponsors list of projectsponsor objects, this: ilist<projectsponsor> sponsors; here nhibernate mapping code : productmap : hasmany(x => x.sponsors).asbag().inverse().cascade.alldeleteorphan(); productsponsormap: references(x => x.project).not.nullable(); references(x => x.sponsor).not.nullable(); here my domain objects : public class project { public virtual ilist<projectsponsor> sponsors { get; set; } } public class projectsponsor { public virtual project project { get; set; } public virtual sponsor sponsor { get; set; } } ok . . issue, when try add new projects (with associated projectsponsor) database. here code: foreach (project project in newprojects) { repository.save(project); foreach (projectsponsor projectsponsor in project.sponsors) { repository.sav

jquery - Convert an ajax request into an object? -

i making several jquery xml requests , need called on document ready , others need called function call? noticing lot of code duplicates because wrapping xml requests in function. here example. $.ajax({ type: "get", url: "english.xml", datatype: "xml", success: function searchstr(xml, val){ val = val.tolowercase(); $(xml).find("a").each(function(){ $(this).find('b').each(function(){ $(this).find('c').each(function(){ $(this).find('d').each(function(){ //calculations }); $(this).find('d2').each(function(){ //calculations }); }); }); }); } }); this first 1 being called on document ready.... function searchforstring(val){ $.ajax({ type: "get", url: "english.xml", datatype: "xml", succe

saxparser - Difference in doing Android XML Parsing using DOM Parser and SAX Parser -

i know exact advantage gained in doing android xml parsing using dom parser , sax parser? dom parser advantageous sax parser or vice-versa? please clarify. thanks, sen hi sax parsing best 1 implement dom, see difference between these 2 in following: dom the nodes in form of tree structure memory: occupies more memory, dom preffered in case of small xml documents slower @ runtime stored objects programmatically easy implement ease of navigation , use. sax sequence of events it doesn't use memory preferred large documents. faster @ runtime, because of above mentioned point. objects created. need write code creating objects in sax backward navigation not possible sequentially processes document

c++ - QThread confusion -

i'm using qt 4.7.0 (32 bit) on windows 7 ultimate (32 bit) machine. i've been using qt version 4.0 or 4.2 , i've used 4.x.y releases. recently, qt 4.7 i've faced trouble. i've written multithreaded application in older version of qt. i've forgotten version last version compiled , ran 4.5.x or 4.6.x. threaded part doesn't seem working correctly in 4.7, or misunderstood something. here problem: the main thread starts thinker thread. following run() function of thinker thread: void thinkerthread::run() { _threads_running = nsubthinkers; // ... _sub_thinker[0].start(); // ... _sub_thinker[1].start(); exec(); } the _sub_thinker 's finished() signal connected thinkerthread::subthinkerfinished() slot _sub_thinker s. when _sub_thinker s finish, thinkerthread::subthinkerfinished() calls quit() . there place quit() called: void thinkerthread::trykill() { (int = 0; < nsubthinkers; i++) _sub_

sql - Returning Null with WHERE -

i have basic query access using sql, want bring null if nothing returned. for example if state where cust_id = "win" if there no "win" query bring null. i had thought use isnull have not managed work. thanks in advance zane to null if condition fails require either case statement around column definition or left outer join instead of clause. iif(cust_id = "win", "win", null) or left outer join tablename on tablename.cust_id = "win" should work - don't have access available check.

html5 - Is there a pure javascript implementation of IndexedDb? -

i looking simplify of code implementing pretty simple schema , discovered indexeddb spec isn't yet finalized. the schema used present table user filtering mechanism , allow user add/edit rows of table. doesn't need stay persisted client (but make less traffic when available). feel confident use implementation done in js , gain benefits of native implementation when exists (presumably increased query speed , local storage). i aware of http://code.google.com/p/indexeddb/ under requirement in such way nothing needs installed. have gone mad or there this? indexeddb not implemented in major browser atm. think firefox 4 may testing -- http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/ edit: didn't read -- want pure js implementation; sorry.

java - Synthetic accessor method warning -

i've made new warning settings in eclipse. these new settings i'm facing strange warning. after reading got know couldn't find way remove it. here problem sample code public class test { private string teststring; public void performaction() { new thread( new runnable() { @override public void run() { teststring = "initialize"; // ** } }); } } the line * * gives me warning in eclipse read access enclosing field test.teststring emulated synthetic accessor method. increasing visibility improve performance. problem is, don't want change access modifier of teststring . also, don't want create getter it. what change should done? more descriptive example public class synthetic { private jbutton testbutton; public synthetic() { testbutton = new jbutton("run"); testbutton.addactionlistener(new actionlistener() {

python - Creating sublists -

the opposite of list flattening. given list , length n return list of sub lists of length n. def sublist(lst, n): sub=[] ; result=[] in lst: sub+=[i] if len(sub)==n: result+=[sub] ; sub=[] if sub: result+=[sub] return result an example: if list is: [1,2,3,4,5,6,7,8] and n is: 3 return: [[1, 2, 3], [4, 5, 6], [7, 8]] is there more eloquent / concise way? an aside, preferred when appending lists lists (in context above): list1+=[list2] or: list1.append(list2) given (according summerfeild's 'programming in python 3') same? thanks. such list of lists constructed using list comprehension : in [17]: seq=[1,2,3,4,5,6,7,8] in [18]: [seq[i:i+3] in range(0,len(seq),3)] out[18]: [[1, 2, 3], [4, 5, 6], [7, 8]] there grouper idiom : in [19]: import itertools in [20]: list(itertools.izip_longest(*[iter(seq)]*3)) out[20]: [(1, 2, 3), (4, 5, 6), (7, 8, none)] but note missing elements filled value none. iz

c# - Best way to prevent unused properties from being passed from object -

i'm putting wcf service handles large search (currently 50-60 parameters, more added in future). handle this, have search object criteria passed service in message object. while search parameters must available, case 2-3 of parameters receive user input , others null. mind, doesn't make sense pass entire object around through every method if few fields used. i'm looking technique extract fields used values, can validated , passed data layer execute search. few ways accomplish can think of include: use reflection loop through properties, , add non-null properties dictionary<string, object> . problem comes mind here lose type of search parameter, means data layer search function 1 giant case statement hard-coded cast values each potential field. seems overkill , creating way tight of coupling. create searchvalue class name, value, , system.type properties, , use reflection build list<searchvalue> . still results in big case check in search, rather property

xstream json: convert java.util.Properties to object literal -

i using xstream de/serialize objects json. i want serialize java.util.properties want serialized in javascript object literal. i.e. properties p = new properties(); p.setproperty("a", "b"); p.setproperty("x", "y"); should converted to: {a: 'b', x: 'y'} it not easy xstream, because xstream first marshals properties object intermediary xml before converting xml json , getting xml right hard. it far easier loop on properties , build json string directly. example, this: stringbuilder builder = new stringbuilder() ; builder.append('{'); enumeration keys = props.keys(); while (keys.hasmoreelements()) { string key = (string)keys.nextelement(); string value = (string)props.get(key); builder.append('"').append(key).append('"'); builder.append(':'); builder.append('"').append(value).append('"').append(','); } builder.

datepicker - SimpleModal w/ Date Picker in a "Wizard" Scenario -

i'm using simplemodal (great library eric martin) create "wizard" users enter data. i'm making wizard work replacing contents of modal's div... ie: when modal displayed move contents of page1 modaldiv. when user clicks next, move contents of modaldiv page1 , move contents of page2 modaldiv. this works great, problem have having i'm using datepicker on page2. reading simplemodal documentation initializing datepicker in "onshow" callback... works great if datepicker on page1, not work if datepicker on page 2. how re-initialize datepicker when load page 2? well crap.. right when finished typing had idea solution, , worked (and it's better). i put page1 div , page2 div in modal div , hide/show page1 div , page2 div instead of moving contents around... kiss principle... gotta love it...

c# - Can you set a setting's default value to the program's current working directory? -

i'm using vs 2010 , playing around ability create, load, , save settings. read http://www.codeproject.com/kb/cs/usersettings.aspx default value field must given. possible set default value of string-type setting applications running directory? if not possible, hack @ give default value of "." , check @ run-time, changing program's current directory if needed, i'm open suggestions less hacky. go "hack" , detect when need use assigned value or else. settings dumb containers , know nothing app itself.

walkthrough - iPhone App Tutorial/Help Screen UI -

Image
what best way create tutorial or screens can viewed in iphone app on launch? i'm debating between using 2 paradigms: edit screenshot of app image editing program add static text. interaction tapping or scrolling through tips. involves creating custom uiviewcontroller advance next screen. create custom iphone uicontrol on top of app user interface can tapped advance next tutorial tip. application transition between modes , active, rather static. involves adding hooks app's custom viewcontroller's handle "tutorialuicontrol" objects. here's screenshots of application need make screen ui for, it's application creates artwork. more app information screenshot 1: view mode allows viewers scroll through image list, uiimagepicker, custom image collections. screenshot 2: action mode - allows viewers select images save "my saved" album active art generation album "my evolution" or evolve images using sexual/asexual image reprodu

jquery - Named parameters passing incorrectly through ajax call (Js helper) in CakePHP -

i trying make ajax call passing named parameters: $this->js->link('save',array( 'controller' => 'screens', 'action' => 'create') + $this->params['named'], array( 'update' => '#results')); however named parameters passed in above call incorrect (though correct when passed without ajax): example results: without ajax: http://paste.ubuntu.com/546338/ with ajax: http://paste.ubuntu.com/546337/ escaping ajax url might help, how can (or other way) ? p.s. : problem persists js helper, if use ajax helper data passes correctly. however, ajax helper depreciated , not recommended. what leo means this: $this->js->link('save', array('url'=>array('controller'=>'blah', 'action'=>'foo', $this->params['named']), 'update'=>'div&#

regex - How to replace all the blanks within square brackets with an underscore using sed? -

i figured out in order turn [some name] [some_name] need use following expression: s/\(\[[^ ]*\) /\1_/ i.e. create backreference capture starts literal '[' contains number of non space characters, followed space, replaced non space characters followed underscore. don't know yet though how alter expression works underscores within braces e.g. [a few words] [a_few_words]. i sense i'm close, missing chunk of knowledge unlock key making thing work infinite number of times within constraints of first set of []s contained in line (of sql server ddl in case). any suggestions gratefully received.... there 2 parts trickery needed: stop replacing when reach close square bracket (but repeatedly on line): s/\(\[[^] ]*\) /\1_/g this matches open square bracket, followed 0 or more characters neither blank nor close square bracket. global suffix means pattern applied sequences starting open square bracket followed blank or close square bracket on line. no

taocp - Printing a number contained in a register -

i'm learning mmix tried making simple program add 1 , print result. unfortunately doesn't print anything. here program: n $4 y $3 t $255 loc #100 main set n,1 %let n = 1 add y,n,1 %add 1 n , store result in y lda t,y trap 0,fputs,stdout trap 0,halt,0 what doing wrong? i ended figuring out after seeing code here . had first create byte, store value of register byte. printing out byte, result of add y,n,1.

asp.net mvc - C# DateTime.ParseExact throwing format exception -

i'm developing .net4 webapplication using mvc3. let's i'm getting following datetime string xml-feed. xml feed being read application , i'm looping through it's descendants. datetime i'm receiving begin returned in following format (as string); var mydatetime = "sun dec 19 11:45:45 +0000 2010" i'm using piece of code below try , parse datetime string mentioned above valid datetime format (preferably dutch) var correctdatetime = datetime.parseexact(mydatetime , "dd mmm yyyy hh:mm:ss", cultureinfo.invariantculture); when trying execute code i'm facing formatexception. has got ideas? --update-- this i've got after various answers. still throwing same exception though. var correcteddatetime = datetime.parseexact(latesttweettime, "ddd mmm hh:mm:ss k yyyy", cultureinfo.invariantculture); string display = correcteddatetime.tostring("dd mmm yyyy hh:mm:ss"); if you're trying read this: &

JavaScript enum sample - how does this work? -

this bit of code this answer . i'm trying understand how works i'm not getting all. what think happening test_error closure errorvalue can't changed. 1 reference value this: test_error.success. please correct me if either of statements incorrect. what don't understand return statement doing. it's returning object made of different errorvalues, returning what? , returning from? , when being called? var test_error = (function() { function errorvalue(value, friendly) { this.value = value; this.friendly = friendly; } errorvalue.prototype = { tostring: function() { return this.friendly; }, valueof: function() { return this.value; } }; return { 'success': new errorvalue(0, 'success'), 'fail': new errorvalue(1, 'fail'), 'id_error': new errorvalue(2, 'id error') }; })(); thanks! paul test_error closure errorvalue can't changed. test_error end bein

performance - How can I load a .net native image (NGEN) into multiple appdomains without specifying domain neutrality? -

ngen + appdomain problem here. i'm working on application changes revolve around making native images load correctly prevent awful jit time in our .net application. parts easy, assemblies have load in appdomains (which our app has use variety of reasons) load native image first time, , on subsequent loads (in new appdomain) image rejected , jit occurs. i know domain-neutral loading, , have made use of of our assemblies makes sense, doing domain-neutral loading cancels out 1 of major reasons using appdomains in first place -- domain neutral images can never unloaded. put succinctly, need way have native images loading , assembly unloading. had hoped normal restriction wouldn't apply long unloaded first usage of native image before tried load again, resulted in rejection if trying load native image concurrently. this msdn article contains following quote: an alternative approach falling jit compilation load different copies of native image every appdomai