Posts

Showing posts from July, 2012

Rails session gets destroy whenever model destroy link is clicked -

if click destroy on record 3 models models, user gets logged out. i'm using devise , ominauth. #this logs out user def destroy @rating = rating.find(params[:id]) @rating.destroy end started post "/ratings/29" 192.168.1.103 @ 2011-02-26 20:11:45 +0000 processing ratingscontroller#destroy html parameters: {"id"=>"29"} user load (0.5ms) select `users`.* `users` `users`.`id` = 2 limit 1 rating load (0.3ms) select `ratings`.* `ratings` `ratings`.`id` = 29 limit 1 sql (0.0ms) begin arel (0.5ms) delete `ratings` `ratings`.`id` = 29 sql (2.7ms) commit request parameters: none show session dump session_id: "16a92c418fdfa8966b60b09e76346443" show env dump gateway_interface: "cgi/1.1" http_accept: "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" http_accept_charset: "iso-8859-1,utf-8;q=0.7,*;q=0.3" http_accept_encoding: "gzip,...

java - Removing the first 3 characters from a string -

what efficient way remove first 3 characters of string? for example: 'apple' change 'le' 'a cat' change 'at' ' b c'change 'b c' just use substring: "apple".substring(3); return le

android - How to use lots of bitmaps in a game without exceeding VM memory budget? -

in game have 12 different animations , each animation consist of 10 bitmaps , each bitmap 200x150 pixel. every time user touches screen(virtual gamepad) 1 of animations play. easy job performance wise having trouble. loading bitmaps on array beginning of game cause crash game because of vm memory budget problem. seems other option recreate bitmaps everytime need , recyle them, might cause lag because of creating time , garbage collection. can't think of third option asking you. there memory efficient , not laggy option ? that's 14mb of memory animations might lot vm heap should fit nicely graphics card memory. assuming using opengl (if not have to). in case can build frames one-by-one, bind them texture , release them vm's memtory. fast wouldn't or offer sort of loading feature if lag greater 1/2 second or so.

File open causes timeout when php script is called by ajax with jquery -

i'm writing code imageboard , users going able post textfiles load pages in css layer. have simple php script takes filename , parameters(for start of line , lines per page) through get, opens file passed, , displays section of file html: http://pastebay.com/115710 i can confirm script works calling in browser , setting string in url. i'm calling script ajax using jquery, binding function links textfiles in page that, when links clicked on, layer opens , (what want happen is) html returned php file dumped layer: http://pastebay.com/115711 when use same ajax call using textfile call successful , can load contents of textfile layer. when call php file ajax, following response when php file never opens textfile passed: blockquote warning: file(http://localhost/kusabax/lit/src/nrd.txt) [function.file]: failed open stream: connection attempt failed because connected party did not respond after period of time, or established connection failed because connected ...

android - change the background image in gallery -

i shows buttons in gallery view scrolling purpose. if clicked 1 button(ex:button1) change button1 background , clicked button(ex:button2) change background of button2 , previous background of button1. please tell me how change background in gallery. best regards. thank in advance. how handle positions in gallery android? link working

python - Google Buzz API -

guys!! want try buzz api in python need accomplish i'm starter web , python programming. please me out here. want statuses , post messages in google buzz!! the official buzz api documentation @ http://code.google.com/apis/buzz/ - include language-specific libraries , examples: http://code.google.com/apis/buzz/docs/libraries.html

flex - Blazeds - Spring - Messaging - Selective server data push -

i have flex ui communicates server using spring blazeds. have typical requirement of live data streaming on panel in ui. requirement this, have object say, person , server keeps pushing data on blazeds message destination ui panel consumer has subscribed , hence user can see live data in panel. user can open multiple panels in same browser view data different persons @ same time (e.g id=1,2,3 respectively) there can multiple ui users may viewing same data person id=1 @ given time, lets say. basically want separate data between ui panels. ui panel opened person id=1 must not display data of person id=2. doing using headers-selectors, apparently found out differentiation select , display data happens on ui causing performance issues. learned using subtopics may improve performance. but, before proceeding it, want know, ui browser end in receiving data irrespective of subtopic assigned data , consumer decide accept or not? if so, problem remain same. there way achieve obje...

c# - Any idea how to enforce utf8 within a document -

i creating xml document , atttempting store @ utf8. however, receiving non utf8 apostrophe within stored document. eg : <name=dave t="owner(e.g pete’s)"> i have tried follwoing `system.text.utf8encoding encoding = new system.text.utf8encoding(); var docx = encoding.getbytes(vdd.tostring()); system.io.streamwriter s = new streamwriter(pathandfilename, false, encoding); string mystring = encoding.getstring(docx); s.write(mystring); ` which should have been overkill, '’' inside of brackets still showing. have tried htmlencode, didn't help. the xml reads fine utf8 in notepad++, ’ character not parsing on of clients systems. help please..... edit: dour noted missed in confusion; sample pasted not xml @ all, , therefore not parse. answer still applies insofar 'html encoding' , utf8 encoding wrong roads going down here. it's difficult tell problem is, i've tried eliminate of possibilities , come possibility: ’ ...

How widely accepted is OAuth? -

how supported oauth vs. other authentication standards? this may community wiki, i'm gonna ask anyway. i need invest in related server authentication , there seem few ones out there. oauth used authorization mechanism whereas openid widespread authentication protocol. let me explain example: authentication :openid used substitute managing user accounts...people hate creating new accounts , remembering passwords it...so u can use openid such situations... authorization :if want give access third party application lets website twitterwithsoccerui.com....which tweets you...except has soccerposter ui....in case u need authorize twitterwithsoccerui.com tweet on behalf... here's list... google -> oauth(for authorization) + openid(for authentication) facebook -> oauth 2.0 twitter -> oauth 1.0a yahoo -> openid stackexchange -> openid feel free add more..

vb.net - Combobox combinatorics -

i have form 3 combo boxes. value of combo boxes generates sql query 3 parameters. sql generates rdlc report. for example: combox1 values(v1,v2,v3,all) combox2 values(v1,v2,all) combox3 values(v1,v2,v3,4,all) me.exampletableadapter.querywithparams(me.exampledataset.table, combobox1.selectedindex, combobox2.selectedindex,combobox1.selectedindex) querywithparams: select * table column1=@c1 , column2=@c2 , column3=@c3 ok, problem when selected value in combo x, cannot values because must change query , kick out parameter. example: if combo1, combo2, combo3 have values all. don't need parameters. select * table if combo1 all. select * table column2=@c2 , column3=@c3 if combo1 , combo3 all select* table column2=@c2 ... in code selected value of combo , upon query. is there way thing without generating all 8 types of queries? ps. cannot use stored procedures because i'm using sql server compact if value 'all' should sent query va...

oracle11g - Update Oracle SQL Query throwing missing right parenthesis error -

update mytable set node_index=0 id in ( select id mytable rownum<=10 , procs_dt null order cret_dt,prty desc) this error getting error report: sql error: ora-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *cause: *action: whats wrong? experts please help.. new oracle 11g update mytable set node_index = 0 rowid in ( select rid ( select rowid rid mytable procs_dt not null order cret_dt, prty ) rownum <= 10 )

android - Where can I download DroidEx.jar? -

hi, i'm not able find droidex.jar anywhere. can me download jar file? if not, there alternative project device screen on monitor or projector? droidex replaced long time ago droid@screen .

sql - Using sum(), count(), and "group by" in Berkeley DB -

how use sum() , count() , , group by in berkeley db? there alternative way? which api using? if you're using key/value api, need implement functions yourself, scanning database using cursor. if using sql api , can "select sum(), count() ... group ..." sql statement. you may want post questions berkeley db forum .

C# - Move TextBox to ListBox and be able to use Add/Remove Buttons -

i have 3 textboxes have values in them. values split depending on strings contain using different regex. these textboxes in background , user not see them.. however, do want user see listboxes correspond each textbox. that code below is: private void listformathelper() { // splits lines in rich text boxes var listonelines = placementonerichtextbox.text.split('\n'); var listtwolines = placementtworichtextbox.text.split('\n'); var listuserlines = userdefinedrichtextbox.text.split('\n'); // resest text in listboxes placementonelistbox.resettext(); placementtwolistbox.resettext(); userdefinedlistbox.resettext(); // set selection mode multiple , extended. placementonelistbox.selectionmode = selectionmode.multiextended; placementtwolistbox.selectionmode = selectionmode.multiextended; userdefinedlistbox.selectionmode = selectionmode.multiextended; ...

How do I get the decimal value of a unicode character in Java? -

i need programmatic way decimal value of each character in string, can encode them html entities, example: utf-8: 著者名 decimal: &#33879;&#32773;&#21517; i suspect you're interested in conversion char int , implicit: for (int = 0; < text.length(); i++) { char c = text.charat(i); int value = c; system.out.println(value); } edit: if want handle surrogate pairs, can use like: for (int = 0; < text.length(); i++) { int codepoint = text.codepointat(i); // skip on second char in surrogate pair if (codepoint > 0xffff) { i++; } system.out.println(codepoint); }

jquery - slideDown Doesn't work for me -

why doesn't jquery code work? $(document).ready(function () { $('currentpage').click(function() { $('myaccount').slidedown('slow', function() { // animation complete. }); }); }); <li><a class="currentpage">home</a></li> <li><a class="myaccount">my account</a></li> anyone got ideas? don't. we use dots select classes : $('.class_name') $('.currentpage').click(function() { $('.myaccount').slidedown('slow', function() { // animation complete. }); }); in version, it's looking <currentpage> tag. edit an example . might seem 'not working' because myaccount link visible, sliding down won't change thing. thus, i've hidden in example above.

Python Ask For Decimal Number -

can please tell me how code ask value (say user enter 100.00) , put number it's 2 decimal points value more functions later on, ie: multipling it, etc. thanks. here's start (for python 3; python 2, use raw_input instead of input ): while true: snum = input("please enter decimal number:") try: num = float(snum) break except valueerror: print("this not valid decimal number!") print("this number, rounded 2 places, is: {:0.2f}".format(num))

javascript - Obtaining a reference to the streamManager of the internal object model on twitter.com -

for greasemonkey script running on twitter.com, need access twttr.streams.tweetstream instance of main timeline (dubbed 'home' internally) programmatically. i'm using firebug , javascript deminifier bring js code readable form. way, work out access via twttr.app.currentpage().streammanager.streams.current in gm script. this has worked on last months. today, twitter seems have changed code, breaking approach (not fault, ;)). i can still current page via twttr.app.currentpage() . however, doesn't have streammanager field anymore. i've tried various paths there, dead ends. unfortunately, don't understand class system using yet. seems streammanager property still there -- on mixin called mixins/streamablepage , should provided class twttr.components.pages.home . can't figure out how access it, though. (or if class system hides in impenetrable way.) mixin provides getstreammanager() method, can't access either, e.g. via twttr.app.currentpage()...

javascript - Output variable value for attribution in OpenLayers -

i display string (let's 'blabla') on openlayers map such string's position stays constant relative viewfram - i.e. not move when user zooms (similar control.panzoom() controls). control.attribution() this. works 'static' data such as 'attribution': "blabla" however, display strings value changes (let's variable named var, initial value var='blabla', value changed 'blu' , 'pla' depending on user interaction). i tried using 'attribution': "${var}" but outputs ${var} instead of 'blabla'. would know either 1) how output variables attribution option or 2) how place variables on map such stays in same position relative viewframe? thank you try use directly variable this: var myvar = 'blabla'; // code , then... 'attribution': myvar

asp.net - Imagemaps and Statelessness - is it possible? -

i created clickable tag cloud generator. tool generates nice image actual tag cloud, , make clickable , hover-able (interactive), tool (essentially method in class) returns html. since image , html both generated in same action method, in mvc project, wondering whether return viewresult (with html) or fileresult (with image). not want use session, , have <sessionstate mode="off"> in app. right now, have partial solution, save image filesystem , send html viewresult <img> tag in pointing saved image. not work concurrent users (each user may overwrite file, , interfere each other) essentially best way send image , html browser, without using server-side session? , without using elaborate filesystem based store images? i'm aware of <img src="data: .. " /> , since not work ie7 , less, , since image quite big, not option. thanks in advance! your image must identifiable in unique way. perhaps time stamp of when tag cloud chang...

oracle - pl/sql function called how many times? -

assume have following update: update table set col1 = func(col2) col1<>func(col2) the func function evaluated 2 times every row, or once every row? thanks, this kind of situation experimentation useful (this conducted on 10g). using following query, can tell normal functions, using same parameters (in case, none) executed each time called: select dbms_random.value() all_tables this because oracle assumes function not return same value consistently unless tell otherwise. can creating function using deterministic keyword: create function rand_det return number deterministic begin return dbms_random.value (); end; using function instead of dbms_random in first query tells query being executed once, despite many calls. clarifies select section. if use same deterministic function in both select , where clause. can test using following query: select rand_det all_tables rand_det > .5; you may have run several times see our proof, bu...

django - How to read variables added to RequestContext inside class-based generic views? -

with regular views, requestcontext variables can accessed request.varname : def example(request, template_name='stuff_list'): return render_to_response(template_name, {'stuff_list': get_list_or_404(stuff, foo=request.debug)}, context_instance=requestcontext(request)) ... instead of setting context_instance call function-based generic view direct_to_template 1 how read variables added requestcontext inside class-based generic views 2 ? for example: class articlelistview(listview): template_name = 'stuff_list' bar = request.debug # won't work. should use instead? queryset = get_list_or_404(stuff, foo=bar) 1 replaced class-based templateview anyway. 2 new in django 1.3 , want use them because. you need use callback — get_queryset() in case — instead of class attributes. class attributes shortcuts when you're controlling options statically, , they're limited pretty simple things. when need more c...

c# - File locked after sending it as attachment -

i sending file attachment: // create file attachment e-mail message. attachment data = new attachment(filepath, mediatypenames.application.octet); // add time stamp information file. contentdisposition disposition = data.contentdisposition; disposition.creationdate = system.io.file.getcreationtime(filepath); disposition.modificationdate = system.io.file.getlastwritetime(filepath); disposition.readdate = system.io.file.getlastaccesstime(filepath); // add file attachment e-mail message. message.attachments.add(data); and want move file folder, when try this try { //file.open(oldfullpath, filemode.open, fileaccess.readwrite,fileshare.readwrite); file.move(oldfullpath, newfullpath); } catch (exception ex) { ...

c# - How to join 2 or more .WAV files together programmatically? -

i need ability join 2 or more .wav files in 1 .wav file. must programmatically, using c# (3rd-party products not option). know of system.media.soundplayer class, not looking play the .wav, create it. here's basic wav concatenation function built using naudio . ensure data chunks concatenated (unlike code example in this codeproject article linked in answer). protect against concatenating wav files not share same format. public static void concatenate(string outputfile, ienumerable<string> sourcefiles) { byte[] buffer = new byte[1024]; wavefilewriter wavefilewriter = null; try { foreach (string sourcefile in sourcefiles) { using (wavefilereader reader = new wavefilereader(sourcefile)) { if (wavefilewriter == null) { // first time in create new writer wavefilewriter = new wavefilewriter(outputfile, reader.waveformat); ...

javascript - How can I handle multiple AJAX results in a userscript? -

i'm developing greasemonkey script translate <textarea> fields in intranet app, using google translation api. but texts way large translated 1 request. error when trying : request entity large anyway, found way cut texts in fragments, , send them in separate requests. gets tricky, how should replace fragments in original textareas, , @ right place. after trying several methods without success, inserted placeholders in textarea, corresponding fragments of text have translated : {1} {2} ... but in success callback of xhr, have replace placeholder translated text. thing is, xhr inside for loop, iterating on table containing fragments of original text, , when requests finish, loop long finished , don't know how put translation. here's code : //array text[] contains fragments of original text var translated_text = []; var l = text.length; for(var = 0; < l; i++) { var fullurl = apiurl+encodeuricomponent(text[i]); gm_xmlhttprequest({ method: ...

design patterns - Solid approach to loading reference data into view models in ASP.NET MVC -

i want way separate loading of reference data view model controller. @ moment have view model property selected value , reference data: public ienumerable<selectlistitem> daytypes { get; set; } public int daytypeid { get; set; } and data populated relevant repository in controller action: model.daytypes = _daytyperepository.getall().toselectlist(d => d.description, d => d.identifier.tostring()); i change because pollutes controller lots of repositories , code not core concerns. of these dependencies make unit testing controller pain. one possible approach solving make view model class loading require custom model binder instantiate them using ioc container provide repository dependency. option? another approach think hinted @ in codecampserver incomplete , commented out involving attributes on field in view model: [selectlistprovided(typeof(alldaysselectlistprovider))] public ienumerable<selectlistitem> daytypes { get; set; } however struggling fi...

Smtp error in sending mails in rails -

trying send mail on registration. in console getting mail sent. not getting mail.. my development.rb file has: config.cache_classes = false config.log_level = :debug # log error messages when accidentally call methods on nil. config.whiny_nils = true # show full error reports , disable caching config.action_controller.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = false # don't care if mailer can't send config.action_mailer.raise_delivery_errors = true config.action_mailer.default_url_options = {:host => "localhost:3000"} config.action_mailer.delivery_method = :smtp config.action_mailer.default_charset = 'utf-8' config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => 'gmail.com', :user_name => "mailme@gmail.c...

c++ - Recreate QApplication after previous instance has been exited -

is possible create , use new qapplication instance after previous 1 has been exited? yes, can create new qapplication after previous instance destroyed. verified in windows using pyqt4. program below displays empty windows. upon closing first window first qapplication destroyed , second qapplication created shows second blank window. note had problems without del app statement. equivalent using delete on qapplication in c++. make sure allocate qapplication instance on heap instead of stack. from pyqt4 import qtcore, qtgui import sys app = qtgui.qapplication(sys.argv) window = qtgui.qwidget() window.show() app.exec_() del app # force garbage collection of first qapplication app = qtgui.qapplication(sys.argv) window = qtgui.qwidget() window.show() app.exec_()

orientation - IllegalArgumentException while rotating device in Live Wallpaper picker Android 3.0 -

i'm developing live wallpaper honeycomb 3.0 , random error. when i'm in wallpaper picker (the window "set wallpaper" , "settings..." buttons, understand) , live wallpaper displayed, if rotate device, wallpaper should reload configuration adapted new orientation. does, crashes. the error in way related basesurfaceholder.unlockcanvasandpost method, don't know issue. think cannot load correctly resources.. here's error log: 07-21 16:07:38.490: warn/windowmanager(292): java.lang.illegalargumentexception: requested window android.os.binderproxy@40d19f28 not exist 07-21 16:07:38.490: warn/windowmanager(292): @ com.android.server.wm.windowmanagerservice.windowforclientlocked(windowmanagerservice.java:6731) 07-21 16:07:38.490: warn/windowmanager(292): @ com.android.server.wm.windowmanagerservice.windowforclientlocked(windowmanagerservice.java:6722) 07-21 16:07:38.490: warn/windowmanager(292): @ com.android.server.wm.windowmanagerser...

c++ - Listing specific subsets using STL -

say have range of number, {2,3,4,5}, stored in order in std::vector v , , want list possibles subsets end 5 using stl... : 2 3 4 5 2 3 5 2 4 5 3 4 5 2 5 3 5 4 5 5 ( hope don't forget any:) ) i tried using while(next_permutation(v.begin(),v.end())) didn't come wanted result :) does have idea? ps : have done archives of google code jam 2010 may recognize :) tomasz describes solution workable long n<=32 although take very long time print 2^32 different subsets. since bounds large dataset 2 <= n <= 500 generating subsets not way go. need come clever way avoid having generate them. in fact, whole point of problem. you can find solutions googling problem if want. hint need @ structure of sets , avoid generating them @ all. should calculate how many there are.

iphone - Question about FMDB and JOIN clause -

i'm using fmdb sqlite wrapper, pretty easy onto. encountered problem when try join 2 (in fact one) table. to distinguish joined 2 table's columns, have use select a.a 'a.a', b.a 'b.a' the_table join the_table b on... . can use [rs stringforcolumn:@"a.a"] , [rs stringforcolumn:@"b.a"] access them (where rs of class fmresultset). have 15 columns sql string seems long. i'm wondering if there's easier way this? using select * the_table join the_table b... , can access content of , b separately? may [rs resultsetforrenamedtable:@"a"] ; well, fmdb wrapper on top of sqlite, i suppose sqlite fire error if use * in particular case. like: sql error: ambiguous column name: a

c# - Setting Values on a derived class from the base class constructor using Reflection -

i have 2 classes this: public abstract class mybase { protected mybase(){ initialize(); } protected idictionary<string,string> _data; private void initialize() { // use reflection properties // of derived class (e.g., call new myderived() // want know names "hello" , "id" here var data = getdatafrombackend(propertynamesfromderived); _data = data; } } public class myconcrete : mybase { public myconcrete(){ // possibly use reflection here hello = _data["hello"]; id = new guid(data["id"]); } public string hello {get;set;} public guid id {get; set;} } as see, want constructor of base class know properties of derived class i'm instantiating. now, seems huge , big code smell, let me give more background intentions, maybe there better way. i have backend system stores key/value pairs, dictionary<strin...

python - a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it -

how check string every character in it, there exists characters alphabetically smaller before e.g aab correct while aacb not, because second case, have 'c' 'b' not present before it. aac not correct not have 'b' before 'c'. a pseudocode. works cases abac too. max = 'a' - 1 // character before 'a' char in string if char > max + 1 // bad string, stop algorithm end if char > max max = char end end the idea need check character preceding current 1 alphabetically has occurred before. if have character e , d has occurred before, c , b , a did too.

java - How to convert ResultSet into Object[] and retrieve the data -

i have list<object[]> records=null; i retrieving data , storing in resultset . now, how convert resultset object[] , return records(retrieved values). for whatever weird reasons need this. here how: list<object[]> records=new arraylist<object[]>(); while(resultset.next()){ int cols = resultset.getmetadata().getcolumncount(); object[] arr = new object[cols]; for(int i=0; i<cols; i++){ arr[i] = resultset.getobject(i+1); } records.add(arr); } my 2 cents: ideally, have proper object maps table columns java object fields. instead of using array of objects, set properties pojo or value object (vo) , return list of object. simpler , makes more sense. may want revisit design if have live on list of object array!

c# - How To Mock/Stub a Nhibernate QueryOver Call? -

how can stub call returns queryover object contains data? public interface idata { iqueryable<customer> customersasqueryable { get; } iqueryover<customer> customersasqueryover { get; } } [fact] public void queryover_spike() { var customers = new list<customer> { new customer {name = "this"}, new customer {name = "is"}, new customer {name = "fubar"} }; var data = mockrepository.generatemock<idata>(); //this works data.stub(x => x.customersasqueryable).return(customers.asqueryable()); //how can stub this? data.stub(x => x.customersasqueryover).return(?????????); } just phill said s...

javascript - Programmatically disable window.location.reload? -

is there way override default behavior of window.location.reload - making no-op, debugging purposes? the problem reason, location.reload not writable property in firefox , chrome. here's crazy way came override (and others) in browsers. uses non-standard .__definegetter__() method, in part bypass magic of window.location = "/home.html" interfering. var _location = location; __definegetter__('location', function() { var s = new string(_location); for(i in _location) (function(i) { s.__definegetter__(i, function() { return typeof _location[i] == 'function' ? function(){} : _location[i]; }); s.__definesetter__(i, function(){}); })(i); return s; }); __definesetter__('location', function(){}); the resulting mock object should prevent function call (including .reload ) or assignment (setting .href ) taking effect. alternatively, can limit testing ie, safari, , opera, in .reload writ...

What's the difference between "STL" and "C++ Standard Library"? -

someone brought this article attention claims (i'm paraphrasing) stl term misused refer entire c++ standard library instead of parts taken sgi stl. (...) refers "stl", despite fact few people still use stl (which designed @ sgi). parts of c++ standard library based on parts of stl, , these parts many people (including several authors , notoriously error-ridden cplusplus.com) still refer "the stl". however, inaccurate; indeed, c++ standard never mentions "stl", , there content differences between two. (...) "stl" used refer bits of stdlib happen based on sgi stl. people think it's entire standard library. gets put on cvs. , misleading. i hardly know c++'s history can't judge article's correctness. should refrain using term stl? or isolated opinion? the "stl" was written alexander stepanov in days long before c++ standardised. c++ existed through 80s, call " c++ " language ...

What are the best practices for combining analyzers in Lucene? -

i have situation i'm using standardanalyzer in lucene index text strings follows: public void indextext(string suffix, boolean includestopwords) { standardanalyzer analyzer = null; if (includestopwords) { analyzer = new standardanalyzer(version.lucene_30); } else { // stop_words exclude them. set<string> stopwords = (set<string>) stop_word_listener.getstopwords(); analyzer = new standardanalyzer(version.lucene_30, stopwords); } try { // index text. directory index = new ramdirectory(); indexwriter w = new indexwriter(index, analyzer, true, indexwriter.maxfieldlength.unlimited); this.addtexttoindex(w, this.gettexttoindex()); w.close(); // read index. indexreader ir = indexreader.open(index); text_termvectormapper ttvm = new text_termvectormapper(); int docid = 0; ir.gettermfreqvector(docid, proper...

How to execute an SQL string in DB2 -

how execute sql string statement in db2? i'm using ibm data studio. do mean executing dynamic sql string? like: declare stmt varchar(1000); declare my_table varchar(50); set my_table = 'dept_'||deptnumber; set stmt = 'select * '||my_table; prepare s1 stmt; execute s1; you can in stored proc though. 1 defined create procedure getdeptinfo (deptnumber varchar(5)) example. read execute , prepare in db2 docs http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp

c# - Global jQuery AJAX error handling with MVC 3 unobtrusive Javascript -

i have global error handler ajax calls looks this: $.ajaxsetup( { error: function(xmlhttprequest, textstatus, errorthrown) { alert("error"); } }); and i'm making ajax call this: @ajax.actionlink("submit", "submitquery", new ajaxoptions { httpmethod = "post" }) on controller action have customauthorizeattribute returns: filtercontext.result = new httpstatuscoderesult(403, "adsfasd"); when user isn't logged in. for reason global jquery ajax error handler isn't catching 403 error. i managed figure out. i needed: filtercontext.result = new contentresult { contenttype = "text/plain", content = "access denied. invalid user name and/or password." }; filtercontext.httpcontext.response.status = "500 ".replace("\r", " ").replace("\n", " ");

java - Getting jert.jar, jnet.jar and jsse.jar? -

i'm trying setup jetty 7 ssl, part of instructions say: make sure jcert.jar, jnet.jar , jsse.jar on classpath where find jars from? i'm running on mac 10.6. don't seem part of java installation, , not sure download them otherwise, thanks jsse.jar should in /system/library/frameworks/javavm.framework/versions/currentjdk/classes/jsse.jar suspect others around there somewhere perhaps different names think jsse has been bundled jdk since 1.4

php sessions value get wiped after ajax request -

i have script set uid , email sessions when user logs in. in 2 variables: $_session["uid"] = $user_id;//1,2,3 etc.. $_session["email"] = 'my@email.com'; i have feature user can post data via ajax. when data sent server , request completed, email session's value gets wiped , causes user not able actions. i searched whole script , couldnt find any $_session["email"] = ''; after ajax request done or wherever else might be. any clues? edit: var_dump of _session: array(2) { ["email"]=> &string(0) "" ["uid"]=> &string(11) "91283921834" } solution: host showing 5.2.17 default php version had call addtype application/x-httpd-php53 .php in .htaccess file make see 5.3.5 live php version removed references , working fine. you somewhere assign variable reference session, can see & character in var_dump : array(2) { ["email"]=> &strin...

php - Duplicate function -

first, did resarch that. couldn't find solution that. here want do. have multiple files same function name, during test didn't specify function , kept simple. the mulitple files included, since function been declared, i'm getting fatal error cannot redeclare function ..., declared in ... i know how avoid fatal error since include multiple files same function don't fix it. my question, logical, or should rethink , someting diffrent. my friend told me handled objects , on. thanks suggestion. are functions identical? in case, may able "hack" around problem wrapping function declarations function_exists() clause, see how avoid fatal error cannot redeclare function in php : <?php if (!function_exists('utility')) { function utility() { // ... } } ?> alternatively, might worth time read on namespaces : in php world, namespaces designed solve 2 problems authors of libraries , applications encounter when creati...

android - Change size of FrameLayout when screen size has been found -

at moment have framelayout hold preview of picture taken. size of determined in layout xml file created it, @ moment set fill_parent. image taken @ 4:3 aspect ratio, isn't going right aspect ratio users screen. for example xperia x10 480 x 854, 4:3 image taken camera stretches fit framelayout. what want change size of framelayout outside of xml file 4:3 , size appropriate users screen size. ideas? i guess using imageview inside framelayout display actual picture? in case, use scaletype define how picture should stretched. you can set in xml, use android:scaletype=".." inside imageview tag.

xcode - Objective C - Get a class to return a value -

i ask questions, 1 frustrating me can not find answer anywhere! i need call function in gamechallenges.m , return value view controller. gamechallenges.m called different view controllers, thats why separate. please help! i have separate class file called gamechallenges. this has function/method in it: in .h @class statsviewcontroller; @interface gamechallenges : nsobject { statsviewcontroller* statscontroller; nsstring* challengetitle; } @property (nonatomic, retain) iboutlet statsviewcontroller* statscontroller; @property (assign) nsstring* challengetitle; -(nsstring*)checkchallenge:(int)challegeid; @end in .m #import "gamechallenges.h" #import "statsviewcontroller.h" @implementation gamechallenges @synthesize challengetitle,statscontroller; -(nsstring*)checkchallenge:(int)challegeid{ if(challegeid==1){ self.challengetitle = @"some text."; return challengetitle; }else if(challegeid==2){ self...

javascript - How to filter elements returned by QuerySelectorAll -

i'm working on javascript libarary, , use function match elements: $ = function (a) { var x; if (typeof !== "string" || typeof === "undefined"){ return a;} //pick quickest method each kind of selector if(a.match(/^#([\w\-]+$)/)) { return document.getelementbyid(a.split('#')[1]); } else if(a.match(/^([\w\-]+)$/)) { x = document.getelementsbytagname(a); } else { x = document.queryselectorall(a); } //return single object if applicable return (x.length === 1) ? x[0] : x; }; there occasions want filter result of function, pick out div span , or #id div or other simple selector. how can filter these results? can create document fragement, , use queryselectorall method on fragment, or have resort manual string manipulation? i care modern browsers, , ie8+. if want @ rest of library, it's here: https://github.com/timw4mail/kis-js edit: to clarify, want able $_...

download - Android Inputstream.read problem on Gingerbread (while downloading) -

i didn't find question here. yesterday got gingerbread 2.3.4 on nexus one. when opened application (basically loads xml feed listview) again, got stuck while downloading. it seems inputstream stream; -> stream.read(buffer); doesn't return -1 more, when it's finished. the code ist same here download progress here's code: public inputstream getinputstreamfromurl(string urlstring, downloadprogresscallback callback) throws ioexception, illegalargumentexception { inputstream in = null; conn = (httpurlconnection) new url(urlstring).openconnection(); filesize = conn.getcontentlength(); out = new bytearrayoutputstream((int) filesize); conn.connect(); stream = conn.getinputstream(); // loop step 1kb while (status == downloading) { byte buffer[]; if (filesize - downloaded > max_buffer_size) { buffer = new byte[max_buffer_size]; } else...

Javascript bug in i.e function returning NAN (works in other browsers) -

hello have created javascript function recaculates grand total of order when delivery method changed. code works fine in firefox, chrome , i.e 9 returns nan in i.e 8 , 7, understand means not number. i have tried using parseint, paresefloat , number can't understand why not work in i.e 6, 7 or 8 my code follows <script type="text/javascript"> function changeprice(a) { // grabs delivery price of selected option i.e 10.99 var price = parsefloat(a); // grab delivery price on screen i.e 4.99 old_price = document.getelementbyid('delivery-sidebar').innerhtml; // removing span tags around function not needed old_price = old_price.replace('<span class=price>',''); old_price = old_price.replace('</span>',''); //grab subtotal price (which not include delivery) on screen i.e 34.99 var subtotal = document.getelementbyid('overall').innerhtml; // removing span ta...

how upload object in oracle database by java -

i want upload multiple objects oracle database using java . my objects included { doc, docx , ppt , pptx , pdf } files. how can upload objects in oracle database , retrieve database. also interested know more "how can batch insert list of objects in oracle database java?" think question answered before. if have new or interesting resource please share me please ... insert db: int primarykeyid = getnextprimarykeyid(); preparedstatement stmt1 = conn.preparestatement(" insert doctable values (?, ?, empty_blob()) "); stmt1.setint(1, primarykeyid ); stmt1.setstring(2, getdocumenttitle()); stmt1.executeupdate(); preparedstatement stmt2 = conn.preparestatement(" select doc doctable id = ? update "); stmt2.setint(1, primarykeyid); stmt2.execute(); oracleresultset rset = (oracleresultset)stmt2.getresultset(); if (rset.next()) { blob document = rset.getblob("doc"); document.trim(0); outputstream os = document.getbinaryoutputs...

javascript - Ruby toplevel == JS global object? -

coming ruby js, think it'd easy learn if compare , contrast between two. when stumbled ruby toplevel can't think of similar global object (window object) in javascript. am correct in making assumption? it's not similar in meaningful way except both objects act this / self outside context of other object. in other respect, quite different. there no useful way refer main outside of top level there window . global variables true global variables, , constants or methods defined in context of main not defined on main , on object class.

c# - Add-Update-Delete GridView in asp.net -

i want populate gridview in asp.net web application. in fact able scenario want develop based on user authentication. means let admin logged in must authorized edit fields of row in gridview. if employee logged in then, should applicable edit name , address columns in gridview. can ? have take under consideration. in event can this? also how can convert / create gridview user control? let have column of edit command like... <asp:templatefield> <itemtemplate> <asp:imagebutton id="ibtnedit" commandargument='<%# eval("id") %>' commandname="edit" runat="server" /> </itemtemplate> </asp:templatefield> and have hide edit column, user not able edit records. need put condition like... if(user not in in admin role) { gridview1.column[editcolumnindex].visible = false; }